From: Jelmer Vernooij Date: Tue, 21 Oct 2008 12:51:13 +0000 (+0200) Subject: Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv X-Git-Url: http://git.samba.org/samba.git/?p=tprouty%2Fsamba.git;a=commitdiff_plain;h=5209a846a9157e649fcdcb561f7eaf19c8c0e465;hp=625359b2e266105022309df8985720108ecd6f67 Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv Conflicts: source4/lib/registry/ldb.c source4/rpc_server/winreg/rpc_winreg.c --- diff --git a/.gitignore b/.gitignore index b72ebe63a7..e617400cc5 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,8 @@ source3/smbd/build_options.c source3/st source3/tags source3/TAGS +source3/samba4-data.mk +source3/samba4-config.mk source3/torture.tdb source4/apidocs source4/auth/auth_proto.h @@ -179,7 +181,7 @@ source4/libcli/composite/proto.h source4/libcli/finddcs.h source4/libcli/ldap/ldap_proto.h source4/libcli/libcli_proto.h -source4/libcli/nbt/nbtname.h +libcli/nbt/nbtname.h source4/libcli/nbt/nbt_proto.h source4/libcli/ndr_netlogon_proto.h source4/libcli/netlogon_proto.h @@ -194,7 +196,7 @@ source4/libcli/util/proto.h source4/libcli/wrepl/winsrepl_proto.h source4/lib/cmdline/credentials.h source4/lib/cmdline/popt_credentials.h -source4/lib/crypto/test_proto.h +lib/crypto/test_proto.h source4/lib/db_wrap_proto.h source4/lib/ldb/bin source4/lib/ldb/examples/ldbreader @@ -228,12 +230,11 @@ source4/lib/tdb/bin/tdbdump source4/lib/tdb/bin/tdbtool source4/lib/tdb/bin/tdbtorture source4/lib/tdr/tdr_proto.h -source4/lib/util/apidocs -source4/lib/util/asn1_proto.h -source4/lib/util/pidfile.h -source4/lib/util/unix_privs.h -source4/lib/util/util_proto.h -source4/lib/util/util_tdb.h +lib/util/apidocs +lib/util/asn1_proto.h +lib/util/pidfile.h +lib/util/unix_privs.h +lib/util/util_proto.h source4/mkconfig.mk source4/nbt_server/dgram/proto.h source4/nbt_server/nbt_server_proto.h @@ -250,10 +251,10 @@ source4/param/proto.h source4/param/secrets_proto.h source4/param/share_proto.h source4/passdb/proto.h -source4/pidl/blib -source4/pidl/cover_db -source4/pidl/Makefile -source4/pidl/pm_to_blib +pidl/blib +pidl/cover_db +pidl/Makefile +pidl/pm_to_blib source4/rpc_server/common/proto.h source4/rpc_server/dcerpc_server_proto.h source4/rpc_server/lsa/proto.h @@ -296,6 +297,17 @@ source4/winbind/idmap_proto.h source4/winbind/wb_helper.h source4/winbind/wb_proto.h source4/wrepl_server/wrepl_server_proto.h +source4/heimdal/lib/roken/roken.h +source4/lib/ldb-samba/ldif_handlers_proto.h +source4/libcli/drsblobs_proto.h +source4/ntvfs/posix/vfs_acl_proto.h *.swp tags *.x +packaging/RHEL-CTDB/samba.spec +packaging/RHEL/samba.spec +packaging/RHEL/makerpms.sh +source3/librpc/gen_ndr/cli_drsblobs.c +source3/librpc/gen_ndr/cli_drsblobs.h +source3/librpc/gen_ndr/srv_drsblobs.c +source3/librpc/gen_ndr/srv_drsblobs.h diff --git a/MAINTAINERS b/MAINTAINERS index 2b09221efc..f6824a1181 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26,8 +26,8 @@ libmsrpc Chris Nichols libsmbclient Derrell Lipman -pdb_*sql Wilco Baan Hofman - Florian Effenberger +pdb_*sql Collen Blijenberg + Herwin Weststrate http://pdbsql.sourceforge.net/ diff --git a/README.Coding b/README.Coding index 52ecf0e102..c1b6641a5a 100644 --- a/README.Coding +++ b/README.Coding @@ -1,6 +1,7 @@ -## -## Coding conventions in the Samba 3 tree -## +Coding conventions in the Samba tree +------------------------------------ + +.. contents:: =========== Quick Start @@ -14,15 +15,13 @@ style should never outweigh coding itself and so the the guidelines described here are hopefully easy enough to follow as they are very common and supported by tools and editors. -The basic style, also mentioned in the SAMBA_4_0/prog_guide.txt is the -Linux kernel coding style (See Documentation/CodingStyle in the kernel -source tree). The closely matches what most Samba developers use already -anyways. +The basic style, also mentioned in prog_guide4.txt, is the Linux kernel coding +style (See Documentation/CodingStyle in the kernel source tree). This closely +matches what most Samba developers use already anyways. But to save you the trouble of reading the Linux kernel style guide, here are the highlights. - * Maximum Line Width is 80 Characters The reason is not for people with low-res screens but rather sticking to 80 columns prevents you from easily nesting more than one level of @@ -59,14 +58,14 @@ Vi -- (Thanks to SATOH Fumiyasu for these hints): -For the basic vi editor including with all variants of *nix, add the +For the basic vi editor including with all variants of \*nix, add the following to $HOME/.exrc: set tabstop=8 set shiftwidth=8 For Vim, the following settings in $HOME/.vimrc will also deal with -displaying trailing whitespace: +displaying trailing whitespace:: if has("syntax") && (&t_Co > 2 || has("gui_running")) syntax on @@ -91,7 +90,7 @@ FAQ & Statement Reference Comments -------- -Comments should always use the standard C syntax. I.e. /* ... */. C++ +Comments should always use the standard C syntax. C++ style comments are not currently allowed. @@ -145,7 +144,7 @@ The exception to the ending rule is when the closing brace is followed by another language keyword such as else or the closing while in a do..while loop. -Good examples: +Good examples:: if (x == 1) { printf("good\n"); @@ -162,7 +161,7 @@ Good examples: printf("also good\n"); } while (1); -Bad examples: +Bad examples:: while (1) { @@ -173,33 +172,33 @@ Goto ---- While many people have been academically taught that goto's are fundamentally -evil, then can greatly enhance readability and reduce memory leaks when used +evil, they can greatly enhance readability and reduce memory leaks when used as the single exit point from a function. But in no Samba world what so ever is a goto outside of a function or block of code a good idea. -Good Examples: - -int function foo(int y) -{ - int *z = NULL; - int ret = 0; +Good Examples:: - if ( y < 10 ) { - z = malloc(sizeof(int)*y); - if (!z) { - ret = 1; - goto done; + int function foo(int y) + { + int *z = NULL; + int ret = 0; + + if ( y < 10 ) { + z = malloc(sizeof(int)*y); + if (!z) { + ret = 1; + goto done; + } } - } - print("Allocated %d elements.\n", y); + print("Allocated %d elements.\n", y); - done: - if (z) - free(z); + done: + if (z) + free(z); - return ret; -} + return ret; + } Checking Pointer Values @@ -207,13 +206,13 @@ Checking Pointer Values When invoking functions that return pointer values, either of the following are acceptable. Use you best judgement and choose the more readable option. -Remember that many other people will review it. +Remember that many other people will review it.:: if ((x = malloc(sizeof(short)*10)) == NULL ) { fprintf(stderr, "Unable to alloc memory!\n"); } -or +or:: x = malloc(sizeof(short)*10); if (!x) { diff --git a/docs-xml/manpages-3/cifs.upcall.8.xml b/docs-xml/manpages-3/cifs.upcall.8.xml index 3c1bb247fa..5faf0f7102 100644 --- a/docs-xml/manpages-3/cifs.upcall.8.xml +++ b/docs-xml/manpages-3/cifs.upcall.8.xml @@ -62,7 +62,11 @@ to be run that way. CONFIGURATION FOR KEYCTL - cifs.upcall is designed to be called from the kernel via the request-key callout program. This requres that request-key be told where and how to call this program. The current cifs.upcall program handles two different key types: + cifs.upcall is designed to be called from the kernel via the + request-key callout program. This requires that request-key be told + where and how to call this program. The current cifs.upcall program + handles two different key types: + diff --git a/docs-xml/manpages-3/idmap_adex.8.xml b/docs-xml/manpages-3/idmap_adex.8.xml new file mode 100644 index 0000000000..9eb2ff7d46 --- /dev/null +++ b/docs-xml/manpages-3/idmap_adex.8.xml @@ -0,0 +1,89 @@ + + + + + + idmap_adex + 8 + Samba + System Administration tools + 3.2 + + + + + idmap_adex + Samba's idmap_adex Backend for Winbind + + + + DESCRIPTION + + The idmap_adex plugin provides a way for Winbind to read + id mappings from an AD server that uses RFC2307 schema + extensions. This module implements both the idmap and nss_info + APIs and supports domain trustes as well as two-way cross + forest trusts. It is a read-only plugin requiring that the + administrator provide mappings in advance by adding the + POSIX attribute information to the users and groups objects + in AD. The most common means of doing this is using "Identity + Services for Unix" support on Windows 2003 R2 and later. + + + + Note that you must add the uidNumber, gidNumber, and uid + attributes to the partial attribute set of the forest global + catalog servers. This can be done using the Active Directory Schema + Management MMC plugin (schmmgmt.dll). + + + + + NSS_INFO + + The nss_info plugin supports reading the unixHomeDirectory, + gidNumber, loginShell, and uidNumber attributes from the user + object and the gidNumber attribute from the group object to + fill in information required by the libc getpwnam() and + getgrnam() family of functions. Group membership is filled in + according to the Windows group membership and not the + msSFU30PosixMember attribute. + + + + Username aliases are implement by setting the uid attribute + on the user object. While group name aliases are implemented + by reading the displayname attribute from the group object. + + + + + EXAMPLES + + The following example shows how to retrieve idmappings and NSS data + from our principal and trusted AD domains. + + + + [global] + idmap backend = adex + idmap uid = 1000-4000000000 + idmap gid = 1000-4000000000 + + winbind nss info = adex + winbind normalize names = yes + + + + + AUTHOR + + + The original Samba software and related utilities + were created by Andrew Tridgell. Samba is now developed + by the Samba Team as an Open Source project similar + to the way the Linux kernel is developed. + + + + diff --git a/docs-xml/manpages-3/idmap_hash.8.xml b/docs-xml/manpages-3/idmap_hash.8.xml new file mode 100644 index 0000000000..8e452b3c89 --- /dev/null +++ b/docs-xml/manpages-3/idmap_hash.8.xml @@ -0,0 +1,76 @@ + + + + + + idmap_hash + 8 + Samba + System Administration tools + 3.2 + + + + + idmap_hash + Samba's idmap_hash Backend for Winbind + + + + DESCRIPTION + The idmap_hash plugin implements a hashing algorithm used + map SIDs for domain users and groups to a 31-bit uid and gid. + This plugin also implements the nss_info API and can be used + to support a local name mapping files if enabled via the + "winbind normlaize names" and "winbind nss info" + parameters in smb.conf. + + + + + IDMAP OPTIONS + + + + name_map + + Specifies the absolute path to the name mapping + file used by the nss_info API. Entries in the file + are of the form "unix name + = qualified domain name"e;. + Mapping of both user and group names is supported. + + + + + + + EXAMPLES + The following example utilizes the idmap_hash plugin for + the idmap and nss_info information. + + + + [global] + idmap backend = hash + idmap uid = 1000-4000000000 + idmap gid = 1000-4000000000 + + winbind nss info = hash + winbind normalize names = yes + idmap_hash:name_map = /etc/samba/name_map.cfg + + + + + AUTHOR + + + The original Samba software and related utilities + were created by Andrew Tridgell. Samba is now developed + by the Samba Team as an Open Source project similar + to the way the Linux kernel is developed. + + + + diff --git a/docs-xml/manpages-3/pam_winbind.7.xml b/docs-xml/manpages-3/pam_winbind.7.xml index cf7fd5a0f6..7f233c1386 100644 --- a/docs-xml/manpages-3/pam_winbind.7.xml +++ b/docs-xml/manpages-3/pam_winbind.7.xml @@ -134,6 +134,14 @@ + + mkhomedir + + Create homedirectory for a user on-the-fly, option is valid in + PAM session block. + + + diff --git a/docs-xml/manpages-3/vfs_smb_traffic_analyzer.8.xml b/docs-xml/manpages-3/vfs_smb_traffic_analyzer.8.xml new file mode 100644 index 0000000000..556fa3e86e --- /dev/null +++ b/docs-xml/manpages-3/vfs_smb_traffic_analyzer.8.xml @@ -0,0 +1,176 @@ + + + + + + smb_traffic_analyzer + 8 + Samba + System Administration tools + 3.3 + + + + + vfs_smb_traffic_analyzer + log Samba VFS read and write operations through a socket + to a helper application + + + + + vfs objects = smb_traffic_analyzer + + + + + DESCRIPTION + + This VFS module is part of the + samba + 7 suite. + + The vfs_smb_traffic_analyzer VFS module logs + client write and read operations on a Samba server and sends this data + over a socket to a helper program, which feeds a SQL database. More + information on the helper programs can be obtained from the + homepage of the project at: + http://holger123.wordpress.com/smb-traffic-analyzer/ + + vfs_smb_traffic_analyzer currently is aware + of the following VFS operations: + + + write + pwrite + read + pread + + + vfs_smb_traffic_analyzer sends the following data + in a fixed format seperated by a comma through either an internet or a + unix domain socket: + + BYTES|USER|DOMAIN|READ/WRITE|SHARE|FILENAME|TIMESTAMP + + + Description of the records: + + + BYTES - the length in bytes of the VFS operation + USER - the user who initiated the operation + DOMAIN - the domain of the user + READ/WRITE - either "W" for a write operation or "R" for read + SHARE - the name of the share on which the VFS operation occured + FILENAME - the name of the file that was used by the VFS operation + TIMESTAMP - a timestamp, formatted as "yyyy-mm-dd hh-mm-ss.ms" indicating when the VFS operation occured + + + + + This module is stackable. + + + + + + OPTIONS + + + + + smb_traffic_analyzer:mode = STRING + + If STRING matches to "unix_domain_socket", the module will + use a unix domain socket located at /var/tmp/stadsocket, if + STRING contains an different string or is not defined, the module will + use an internet domain socket for data transfer. + + + + + + + smb_traffic_analyzer:host = STRING + + The module will send the data to the system named with + the hostname STRING. + + + + + + smb_traffic_analyzer:port = STRING + + The module will send the data using the TCP port given + in STRING. + + + + + smb_traffic_analyzer:anonymize_prefix = STRING + + The module will replace the user names with a prefix + given by STRING and a simple hash number. + + + + + + + + + + + EXAMPLES + + The module running on share "example_share", using a unix domain socket + + + /data/example + smb_traffic_analyzer + unix_domain_socket + + + The module running on share "example_share", using an internet socket, + connecting to host "examplehost" on port 3491. + + + /data/example + smb_traffic_analyzer + examplehost + 3491 + + + The module running on share "example_share", using an internet socket, + connecting to host "examplehost" on port 3491, anonymizing user names with + the prefix "User". + + + /data/example + smb_traffic_analyzer + examplehost + 3491 + User + + + + + VERSION + This man page is correct for version 3.3 of the Samba suite. + + + + + AUTHOR + + The original Samba software and related utilities + were created by Andrew Tridgell. Samba is now developed + by the Samba Team as an Open Source project similar + to the way the Linux kernel is developed. + + The original version of the VFS module and the + helper tools were created by Holger Hetterich. + + + diff --git a/docs-xml/smbdotconf/printing/cupsconnectiontimeout.xml b/docs-xml/smbdotconf/printing/cupsconnectiontimeout.xml new file mode 100644 index 0000000000..1c7df15c3c --- /dev/null +++ b/docs-xml/smbdotconf/printing/cupsconnectiontimeout.xml @@ -0,0 +1,20 @@ + + + + This parameter is only applicable if is set to cups. + + + + If set, this option specifies the number of seconds that smbd will wait + whilst trying to contact to the CUPS server. The connection will fail + if it takes longer than this number of seconds. + + + +30 +60 + diff --git a/docs-xml/smbdotconf/winbind/winbindnormalizenames.xml b/docs-xml/smbdotconf/winbind/winbindnormalizenames.xml index 28826cf5f3..5b68bca912 100644 --- a/docs-xml/smbdotconf/winbind/winbindnormalizenames.xml +++ b/docs-xml/smbdotconf/winbind/winbindnormalizenames.xml @@ -5,14 +5,25 @@ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> This parameter controls whether winbindd will replace - whitespace in user and group names with an underscore (_) character. - For example, whether the name "Space Kadet" should be - replaced with the string "space_kadet". - Frequently Unix shell scripts will have difficulty with usernames - contains whitespace due to the default field separator in the shell. - Do not enable this option if the underscore character is used in - account names within your domain - + whitespace in user and group names with an underscore (_) character. + For example, whether the name "Space Kadet" should be + replaced with the string "space_kadet". + Frequently Unix shell scripts will have difficulty with usernames + contains whitespace due to the default field separator in the shell. + If your domain possesses names containing the underscore character, + this option may cause problems unless the name aliasing feature + is supported by your nss_info plugin. + + + This feature also enables the name aliasing API which can + be used to make domain user and group names to a non-qlaified + version. Please refer to the manpage for the configured + idmap and nss_info plugin for the specifics on how to configure + name aliasing for a specific configuration. Name aliasing takes + precendence (and is mutually exclusive) over the whitespace + replacement mechanism discussed previsouly. + + no diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 89d8ce5239..3df1fcd5bf 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -315,7 +315,7 @@ static size_t skel_get_nt_acl(vfs_handle_struct *handle, } static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - uint32 security_info_sent, SEC_DESC *psd) + uint32 security_info_sent, const SEC_DESC *psd) { errno = ENOSYS; return NT_STATUS_NOT_IMPLEMENTED; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index ea8530d855..e6dee97775 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -302,7 +302,7 @@ static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle, } static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - uint32 security_info_sent, SEC_DESC *psd) + uint32 security_info_sent, const SEC_DESC *psd) { return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd); } diff --git a/examples/libsmbclient/Makefile.internal.in b/examples/libsmbclient/Makefile.internal.in index dd4518f212..d9f0fd32c8 100644 --- a/examples/libsmbclient/Makefile.internal.in +++ b/examples/libsmbclient/Makefile.internal.in @@ -6,7 +6,7 @@ CC = @CC@ -SAMBA_DIR = ../../source +SAMBA_DIR = ../../source3 SAMBA_INCLUDES = -I$(SAMBA_DIR)/include SAMBA_LIBPATH = -L$(SAMBA_DIR)/bin @@ -16,7 +16,7 @@ GTK_LIBS = `gtk-config --libs` #GTK_CFLAGS = `pkg-config gtk+-2.0 --cflags` #GTK_LIBS = `pkg-config gtk+-2.0 --libs` -FLAGS = @CPPFLAGS@ @CFLAGS@ $(GTK_CFLAGS) $(SAMBA_INCLUDES) +CCFLAGS = @CPPFLAGS@ @CFLAGS@ $(GTK_CFLAGS) $(SAMBA_INCLUDES) PICFLAG=@PICFLAG@ LDFLAGS= $(SAMBA_LIBPATH) @PIE_LDFLAGS@ @LDFLAGS@ @@ -27,7 +27,7 @@ CMDLINE_LIBS = @POPTLIBS@ LIBS = $(EXTERNAL_LIBS) $(LIBSMBCLIENT_LIBS) # Compile a source file. (.c --> .o) -COMPILE_CC = $(CC) -I. $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC = $(CC) -I. $(CCFLAGS) $(PICFLAG) -c $< -o $@ COMPILE = $(COMPILE_CC) MAKEDIR = || exec false; \ @@ -68,67 +68,67 @@ all: $(TESTS) smbsh testsmbc: testsmbc.o @echo Linking testsmbc - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) tree: tree.o @echo Linking tree - @$(CC) $(GTK_CFLAGS) $(FLAGS) $(LDFLAGS) -o $@ $< $(GTK_LIBS) $(LIBS) + @$(CC) $(GTK_CFLAGS) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(GTK_LIBS) $(LIBS) testacl: testacl.o @echo Linking testacl - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testacl2: testacl2.o @echo Linking testacl2 - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testacl3: testacl3.o @echo Linking testacl3 - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testbrowse: testbrowse.o @echo Linking testbrowse - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testbrowse2: testbrowse2.o @echo Linking testbrowse2 - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) teststat: teststat.o @echo Linking teststat - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) teststat2: teststat2.o @echo Linking teststat2 - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) teststat3: teststat3.o @echo Linking teststat3 - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testtruncate: testtruncate.o @echo Linking testtruncate - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testchmod: testchmod.o @echo Linking testchmod - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testutime: testutime.o @echo Linking testutime - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testread: testread.o @echo Linking testread - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testwrite: testwrite.o @echo Linking testwrite - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) testctx: testctx.o @echo Linking testctx - @$(CC) $(FLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(CMDLINE_LIBS) smbsh: make -C smbwrapper diff --git a/examples/libsmbclient/smbwrapper/Makefile b/examples/libsmbclient/smbwrapper/Makefile index eb470056e1..952015e96e 100644 --- a/examples/libsmbclient/smbwrapper/Makefile +++ b/examples/libsmbclient/smbwrapper/Makefile @@ -3,9 +3,9 @@ DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE CFLAGS = -I$(SAMBA_INCL) $(EXTLIB_INCL) -LDFLAGS = -L/usr/local/samba/lib -L../../../source/bin +LDFLAGS = -L/usr/local/samba/lib -L../../../source3/bin -SMBINCLUDE = -I../../../source/include +SMBINCLUDE = -I../../../source3/include CFLAGS= -fpic -g -O0 $(DEFS) $(SMBINCLUDE) BIN = . diff --git a/examples/pam_winbind/pam_winbind.conf b/examples/pam_winbind/pam_winbind.conf index a9e02a833a..dd0b112f30 100644 --- a/examples/pam_winbind/pam_winbind.conf +++ b/examples/pam_winbind/pam_winbind.conf @@ -33,3 +33,6 @@ # omit pam conversations ;silent = no + +# create homedirectory on the fly +;mkhomedir = no diff --git a/lib/README b/lib/README new file mode 100644 index 0000000000..b994447f4b --- /dev/null +++ b/lib/README @@ -0,0 +1,10 @@ +compression - Various compression algorithms (MSZIP, lzxpress) +nss_wrapper - Wrapper for the user and group NSS API allowing the use + of other data sources. +popt - Command-line option parsing library +replace - Provides replacements for standard (POSIX, C99) functions + not provided by the host platform. +socket_wrapper - Wrapper library allowing TCP/IP traffic to be redirected + over Unix domain sockets. +talloc - Hierarchical pool based memory allocator +tdb - Simple but fast key/value database library, supporting multiple writers diff --git a/source4/lib/compression/lzxpress.c b/lib/compression/lzxpress.c similarity index 100% rename from source4/lib/compression/lzxpress.c rename to lib/compression/lzxpress.c diff --git a/source4/lib/compression/lzxpress.h b/lib/compression/lzxpress.h similarity index 100% rename from source4/lib/compression/lzxpress.h rename to lib/compression/lzxpress.h diff --git a/source3/lib/compression/mszip.c b/lib/compression/mszip.c similarity index 99% rename from source3/lib/compression/mszip.c rename to lib/compression/mszip.c index aeeb2d8afd..9aa1772414 100644 --- a/source3/lib/compression/mszip.c +++ b/lib/compression/mszip.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/compression/mszip.h" +#include "../compression/mszip.h" /*--------------------------------------------------------------------------*/ /* our archiver information / state */ diff --git a/source3/lib/compression/mszip.h b/lib/compression/mszip.h similarity index 100% rename from source3/lib/compression/mszip.h rename to lib/compression/mszip.h diff --git a/source4/lib/compression/testsuite.c b/lib/compression/testsuite.c similarity index 96% rename from source4/lib/compression/testsuite.c rename to lib/compression/testsuite.c index f6e4d49afb..b9cebb2e8d 100644 --- a/source4/lib/compression/testsuite.c +++ b/lib/compression/testsuite.c @@ -20,7 +20,7 @@ #include "includes.h" #include "torture/torture.h" -#include "lib/compression/mszip.h" +#include "../compression/mszip.h" struct torture_suite *torture_local_compression(TALLOC_CTX *mem_ctx) { diff --git a/source4/lib/crypto/arcfour.c b/lib/crypto/arcfour.c similarity index 98% rename from source4/lib/crypto/arcfour.c rename to lib/crypto/arcfour.c index 94196fa1ee..c57e05d0e9 100644 --- a/source4/lib/crypto/arcfour.c +++ b/lib/crypto/arcfour.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/arcfour.h" /* initialise the arcfour sbox with key */ _PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key) diff --git a/lib/crypto/arcfour.h b/lib/crypto/arcfour.h new file mode 100644 index 0000000000..501b3f2fab --- /dev/null +++ b/lib/crypto/arcfour.h @@ -0,0 +1,15 @@ +#ifndef ARCFOUR_HEADER_H +#define ARCFOUR_HEADER_H + +struct arcfour_state { + uint8_t sbox[256]; + uint8_t index_i; + uint8_t index_j; +}; + +void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key); +void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len); +void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key); +void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len); + +#endif /* ARCFOUR_HEADER_H */ diff --git a/source4/lib/crypto/config.mk b/lib/crypto/config.mk similarity index 100% rename from source4/lib/crypto/config.mk rename to lib/crypto/config.mk diff --git a/source4/lib/crypto/crc32.c b/lib/crypto/crc32.c similarity index 99% rename from source4/lib/crypto/crc32.c rename to lib/crypto/crc32.c index 5b9d9b108d..e6cc529767 100644 --- a/source4/lib/crypto/crc32.c +++ b/lib/crypto/crc32.c @@ -41,6 +41,7 @@ */ #include "includes.h" +#include "../lib/crypto/crc32.h" static const uint32_t crc32_tab[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, diff --git a/source4/lib/crypto/crc32.h b/lib/crypto/crc32.h similarity index 100% rename from source4/lib/crypto/crc32.h rename to lib/crypto/crc32.h diff --git a/source4/libcli/drsblobs.h b/lib/crypto/crypto.h similarity index 70% rename from source4/libcli/drsblobs.h rename to lib/crypto/crypto.h index 8fee4114be..0a43cbe7d4 100644 --- a/source4/libcli/drsblobs.h +++ b/lib/crypto/crypto.h @@ -1,9 +1,7 @@ /* Unix SMB/CIFS implementation. - Manually parsed structures found in the DRS protocol - - Copyright (C) Andrew Bartlett 2008 + Copyright (C) Andrew Tridgell 2004 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 @@ -19,10 +17,12 @@ along with this program. If not, see . */ -#ifndef __LIBCLI_DRSBLOBS_H__ -#define __LIBCLI_DRSBLOBS_H__ +#include "../lib/crypto/crc32.h" +#include "../lib/crypto/md4.h" +#include "../lib/crypto/md5.h" +#include "../lib/crypto/hmacmd5.h" +#include "../lib/crypto/sha256.h" +#include "../lib/crypto/hmacsha256.h" +#include "../lib/crypto/arcfour.h" -#include "librpc/gen_ndr/ndr_drsblobs.h" -#include "libcli/drsblobs_proto.h" -#endif /* __CLDAP_SERVER_PROTO_H__ */ diff --git a/source4/lib/crypto/hmacmd5.c b/lib/crypto/hmacmd5.c similarity index 99% rename from source4/lib/crypto/hmacmd5.c rename to lib/crypto/hmacmd5.c index 3a9ec38a27..0c8d1ab598 100644 --- a/source4/lib/crypto/hmacmd5.c +++ b/lib/crypto/hmacmd5.c @@ -23,7 +23,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/hmacmd5.h" /*********************************************************************** the rfc 2104 version of hmac_md5 initialisation. diff --git a/source4/lib/crypto/hmacmd5.h b/lib/crypto/hmacmd5.h similarity index 96% rename from source4/lib/crypto/hmacmd5.h rename to lib/crypto/hmacmd5.h index 5769737fcd..91b8ca586c 100644 --- a/source4/lib/crypto/hmacmd5.h +++ b/lib/crypto/hmacmd5.h @@ -19,6 +19,9 @@ */ #ifndef _HMAC_MD5_H +#define _HMAC_MD5_H + +#include "../lib/crypto/md5.h" typedef struct { diff --git a/source4/lib/crypto/hmacmd5test.c b/lib/crypto/hmacmd5test.c similarity index 77% rename from source4/lib/crypto/hmacmd5test.c rename to lib/crypto/hmacmd5test.c index 07ed54c98d..77f305a5d3 100644 --- a/source4/lib/crypto/hmacmd5test.c +++ b/lib/crypto/hmacmd5test.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" struct torture_context; @@ -41,34 +41,37 @@ bool torture_local_crypto_hmacmd5(struct torture_context *torture) DATA_BLOB md5; } testarray[8]; + TALLOC_CTX *tctx = talloc_new(torture); + if (!tctx) { return false; }; + testarray[0].key = data_blob_repeat_byte(0x0b, 16); testarray[0].data = data_blob_string_const("Hi There"); - testarray[0].md5 = strhex_to_data_blob("9294727a3638bb1c13f48ef8158bfc9d"); + testarray[0].md5 = strhex_to_data_blob(tctx, "9294727a3638bb1c13f48ef8158bfc9d"); testarray[1].key = data_blob_string_const("Jefe"); testarray[1].data = data_blob_string_const("what do ya want for nothing?"); - testarray[1].md5 = strhex_to_data_blob("750c783e6ab0b503eaa86e310a5db738"); + testarray[1].md5 = strhex_to_data_blob(tctx, "750c783e6ab0b503eaa86e310a5db738"); testarray[2].key = data_blob_repeat_byte(0xaa, 16); testarray[2].data = data_blob_repeat_byte(0xdd, 50); - testarray[2].md5 = strhex_to_data_blob("56be34521d144c88dbb8c733f0e8b3f6"); + testarray[2].md5 = strhex_to_data_blob(tctx, "56be34521d144c88dbb8c733f0e8b3f6"); - testarray[3].key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f10111213141516171819"); + testarray[3].key = strhex_to_data_blob(tctx, "0102030405060708090a0b0c0d0e0f10111213141516171819"); testarray[3].data = data_blob_repeat_byte(0xcd, 50); - testarray[3].md5 = strhex_to_data_blob("697eaf0aca3a3aea3a75164746ffaa79"); + testarray[3].md5 = strhex_to_data_blob(tctx, "697eaf0aca3a3aea3a75164746ffaa79"); testarray[4].key = data_blob_repeat_byte(0x0c, 16); testarray[4].data = data_blob_string_const("Test With Truncation"); - testarray[4].md5 = strhex_to_data_blob("56461ef2342edc00f9bab995690efd4c"); + testarray[4].md5 = strhex_to_data_blob(tctx, "56461ef2342edc00f9bab995690efd4c"); testarray[5].key = data_blob_repeat_byte(0xaa, 80); testarray[5].data = data_blob_string_const("Test Using Larger Than Block-Size Key - Hash Key First"); - testarray[5].md5 = strhex_to_data_blob("6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"); + testarray[5].md5 = strhex_to_data_blob(tctx, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"); testarray[6].key = data_blob_repeat_byte(0xaa, 80); testarray[6].data = data_blob_string_const("Test Using Larger Than Block-Size Key " "and Larger Than One Block-Size Data"); - testarray[6].md5 = strhex_to_data_blob("6f630fad67cda0ee1fb1f562db3aa53e"); + testarray[6].md5 = strhex_to_data_blob(tctx, "6f630fad67cda0ee1fb1f562db3aa53e"); testarray[7].key = data_blob(NULL, 0); @@ -93,6 +96,6 @@ bool torture_local_crypto_hmacmd5(struct torture_context *torture) ret = false; } } - + talloc_free(tctx); return ret; } diff --git a/source4/lib/crypto/hmacsha256.c b/lib/crypto/hmacsha256.c similarity index 98% rename from source4/lib/crypto/hmacsha256.c rename to lib/crypto/hmacsha256.c index 6b0af9ee83..53d4fe3883 100644 --- a/source4/lib/crypto/hmacsha256.c +++ b/lib/crypto/hmacsha256.c @@ -27,7 +27,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" /*********************************************************************** the rfc 2104/2202 version of hmac_sha256 initialisation. diff --git a/source4/lib/crypto/hmacsha256.h b/lib/crypto/hmacsha256.h similarity index 100% rename from source4/lib/crypto/hmacsha256.h rename to lib/crypto/hmacsha256.h diff --git a/source4/lib/crypto/md4.c b/lib/crypto/md4.c similarity index 99% rename from source4/lib/crypto/md4.c rename to lib/crypto/md4.c index 7ad93ce786..aea2c821c5 100644 --- a/source4/lib/crypto/md4.c +++ b/lib/crypto/md4.c @@ -18,6 +18,7 @@ */ #include "includes.h" +#include "../lib/crypto/md4.h" /* NOTE: This code makes no attempt to be fast! diff --git a/source4/lib/crypto/md4.h b/lib/crypto/md4.h similarity index 100% rename from source4/lib/crypto/md4.h rename to lib/crypto/md4.h diff --git a/source4/lib/crypto/md4test.c b/lib/crypto/md4test.c similarity index 95% rename from source4/lib/crypto/md4test.c rename to lib/crypto/md4test.c index 5e0451973c..a6080cff82 100644 --- a/source4/lib/crypto/md4test.c +++ b/lib/crypto/md4test.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" struct torture_context; @@ -64,7 +64,7 @@ bool torture_local_crypto_md4(struct torture_context *torture) DATA_BLOB md4blob; data = data_blob_string_const(testarray[i].data); - md4blob = strhex_to_data_blob(testarray[i].md4); + md4blob = strhex_to_data_blob(NULL, testarray[i].md4); mdfour(md4, data.data, data.length); diff --git a/source4/lib/crypto/md5.c b/lib/crypto/md5.c similarity index 100% rename from source4/lib/crypto/md5.c rename to lib/crypto/md5.c diff --git a/source4/lib/crypto/md5.h b/lib/crypto/md5.h similarity index 100% rename from source4/lib/crypto/md5.h rename to lib/crypto/md5.h diff --git a/source4/lib/crypto/md5test.c b/lib/crypto/md5test.c similarity index 96% rename from source4/lib/crypto/md5test.c rename to lib/crypto/md5test.c index 702e0fcf41..7223af2114 100644 --- a/source4/lib/crypto/md5test.c +++ b/lib/crypto/md5test.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" struct torture_context; @@ -70,7 +70,7 @@ bool torture_local_crypto_md5(struct torture_context *torture) DATA_BLOB md5blob; data = data_blob_string_const(testarray[i].data); - md5blob = strhex_to_data_blob(testarray[i].md5); + md5blob = strhex_to_data_blob(NULL, testarray[i].md5); MD5Init(&ctx); MD5Update(&ctx, data.data, data.length); diff --git a/source4/lib/crypto/sha256.c b/lib/crypto/sha256.c similarity index 100% rename from source4/lib/crypto/sha256.c rename to lib/crypto/sha256.c diff --git a/source4/lib/crypto/sha256.h b/lib/crypto/sha256.h similarity index 100% rename from source4/lib/crypto/sha256.h rename to lib/crypto/sha256.h diff --git a/source3/lib/nss_wrapper/config.m4 b/lib/nss_wrapper/config.m4 similarity index 88% rename from source3/lib/nss_wrapper/config.m4 rename to lib/nss_wrapper/config.m4 index 58e94f9830..45423788d1 100644 --- a/source3/lib/nss_wrapper/config.m4 +++ b/lib/nss_wrapper/config.m4 @@ -12,7 +12,7 @@ if eval "test x$enable_nss_wrapper = xyes"; then HAVE_NSS_WRAPPER=yes # this is only used for samba3 - NSS_WRAPPER_OBJS="lib/nss_wrapper/nss_wrapper.o" + NSS_WRAPPER_OBJS="../lib/nss_wrapper/nss_wrapper.o" fi AC_SUBST(HAVE_NSS_WRAPPER) diff --git a/source4/lib/nss_wrapper/config.mk b/lib/nss_wrapper/config.mk similarity index 100% rename from source4/lib/nss_wrapper/config.mk rename to lib/nss_wrapper/config.mk diff --git a/source3/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c similarity index 99% rename from source3/lib/nss_wrapper/nss_wrapper.c rename to lib/nss_wrapper/nss_wrapper.c index 5d443facd3..da090832b0 100644 --- a/source3/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -34,7 +34,7 @@ #ifdef _SAMBA_BUILD_ #define NSS_WRAPPER_NOT_REPLACE -#include "lib/replace/replace.h" +#include "../replace/replace.h" #include "system/passwd.h" #include "system/filesys.h" diff --git a/source3/lib/nss_wrapper/nss_wrapper.h b/lib/nss_wrapper/nss_wrapper.h similarity index 100% rename from source3/lib/nss_wrapper/nss_wrapper.h rename to lib/nss_wrapper/nss_wrapper.h diff --git a/source3/lib/nss_wrapper/nss_wrapper.pl b/lib/nss_wrapper/nss_wrapper.pl similarity index 100% rename from source3/lib/nss_wrapper/nss_wrapper.pl rename to lib/nss_wrapper/nss_wrapper.pl diff --git a/source3/popt/CHANGES b/lib/popt/CHANGES similarity index 100% rename from source3/popt/CHANGES rename to lib/popt/CHANGES diff --git a/source3/popt/COPYING b/lib/popt/COPYING similarity index 100% rename from source3/popt/COPYING rename to lib/popt/COPYING diff --git a/source3/popt/README b/lib/popt/README similarity index 100% rename from source3/popt/README rename to lib/popt/README diff --git a/source4/lib/popt/config.mk b/lib/popt/config.mk similarity index 83% rename from source4/lib/popt/config.mk rename to lib/popt/config.mk index e015577aea..04cc2c7ea5 100644 --- a/source4/lib/popt/config.mk +++ b/lib/popt/config.mk @@ -1,5 +1,5 @@ [SUBSYSTEM::LIBPOPT] -CFLAGS = -Ilib/popt +CFLAGS = -I$(poptsrcdir) LIBPOPT_OBJ_FILES = $(addprefix $(poptsrcdir)/, findme.o popt.o poptconfig.o popthelp.o poptparse.o) diff --git a/source3/popt/dummy.in b/lib/popt/dummy.in similarity index 100% rename from source3/popt/dummy.in rename to lib/popt/dummy.in diff --git a/source3/popt/findme.c b/lib/popt/findme.c similarity index 100% rename from source3/popt/findme.c rename to lib/popt/findme.c diff --git a/source3/popt/findme.h b/lib/popt/findme.h similarity index 100% rename from source3/popt/findme.h rename to lib/popt/findme.h diff --git a/source4/lib/popt/libpopt.m4 b/lib/popt/libpopt.m4 similarity index 98% rename from source4/lib/popt/libpopt.m4 rename to lib/popt/libpopt.m4 index 79980d1d6b..cfa2eaad23 100644 --- a/source4/lib/popt/libpopt.m4 +++ b/lib/popt/libpopt.m4 @@ -25,7 +25,7 @@ if test x"$INCLUDED_POPT" != x"no"; then dnl find the popt sources. This is meant to work both for dnl popt standalone builds, and builds of packages using popt poptdir="" - poptpaths="$srcdir $srcdir/lib/popt $srcdir/popt $srcdir/../popt" + poptpaths="$srcdir $srcdir/lib/popt $srcdir/popt $srcdir/../popt $srcdir/../lib/popt" for d in $poptpaths; do if test -f "$d/popt.c"; then poptdir="$d" diff --git a/source3/popt/popt.c b/lib/popt/popt.c similarity index 100% rename from source3/popt/popt.c rename to lib/popt/popt.c diff --git a/source3/popt/popt.h b/lib/popt/popt.h similarity index 100% rename from source3/popt/popt.h rename to lib/popt/popt.h diff --git a/source3/popt/poptconfig.c b/lib/popt/poptconfig.c similarity index 100% rename from source3/popt/poptconfig.c rename to lib/popt/poptconfig.c diff --git a/source3/popt/popthelp.c b/lib/popt/popthelp.c similarity index 100% rename from source3/popt/popthelp.c rename to lib/popt/popthelp.c diff --git a/source3/popt/poptint.h b/lib/popt/poptint.h similarity index 100% rename from source3/popt/poptint.h rename to lib/popt/poptint.h diff --git a/source3/popt/poptparse.c b/lib/popt/poptparse.c similarity index 100% rename from source3/popt/poptparse.c rename to lib/popt/poptparse.c diff --git a/source4/lib/popt/samba.m4 b/lib/popt/samba.m4 similarity index 52% rename from source4/lib/popt/samba.m4 rename to lib/popt/samba.m4 index 855fd6c402..627dd854b2 100644 --- a/source4/lib/popt/samba.m4 +++ b/lib/popt/samba.m4 @@ -1,8 +1,8 @@ -m4_include(lib/popt/libpopt.m4) +m4_include(../lib/popt/libpopt.m4) if test x"$POPT_OBJ" = "x"; then SMB_EXT_LIB(LIBPOPT, [${POPT_LIBS}]) else - SMB_INCLUDE_MK(lib/popt/config.mk) + SMB_INCLUDE_MK(../lib/popt/config.mk) fi diff --git a/source3/popt/system.h b/lib/popt/system.h similarity index 100% rename from source3/popt/system.h rename to lib/popt/system.h diff --git a/source3/lib/replace/.checker_innocent b/lib/replace/.checker_innocent similarity index 100% rename from source3/lib/replace/.checker_innocent rename to lib/replace/.checker_innocent diff --git a/source4/lib/replace/Makefile.in b/lib/replace/Makefile.in similarity index 71% rename from source4/lib/replace/Makefile.in rename to lib/replace/Makefile.in index c989835a8d..65f8125efd 100644 --- a/source4/lib/replace/Makefile.in +++ b/lib/replace/Makefile.in @@ -9,7 +9,8 @@ libdir = @libdir@ VPATH = @libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ -INSTALL = @INSTALL@ +sharedbuilddir = @sharedbuilddir@ +INSTALLCMD = @INSTALL@ LIBS = @LIBS@ .PHONY: test all showflags install installcheck clean distclean realdistclean @@ -29,8 +30,14 @@ showflags: @echo ' LIBS = $(LIBS)' install: all - mkdir -p $(libdir) - $(INSTALL) libreplace.a $(libdir) + ${INSTALLCMD} -d $(libdir) + ${INSTALLCMD} -m 644 libreplace.a $(libdir) + +shared-build: all + ${INSTALLCMD} -d $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 replace.h $(sharedbuilddir)/include + ${INSTALLCMD} -d $(sharedbuilddir)/lib + ${INSTALLCMD} -m 644 libreplace.a $(sharedbuilddir)/lib libreplace.a: $(OBJS) ar -rcsv $@ $(OBJS) @@ -40,7 +47,7 @@ test: all installcheck: install test -TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o +TEST_OBJS = test/main.o test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o testsuite: libreplace.a $(TEST_OBJS) $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS) diff --git a/source3/lib/replace/README b/lib/replace/README similarity index 100% rename from source3/lib/replace/README rename to lib/replace/README diff --git a/source3/lib/replace/aclocal.m4 b/lib/replace/aclocal.m4 similarity index 100% rename from source3/lib/replace/aclocal.m4 rename to lib/replace/aclocal.m4 diff --git a/source3/lib/replace/autoconf-2.60.m4 b/lib/replace/autoconf-2.60.m4 similarity index 100% rename from source3/lib/replace/autoconf-2.60.m4 rename to lib/replace/autoconf-2.60.m4 diff --git a/source3/lib/replace/autogen.sh b/lib/replace/autogen.sh similarity index 100% rename from source3/lib/replace/autogen.sh rename to lib/replace/autogen.sh diff --git a/lib/replace/build_macros.m4 b/lib/replace/build_macros.m4 new file mode 100644 index 0000000000..c036668cd1 --- /dev/null +++ b/lib/replace/build_macros.m4 @@ -0,0 +1,14 @@ +AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, + [ AC_ARG_WITH([shared-build-dir], + [AC_HELP_STRING([--with-shared-build-dir=DIR], + [temporary build directory where libraries are installed [$srcdir/sharedbuild]])]) + + sharedbuilddir="$srcdir/sharedbuild" + if test x"$with_shared_build_dir" != x; then + sharedbuilddir=$with_shared_build_dir + CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" + fi + AC_SUBST(sharedbuilddir) + ]) + diff --git a/source3/lib/replace/config.guess b/lib/replace/config.guess similarity index 100% rename from source3/lib/replace/config.guess rename to lib/replace/config.guess diff --git a/source3/lib/replace/config.sub b/lib/replace/config.sub similarity index 100% rename from source3/lib/replace/config.sub rename to lib/replace/config.sub diff --git a/source4/lib/replace/configure.ac b/lib/replace/configure.ac similarity index 92% rename from source4/lib/replace/configure.ac rename to lib/replace/configure.ac index 81997e09b7..0361825a02 100644 --- a/source4/lib/replace/configure.ac +++ b/lib/replace/configure.ac @@ -22,6 +22,9 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi +m4_include(build_macros.m4) +BUILD_WITH_SHARED_BUILD_DIR + LIBS="${LIBREPLACE_NETWORK_LIBS}" AC_SUBST(LIBS) diff --git a/source3/lib/ufc.c b/lib/replace/crypt.c similarity index 99% rename from source3/lib/ufc.c rename to lib/replace/crypt.c index 89329808c9..22341ce511 100644 --- a/source3/lib/ufc.c +++ b/lib/replace/crypt.c @@ -16,7 +16,7 @@ */ -#include "includes.h" +#include "replace.h" #ifndef HAVE_CRYPT diff --git a/lib/replace/crypt.m4 b/lib/replace/crypt.m4 new file mode 100644 index 0000000000..4e90866205 --- /dev/null +++ b/lib/replace/crypt.m4 @@ -0,0 +1,7 @@ +############################################### +# test for where we get crypt() from +AC_CHECK_HEADERS(crypt.h) +AC_SEARCH_LIBS_EXT(crypt, [crypt], + [test "$ac_cv_search_ext_crypt" = "none required" || CRYPT_LIBS="-lcrypt" + AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])], + [ LIBREPLACEOBJ="${LIBREPLACEOBJ} crypt.o" ]) diff --git a/source3/lib/replace/dlfcn.c b/lib/replace/dlfcn.c similarity index 100% rename from source3/lib/replace/dlfcn.c rename to lib/replace/dlfcn.c diff --git a/source3/lib/replace/dlfcn.m4 b/lib/replace/dlfcn.m4 similarity index 100% rename from source3/lib/replace/dlfcn.m4 rename to lib/replace/dlfcn.m4 diff --git a/source3/lib/replace/getaddrinfo.c b/lib/replace/getaddrinfo.c similarity index 100% rename from source3/lib/replace/getaddrinfo.c rename to lib/replace/getaddrinfo.c diff --git a/source3/lib/replace/getaddrinfo.h b/lib/replace/getaddrinfo.h similarity index 98% rename from source3/lib/replace/getaddrinfo.h rename to lib/replace/getaddrinfo.h index dddd699b62..cf040da2db 100644 --- a/source3/lib/replace/getaddrinfo.h +++ b/lib/replace/getaddrinfo.h @@ -75,7 +75,9 @@ in lib/replace we use rep_xxx() #undef getnameinfo #endif #define getnameinfo rep_getnameinfo +#ifndef HAVE_GETNAMEINFO #define HAVE_GETNAMEINFO +#endif extern int rep_getaddrinfo(const char *node, const char *service, const struct addrinfo * hints, struct addrinfo ** res); diff --git a/source3/lib/replace/getifaddrs.c b/lib/replace/getifaddrs.c similarity index 100% rename from source3/lib/replace/getifaddrs.c rename to lib/replace/getifaddrs.c diff --git a/source3/lib/replace/getpass.c b/lib/replace/getpass.c similarity index 100% rename from source3/lib/replace/getpass.c rename to lib/replace/getpass.c diff --git a/source3/lib/replace/getpass.m4 b/lib/replace/getpass.m4 similarity index 100% rename from source3/lib/replace/getpass.m4 rename to lib/replace/getpass.m4 diff --git a/source3/lib/replace/inet_aton.c b/lib/replace/inet_aton.c similarity index 100% rename from source3/lib/replace/inet_aton.c rename to lib/replace/inet_aton.c diff --git a/source3/lib/replace/inet_ntoa.c b/lib/replace/inet_ntoa.c similarity index 100% rename from source3/lib/replace/inet_ntoa.c rename to lib/replace/inet_ntoa.c diff --git a/source3/lib/replace/inet_ntop.c b/lib/replace/inet_ntop.c similarity index 100% rename from source3/lib/replace/inet_ntop.c rename to lib/replace/inet_ntop.c diff --git a/source3/lib/replace/inet_pton.c b/lib/replace/inet_pton.c similarity index 100% rename from source3/lib/replace/inet_pton.c rename to lib/replace/inet_pton.c diff --git a/source3/lib/replace/install-sh b/lib/replace/install-sh similarity index 100% rename from source3/lib/replace/install-sh rename to lib/replace/install-sh diff --git a/source4/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4 similarity index 95% rename from source4/lib/replace/libreplace.m4 rename to lib/replace/libreplace.m4 index 71fa041672..05e73fb569 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/lib/replace/libreplace.m4 @@ -5,7 +5,7 @@ echo "LIBREPLACE_LOCATION_CHECKS: START" dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" -libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace" +libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace $srcdir/../../../lib/replace" for d in $libreplacepaths; do if test -f "$d/replace.c"; then libreplacedir="$d" @@ -34,13 +34,18 @@ echo "LIBREPLACE_BROKEN_CHECKS: START" dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" -for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do +libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace $srcdir/../../../lib/replace" +for d in $libreplacepaths; do if test -f "$d/replace.c"; then libreplacedir="$d" AC_SUBST(libreplacedir) break; fi done +if test x"$libreplacedir" = "x"; then + AC_MSG_ERROR([cannot find libreplace in $libreplacepaths]) +fi + LIBREPLACEOBJ="replace.o" AC_SUBST(LIBREPLACEOBJ) @@ -271,6 +276,7 @@ m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) m4_include(repdir.m4) +m4_include(crypt.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source3/lib/replace/libreplace_cc.m4 b/lib/replace/libreplace_cc.m4 similarity index 100% rename from source3/lib/replace/libreplace_cc.m4 rename to lib/replace/libreplace_cc.m4 diff --git a/source3/lib/replace/libreplace_ld.m4 b/lib/replace/libreplace_ld.m4 similarity index 100% rename from source3/lib/replace/libreplace_ld.m4 rename to lib/replace/libreplace_ld.m4 diff --git a/source3/lib/replace/libreplace_macros.m4 b/lib/replace/libreplace_macros.m4 similarity index 100% rename from source3/lib/replace/libreplace_macros.m4 rename to lib/replace/libreplace_macros.m4 diff --git a/source3/lib/replace/libreplace_network.m4 b/lib/replace/libreplace_network.m4 similarity index 100% rename from source3/lib/replace/libreplace_network.m4 rename to lib/replace/libreplace_network.m4 diff --git a/source3/lib/replace/repdir.m4 b/lib/replace/repdir.m4 similarity index 100% rename from source3/lib/replace/repdir.m4 rename to lib/replace/repdir.m4 diff --git a/source3/lib/replace/repdir_getdents.c b/lib/replace/repdir_getdents.c similarity index 100% rename from source3/lib/replace/repdir_getdents.c rename to lib/replace/repdir_getdents.c diff --git a/source3/lib/replace/repdir_getdirentries.c b/lib/replace/repdir_getdirentries.c similarity index 100% rename from source3/lib/replace/repdir_getdirentries.c rename to lib/replace/repdir_getdirentries.c diff --git a/source3/lib/replace/replace.c b/lib/replace/replace.c similarity index 100% rename from source3/lib/replace/replace.c rename to lib/replace/replace.c diff --git a/source3/lib/replace/replace.h b/lib/replace/replace.h similarity index 93% rename from source3/lib/replace/replace.h rename to lib/replace/replace.h index c69ea6cdac..af1208a8fc 100644 --- a/source3/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -52,9 +52,58 @@ which causes a warning storm on irix */ #undef HAVE_INTTYPES_H #elif HAVE_INTTYPES_H +#define __STDC_FORMAT_MACROS #include #endif +#ifndef __PRI64_PREFIX +# if __WORDSIZE == 64 +# define __PRI64_PREFIX "l" +# else +# define __PRI64_PREFIX "ll" +# endif +#endif + +/* Decimal notation. */ +#ifndef PRId8 +# define PRId8 "d" +#endif +#ifndef PRId16 +# define PRId16 "d" +#endif +#ifndef PRId32 +# define PRId32 "d" +#endif +#ifndef PRId64 +# define PRId64 __PRI64_PREFIX "d" +#endif + +#ifndef PRIi8 +# define PRIi8 "i" +#endif +#ifndef PRIi8 +# define PRIi16 "i" +#endif +#ifndef PRIi8 +# define PRIi32 "i" +#endif +#ifndef PRIi8 +# define PRIi64 __PRI64_PREFIX "i" +#endif + +#ifndef PRIu8 +# define PRIu8 "u" +#endif +#ifndef PRIu16 +# define PRIu16 "u" +#endif +#ifndef PRIu32 +# define PRIu32 "u" +#endif +#ifndef PRIu64 +# define PRIu64 __PRI64_PREFIX "u" +#endif + #ifdef HAVE_STRING_H #include #endif @@ -579,4 +628,13 @@ typedef int bool; #define MAX_DNS_NAME_LENGTH 256 /* Actually 255 but +1 for terminating null. */ #endif +#ifndef HAVE_CRYPT +char *ufc_crypt(const char *key, const char *salt); +#define crypt ufc_crypt +#else +#ifdef HAVE_CRYPT_H +#include +#endif +#endif + #endif /* _LIBREPLACE_REPLACE_H */ diff --git a/source4/lib/replace/samba.m4 b/lib/replace/samba.m4 similarity index 94% rename from source4/lib/replace/samba.m4 rename to lib/replace/samba.m4 index 07c4d38887..ccb6f2e20d 100644 --- a/source4/lib/replace/samba.m4 +++ b/lib/replace/samba.m4 @@ -1,7 +1,7 @@ AC_LIBREPLACE_BROKEN_CHECKS AC_LIBREPLACE_NETWORK_CHECKS -SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) +SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL} ${CRYPT_LIBS}]) SMB_ENABLE(LIBREPLACE_EXT) SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}]) diff --git a/source3/lib/replace/snprintf.c b/lib/replace/snprintf.c similarity index 100% rename from source3/lib/replace/snprintf.c rename to lib/replace/snprintf.c diff --git a/source3/lib/replace/socket.c b/lib/replace/socket.c similarity index 100% rename from source3/lib/replace/socket.c rename to lib/replace/socket.c diff --git a/source3/lib/replace/socketpair.c b/lib/replace/socketpair.c similarity index 100% rename from source3/lib/replace/socketpair.c rename to lib/replace/socketpair.c diff --git a/source3/lib/replace/strptime.c b/lib/replace/strptime.c similarity index 100% rename from source3/lib/replace/strptime.c rename to lib/replace/strptime.c diff --git a/source3/lib/replace/strptime.m4 b/lib/replace/strptime.m4 similarity index 100% rename from source3/lib/replace/strptime.m4 rename to lib/replace/strptime.m4 diff --git a/source3/lib/replace/system/README b/lib/replace/system/README similarity index 100% rename from source3/lib/replace/system/README rename to lib/replace/system/README diff --git a/source3/lib/replace/system/aio.h b/lib/replace/system/aio.h similarity index 100% rename from source3/lib/replace/system/aio.h rename to lib/replace/system/aio.h diff --git a/source3/lib/replace/system/capability.h b/lib/replace/system/capability.h similarity index 100% rename from source3/lib/replace/system/capability.h rename to lib/replace/system/capability.h diff --git a/source3/lib/replace/system/config.m4 b/lib/replace/system/config.m4 similarity index 100% rename from source3/lib/replace/system/config.m4 rename to lib/replace/system/config.m4 diff --git a/source3/lib/replace/system/dir.h b/lib/replace/system/dir.h similarity index 100% rename from source3/lib/replace/system/dir.h rename to lib/replace/system/dir.h diff --git a/source3/lib/replace/system/filesys.h b/lib/replace/system/filesys.h similarity index 100% rename from source3/lib/replace/system/filesys.h rename to lib/replace/system/filesys.h diff --git a/source3/lib/replace/system/glob.h b/lib/replace/system/glob.h similarity index 100% rename from source3/lib/replace/system/glob.h rename to lib/replace/system/glob.h diff --git a/source3/lib/replace/system/iconv.h b/lib/replace/system/iconv.h similarity index 100% rename from source3/lib/replace/system/iconv.h rename to lib/replace/system/iconv.h diff --git a/source3/lib/replace/system/kerberos.h b/lib/replace/system/kerberos.h similarity index 100% rename from source3/lib/replace/system/kerberos.h rename to lib/replace/system/kerberos.h diff --git a/source3/lib/replace/system/locale.h b/lib/replace/system/locale.h similarity index 100% rename from source3/lib/replace/system/locale.h rename to lib/replace/system/locale.h diff --git a/source3/lib/replace/system/network.h b/lib/replace/system/network.h similarity index 99% rename from source3/lib/replace/system/network.h rename to lib/replace/system/network.h index 077892a54e..473d79b5f2 100644 --- a/source3/lib/replace/system/network.h +++ b/lib/replace/system/network.h @@ -326,7 +326,7 @@ struct addrinfo { #ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE #endif -#include "lib/socket_wrapper/socket_wrapper.h" +#include "../socket_wrapper/socket_wrapper.h" #endif #endif diff --git a/source4/lib/replace/system/passwd.h b/lib/replace/system/passwd.h similarity index 98% rename from source4/lib/replace/system/passwd.h rename to lib/replace/system/passwd.h index cad3197ccb..9d7de34bce 100644 --- a/source4/lib/replace/system/passwd.h +++ b/lib/replace/system/passwd.h @@ -104,7 +104,7 @@ char *rep_getpass(const char *prompt); #ifndef NSS_WRAPPER_NOT_REPLACE #define NSS_WRAPPER_REPLACE #endif -#include "lib/nss_wrapper/nss_wrapper.h" +#include "../nss_wrapper/nss_wrapper.h" #endif #endif diff --git a/source3/lib/replace/system/readline.h b/lib/replace/system/readline.h similarity index 100% rename from source3/lib/replace/system/readline.h rename to lib/replace/system/readline.h diff --git a/source3/lib/replace/system/select.h b/lib/replace/system/select.h similarity index 100% rename from source3/lib/replace/system/select.h rename to lib/replace/system/select.h diff --git a/source3/lib/replace/system/shmem.h b/lib/replace/system/shmem.h similarity index 100% rename from source3/lib/replace/system/shmem.h rename to lib/replace/system/shmem.h diff --git a/source3/lib/replace/system/syslog.h b/lib/replace/system/syslog.h similarity index 100% rename from source3/lib/replace/system/syslog.h rename to lib/replace/system/syslog.h diff --git a/source3/lib/replace/system/terminal.h b/lib/replace/system/terminal.h similarity index 100% rename from source3/lib/replace/system/terminal.h rename to lib/replace/system/terminal.h diff --git a/source3/lib/replace/system/time.h b/lib/replace/system/time.h similarity index 100% rename from source3/lib/replace/system/time.h rename to lib/replace/system/time.h diff --git a/source3/lib/replace/system/wait.h b/lib/replace/system/wait.h similarity index 100% rename from source3/lib/replace/system/wait.h rename to lib/replace/system/wait.h diff --git a/source3/lib/replace/test/getifaddrs.c b/lib/replace/test/getifaddrs.c similarity index 100% rename from source3/lib/replace/test/getifaddrs.c rename to lib/replace/test/getifaddrs.c diff --git a/source4/lib/replace/system/glob.h b/lib/replace/test/main.c similarity index 71% rename from source4/lib/replace/system/glob.h rename to lib/replace/test/main.c index 3e23db6828..9bd12840a5 100644 --- a/source4/lib/replace/system/glob.h +++ b/lib/replace/test/main.c @@ -1,16 +1,14 @@ -#ifndef _system_glob_h -#define _system_glob_h -/* +/* Unix SMB/CIFS implementation. - glob system include wrappers + libreplace tests - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace + Copyright (C) Jelmer Vernooij 2006 + + ** NOTE! The following LGPL license applies to the talloc ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -23,15 +21,17 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, see . - */ -#ifdef HAVE_GLOB_H -#include -#endif +#include "replace.h" -#ifdef HAVE_FNMATCH_H -#include -#endif +struct torture_context; +bool torture_local_replace(struct torture_context *ctx); -#endif +int main(void) +{ + bool ret = torture_local_replace(NULL); + if (ret) + return 0; + return -1; +} diff --git a/source3/lib/replace/test/os2_delete.c b/lib/replace/test/os2_delete.c similarity index 100% rename from source3/lib/replace/test/os2_delete.c rename to lib/replace/test/os2_delete.c diff --git a/source3/lib/replace/test/shared_mmap.c b/lib/replace/test/shared_mmap.c similarity index 100% rename from source3/lib/replace/test/shared_mmap.c rename to lib/replace/test/shared_mmap.c diff --git a/source3/lib/replace/test/strptime.c b/lib/replace/test/strptime.c similarity index 100% rename from source3/lib/replace/test/strptime.c rename to lib/replace/test/strptime.c diff --git a/source4/lib/replace/test/testsuite.c b/lib/replace/test/testsuite.c similarity index 99% rename from source4/lib/replace/test/testsuite.c rename to lib/replace/test/testsuite.c index 1e8290906e..7929f11add 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/lib/replace/test/testsuite.c @@ -1068,13 +1068,3 @@ bool torture_local_replace(struct torture_context *ctx) return ret; } - -#if _SAMBA_BUILD_<4 -int main(void) -{ - bool ret = torture_local_replace(NULL); - if (ret) - return 0; - return -1; -} -#endif diff --git a/source3/lib/replace/timegm.c b/lib/replace/timegm.c similarity index 100% rename from source3/lib/replace/timegm.c rename to lib/replace/timegm.c diff --git a/source3/lib/replace/timegm.m4 b/lib/replace/timegm.m4 similarity index 100% rename from source3/lib/replace/timegm.m4 rename to lib/replace/timegm.m4 diff --git a/source3/lib/replace/win32.m4 b/lib/replace/win32.m4 similarity index 100% rename from source3/lib/replace/win32.m4 rename to lib/replace/win32.m4 diff --git a/source3/lib/replace/win32_replace.h b/lib/replace/win32_replace.h similarity index 100% rename from source3/lib/replace/win32_replace.h rename to lib/replace/win32_replace.h diff --git a/source4/lib/socket_wrapper/config.m4 b/lib/socket_wrapper/config.m4 similarity index 89% rename from source4/lib/socket_wrapper/config.m4 rename to lib/socket_wrapper/config.m4 index f3ffb895a9..68e392b3e7 100644 --- a/source4/lib/socket_wrapper/config.m4 +++ b/lib/socket_wrapper/config.m4 @@ -14,7 +14,7 @@ if eval "test x$enable_socket_wrapper = xyes"; then HAVE_SOCKET_WRAPPER=yes # this is only used for samba3 - SOCKET_WRAPPER_OBJS="lib/socket_wrapper/socket_wrapper.o" + SOCKET_WRAPPER_OBJS="../lib/socket_wrapper/socket_wrapper.o" fi AC_SUBST(DEFAULT_TEST_OPTIONS) diff --git a/source3/lib/socket_wrapper/config.mk b/lib/socket_wrapper/config.mk similarity index 100% rename from source3/lib/socket_wrapper/config.mk rename to lib/socket_wrapper/config.mk diff --git a/source3/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c similarity index 99% rename from source3/lib/socket_wrapper/socket_wrapper.c rename to lib/socket_wrapper/socket_wrapper.c index 33e4b38370..9d61976950 100644 --- a/source3/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -42,7 +42,7 @@ #ifdef _SAMBA_BUILD_ #define SOCKET_WRAPPER_NOT_REPLACE -#include "lib/replace/replace.h" +#include "../replace/replace.h" #include "system/network.h" #include "system/filesys.h" #include "system/time.h" diff --git a/source3/lib/socket_wrapper/socket_wrapper.h b/lib/socket_wrapper/socket_wrapper.h similarity index 100% rename from source3/lib/socket_wrapper/socket_wrapper.h rename to lib/socket_wrapper/socket_wrapper.h diff --git a/source3/lib/socket_wrapper/testsuite.c b/lib/socket_wrapper/testsuite.c similarity index 98% rename from source3/lib/socket_wrapper/testsuite.c rename to lib/socket_wrapper/testsuite.c index 8877418e4c..e6e08e3be6 100644 --- a/source3/lib/socket_wrapper/testsuite.c +++ b/lib/socket_wrapper/testsuite.c @@ -21,7 +21,7 @@ #include "includes.h" #include "system/network.h" -#include "lib/socket_wrapper/socket_wrapper.h" +#include "../socket_wrapper/socket_wrapper.h" #include "torture/torture.h" static char *old_dir = NULL; diff --git a/source4/script/harness2subunit.pl b/lib/subunit/harness2subunit.pl similarity index 77% rename from source4/script/harness2subunit.pl rename to lib/subunit/harness2subunit.pl index 9f2391ad6c..45f515540b 100755 --- a/source4/script/harness2subunit.pl +++ b/lib/subunit/harness2subunit.pl @@ -1,4 +1,8 @@ #!/usr/bin/perl +# Simple script that converts Perl test harness output to +# Subunit +# Copyright (C) 2008 Jelmer Vernooij +# Published under the GNU GPL, v3 or later my $firstline = 1; my $error = 0; diff --git a/source4/scripting/python/subunit/__init__.py b/lib/subunit/python/subunit/__init__.py similarity index 100% rename from source4/scripting/python/subunit/__init__.py rename to lib/subunit/python/subunit/__init__.py diff --git a/lib/subunit/python/subunit/tests/TestUtil.py b/lib/subunit/python/subunit/tests/TestUtil.py new file mode 100644 index 0000000000..1b5ba9c293 --- /dev/null +++ b/lib/subunit/python/subunit/tests/TestUtil.py @@ -0,0 +1,80 @@ +# Copyright (c) 2004 Canonical Limited +# Author: Robert Collins +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import logging +import unittest + + +class LogCollector(logging.Handler): + def __init__(self): + logging.Handler.__init__(self) + self.records=[] + def emit(self, record): + self.records.append(record.getMessage()) + + +def makeCollectingLogger(): + """I make a logger instance that collects its logs for programmatic analysis + -> (logger, collector)""" + logger=logging.Logger("collector") + handler=LogCollector() + handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) + logger.addHandler(handler) + return logger, handler + + +def visitTests(suite, visitor): + """A foreign method for visiting the tests in a test suite.""" + for test in suite._tests: + #Abusing types to avoid monkey patching unittest.TestCase. + # Maybe that would be better? + try: + test.visit(visitor) + except AttributeError: + if isinstance(test, unittest.TestCase): + visitor.visitCase(test) + elif isinstance(test, unittest.TestSuite): + visitor.visitSuite(test) + visitTests(test, visitor) + else: + print "unvisitable non-unittest.TestCase element %r (%r)" % (test, test.__class__) + + +class TestSuite(unittest.TestSuite): + """I am an extended TestSuite with a visitor interface. + This is primarily to allow filtering of tests - and suites or + more in the future. An iterator of just tests wouldn't scale...""" + + def visit(self, visitor): + """visit the composite. Visiting is depth-first. + current callbacks are visitSuite and visitCase.""" + visitor.visitSuite(self) + visitTests(self, visitor) + + +class TestLoader(unittest.TestLoader): + """Custome TestLoader to set the right TestSuite class.""" + suiteClass = TestSuite + +class TestVisitor(object): + """A visitor for Tests""" + def visitSuite(self, aTestSuite): + pass + def visitCase(self, aTestCase): + pass diff --git a/lib/subunit/python/subunit/tests/__init__.py b/lib/subunit/python/subunit/tests/__init__.py new file mode 100644 index 0000000000..544d0e704f --- /dev/null +++ b/lib/subunit/python/subunit/tests/__init__.py @@ -0,0 +1,25 @@ +# +# subunit: extensions to python unittest to get test results from subprocesses. +# Copyright (C) 2005 Robert Collins +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +from subunit.tests import TestUtil, test_test_protocol + +def test_suite(): + result = TestUtil.TestSuite() + result.addTest(test_test_protocol.test_suite()) + return result diff --git a/lib/subunit/python/subunit/tests/sample-script.py b/lib/subunit/python/subunit/tests/sample-script.py new file mode 100755 index 0000000000..223d2f5d9f --- /dev/null +++ b/lib/subunit/python/subunit/tests/sample-script.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +import sys +print "test old mcdonald" +print "success old mcdonald" +print "test bing crosby" +print "failure bing crosby [" +print "foo.c:53:ERROR invalid state" +print "]" +print "test an error" +print "error an error" +sys.exit(0) diff --git a/lib/subunit/python/subunit/tests/sample-two-script.py b/lib/subunit/python/subunit/tests/sample-two-script.py new file mode 100755 index 0000000000..d5550842bf --- /dev/null +++ b/lib/subunit/python/subunit/tests/sample-two-script.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python +import sys +print "test old mcdonald" +print "success old mcdonald" +print "test bing crosby" +print "success bing crosby" +sys.exit(0) diff --git a/lib/subunit/python/subunit/tests/test_test_protocol.py b/lib/subunit/python/subunit/tests/test_test_protocol.py new file mode 100644 index 0000000000..af31584a97 --- /dev/null +++ b/lib/subunit/python/subunit/tests/test_test_protocol.py @@ -0,0 +1,730 @@ +# +# subunit: extensions to python unittest to get test results from subprocesses. +# Copyright (C) 2005 Robert Collins +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import unittest +from StringIO import StringIO +import os +import subunit +import sys + +try: + class MockTestProtocolServerClient(object): + """A mock protocol server client to test callbacks.""" + + def __init__(self): + self.end_calls = [] + self.error_calls = [] + self.failure_calls = [] + self.start_calls = [] + self.success_calls = [] + super(MockTestProtocolServerClient, self).__init__() + + def addError(self, test, error): + self.error_calls.append((test, error)) + + def addFailure(self, test, error): + self.failure_calls.append((test, error)) + + def addSuccess(self, test): + self.success_calls.append(test) + + def stopTest(self, test): + self.end_calls.append(test) + + def startTest(self, test): + self.start_calls.append(test) + +except AttributeError: + MockTestProtocolServer = None + + +class TestMockTestProtocolServer(unittest.TestCase): + + def test_start_test(self): + protocol = MockTestProtocolServerClient() + protocol.startTest(subunit.RemotedTestCase("test old mcdonald")) + self.assertEqual(protocol.start_calls, + [subunit.RemotedTestCase("test old mcdonald")]) + self.assertEqual(protocol.end_calls, []) + self.assertEqual(protocol.error_calls, []) + self.assertEqual(protocol.failure_calls, []) + self.assertEqual(protocol.success_calls, []) + + def test_add_error(self): + protocol = MockTestProtocolServerClient() + protocol.addError(subunit.RemotedTestCase("old mcdonald"), + subunit.RemoteError("omg it works")) + self.assertEqual(protocol.start_calls, []) + self.assertEqual(protocol.end_calls, []) + self.assertEqual(protocol.error_calls, [( + subunit.RemotedTestCase("old mcdonald"), + subunit.RemoteError("omg it works"))]) + self.assertEqual(protocol.failure_calls, []) + self.assertEqual(protocol.success_calls, []) + + def test_add_failure(self): + protocol = MockTestProtocolServerClient() + protocol.addFailure(subunit.RemotedTestCase("old mcdonald"), + subunit.RemoteError("omg it works")) + self.assertEqual(protocol.start_calls, []) + self.assertEqual(protocol.end_calls, []) + self.assertEqual(protocol.error_calls, []) + self.assertEqual(protocol.failure_calls, [ + (subunit.RemotedTestCase("old mcdonald"), + subunit.RemoteError("omg it works"))]) + self.assertEqual(protocol.success_calls, []) + + def test_add_success(self): + protocol = MockTestProtocolServerClient() + protocol.addSuccess(subunit.RemotedTestCase("test old mcdonald")) + self.assertEqual(protocol.start_calls, []) + self.assertEqual(protocol.end_calls, []) + self.assertEqual(protocol.error_calls, []) + self.assertEqual(protocol.failure_calls, []) + self.assertEqual(protocol.success_calls, + [subunit.RemotedTestCase("test old mcdonald")]) + + def test_end_test(self): + protocol = MockTestProtocolServerClient() + protocol.stopTest(subunit.RemotedTestCase("test old mcdonald")) + self.assertEqual(protocol.end_calls, + [subunit.RemotedTestCase("test old mcdonald")]) + self.assertEqual(protocol.error_calls, []) + self.assertEqual(protocol.failure_calls, []) + self.assertEqual(protocol.success_calls, []) + self.assertEqual(protocol.start_calls, []) + + +class TestTestImports(unittest.TestCase): + + def test_imports(self): + from subunit import TestProtocolServer + from subunit import RemotedTestCase + from subunit import RemoteError + from subunit import ExecTestCase + from subunit import IsolatedTestCase + from subunit import TestProtocolClient + + +class TestTestProtocolServerPipe(unittest.TestCase): + + def test_story(self): + client = unittest.TestResult() + protocol = subunit.TestProtocolServer(client) + pipe = StringIO("test old mcdonald\n" + "success old mcdonald\n" + "test bing crosby\n" + "failure bing crosby [\n" + "foo.c:53:ERROR invalid state\n" + "]\n" + "test an error\n" + "error an error\n") + protocol.readFrom(pipe) + mcdonald = subunit.RemotedTestCase("old mcdonald") + bing = subunit.RemotedTestCase("bing crosby") + an_error = subunit.RemotedTestCase("an error") + self.assertEqual(client.errors, + [(an_error, 'RemoteException: \n\n')]) + self.assertEqual( + client.failures, + [(bing, "RemoteException: foo.c:53:ERROR invalid state\n\n")]) + self.assertEqual(client.testsRun, 3) + + +class TestTestProtocolServerStartTest(unittest.TestCase): + + def setUp(self): + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + + def test_start_test(self): + self.protocol.lineReceived("test old mcdonald\n") + self.assertEqual(self.client.start_calls, + [subunit.RemotedTestCase("old mcdonald")]) + + def test_start_testing(self): + self.protocol.lineReceived("testing old mcdonald\n") + self.assertEqual(self.client.start_calls, + [subunit.RemotedTestCase("old mcdonald")]) + + def test_start_test_colon(self): + self.protocol.lineReceived("test: old mcdonald\n") + self.assertEqual(self.client.start_calls, + [subunit.RemotedTestCase("old mcdonald")]) + + def test_start_testing_colon(self): + self.protocol.lineReceived("testing: old mcdonald\n") + self.assertEqual(self.client.start_calls, + [subunit.RemotedTestCase("old mcdonald")]) + + +class TestTestProtocolServerPassThrough(unittest.TestCase): + + def setUp(self): + from StringIO import StringIO + self.stdout = StringIO() + self.test = subunit.RemotedTestCase("old mcdonald") + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client, self.stdout) + + def keywords_before_test(self): + self.protocol.lineReceived("failure a\n") + self.protocol.lineReceived("failure: a\n") + self.protocol.lineReceived("error a\n") + self.protocol.lineReceived("error: a\n") + self.protocol.lineReceived("success a\n") + self.protocol.lineReceived("success: a\n") + self.protocol.lineReceived("successful a\n") + self.protocol.lineReceived("successful: a\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.stdout.getvalue(), "failure a\n" + "failure: a\n" + "error a\n" + "error: a\n" + "success a\n" + "success: a\n" + "successful a\n" + "successful: a\n" + "]\n") + + def test_keywords_before_test(self): + self.keywords_before_test() + self.assertEqual(self.client.start_calls, []) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_keywords_after_error(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("error old mcdonald\n") + self.keywords_before_test() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, + [(self.test, subunit.RemoteError(""))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_keywords_after_failure(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("failure old mcdonald\n") + self.keywords_before_test() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError())]) + self.assertEqual(self.client.success_calls, []) + + def test_keywords_after_success(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("success old mcdonald\n") + self.keywords_before_test() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_keywords_after_test(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("failure a\n") + self.protocol.lineReceived("failure: a\n") + self.protocol.lineReceived("error a\n") + self.protocol.lineReceived("error: a\n") + self.protocol.lineReceived("success a\n") + self.protocol.lineReceived("success: a\n") + self.protocol.lineReceived("successful a\n") + self.protocol.lineReceived("successful: a\n") + self.protocol.lineReceived("]\n") + self.protocol.lineReceived("failure old mcdonald\n") + self.assertEqual(self.stdout.getvalue(), "test old mcdonald\n" + "failure a\n" + "failure: a\n" + "error a\n" + "error: a\n" + "success a\n" + "success: a\n" + "successful a\n" + "successful: a\n" + "]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError())]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_keywords_during_failure(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("failure: old mcdonald [\n") + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("failure a\n") + self.protocol.lineReceived("failure: a\n") + self.protocol.lineReceived("error a\n") + self.protocol.lineReceived("error: a\n") + self.protocol.lineReceived("success a\n") + self.protocol.lineReceived("success: a\n") + self.protocol.lineReceived("successful a\n") + self.protocol.lineReceived("successful: a\n") + self.protocol.lineReceived(" ]\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.stdout.getvalue(), "") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError("test old mcdonald\n" + "failure a\n" + "failure: a\n" + "error a\n" + "error: a\n" + "success a\n" + "success: a\n" + "successful a\n" + "successful: a\n" + "]\n"))]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_stdout_passthrough(self): + """Lines received which cannot be interpreted as any protocol action + should be passed through to sys.stdout. + """ + bytes = "randombytes\n" + self.protocol.lineReceived(bytes) + self.assertEqual(self.stdout.getvalue(), bytes) + + +class TestTestProtocolServerLostConnection(unittest.TestCase): + + def setUp(self): + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + self.test = subunit.RemotedTestCase("old mcdonald") + + def test_lost_connection_no_input(self): + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, []) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connection_after_start(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError("lost connection during " + "test 'old mcdonald'"))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connected_after_error(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("error old mcdonald\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError(""))]) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connection_during_error(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("error old mcdonald [\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError("lost connection during error " + "report of test 'old mcdonald'"))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connected_after_failure(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("failure old mcdonald\n") + self.protocol.lostConnection() + test = subunit.RemotedTestCase("old mcdonald") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError())]) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connection_during_failure(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("failure old mcdonald [\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, + [(self.test, + subunit.RemoteError("lost connection during " + "failure report" + " of test 'old mcdonald'"))]) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, []) + + def test_lost_connection_after_success(self): + self.protocol.lineReceived("test old mcdonald\n") + self.protocol.lineReceived("success old mcdonald\n") + self.protocol.lostConnection() + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + +class TestTestProtocolServerAddError(unittest.TestCase): + + def setUp(self): + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + self.protocol.lineReceived("test mcdonalds farm\n") + self.test = subunit.RemotedTestCase("mcdonalds farm") + + def simple_error_keyword(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm\n" % keyword) + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError(""))]) + self.assertEqual(self.client.failure_calls, []) + + def test_simple_error(self): + self.simple_error_keyword("error") + + def test_simple_error_colon(self): + self.simple_error_keyword("error:") + + def test_error_empty_message(self): + self.protocol.lineReceived("error mcdonalds farm [\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError(""))]) + self.assertEqual(self.client.failure_calls, []) + + def error_quoted_bracket(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) + self.protocol.lineReceived(" ]\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, [ + (self.test, subunit.RemoteError("]\n"))]) + self.assertEqual(self.client.failure_calls, []) + + def test_error_quoted_bracket(self): + self.error_quoted_bracket("error") + + def test_error_colon_quoted_bracket(self): + self.error_quoted_bracket("error:") + + +class TestTestProtocolServerAddFailure(unittest.TestCase): + + def setUp(self): + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + self.protocol.lineReceived("test mcdonalds farm\n") + self.test = subunit.RemotedTestCase("mcdonalds farm") + + def simple_failure_keyword(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm\n" % keyword) + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError())]) + + def test_simple_failure(self): + self.simple_failure_keyword("failure") + + def test_simple_failure_colon(self): + self.simple_failure_keyword("failure:") + + def test_failure_empty_message(self): + self.protocol.lineReceived("failure mcdonalds farm [\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError())]) + + def failure_quoted_bracket(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm [\n" % keyword) + self.protocol.lineReceived(" ]\n") + self.protocol.lineReceived("]\n") + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.failure_calls, + [(self.test, subunit.RemoteError("]\n"))]) + + def test_failure_quoted_bracket(self): + self.failure_quoted_bracket("failure") + + def test_failure_colon_quoted_bracket(self): + self.failure_quoted_bracket("failure:") + + +class TestTestProtocolServerAddSuccess(unittest.TestCase): + + def setUp(self): + self.client = MockTestProtocolServerClient() + self.protocol = subunit.TestProtocolServer(self.client) + self.protocol.lineReceived("test mcdonalds farm\n") + self.test = subunit.RemotedTestCase("mcdonalds farm") + + def simple_success_keyword(self, keyword): + self.protocol.lineReceived("%s mcdonalds farm\n" % keyword) + self.assertEqual(self.client.start_calls, [self.test]) + self.assertEqual(self.client.end_calls, [self.test]) + self.assertEqual(self.client.error_calls, []) + self.assertEqual(self.client.success_calls, [self.test]) + + def test_simple_success(self): + self.simple_success_keyword("failure") + + def test_simple_success_colon(self): + self.simple_success_keyword("failure:") + + def test_simple_success(self): + self.simple_success_keyword("successful") + + def test_simple_success_colon(self): + self.simple_success_keyword("successful:") + + +class TestRemotedTestCase(unittest.TestCase): + + def test_simple(self): + test = subunit.RemotedTestCase("A test description") + self.assertRaises(NotImplementedError, test.setUp) + self.assertRaises(NotImplementedError, test.tearDown) + self.assertEqual("A test description", + test.shortDescription()) + self.assertEqual("subunit.RemotedTestCase.A test description", + test.id()) + self.assertEqual("A test description (subunit.RemotedTestCase)", "%s" % test) + self.assertEqual("", "%r" % test) + result = unittest.TestResult() + test.run(result) + self.assertEqual([(test, "RemoteException: " + "Cannot run RemotedTestCases.\n\n")], + result.errors) + self.assertEqual(1, result.testsRun) + another_test = subunit.RemotedTestCase("A test description") + self.assertEqual(test, another_test) + different_test = subunit.RemotedTestCase("ofo") + self.assertNotEqual(test, different_test) + self.assertNotEqual(another_test, different_test) + + +class TestRemoteError(unittest.TestCase): + + def test_eq(self): + error = subunit.RemoteError("Something went wrong") + another_error = subunit.RemoteError("Something went wrong") + different_error = subunit.RemoteError("boo!") + self.assertEqual(error, another_error) + self.assertNotEqual(error, different_error) + self.assertNotEqual(different_error, another_error) + + def test_empty_constructor(self): + self.assertEqual(subunit.RemoteError(), subunit.RemoteError("")) + + +class TestExecTestCase(unittest.TestCase): + + class SampleExecTestCase(subunit.ExecTestCase): + + def test_sample_method(self): + """sample-script.py""" + # the sample script runs three tests, one each + # that fails, errors and succeeds + + + def test_construct(self): + test = self.SampleExecTestCase("test_sample_method") + self.assertEqual(test.script, + subunit.join_dir(__file__, 'sample-script.py')) + + def test_run(self): + runner = MockTestProtocolServerClient() + test = self.SampleExecTestCase("test_sample_method") + test.run(runner) + mcdonald = subunit.RemotedTestCase("old mcdonald") + bing = subunit.RemotedTestCase("bing crosby") + an_error = subunit.RemotedTestCase("an error") + self.assertEqual(runner.error_calls, + [(an_error, subunit.RemoteError())]) + self.assertEqual(runner.failure_calls, + [(bing, + subunit.RemoteError( + "foo.c:53:ERROR invalid state\n"))]) + self.assertEqual(runner.start_calls, [mcdonald, bing, an_error]) + self.assertEqual(runner.end_calls, [mcdonald, bing, an_error]) + + def test_debug(self): + test = self.SampleExecTestCase("test_sample_method") + test.debug() + + def test_count_test_cases(self): + """TODO run the child process and count responses to determine the count.""" + + def test_join_dir(self): + sibling = subunit.join_dir(__file__, 'foo') + expected = '%s/foo' % (os.path.split(__file__)[0],) + self.assertEqual(sibling, expected) + + +class DoExecTestCase(subunit.ExecTestCase): + + def test_working_script(self): + """sample-two-script.py""" + + +class TestIsolatedTestCase(unittest.TestCase): + + class SampleIsolatedTestCase(subunit.IsolatedTestCase): + + SETUP = False + TEARDOWN = False + TEST = False + + def setUp(self): + TestIsolatedTestCase.SampleIsolatedTestCase.SETUP = True + + def tearDown(self): + TestIsolatedTestCase.SampleIsolatedTestCase.TEARDOWN = True + + def test_sets_global_state(self): + TestIsolatedTestCase.SampleIsolatedTestCase.TEST = True + + + def test_construct(self): + test = self.SampleIsolatedTestCase("test_sets_global_state") + + def test_run(self): + result = unittest.TestResult() + test = self.SampleIsolatedTestCase("test_sets_global_state") + test.run(result) + self.assertEqual(result.testsRun, 1) + self.assertEqual(self.SampleIsolatedTestCase.SETUP, False) + self.assertEqual(self.SampleIsolatedTestCase.TEARDOWN, False) + self.assertEqual(self.SampleIsolatedTestCase.TEST, False) + + def test_debug(self): + pass + #test = self.SampleExecTestCase("test_sample_method") + #test.debug() + + +class TestIsolatedTestSuite(unittest.TestCase): + + class SampleTestToIsolate(unittest.TestCase): + + SETUP = False + TEARDOWN = False + TEST = False + + def setUp(self): + TestIsolatedTestSuite.SampleTestToIsolate.SETUP = True + + def tearDown(self): + TestIsolatedTestSuite.SampleTestToIsolate.TEARDOWN = True + + def test_sets_global_state(self): + TestIsolatedTestSuite.SampleTestToIsolate.TEST = True + + + def test_construct(self): + suite = subunit.IsolatedTestSuite() + + def test_run(self): + result = unittest.TestResult() + suite = subunit.IsolatedTestSuite() + sub_suite = unittest.TestSuite() + sub_suite.addTest(self.SampleTestToIsolate("test_sets_global_state")) + sub_suite.addTest(self.SampleTestToIsolate("test_sets_global_state")) + suite.addTest(sub_suite) + suite.addTest(self.SampleTestToIsolate("test_sets_global_state")) + suite.run(result) + self.assertEqual(result.testsRun, 3) + self.assertEqual(self.SampleTestToIsolate.SETUP, False) + self.assertEqual(self.SampleTestToIsolate.TEARDOWN, False) + self.assertEqual(self.SampleTestToIsolate.TEST, False) + + +class TestTestProtocolClient(unittest.TestCase): + + def setUp(self): + self.io = StringIO() + self.protocol = subunit.TestProtocolClient(self.io) + self.test = TestTestProtocolClient("test_start_test") + + + def test_start_test(self): + """Test startTest on a TestProtocolClient.""" + self.protocol.startTest(self.test) + self.assertEqual(self.io.getvalue(), "test: %s\n" % self.test.id()) + + def test_stop_test(self): + """Test stopTest on a TestProtocolClient.""" + self.protocol.stopTest(self.test) + self.assertEqual(self.io.getvalue(), "") + + def test_add_success(self): + """Test addSuccess on a TestProtocolClient.""" + self.protocol.addSuccess(self.test) + self.assertEqual( + self.io.getvalue(), "successful: %s\n" % self.test.id()) + + def test_add_failure(self): + """Test addFailure on a TestProtocolClient.""" + self.protocol.addFailure(self.test, subunit.RemoteError("boo")) + self.assertEqual( + self.io.getvalue(), + 'failure: %s [\nRemoteException: boo\n]\n' % self.test.id()) + + def test_add_error(self): + """Test stopTest on a TestProtocolClient.""" + self.protocol.addError(self.test, subunit.RemoteError("phwoar")) + self.assertEqual( + self.io.getvalue(), + 'error: %s [\n' + "RemoteException: phwoar\n" + "]\n" % self.test.id()) + + +def test_suite(): + loader = subunit.tests.TestUtil.TestLoader() + result = loader.loadTestsFromName(__name__) + return result diff --git a/source4/lib/talloc/Makefile.in b/lib/talloc/Makefile.in similarity index 67% rename from source4/lib/talloc/Makefile.in rename to lib/talloc/Makefile.in index 07b8fd4ff0..c28693e2db 100644 --- a/source4/lib/talloc/Makefile.in +++ b/lib/talloc/Makefile.in @@ -9,6 +9,7 @@ mandir = @mandir@ VPATH = @srcdir@:@libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ +sharedbuilddir = @sharedbuilddir@ XSLTPROC = @XSLTPROC@ INSTALLCMD = @INSTALL@ CC = @CC@ @@ -31,6 +32,15 @@ include $(tallocdir)/talloc.mk $(TALLOC_SOLIB): $(LIBOBJ) $(SHLD) $(SHLD_FLAGS) -o $@ $(LIBOBJ) @SONAMEFLAG@$(TALLOC_SONAME) +shared-build: all + ${INSTALLCMD} -d $(sharedbuilddir)/lib + ${INSTALLCMD} -m 644 libtalloc.a $(sharedbuilddir)/lib + ${INSTALLCMD} -m 755 $(TALLOC_SOLIB) $(sharedbuilddir)/lib + ln -sf $(TALLOC_SOLIB) $(sharedbuilddir)/lib/$(TALLOC_SONAME) + ln -sf $(TALLOC_SOLIB) $(sharedbuilddir)/lib/libtalloc.so + ${INSTALLCMD} -d $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(sharedbuilddir)/include + check: test installcheck:: test install diff --git a/source3/lib/talloc/NEWS b/lib/talloc/NEWS similarity index 100% rename from source3/lib/talloc/NEWS rename to lib/talloc/NEWS diff --git a/source3/lib/talloc/aclocal.m4 b/lib/talloc/aclocal.m4 similarity index 100% rename from source3/lib/talloc/aclocal.m4 rename to lib/talloc/aclocal.m4 diff --git a/source3/lib/talloc/autogen.sh b/lib/talloc/autogen.sh similarity index 100% rename from source3/lib/talloc/autogen.sh rename to lib/talloc/autogen.sh diff --git a/lib/talloc/build_macros.m4 b/lib/talloc/build_macros.m4 new file mode 100644 index 0000000000..c036668cd1 --- /dev/null +++ b/lib/talloc/build_macros.m4 @@ -0,0 +1,14 @@ +AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, + [ AC_ARG_WITH([shared-build-dir], + [AC_HELP_STRING([--with-shared-build-dir=DIR], + [temporary build directory where libraries are installed [$srcdir/sharedbuild]])]) + + sharedbuilddir="$srcdir/sharedbuild" + if test x"$with_shared_build_dir" != x; then + sharedbuilddir=$with_shared_build_dir + CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" + fi + AC_SUBST(sharedbuilddir) + ]) + diff --git a/source3/lib/talloc/config.guess b/lib/talloc/config.guess similarity index 100% rename from source3/lib/talloc/config.guess rename to lib/talloc/config.guess diff --git a/source3/lib/talloc/config.mk b/lib/talloc/config.mk similarity index 52% rename from source3/lib/talloc/config.mk rename to lib/talloc/config.mk index c13e1b79ab..5cdf3a1a8e 100644 --- a/source3/lib/talloc/config.mk +++ b/lib/talloc/config.mk @@ -1,7 +1,7 @@ [LIBRARY::LIBTALLOC] OUTPUT_TYPE = MERGED_OBJ -CFLAGS = -Ilib/talloc +CFLAGS = -I$(tallocsrcdir) -LIBTALLOC_OBJ_FILES = lib/talloc/talloc.o +LIBTALLOC_OBJ_FILES = $(tallocsrcdir)/talloc.o MANPAGES += $(tallocdir)/talloc.3 diff --git a/source3/lib/talloc/config.sub b/lib/talloc/config.sub similarity index 100% rename from source3/lib/talloc/config.sub rename to lib/talloc/config.sub diff --git a/source4/lib/talloc/configure.ac b/lib/talloc/configure.ac similarity index 87% rename from source4/lib/talloc/configure.ac rename to lib/talloc/configure.ac index 4719aa04b5..d2538f9222 100644 --- a/source4/lib/talloc/configure.ac +++ b/lib/talloc/configure.ac @@ -21,4 +21,7 @@ AC_LD_SONAMEFLAG AC_LIBREPLACE_SHLD AC_LIBREPLACE_SHLD_FLAGS +m4_include(build_macros.m4) +BUILD_WITH_SHARED_BUILD_DIR + AC_OUTPUT(Makefile talloc.pc) diff --git a/source3/lib/talloc/install-sh b/lib/talloc/install-sh similarity index 100% rename from source3/lib/talloc/install-sh rename to lib/talloc/install-sh diff --git a/source4/lib/talloc/libtalloc.m4 b/lib/talloc/libtalloc.m4 similarity index 94% rename from source4/lib/talloc/libtalloc.m4 rename to lib/talloc/libtalloc.m4 index fd2b4b22cd..e6830fbef6 100644 --- a/source4/lib/talloc/libtalloc.m4 +++ b/lib/talloc/libtalloc.m4 @@ -1,7 +1,7 @@ dnl find the talloc sources. This is meant to work both for dnl talloc standalone builds, and builds of packages using talloc tallocdir="" -tallocpaths=". lib/talloc talloc ../talloc" +tallocpaths=". lib/talloc talloc ../talloc ../lib/talloc" for d in $tallocpaths; do if test -f "$srcdir/$d/talloc.c"; then tallocdir="$d" diff --git a/source3/lib/talloc/rules.mk b/lib/talloc/rules.mk similarity index 100% rename from source3/lib/talloc/rules.mk rename to lib/talloc/rules.mk diff --git a/source3/lib/talloc/talloc.3.xml b/lib/talloc/talloc.3.xml similarity index 100% rename from source3/lib/talloc/talloc.3.xml rename to lib/talloc/talloc.3.xml diff --git a/source3/lib/talloc/talloc.c b/lib/talloc/talloc.c similarity index 100% rename from source3/lib/talloc/talloc.c rename to lib/talloc/talloc.c diff --git a/source3/lib/talloc/talloc.h b/lib/talloc/talloc.h similarity index 100% rename from source3/lib/talloc/talloc.h rename to lib/talloc/talloc.h diff --git a/source3/lib/talloc/talloc.i b/lib/talloc/talloc.i similarity index 100% rename from source3/lib/talloc/talloc.i rename to lib/talloc/talloc.i diff --git a/source4/lib/talloc/talloc.mk b/lib/talloc/talloc.mk similarity index 76% rename from source4/lib/talloc/talloc.mk rename to lib/talloc/talloc.mk index e1fe88c84b..f183cd57ef 100644 --- a/source4/lib/talloc/talloc.mk +++ b/lib/talloc/talloc.mk @@ -5,8 +5,8 @@ TALLOC_SONAME = libtalloc.$(SHLIBEXT).1 all:: libtalloc.a $(TALLOC_SOLIB) testsuite -testsuite:: $(LIBOBJ) testsuite.o - $(CC) $(CFLAGS) -o testsuite testsuite.o $(LIBOBJ) $(LIBS) +testsuite:: $(LIBOBJ) testsuite.o testsuite_main.o + $(CC) $(CFLAGS) -o testsuite testsuite.o testsuite_main.o $(LIBOBJ) $(LIBS) libtalloc.a: $(LIBOBJ) ar -rv $@ $(LIBOBJ) @@ -22,13 +22,13 @@ install:: all ${INSTALLCMD} -m 644 talloc.pc $(DESTDIR)$(libdir)/pkgconfig if [ -f talloc.3 ];then ${INSTALLCMD} -d $(DESTDIR)$(mandir)/man3; fi if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(DESTDIR)$(mandir)/man3; fi - which swig >/dev/null 2>&1 && ${INSTALLCMD} -d $(DESTDIR)`swig -swiglib` || true - which swig >/dev/null 2>&1 && ${INSTALLCMD} -m 644 talloc.i $(DESTDIR)`swig -swiglib` || true + which swig >/dev/null 2>&1 && ${INSTALLCMD} -d $(DESTDIR)$(prefix)`swig -swiglib` || true + which swig >/dev/null 2>&1 && ${INSTALLCMD} -m 644 talloc.i $(DESTDIR)$(prefix)`swig -swiglib` || true doc:: talloc.3 talloc.3.html clean:: - rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o *.gc?? talloc.3 talloc.3.html + rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o testsuite_main.o *.gc?? talloc.3 talloc.3.html test:: testsuite ./testsuite diff --git a/source3/lib/talloc/talloc.pc.in b/lib/talloc/talloc.pc.in similarity index 100% rename from source3/lib/talloc/talloc.pc.in rename to lib/talloc/talloc.pc.in diff --git a/source3/lib/talloc/talloc_guide.txt b/lib/talloc/talloc_guide.txt similarity index 97% rename from source3/lib/talloc/talloc_guide.txt rename to lib/talloc/talloc_guide.txt index 18663b370d..3201fe6f0f 100644 --- a/source3/lib/talloc/talloc_guide.txt +++ b/lib/talloc/talloc_guide.txt @@ -1,5 +1,7 @@ Using talloc in Samba4 ----------------------- +====================== + +.. contents:: Andrew Tridgell September 2004 @@ -18,7 +20,7 @@ get used to it. Perhaps the biggest change from Samba3 is that there is no distinction between a "talloc context" and a "talloc pointer". Any pointer returned from talloc() is itself a valid talloc context. This means -you can do this: +you can do this:: struct foo *X = talloc(mem_ctx, struct foo); X->name = talloc_strdup(X, "foo"); @@ -271,7 +273,7 @@ equivalent to: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- void *talloc_named_const(const void *context, size_t size, const char *name); -This is equivalent to: +This is equivalent to:: ptr = talloc_size(context, size); talloc_set_name_const(ptr, name); @@ -288,7 +290,7 @@ talloc_set_name() for details. void *talloc_init(const char *fmt, ...); This function creates a zero length named talloc context as a top -level context. It is equivalent to: +level context. It is equivalent to:: talloc_named(NULL, 0, fmt, ...); @@ -309,7 +311,7 @@ The talloc_realloc() macro changes the size of a talloc pointer. The "count" argument is the number of elements of type "type" that you want the resulting pointer to hold. -talloc_realloc() has the following equivalences: +talloc_realloc() has the following equivalences:: talloc_realloc(context, NULL, type, 1) ==> talloc(context, type); talloc_realloc(context, NULL, type, N) ==> talloc_array(context, type, N); @@ -490,7 +492,7 @@ This disables tracking of the NULL memory context. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- (type *)talloc_zero(const void *ctx, type); -The talloc_zero() macro is equivalent to: +The talloc_zero() macro is equivalent to:: ptr = talloc(ctx, type); if (ptr) memset(ptr, 0, sizeof(type)); @@ -505,7 +507,7 @@ The talloc_zero_size() function is useful when you don't have a known type =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- void *talloc_memdup(const void *ctx, const void *p, size_t size); -The talloc_memdup() function is equivalent to: +The talloc_memdup() function is equivalent to:: ptr = talloc_size(ctx, size); if (ptr) memcpy(ptr, p, size); @@ -514,13 +516,14 @@ The talloc_memdup() function is equivalent to: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- char *talloc_strdup(const void *ctx, const char *p); -The talloc_strdup() function is equivalent to: +The talloc_strdup() function is equivalent to:: ptr = talloc_size(ctx, strlen(p)+1); if (ptr) memcpy(ptr, p, strlen(p)+1); This functions sets the name of the new pointer to the passed -string. This is equivalent to: +string. This is equivalent to:: + talloc_set_name_const(ptr, ptr) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -540,7 +543,8 @@ The talloc_append_string() function appends the given formatted string to the given string. This function sets the name of the new pointer to the new -string. This is equivalent to: +string. This is equivalent to:: + talloc_set_name_const(ptr, ptr) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -550,7 +554,8 @@ The talloc_vasprintf() function is the talloc equivalent of the C library function vasprintf() This functions sets the name of the new pointer to the new -string. This is equivalent to: +string. This is equivalent to:: + talloc_set_name_const(ptr, ptr) @@ -561,7 +566,8 @@ The talloc_asprintf() function is the talloc equivalent of the C library function asprintf() This functions sets the name of the new pointer to the new -string. This is equivalent to: +string. This is equivalent to:: + talloc_set_name_const(ptr, ptr) @@ -574,7 +580,8 @@ Use this varient when the string in the current talloc buffer may have been truncated in length. This functions sets the name of the new pointer to the new -string. This is equivalent to: +string. This is equivalent to:: + talloc_set_name_const(ptr, ptr) @@ -587,14 +594,15 @@ Use this varient when the string in the current talloc buffer has not been changed. This functions sets the name of the new pointer to the new -string. This is equivalent to: +string. This is equivalent to:: + talloc_set_name_const(ptr, ptr) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ((type *)talloc_array(const void *ctx, type, uint_t count); -The talloc_array() macro is equivalent to: +The talloc_array() macro is equivalent to:: (type *)talloc_size(ctx, sizeof(type) * count); @@ -648,7 +656,7 @@ then the pointer is returned. It it doesn't then NULL is returned. This macro allows you to do type checking on talloc pointers. It is particularly useful for void* private pointers. It is equivalent to -this: +this:: (type *)talloc_check_name(ptr, #type) @@ -660,7 +668,8 @@ This macro allows you to force the name of a pointer to be a particular type. This can be used in conjunction with talloc_get_type() to do type checking on void* pointers. -It is equivalent to this: +It is equivalent to this:: + talloc_set_name_const(ptr, #type) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- diff --git a/source3/lib/talloc/testsuite.c b/lib/talloc/testsuite.c similarity index 99% rename from source3/lib/talloc/testsuite.c rename to lib/talloc/testsuite.c index 3f06eee566..3d490ddf49 100644 --- a/source3/lib/talloc/testsuite.c +++ b/lib/talloc/testsuite.c @@ -1140,13 +1140,3 @@ bool torture_local_talloc(struct torture_context *tctx) return ret; } - -#if _SAMBA_BUILD_ < 4 -int main(void) -{ - bool ret = torture_local_talloc(NULL); - if (!ret) - return -1; - return 0; -} -#endif diff --git a/source4/lib/replace/system/locale.h b/lib/talloc/testsuite_main.c similarity index 73% rename from source4/lib/replace/system/locale.h rename to lib/talloc/testsuite_main.c index e73a9bb274..1b51333278 100644 --- a/source4/lib/replace/system/locale.h +++ b/lib/talloc/testsuite_main.c @@ -1,17 +1,14 @@ -#ifndef _system_locale_h -#define _system_locale_h - -/* +/* Unix SMB/CIFS implementation. - locale include wrappers + local testing of talloc routines. Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace + + ** NOTE! The following LGPL license applies to the talloc ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -24,15 +21,17 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, see . - */ -#ifdef HAVE_CTYPE_H -#include -#endif +#include "replace.h" -#ifdef HAVE_LOCALE_H -#include -#endif +struct torture_context; +bool torture_local_talloc(struct torture_context *tctx); -#endif +int main(void) +{ + bool ret = torture_local_talloc(NULL); + if (!ret) + return -1; + return 0; +} diff --git a/source3/lib/talloc/web/index.html b/lib/talloc/web/index.html similarity index 100% rename from source3/lib/talloc/web/index.html rename to lib/talloc/web/index.html diff --git a/source3/lib/tdb/Makefile.in b/lib/tdb/Makefile.in similarity index 73% rename from source3/lib/tdb/Makefile.in rename to lib/tdb/Makefile.in index 090bb6e2dc..9915d88264 100644 --- a/source3/lib/tdb/Makefile.in +++ b/lib/tdb/Makefile.in @@ -12,6 +12,8 @@ libdir = @libdir@ VPATH = @srcdir@:@libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ +sharedbuilddir = @sharedbuilddir@ +INSTALLCMD = @INSTALL@ CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude CFLAGS = $(CPPFLAGS) @CFLAGS@ LDFLAGS = @LDFLAGS@ @@ -43,6 +45,15 @@ install:: all $(TDB_SOLIB): $(TDB_OBJ) $(SHLD) $(SHLD_FLAGS) -o $@ $(TDB_OBJ) @SONAMEFLAG@$(TDB_SONAME) +shared-build: all + ${INSTALLCMD} -d $(sharedbuilddir)/lib + ${INSTALLCMD} -m 644 libtdb.a $(sharedbuilddir)/lib + ${INSTALLCMD} -m 755 $(TDB_SOLIB) $(sharedbuilddir)/lib + ln -sf $(TDB_SOLIB) $(sharedbuilddir)/lib/$(TDB_SONAME) + ln -sf $(TDB_SOLIB) $(sharedbuilddir)/lib/libtdb.so + ${INSTALLCMD} -d $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 $(srcdir)/include/tdb.h $(sharedbuilddir)/include + check: test test:: $(PYTHON_CHECK_TARGET) diff --git a/source3/lib/tdb/aclocal.m4 b/lib/tdb/aclocal.m4 similarity index 100% rename from source3/lib/tdb/aclocal.m4 rename to lib/tdb/aclocal.m4 diff --git a/source3/lib/tdb/autogen.sh b/lib/tdb/autogen.sh similarity index 100% rename from source3/lib/tdb/autogen.sh rename to lib/tdb/autogen.sh diff --git a/lib/tdb/build_macros.m4 b/lib/tdb/build_macros.m4 new file mode 100644 index 0000000000..c036668cd1 --- /dev/null +++ b/lib/tdb/build_macros.m4 @@ -0,0 +1,14 @@ +AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, + [ AC_ARG_WITH([shared-build-dir], + [AC_HELP_STRING([--with-shared-build-dir=DIR], + [temporary build directory where libraries are installed [$srcdir/sharedbuild]])]) + + sharedbuilddir="$srcdir/sharedbuild" + if test x"$with_shared_build_dir" != x; then + sharedbuilddir=$with_shared_build_dir + CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" + fi + AC_SUBST(sharedbuilddir) + ]) + diff --git a/source3/lib/tdb/common/dump.c b/lib/tdb/common/dump.c similarity index 100% rename from source3/lib/tdb/common/dump.c rename to lib/tdb/common/dump.c diff --git a/source3/lib/tdb/common/error.c b/lib/tdb/common/error.c similarity index 100% rename from source3/lib/tdb/common/error.c rename to lib/tdb/common/error.c diff --git a/source3/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c similarity index 100% rename from source3/lib/tdb/common/freelist.c rename to lib/tdb/common/freelist.c diff --git a/source3/lib/tdb/common/freelistcheck.c b/lib/tdb/common/freelistcheck.c similarity index 100% rename from source3/lib/tdb/common/freelistcheck.c rename to lib/tdb/common/freelistcheck.c diff --git a/source3/lib/tdb/common/io.c b/lib/tdb/common/io.c similarity index 100% rename from source3/lib/tdb/common/io.c rename to lib/tdb/common/io.c diff --git a/source3/lib/tdb/common/lock.c b/lib/tdb/common/lock.c similarity index 100% rename from source3/lib/tdb/common/lock.c rename to lib/tdb/common/lock.c diff --git a/source3/lib/tdb/common/open.c b/lib/tdb/common/open.c similarity index 100% rename from source3/lib/tdb/common/open.c rename to lib/tdb/common/open.c diff --git a/source3/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c similarity index 100% rename from source3/lib/tdb/common/tdb.c rename to lib/tdb/common/tdb.c diff --git a/source3/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h similarity index 100% rename from source3/lib/tdb/common/tdb_private.h rename to lib/tdb/common/tdb_private.h diff --git a/source3/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c similarity index 100% rename from source3/lib/tdb/common/transaction.c rename to lib/tdb/common/transaction.c diff --git a/source3/lib/tdb/common/traverse.c b/lib/tdb/common/traverse.c similarity index 100% rename from source3/lib/tdb/common/traverse.c rename to lib/tdb/common/traverse.c diff --git a/source3/lib/tdb/config.guess b/lib/tdb/config.guess similarity index 100% rename from source3/lib/tdb/config.guess rename to lib/tdb/config.guess diff --git a/source4/lib/tdb/config.mk b/lib/tdb/config.mk similarity index 79% rename from source4/lib/tdb/config.mk rename to lib/tdb/config.mk index b9a8f80dda..90c9ba2863 100644 --- a/source4/lib/tdb/config.mk +++ b/lib/tdb/config.mk @@ -2,12 +2,12 @@ # Start SUBSYSTEM LIBTDB [LIBRARY::LIBTDB] OUTPUT_TYPE = STATIC_LIBRARY -CFLAGS = -Ilib/tdb/include +CFLAGS = -I$(tdbsrcdir)/include # # End SUBSYSTEM ldb ################################################ -LIBTDB_OBJ_FILES = $(addprefix lib/tdb/common/, \ +LIBTDB_OBJ_FILES = $(addprefix $(tdbsrcdir)/common/, \ tdb.o dump.o io.o lock.o \ open.o traverse.o freelist.o \ error.o transaction.o) @@ -21,7 +21,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY tdbtool ################################################ -tdbtool_OBJ_FILES = lib/tdb/tools/tdbtool.o +tdbtool_OBJ_FILES = $(tdbsrcdir)/tools/tdbtool.o ################################################ # Start BINARY tdbtorture @@ -32,7 +32,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY tdbtorture ################################################ -tdbtorture_OBJ_FILES = lib/tdb/tools/tdbtorture.o +tdbtorture_OBJ_FILES = $(tdbsrcdir)/tools/tdbtorture.o ################################################ # Start BINARY tdbdump @@ -43,7 +43,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY tdbdump ################################################ -tdbdump_OBJ_FILES = lib/tdb/tools/tdbdump.o +tdbdump_OBJ_FILES = $(tdbsrcdir)/tools/tdbdump.o ################################################ # Start BINARY tdbbackup @@ -54,4 +54,4 @@ PRIVATE_DEPENDENCIES = \ # End BINARY tdbbackup ################################################ -tdbbackup_OBJ_FILES = lib/tdb/tools/tdbbackup.o +tdbbackup_OBJ_FILES = $(tdbsrcdir)/tools/tdbbackup.o diff --git a/source3/lib/tdb/config.sub b/lib/tdb/config.sub similarity index 100% rename from source3/lib/tdb/config.sub rename to lib/tdb/config.sub diff --git a/source3/lib/tdb/configure.ac b/lib/tdb/configure.ac similarity index 91% rename from source3/lib/tdb/configure.ac rename to lib/tdb/configure.ac index eaf70d30b4..2feaa6f5f5 100644 --- a/source3/lib/tdb/configure.ac +++ b/lib/tdb/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.50) AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) AC_DEFUN([SMB_ENABLE], [echo -n ""]) -AC_INIT(tdb, 1.1.2) +AC_INIT(tdb, 1.1.3) AC_CONFIG_SRCDIR([common/tdb.c]) AC_CONFIG_HEADER(include/config.h) AC_LIBREPLACE_ALL_CHECKS @@ -27,4 +27,8 @@ if test -z "$PYTHON_CONFIG"; then PYTHON_INSTALL_TARGET="" PYTHON_CHECK_TARGET="" fi + +m4_include(build_macros.m4) +BUILD_WITH_SHARED_BUILD_DIR + AC_OUTPUT(Makefile tdb.pc) diff --git a/source3/lib/tdb/docs/README b/lib/tdb/docs/README similarity index 100% rename from source3/lib/tdb/docs/README rename to lib/tdb/docs/README diff --git a/source3/lib/tdb/docs/tdb.magic b/lib/tdb/docs/tdb.magic similarity index 100% rename from source3/lib/tdb/docs/tdb.magic rename to lib/tdb/docs/tdb.magic diff --git a/source3/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h similarity index 99% rename from source3/lib/tdb/include/tdb.h rename to lib/tdb/include/tdb.h index 0008085de5..c41c9941f0 100644 --- a/source3/lib/tdb/include/tdb.h +++ b/lib/tdb/include/tdb.h @@ -30,6 +30,7 @@ extern "C" { #endif +#include "signal.h" /* flags to tdb_store() */ #define TDB_REPLACE 1 /* Unused */ diff --git a/source3/lib/tdb/install-sh b/lib/tdb/install-sh similarity index 100% rename from source3/lib/tdb/install-sh rename to lib/tdb/install-sh diff --git a/source4/lib/tdb/libtdb.m4 b/lib/tdb/libtdb.m4 similarity index 91% rename from source4/lib/tdb/libtdb.m4 rename to lib/tdb/libtdb.m4 index 1e17a7a4f2..252e0b0be3 100644 --- a/source4/lib/tdb/libtdb.m4 +++ b/lib/tdb/libtdb.m4 @@ -1,7 +1,7 @@ dnl find the tdb sources. This is meant to work both for dnl tdb standalone builds, and builds of packages using tdb tdbdir="" -tdbpaths="$srcdir $srcdir/lib/tdb $srcdir/tdb $srcdir/../tdb" +tdbpaths="$srcdir $srcdir/lib/tdb $srcdir/tdb $srcdir/../tdb $srcdir/../lib/tdb" for d in $tdbpaths; do if test -f "$d/common/tdb.c"; then tdbdir="$d" diff --git a/source3/lib/tdb/python.mk b/lib/tdb/python.mk similarity index 100% rename from source3/lib/tdb/python.mk rename to lib/tdb/python.mk diff --git a/source3/lib/tdb/python/tdbdump.py b/lib/tdb/python/tdbdump.py similarity index 100% rename from source3/lib/tdb/python/tdbdump.py rename to lib/tdb/python/tdbdump.py diff --git a/source3/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py similarity index 100% rename from source3/lib/tdb/python/tests/simple.py rename to lib/tdb/python/tests/simple.py diff --git a/source3/lib/tdb/rules.mk b/lib/tdb/rules.mk similarity index 100% rename from source3/lib/tdb/rules.mk rename to lib/tdb/rules.mk diff --git a/source4/lib/tdb/tdb.i b/lib/tdb/tdb.i similarity index 99% rename from source4/lib/tdb/tdb.i rename to lib/tdb/tdb.i index 3d8b697732..4b529913d7 100644 --- a/source4/lib/tdb/tdb.i +++ b/lib/tdb/tdb.i @@ -321,3 +321,8 @@ typedef struct tdb_context { # TODO: any other missing methods for container types } } tdb; + +%pythoncode { +__docformat__ = 'restructuredText' +open = Tdb +} diff --git a/source3/lib/tdb/tdb.mk b/lib/tdb/tdb.mk similarity index 100% rename from source3/lib/tdb/tdb.mk rename to lib/tdb/tdb.mk diff --git a/source3/lib/tdb/tdb.pc.in b/lib/tdb/tdb.pc.in similarity index 100% rename from source3/lib/tdb/tdb.pc.in rename to lib/tdb/tdb.pc.in diff --git a/source4/lib/tdb/tdb.py b/lib/tdb/tdb.py similarity index 99% rename from source4/lib/tdb/tdb.py rename to lib/tdb/tdb.py index 9f306bab8c..42129d2091 100644 --- a/source4/lib/tdb/tdb.py +++ b/lib/tdb/tdb.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. @@ -337,5 +337,8 @@ Tdb.name = new_instancemethod(_tdb.Tdb_name,None,Tdb) Tdb_swigregister = _tdb.Tdb_swigregister Tdb_swigregister(Tdb) +__docformat__ = 'restructuredText' +open = Tdb + diff --git a/source3/lib/tdb/tdb_wrap.c b/lib/tdb/tdb_wrap.c similarity index 99% rename from source3/lib/tdb/tdb_wrap.c rename to lib/tdb/tdb_wrap.c index 32665d79fd..e997e88572 100644 --- a/source3/lib/tdb/tdb_wrap.c +++ b/lib/tdb/tdb_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2518,7 +2524,7 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; #define SWIG_name "_tdb" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2818,7 +2824,6 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg int arg3 ; int arg4 ; mode_t arg5 ; - tdb *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2838,6 +2843,7 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg char * kwnames[] = { (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "flags",(char *) "mode", NULL }; + tdb *result = 0 ; arg2 = 0; arg3 = TDB_DEFAULT; @@ -2895,10 +2901,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - enum TDB_ERROR result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + enum TDB_ERROR result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2930,7 +2936,6 @@ SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject * } arg1 = (tdb *)(argp1); delete_tdb(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -2941,10 +2946,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2966,7 +2971,6 @@ SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject * tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; TDB_DATA arg3 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -2975,6 +2979,7 @@ SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "key",(char *) "new_dbuf", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3013,10 +3018,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3037,7 +3042,6 @@ SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - TDB_DATA result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3045,6 +3049,7 @@ SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + TDB_DATA result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3079,7 +3084,6 @@ SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3087,6 +3091,7 @@ SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3118,7 +3123,6 @@ SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a TDB_DATA arg2 ; TDB_DATA arg3 ; int arg4 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int val4 ; @@ -3130,6 +3134,7 @@ SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a char * kwnames[] = { (char *) "self",(char *) "key",(char *) "dbuf",(char *) "flag", NULL }; + int result; arg4 = TDB_REPLACE; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; @@ -3177,7 +3182,6 @@ SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3185,6 +3189,7 @@ SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3213,10 +3218,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - TDB_DATA result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + TDB_DATA result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3242,7 +3247,6 @@ SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - TDB_DATA result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3250,6 +3254,7 @@ SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + TDB_DATA result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3283,10 +3288,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3306,10 +3311,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3329,10 +3334,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3352,10 +3357,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3375,10 +3380,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3398,10 +3403,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3421,10 +3426,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3444,10 +3449,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3467,10 +3472,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3490,10 +3495,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3513,10 +3518,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - size_t result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + size_t result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3536,10 +3541,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3592,10 +3597,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; diff --git a/source3/lib/tdb/tools/tdbbackup.c b/lib/tdb/tools/tdbbackup.c similarity index 100% rename from source3/lib/tdb/tools/tdbbackup.c rename to lib/tdb/tools/tdbbackup.c diff --git a/source3/lib/tdb/tools/tdbdump.c b/lib/tdb/tools/tdbdump.c similarity index 100% rename from source3/lib/tdb/tools/tdbdump.c rename to lib/tdb/tools/tdbdump.c diff --git a/source3/lib/tdb/tools/tdbtest.c b/lib/tdb/tools/tdbtest.c similarity index 100% rename from source3/lib/tdb/tools/tdbtest.c rename to lib/tdb/tools/tdbtest.c diff --git a/source3/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c similarity index 100% rename from source3/lib/tdb/tools/tdbtool.c rename to lib/tdb/tools/tdbtool.c diff --git a/source3/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c similarity index 100% rename from source3/lib/tdb/tools/tdbtorture.c rename to lib/tdb/tools/tdbtorture.c diff --git a/source3/lib/tdb/web/index.html b/lib/tdb/web/index.html similarity index 100% rename from source3/lib/tdb/web/index.html rename to lib/tdb/web/index.html diff --git a/source4/lib/util/Doxyfile b/lib/util/Doxyfile similarity index 100% rename from source4/lib/util/Doxyfile rename to lib/util/Doxyfile diff --git a/lib/util/README b/lib/util/README new file mode 100644 index 0000000000..fffd44d580 --- /dev/null +++ b/lib/util/README @@ -0,0 +1,6 @@ +This directory contains libutil (until we can think of a better name) + +The idea is that this library contains simple but useful data structures +and support functions that are generally useful; not just for Samba but for +other projects as well. Functions here should not depend on any external +libraries, just on libc (perhaps partially provided by libreplace). diff --git a/source4/lib/util/asn1.c b/lib/util/asn1.c similarity index 99% rename from source4/lib/util/asn1.c rename to lib/util/asn1.c index 4756c0640d..ef346542a6 100644 --- a/source4/lib/util/asn1.c +++ b/lib/util/asn1.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/util/asn1.h" +#include "../lib/util/asn1.h" /* allocate an asn1 structure */ struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx) diff --git a/source4/lib/util/asn1.h b/lib/util/asn1.h similarity index 97% rename from source4/lib/util/asn1.h rename to lib/util/asn1.h index 34aa1e2cb9..c8e83b9266 100644 --- a/source4/lib/util/asn1.h +++ b/lib/util/asn1.h @@ -49,6 +49,6 @@ struct asn1_data { #define ASN1_MAX_OIDS 20 -#include "lib/util/asn1_proto.h" +#include "../lib/util/asn1_proto.h" #endif /* _ASN_1_H */ diff --git a/source4/lib/util/attr.h b/lib/util/attr.h similarity index 100% rename from source4/lib/util/attr.h rename to lib/util/attr.h diff --git a/source4/lib/util/become_daemon.c b/lib/util/become_daemon.c similarity index 100% rename from source4/lib/util/become_daemon.c rename to lib/util/become_daemon.c diff --git a/source4/lib/util/byteorder.h b/lib/util/byteorder.h similarity index 100% rename from source4/lib/util/byteorder.h rename to lib/util/byteorder.h diff --git a/source4/lib/util/capability.c b/lib/util/capability.c similarity index 100% rename from source4/lib/util/capability.c rename to lib/util/capability.c diff --git a/source4/lib/util/capability.m4 b/lib/util/capability.m4 similarity index 100% rename from source4/lib/util/capability.m4 rename to lib/util/capability.m4 diff --git a/source4/lib/util/config.mk b/lib/util/config.mk similarity index 93% rename from source4/lib/util/config.mk rename to lib/util/config.mk index 925713a53c..5488534f26 100644 --- a/source4/lib/util/config.mk +++ b/lib/util/config.mk @@ -14,15 +14,18 @@ LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \ genrand.o \ dprintf.o \ util_str.o \ + substitute.o \ util_strlist.o \ util_file.o \ data_blob.o \ util.o \ + util_net.o \ fsusage.o \ ms_fnmatch.o \ mutex.o \ idtree.o \ become_daemon.o \ + rbtree.o \ params.o) PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \ @@ -63,8 +66,6 @@ PUBLIC_DEPENDENCIES = LIBTDB UTIL_TDB_OBJ_FILES = $(libutilsrcdir)/util_tdb.o -$(eval $(call proto_header_template,$(libutilsrcdir)/util_tdb.h,$(UTIL_TDB_OBJ_FILES:.o=.c))) - [SUBSYSTEM::UTIL_LDB] PUBLIC_DEPENDENCIES = LIBLDB diff --git a/source4/lib/util/data_blob.c b/lib/util/data_blob.c similarity index 93% rename from source4/lib/util/data_blob.c rename to lib/util/data_blob.c index 57b34b7ae7..c7d01bacc7 100644 --- a/source4/lib/util/data_blob.c +++ b/lib/util/data_blob.c @@ -20,6 +20,8 @@ #include "includes.h" +const DATA_BLOB data_blob_null = { NULL, 0 }; + /** * @file * @brief Manipulation of arbitrary data blobs @@ -180,6 +182,18 @@ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str) return blob; } +/** + useful for constructing data blobs in test suites, while + avoiding const warnings +**/ +_PUBLIC_ DATA_BLOB data_blob_string_const_null(const char *str) +{ + DATA_BLOB blob; + blob.data = discard_const_p(uint8_t, str); + blob.length = str ? strlen(str)+1 : 0; + return blob; +} + /** * Create a new data blob from const data */ diff --git a/source4/lib/util/data_blob.h b/lib/util/data_blob.h similarity index 92% rename from source4/lib/util/data_blob.h rename to lib/util/data_blob.h index e9dca67772..ffde51cf33 100644 --- a/source4/lib/util/data_blob.h +++ b/lib/util/data_blob.h @@ -104,6 +104,14 @@ _PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob); **/ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str); +/** + useful for constructing data blobs in test suites, while + avoiding const warnings + + includes the terminating null character (as opposed to data_blo_string_const) +**/ +_PUBLIC_ DATA_BLOB data_blob_string_const_null(const char *str); + /** * Create a new data blob from const data */ @@ -120,4 +128,6 @@ _PUBLIC_ bool data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t len _PUBLIC_ bool data_blob_append(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const void *p, size_t length); +extern const DATA_BLOB data_blob_null; + #endif /* _SAMBA_DATABLOB_H_ */ diff --git a/source4/lib/util/debug.c b/lib/util/debug.c similarity index 89% rename from source4/lib/util/debug.c rename to lib/util/debug.c index 00dcbfc8bd..98aabc554b 100644 --- a/source4/lib/util/debug.c +++ b/lib/util/debug.c @@ -31,7 +31,13 @@ /** * this global variable determines what messages are printed */ -_PUBLIC_ int DEBUGLEVEL; +int _debug_level = 0; +_PUBLIC_ int *debug_level = &_debug_level; +static int debug_all_class_hack = 1; +int *DEBUGLEVEL_CLASS = &debug_all_class_hack; /* For samba 3 */ +static bool debug_all_class_isset_hack = true; +bool *DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack; /* For samba 3 */ +XFILE *dbf = NULL; /* For Samba 3*/ /* the registered mutex handlers */ static struct { @@ -89,12 +95,19 @@ static void log_timestring(int level, const char *location, const char *func) the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called */ -_PUBLIC_ void do_debug_header(int level, const char *location, const char *func) +_PUBLIC_ void dbghdr(int level, const char *location, const char *func) { log_timestring(level, location, func); log_task_id(); } + +_PUBLIC_ void dbghdrclass(int level, int class, const char *location, const char *func) +{ + /* Simple wrapper, Samba 4 doesn't do debug classes */ + dbghdr(level, location, func); +} + /** the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called @@ -102,7 +115,7 @@ _PUBLIC_ void do_debug_header(int level, const char *location, const char *func) @note You should never have to call this function directly. Call the DEBUG() macro instead. */ -_PUBLIC_ void do_debug(const char *format, ...) +_PUBLIC_ void dbgtext(const char *format, ...) { va_list ap; char *s = NULL; diff --git a/source4/lib/util/debug.h b/lib/util/debug.h similarity index 91% rename from source4/lib/util/debug.h rename to lib/util/debug.h index 605628174a..8c634f910a 100644 --- a/source4/lib/util/debug.h +++ b/lib/util/debug.h @@ -39,6 +39,7 @@ struct debug_ops { void (*log_task_id)(int fd); }; +#define DEBUGLEVEL *debug_level extern int DEBUGLEVEL; #define debug_ctx() (_debug_ctx?_debug_ctx:(_debug_ctx=talloc_new(NULL))) @@ -48,9 +49,9 @@ extern int DEBUGLEVEL; if (DEBUGLVL(level)) { \ void* _debug_ctx=NULL; \ if (header) { \ - do_debug_header(level, __location__, __FUNCTION__); \ + dbghdr(level, __location__, __FUNCTION__); \ } \ - do_debug body; \ + dbgtext body; \ talloc_free(_debug_ctx); \ } \ } while (0) @@ -77,7 +78,9 @@ enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2}; the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called */ -_PUBLIC_ void do_debug_header(int level, const char *location, const char *func); +_PUBLIC_ void dbghdr(int level, const char *location, const char *func); + +_PUBLIC_ void dbghdrclass(int level, int class, const char *location, const char *func); /** reopen the log file (usually called because the log file name might have changed) @@ -125,4 +128,6 @@ _PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops); @note You should never have to call this function directly. Call the DEBUG() macro instead. */ -_PUBLIC_ void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1,2); +_PUBLIC_ void dbgtext(const char *format, ...) PRINTF_ATTRIBUTE(1,2); + +extern XFILE *dbf; diff --git a/source3/include/dlinklist.h b/lib/util/dlinklist.h similarity index 100% rename from source3/include/dlinklist.h rename to lib/util/dlinklist.h diff --git a/source4/lib/util/dprintf.c b/lib/util/dprintf.c similarity index 100% rename from source4/lib/util/dprintf.c rename to lib/util/dprintf.c diff --git a/source4/lib/util/fault.c b/lib/util/fault.c similarity index 100% rename from source4/lib/util/fault.c rename to lib/util/fault.c diff --git a/source4/lib/util/fault.m4 b/lib/util/fault.m4 similarity index 100% rename from source4/lib/util/fault.m4 rename to lib/util/fault.m4 diff --git a/source4/lib/util/fsusage.c b/lib/util/fsusage.c similarity index 92% rename from source4/lib/util/fsusage.c rename to lib/util/fsusage.c index 43c8787216..e5f2678a9f 100644 --- a/source4/lib/util/fsusage.c +++ b/lib/util/fsusage.c @@ -19,7 +19,7 @@ #include "includes.h" #include "system/filesys.h" - + /** * @file * @brief Utility functions for getting the amount of free disk space @@ -30,12 +30,17 @@ */ static uint64_t adjust_blocks(uint64_t blocks, uint64_t fromsize, uint64_t tosize) { - if (fromsize == tosize) /* e.g., from 512 to 512 */ + if (fromsize == tosize) { /* e.g., from 512 to 512 */ return blocks; - else if (fromsize > tosize) /* e.g., from 2048 to 512 */ + } else if (fromsize > tosize) { /* e.g., from 2048 to 512 */ return blocks * (fromsize / tosize); - else /* e.g., from 256 to 512 */ + } else { /* e.g., from 256 to 512 */ + /* Protect against broken filesystems... */ + if (fromsize == 0) { + fromsize = tosize; + } return (blocks + 1) / (tosize / fromsize); + } } /** @@ -124,8 +129,13 @@ _PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize) #endif /* STAT_STATFS4 */ #if defined(STAT_STATVFS) || defined(STAT_STATVFS64) /* SVR4 */ +#ifdef HAVE_FRSIZE # define CONVERT_BLOCKS(B) \ adjust_blocks ((uint64_t)(B), fsd.f_frsize ? (uint64_t)fsd.f_frsize : (uint64_t)fsd.f_bsize, (uint64_t)512) +#else +# define CONVERT_BLOCKS(B) \ + adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_bsize, (uint64_t)512) +#endif #ifdef STAT_STATVFS64 struct statvfs64 fsd; diff --git a/source4/lib/util/fsusage.m4 b/lib/util/fsusage.m4 similarity index 92% rename from source4/lib/util/fsusage.m4 rename to lib/util/fsusage.m4 index 6d5d13fe25..843965041f 100644 --- a/source4/lib/util/fsusage.m4 +++ b/lib/util/fsusage.m4 @@ -54,6 +54,16 @@ if test $space = no; then fi fi +# fsusage.c assumes that statvfs has an f_frsize entry. Some weird +# systems use f_bsize. +AC_CACHE_CHECK([that statvfs.f_frsize works],samba_cv_frsize, [ + AC_TRY_COMPILE([#include +#include ],[struct statvfs buf; buf.f_frsize = 0], + samba_cv_frsize=yes,samba_cv_frsize=no)]) +if test x"$samba_cv_frsize" = x"yes"; then + AC_DEFINE(HAVE_FRSIZE, 1, [Whether statvfs.f_frsize exists]) +fi + if test $space = no; then # DEC Alpha running OSF/1 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) diff --git a/source4/lib/util/genrand.c b/lib/util/genrand.c similarity index 99% rename from source4/lib/util/genrand.c rename to lib/util/genrand.c index 7df4ec4e20..cd1823a9a0 100644 --- a/source4/lib/util/genrand.c +++ b/lib/util/genrand.c @@ -21,7 +21,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "system/locale.h" /** diff --git a/source4/lib/util/idtree.c b/lib/util/idtree.c similarity index 96% rename from source4/lib/util/idtree.c rename to lib/util/idtree.c index 1e2cc2976a..193922973f 100644 --- a/source4/lib/util/idtree.c +++ b/lib/util/idtree.c @@ -12,7 +12,7 @@ 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 + 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, @@ -105,12 +105,13 @@ static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id) int n, m, sh; struct idr_layer *p, *new; struct idr_layer *pa[MAX_LEVEL]; - int l, id; + int l, id, oid; uint32_t bm; memset(pa, 0, sizeof(pa)); id = *starting_id; +restart: p = idp->top; l = idp->layers; pa[l--] = NULL; @@ -124,12 +125,23 @@ static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id) if (m == IDR_SIZE) { /* no space available go back to previous layer. */ l++; + oid = id; id = (id | ((1 << (IDR_BITS*l))-1)) + 1; + + /* if already at the top layer, we need to grow */ if (!(p = pa[l])) { *starting_id = id; return -2; } + + /* If we need to go up one layer, continue the + * loop; otherwise, restart from the top. + */ + sh = IDR_BITS * (l + 1); + if (oid >> sh == id >> sh) continue; + else + goto restart; } if (m != n) { sh = IDR_BITS*l; diff --git a/source4/lib/util/mainpage.dox b/lib/util/mainpage.dox similarity index 100% rename from source4/lib/util/mainpage.dox rename to lib/util/mainpage.dox diff --git a/lib/util/memory.h b/lib/util/memory.h new file mode 100644 index 0000000000..cfc13ab836 --- /dev/null +++ b/lib/util/memory.h @@ -0,0 +1,118 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Andrew Tridgell 1992-1999 + Copyright (C) Jelmer Vernooij 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 . +*/ + +#ifndef _SAMBA_MEMORY_H_ +#define _SAMBA_MEMORY_H_ + +#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */ +/** + * Free memory if the pointer and zero the pointer. + * + * @note You are explicitly allowed to pass NULL pointers -- they will + * always be ignored. + **/ +#define SAFE_FREE(x) do { if ((x) != NULL) {free(discard_const_p(void *, (x))); (x)=NULL;} } while(0) +#endif + +/** + * Type-safe version of malloc. Allocated one copy of the + * specified data type. + */ +#define malloc_p(type) (type *)malloc(sizeof(type)) + +/** + * Allocate an array of elements of one data type. Does type-checking. + */ +#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count, false) + +/** + * Resize an array of elements of one data type. Does type-checking. + */ +#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count, false) + +/** + * zero a structure + */ +#ifndef ZERO_STRUCT +#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) +#endif + +/** + * zero a structure given a pointer to the structure + */ +#ifndef ZERO_STRUCTP +#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) +#endif + +/** + * zero a structure given a pointer to the structure - no zero check + */ +#ifndef ZERO_STRUCTPN +#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) +#endif + +/* zero an array - note that sizeof(array) must work - ie. it must not be a + pointer */ +#ifndef ZERO_ARRAY +#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) +#endif + +/** + * work out how many elements there are in a static array + */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) +#endif + +/** + * pointer difference macro + */ +#ifndef PTR_DIFF +#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) +#endif + +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#ifndef discard_const +#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) +#endif + +/** Type-safe version of discard_const */ +#ifndef discard_const_p +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#endif + +#endif /* _SAMBA_MEMORY_H_ */ diff --git a/source4/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c similarity index 100% rename from source4/lib/util/ms_fnmatch.c rename to lib/util/ms_fnmatch.c diff --git a/source4/lib/util/mutex.c b/lib/util/mutex.c similarity index 100% rename from source4/lib/util/mutex.c rename to lib/util/mutex.c diff --git a/source4/lib/util/mutex.h b/lib/util/mutex.h similarity index 100% rename from source4/lib/util/mutex.h rename to lib/util/mutex.h diff --git a/source4/lib/util/params.c b/lib/util/params.c similarity index 99% rename from source4/lib/util/params.c rename to lib/util/params.c index 3a9e2b9505..7af7ac7348 100644 --- a/source4/lib/util/params.c +++ b/lib/util/params.c @@ -105,11 +105,6 @@ static int mygetc(myFILE *f) return (int)( *(f->p++) & 0x00FF ); } -static void myfile_close(myFILE *f) -{ - talloc_free(f); -} - /* -------------------------------------------------------------------------- ** * Functions... */ @@ -510,7 +505,7 @@ static myFILE *OpenConfFile( const char *FileName ) ret = talloc(talloc_autofree_context(), myFILE); if (!ret) return NULL; - ret->buf = file_load(FileName, &ret->size, ret); + ret->buf = file_load(FileName, &ret->size, 0, ret); if( NULL == ret->buf ) { DEBUG( 1, @@ -565,7 +560,7 @@ bool pm_process( const char *FileName, if( NULL == InFile->bufr ) { DEBUG(0,("%s memory allocation failure.\n", func)); - myfile_close(InFile); + talloc_free(InFile); return( false ); } result = Parse( InFile, sfunc, pfunc, userdata ); @@ -573,7 +568,7 @@ bool pm_process( const char *FileName, InFile->bSize = 0; } - myfile_close(InFile); + talloc_free(InFile); if( !result ) /* Generic failure. */ { diff --git a/source3/lib/rbtree.c b/lib/util/rbtree.c similarity index 100% rename from source3/lib/rbtree.c rename to lib/util/rbtree.c diff --git a/source3/include/rbtree.h b/lib/util/rbtree.h similarity index 100% rename from source3/include/rbtree.h rename to lib/util/rbtree.h diff --git a/source4/lib/util/safe_string.h b/lib/util/safe_string.h similarity index 100% rename from source4/lib/util/safe_string.h rename to lib/util/safe_string.h diff --git a/source4/lib/util/signal.c b/lib/util/signal.c similarity index 100% rename from source4/lib/util/signal.c rename to lib/util/signal.c diff --git a/source4/lib/util/signal.m4 b/lib/util/signal.m4 similarity index 100% rename from source4/lib/util/signal.m4 rename to lib/util/signal.m4 diff --git a/lib/util/substitute.c b/lib/util/substitute.c new file mode 100644 index 0000000000..84514ac714 --- /dev/null +++ b/lib/util/substitute.c @@ -0,0 +1,165 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + + Copyright (C) Andrew Tridgell 1992-2001 + Copyright (C) Simo Sorce 2001-2002 + Copyright (C) Martin Pool 2003 + Copyright (C) James Peach 2005 + + 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 . +*/ + +#include "includes.h" + +/** + * @file + * @brief Substitute utilities. + **/ + +/** + Substitute a string for a pattern in another string. Make sure there is + enough room! + + This routine looks for pattern in s and replaces it with + insert. It may do multiple replacements. + + Any of " ; ' $ or ` in the insert string are replaced with _ + if len==0 then the string cannot be extended. This is different from the old + use of len==0 which was for no length checks to be done. +**/ + +_PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_t len) +{ + char *p; + ssize_t ls, lp, li, i; + + if (!insert || !pattern || !*pattern || !s) + return; + + ls = (ssize_t)strlen(s); + lp = (ssize_t)strlen(pattern); + li = (ssize_t)strlen(insert); + + if (len == 0) + len = ls + 1; /* len is number of *bytes* */ + + while (lp <= ls && (p = strstr(s, pattern))) { + if (ls + (li-lp) >= len) { + DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n", + (int)(ls + (li-lp) - len), + pattern, (int)len)); + break; + } + if (li != lp) { + memmove(p+li,p+lp,strlen(p+lp)+1); + } + for (i=0;i= len) { + DEBUG(0,("ERROR: string overflow by %d in all_string_sub(%.50s, %d)\n", + (int)(ls + (li-lp) - len), + pattern, (int)len)); + break; + } + if (li != lp) { + memmove(p+li,p+lp,strlen(p+lp)+1); + } + memcpy(p, insert, li); + s = p + li; + ls += (li-lp); + } +} diff --git a/source4/lib/util/system.c b/lib/util/system.c similarity index 100% rename from source4/lib/util/system.c rename to lib/util/system.c diff --git a/lib/util/tests/data_blob.c b/lib/util/tests/data_blob.c new file mode 100644 index 0000000000..875e5fdef8 --- /dev/null +++ b/lib/util/tests/data_blob.c @@ -0,0 +1,97 @@ +/* + Unix SMB/CIFS implementation. + + data blob testing + + Copyright (C) Jelmer Vernooij 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 . +*/ + +#include "includes.h" +#include "torture/torture.h" + +static bool test_string(struct torture_context *tctx) +{ + DATA_BLOB blob = data_blob_string_const("bla"); + + torture_assert_int_equal(tctx, blob.length, 3, "blob length"); + torture_assert_str_equal(tctx, (char *)blob.data, "bla", "blob data"); + + return true; +} + +static bool test_string_null(struct torture_context *tctx) +{ + DATA_BLOB blob = data_blob_string_const_null("bla"); + + torture_assert_int_equal(tctx, blob.length, 4, "blob length"); + torture_assert_str_equal(tctx, (char *)blob.data, "bla", "blob data"); + + return true; +} + +static bool test_zero(struct torture_context *tctx) +{ + int i; + DATA_BLOB z = data_blob_talloc_zero(tctx, 4); + torture_assert_int_equal(tctx, z.length, 4, "length"); + for (i = 0; i < z.length; i++) + torture_assert_int_equal(tctx, z.data[i], 0, "contents"); + data_blob_free(&z); + return true; +} + + +static bool test_clear(struct torture_context *tctx) +{ + int i; + DATA_BLOB z = data_blob("lalala", 6); + torture_assert_int_equal(tctx, z.length, 6, "length"); + data_blob_clear(&z); + for (i = 0; i < z.length; i++) + torture_assert_int_equal(tctx, z.data[i], 0, "contents"); + data_blob_free(&z); + return true; +} + +static bool test_cmp(struct torture_context *tctx) +{ + DATA_BLOB a = data_blob_string_const("bla"); + DATA_BLOB b = data_blob_string_const("blae"); + torture_assert(tctx, data_blob_cmp(&a, &b) != 0, "cmp different"); + torture_assert(tctx, data_blob_cmp(&a, &a) == 0, "cmp self"); + return true; +} + +static bool test_hex_string(struct torture_context *tctx) +{ + DATA_BLOB a = data_blob_string_const("\xC\xA\xF\xE"); + torture_assert_str_equal(tctx, data_blob_hex_string(tctx, &a), "0C0A0F0E", "hex string"); + return true; +} + +struct torture_suite *torture_local_util_data_blob(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "DATABLOB"); + + torture_suite_add_simple_test(suite, "string", test_string); + torture_suite_add_simple_test(suite, "string_null", test_string_null); + torture_suite_add_simple_test(suite, "zero", test_zero);; + torture_suite_add_simple_test(suite, "clear", test_clear); + torture_suite_add_simple_test(suite, "cmp", test_cmp); + torture_suite_add_simple_test(suite, "hex string", test_hex_string); + + return suite; +} diff --git a/source4/lib/util/tests/file.c b/lib/util/tests/file.c similarity index 92% rename from source4/lib/util/tests/file.c rename to lib/util/tests/file.c index 3377e833dc..4aff0e9afd 100644 --- a/source4/lib/util/tests/file.c +++ b/lib/util/tests/file.c @@ -42,13 +42,19 @@ static bool test_file_load_save(struct torture_context *tctx) torture_assert_file_contains_text(tctx, TEST_FILENAME, TEST_DATA, "file contents"); - data = file_load(TEST_FILENAME, &len, mem_ctx); + data = file_load(TEST_FILENAME, &len, 0, mem_ctx); torture_assert(tctx, data, "loading file"); torture_assert_int_equal(tctx, len, strlen(TEST_DATA), "Length"); torture_assert_mem_equal(tctx, data, TEST_DATA, len, "Contents"); + data = file_load(TEST_FILENAME, &len, 5, mem_ctx); + + torture_assert_int_equal(tctx, len, 5, "Length"); + + torture_assert_mem_equal(tctx, data, TEST_DATA, len, "Contents"); + unlink(TEST_FILENAME); return true; } diff --git a/source4/lib/util/tests/genrand.c b/lib/util/tests/genrand.c similarity index 100% rename from source4/lib/util/tests/genrand.c rename to lib/util/tests/genrand.c diff --git a/source4/lib/util/tests/idtree.c b/lib/util/tests/idtree.c similarity index 100% rename from source4/lib/util/tests/idtree.c rename to lib/util/tests/idtree.c diff --git a/source4/lib/util/tests/str.c b/lib/util/tests/str.c similarity index 100% rename from source4/lib/util/tests/str.c rename to lib/util/tests/str.c diff --git a/source4/lib/util/tests/strlist.c b/lib/util/tests/strlist.c similarity index 94% rename from source4/lib/util/tests/strlist.c rename to lib/util/tests/strlist.c index 9af26f9e71..8605102954 100644 --- a/source4/lib/util/tests/strlist.c +++ b/lib/util/tests/strlist.c @@ -71,17 +71,17 @@ static bool test_list_copy(struct torture_context *tctx) const char *empty_list[] = { NULL }; const char **null_list = NULL; - result = str_list_copy(tctx, list); + result = (const char **)str_list_copy(tctx, list); torture_assert_int_equal(tctx, str_list_length(result), 2, "list length"); torture_assert_str_equal(tctx, result[0], "foo", "element 0"); torture_assert_str_equal(tctx, result[1], "bar", "element 1"); torture_assert_str_equal(tctx, result[2], NULL, "element 2"); - result = str_list_copy(tctx, empty_list); + result = (const char **)str_list_copy(tctx, empty_list); torture_assert_int_equal(tctx, str_list_length(result), 0, "list length"); torture_assert_str_equal(tctx, result[0], NULL, "element 0"); - result = str_list_copy(tctx, null_list); + result = (const char **)str_list_copy(tctx, null_list); torture_assert(tctx, result == NULL, "result NULL"); return true; diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c new file mode 100644 index 0000000000..4a31566b42 --- /dev/null +++ b/lib/util/tests/time.c @@ -0,0 +1,75 @@ +/* + Unix SMB/CIFS implementation. + + util time testing + + Copyright (C) Jelmer Vernooij 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 . +*/ + +#include "includes.h" +#include "torture/torture.h" + +static bool test_null_time(struct torture_context *tctx) +{ + torture_assert(tctx, null_time(0), "0"); + torture_assert(tctx, null_time(0xFFFFFFFF), "0xFFFFFFFF"); + torture_assert(tctx, null_time(-1), "-1"); + torture_assert(tctx, !null_time(42), "42"); + return true; +} + +static bool test_null_nttime(struct torture_context *tctx) +{ + torture_assert(tctx, null_nttime(-1), "-1"); + torture_assert(tctx, null_nttime(-1), "-1"); + torture_assert(tctx, !null_nttime(42), "42"); + return true; +} + + +static bool test_http_timestring(struct torture_context *tctx) +{ + const char *start = "Thu, 01 Jan 1970"; + torture_assert(tctx, !strncmp(start, http_timestring(tctx, 42), + strlen(start)), "42"); + torture_assert_str_equal(tctx, "never", + http_timestring(tctx, get_time_t_max()), "42"); + return true; +} + +static bool test_timestring(struct torture_context *tctx) +{ + const char *start = "Thu Jan 1"; + torture_assert(tctx, !strncmp(start, timestring(tctx, 42), strlen(start)), + "42"); + return true; +} + + + +struct torture_suite *torture_local_util_time(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "TIME"); + + torture_suite_add_simple_test(suite, "null_time", test_null_time); + torture_suite_add_simple_test(suite, "null_nttime", test_null_nttime); + torture_suite_add_simple_test(suite, "http_timestring", + test_http_timestring); + torture_suite_add_simple_test(suite, "timestring", + test_timestring); + + return suite; +} diff --git a/source4/lib/util/time.c b/lib/util/time.c similarity index 86% rename from source4/lib/util/time.c rename to lib/util/time.c index 978d73cc0a..a001e5f66e 100644 --- a/source4/lib/util/time.c +++ b/lib/util/time.c @@ -32,6 +32,14 @@ #define TIME_T_MIN 0 #endif +#if (SIZEOF_LONG == 8) +#define TIME_FIXUP_CONSTANT_INT 11644473600L +#elif (SIZEOF_LONG_LONG == 8) +#define TIME_FIXUP_CONSTANT_INT 11644473600LL +#endif + + + /* * we use the INT32_MAX here as on 64 bit systems, * gmtime() fails with INT64_MAX @@ -64,27 +72,40 @@ _PUBLIC_ void GetTimeOfDay(struct timeval *tval) #define TIME_FIXUP_CONSTANT 11644473600LL -/** -interpret an 8 byte "filetime" structure to a time_t -It's originally in "100ns units since jan 1st 1601" -**/ -_PUBLIC_ time_t nt_time_to_unix(NTTIME nt) +time_t convert_timespec_to_time_t(struct timespec ts) { - if (nt == 0) { - return 0; - } - if (nt == -1LL) { - return (time_t)-1; + /* 1 ns == 1,000,000,000 - one thousand millionths of a second. + increment if it's greater than 500 millionth of a second. */ + if (ts.tv_nsec > 500000000) { + return ts.tv_sec + 1; } - nt += 1000*1000*10/2; - nt /= 1000*1000*10; - nt -= TIME_FIXUP_CONSTANT; + return ts.tv_sec; +} - if (TIME_T_MIN > nt || nt > TIME_T_MAX) { - return 0; - } +struct timespec convert_time_t_to_timespec(time_t t) +{ + struct timespec ts; + ts.tv_sec = t; + ts.tv_nsec = 0; + return ts; +} - return (time_t)nt; + + +/** + Interpret an 8 byte "filetime" structure to a time_t + It's originally in "100ns units since jan 1st 1601" + + An 8 byte value of 0xffffffffffffffff will be returned as a timespec of + + tv_sec = 0 + tv_nsec = 0; + + Returns GMT. +**/ +time_t nt_time_to_unix(NTTIME nt) +{ + return convert_timespec_to_time_t(nt_time_to_unix_timespec(&nt)); } @@ -99,14 +120,20 @@ _PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t) if (t == (time_t)-1) { *nt = (NTTIME)-1LL; return; - } + } + + if (t == TIME_T_MAX) { + *nt = 0x7fffffffffffffffLL; + return; + } + if (t == 0) { *nt = 0; return; } t2 = t; - t2 += TIME_FIXUP_CONSTANT; + t2 += TIME_FIXUP_CONSTANT_INT; t2 *= 1000*1000*10; *nt = t2; @@ -218,7 +245,7 @@ _PUBLIC_ void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_o /******************************************************************* interpret a 32 bit dos packed date/time to some parameters ********************************************************************/ -static void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second) +void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second) { uint32_t p0,p1,p2,p3; @@ -295,6 +322,10 @@ _PUBLIC_ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t) char tempTime[60]; struct tm *tm = localtime(&t); + if (t == TIME_T_MAX) { + return talloc_strdup(mem_ctx, "never"); + } + if (!tm) { return talloc_asprintf(mem_ctx,"%ld seconds since the Epoch",(long)t); } @@ -613,6 +644,50 @@ _PUBLIC_ int get_time_zone(time_t t) return tm_diff(&tm_utc,tm); } +struct timespec nt_time_to_unix_timespec(NTTIME *nt) +{ + int64_t d; + struct timespec ret; + + if (*nt == 0 || *nt == (int64_t)-1) { + ret.tv_sec = 0; + ret.tv_nsec = 0; + return ret; + } + + d = (int64_t)*nt; + /* d is now in 100ns units, since jan 1st 1601". + Save off the ns fraction. */ + + /* + * Take the last seven decimal digits and multiply by 100. + * to convert from 100ns units to 1ns units. + */ + ret.tv_nsec = (long) ((d % (1000 * 1000 * 10)) * 100); + + /* Convert to seconds */ + d /= 1000*1000*10; + + /* Now adjust by 369 years to make the secs since 1970 */ + d -= TIME_FIXUP_CONSTANT_INT; + + if (d <= (int64_t)TIME_T_MIN) { + ret.tv_sec = TIME_T_MIN; + ret.tv_nsec = 0; + return ret; + } + + if (d >= (int64_t)TIME_T_MAX) { + ret.tv_sec = TIME_T_MAX; + ret.tv_nsec = 0; + return ret; + } + + ret.tv_sec = (time_t)d; + return ret; +} + + /** check if 2 NTTIMEs are equal. */ @@ -620,3 +695,16 @@ bool nt_time_equal(NTTIME *t1, NTTIME *t2) { return *t1 == *t2; } + +/** + Check if it's a null timespec. +**/ + +bool null_timespec(struct timespec ts) +{ + return ts.tv_sec == 0 || + ts.tv_sec == (time_t)0xFFFFFFFF || + ts.tv_sec == (time_t)-1; +} + + diff --git a/source4/lib/util/time.h b/lib/util/time.h similarity index 94% rename from source4/lib/util/time.h rename to lib/util/time.h index e4008c5782..42644a3954 100644 --- a/source4/lib/util/time.h +++ b/lib/util/time.h @@ -229,4 +229,14 @@ _PUBLIC_ int get_time_zone(time_t t); */ bool nt_time_equal(NTTIME *t1, NTTIME *t2); +void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second); + +struct timespec nt_time_to_unix_timespec(NTTIME *nt); + +time_t convert_timespec_to_time_t(struct timespec ts); + +struct timespec convert_time_t_to_timespec(time_t t); + +bool null_timespec(struct timespec ts); + #endif /* _SAMBA_TIME_H_ */ diff --git a/source4/lib/util/time.m4 b/lib/util/time.m4 similarity index 100% rename from source4/lib/util/time.m4 rename to lib/util/time.m4 diff --git a/source4/lib/util/unix_privs.c b/lib/util/unix_privs.c similarity index 98% rename from source4/lib/util/unix_privs.c rename to lib/util/unix_privs.c index 47c172dcfa..f55e739a9b 100644 --- a/source4/lib/util/unix_privs.c +++ b/lib/util/unix_privs.c @@ -21,6 +21,7 @@ #include "includes.h" #include "system/filesys.h" +#include "../lib/util/unix_privs.h" /** * @file diff --git a/source4/lib/util/util.c b/lib/util/util.c similarity index 59% rename from source4/lib/util/util.c rename to lib/util/util.c index b5bb75358e..4e2a5aab09 100644 --- a/source4/lib/util/util.c +++ b/lib/util/util.c @@ -25,6 +25,11 @@ #include "system/network.h" #include "system/filesys.h" #include "system/locale.h" +#undef malloc +#undef strcasecmp +#undef strncasecmp +#undef strdup +#undef realloc /** * @file @@ -216,113 +221,11 @@ _PUBLIC_ char *get_myname(void) return hostname; } -/** - Return true if a string could be a pure IP address. -**/ - -_PUBLIC_ bool is_ipaddress(const char *str) -{ - bool pure_address = true; - int i; - - if (str == NULL) return false; - - for (i=0; pure_address && str[i]; i++) - if (!(isdigit((int)str[i]) || str[i] == '.')) - pure_address = false; - - /* Check that a pure number is not misinterpreted as an IP */ - pure_address = pure_address && (strchr(str, '.') != NULL); - - return pure_address; -} - -/** - Interpret an internet address or name into an IP address in 4 byte form. -**/ -_PUBLIC_ uint32_t interpret_addr(const char *str) -{ - struct hostent *hp; - uint32_t res; - - if (str == NULL || *str == 0 || - strcmp(str,"0.0.0.0") == 0) { - return 0; - } - if (strcmp(str,"255.255.255.255") == 0) { - return 0xFFFFFFFF; - } - /* recognise 'localhost' as a special name. This fixes problems with - some hosts that don't have localhost in /etc/hosts */ - if (strcasecmp(str,"localhost") == 0) { - str = "127.0.0.1"; - } - - /* if it's in the form of an IP address then get the lib to interpret it */ - if (is_ipaddress(str)) { - res = inet_addr(str); - } else { - /* otherwise assume it's a network name of some sort and use - sys_gethostbyname */ - if ((hp = sys_gethostbyname(str)) == 0) { - DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str)); - return 0; - } - - if(hp->h_addr == NULL) { - DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str)); - return 0; - } - memcpy((char *)&res,(char *)hp->h_addr, 4); - } - - if (res == (uint32_t)-1) - return(0); - - return(res); -} - -/** - A convenient addition to interpret_addr(). -**/ -_PUBLIC_ struct in_addr interpret_addr2(const char *str) -{ - struct in_addr ret; - uint32_t a = interpret_addr(str); - ret.s_addr = a; - return ret; -} - -/** - Check if an IP is the 0.0.0.0. -**/ - -_PUBLIC_ bool is_zero_ip(struct in_addr ip) -{ - return ip.s_addr == 0; -} - -/** - Are two IPs on the same subnet? -**/ - -_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask) -{ - uint32_t net1,net2,nmask; - - nmask = ntohl(mask.s_addr); - net1 = ntohl(ip1.s_addr); - net2 = ntohl(ip2.s_addr); - - return((net1 & nmask) == (net2 & nmask)); -} - - /** Check if a process exists. Does this work on all unixes? **/ -_PUBLIC_ bool process_exists(pid_t pid) +_PUBLIC_ bool process_exists_by_pid(pid_t pid) { /* Doing kill with a non-positive pid causes messages to be * sent to places we don't want. */ @@ -380,8 +283,7 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type) return true; } - -static void print_asc(int level, const uint8_t *buf,int len) +void print_asc(int level, const uint8_t *buf,int len) { int i; for (i=0;i= MAX_MALLOC_SIZE/el_size) { + if (free_on_fail) + SAFE_FREE(ptr); return NULL; } if (!ptr) { @@ -582,6 +535,15 @@ _PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count) return realloc(ptr, el_size * count); } +/**************************************************************************** + Type-safe malloc. +****************************************************************************/ + +void *malloc_array(size_t el_size, unsigned int count) +{ + return realloc_array(NULL, el_size, count, false); +} + _PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name) { void *result; @@ -597,3 +559,280 @@ _PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name) return NULL; } +/** + Trim the specified elements off the front and back of a string. +**/ +_PUBLIC_ bool trim_string(char *s, const char *front, const char *back) +{ + bool ret = false; + size_t front_len; + size_t back_len; + size_t len; + + /* Ignore null or empty strings. */ + if (!s || (s[0] == '\0')) + return false; + + front_len = front? strlen(front) : 0; + back_len = back? strlen(back) : 0; + + len = strlen(s); + + if (front_len) { + while (len && strncmp(s, front, front_len)==0) { + /* Must use memmove here as src & dest can + * easily overlap. Found by valgrind. JRA. */ + memmove(s, s+front_len, (len-front_len)+1); + len -= front_len; + ret=true; + } + } + + if (back_len) { + while ((len >= back_len) && strncmp(s+len-back_len,back,back_len)==0) { + s[len-back_len]='\0'; + len -= back_len; + ret=true; + } + } + return ret; +} + +/** + Find the number of 'c' chars in a string +**/ +_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c) +{ + size_t count = 0; + + while (*s) { + if (*s == c) count++; + s ++; + } + + return count; +} + +/** + Routine to get hex characters and turn them into a 16 byte array. + the array can be variable length, and any non-hex-numeric + characters are skipped. "0xnn" or "0Xnn" is specially catered + for. + + valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n" + + +**/ +_PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t strhex_len) +{ + size_t i; + size_t num_chars = 0; + uint8_t lonybble, hinybble; + const char *hexchars = "0123456789ABCDEF"; + char *p1 = NULL, *p2 = NULL; + + for (i = 0; i < strhex_len && strhex[i] != 0; i++) { + if (strncasecmp(hexchars, "0x", 2) == 0) { + i++; /* skip two chars */ + continue; + } + + if (!(p1 = strchr(hexchars, toupper((unsigned char)strhex[i])))) + break; + + i++; /* next hex digit */ + + if (!(p2 = strchr(hexchars, toupper((unsigned char)strhex[i])))) + break; + + /* get the two nybbles */ + hinybble = PTR_DIFF(p1, hexchars); + lonybble = PTR_DIFF(p2, hexchars); + + if (num_chars >= p_len) { + break; + } + + p[num_chars] = (hinybble << 4) | lonybble; + num_chars++; + + p1 = NULL; + p2 = NULL; + } + return num_chars; +} + +/** + * Parse a hex string and return a data blob. + */ +_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) +{ + DATA_BLOB ret_blob = data_blob_talloc(mem_ctx, NULL, strlen(strhex)/2+1); + + ret_blob.length = strhex_to_str((char *)ret_blob.data, ret_blob.length, + strhex, + strlen(strhex)); + + return ret_blob; +} + + +/** + * Routine to print a buffer as HEX digits, into an allocated string. + */ +_PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) +{ + int i; + char *hex_buffer; + + *out_hex_buffer = malloc_array_p(char, (len*2)+1); + hex_buffer = *out_hex_buffer; + + for (i = 0; i < len; i++) + slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); +} + +/** + * talloc version of hex_encode() + */ +_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len) +{ + int i; + char *hex_buffer; + + hex_buffer = talloc_array(mem_ctx, char, (len*2)+1); + + for (i = 0; i < len; i++) + slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); + + return hex_buffer; +} + +/** + Unescape a URL encoded string, in place. +**/ + +_PUBLIC_ void rfc1738_unescape(char *buf) +{ + char *p=buf; + + while ((p=strchr(p,'+'))) + *p = ' '; + + p = buf; + + while (p && *p && (p=strchr(p,'%'))) { + int c1 = p[1]; + int c2 = p[2]; + + if (c1 >= '0' && c1 <= '9') + c1 = c1 - '0'; + else if (c1 >= 'A' && c1 <= 'F') + c1 = 10 + c1 - 'A'; + else if (c1 >= 'a' && c1 <= 'f') + c1 = 10 + c1 - 'a'; + else {p++; continue;} + + if (c2 >= '0' && c2 <= '9') + c2 = c2 - '0'; + else if (c2 >= 'A' && c2 <= 'F') + c2 = 10 + c2 - 'A'; + else if (c2 >= 'a' && c2 <= 'f') + c2 = 10 + c2 - 'a'; + else {p++; continue;} + + *p = (c1<<4) | c2; + + memmove(p+1, p+3, strlen(p+3)+1); + p++; + } +} + +/** + varient of strcmp() that handles NULL ptrs +**/ +_PUBLIC_ int strcmp_safe(const char *s1, const char *s2) +{ + if (s1 == s2) { + return 0; + } + if (s1 == NULL || s2 == NULL) { + return s1?-1:1; + } + return strcmp(s1, s2); +} + + +/** +return the number of bytes occupied by a buffer in ASCII format +the result includes the null termination +limited by 'n' bytes +**/ +_PUBLIC_ size_t ascii_len_n(const char *src, size_t n) +{ + size_t len; + + len = strnlen(src, n); + if (len+1 <= n) { + len += 1; + } + + return len; +} + +/** + Set a boolean variable from the text value stored in the passed string. + Returns true in success, false if the passed string does not correctly + represent a boolean. +**/ + +_PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean) +{ + if (strwicmp(boolean_string, "yes") == 0 || + strwicmp(boolean_string, "true") == 0 || + strwicmp(boolean_string, "on") == 0 || + strwicmp(boolean_string, "1") == 0) { + *boolean = true; + return true; + } else if (strwicmp(boolean_string, "no") == 0 || + strwicmp(boolean_string, "false") == 0 || + strwicmp(boolean_string, "off") == 0 || + strwicmp(boolean_string, "0") == 0) { + *boolean = false; + return true; + } + return false; +} + +/** +return the number of bytes occupied by a buffer in CH_UTF16 format +the result includes the null termination +**/ +_PUBLIC_ size_t utf16_len(const void *buf) +{ + size_t len; + + for (len = 0; SVAL(buf,len); len += 2) ; + + return len + 2; +} + +/** +return the number of bytes occupied by a buffer in CH_UTF16 format +the result includes the null termination +limited by 'n' bytes +**/ +_PUBLIC_ size_t utf16_len_n(const void *src, size_t n) +{ + size_t len; + + for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ; + + if (len+2 <= n) { + len += 2; + } + + return len; +} + + diff --git a/source4/lib/util/util.h b/lib/util/util.h similarity index 84% rename from source4/lib/util/util.h rename to lib/util/util.h index ffe83c14b2..fc651d58af 100644 --- a/source4/lib/util/util.h +++ b/lib/util/util.h @@ -21,9 +21,10 @@ #ifndef _SAMBA_UTIL_H_ #define _SAMBA_UTIL_H_ -#include "util/attr.h" - -#include "charset/charset.h" +#if _SAMBA_BUILD_ == 4 +#include "lib/charset/charset.h" +#endif +#include "../lib/util/attr.h" /* for TALLOC_CTX */ #include @@ -38,39 +39,11 @@ struct smbsrv_tcon; extern const char *logfile; extern const char *panic_action; -#include "util/time.h" -#include "util/data_blob.h" -#include "util/xfile.h" -#include "util/debug.h" -#include "util/mutex.h" -#include "util/byteorder.h" - -/** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#ifndef discard_const -#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) -#endif - -/** Type-safe version of discard_const */ -#ifndef discard_const_p -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -#endif +#include "../lib/util/time.h" +#include "../lib/util/data_blob.h" +#include "../lib/util/xfile.h" +#include "../lib/util/mutex.h" +#include "../lib/util/byteorder.h" /** * assert macros @@ -79,79 +52,11 @@ extern const char *panic_action; DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)); \ smb_panic("assert failed"); }} while (0) -#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */ -/** - * Free memory if the pointer and zero the pointer. - * - * @note You are explicitly allowed to pass NULL pointers -- they will - * always be ignored. - **/ -#define SAFE_FREE(x) do { if ((x) != NULL) {free(discard_const_p(void *, (x))); (x)=NULL;} } while(0) -#endif - -/** - * Type-safe version of malloc. Allocated one copy of the - * specified data type. - */ -#define malloc_p(type) (type *)malloc(sizeof(type)) - -/** - * Allocate an array of elements of one data type. Does type-checking. - */ -#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) - -/** - * Resize an array of elements of one data type. Does type-checking. - */ -#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) - #if defined(VALGRIND) #define strlen(x) valgrind_strlen(x) #endif -/** - * zero a structure - */ -#ifndef ZERO_STRUCT -#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) -#endif - -/** - * zero a structure given a pointer to the structure - */ -#ifndef ZERO_STRUCTP -#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) -#endif - -/** - * zero a structure given a pointer to the structure - no zero check - */ -#ifndef ZERO_STRUCTPN -#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) -#endif - -/* zero an array - note that sizeof(array) must work - ie. it must not be a - pointer */ -#ifndef ZERO_ARRAY -#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) -#endif - -/** - * work out how many elements there are in a static array - */ -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) -#endif - -/** - * pointer difference macro - */ -#ifndef PTR_DIFF -#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) -#endif - -/* The following definitions come from lib/util/fault.c */ - +#include "../lib/util/memory.h" /** * Write backtrace to debug log @@ -304,12 +209,12 @@ _PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength); **/ -_PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex); +_PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t strhex_len); /** * Parse a hex string and return a data blob. */ -_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex) ; +_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) ; /** * Routine to print a buffer as HEX digits, into an allocated string. @@ -453,7 +358,7 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2); separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); +_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); /** * build a null terminated list of strings from an argv-like input string @@ -474,12 +379,12 @@ _PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char /** return the number of elements in a string list */ -_PUBLIC_ size_t str_list_length(const char **list); +_PUBLIC_ size_t str_list_length(const char * const *list); /** copy a string list */ -_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); +_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); /** Return true if all the elements of the list match exactly. @@ -524,12 +429,15 @@ _PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint); /** load a file into memory from a fd. **/ -_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx); +_PUBLIC_ char *fd_load(int fd, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx); + + +char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx); /** load a file into memory **/ -_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx); +_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx); /** mmap (if possible) or read a file @@ -540,14 +448,14 @@ _PUBLIC_ void *map_file(const char *fname, size_t size); load a file into memory and return an array of pointers to lines in the file must be freed with talloc_free(). **/ -_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx); +_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx); /** load a fd into memory and return an array of pointers to lines in the file must be freed with talloc_free(). If convert is true calls unix_to_dos on the list. **/ -_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx); +_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx); /** take a list of lines and modify them to produce a list where \ continues @@ -642,7 +550,7 @@ _PUBLIC_ bool same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask /** Check if a process exists. Does this work on all unixes? **/ -_PUBLIC_ bool process_exists(pid_t pid); +_PUBLIC_ bool process_exists_by_pid(pid_t pid); /** Simple routine to do POSIX file locking. Cruft in NFS and 64->32 bit mapping @@ -680,6 +588,8 @@ _PUBLIC_ void *smb_xmemdup(const void *p, size_t size); **/ _PUBLIC_ char *smb_xstrdup(const char *s); +char *smb_xstrndup(const char *s, size_t n); + /** Like strdup but for memory. **/ @@ -702,7 +612,9 @@ _PUBLIC_ bool all_zero(const uint8_t *ptr, size_t size); /** realloc an array, checking for integer overflow in the array size */ -_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count); +_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count, bool free_on_fail); + +void *malloc_array(size_t el_size, unsigned int count); /* The following definitions come from lib/util/fsusage.c */ @@ -810,4 +722,8 @@ _PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name); #define talloc_get_type_abort(ptr, type) \ (type *)talloc_check_name_abort(ptr, #type) +bool unmap_file(void *start, size_t size); + +void print_asc(int level, const uint8_t *buf,int len); + #endif /* _SAMBA_UTIL_H_ */ diff --git a/source4/lib/util/util.m4 b/lib/util/util.m4 similarity index 100% rename from source4/lib/util/util.m4 rename to lib/util/util.m4 diff --git a/source4/lib/util/util_file.c b/lib/util/util_file.c similarity index 85% rename from source4/lib/util/util_file.c rename to lib/util/util_file.c index c3e22196c0..0275e78c54 100644 --- a/source4/lib/util/util_file.c +++ b/lib/util/util_file.c @@ -22,6 +22,10 @@ #include "includes.h" #include "system/shmem.h" #include "system/filesys.h" +#if _SAMBA_BUILD_ == 3 +#undef malloc +#undef realloc +#endif /** * @file @@ -160,23 +164,30 @@ _PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint) /** load a file into memory from a fd. **/ -_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx) +_PUBLIC_ char *fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx) { struct stat sbuf; char *p; + size_t size; if (fstat(fd, &sbuf) != 0) return NULL; - p = (char *)talloc_size(mem_ctx, sbuf.st_size+1); + size = sbuf.st_size; + + if (maxsize) { + size = MIN(size, maxsize); + } + + p = (char *)talloc_size(mem_ctx, size+1); if (!p) return NULL; - if (read(fd, p, sbuf.st_size) != sbuf.st_size) { + if (read(fd, p, size) != size) { talloc_free(p); return NULL; } - p[sbuf.st_size] = 0; + p[size] = 0; - if (size) *size = sbuf.st_size; + if (psize) *psize = size; return p; } @@ -184,7 +195,7 @@ _PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx) /** load a file into memory **/ -_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx) +_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx) { int fd; char *p; @@ -194,7 +205,7 @@ _PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx) fd = open(fname,O_RDONLY); if (fd == -1) return NULL; - p = fd_load(fd, size, mem_ctx); + p = fd_load(fd, size, maxsize, mem_ctx); close(fd); @@ -224,7 +235,7 @@ _PUBLIC_ void *map_file(const char *fname, size_t size) } #endif if (!p) { - p = file_load(fname, &s2, talloc_autofree_context()); + p = file_load(fname, &s2, 0, talloc_autofree_context()); if (!p) return NULL; if (s2 != size) { DEBUG(1,("incorrect size for %s - got %d expected %d\n", @@ -237,12 +248,31 @@ _PUBLIC_ void *map_file(const char *fname, size_t size) return p; } +/** + unmap or free memory +**/ + +bool unmap_file(void *start, size_t size) +{ +#ifdef HAVE_MMAP + if (munmap( start, size ) != 0) { + DEBUG( 1, ("map_file: Failed to unmap address %p " + "of size %u - %s\n", + start, (unsigned int)size, strerror(errno) )); + return false; + } + return true; +#else + talloc_free(start); + return true; +#endif +} /** parse a buffer into lines 'p' will be freed on error, and otherwise will be made a child of the returned array **/ -static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx) +char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx) { int i; char *s, **ret; @@ -288,12 +318,12 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX * load a file into memory and return an array of pointers to lines in the file must be freed with talloc_free(). **/ -_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx) +_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx) { char *p; size_t size; - p = file_load(fname, &size, mem_ctx); + p = file_load(fname, &size, maxsize, mem_ctx); if (!p) return NULL; return file_lines_parse(p, size, numlines, mem_ctx); @@ -304,12 +334,12 @@ load a fd into memory and return an array of pointers to lines in the file must be freed with talloc_free(). If convert is true calls unix_to_dos on the list. **/ -_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx) +_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx) { char *p; size_t size; - p = fd_load(fd, &size, mem_ctx); + p = fd_load(fd, &size, maxsize, mem_ctx); if (!p) return NULL; return file_lines_parse(p, size, numlines, mem_ctx); @@ -402,3 +432,5 @@ _PUBLIC_ bool large_file_support(const char *path) close(fd); return ret == 0; } + + diff --git a/source4/lib/util/util_getent.c b/lib/util/util_getent.c similarity index 100% rename from source4/lib/util/util_getent.c rename to lib/util/util_getent.c diff --git a/source4/lib/util/util_ldb.c b/lib/util/util_ldb.c similarity index 96% rename from source4/lib/util/util_ldb.c rename to lib/util/util_ldb.c index fab729c036..70b18478c6 100644 --- a/source4/lib/util/util_ldb.c +++ b/lib/util/util_ldb.c @@ -24,7 +24,7 @@ #include "lib/events/events.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/util_ldb.h" +#include "../lib/util/util_ldb.h" /* search the sam for the specified attributes - va_list variant */ @@ -52,7 +52,8 @@ int gendb_search_v(struct ldb_context *ldb, res = NULL; - ret = ldb_search(ldb, basedn, scope, expr, attrs, &res); + ret = ldb_search(ldb, mem_ctx, &res, basedn, scope, attrs, + expr?"%s":NULL, expr); if (ret == LDB_SUCCESS) { talloc_steal(mem_ctx, res->msgs); diff --git a/source4/lib/util/util_ldb.h b/lib/util/util_ldb.h similarity index 100% rename from source4/lib/util/util_ldb.h rename to lib/util/util_ldb.h diff --git a/lib/util/util_net.c b/lib/util/util_net.c new file mode 100644 index 0000000000..ee57e9dd23 --- /dev/null +++ b/lib/util/util_net.c @@ -0,0 +1,131 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 2008 + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Jeremy Allison 2001-2002 + Copyright (C) Simo Sorce 2001 + Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. + Copyright (C) James J Myers 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 . +*/ + +#include "includes.h" +#include "system/network.h" +#include "system/locale.h" +#include "system/filesys.h" + +/** + Interpret an internet address or name into an IP address in 4 byte form. +**/ +_PUBLIC_ uint32_t interpret_addr(const char *str) +{ + struct hostent *hp; + uint32_t res; + + if (str == NULL || *str == 0 || + strcmp(str,"0.0.0.0") == 0) { + return 0; + } + if (strcmp(str,"255.255.255.255") == 0) { + return 0xFFFFFFFF; + } + /* recognise 'localhost' as a special name. This fixes problems with + some hosts that don't have localhost in /etc/hosts */ + if (strcasecmp(str,"localhost") == 0) { + str = "127.0.0.1"; + } + + /* if it's in the form of an IP address then get the lib to interpret it */ + if (is_ipaddress(str)) { + res = inet_addr(str); + } else { + /* otherwise assume it's a network name of some sort and use + sys_gethostbyname */ + if ((hp = sys_gethostbyname(str)) == 0) { + DEBUG(3,("sys_gethostbyname: Unknown host. %s\n",str)); + return 0; + } + + if(hp->h_addr == NULL) { + DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str)); + return 0; + } + memcpy((char *)&res,(char *)hp->h_addr, 4); + } + + if (res == (uint32_t)-1) + return(0); + + return(res); +} + +/** + A convenient addition to interpret_addr(). +**/ +_PUBLIC_ struct in_addr interpret_addr2(const char *str) +{ + struct in_addr ret; + uint32_t a = interpret_addr(str); + ret.s_addr = a; + return ret; +} + +/** + Check if an IP is the 0.0.0.0. +**/ + +_PUBLIC_ bool is_zero_ip(struct in_addr ip) +{ + return ip.s_addr == 0; +} + +/** + Are two IPs on the same subnet? +**/ + +_PUBLIC_ bool same_net(struct in_addr ip1, struct in_addr ip2, struct in_addr mask) +{ + uint32_t net1,net2,nmask; + + nmask = ntohl(mask.s_addr); + net1 = ntohl(ip1.s_addr); + net2 = ntohl(ip2.s_addr); + + return((net1 & nmask) == (net2 & nmask)); +} + +/** + Return true if a string could be a pure IP address. +**/ + +_PUBLIC_ bool is_ipaddress(const char *str) +{ + bool pure_address = true; + int i; + + if (str == NULL) return false; + + for (i=0; pure_address && str[i]; i++) + if (!(isdigit((int)str[i]) || str[i] == '.')) + pure_address = false; + + /* Check that a pure number is not misinterpreted as an IP */ + pure_address = pure_address && (strchr(str, '.') != NULL); + + return pure_address; +} + + diff --git a/source4/lib/util/util_pw.c b/lib/util/util_pw.c similarity index 100% rename from source4/lib/util/util_pw.c rename to lib/util/util_pw.c diff --git a/lib/util/util_str.c b/lib/util/util_str.c new file mode 100644 index 0000000000..7dcefc90dd --- /dev/null +++ b/lib/util/util_str.c @@ -0,0 +1,333 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + + Copyright (C) Andrew Tridgell 1992-2001 + Copyright (C) Simo Sorce 2001-2002 + Copyright (C) Martin Pool 2003 + Copyright (C) James Peach 2005 + + 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 . +*/ + +#include "includes.h" +#include "system/locale.h" +#undef strncasecmp +#undef strcasemp + +/** + * @file + * @brief String utilities. + **/ + +/** + Safe string copy into a known length string. maxlength does not + include the terminating zero. +**/ +_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength) +{ + size_t len; + + if (!dest) { + DEBUG(0,("ERROR: NULL dest in safe_strcpy\n")); + return NULL; + } + +#ifdef DEVELOPER + /* We intentionally write out at the extremity of the destination + * string. If the destination is too short (e.g. pstrcpy into mallocd + * or fstring) then this should cause an error under a memory + * checker. */ + dest[maxlength] = '\0'; + if (PTR_DIFF(&len, dest) > 0) { /* check if destination is on the stack, ok if so */ + log_suspicious_usage("safe_strcpy", src); + } +#endif + + if (!src) { + *dest = 0; + return dest; + } + + len = strlen(src); + + if (len > maxlength) { + DEBUG(0,("ERROR: string overflow by %u (%u - %u) in safe_strcpy [%.50s]\n", + (uint_t)(len-maxlength), (unsigned)len, (unsigned)maxlength, src)); + len = maxlength; + } + + memmove(dest, src, len); + dest[len] = 0; + return dest; +} + +/** + Safe string cat into a string. maxlength does not + include the terminating zero. +**/ +_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength) +{ + size_t src_len, dest_len; + + if (!dest) { + DEBUG(0,("ERROR: NULL dest in safe_strcat\n")); + return NULL; + } + + if (!src) + return dest; + +#ifdef DEVELOPER + if (PTR_DIFF(&src_len, dest) > 0) { /* check if destination is on the stack, ok if so */ + log_suspicious_usage("safe_strcat", src); + } +#endif + src_len = strlen(src); + dest_len = strlen(dest); + + if (src_len + dest_len > maxlength) { + DEBUG(0,("ERROR: string overflow by %d in safe_strcat [%.50s]\n", + (int)(src_len + dest_len - maxlength), src)); + if (maxlength > dest_len) { + memcpy(&dest[dest_len], src, maxlength - dest_len); + } + dest[maxlength] = 0; + return NULL; + } + + memcpy(&dest[dest_len], src, src_len); + dest[dest_len + src_len] = 0; + return dest; +} + +#ifdef VALGRIND +size_t valgrind_strlen(const char *s) +{ + size_t count; + for(count = 0; *s++; count++) + ; + return count; +} +#endif + + +/** + format a string into length-prefixed dotted domain format, as used in NBT + and in some ADS structures +**/ +_PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) +{ + char *ret; + int i; + if (!s || !*s) { + return talloc_strdup(mem_ctx, ""); + } + ret = talloc_array(mem_ctx, char, strlen(s)+2); + if (!ret) { + return ret; + } + + memcpy(ret+1, s, strlen(s)+1); + ret[0] = '.'; + + for (i=0;ret[i];i++) { + if (ret[i] == '.') { + char *p = strchr(ret+i+1, '.'); + if (p) { + ret[i] = p-(ret+i+1); + } else { + ret[i] = strlen(ret+i+1); + } + } + } + + return ret; +} + +/** + * Add a string to an array of strings. + * + * num should be a pointer to an integer that holds the current + * number of elements in strings. It will be updated by this function. + */ +_PUBLIC_ bool add_string_to_array(TALLOC_CTX *mem_ctx, + const char *str, const char ***strings, int *num) +{ + char *dup_str = talloc_strdup(mem_ctx, str); + + *strings = talloc_realloc(mem_ctx, + *strings, + const char *, ((*num)+1)); + + if ((*strings == NULL) || (dup_str == NULL)) + return false; + + (*strings)[*num] = dup_str; + *num += 1; + + return true; +} + +/** + * Parse a string containing a boolean value. + * + * val will be set to the read value. + * + * @retval true if a boolean value was parsed, false otherwise. + */ +_PUBLIC_ bool conv_str_bool(const char * str, bool * val) +{ + char * end = NULL; + long lval; + + if (str == NULL || *str == '\0') { + return false; + } + + lval = strtol(str, &end, 10 /* base */); + if (end == NULL || *end != '\0' || end == str) { + return set_boolean(str, val); + } + + *val = (lval) ? true : false; + return true; +} + +/** + * Convert a size specification like 16K into an integral number of bytes. + **/ +_PUBLIC_ bool conv_str_size(const char * str, uint64_t * val) +{ + char * end = NULL; + unsigned long long lval; + + if (str == NULL || *str == '\0') { + return false; + } + + lval = strtoull(str, &end, 10 /* base */); + if (end == NULL || end == str) { + return false; + } + + if (*end) { + if (strwicmp(end, "K") == 0) { + lval *= 1024ULL; + } else if (strwicmp(end, "M") == 0) { + lval *= (1024ULL * 1024ULL); + } else if (strwicmp(end, "G") == 0) { + lval *= (1024ULL * 1024ULL * 1024ULL); + } else if (strwicmp(end, "T") == 0) { + lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL); + } else if (strwicmp(end, "P") == 0) { + lval *= (1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL); + } else { + return false; + } + } + + *val = (uint64_t)lval; + return true; +} + +/** + * Parse a uint64_t value from a string + * + * val will be set to the value read. + * + * @retval true if parsing was successful, false otherwise + */ +_PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val) +{ + char * end = NULL; + unsigned long long lval; + + if (str == NULL || *str == '\0') { + return false; + } + + lval = strtoull(str, &end, 10 /* base */); + if (end == NULL || *end != '\0' || end == str) { + return false; + } + + *val = (uint64_t)lval; + return true; +} + +/** +Do a case-insensitive, whitespace-ignoring string compare. +**/ +_PUBLIC_ int strwicmp(const char *psz1, const char *psz2) +{ + /* if BOTH strings are NULL, return TRUE, if ONE is NULL return */ + /* appropriate value. */ + if (psz1 == psz2) + return (0); + else if (psz1 == NULL) + return (-1); + else if (psz2 == NULL) + return (1); + + /* sync the strings on first non-whitespace */ + while (1) { + while (isspace((int)*psz1)) + psz1++; + while (isspace((int)*psz2)) + psz2++; + if (toupper((unsigned char)*psz1) != toupper((unsigned char)*psz2) + || *psz1 == '\0' + || *psz2 == '\0') + break; + psz1++; + psz2++; + } + return (*psz1 - *psz2); +} + +/** + * Compare 2 strings. + * + * @note The comparison is case-insensitive. + **/ +_PUBLIC_ bool strequal(const char *s1, const char *s2) +{ + if (s1 == s2) + return true; + if (!s1 || !s2) + return false; + + return strcasecmp(s1,s2) == 0; +} + +_PUBLIC_ size_t ucs2_align(const void *base_ptr, const void *p, int flags) +{ + if (flags & (STR_NOALIGN|STR_ASCII)) + return 0; + return PTR_DIFF(p, base_ptr) & 1; +} + +/** + String replace. +**/ +_PUBLIC_ void string_replace(char *s, char oldc, char newc) +{ + while (*s) { + if (*s == oldc) *s = newc; + s++; + } +} + + diff --git a/source4/lib/util/util_strlist.c b/lib/util/util_strlist.c similarity index 92% rename from source4/lib/util/util_strlist.c rename to lib/util/util_strlist.c index 30de4b962d..b069a11e38 100644 --- a/source4/lib/util/util_strlist.c +++ b/lib/util/util_strlist.c @@ -21,6 +21,8 @@ #include "includes.h" #include "system/locale.h" +#undef strcasecmp + /** * @file * @brief String list manipulation @@ -31,30 +33,30 @@ separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) +_PUBLIC_ char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { int num_elements = 0; - const char **ret = NULL; + char **ret = NULL; if (sep == NULL) { sep = LIST_SEP; } - ret = talloc_array(mem_ctx, const char *, 1); + ret = talloc_array(mem_ctx, char *, 1); if (ret == NULL) { return NULL; } while (string && *string) { size_t len = strcspn(string, sep); - const char **ret2; + char **ret2; if (len == 0) { string += strspn(string, sep); continue; } - ret2 = talloc_realloc(mem_ctx, ret, const char *, num_elements+2); + ret2 = talloc_realloc(mem_ctx, ret, char *, num_elements+2); if (ret2 == NULL) { talloc_free(ret); return NULL; @@ -185,7 +187,7 @@ _PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char /** return the number of elements in a string list */ -_PUBLIC_ size_t str_list_length(const char **list) +_PUBLIC_ size_t str_list_length(const char * const*list) { size_t ret; for (ret=0;list && list[ret];ret++) /* noop */ ; @@ -196,15 +198,15 @@ _PUBLIC_ size_t str_list_length(const char **list) /** copy a string list */ -_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) +_PUBLIC_ char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) { int i; - const char **ret; + char **ret; if (list == NULL) return NULL; - ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1); + ret = talloc_array(mem_ctx, char *, str_list_length(list)+1); if (ret == NULL) return NULL; diff --git a/source4/lib/util/util_tdb.c b/lib/util/util_tdb.c similarity index 61% rename from source4/lib/util/util_tdb.c rename to lib/util/util_tdb.c index e4219dfd69..2d6012c9f4 100644 --- a/source4/lib/util/util_tdb.c +++ b/lib/util/util_tdb.c @@ -20,9 +20,8 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" -#include "pstring.h" -#include "lib/util/util_tdb.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/util_tdb.h" /* these are little tdb utility functions that are meant to make dealing with a tdb database a little less cumbersome in Samba */ @@ -31,21 +30,31 @@ Make a TDB_DATA and keep the const warning in one place ****************************************************************/ -static TDB_DATA make_tdb_data(const char *dptr, size_t dsize) +TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize) { TDB_DATA ret; - ret.dptr = discard_const_p(unsigned char, dptr); + ret.dptr = discard_const_p(uint8_t, dptr); ret.dsize = dsize; return ret; } +TDB_DATA string_tdb_data(const char *string) +{ + return make_tdb_data((const uint8_t *)string, string ? strlen(string) : 0 ); +} + +TDB_DATA string_term_tdb_data(const char *string) +{ + return make_tdb_data((const uint8_t *)string, string ? strlen(string) + 1 : 0); +} + /**************************************************************************** Lock a chain by string. Return -1 if lock failed. ****************************************************************************/ int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval) { - TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1); + TDB_DATA key = string_term_tdb_data(keyval); return tdb_chainlock(tdb, key); } @@ -56,7 +65,7 @@ int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval) void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval) { - TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1); + TDB_DATA key = string_term_tdb_data(keyval); tdb_chainunlock(tdb, key); } @@ -67,7 +76,7 @@ void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval) int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval) { - TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1); + TDB_DATA key = string_term_tdb_data(keyval); return tdb_chainlock_read(tdb, key); } @@ -78,7 +87,7 @@ int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval) void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval) { - TDB_DATA key = make_tdb_data(keyval, strlen(keyval)+1); + TDB_DATA key = string_term_tdb_data(keyval); tdb_chainunlock_read(tdb, key); } @@ -89,9 +98,8 @@ void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval) Output is int32_t in native byte order. ****************************************************************************/ -int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, const char *keyval, size_t len) +int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key) { - TDB_DATA key = make_tdb_data(keyval, len); TDB_DATA data; int32_t ret; @@ -113,7 +121,7 @@ int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, const char *keyval, size int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr) { - return tdb_fetch_int32_byblob(tdb, keystr, strlen(keystr) + 1); + return tdb_fetch_int32_byblob(tdb, string_term_tdb_data(keystr)); } /**************************************************************************** @@ -121,9 +129,8 @@ int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr) Input is int32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ -int tdb_store_int32_byblob(struct tdb_context *tdb, const char *keystr, size_t len, int32_t v) +int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v) { - TDB_DATA key = make_tdb_data(keystr, len); TDB_DATA data; int32_t v_store; @@ -141,7 +148,7 @@ int tdb_store_int32_byblob(struct tdb_context *tdb, const char *keystr, size_t l int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v) { - return tdb_store_int32_byblob(tdb, keystr, strlen(keystr) + 1, v); + return tdb_store_int32_byblob(tdb, string_term_tdb_data(keystr), v); } /**************************************************************************** @@ -149,9 +156,8 @@ int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v) Output is uint32_t in native byte order. ****************************************************************************/ -bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, const char *keyval, size_t len, uint32_t *value) +bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value) { - TDB_DATA key = make_tdb_data(keyval, len); TDB_DATA data; data = tdb_fetch(tdb, key); @@ -172,7 +178,7 @@ bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, const char *keyval, size_t bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value) { - return tdb_fetch_uint32_byblob(tdb, keystr, strlen(keystr) + 1, value); + return tdb_fetch_uint32_byblob(tdb, string_term_tdb_data(keystr), value); } /**************************************************************************** @@ -180,9 +186,8 @@ bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *val Input is uint32_t in native byte order. Output in tdb is in little-endian. ****************************************************************************/ -bool tdb_store_uint32_byblob(struct tdb_context *tdb, const char *keystr, size_t len, uint32_t value) +bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value) { - TDB_DATA key = make_tdb_data(keystr, len); TDB_DATA data; uint32_t v_store; bool ret = true; @@ -204,7 +209,7 @@ bool tdb_store_uint32_byblob(struct tdb_context *tdb, const char *keystr, size_t bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value) { - return tdb_store_uint32_byblob(tdb, keystr, strlen(keystr) + 1, value); + return tdb_store_uint32_byblob(tdb, string_term_tdb_data(keystr), value); } /**************************************************************************** Store a buffer by a null terminated string key. Return 0 on success, -1 @@ -213,7 +218,7 @@ bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t valu int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags) { - TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1); + TDB_DATA key = string_term_tdb_data(keystr); return tdb_store(tdb, key, data, flags); } @@ -225,7 +230,7 @@ int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA dat TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr) { - TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1); + TDB_DATA key = string_term_tdb_data(keystr); return tdb_fetch(tdb, key); } @@ -236,7 +241,7 @@ TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr) int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr) { - TDB_DATA key = make_tdb_data(keystr, strlen(keystr)+1); + TDB_DATA key = string_term_tdb_data(keystr); return tdb_delete(tdb, key); } @@ -333,214 +338,3 @@ int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA d { return tdb_delete(the_tdb, key); } - - - -/**************************************************************************** - Useful pair of routines for packing/unpacking data consisting of - integers and strings. -****************************************************************************/ - -size_t tdb_pack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) -{ - va_list ap; - uint8_t bt; - uint16_t w; - uint32_t d; - int i; - void *p; - int len; - char *s; - char c; - char *buf0 = buf; - const char *fmt0 = fmt; - int bufsize0 = bufsize; - tdb_log_func log_fn = tdb_log_fn(tdb); - - va_start(ap, fmt); - - while (*fmt) { - switch ((c = *fmt++)) { - case 'b': /* unsigned 8-bit integer */ - len = 1; - bt = (uint8_t)va_arg(ap, int); - if (bufsize && bufsize >= len) - SSVAL(buf, 0, bt); - break; - case 'w': /* unsigned 16-bit integer */ - len = 2; - w = (uint16_t)va_arg(ap, int); - if (bufsize && bufsize >= len) - SSVAL(buf, 0, w); - break; - case 'd': /* signed 32-bit integer (standard int in most systems) */ - len = 4; - d = va_arg(ap, uint32_t); - if (bufsize && bufsize >= len) - SIVAL(buf, 0, d); - break; - case 'p': /* pointer */ - len = 4; - p = va_arg(ap, void *); - d = p?1:0; - if (bufsize && bufsize >= len) - SIVAL(buf, 0, d); - break; - case 'P': /* null-terminated string */ - s = va_arg(ap,char *); - w = strlen(s); - len = w + 1; - if (bufsize && bufsize >= len) - memcpy(buf, s, len); - break; - case 'f': /* null-terminated string */ - s = va_arg(ap,char *); - w = strlen(s); - len = w + 1; - if (bufsize && bufsize >= len) - memcpy(buf, s, len); - break; - case 'B': /* fixed-length string */ - i = va_arg(ap, int); - s = va_arg(ap, char *); - len = 4+i; - if (bufsize && bufsize >= len) { - SIVAL(buf, 0, i); - memcpy(buf+4, s, i); - } - break; - default: - log_fn(tdb, 0,"Unknown tdb_pack format %c in %s\n", - c, fmt); - len = 0; - break; - } - - buf += len; - if (bufsize) - bufsize -= len; - if (bufsize < 0) - bufsize = 0; - } - - va_end(ap); - - log_fn(tdb, 18,"tdb_pack(%s, %d) -> %d\n", - fmt0, bufsize0, (int)PTR_DIFF(buf, buf0)); - - return PTR_DIFF(buf, buf0); -} - -/**************************************************************************** - Useful pair of routines for packing/unpacking data consisting of - integers and strings. -****************************************************************************/ - -int tdb_unpack(TDB_CONTEXT *tdb, char *buf, int bufsize, const char *fmt, ...) -{ - va_list ap; - uint8_t *bt; - uint16_t *w; - uint32_t *d; - int len; - int *i; - void **p; - char *s, **b, **ps; - char c; - char *buf0 = buf; - const char *fmt0 = fmt; - int bufsize0 = bufsize; - tdb_log_func log_fn = tdb_log_fn(tdb); - - va_start(ap, fmt); - - while (*fmt) { - switch ((c=*fmt++)) { - case 'b': - len = 1; - bt = va_arg(ap, uint8_t *); - if (bufsize < len) - goto no_space; - *bt = SVAL(buf, 0); - break; - case 'w': - len = 2; - w = va_arg(ap, uint16_t *); - if (bufsize < len) - goto no_space; - *w = SVAL(buf, 0); - break; - case 'd': - len = 4; - d = va_arg(ap, uint32_t *); - if (bufsize < len) - goto no_space; - *d = IVAL(buf, 0); - break; - case 'p': - len = 4; - p = va_arg(ap, void **); - if (bufsize < len) - goto no_space; - - /* - * This isn't a real pointer - only a token (1 or 0) - * to mark the fact a pointer is present. - */ - - *p = (void *)(IVAL(buf, 0) ? (void *)1 : NULL); - break; - case 'P': - /* Return a malloc'ed string. */ - ps = va_arg(ap,char ** ); - len = strlen((const char *)buf) + 1; - *ps = strdup((const char *)buf); - break; - case 'f': - s = va_arg(ap,char *); - len = strlen(buf) + 1; - if (bufsize < len || len > sizeof(fstring)) - goto no_space; - memcpy(s, buf, len); - break; - case 'B': - i = va_arg(ap, int *); - b = va_arg(ap, char **); - len = 4; - if (bufsize < len) - goto no_space; - *i = IVAL(buf, 0); - if (! *i) { - *b = NULL; - break; - } - len += *i; - if (bufsize < len) - goto no_space; - *b = (char *)malloc(*i); - if (! *b) - goto no_space; - memcpy(*b, buf+4, *i); - break; - default: - log_fn(tdb, 0, "Unknown tdb_unpack format %c in %s\n", - c, fmt); - - len = 0; - break; - } - - buf += len; - bufsize -= len; - } - - va_end(ap); - - log_fn(tdb, 18, "tdb_unpack(%s, %d) -> %d\n", - fmt0, bufsize0, (int)PTR_DIFF(buf, buf0)); - - return PTR_DIFF(buf, buf0); - - no_space: - return -1; -} diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h new file mode 100644 index 0000000000..da6378ee6a --- /dev/null +++ b/lib/util/util_tdb.h @@ -0,0 +1,114 @@ +#ifndef _____LIB_UTIL_UTIL_TDB_H__ +#define _____LIB_UTIL_UTIL_TDB_H__ + + +/*************************************************************** + Make a TDB_DATA and keep the const warning in one place +****************************************************************/ +TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize); +TDB_DATA string_tdb_data(const char *string); +TDB_DATA string_term_tdb_data(const char *string); + +/**************************************************************************** + Lock a chain by string. Return -1 if lock failed. +****************************************************************************/ +int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval); + +/**************************************************************************** + Unlock a chain by string. +****************************************************************************/ +void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval); + +/**************************************************************************** + Read lock a chain by string. Return -1 if lock failed. +****************************************************************************/ +int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval); + +/**************************************************************************** + Read unlock a chain by string. +****************************************************************************/ +void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval); + +/**************************************************************************** + Fetch a int32_t value by a arbitrary blob key, return -1 if not found. + Output is int32_t in native byte order. +****************************************************************************/ +int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key); + +/**************************************************************************** + Fetch a int32_t value by string key, return -1 if not found. + Output is int32_t in native byte order. +****************************************************************************/ +int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); + +/**************************************************************************** + Store a int32_t value by an arbitary blob key, return 0 on success, -1 on failure. + Input is int32_t in native byte order. Output in tdb is in little-endian. +****************************************************************************/ +int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v); + +/**************************************************************************** + Store a int32_t value by string key, return 0 on success, -1 on failure. + Input is int32_t in native byte order. Output in tdb is in little-endian. +****************************************************************************/ +int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v); + +/**************************************************************************** + Fetch a uint32_t value by a arbitrary blob key, return -1 if not found. + Output is uint32_t in native byte order. +****************************************************************************/ +bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value); + +/**************************************************************************** + Fetch a uint32_t value by string key, return -1 if not found. + Output is uint32_t in native byte order. +****************************************************************************/ +bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value); + +/**************************************************************************** + Store a uint32_t value by an arbitary blob key, return 0 on success, -1 on failure. + Input is uint32_t in native byte order. Output in tdb is in little-endian. +****************************************************************************/ +bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value); + +/**************************************************************************** + Store a uint32_t value by string key, return 0 on success, -1 on failure. + Input is uint32_t in native byte order. Output in tdb is in little-endian. +****************************************************************************/ +bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value); + +/**************************************************************************** + Store a buffer by a null terminated string key. Return 0 on success, -1 + on failure. +****************************************************************************/ +int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); + +/**************************************************************************** + Fetch a buffer using a null terminated string key. Don't forget to call + free() on the result dptr. +****************************************************************************/ +TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr); + +/**************************************************************************** + Delete an entry using a null terminated string key. +****************************************************************************/ +int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr); + +/**************************************************************************** + Atomic integer change. Returns old value. To create, set initial value in *oldval. +****************************************************************************/ +int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val); + +/**************************************************************************** + Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval. +****************************************************************************/ +bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, uint32_t *oldval, uint32_t change_val); + +/**************************************************************************** + Allow tdb_delete to be used as a tdb_traversal_fn. +****************************************************************************/ +int tdb_traverse_delete_fn(struct tdb_context *the_tdb, TDB_DATA key, TDB_DATA dbuf, + void *state); + +#endif /* _____LIB_UTIL_UTIL_TDB_H__ */ + diff --git a/source4/lib/util/wrap_xattr.c b/lib/util/wrap_xattr.c similarity index 99% rename from source4/lib/util/wrap_xattr.c rename to lib/util/wrap_xattr.c index 955f39a7eb..b7e69c3676 100644 --- a/source4/lib/util/wrap_xattr.c +++ b/lib/util/wrap_xattr.c @@ -21,7 +21,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/util/wrap_xattr.h" +#include "../lib/util/wrap_xattr.h" #if defined(HAVE_XATTR_SUPPORT) && defined(XATTR_ADDITIONAL_OPTIONS) static ssize_t _wrap_darwin_fgetxattr(int fd, const char *name, void *value, size_t size) diff --git a/source4/lib/util/wrap_xattr.h b/lib/util/wrap_xattr.h similarity index 100% rename from source4/lib/util/wrap_xattr.h rename to lib/util/wrap_xattr.h diff --git a/source4/lib/util/xattr.m4 b/lib/util/xattr.m4 similarity index 100% rename from source4/lib/util/xattr.m4 rename to lib/util/xattr.m4 diff --git a/source4/lib/util/xfile.c b/lib/util/xfile.c similarity index 94% rename from source4/lib/util/xfile.c rename to lib/util/xfile.c index a016031a77..94b0ee9b18 100644 --- a/source4/lib/util/xfile.c +++ b/lib/util/xfile.c @@ -36,6 +36,10 @@ #include "includes.h" #include "system/filesys.h" +#if _SAMBA_BUILD_ == 3 +#undef malloc +#endif + #define XBUFSIZE BUFSIZ static XFILE _x_stdin = { 0, NULL, NULL, XBUFSIZE, 0, O_RDONLY, X_IOFBF, 0 }; @@ -100,7 +104,7 @@ XFILE *x_fopen(const char *fname, int flags, mode_t mode) { XFILE *ret; - ret = malloc_p(XFILE); + ret = (XFILE *)malloc_p(XFILE); if (!ret) return NULL; memset(ret, 0, sizeof(XFILE)); @@ -222,7 +226,7 @@ size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f) } /* at least fileno() is simple! */ -int x_fileno(XFILE *f) +int x_fileno(const XFILE *f) { return f->fd; } @@ -387,3 +391,26 @@ off_t x_tseek(XFILE *f, off_t offset, int whence) f->flags &= ~X_FLAG_EOF; return lseek(f->fd, offset, whence); } + +XFILE *x_fdup(const XFILE *f) +{ + XFILE *ret; + int fd; + + fd = dup(x_fileno(f)); + if (fd < 0) { + return NULL; + } + + ret = (XFILE *)malloc_p(XFILE); + if (!ret) { + close(fd); + return NULL; + } + memset(ret, 0, sizeof(XFILE)); + + ret->fd = fd; + ret->open_flags = f->open_flags; + x_setvbuf(ret, NULL, X_IOFBF, XBUFSIZE); + return ret; +} diff --git a/source4/lib/util/xfile.h b/lib/util/xfile.h similarity index 97% rename from source4/lib/util/xfile.h rename to lib/util/xfile.h index 2cc369d8d8..af90f3f55c 100644 --- a/source4/lib/util/xfile.h +++ b/lib/util/xfile.h @@ -62,7 +62,7 @@ int x_fclose(XFILE *f); size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f); /** thank goodness for asprintf() */ -int x_fileno(XFILE *f); +int x_fileno(const XFILE *f); /** simulate fflush() */ int x_fflush(XFILE *f); @@ -96,4 +96,6 @@ char *x_fgets(char *s, int size, XFILE *stream) ; * set then an error is returned */ off_t x_tseek(XFILE *f, off_t offset, int whence); +XFILE *x_fdup(const XFILE *f); + #endif /* _XFILE_H_ */ diff --git a/source4/lib/zlib/ChangeLog b/lib/zlib/ChangeLog similarity index 100% rename from source4/lib/zlib/ChangeLog rename to lib/zlib/ChangeLog diff --git a/source4/lib/zlib/FAQ b/lib/zlib/FAQ similarity index 100% rename from source4/lib/zlib/FAQ rename to lib/zlib/FAQ diff --git a/source4/lib/zlib/INDEX b/lib/zlib/INDEX similarity index 100% rename from source4/lib/zlib/INDEX rename to lib/zlib/INDEX diff --git a/source4/lib/zlib/Makefile b/lib/zlib/Makefile similarity index 100% rename from source4/lib/zlib/Makefile rename to lib/zlib/Makefile diff --git a/source4/lib/zlib/Makefile.in b/lib/zlib/Makefile.in similarity index 100% rename from source4/lib/zlib/Makefile.in rename to lib/zlib/Makefile.in diff --git a/source4/lib/zlib/README b/lib/zlib/README similarity index 100% rename from source4/lib/zlib/README rename to lib/zlib/README diff --git a/source4/lib/zlib/adler32.c b/lib/zlib/adler32.c similarity index 100% rename from source4/lib/zlib/adler32.c rename to lib/zlib/adler32.c diff --git a/source4/lib/zlib/algorithm.txt b/lib/zlib/algorithm.txt similarity index 100% rename from source4/lib/zlib/algorithm.txt rename to lib/zlib/algorithm.txt diff --git a/source4/lib/zlib/amiga/Makefile.pup b/lib/zlib/amiga/Makefile.pup similarity index 100% rename from source4/lib/zlib/amiga/Makefile.pup rename to lib/zlib/amiga/Makefile.pup diff --git a/source4/lib/zlib/amiga/Makefile.sas b/lib/zlib/amiga/Makefile.sas similarity index 100% rename from source4/lib/zlib/amiga/Makefile.sas rename to lib/zlib/amiga/Makefile.sas diff --git a/source4/lib/zlib/as400/bndsrc b/lib/zlib/as400/bndsrc similarity index 100% rename from source4/lib/zlib/as400/bndsrc rename to lib/zlib/as400/bndsrc diff --git a/source4/lib/zlib/as400/compile.clp b/lib/zlib/as400/compile.clp similarity index 100% rename from source4/lib/zlib/as400/compile.clp rename to lib/zlib/as400/compile.clp diff --git a/source4/lib/zlib/as400/readme.txt b/lib/zlib/as400/readme.txt similarity index 100% rename from source4/lib/zlib/as400/readme.txt rename to lib/zlib/as400/readme.txt diff --git a/source4/lib/zlib/as400/zlib.inc b/lib/zlib/as400/zlib.inc similarity index 100% rename from source4/lib/zlib/as400/zlib.inc rename to lib/zlib/as400/zlib.inc diff --git a/source4/lib/zlib/compress.c b/lib/zlib/compress.c similarity index 100% rename from source4/lib/zlib/compress.c rename to lib/zlib/compress.c diff --git a/source4/lib/zlib/contrib/README.contrib b/lib/zlib/contrib/README.contrib similarity index 100% rename from source4/lib/zlib/contrib/README.contrib rename to lib/zlib/contrib/README.contrib diff --git a/source4/lib/zlib/contrib/ada/buffer_demo.adb b/lib/zlib/contrib/ada/buffer_demo.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/buffer_demo.adb rename to lib/zlib/contrib/ada/buffer_demo.adb diff --git a/source4/lib/zlib/contrib/ada/mtest.adb b/lib/zlib/contrib/ada/mtest.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/mtest.adb rename to lib/zlib/contrib/ada/mtest.adb diff --git a/source4/lib/zlib/contrib/ada/read.adb b/lib/zlib/contrib/ada/read.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/read.adb rename to lib/zlib/contrib/ada/read.adb diff --git a/source4/lib/zlib/contrib/ada/readme.txt b/lib/zlib/contrib/ada/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/ada/readme.txt rename to lib/zlib/contrib/ada/readme.txt diff --git a/source4/lib/zlib/contrib/ada/test.adb b/lib/zlib/contrib/ada/test.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/test.adb rename to lib/zlib/contrib/ada/test.adb diff --git a/source4/lib/zlib/contrib/ada/zlib-streams.adb b/lib/zlib/contrib/ada/zlib-streams.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib-streams.adb rename to lib/zlib/contrib/ada/zlib-streams.adb diff --git a/source4/lib/zlib/contrib/ada/zlib-streams.ads b/lib/zlib/contrib/ada/zlib-streams.ads similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib-streams.ads rename to lib/zlib/contrib/ada/zlib-streams.ads diff --git a/source4/lib/zlib/contrib/ada/zlib-thin.adb b/lib/zlib/contrib/ada/zlib-thin.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib-thin.adb rename to lib/zlib/contrib/ada/zlib-thin.adb diff --git a/source4/lib/zlib/contrib/ada/zlib-thin.ads b/lib/zlib/contrib/ada/zlib-thin.ads similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib-thin.ads rename to lib/zlib/contrib/ada/zlib-thin.ads diff --git a/source4/lib/zlib/contrib/ada/zlib.adb b/lib/zlib/contrib/ada/zlib.adb similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib.adb rename to lib/zlib/contrib/ada/zlib.adb diff --git a/source4/lib/zlib/contrib/ada/zlib.ads b/lib/zlib/contrib/ada/zlib.ads similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib.ads rename to lib/zlib/contrib/ada/zlib.ads diff --git a/source4/lib/zlib/contrib/ada/zlib.gpr b/lib/zlib/contrib/ada/zlib.gpr similarity index 100% rename from source4/lib/zlib/contrib/ada/zlib.gpr rename to lib/zlib/contrib/ada/zlib.gpr diff --git a/source4/lib/zlib/contrib/asm586/README.586 b/lib/zlib/contrib/asm586/README.586 similarity index 100% rename from source4/lib/zlib/contrib/asm586/README.586 rename to lib/zlib/contrib/asm586/README.586 diff --git a/source4/lib/zlib/contrib/asm586/match.S b/lib/zlib/contrib/asm586/match.S similarity index 100% rename from source4/lib/zlib/contrib/asm586/match.S rename to lib/zlib/contrib/asm586/match.S diff --git a/source4/lib/zlib/contrib/asm686/README.686 b/lib/zlib/contrib/asm686/README.686 similarity index 100% rename from source4/lib/zlib/contrib/asm686/README.686 rename to lib/zlib/contrib/asm686/README.686 diff --git a/source4/lib/zlib/contrib/asm686/match.S b/lib/zlib/contrib/asm686/match.S similarity index 100% rename from source4/lib/zlib/contrib/asm686/match.S rename to lib/zlib/contrib/asm686/match.S diff --git a/source4/lib/zlib/contrib/blast/Makefile b/lib/zlib/contrib/blast/Makefile similarity index 100% rename from source4/lib/zlib/contrib/blast/Makefile rename to lib/zlib/contrib/blast/Makefile diff --git a/source4/lib/zlib/contrib/blast/README b/lib/zlib/contrib/blast/README similarity index 100% rename from source4/lib/zlib/contrib/blast/README rename to lib/zlib/contrib/blast/README diff --git a/source4/lib/zlib/contrib/blast/blast.c b/lib/zlib/contrib/blast/blast.c similarity index 100% rename from source4/lib/zlib/contrib/blast/blast.c rename to lib/zlib/contrib/blast/blast.c diff --git a/source4/lib/zlib/contrib/blast/blast.h b/lib/zlib/contrib/blast/blast.h similarity index 100% rename from source4/lib/zlib/contrib/blast/blast.h rename to lib/zlib/contrib/blast/blast.h diff --git a/source4/lib/zlib/contrib/blast/test.pk b/lib/zlib/contrib/blast/test.pk similarity index 100% rename from source4/lib/zlib/contrib/blast/test.pk rename to lib/zlib/contrib/blast/test.pk diff --git a/source4/lib/zlib/contrib/blast/test.txt b/lib/zlib/contrib/blast/test.txt similarity index 100% rename from source4/lib/zlib/contrib/blast/test.txt rename to lib/zlib/contrib/blast/test.txt diff --git a/source4/lib/zlib/contrib/delphi/ZLib.pas b/lib/zlib/contrib/delphi/ZLib.pas similarity index 100% rename from source4/lib/zlib/contrib/delphi/ZLib.pas rename to lib/zlib/contrib/delphi/ZLib.pas diff --git a/source4/lib/zlib/contrib/delphi/ZLibConst.pas b/lib/zlib/contrib/delphi/ZLibConst.pas similarity index 100% rename from source4/lib/zlib/contrib/delphi/ZLibConst.pas rename to lib/zlib/contrib/delphi/ZLibConst.pas diff --git a/source4/lib/zlib/contrib/delphi/readme.txt b/lib/zlib/contrib/delphi/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/delphi/readme.txt rename to lib/zlib/contrib/delphi/readme.txt diff --git a/source4/lib/zlib/contrib/delphi/zlibd32.mak b/lib/zlib/contrib/delphi/zlibd32.mak similarity index 100% rename from source4/lib/zlib/contrib/delphi/zlibd32.mak rename to lib/zlib/contrib/delphi/zlibd32.mak diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib.build b/lib/zlib/contrib/dotzlib/DotZLib.build similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib.build rename to lib/zlib/contrib/dotzlib/DotZLib.build diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib.chm b/lib/zlib/contrib/dotzlib/DotZLib.chm similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib.chm rename to lib/zlib/contrib/dotzlib/DotZLib.chm diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib.sln b/lib/zlib/contrib/dotzlib/DotZLib.sln similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib.sln rename to lib/zlib/contrib/dotzlib/DotZLib.sln diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs b/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs rename to lib/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs b/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs rename to lib/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs b/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs rename to lib/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs b/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs rename to lib/zlib/contrib/dotzlib/DotZLib/CodecBase.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs b/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs rename to lib/zlib/contrib/dotzlib/DotZLib/Deflater.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs b/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs rename to lib/zlib/contrib/dotzlib/DotZLib/DotZLib.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj b/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj rename to lib/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs b/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs rename to lib/zlib/contrib/dotzlib/DotZLib/GZipStream.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs b/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs rename to lib/zlib/contrib/dotzlib/DotZLib/Inflater.cs diff --git a/source4/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs rename to lib/zlib/contrib/dotzlib/DotZLib/UnitTests.cs diff --git a/source4/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt b/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/LICENSE_1_0.txt rename to lib/zlib/contrib/dotzlib/LICENSE_1_0.txt diff --git a/source4/lib/zlib/contrib/dotzlib/readme.txt b/lib/zlib/contrib/dotzlib/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/dotzlib/readme.txt rename to lib/zlib/contrib/dotzlib/readme.txt diff --git a/source4/lib/zlib/contrib/infback9/README b/lib/zlib/contrib/infback9/README similarity index 100% rename from source4/lib/zlib/contrib/infback9/README rename to lib/zlib/contrib/infback9/README diff --git a/source4/lib/zlib/contrib/infback9/infback9.c b/lib/zlib/contrib/infback9/infback9.c similarity index 100% rename from source4/lib/zlib/contrib/infback9/infback9.c rename to lib/zlib/contrib/infback9/infback9.c diff --git a/source4/lib/zlib/contrib/infback9/infback9.h b/lib/zlib/contrib/infback9/infback9.h similarity index 100% rename from source4/lib/zlib/contrib/infback9/infback9.h rename to lib/zlib/contrib/infback9/infback9.h diff --git a/source4/lib/zlib/contrib/infback9/inffix9.h b/lib/zlib/contrib/infback9/inffix9.h similarity index 100% rename from source4/lib/zlib/contrib/infback9/inffix9.h rename to lib/zlib/contrib/infback9/inffix9.h diff --git a/source4/lib/zlib/contrib/infback9/inflate9.h b/lib/zlib/contrib/infback9/inflate9.h similarity index 100% rename from source4/lib/zlib/contrib/infback9/inflate9.h rename to lib/zlib/contrib/infback9/inflate9.h diff --git a/source4/lib/zlib/contrib/infback9/inftree9.c b/lib/zlib/contrib/infback9/inftree9.c similarity index 100% rename from source4/lib/zlib/contrib/infback9/inftree9.c rename to lib/zlib/contrib/infback9/inftree9.c diff --git a/source4/lib/zlib/contrib/infback9/inftree9.h b/lib/zlib/contrib/infback9/inftree9.h similarity index 100% rename from source4/lib/zlib/contrib/infback9/inftree9.h rename to lib/zlib/contrib/infback9/inftree9.h diff --git a/source4/lib/zlib/contrib/inflate86/inffas86.c b/lib/zlib/contrib/inflate86/inffas86.c similarity index 100% rename from source4/lib/zlib/contrib/inflate86/inffas86.c rename to lib/zlib/contrib/inflate86/inffas86.c diff --git a/source4/lib/zlib/contrib/inflate86/inffast.S b/lib/zlib/contrib/inflate86/inffast.S similarity index 100% rename from source4/lib/zlib/contrib/inflate86/inffast.S rename to lib/zlib/contrib/inflate86/inffast.S diff --git a/source4/lib/zlib/contrib/iostream/test.cpp b/lib/zlib/contrib/iostream/test.cpp similarity index 100% rename from source4/lib/zlib/contrib/iostream/test.cpp rename to lib/zlib/contrib/iostream/test.cpp diff --git a/source4/lib/zlib/contrib/iostream/zfstream.cpp b/lib/zlib/contrib/iostream/zfstream.cpp similarity index 100% rename from source4/lib/zlib/contrib/iostream/zfstream.cpp rename to lib/zlib/contrib/iostream/zfstream.cpp diff --git a/source4/lib/zlib/contrib/iostream/zfstream.h b/lib/zlib/contrib/iostream/zfstream.h similarity index 100% rename from source4/lib/zlib/contrib/iostream/zfstream.h rename to lib/zlib/contrib/iostream/zfstream.h diff --git a/source4/lib/zlib/contrib/iostream2/zstream.h b/lib/zlib/contrib/iostream2/zstream.h similarity index 100% rename from source4/lib/zlib/contrib/iostream2/zstream.h rename to lib/zlib/contrib/iostream2/zstream.h diff --git a/source4/lib/zlib/contrib/iostream2/zstream_test.cpp b/lib/zlib/contrib/iostream2/zstream_test.cpp similarity index 100% rename from source4/lib/zlib/contrib/iostream2/zstream_test.cpp rename to lib/zlib/contrib/iostream2/zstream_test.cpp diff --git a/source4/lib/zlib/contrib/iostream3/README b/lib/zlib/contrib/iostream3/README similarity index 100% rename from source4/lib/zlib/contrib/iostream3/README rename to lib/zlib/contrib/iostream3/README diff --git a/source4/lib/zlib/contrib/iostream3/TODO b/lib/zlib/contrib/iostream3/TODO similarity index 100% rename from source4/lib/zlib/contrib/iostream3/TODO rename to lib/zlib/contrib/iostream3/TODO diff --git a/source4/lib/zlib/contrib/iostream3/test.cc b/lib/zlib/contrib/iostream3/test.cc similarity index 100% rename from source4/lib/zlib/contrib/iostream3/test.cc rename to lib/zlib/contrib/iostream3/test.cc diff --git a/source4/lib/zlib/contrib/iostream3/zfstream.cc b/lib/zlib/contrib/iostream3/zfstream.cc similarity index 100% rename from source4/lib/zlib/contrib/iostream3/zfstream.cc rename to lib/zlib/contrib/iostream3/zfstream.cc diff --git a/source4/lib/zlib/contrib/iostream3/zfstream.h b/lib/zlib/contrib/iostream3/zfstream.h similarity index 100% rename from source4/lib/zlib/contrib/iostream3/zfstream.h rename to lib/zlib/contrib/iostream3/zfstream.h diff --git a/source4/lib/zlib/contrib/masm686/match.asm b/lib/zlib/contrib/masm686/match.asm similarity index 100% rename from source4/lib/zlib/contrib/masm686/match.asm rename to lib/zlib/contrib/masm686/match.asm diff --git a/source4/lib/zlib/contrib/masmx64/bld_ml64.bat b/lib/zlib/contrib/masmx64/bld_ml64.bat similarity index 100% rename from source4/lib/zlib/contrib/masmx64/bld_ml64.bat rename to lib/zlib/contrib/masmx64/bld_ml64.bat diff --git a/source4/lib/zlib/contrib/masmx64/gvmat64.asm b/lib/zlib/contrib/masmx64/gvmat64.asm similarity index 100% rename from source4/lib/zlib/contrib/masmx64/gvmat64.asm rename to lib/zlib/contrib/masmx64/gvmat64.asm diff --git a/source4/lib/zlib/contrib/masmx64/gvmat64.obj b/lib/zlib/contrib/masmx64/gvmat64.obj similarity index 100% rename from source4/lib/zlib/contrib/masmx64/gvmat64.obj rename to lib/zlib/contrib/masmx64/gvmat64.obj diff --git a/source4/lib/zlib/contrib/masmx64/inffas8664.c b/lib/zlib/contrib/masmx64/inffas8664.c similarity index 100% rename from source4/lib/zlib/contrib/masmx64/inffas8664.c rename to lib/zlib/contrib/masmx64/inffas8664.c diff --git a/source4/lib/zlib/contrib/masmx64/inffasx64.asm b/lib/zlib/contrib/masmx64/inffasx64.asm similarity index 100% rename from source4/lib/zlib/contrib/masmx64/inffasx64.asm rename to lib/zlib/contrib/masmx64/inffasx64.asm diff --git a/source4/lib/zlib/contrib/masmx64/inffasx64.obj b/lib/zlib/contrib/masmx64/inffasx64.obj similarity index 100% rename from source4/lib/zlib/contrib/masmx64/inffasx64.obj rename to lib/zlib/contrib/masmx64/inffasx64.obj diff --git a/source4/lib/zlib/contrib/masmx64/readme.txt b/lib/zlib/contrib/masmx64/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/masmx64/readme.txt rename to lib/zlib/contrib/masmx64/readme.txt diff --git a/source4/lib/zlib/contrib/masmx86/bld_ml32.bat b/lib/zlib/contrib/masmx86/bld_ml32.bat similarity index 100% rename from source4/lib/zlib/contrib/masmx86/bld_ml32.bat rename to lib/zlib/contrib/masmx86/bld_ml32.bat diff --git a/source4/lib/zlib/contrib/masmx86/gvmat32.asm b/lib/zlib/contrib/masmx86/gvmat32.asm similarity index 100% rename from source4/lib/zlib/contrib/masmx86/gvmat32.asm rename to lib/zlib/contrib/masmx86/gvmat32.asm diff --git a/source4/lib/zlib/contrib/masmx86/gvmat32.obj b/lib/zlib/contrib/masmx86/gvmat32.obj similarity index 100% rename from source4/lib/zlib/contrib/masmx86/gvmat32.obj rename to lib/zlib/contrib/masmx86/gvmat32.obj diff --git a/source4/lib/zlib/contrib/masmx86/gvmat32c.c b/lib/zlib/contrib/masmx86/gvmat32c.c similarity index 100% rename from source4/lib/zlib/contrib/masmx86/gvmat32c.c rename to lib/zlib/contrib/masmx86/gvmat32c.c diff --git a/source4/lib/zlib/contrib/masmx86/inffas32.asm b/lib/zlib/contrib/masmx86/inffas32.asm similarity index 100% rename from source4/lib/zlib/contrib/masmx86/inffas32.asm rename to lib/zlib/contrib/masmx86/inffas32.asm diff --git a/source4/lib/zlib/contrib/masmx86/inffas32.obj b/lib/zlib/contrib/masmx86/inffas32.obj similarity index 100% rename from source4/lib/zlib/contrib/masmx86/inffas32.obj rename to lib/zlib/contrib/masmx86/inffas32.obj diff --git a/source4/lib/zlib/contrib/masmx86/mkasm.bat b/lib/zlib/contrib/masmx86/mkasm.bat similarity index 100% rename from source4/lib/zlib/contrib/masmx86/mkasm.bat rename to lib/zlib/contrib/masmx86/mkasm.bat diff --git a/source4/lib/zlib/contrib/masmx86/readme.txt b/lib/zlib/contrib/masmx86/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/masmx86/readme.txt rename to lib/zlib/contrib/masmx86/readme.txt diff --git a/source4/lib/zlib/contrib/minizip/ChangeLogUnzip b/lib/zlib/contrib/minizip/ChangeLogUnzip similarity index 100% rename from source4/lib/zlib/contrib/minizip/ChangeLogUnzip rename to lib/zlib/contrib/minizip/ChangeLogUnzip diff --git a/source4/lib/zlib/contrib/minizip/Makefile b/lib/zlib/contrib/minizip/Makefile similarity index 100% rename from source4/lib/zlib/contrib/minizip/Makefile rename to lib/zlib/contrib/minizip/Makefile diff --git a/source4/lib/zlib/contrib/minizip/crypt.h b/lib/zlib/contrib/minizip/crypt.h similarity index 100% rename from source4/lib/zlib/contrib/minizip/crypt.h rename to lib/zlib/contrib/minizip/crypt.h diff --git a/source4/lib/zlib/contrib/minizip/ioapi.c b/lib/zlib/contrib/minizip/ioapi.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/ioapi.c rename to lib/zlib/contrib/minizip/ioapi.c diff --git a/source4/lib/zlib/contrib/minizip/ioapi.h b/lib/zlib/contrib/minizip/ioapi.h similarity index 100% rename from source4/lib/zlib/contrib/minizip/ioapi.h rename to lib/zlib/contrib/minizip/ioapi.h diff --git a/source4/lib/zlib/contrib/minizip/iowin32.c b/lib/zlib/contrib/minizip/iowin32.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/iowin32.c rename to lib/zlib/contrib/minizip/iowin32.c diff --git a/source4/lib/zlib/contrib/minizip/iowin32.h b/lib/zlib/contrib/minizip/iowin32.h similarity index 100% rename from source4/lib/zlib/contrib/minizip/iowin32.h rename to lib/zlib/contrib/minizip/iowin32.h diff --git a/source4/lib/zlib/contrib/minizip/miniunz.c b/lib/zlib/contrib/minizip/miniunz.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/miniunz.c rename to lib/zlib/contrib/minizip/miniunz.c diff --git a/source4/lib/zlib/contrib/minizip/minizip.c b/lib/zlib/contrib/minizip/minizip.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/minizip.c rename to lib/zlib/contrib/minizip/minizip.c diff --git a/source4/lib/zlib/contrib/minizip/mztools.c b/lib/zlib/contrib/minizip/mztools.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/mztools.c rename to lib/zlib/contrib/minizip/mztools.c diff --git a/source4/lib/zlib/contrib/minizip/mztools.h b/lib/zlib/contrib/minizip/mztools.h similarity index 100% rename from source4/lib/zlib/contrib/minizip/mztools.h rename to lib/zlib/contrib/minizip/mztools.h diff --git a/source4/lib/zlib/contrib/minizip/unzip.c b/lib/zlib/contrib/minizip/unzip.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/unzip.c rename to lib/zlib/contrib/minizip/unzip.c diff --git a/source4/lib/zlib/contrib/minizip/unzip.h b/lib/zlib/contrib/minizip/unzip.h similarity index 100% rename from source4/lib/zlib/contrib/minizip/unzip.h rename to lib/zlib/contrib/minizip/unzip.h diff --git a/source4/lib/zlib/contrib/minizip/zip.c b/lib/zlib/contrib/minizip/zip.c similarity index 100% rename from source4/lib/zlib/contrib/minizip/zip.c rename to lib/zlib/contrib/minizip/zip.c diff --git a/source4/lib/zlib/contrib/minizip/zip.h b/lib/zlib/contrib/minizip/zip.h similarity index 100% rename from source4/lib/zlib/contrib/minizip/zip.h rename to lib/zlib/contrib/minizip/zip.h diff --git a/source4/lib/zlib/contrib/pascal/example.pas b/lib/zlib/contrib/pascal/example.pas similarity index 100% rename from source4/lib/zlib/contrib/pascal/example.pas rename to lib/zlib/contrib/pascal/example.pas diff --git a/source4/lib/zlib/contrib/pascal/readme.txt b/lib/zlib/contrib/pascal/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/pascal/readme.txt rename to lib/zlib/contrib/pascal/readme.txt diff --git a/source4/lib/zlib/contrib/pascal/zlibd32.mak b/lib/zlib/contrib/pascal/zlibd32.mak similarity index 100% rename from source4/lib/zlib/contrib/pascal/zlibd32.mak rename to lib/zlib/contrib/pascal/zlibd32.mak diff --git a/source4/lib/zlib/contrib/pascal/zlibpas.pas b/lib/zlib/contrib/pascal/zlibpas.pas similarity index 100% rename from source4/lib/zlib/contrib/pascal/zlibpas.pas rename to lib/zlib/contrib/pascal/zlibpas.pas diff --git a/source4/lib/zlib/contrib/puff/Makefile b/lib/zlib/contrib/puff/Makefile similarity index 100% rename from source4/lib/zlib/contrib/puff/Makefile rename to lib/zlib/contrib/puff/Makefile diff --git a/source4/lib/zlib/contrib/puff/README b/lib/zlib/contrib/puff/README similarity index 100% rename from source4/lib/zlib/contrib/puff/README rename to lib/zlib/contrib/puff/README diff --git a/source4/lib/zlib/contrib/puff/puff.c b/lib/zlib/contrib/puff/puff.c similarity index 100% rename from source4/lib/zlib/contrib/puff/puff.c rename to lib/zlib/contrib/puff/puff.c diff --git a/source4/lib/zlib/contrib/puff/puff.h b/lib/zlib/contrib/puff/puff.h similarity index 100% rename from source4/lib/zlib/contrib/puff/puff.h rename to lib/zlib/contrib/puff/puff.h diff --git a/source4/lib/zlib/contrib/puff/zeros.raw b/lib/zlib/contrib/puff/zeros.raw similarity index 100% rename from source4/lib/zlib/contrib/puff/zeros.raw rename to lib/zlib/contrib/puff/zeros.raw diff --git a/source4/lib/zlib/contrib/testzlib/testzlib.c b/lib/zlib/contrib/testzlib/testzlib.c similarity index 100% rename from source4/lib/zlib/contrib/testzlib/testzlib.c rename to lib/zlib/contrib/testzlib/testzlib.c diff --git a/source4/lib/zlib/contrib/testzlib/testzlib.txt b/lib/zlib/contrib/testzlib/testzlib.txt similarity index 100% rename from source4/lib/zlib/contrib/testzlib/testzlib.txt rename to lib/zlib/contrib/testzlib/testzlib.txt diff --git a/source4/lib/zlib/contrib/untgz/Makefile b/lib/zlib/contrib/untgz/Makefile similarity index 100% rename from source4/lib/zlib/contrib/untgz/Makefile rename to lib/zlib/contrib/untgz/Makefile diff --git a/source4/lib/zlib/contrib/untgz/Makefile.msc b/lib/zlib/contrib/untgz/Makefile.msc similarity index 100% rename from source4/lib/zlib/contrib/untgz/Makefile.msc rename to lib/zlib/contrib/untgz/Makefile.msc diff --git a/source4/lib/zlib/contrib/untgz/untgz.c b/lib/zlib/contrib/untgz/untgz.c similarity index 100% rename from source4/lib/zlib/contrib/untgz/untgz.c rename to lib/zlib/contrib/untgz/untgz.c diff --git a/source4/lib/zlib/contrib/vstudio/readme.txt b/lib/zlib/contrib/vstudio/readme.txt similarity index 100% rename from source4/lib/zlib/contrib/vstudio/readme.txt rename to lib/zlib/contrib/vstudio/readme.txt diff --git a/source4/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj b/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/miniunz.vcproj rename to lib/zlib/contrib/vstudio/vc7/miniunz.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc7/minizip.vcproj b/lib/zlib/contrib/vstudio/vc7/minizip.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/minizip.vcproj rename to lib/zlib/contrib/vstudio/vc7/minizip.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj b/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/testzlib.vcproj rename to lib/zlib/contrib/vstudio/vc7/testzlib.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlib.rc b/lib/zlib/contrib/vstudio/vc7/zlib.rc similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/zlib.rc rename to lib/zlib/contrib/vstudio/vc7/zlib.rc diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj b/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj rename to lib/zlib/contrib/vstudio/vc7/zlibstat.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.def b/lib/zlib/contrib/vstudio/vc7/zlibvc.def similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/zlibvc.def rename to lib/zlib/contrib/vstudio/vc7/zlibvc.def diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.sln b/lib/zlib/contrib/vstudio/vc7/zlibvc.sln similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/zlibvc.sln rename to lib/zlib/contrib/vstudio/vc7/zlibvc.sln diff --git a/source4/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj b/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj rename to lib/zlib/contrib/vstudio/vc7/zlibvc.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj b/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/miniunz.vcproj rename to lib/zlib/contrib/vstudio/vc8/miniunz.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc8/minizip.vcproj b/lib/zlib/contrib/vstudio/vc8/minizip.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/minizip.vcproj rename to lib/zlib/contrib/vstudio/vc8/minizip.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj b/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/testzlib.vcproj rename to lib/zlib/contrib/vstudio/vc8/testzlib.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj b/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj rename to lib/zlib/contrib/vstudio/vc8/testzlibdll.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlib.rc b/lib/zlib/contrib/vstudio/vc8/zlib.rc similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/zlib.rc rename to lib/zlib/contrib/vstudio/vc8/zlib.rc diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj b/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj rename to lib/zlib/contrib/vstudio/vc8/zlibstat.vcproj diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.def b/lib/zlib/contrib/vstudio/vc8/zlibvc.def similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/zlibvc.def rename to lib/zlib/contrib/vstudio/vc8/zlibvc.def diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.sln b/lib/zlib/contrib/vstudio/vc8/zlibvc.sln similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/zlibvc.sln rename to lib/zlib/contrib/vstudio/vc8/zlibvc.sln diff --git a/source4/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj b/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj similarity index 100% rename from source4/lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj rename to lib/zlib/contrib/vstudio/vc8/zlibvc.vcproj diff --git a/source4/lib/zlib/crc32.c b/lib/zlib/crc32.c similarity index 100% rename from source4/lib/zlib/crc32.c rename to lib/zlib/crc32.c diff --git a/source4/lib/zlib/crc32.h b/lib/zlib/crc32.h similarity index 100% rename from source4/lib/zlib/crc32.h rename to lib/zlib/crc32.h diff --git a/source4/lib/zlib/deflate.c b/lib/zlib/deflate.c similarity index 100% rename from source4/lib/zlib/deflate.c rename to lib/zlib/deflate.c diff --git a/source4/lib/zlib/deflate.h b/lib/zlib/deflate.h similarity index 100% rename from source4/lib/zlib/deflate.h rename to lib/zlib/deflate.h diff --git a/source4/lib/zlib/example.c b/lib/zlib/example.c similarity index 100% rename from source4/lib/zlib/example.c rename to lib/zlib/example.c diff --git a/source4/lib/zlib/examples/README.examples b/lib/zlib/examples/README.examples similarity index 100% rename from source4/lib/zlib/examples/README.examples rename to lib/zlib/examples/README.examples diff --git a/source4/lib/zlib/examples/fitblk.c b/lib/zlib/examples/fitblk.c similarity index 100% rename from source4/lib/zlib/examples/fitblk.c rename to lib/zlib/examples/fitblk.c diff --git a/source4/lib/zlib/examples/gun.c b/lib/zlib/examples/gun.c similarity index 100% rename from source4/lib/zlib/examples/gun.c rename to lib/zlib/examples/gun.c diff --git a/source4/lib/zlib/examples/gzappend.c b/lib/zlib/examples/gzappend.c similarity index 100% rename from source4/lib/zlib/examples/gzappend.c rename to lib/zlib/examples/gzappend.c diff --git a/source4/lib/zlib/examples/gzjoin.c b/lib/zlib/examples/gzjoin.c similarity index 100% rename from source4/lib/zlib/examples/gzjoin.c rename to lib/zlib/examples/gzjoin.c diff --git a/source4/lib/zlib/examples/gzlog.c b/lib/zlib/examples/gzlog.c similarity index 100% rename from source4/lib/zlib/examples/gzlog.c rename to lib/zlib/examples/gzlog.c diff --git a/source4/lib/zlib/examples/gzlog.h b/lib/zlib/examples/gzlog.h similarity index 100% rename from source4/lib/zlib/examples/gzlog.h rename to lib/zlib/examples/gzlog.h diff --git a/source4/lib/zlib/examples/zlib_how.html b/lib/zlib/examples/zlib_how.html similarity index 100% rename from source4/lib/zlib/examples/zlib_how.html rename to lib/zlib/examples/zlib_how.html diff --git a/source4/lib/zlib/examples/zpipe.c b/lib/zlib/examples/zpipe.c similarity index 100% rename from source4/lib/zlib/examples/zpipe.c rename to lib/zlib/examples/zpipe.c diff --git a/source4/lib/zlib/examples/zran.c b/lib/zlib/examples/zran.c similarity index 100% rename from source4/lib/zlib/examples/zran.c rename to lib/zlib/examples/zran.c diff --git a/source4/lib/zlib/gzio.c b/lib/zlib/gzio.c similarity index 100% rename from source4/lib/zlib/gzio.c rename to lib/zlib/gzio.c diff --git a/source4/lib/zlib/infback.c b/lib/zlib/infback.c similarity index 97% rename from source4/lib/zlib/infback.c rename to lib/zlib/infback.c index 5680937f34..284d523a6d 100644 --- a/source4/lib/zlib/infback.c +++ b/lib/zlib/infback.c @@ -309,7 +309,7 @@ void FAR *out_desc; break; case 3: strm->msg = "invalid block type"; - state->mode = BAD; + state->mode = BAD_DATA; } DROPBITS(2); break; @@ -320,7 +320,7 @@ void FAR *out_desc; NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = "invalid stored block lengths"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->length = (unsigned)hold & 0xffff; @@ -358,7 +358,7 @@ void FAR *out_desc; #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { strm->msg = "too many length or distance symbols"; - state->mode = BAD; + state->mode = BAD_DATA; break; } #endif @@ -380,7 +380,7 @@ void FAR *out_desc; &(state->lenbits), state->work); if (ret) { strm->msg = "invalid code lengths set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } Tracev((stderr, "inflate: code lengths ok\n")); @@ -404,7 +404,7 @@ void FAR *out_desc; DROPBITS(this.bits); if (state->have == 0) { strm->msg = "invalid bit length repeat"; - state->mode = BAD; + state->mode = BAD_DATA; break; } len = (unsigned)(state->lens[state->have - 1]); @@ -427,7 +427,7 @@ void FAR *out_desc; } if (state->have + copy > state->nlen + state->ndist) { strm->msg = "invalid bit length repeat"; - state->mode = BAD; + state->mode = BAD_DATA; break; } while (copy--) @@ -436,7 +436,7 @@ void FAR *out_desc; } /* handle error breaks in while */ - if (state->mode == BAD) break; + if (state->mode == BAD_DATA) break; /* build code tables */ state->next = state->codes; @@ -446,7 +446,7 @@ void FAR *out_desc; &(state->lenbits), state->work); if (ret) { strm->msg = "invalid literal/lengths set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->distcode = (code const FAR *)(state->next); @@ -455,7 +455,7 @@ void FAR *out_desc; &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = "invalid distances set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } Tracev((stderr, "inflate: codes ok\n")); @@ -513,7 +513,7 @@ void FAR *out_desc; /* invalid code */ if (this.op & 64) { strm->msg = "invalid literal/length code"; - state->mode = BAD; + state->mode = BAD_DATA; break; } @@ -545,7 +545,7 @@ void FAR *out_desc; DROPBITS(this.bits); if (this.op & 64) { strm->msg = "invalid distance code"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->offset = (unsigned)this.val; @@ -560,7 +560,7 @@ void FAR *out_desc; if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) { strm->msg = "invalid distance too far back"; - state->mode = BAD; + state->mode = BAD_DATA; break; } Tracevv((stderr, "inflate: distance %u\n", state->offset)); @@ -595,7 +595,7 @@ void FAR *out_desc; } goto inf_leave; - case BAD: + case BAD_DATA: ret = Z_DATA_ERROR; goto inf_leave; diff --git a/source4/lib/zlib/inffast.c b/lib/zlib/inffast.c similarity index 98% rename from source4/lib/zlib/inffast.c rename to lib/zlib/inffast.c index bfc727694a..687dfa054b 100644 --- a/source4/lib/zlib/inffast.c +++ b/lib/zlib/inffast.c @@ -49,7 +49,7 @@ LEN -- ran out of enough output space or enough available input TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data + BAD_DATA -- error in block data Notes: @@ -176,7 +176,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ #ifdef INFLATE_STRICT if (dist > dmax) { strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; + state->mode = BAD_DATA; break; } #endif @@ -188,7 +188,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ op = dist - op; /* distance back in window */ if (op > whave) { strm->msg = "invalid distance too far back"; - state->mode = BAD; + state->mode = BAD_DATA; break; } from = window - OFF; @@ -264,7 +264,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ } else { strm->msg = "invalid distance code"; - state->mode = BAD; + state->mode = BAD_DATA; break; } } @@ -279,7 +279,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ } else { strm->msg = "invalid literal/length code"; - state->mode = BAD; + state->mode = BAD_DATA; break; } } while (in < last && out < end); diff --git a/source4/lib/zlib/inffast.h b/lib/zlib/inffast.h similarity index 100% rename from source4/lib/zlib/inffast.h rename to lib/zlib/inffast.h diff --git a/source4/lib/zlib/inffixed.h b/lib/zlib/inffixed.h similarity index 100% rename from source4/lib/zlib/inffixed.h rename to lib/zlib/inffixed.h diff --git a/source4/lib/zlib/inflate.c b/lib/zlib/inflate.c similarity index 98% rename from source4/lib/zlib/inflate.c rename to lib/zlib/inflate.c index ccbfac804d..bcaca0d773 100644 --- a/source4/lib/zlib/inflate.c +++ b/lib/zlib/inflate.c @@ -609,19 +609,19 @@ int flush; #endif ((BITS(8) << 8) + (hold >> 8)) % 31) { strm->msg = "incorrect header check"; - state->mode = BAD; + state->mode = BAD_DATA; break; } if (BITS(4) != Z_DEFLATED) { strm->msg = "unknown compression method"; - state->mode = BAD; + state->mode = BAD_DATA; break; } DROPBITS(4); len = BITS(4) + 8; if (len > state->wbits) { strm->msg = "invalid window size"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->dmax = 1U << len; @@ -636,12 +636,12 @@ int flush; state->flags = (int)(hold); if ((state->flags & 0xff) != Z_DEFLATED) { strm->msg = "unknown compression method"; - state->mode = BAD; + state->mode = BAD_DATA; break; } if (state->flags & 0xe000) { strm->msg = "unknown header flags set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } if (state->head != Z_NULL) @@ -745,7 +745,7 @@ int flush; NEEDBITS(16); if (hold != (state->check & 0xffff)) { strm->msg = "header crc mismatch"; - state->mode = BAD; + state->mode = BAD_DATA; break; } INITBITS(); @@ -800,7 +800,7 @@ int flush; break; case 3: strm->msg = "invalid block type"; - state->mode = BAD; + state->mode = BAD_DATA; } DROPBITS(2); break; @@ -809,7 +809,7 @@ int flush; NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = "invalid stored block lengths"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->length = (unsigned)hold & 0xffff; @@ -845,7 +845,7 @@ int flush; #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { strm->msg = "too many length or distance symbols"; - state->mode = BAD; + state->mode = BAD_DATA; break; } #endif @@ -867,7 +867,7 @@ int flush; &(state->lenbits), state->work); if (ret) { strm->msg = "invalid code lengths set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } Tracev((stderr, "inflate: code lengths ok\n")); @@ -891,7 +891,7 @@ int flush; DROPBITS(this.bits); if (state->have == 0) { strm->msg = "invalid bit length repeat"; - state->mode = BAD; + state->mode = BAD_DATA; break; } len = state->lens[state->have - 1]; @@ -914,7 +914,7 @@ int flush; } if (state->have + copy > state->nlen + state->ndist) { strm->msg = "invalid bit length repeat"; - state->mode = BAD; + state->mode = BAD_DATA; break; } while (copy--) @@ -923,7 +923,7 @@ int flush; } /* handle error breaks in while */ - if (state->mode == BAD) break; + if (state->mode == BAD_DATA) break; /* build code tables */ state->next = state->codes; @@ -933,7 +933,7 @@ int flush; &(state->lenbits), state->work); if (ret) { strm->msg = "invalid literal/lengths set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->distcode = (code const FAR *)(state->next); @@ -942,7 +942,7 @@ int flush; &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = "invalid distances set"; - state->mode = BAD; + state->mode = BAD_DATA; break; } Tracev((stderr, "inflate: codes ok\n")); @@ -985,7 +985,7 @@ int flush; } if (this.op & 64) { strm->msg = "invalid literal/length code"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->extra = (unsigned)(this.op) & 15; @@ -1017,7 +1017,7 @@ int flush; DROPBITS(this.bits); if (this.op & 64) { strm->msg = "invalid distance code"; - state->mode = BAD; + state->mode = BAD_DATA; break; } state->offset = (unsigned)this.val; @@ -1032,13 +1032,13 @@ int flush; #ifdef INFLATE_STRICT if (state->offset > state->dmax) { strm->msg = "invalid distance too far back"; - state->mode = BAD; + state->mode = BAD_DATA; break; } #endif if (state->offset > state->whave + out - left) { strm->msg = "invalid distance too far back"; - state->mode = BAD; + state->mode = BAD_DATA; break; } Tracevv((stderr, "inflate: distance %u\n", state->offset)); @@ -1090,7 +1090,7 @@ int flush; #endif REVERSE(hold)) != state->check) { strm->msg = "incorrect data check"; - state->mode = BAD; + state->mode = BAD_DATA; break; } INITBITS(); @@ -1103,7 +1103,7 @@ int flush; NEEDBITS(32); if (hold != (state->total & 0xffffffffUL)) { strm->msg = "incorrect length check"; - state->mode = BAD; + state->mode = BAD_DATA; break; } INITBITS(); @@ -1114,7 +1114,7 @@ int flush; case DONE: ret = Z_STREAM_END; goto inf_leave; - case BAD: + case BAD_DATA: ret = Z_DATA_ERROR; goto inf_leave; case MEM: diff --git a/source4/lib/zlib/inflate.h b/lib/zlib/inflate.h similarity index 97% rename from source4/lib/zlib/inflate.h rename to lib/zlib/inflate.h index 07bd3e78a7..25b6538bc2 100644 --- a/source4/lib/zlib/inflate.h +++ b/lib/zlib/inflate.h @@ -45,7 +45,7 @@ typedef enum { CHECK, /* i: waiting for 32-bit check value */ LENGTH, /* i: waiting for 32-bit length (gzip) */ DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ + BAD_DATA, /* got a data error -- remain here until reset */ MEM, /* got an inflate() memory error -- remain here until reset */ SYNC /* looking for synchronization bytes to restart inflate() */ } inflate_mode; @@ -53,7 +53,7 @@ typedef enum { /* State transitions between above modes - - (most modes can go to the BAD or MEM mode -- not shown for clarity) + (most modes can go to the BAD_DATA or MEM mode -- not shown for clarity) Process header: HEAD -> (gzip) or (zlib) diff --git a/source4/lib/zlib/inftrees.c b/lib/zlib/inftrees.c similarity index 100% rename from source4/lib/zlib/inftrees.c rename to lib/zlib/inftrees.c diff --git a/source4/lib/zlib/inftrees.h b/lib/zlib/inftrees.h similarity index 100% rename from source4/lib/zlib/inftrees.h rename to lib/zlib/inftrees.h diff --git a/source4/lib/zlib/make_vms.com b/lib/zlib/make_vms.com similarity index 100% rename from source4/lib/zlib/make_vms.com rename to lib/zlib/make_vms.com diff --git a/source4/lib/zlib/minigzip.c b/lib/zlib/minigzip.c similarity index 100% rename from source4/lib/zlib/minigzip.c rename to lib/zlib/minigzip.c diff --git a/source4/lib/zlib/msdos/Makefile.bor b/lib/zlib/msdos/Makefile.bor similarity index 100% rename from source4/lib/zlib/msdos/Makefile.bor rename to lib/zlib/msdos/Makefile.bor diff --git a/source4/lib/zlib/msdos/Makefile.dj2 b/lib/zlib/msdos/Makefile.dj2 similarity index 100% rename from source4/lib/zlib/msdos/Makefile.dj2 rename to lib/zlib/msdos/Makefile.dj2 diff --git a/source4/lib/zlib/msdos/Makefile.emx b/lib/zlib/msdos/Makefile.emx similarity index 100% rename from source4/lib/zlib/msdos/Makefile.emx rename to lib/zlib/msdos/Makefile.emx diff --git a/source4/lib/zlib/msdos/Makefile.msc b/lib/zlib/msdos/Makefile.msc similarity index 100% rename from source4/lib/zlib/msdos/Makefile.msc rename to lib/zlib/msdos/Makefile.msc diff --git a/source4/lib/zlib/msdos/Makefile.tc b/lib/zlib/msdos/Makefile.tc similarity index 100% rename from source4/lib/zlib/msdos/Makefile.tc rename to lib/zlib/msdos/Makefile.tc diff --git a/source4/lib/zlib/old/Makefile.riscos b/lib/zlib/old/Makefile.riscos similarity index 100% rename from source4/lib/zlib/old/Makefile.riscos rename to lib/zlib/old/Makefile.riscos diff --git a/source4/lib/zlib/old/README b/lib/zlib/old/README similarity index 100% rename from source4/lib/zlib/old/README rename to lib/zlib/old/README diff --git a/source4/lib/zlib/old/descrip.mms b/lib/zlib/old/descrip.mms similarity index 100% rename from source4/lib/zlib/old/descrip.mms rename to lib/zlib/old/descrip.mms diff --git a/source4/lib/zlib/old/os2/Makefile.os2 b/lib/zlib/old/os2/Makefile.os2 similarity index 100% rename from source4/lib/zlib/old/os2/Makefile.os2 rename to lib/zlib/old/os2/Makefile.os2 diff --git a/source4/lib/zlib/old/os2/zlib.def b/lib/zlib/old/os2/zlib.def similarity index 100% rename from source4/lib/zlib/old/os2/zlib.def rename to lib/zlib/old/os2/zlib.def diff --git a/source4/lib/zlib/old/visual-basic.txt b/lib/zlib/old/visual-basic.txt similarity index 100% rename from source4/lib/zlib/old/visual-basic.txt rename to lib/zlib/old/visual-basic.txt diff --git a/source4/lib/zlib/old/zlib.html b/lib/zlib/old/zlib.html similarity index 100% rename from source4/lib/zlib/old/zlib.html rename to lib/zlib/old/zlib.html diff --git a/source4/lib/zlib/projects/README.projects b/lib/zlib/projects/README.projects similarity index 100% rename from source4/lib/zlib/projects/README.projects rename to lib/zlib/projects/README.projects diff --git a/source4/lib/zlib/projects/visualc6/README.txt b/lib/zlib/projects/visualc6/README.txt similarity index 100% rename from source4/lib/zlib/projects/visualc6/README.txt rename to lib/zlib/projects/visualc6/README.txt diff --git a/source4/lib/zlib/projects/visualc6/example.dsp b/lib/zlib/projects/visualc6/example.dsp similarity index 100% rename from source4/lib/zlib/projects/visualc6/example.dsp rename to lib/zlib/projects/visualc6/example.dsp diff --git a/source4/lib/zlib/projects/visualc6/minigzip.dsp b/lib/zlib/projects/visualc6/minigzip.dsp similarity index 100% rename from source4/lib/zlib/projects/visualc6/minigzip.dsp rename to lib/zlib/projects/visualc6/minigzip.dsp diff --git a/source4/lib/zlib/projects/visualc6/zlib.dsp b/lib/zlib/projects/visualc6/zlib.dsp similarity index 100% rename from source4/lib/zlib/projects/visualc6/zlib.dsp rename to lib/zlib/projects/visualc6/zlib.dsp diff --git a/source4/lib/zlib/projects/visualc6/zlib.dsw b/lib/zlib/projects/visualc6/zlib.dsw similarity index 100% rename from source4/lib/zlib/projects/visualc6/zlib.dsw rename to lib/zlib/projects/visualc6/zlib.dsw diff --git a/source4/lib/zlib/qnx/package.qpg b/lib/zlib/qnx/package.qpg similarity index 100% rename from source4/lib/zlib/qnx/package.qpg rename to lib/zlib/qnx/package.qpg diff --git a/source4/lib/zlib/trees.c b/lib/zlib/trees.c similarity index 100% rename from source4/lib/zlib/trees.c rename to lib/zlib/trees.c diff --git a/source4/lib/zlib/trees.h b/lib/zlib/trees.h similarity index 100% rename from source4/lib/zlib/trees.h rename to lib/zlib/trees.h diff --git a/source4/lib/zlib/uncompr.c b/lib/zlib/uncompr.c similarity index 100% rename from source4/lib/zlib/uncompr.c rename to lib/zlib/uncompr.c diff --git a/source4/lib/zlib/win32/DLL_FAQ.txt b/lib/zlib/win32/DLL_FAQ.txt similarity index 100% rename from source4/lib/zlib/win32/DLL_FAQ.txt rename to lib/zlib/win32/DLL_FAQ.txt diff --git a/source4/lib/zlib/win32/Makefile.bor b/lib/zlib/win32/Makefile.bor similarity index 100% rename from source4/lib/zlib/win32/Makefile.bor rename to lib/zlib/win32/Makefile.bor diff --git a/source4/lib/zlib/win32/Makefile.emx b/lib/zlib/win32/Makefile.emx similarity index 100% rename from source4/lib/zlib/win32/Makefile.emx rename to lib/zlib/win32/Makefile.emx diff --git a/source4/lib/zlib/win32/Makefile.gcc b/lib/zlib/win32/Makefile.gcc similarity index 100% rename from source4/lib/zlib/win32/Makefile.gcc rename to lib/zlib/win32/Makefile.gcc diff --git a/source4/lib/zlib/win32/Makefile.msc b/lib/zlib/win32/Makefile.msc similarity index 100% rename from source4/lib/zlib/win32/Makefile.msc rename to lib/zlib/win32/Makefile.msc diff --git a/source4/lib/zlib/win32/VisualC.txt b/lib/zlib/win32/VisualC.txt similarity index 100% rename from source4/lib/zlib/win32/VisualC.txt rename to lib/zlib/win32/VisualC.txt diff --git a/source4/lib/zlib/win32/zlib.def b/lib/zlib/win32/zlib.def similarity index 100% rename from source4/lib/zlib/win32/zlib.def rename to lib/zlib/win32/zlib.def diff --git a/source4/lib/zlib/win32/zlib1.rc b/lib/zlib/win32/zlib1.rc similarity index 100% rename from source4/lib/zlib/win32/zlib1.rc rename to lib/zlib/win32/zlib1.rc diff --git a/source4/lib/zlib/zconf.h b/lib/zlib/zconf.h similarity index 100% rename from source4/lib/zlib/zconf.h rename to lib/zlib/zconf.h diff --git a/source4/lib/zlib/zconf.in.h b/lib/zlib/zconf.in.h similarity index 100% rename from source4/lib/zlib/zconf.in.h rename to lib/zlib/zconf.in.h diff --git a/source4/lib/zlib/zlib.h b/lib/zlib/zlib.h similarity index 100% rename from source4/lib/zlib/zlib.h rename to lib/zlib/zlib.h diff --git a/source4/lib/zlib.m4 b/lib/zlib/zlib.m4 similarity index 87% rename from source4/lib/zlib.m4 rename to lib/zlib/zlib.m4 index 9ee7b8e49e..32d747c388 100644 --- a/source4/lib/zlib.m4 +++ b/lib/zlib/zlib.m4 @@ -1,4 +1,4 @@ - +AC_DEFUN([AC_ZLIB],[ AC_CHECK_HEADERS(zlib.h) AC_CHECK_LIB_EXT(z, ZLIB_LIBS, zlibVersion) @@ -21,7 +21,9 @@ AC_CACHE_CHECK([for zlib >= 1.2.3], samba_cv_zlib_1_2_3, [ if test x"$ac_cv_header_zlib_h" = x"yes" -a \ x"$ac_cv_lib_ext_z_zlibVersion" = x"yes" -a \ x"$samba_cv_zlib_1_2_3" = x"yes"; then - SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}]) + $1 else - SMB_INCLUDE_MK(lib/zlib.mk) + $2 fi +]) + diff --git a/source4/lib/zlib/zutil.c b/lib/zlib/zutil.c similarity index 100% rename from source4/lib/zlib/zutil.c rename to lib/zlib/zutil.c diff --git a/source4/lib/zlib/zutil.h b/lib/zlib/zutil.h similarity index 100% rename from source4/lib/zlib/zutil.h rename to lib/zlib/zutil.h diff --git a/source3/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h similarity index 96% rename from source3/libcli/nbt/libnbt.h rename to libcli/nbt/libnbt.h index d37a17c192..4ef4e9d60d 100644 --- a/source3/libcli/nbt/libnbt.h +++ b/libcli/nbt/libnbt.h @@ -83,7 +83,7 @@ struct nbt_name_request { /* information on what to do on completion */ struct { void (*fn)(struct nbt_name_request *); - void *_private; + void *private_data; } async; }; @@ -95,9 +95,8 @@ struct nbt_name_request { struct nbt_name_socket { struct socket_context *sock; struct event_context *event_ctx; -/* struct smb_iconv_convenience *iconv_convenience; -*/ + /* a queue of requests pending to be sent */ struct nbt_name_request *send_queue; @@ -114,14 +113,14 @@ struct nbt_name_socket { struct { void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, struct socket_address *); - void *_private; + void *private_data; } incoming; /* what to do with unexpected replies */ struct { void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, struct socket_address *); - void *_private; + void *private_data; } unexpected; }; @@ -276,9 +275,8 @@ struct nbt_name_release { }; struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, - struct event_context *event_ctx); - /*, - struct smb_iconv_convenience *iconv_convenience);*/ + struct event_context *event_ctx, + struct smb_iconv_convenience *iconv_convenience); struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock, struct nbt_name_query *io); NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, @@ -293,7 +291,7 @@ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock, TALLOC_CTX *mem_ctx, struct nbt_name_status *io); NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname); -NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name); +NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name); NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name); void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type); char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name); @@ -325,7 +323,7 @@ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock, void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, struct socket_address *), - void *_private); + void *private_data); NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, struct socket_address *dest, struct nbt_name_packet *request); diff --git a/libcli/nbt/man/nmblookup.1.xml b/libcli/nbt/man/nmblookup.1.xml new file mode 100644 index 0000000000..85640da033 --- /dev/null +++ b/libcli/nbt/man/nmblookup.1.xml @@ -0,0 +1,223 @@ + + + + + + nmblookup + 1 + Samba + User Commands + 3.2 + + + + + nmblookup + NetBIOS over TCP/IP client used to lookup NetBIOS + names + + + + + nmblookup + -M + -R + -S + -r + -A + -h + -B <broadcast address> + -U <unicast address> + -d <debug level> + -s <smb config file> + -i <NetBIOS scope> + -T + -f + name + + + + + DESCRIPTION + + This tool is part of the samba + 7 suite. + + nmblookup is used to query NetBIOS names + and map them to IP addresses in a network using NetBIOS over TCP/IP + queries. The options allow the name queries to be directed at a + particular IP broadcast area or to a particular machine. All queries + are done over UDP. + + + + OPTIONS + + + + -M + Searches for a master browser by looking + up the NetBIOS name name with a + type of 0x1d. If + name is "-" then it does a lookup on the special name + __MSBROWSE__. Please note that in order to + use the name "-", you need to make sure "-" isn't parsed as an + argument, e.g. use : + nmblookup -M -- -. + + + + -R + Set the recursion desired bit in the packet + to do a recursive lookup. This is used when sending a name + query to a machine running a WINS server and the user wishes + to query the names in the WINS server. If this bit is unset + the normal (broadcast responding) NetBIOS processing code + on a machine is used instead. See RFC1001, RFC1002 for details. + + + + + -S + Once the name query has returned an IP + address then do a node status query as well. A node status + query returns the NetBIOS names registered by a host. + + + + + + -r + Try and bind to UDP port 137 to send and receive UDP + datagrams. The reason for this option is a bug in Windows 95 + where it ignores the source port of the requesting packet + and only replies to UDP port 137. Unfortunately, on most UNIX + systems root privilege is needed to bind to this port, and + in addition, if the nmbd + 8 daemon is running on this machine it also binds to this port. + + + + + + -A + Interpret name as + an IP Address and do a node status query on this address. + + + + + + &popt.common.connection; + &stdarg.help; + + + -B <broadcast address> + Send the query to the given broadcast address. Without + this option the default behavior of nmblookup is to send the + query to the broadcast address of the network interfaces as + either auto-detected or defined in the interfaces + parameter of the smb.conf + 5 file. + + + + + + + -U <unicast address> + Do a unicast query to the specified address or + host unicast address. This option + (along with the -R option) is needed to + query a WINS server. + + + &stdarg.server.debug; + &popt.common.samba; + + + -T + This causes any IP addresses found in the + lookup to be looked up via a reverse DNS lookup into a + DNS name, and printed out before each + + IP address .... NetBIOS name + + pair that is the normal output. + + + + -f + + Show which flags apply to the name that has been looked up. Possible + answers are zero or more of: Response, Authoritative, + Truncated, Recursion_Desired, Recursion_Available, Broadcast. + + + + + + name + This is the NetBIOS name being queried. Depending + upon the previous options this may be a NetBIOS name or IP address. + If a NetBIOS name then the different name types may be specified + by appending '#<type>' to the name. This name may also be + '*', which will return all registered names within a broadcast + area. + + + + + + + EXAMPLES + + nmblookup can be used to query + a WINS server (in the same way nslookup is + used to query DNS servers). To query a WINS server, nmblookup + must be called like this: + + nmblookup -U server -R 'name' + + For example, running : + + nmblookup -U samba.org -R 'IRIX#1B' + + would query the WINS server samba.org for the domain + master browser (1B name type) for the IRIX workgroup. + + + + VERSION + + This man page is correct for version 3 of + the Samba suite. + + + + SEE ALSO + nmbd + 8, samba + 7, and smb.conf + 5. + + + + AUTHOR + + The original Samba software and related utilities + were created by Andrew Tridgell. Samba is now developed + by the Samba Team as an Open Source project similar + to the way the Linux kernel is developed. + + The original Samba man pages were written by Karl Auer. + The man page sources were converted to YODL format (another + excellent piece of Open Source software, available at + ftp://ftp.icce.rug.nl/pub/unix/) and updated for the Samba 2.0 + release by Jeremy Allison. The conversion to DocBook for + Samba 2.2 was done by Gerald Carter. The conversion to DocBook + XML 4.2 for Samba 3.0 was done by Alexander Bokovoy. + + + diff --git a/source4/libcli/nbt/namequery.c b/libcli/nbt/namequery.c similarity index 96% rename from source4/libcli/nbt/namequery.c rename to libcli/nbt/namequery.c index 2e1bcd818b..ed3d8a2492 100644 --- a/source4/libcli/nbt/namequery.c +++ b/libcli/nbt/namequery.c @@ -1,27 +1,27 @@ -/* +/* Unix SMB/CIFS implementation. make nbt name query requests Copyright (C) Andrew Tridgell 2005 - + 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 . */ #include "includes.h" -#include "libcli/nbt/libnbt.h" -#include "libcli/nbt/nbt_proto.h" +#include "../libcli/nbt/libnbt.h" +#include "../libcli/nbt/nbt_proto.h" #include "lib/socket/socket.h" #include "param/param.h" @@ -66,13 +66,13 @@ _PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nb failed: talloc_free(packet); - return NULL; + return NULL; } /** wait for a name query reply */ -_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, +_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, TALLOC_CTX *mem_ctx, struct nbt_name_query *io) { NTSTATUS status; @@ -85,7 +85,7 @@ _PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, talloc_free(req); return status; } - + packet = req->replies[0].packet; io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr); @@ -109,16 +109,16 @@ _PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, talloc_free(req); return NT_STATUS_NO_MEMORY; } - + for (i=0;iout.num_addrs;i++) { - io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs, + io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs, packet->answers[0].rdata.netbios.addresses[i].ipaddr); } io->out.reply_addrs[i] = NULL; talloc_steal(mem_ctx, io->out.name.name); talloc_steal(mem_ctx, io->out.name.scope); - + talloc_free(req); return NT_STATUS_OK; @@ -127,7 +127,7 @@ _PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, /** wait for a name query reply */ -_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock, +_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock, TALLOC_CTX *mem_ctx, struct nbt_name_query *io) { struct nbt_name_request *req = nbt_name_query_send(nbtsock, io); @@ -170,13 +170,13 @@ _PUBLIC_ struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *n failed: talloc_free(packet); - return NULL; + return NULL; } /** wait for a name status reply */ -_PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, +_PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, TALLOC_CTX *mem_ctx, struct nbt_name_status *io) { NTSTATUS status; @@ -189,7 +189,7 @@ _PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, talloc_free(req); return status; } - + packet = req->replies[0].packet; io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr); @@ -216,7 +216,7 @@ _PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, talloc_steal(io->out.status.names, io->out.status.names[i].name); } - + talloc_free(req); return NT_STATUS_OK; @@ -225,7 +225,7 @@ _PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, /** wait for a name status reply */ -_PUBLIC_ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock, +_PUBLIC_ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock, TALLOC_CTX *mem_ctx, struct nbt_name_status *io) { struct nbt_name_request *req = nbt_name_status_send(nbtsock, io); diff --git a/source4/libcli/nbt/namerefresh.c b/libcli/nbt/namerefresh.c similarity index 92% rename from source4/libcli/nbt/namerefresh.c rename to libcli/nbt/namerefresh.c index b372e4a3f3..77f9cbd45c 100644 --- a/source4/libcli/nbt/namerefresh.c +++ b/libcli/nbt/namerefresh.c @@ -1,27 +1,27 @@ -/* +/* Unix SMB/CIFS implementation. send out a name refresh request Copyright (C) Andrew Tridgell 2005 - + 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 . */ #include "includes.h" -#include "libcli/nbt/libnbt.h" -#include "libcli/nbt/nbt_proto.h" +#include "../libcli/nbt/libnbt.h" +#include "../libcli/nbt/nbt_proto.h" #include "libcli/composite/composite.h" #include "lib/socket/socket.h" #include "param/param.h" @@ -65,11 +65,11 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock, struct nbt_rdata_address, 1); if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed; packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags; - packet->additional[0].rdata.netbios.addresses[0].ipaddr = + packet->additional[0].rdata.netbios.addresses[0].ipaddr = talloc_strdup(packet->additional, io->in.address); - dest = socket_address_from_strings(nbtsock, - nbtsock->sock->backend_name, + dest = socket_address_from_strings(nbtsock, + nbtsock->sock->backend_name, io->in.dest_addr, io->in.dest_port); if (dest == NULL) goto failed; req = nbt_name_request_send(nbtsock, dest, packet, @@ -81,13 +81,13 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock, failed: talloc_free(packet); - return NULL; + return NULL; } /* wait for a refresh reply */ -_PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, +_PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io) { NTSTATUS status; @@ -99,7 +99,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, talloc_free(req); return status; } - + packet = req->replies[0].packet; io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr); @@ -116,7 +116,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, talloc_free(req); return NT_STATUS_INVALID_NETWORK_RESPONSE; } - io->out.reply_addr = talloc_steal(mem_ctx, + io->out.reply_addr = talloc_steal(mem_ctx, packet->answers[0].rdata.netbios.addresses[0].ipaddr); talloc_steal(mem_ctx, io->out.name.name); talloc_steal(mem_ctx, io->out.name.scope); @@ -129,7 +129,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, /* synchronous name refresh request */ -_PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock, +_PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock, TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io) { struct nbt_name_request *req = nbt_name_refresh_send(nbtsock, io); @@ -159,9 +159,9 @@ struct refresh_wins_state { */ static void name_refresh_wins_handler(struct nbt_name_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); - struct refresh_wins_state *state = talloc_get_type(c->private_data, + struct refresh_wins_state *state = talloc_get_type(c->private_data, struct refresh_wins_state); NTSTATUS status; @@ -184,7 +184,7 @@ static void name_refresh_wins_handler(struct nbt_name_request *req) c->status = NT_STATUS_NO_MEMORY; } else { state->req->async.fn = name_refresh_wins_handler; - state->req->async.private = c; + state->req->async.private_data = c; } } else if (!NT_STATUS_IS_OK(status)) { c->state = COMPOSITE_STATE_ERROR; @@ -200,7 +200,7 @@ static void name_refresh_wins_handler(struct nbt_name_request *req) c->status = NT_STATUS_NO_MEMORY; } else { state->req->async.fn = name_refresh_wins_handler; - state->req->async.private = c; + state->req->async.private_data = c; } } else { c->state = COMPOSITE_STATE_DONE; @@ -234,12 +234,12 @@ _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_so if (state->io == NULL) goto failed; state->wins_port = io->in.wins_port; - state->wins_servers = str_list_copy(state, io->in.wins_servers); - if (state->wins_servers == NULL || + state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers); + if (state->wins_servers == NULL || state->wins_servers[0] == NULL) goto failed; - state->addresses = str_list_copy(state, io->in.addresses); - if (state->addresses == NULL || + state->addresses = (const char **)str_list_copy(state, io->in.addresses); + if (state->addresses == NULL || state->addresses[0] == NULL) goto failed; state->io->in.name = io->in.name; @@ -259,7 +259,7 @@ _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_so if (state->req == NULL) goto failed; state->req->async.fn = name_refresh_wins_handler; - state->req->async.private = c; + state->req->async.private_data = c; c->private_data = state; c->state = COMPOSITE_STATE_IN_PROGRESS; @@ -281,7 +281,7 @@ _PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC NTSTATUS status; status = composite_wait(c); if (NT_STATUS_IS_OK(status)) { - struct refresh_wins_state *state = + struct refresh_wins_state *state = talloc_get_type(c->private_data, struct refresh_wins_state); io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]); io->out.rcode = state->io->out.rcode; diff --git a/source4/libcli/nbt/nameregister.c b/libcli/nbt/nameregister.c similarity index 94% rename from source4/libcli/nbt/nameregister.c rename to libcli/nbt/nameregister.c index 9c5ae43d40..d9e616fecc 100644 --- a/source4/libcli/nbt/nameregister.c +++ b/libcli/nbt/nameregister.c @@ -1,27 +1,27 @@ -/* +/* Unix SMB/CIFS implementation. send out a name registration request Copyright (C) Andrew Tridgell 2005 - + 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 . */ #include "includes.h" -#include "libcli/nbt/libnbt.h" -#include "libcli/nbt/nbt_proto.h" +#include "../libcli/nbt/libnbt.h" +#include "../libcli/nbt/nbt_proto.h" #include "libcli/composite/composite.h" #include "lib/socket/socket.h" #include "librpc/gen_ndr/ndr_nbt.h" @@ -73,11 +73,11 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock, struct nbt_rdata_address, 1); if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed; packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags; - packet->additional[0].rdata.netbios.addresses[0].ipaddr = + packet->additional[0].rdata.netbios.addresses[0].ipaddr = talloc_strdup(packet->additional, io->in.address); if (packet->additional[0].rdata.netbios.addresses[0].ipaddr == NULL) goto failed; - dest = socket_address_from_strings(packet, nbtsock->sock->backend_name, + dest = socket_address_from_strings(packet, nbtsock->sock->backend_name, io->in.dest_addr, io->in.dest_port); if (dest == NULL) goto failed; req = nbt_name_request_send(nbtsock, dest, packet, @@ -89,13 +89,13 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock, failed: talloc_free(packet); - return NULL; + return NULL; } /* wait for a registration reply */ -_PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, +_PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, TALLOC_CTX *mem_ctx, struct nbt_name_register *io) { NTSTATUS status; @@ -107,7 +107,7 @@ _PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, talloc_free(req); return status; } - + packet = req->replies[0].packet; io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr); @@ -124,11 +124,11 @@ _PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, talloc_free(req); return NT_STATUS_INVALID_NETWORK_RESPONSE; } - io->out.reply_addr = talloc_steal(mem_ctx, + io->out.reply_addr = talloc_steal(mem_ctx, packet->answers[0].rdata.netbios.addresses[0].ipaddr); talloc_steal(mem_ctx, io->out.name.name); talloc_steal(mem_ctx, io->out.name.scope); - + talloc_free(req); return NT_STATUS_OK; @@ -137,7 +137,7 @@ _PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, /* synchronous name registration request */ -_PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock, +_PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock, TALLOC_CTX *mem_ctx, struct nbt_name_register *io) { struct nbt_name_request *req = nbt_name_register_send(nbtsock, io); @@ -161,7 +161,7 @@ struct register_bcast_state { */ static void name_register_bcast_handler(struct nbt_name_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, struct composite_context); + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); struct register_bcast_state *state = talloc_get_type(c->private_data, struct register_bcast_state); NTSTATUS status; @@ -183,7 +183,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req) c->status = NT_STATUS_NO_MEMORY; } else { state->req->async.fn = name_register_bcast_handler; - state->req->async.private = c; + state->req->async.private_data = c; } } else if (!NT_STATUS_IS_OK(status)) { c->state = COMPOSITE_STATE_ERROR; @@ -192,7 +192,7 @@ static void name_register_bcast_handler(struct nbt_name_request *req) c->state = COMPOSITE_STATE_ERROR; c->status = NT_STATUS_CONFLICTING_ADDRESSES; DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n", - state->io->out.reply_from, + state->io->out.reply_from, nbt_name_string(state, &state->io->out.name), state->io->out.reply_addr, state->io->out.rcode)); @@ -241,7 +241,7 @@ _PUBLIC_ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_ if (state->req == NULL) goto failed; state->req->async.fn = name_register_bcast_handler; - state->req->async.private = c; + state->req->async.private_data = c; c->private_data = state; c->state = COMPOSITE_STATE_IN_PROGRESS; @@ -297,9 +297,9 @@ struct register_wins_state { */ static void name_register_wins_handler(struct nbt_name_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); - struct register_wins_state *state = talloc_get_type(c->private_data, + struct register_wins_state *state = talloc_get_type(c->private_data, struct register_wins_state); NTSTATUS status; @@ -322,7 +322,7 @@ static void name_register_wins_handler(struct nbt_name_request *req) c->status = NT_STATUS_NO_MEMORY; } else { state->req->async.fn = name_register_wins_handler; - state->req->async.private = c; + state->req->async.private_data = c; } } else if (!NT_STATUS_IS_OK(status)) { c->state = COMPOSITE_STATE_ERROR; @@ -338,7 +338,7 @@ static void name_register_wins_handler(struct nbt_name_request *req) c->status = NT_STATUS_NO_MEMORY; } else { state->req->async.fn = name_register_wins_handler; - state->req->async.private = c; + state->req->async.private_data = c; } } else { c->state = COMPOSITE_STATE_DONE; @@ -372,12 +372,12 @@ _PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_s if (state->io == NULL) goto failed; state->wins_port = io->in.wins_port; - state->wins_servers = str_list_copy(state, io->in.wins_servers); - if (state->wins_servers == NULL || + state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers); + if (state->wins_servers == NULL || state->wins_servers[0] == NULL) goto failed; - state->addresses = str_list_copy(state, io->in.addresses); - if (state->addresses == NULL || + state->addresses = (const char **)str_list_copy(state, io->in.addresses); + if (state->addresses == NULL || state->addresses[0] == NULL) goto failed; state->io->in.name = io->in.name; @@ -399,7 +399,7 @@ _PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_s if (state->req == NULL) goto failed; state->req->async.fn = name_register_wins_handler; - state->req->async.private = c; + state->req->async.private_data = c; c->private_data = state; c->state = COMPOSITE_STATE_IN_PROGRESS; @@ -421,7 +421,7 @@ _PUBLIC_ NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLO NTSTATUS status; status = composite_wait(c); if (NT_STATUS_IS_OK(status)) { - struct register_wins_state *state = + struct register_wins_state *state = talloc_get_type(c->private_data, struct register_wins_state); io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]); io->out.rcode = state->io->out.rcode; diff --git a/source4/libcli/nbt/namerelease.c b/libcli/nbt/namerelease.c similarity index 94% rename from source4/libcli/nbt/namerelease.c rename to libcli/nbt/namerelease.c index ba3af41752..e57a2f396e 100644 --- a/source4/libcli/nbt/namerelease.c +++ b/libcli/nbt/namerelease.c @@ -1,27 +1,27 @@ -/* +/* Unix SMB/CIFS implementation. send out a name release request Copyright (C) Andrew Tridgell 2005 - + 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 . */ #include "includes.h" -#include "libcli/nbt/libnbt.h" -#include "libcli/nbt/nbt_proto.h" +#include "../libcli/nbt/libnbt.h" +#include "../libcli/nbt/nbt_proto.h" #include "lib/socket/socket.h" #include "param/param.h" @@ -64,10 +64,10 @@ _PUBLIC_ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket * struct nbt_rdata_address, 1); if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed; packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags; - packet->additional[0].rdata.netbios.addresses[0].ipaddr = + packet->additional[0].rdata.netbios.addresses[0].ipaddr = talloc_strdup(packet->additional, io->in.address); - dest = socket_address_from_strings(packet, nbtsock->sock->backend_name, + dest = socket_address_from_strings(packet, nbtsock->sock->backend_name, io->in.dest_addr, io->in.dest_port); if (dest == NULL) goto failed; req = nbt_name_request_send(nbtsock, dest, packet, @@ -79,13 +79,13 @@ _PUBLIC_ struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket * failed: talloc_free(packet); - return NULL; + return NULL; } /* wait for a release reply */ -_PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, +_PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, TALLOC_CTX *mem_ctx, struct nbt_name_release *io) { NTSTATUS status; @@ -97,7 +97,7 @@ _PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, talloc_free(req); return status; } - + packet = req->replies[0].packet; io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr); @@ -114,7 +114,7 @@ _PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, talloc_free(req); return NT_STATUS_INVALID_NETWORK_RESPONSE; } - io->out.reply_addr = talloc_steal(mem_ctx, + io->out.reply_addr = talloc_steal(mem_ctx, packet->answers[0].rdata.netbios.addresses[0].ipaddr); talloc_steal(mem_ctx, io->out.name.name); talloc_steal(mem_ctx, io->out.name.scope); @@ -127,7 +127,7 @@ _PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, /* synchronous name release request */ -_PUBLIC_ NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock, +_PUBLIC_ NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock, TALLOC_CTX *mem_ctx, struct nbt_name_release *io) { struct nbt_name_request *req = nbt_name_release_send(nbtsock, io); diff --git a/libcli/nbt/nbt_proto.h b/libcli/nbt/nbt_proto.h new file mode 100644 index 0000000000..b2e8d8525a --- /dev/null +++ b/libcli/nbt/nbt_proto.h @@ -0,0 +1,43 @@ +#ifndef _____LIBCLI_NBT_NBT_PROTO_H__ +#define _____LIBCLI_NBT_NBT_PROTO_H__ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) +/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ + +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ + + +/* The following definitions come from ../libcli/nbt/nbtsocket.c */ + +struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, + struct socket_address *dest, + struct nbt_name_packet *request, + int timeout, int retries, + bool allow_multiple_replies); +NTSTATUS nbt_name_request_recv(struct nbt_name_request *req); + +/* The following definitions come from ../libcli/nbt/namequery.c */ + + +/* The following definitions come from ../libcli/nbt/nameregister.c */ + +struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock, + struct nbt_name_register *io); +NTSTATUS nbt_name_register_bcast(struct nbt_name_socket *nbtsock, + struct nbt_name_register_bcast *io); + +/* The following definitions come from ../libcli/nbt/namerefresh.c */ + +struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock, + struct nbt_name_refresh *io); + +/* The following definitions come from ../libcli/nbt/namerelease.c */ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) + +#endif /* _____LIBCLI_NBT_NBT_PROTO_H__ */ + diff --git a/source4/libcli/nbt/nbtname.c b/libcli/nbt/nbtname.c similarity index 96% rename from source4/libcli/nbt/nbtname.c rename to libcli/nbt/nbtname.c index 97ae2e9d72..338cb21089 100644 --- a/source4/libcli/nbt/nbtname.c +++ b/libcli/nbt/nbtname.c @@ -1,20 +1,20 @@ -/* +/* Unix SMB/CIFS implementation. manipulate nbt name structures Copyright (C) Andrew Tridgell 2005 - + 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 . */ @@ -27,7 +27,6 @@ #include "librpc/gen_ndr/ndr_nbt.h" #include "librpc/gen_ndr/ndr_misc.h" #include "system/locale.h" -#include "param/param.h" /* don't allow an unlimited number of name components */ #define MAX_COMPONENTS 10 @@ -112,7 +111,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_fla /* break up name into a list of components */ for (num_components=0;num_componentsnbt_string_list, s, &offset, (comparison_fn_t)strcmp, false); if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { uint8_t b[2]; - + if (offset > 0x3FFF) { return ndr_push_error(ndr, NDR_ERR_STRING, "offset for nbt string label pointer %u[%08X] > 0x00003FFF", @@ -219,7 +218,7 @@ static bool decompress_name(char *name, enum nbt_name_type *type) c2 < 'A' || c2 > 'P') { return false; } - name[i] = ((c1-'A')<<4) | (c2-'A'); + name[i] = ((c1-'A')<<4) | (c2-'A'); } name[i] = 0; if (i == 16) { @@ -234,7 +233,7 @@ static bool decompress_name(char *name, enum nbt_name_type *type) for (;i>0 && name[i-1]==' ';i--) { name[i-1] = 0; } - + return true; } @@ -242,7 +241,7 @@ static bool decompress_name(char *name, enum nbt_name_type *type) /* compress a name component */ -static uint8_t *compress_name(TALLOC_CTX *mem_ctx, +static uint8_t *compress_name(TALLOC_CTX *mem_ctx, const uint8_t *name, enum nbt_name_type type) { uint8_t *cname; @@ -356,7 +355,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags } else { fullname = cname; } - + ndr_err = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname); return ndr_err; @@ -422,7 +421,7 @@ _PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx, n->scope = NULL; n->type = type; - if (is_ipaddress(name) || name == NULL) { + if ((name == NULL) || is_ipaddress(name)) { n->name = "*SMBSERVER"; return; } @@ -434,11 +433,11 @@ _PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx, return; } s = talloc_strndup(mem_ctx, name, PTR_DIFF(p, name)); - n->name = strupper_talloc(mem_ctx, s); + n->name = talloc_strdup_upper(mem_ctx, s); return; } - n->name = strupper_talloc(mem_ctx, name); + n->name = talloc_strdup_upper(mem_ctx, name); } @@ -483,14 +482,14 @@ _PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name) { TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); char *ret; - if (name->scope) { + if (name->scope) { ret = talloc_asprintf(mem_ctx, "%s<%02x>-%s", nbt_hex_encode(tmp_ctx, name->name), - name->type, + name->type, nbt_hex_encode(tmp_ctx, name->scope)); } else { - ret = talloc_asprintf(mem_ctx, "%s<%02x>", - nbt_hex_encode(tmp_ctx, name->name), + ret = talloc_asprintf(mem_ctx, "%s<%02x>", + nbt_hex_encode(tmp_ctx, name->name), name->type); } talloc_free(tmp_ctx); @@ -518,7 +517,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr NDR_PULL_ALLOC_N(ndr, namebuf, namebuf_len); NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len)); - NDR_PULL_ALLOC(ndr, r); + NDR_PULL_ALLOC(ndr, r); /* oh wow, what a nasty bug in windows ... */ if (namebuf[0] == 0x1b && namebuf_len >= 16) { @@ -565,7 +564,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr { uint8_t *namebuf; uint32_t namebuf_len; - uint32_t name_len; + uint32_t _name_len; uint32_t scope_len = 0; if (r == NULL) { @@ -577,8 +576,8 @@ _PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr return NDR_ERR_SUCCESS; } - name_len = strlen(r->name); - if (name_len > 15) { + _name_len = strlen(r->name); + if (_name_len > 15) { return ndr_push_error(ndr, NDR_ERR_STRING, "wrepl_nbt_name longer as 15 chars: %s", r->name); diff --git a/source4/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c similarity index 91% rename from source4/libcli/nbt/nbtsocket.c rename to libcli/nbt/nbtsocket.c index 5d4611e2d9..dbbdc1b02a 100644 --- a/source4/libcli/nbt/nbtsocket.c +++ b/libcli/nbt/nbtsocket.c @@ -1,28 +1,29 @@ -/* +/* Unix SMB/CIFS implementation. low level socket handling for nbt requests Copyright (C) Andrew Tridgell 2005 - + 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 . */ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" -#include "libcli/nbt/libnbt.h" +#include "../lib/util/dlinklist.h" +#include "../libcli/nbt/libnbt.h" +#include "../libcli/nbt/nbt_proto.h" #include "lib/socket/socket.h" #include "librpc/gen_ndr/ndr_nbt.h" #include "param/param.h" @@ -33,7 +34,7 @@ destroy a pending request */ static int nbt_name_request_destructor(struct nbt_name_request *req) -{ +{ if (req->state == NBT_REQUEST_SEND) { DLIST_REMOVE(req->nbtsock->send_queue, req); } @@ -51,7 +52,7 @@ static int nbt_name_request_destructor(struct nbt_name_request *req) if (req->nbtsock->send_queue == NULL) { EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde); } - if (req->nbtsock->num_pending == 0 && + if (req->nbtsock->num_pending == 0 && req->nbtsock->incoming.handler == NULL) { EVENT_FD_NOT_READABLE(req->nbtsock->fde); } @@ -70,11 +71,11 @@ static void nbt_name_socket_send(struct nbt_name_socket *nbtsock) while ((req = nbtsock->send_queue)) { size_t len; - + len = req->encoded.length; - status = socket_sendto(nbtsock->sock, &req->encoded, &len, + status = socket_sendto(nbtsock->sock, &req->encoded, &len, req->dest); - if (NT_STATUS_IS_ERR(status)) goto failed; + if (NT_STATUS_IS_ERR(status)) goto failed; if (!NT_STATUS_IS_OK(status)) { talloc_free(tmp_ctx); @@ -116,17 +117,17 @@ failed: static void nbt_name_socket_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *private) { - struct nbt_name_request *req = talloc_get_type(private, + struct nbt_name_request *req = talloc_get_type(private, struct nbt_name_request); if (req->num_retries != 0) { req->num_retries--; - req->te = event_add_timed(req->nbtsock->event_ctx, req, + req->te = event_add_timed(req->nbtsock->event_ctx, req, timeval_add(&t, req->timeout, 0), nbt_name_socket_timeout, req); if (req->state != NBT_REQUEST_SEND) { req->state = NBT_REQUEST_SEND; - DLIST_ADD_END(req->nbtsock->send_queue, req, + DLIST_ADD_END(req->nbtsock->send_queue, req, struct nbt_name_request *); } EVENT_FD_WRITEABLE(req->nbtsock->fde); @@ -201,7 +202,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock) } if (DEBUGLVL(10)) { - DEBUG(10,("Received nbt packet of length %d from %s:%d\n", + DEBUG(10,("Received nbt packet of length %d from %s:%d\n", (int)blob.length, src->addr, src->port)); NDR_PRINT_DEBUG(nbt_name_packet, packet); } @@ -217,7 +218,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock) } /* find the matching request */ - req = (struct nbt_name_request *)idr_find(nbtsock->idr, + req = (struct nbt_name_request *)idr_find(nbtsock->idr, packet->name_trn_id); if (req == NULL) { if (nbtsock->unexpected.handler) { @@ -245,15 +246,15 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock) req->num_retries = 0; req->received_wack = true; /* although there can be a timeout in the packet, w2k3 screws it up, - so better to set it ourselves */ + so better to set it ourselves */ req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30); - req->te = event_add_timed(req->nbtsock->event_ctx, req, + req->te = event_add_timed(req->nbtsock->event_ctx, req, timeval_current_ofs(req->timeout, 0), nbt_name_socket_timeout, req); talloc_free(tmp_ctx); return; } - + req->replies = talloc_realloc(req, req->replies, struct nbt_name_reply, req->num_replies+1); if (req->replies == NULL) { @@ -293,11 +294,11 @@ done: static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *fde, uint16_t flags, void *private) { - struct nbt_name_socket *nbtsock = talloc_get_type(private, + struct nbt_name_socket *nbtsock = talloc_get_type(private, struct nbt_name_socket); if (flags & EVENT_FD_WRITE) { nbt_name_socket_send(nbtsock); - } + } if (flags & EVENT_FD_READ) { nbt_name_socket_recv(nbtsock); } @@ -308,7 +309,7 @@ static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *f initialise a nbt_name_socket. The event_ctx is optional, if provided then operations will use that event context */ -_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, +_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, struct smb_iconv_convenience *iconv_convenience) { @@ -337,10 +338,10 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, nbtsock->unexpected.handler = NULL; nbtsock->iconv_convenience = iconv_convenience; - nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock, + nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock, socket_get_fd(nbtsock->sock), 0, nbt_name_socket_handler, nbtsock); - + return nbtsock; failed: @@ -351,7 +352,7 @@ failed: /* send off a nbt name request */ -struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, +struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, struct socket_address *dest, struct nbt_name_packet *request, int timeout, int retries, @@ -378,7 +379,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, id = idr_get_new_random(req->nbtsock->idr, req, UINT16_MAX); } else { if (idr_find(req->nbtsock->idr, request->name_trn_id)) goto failed; - id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id, + id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id, UINT16_MAX); } if (id == -1) goto failed; @@ -386,13 +387,13 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, request->name_trn_id = id; req->name_trn_id = id; - req->te = event_add_timed(nbtsock->event_ctx, req, + req->te = event_add_timed(nbtsock->event_ctx, req, timeval_current_ofs(req->timeout, 0), nbt_name_socket_timeout, req); - - talloc_set_destructor(req, nbt_name_request_destructor); - ndr_err = ndr_push_struct_blob(&req->encoded, req, + talloc_set_destructor(req, nbt_name_request_destructor); + + ndr_err = ndr_push_struct_blob(&req->encoded, req, req->nbtsock->iconv_convenience, request, (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); @@ -401,7 +402,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *); if (DEBUGLVL(10)) { - DEBUG(10,("Queueing nbt packet to %s:%d\n", + DEBUG(10,("Queueing nbt packet to %s:%d\n", req->dest->addr, req->dest->port)); NDR_PRINT_DEBUG(nbt_name_packet, request); } @@ -419,7 +420,7 @@ failed: /* send off a nbt name reply */ -_PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, +_PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, struct socket_address *dest, struct nbt_name_packet *request) { @@ -435,13 +436,13 @@ _PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, req->state = NBT_REQUEST_SEND; req->is_reply = true; - talloc_set_destructor(req, nbt_name_request_destructor); + talloc_set_destructor(req, nbt_name_request_destructor); if (DEBUGLVL(10)) { - NDR_PRINT_DEBUG(nbt_name_packet, request); + NDR_PRINT_DEBUG(nbt_name_packet, request); } - ndr_err = ndr_push_struct_blob(&req->encoded, req, + ndr_err = ndr_push_struct_blob(&req->encoded, req, req->nbtsock->iconv_convenience, request, (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); @@ -483,12 +484,12 @@ NTSTATUS nbt_name_request_recv(struct nbt_name_request *req) setup a handler for incoming requests */ _PUBLIC_ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock, - void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, + void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, struct socket_address *), void *private) { nbtsock->incoming.handler = handler; - nbtsock->incoming.private = private; + nbtsock->incoming.private_data = private; EVENT_FD_READABLE(nbtsock->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c similarity index 94% rename from source4/libcli/nbt/pynbt.c rename to libcli/nbt/pynbt.c index e91096630a..e49c1776a3 100644 --- a/source4/libcli/nbt/pynbt.c +++ b/libcli/nbt/pynbt.c @@ -1,18 +1,18 @@ -/* +/* Unix SMB/CIFS implementation. Samba utility functions Copyright © Jelmer Vernooij 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 . */ @@ -20,7 +20,7 @@ #include "includes.h" #include #include "libcli/util/pyerrors.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" #include "lib/events/events.h" #include "param/param.h" @@ -48,7 +48,7 @@ static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject * return NULL; ev = s4_event_context_init(ret->mem_ctx); - ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm)); + ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm)); return (PyObject *)ret; } @@ -58,14 +58,14 @@ static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, u *dest_addr = PyString_AsString(obj); *dest_port = NBT_NAME_SERVICE_PORT; return true; - } + } if (PyTuple_Check(obj)) { if (PyTuple_Size(obj) < 1) { PyErr_SetString(PyExc_TypeError, "Destination tuple size invalid"); return false; } - + if (!PyString_Check(PyTuple_GetItem(obj, 0))) { PyErr_SetString(PyExc_TypeError, "Destination tuple first element not string"); return false; @@ -120,7 +120,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *socket, st return false; } -static PyObject *PyObject_FromNBTName(struct nbt_name_socket *socket, struct smb_iconv_convenience *ic, +static PyObject *PyObject_FromNBTName(struct nbt_name_socket *socket, struct smb_iconv_convenience *ic, struct nbt_name *name) { if (name->scope) { @@ -145,10 +145,10 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa io.in.timeout = 0; io.in.retries = 3; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|bbii:query_name", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|bbii:query_name", discard_const_p(char *, kwnames), - &py_name, &py_dest, - &io.in.broadcast, &io.in.wins_lookup, + &py_name, &py_dest, + &io.in.broadcast, &io.in.wins_lookup, &io.in.timeout, &io.in.retries)) { return NULL; } @@ -182,7 +182,7 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa Py_DECREF(ret); return NULL; } - + for (i = 0; i < io.out.num_addrs; i++) { PyList_SetItem(reply_addrs, i, PyString_FromString(io.out.reply_addrs[i])); } @@ -204,9 +204,9 @@ static PyObject *py_nbt_name_status(PyObject *self, PyObject *args, PyObject *kw io.in.timeout = 0; io.in.retries = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii:name_status", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii:name_status", discard_const_p(char *, kwnames), - &py_name, &py_dest, + &py_name, &py_dest, &io.in.timeout, &io.in.retries)) { return NULL; } @@ -238,9 +238,9 @@ static PyObject *py_nbt_name_status(PyObject *self, PyObject *args, PyObject *kw py_names = PyList_New(io.out.status.num_names); for (i = 0; i < io.out.status.num_names; i++) { - PyList_SetItem(py_names, i, Py_BuildValue("(sii)", + PyList_SetItem(py_names, i, Py_BuildValue("(sii)", io.out.status.names[i].name, - io.out.status.names[i].nb_flags, + io.out.status.names[i].nb_flags, io.out.status.names[i].type)); } @@ -256,7 +256,7 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject * struct nbt_name_register io; NTSTATUS status; - const char *kwnames[] = { "name", "address", "dest", "register_demand", "broadcast", + const char *kwnames[] = { "name", "address", "dest", "register_demand", "broadcast", "multi_homed", "ttl", "timeout", "retries", NULL }; io.in.broadcast = true; @@ -265,11 +265,11 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject * io.in.timeout = 0; io.in.retries = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|bbbiii:query_name", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|bbbiii:query_name", discard_const_p(char *, kwnames), - &py_name, &io.in.address, &py_dest, - &io.in.register_demand, - &io.in.broadcast, &io.in.multi_homed, + &py_name, &io.in.address, &py_dest, + &io.in.register_demand, + &io.in.broadcast, &io.in.multi_homed, &io.in.ttl, &io.in.timeout, &io.in.retries)) { return NULL; } @@ -312,7 +312,7 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k struct nbt_name_refresh io; NTSTATUS status; - const char *kwnames[] = { "name", "address", "dest", "nb_flags", "broadcast", + const char *kwnames[] = { "name", "address", "dest", "nb_flags", "broadcast", "ttl", "timeout", "retries", NULL }; io.in.broadcast = true; @@ -320,11 +320,11 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k io.in.timeout = 0; io.in.retries = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|ibiii:query_name", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|ibiii:query_name", discard_const_p(char *, kwnames), - &py_name, &io.in.address, &py_dest, - &io.in.nb_flags, - &io.in.broadcast, + &py_name, &io.in.address, &py_dest, + &io.in.nb_flags, + &io.in.broadcast, &io.in.ttl, &io.in.timeout, &io.in.retries)) { return NULL; } @@ -366,7 +366,7 @@ static PyObject *py_nbt_name_release(PyObject *self, PyObject *args, PyObject *k } static PyMethodDef py_nbt_methods[] = { - { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS, + { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS, "S.query_name(name, dest, broadcast=True, wins=False, timeout=0, retries=3) -> (reply_from, name, reply_addr)\n" "Query for a NetBIOS name" }, { "register_name", (PyCFunction)py_nbt_name_register, METH_VARARGS|METH_KEYWORDS, diff --git a/source4/utils/nmblookup.c b/libcli/nbt/tools/nmblookup.c similarity index 99% rename from source4/utils/nmblookup.c rename to libcli/nbt/tools/nmblookup.c index a74ab5a42e..0d98cb99de 100644 --- a/source4/utils/nmblookup.c +++ b/libcli/nbt/tools/nmblookup.c @@ -29,7 +29,7 @@ #include "system/locale.h" #include "lib/socket/netif.h" #include "librpc/gen_ndr/nbt.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" #include "param/param.h" /* command line options */ diff --git a/source4/libcli/ndr_netlogon.c b/libcli/ndr_netlogon.c similarity index 99% rename from source4/libcli/ndr_netlogon.c rename to libcli/ndr_netlogon.c index 504b3b02a7..ffc075fab2 100644 --- a/source4/libcli/ndr_netlogon.c +++ b/libcli/ndr_netlogon.c @@ -1,20 +1,20 @@ -/* +/* Unix SMB/CIFS implementation. CLDAP server structures Copyright (C) Andrew Bartlett 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 . */ @@ -22,7 +22,8 @@ /* parser auto-generated by pidl, then hand-modified by abartlet */ #include "includes.h" -#include "libcli/netlogon.h" +#include "../libcli/netlogon.h" + /* Manually modified to handle the dom_sid being optional based on if it is present or all zero */ enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_REQUEST(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_REQUEST *r) { diff --git a/libcli/ndr_netlogon_proto.h b/libcli/ndr_netlogon_proto.h new file mode 100644 index 0000000000..ca61c16138 --- /dev/null +++ b/libcli/ndr_netlogon_proto.h @@ -0,0 +1,24 @@ +#ifndef _____LIBCLI_NDR_NETLOGON_PROTO_H__ +#define _____LIBCLI_NDR_NETLOGON_PROTO_H__ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) +/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ + +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ + + +/* The following definitions come from ../libcli/ndr_netlogon.c */ + +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_REQUEST(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_REQUEST *r); +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_REQUEST(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_REQUEST *r); +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r); +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r, + uint32_t nt_version_flags); +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) + +#endif /* _____LIBCLI_NDR_NETLOGON_PROTO_H__ */ + diff --git a/source4/libcli/netlogon.c b/libcli/netlogon.c similarity index 66% rename from source4/libcli/netlogon.c rename to libcli/netlogon.c index 052d7cbc1e..acfce61cca 100644 --- a/source4/libcli/netlogon.c +++ b/libcli/netlogon.c @@ -1,46 +1,53 @@ -/* +/* Unix SMB/CIFS implementation. CLDAP server structures Copyright (C) Andrew Bartlett 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 . */ #include "includes.h" -#include "libcli/netlogon.h" +#include "../libcli/netlogon.h" + +#undef DEBUG +#define DEBUG(x, y) +#undef DEBUGLVL +#define DEBUGLVL(x) false +#undef DEBUGLEVEL +#define DEBUGLEVEL 0 -NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, +NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, - struct netlogon_samlogon_response *response) + struct netlogon_samlogon_response *response) { enum ndr_err_code ndr_err; if (response->ntver == NETLOGON_NT_VERSION_1) { - ndr_err = ndr_push_struct_blob(data, mem_ctx, + ndr_err = ndr_push_struct_blob(data, mem_ctx, iconv_convenience, - &response->nt4, + &response->data.nt4, (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_NT40); } else if (response->ntver & NETLOGON_NT_VERSION_5EX) { - ndr_err = ndr_push_struct_blob(data, mem_ctx, + ndr_err = ndr_push_struct_blob(data, mem_ctx, iconv_convenience, - &response->nt5_ex, + &response->data.nt5_ex, (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags); } else if (response->ntver & NETLOGON_NT_VERSION_5) { - ndr_err = ndr_push_struct_blob(data, mem_ctx, + ndr_err = ndr_push_struct_blob(data, mem_ctx, iconv_convenience, - &response->nt5, + &response->data.nt5, (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE); } else { DEBUG(0, ("Asked to push unknown netlogon response type 0x%02x\n", response->ntver)); @@ -54,7 +61,7 @@ NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, +NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, struct netlogon_samlogon_response *response) { @@ -75,33 +82,48 @@ NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, } ntver = IVAL(data->data, data->length - 8); - + if (ntver == NETLOGON_NT_VERSION_1) { - ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, + ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, iconv_convenience, - &response->nt4, + &response->data.nt4, (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_NT40); response->ntver = NETLOGON_NT_VERSION_1; + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err) && DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(NETLOGON_SAM_LOGON_RESPONSE_NT40, + &response->data.nt4); + } + } else if (ntver & NETLOGON_NT_VERSION_5EX) { struct ndr_pull *ndr; ndr = ndr_pull_init_blob(data, mem_ctx, iconv_convenience); if (!ndr) { return NT_STATUS_NO_MEMORY; } - ndr_err = ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(ndr, NDR_SCALARS|NDR_BUFFERS, &response->nt5_ex, ntver); + ndr_err = ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags( + ndr, NDR_SCALARS|NDR_BUFFERS, &response->data.nt5_ex, + ntver); if (ndr->offset < ndr->data_size) { ndr_err = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, "not all bytes consumed ofs[%u] size[%u]", ndr->offset, ndr->data_size); } response->ntver = NETLOGON_NT_VERSION_5EX; + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err) && DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(NETLOGON_SAM_LOGON_RESPONSE_EX, + &response->data.nt5_ex); + } } else if (ntver & NETLOGON_NT_VERSION_5) { - ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, + ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, iconv_convenience, - &response->nt5, + &response->data.nt5, (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE); response->ntver = NETLOGON_NT_VERSION_5; + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err) && DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(NETLOGON_SAM_LOGON_RESPONSE, + &response->data.nt5); + } } else { DEBUG(2,("failed to parse netlogon response of type 0x%02x - unknown response type\n", ntver)); @@ -115,6 +137,7 @@ NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, dump_data(10, data->data, data->length); return ndr_map_error2ntstatus(ndr_err); } + return NT_STATUS_OK; } @@ -126,48 +149,50 @@ void map_netlogon_samlogon_response(struct netlogon_samlogon_response *response) break; case NETLOGON_NT_VERSION_5: ZERO_STRUCT(response_5_ex); - response_5_ex.command = response->nt5.command; - response_5_ex.pdc_name = response->nt5.pdc_name; - response_5_ex.user_name = response->nt5.user_name; - response_5_ex.domain = response->nt5.domain_name; - response_5_ex.domain_uuid = response->nt5.domain_uuid; - response_5_ex.forest = response->nt5.forest; - response_5_ex.dns_domain = response->nt5.dns_domain; - response_5_ex.pdc_dns_name = response->nt5.pdc_dns_name; - response_5_ex.sockaddr.pdc_ip = response->nt5.pdc_ip; - response_5_ex.server_type = response->nt5.server_type; - response_5_ex.nt_version = response->nt5.nt_version; - response_5_ex.lmnt_token = response->nt5.lmnt_token; - response_5_ex.lm20_token = response->nt5.lm20_token; + response_5_ex.command = response->data.nt5.command; + response_5_ex.pdc_name = response->data.nt5.pdc_name; + response_5_ex.user_name = response->data.nt5.user_name; + response_5_ex.domain = response->data.nt5.domain_name; + response_5_ex.domain_uuid = response->data.nt5.domain_uuid; + response_5_ex.forest = response->data.nt5.forest; + response_5_ex.dns_domain = response->data.nt5.dns_domain; + response_5_ex.pdc_dns_name = response->data.nt5.pdc_dns_name; + response_5_ex.sockaddr.pdc_ip = response->data.nt5.pdc_ip; + response_5_ex.server_type = response->data.nt5.server_type; + response_5_ex.nt_version = response->data.nt5.nt_version; + response_5_ex.lmnt_token = response->data.nt5.lmnt_token; + response_5_ex.lm20_token = response->data.nt5.lm20_token; response->ntver = NETLOGON_NT_VERSION_5EX; - response->nt5_ex = response_5_ex; + response->data.nt5_ex = response_5_ex; break; - + case NETLOGON_NT_VERSION_1: ZERO_STRUCT(response_5_ex); - response_5_ex.command = response->nt4.command; - response_5_ex.pdc_name = response->nt4.server; - response_5_ex.user_name = response->nt4.user_name; - response_5_ex.domain = response->nt4.domain; - response_5_ex.nt_version = response->nt4.nt_version; - response_5_ex.lmnt_token = response->nt4.lmnt_token; - response_5_ex.lm20_token = response->nt4.lm20_token; + response_5_ex.command = response->data.nt4.command; + response_5_ex.pdc_name = response->data.nt4.server; + response_5_ex.user_name = response->data.nt4.user_name; + response_5_ex.domain = response->data.nt4.domain; + response_5_ex.nt_version = response->data.nt4.nt_version; + response_5_ex.lmnt_token = response->data.nt4.lmnt_token; + response_5_ex.lm20_token = response->data.nt4.lm20_token; response->ntver = NETLOGON_NT_VERSION_5EX; - response->nt5_ex = response_5_ex; + response->data.nt5_ex = response_5_ex; break; } return; } -NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, +NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, - struct nbt_netlogon_response *response) + struct nbt_netlogon_response *response) { NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE; enum ndr_err_code ndr_err; switch (response->response_type) { case NETLOGON_GET_PDC: - ndr_err = ndr_push_struct_blob(data, mem_ctx, iconv_convenience, &response->get_pdc, + ndr_err = ndr_push_struct_blob(data, mem_ctx, + iconv_convenience, + &response->data.get_pdc, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_response_from_pdc); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -181,16 +206,18 @@ NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, status = NT_STATUS_OK; break; case NETLOGON_SAMLOGON: - status = push_netlogon_samlogon_response(data, mem_ctx, iconv_convenience, &response->samlogon); + status = push_netlogon_samlogon_response( + data, mem_ctx, iconv_convenience, + &response->data.samlogon); break; } return status; } -NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, +NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, - struct nbt_netlogon_response *response) + struct nbt_netlogon_response *response) { NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE; enum netlogon_command command; @@ -203,7 +230,9 @@ NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, switch (command) { case NETLOGON_RESPONSE_FROM_PDC: - ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, iconv_convenience, &response->get_pdc, + ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, + iconv_convenience, + &response->data.get_pdc, (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_response_from_pdc); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -223,10 +252,12 @@ NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, case LOGON_SAM_LOGON_RESPONSE_EX: case LOGON_SAM_LOGON_PAUSE_RESPONSE_EX: case LOGON_SAM_LOGON_USER_UNKNOWN_EX: - status = pull_netlogon_samlogon_response(data, mem_ctx, iconv_convenience, &response->samlogon); + status = pull_netlogon_samlogon_response( + data, mem_ctx, iconv_convenience, + &response->data.samlogon); response->response_type = NETLOGON_SAMLOGON; break; - + /* These levels are queries, not responses */ case LOGON_PRIMARY_QUERY: case NETLOGON_ANNOUNCE_UAS: diff --git a/source4/libcli/netlogon.h b/libcli/netlogon.h similarity index 93% rename from source4/libcli/netlogon.h rename to libcli/netlogon.h index 177ed3a514..6ca3de3366 100644 --- a/source4/libcli/netlogon.h +++ b/libcli/netlogon.h @@ -1,20 +1,20 @@ -/* +/* Unix SMB/CIFS implementation. CLDAP server structures Copyright (C) Andrew Bartlett 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 . */ @@ -36,7 +36,7 @@ struct netlogon_samlogon_response struct NETLOGON_SAM_LOGON_RESPONSE_NT40 nt4; struct NETLOGON_SAM_LOGON_RESPONSE nt5; struct NETLOGON_SAM_LOGON_RESPONSE_EX nt5_ex; - }; + } data; }; @@ -46,9 +46,9 @@ struct nbt_netlogon_response union { struct nbt_netlogon_response_from_pdc get_pdc; struct netlogon_samlogon_response samlogon; - }; + } data; }; -#include "libcli/netlogon_proto.h" -#include "libcli/ndr_netlogon_proto.h" +#include "../libcli/netlogon_proto.h" +#include "../libcli/ndr_netlogon_proto.h" #endif /* __CLDAP_SERVER_PROTO_H__ */ diff --git a/libcli/netlogon_proto.h b/libcli/netlogon_proto.h new file mode 100644 index 0000000000..905feed876 --- /dev/null +++ b/libcli/netlogon_proto.h @@ -0,0 +1,32 @@ +#ifndef _____LIBCLI_NETLOGON_PROTO_H__ +#define _____LIBCLI_NETLOGON_PROTO_H__ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) +/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ + +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ + + +/* The following definitions come from ../libcli/netlogon.c */ + +NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct netlogon_samlogon_response *response); +NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct netlogon_samlogon_response *response); +void map_netlogon_samlogon_response(struct netlogon_samlogon_response *response); +NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct nbt_netlogon_response *response); +NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *iconv_convenience, + struct nbt_netlogon_response *response); +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) + +#endif /* _____LIBCLI_NETLOGON_PROTO_H__ */ + diff --git a/source4/librpc/idl/atsvc.idl b/librpc/idl/atsvc.idl similarity index 100% rename from source4/librpc/idl/atsvc.idl rename to librpc/idl/atsvc.idl diff --git a/source4/librpc/idl/audiosrv.idl b/librpc/idl/audiosrv.idl similarity index 100% rename from source4/librpc/idl/audiosrv.idl rename to librpc/idl/audiosrv.idl diff --git a/source4/librpc/idl/browser.idl b/librpc/idl/browser.idl similarity index 100% rename from source4/librpc/idl/browser.idl rename to librpc/idl/browser.idl diff --git a/source4/librpc/idl/dbgidl.idl b/librpc/idl/dbgidl.idl similarity index 100% rename from source4/librpc/idl/dbgidl.idl rename to librpc/idl/dbgidl.idl diff --git a/librpc/idl/dcom.idl b/librpc/idl/dcom.idl new file mode 100644 index 0000000000..977c7ed86a --- /dev/null +++ b/librpc/idl/dcom.idl @@ -0,0 +1,302 @@ +/** + DCOM interfaces + http://www.ietf.org/internet-drafts/draft-brown-dcom-v1-spec-04.txt + */ + +import "misc.idl"; + +[ + uuid("18f70770-8e64-11cf-9af1-0020af6e72f4"), + pointer_default(unique), + version(0.0) +] interface dcom_Unknown +{ + void UseProtSeq(); + void GetCustomProtseqInfo(); + void UpdateResolverBindings(); +} + +[ + object, + uuid("00000000-0000-0000-C000-000000000046"), + pointer_default(unique), + helpstring("Base interface for all COM interfaces") +] +interface IUnknown +{ + /*****************/ + /* Function 0x00 */ + /* Returns the interface with the specified IID + if implemented by this object */ + [local] WERROR QueryInterface([in,unique] GUID *iid, + [out,iid_is(riid)] IUnknown **data); + + /*****************/ + /* Function 0x01 */ + [local] uint32 AddRef(); + + /*****************/ + /* Function 0x02 */ + [local] uint32 Release(); +} + + +[ + object, + uuid("00000001-0000-0000-C000-000000000046"), + pointer_default(unique) +] interface IClassFactory : IUnknown +{ + [local] WERROR CreateInstance([in,unique] MInterfacePointer *pUnknown, + [in,unique] GUID *iid, + [out, iid_is(riid),unique] MInterfacePointer *ppv); + + [call_as(CreateInstance)] WERROR RemoteCreateInstance(); + + /* Set lock to TRUE when you want to do a lock + and set it to FALSE when you want to unlock */ + [local] WERROR LockServer([in] uint8 lock); + + [call_as(LockServer)] WERROR RemoteLockServer(); +} + +/* The remote version of IUnknown. This interface exists on every */ +/* OXID (whether an OXID represents either a thread or a process is */ +/* implementation specific). It is used by clients to query for new */ +/* interfaces, get additional references (for marshaling), and release */ +/* outstanding references. */ +/* This interface is passed along during OXID resolution. */ +/* */ +[ + uuid("00000131-0000-0000-C000-000000000046"), + object, + pointer_default(unique), + helpstring("Remote version of IUnknown") +] +interface IRemUnknown : IUnknown +{ + typedef [public] struct + { + WERROR hResult; /* result of call */ + STDOBJREF std; /* data for returned interface */ + } + REMQIRESULT; + + [call_as(QueryInterface)] WERROR RemQueryInterface ( + [in,unique] GUID *ripid, /* interface to QI on */ + [in] uint32 cRefs, /* count of AddRefs requested */ + [in] uint16 cIids, /* count of IIDs that follow */ + [in, unique, size_is(cIids)] GUID *iids, /* IIDs to QI for */ + [out, size_is(cIids), unique] MInterfacePointer *ip + ); + + typedef struct + { + GUID ipid; /* ipid to AddRef/Release */ + uint32 cPublicRefs; + uint32 cPrivateRefs; + } REMINTERFACEREF; + + [call_as(AddRef)] WERROR RemAddRef ( + [in] uint16 cInterfaceRefs, + [in, size_is(cInterfaceRefs)] REMINTERFACEREF InterfaceRefs[], + [out, size_is(cInterfaceRefs), unique] WERROR *pResults + ); + + [call_as(Release)] WERROR RemRelease ( + [in] uint16 cInterfaceRefs, + [in, size_is(cInterfaceRefs)] REMINTERFACEREF InterfaceRefs[] + ); +} + +[ + uuid("00000140-0000-0000-c000-000000000046"), + pointer_default(unique), + object +] interface IClassActivator : IUnknown +{ + void GetClassObject([in] GUID clsid, + [in] uint32 context, + [in] uint32 locale, + [in] GUID iid, + [out, iid_is(iid)] MInterfacePointer data); +} + +[ + uuid("00000136-0000-0000-c000-000000000046"), + pointer_default(unique), + object +] interface ISCMLocalActivator : IClassActivator +{ + WERROR ISCMLocalActivator_CreateInstance( ); +} + +[ + pointer_default(unique), + uuid("c6f3ee72-ce7e-11d1-b71e-00c04fc3111a") +] interface IMachineLocalActivator +{ + WERROR IMachineLocalActivator_foo(); +} + +[ + pointer_default(unique), + uuid("e60c73e6-88f9-11cf-9af1-0020af6e72f4") +] interface ILocalObjectExporter +{ + WERROR ILocalObjectExporter_Foo(); +} + +/* Looks like this is the equivalent of .NET's + System.Activator class */ +[ + uuid("000001a0-0000-0000-c000-000000000046"), + pointer_default(unique), + object +] + interface ISystemActivator : IClassActivator +{ + WERROR ISystemActivatorRemoteCreateInstance([in] hyper unknown1, /* OXID ? */ + [in] MInterfacePointer iface1, + [in] hyper unknown2, + [out] uint32 unknown3, + [out] MInterfacePointer iface2); +} + + + +/* Derived from IRemUnknown, this interface supports Remote Query interface */ +/* for objects that supply additional data beyond the STDOBJREF in their */ +/* marshaled interface packets. */ +[ + object, + pointer_default(unique), + uuid("00000143-0000-0000-C000-000000000046") +] + +interface IRemUnknown2 : IRemUnknown +{ + [call_as(QueryInterface2)] WERROR RemQueryInterface2 ( + [in, unique] GUID *ripid, + [in] uint16 cIids, + [in, size_is(cIids), unique] GUID *iids, + [out, size_is(cIids), unique] WERROR *phr, + [out, size_is(cIids), unique] MInterfacePointer *ppMIF + ); +} + +[ + object, + pointer_default(unique), + uuid("00020400-0000-0000-C000-000000000046") +] interface IDispatch : IUnknown +{ + /*****************/ + /* Function 0x03 */ + WERROR GetTypeInfoCount( + [out, unique] uint16 *pctinfo); + + typedef struct { + } REF_ITypeInfo; + + /*****************/ + /* Function 0x04 */ + WERROR GetTypeInfo ( + [in] uint16 iTInfo, + [in] uint32 lcid, + [out, unique] REF_ITypeInfo *ppTInfo); + + /*****************/ + /* Function 0x05 */ + WERROR GetIDsOfNames( + [in, unique] GUID *riid, + /*FIXME[in,size_is(cNames)] OLESTR *rgszNames[], */ + [in] uint16 cNames, + [in] uint32 lcid, + [out,size_is(cNames), unique] uint32 *rgDispId); + + typedef struct { + uint16 vartype; + uint16 FIXME; + } VARIANT; + + typedef struct { + uint16 FIXME; + } DISPPARAMS; + + /* Exception ? */ + typedef struct { + uint16 FIXME; + } EXCEPINFO; + + /*****************/ + /* Function 0x06 */ + WERROR Invoke( + [in] uint32 dispIdMember, + [in, unique] GUID *riid, + [in] uint32 lcid, + [in] uint16 wFlags, + [out,in, unique] DISPPARAMS *pDispParams, + [out, unique] VARIANT *pVarResult, + [out, unique] EXCEPINFO *pExcepInfo, + [out, unique] uint16 *puArgErr); +} + +[ + object, + local, + uuid("00000003-0000-0000-C000-000000000046") +] interface IMarshal : IUnknown +{ + WERROR MarshalInterface(); + WERROR UnMarshalInterface(); +} + +[ + uuid(DA23F6DB-6F45-466C-9EED-0B65286F2D78), + helpstring("ICoffeeMachine Interface"), + pointer_default(unique), + object +] interface ICoffeeMachine : IUnknown +{ + WERROR MakeCoffee([in,string,charset(UTF16)] uint16 *flavor); +} + +[ + uuid("db7c21f8-fe33-4c11-aea5-ceb56f076fbb"), + helpstring("coffeemachine class") +] coclass coffeemachine +{ + interface icoffeemachine; +} + +[ + object, + pointer_default(unique), + uuid("0000000C-0000-0000-C000-000000000046"), + helpstring("Stream") +] +interface IStream : IUnknown +{ + WERROR Read( + [out, size_is(num_requested), length_is(num_read)] uint8 pv[], + [in] uint32 num_requested, + [in, unique] uint32 *num_readx, + [out] uint32 num_read + ); + + WERROR Write( + [in,size_is(num_requested),unique] uint8 *data, + [in] uint32 num_requested, + [out] uint32 num_written); +} + +[ + uuid("5e9ddec7-5767-11cf-beab-00aa006c3606"), + progid("Samba.Simple"), + helpstring("simple class"), + internal +] coclass simple +{ + interface IStream; +} diff --git a/source4/librpc/idl/dfs.idl b/librpc/idl/dfs.idl similarity index 99% rename from source4/librpc/idl/dfs.idl rename to librpc/idl/dfs.idl index b279f555d9..1b145f3dfa 100644 --- a/source4/librpc/idl/dfs.idl +++ b/librpc/idl/dfs.idl @@ -16,7 +16,8 @@ import "misc.idl"; typedef [v1_enum] enum { DFS_MANAGER_VERSION_NT4 = 1, DFS_MANAGER_VERSION_W2K = 2, - DFS_MANAGER_VERSION_W2K3 = 4 + DFS_MANAGER_VERSION_W2K3 = 4, + DFS_MANAGER_VERSION_W2K8 = 6 } dfs_ManagerVersion; [public] void dfs_GetManagerVersion( diff --git a/source4/librpc/idl/dnsserver.idl b/librpc/idl/dnsserver.idl similarity index 100% rename from source4/librpc/idl/dnsserver.idl rename to librpc/idl/dnsserver.idl diff --git a/source4/librpc/idl/drsblobs.idl b/librpc/idl/drsblobs.idl similarity index 94% rename from source4/librpc/idl/drsblobs.idl rename to librpc/idl/drsblobs.idl index 6b1f649ff5..087f0c982d 100644 --- a/source4/librpc/idl/drsblobs.idl +++ b/librpc/idl/drsblobs.idl @@ -332,7 +332,7 @@ interface drsblobs { ); typedef [public] struct { - [flag(STR_NOTERM|NDR_REMAINING)] string cleartext; + [flag(NDR_REMAINING)] DATA_BLOB cleartext; } package_PrimaryCLEARTEXTBlob; void decode_PrimaryCLEARTEXT( @@ -409,24 +409,35 @@ interface drsblobs { [size_is(1)] AuthenticationInformation array[]; } AuthenticationInformationArray; + /* This is nopull,nopush because we pass count down to the + * manual parser of AuthenticationInformationArray */ typedef [public,nopull,nopush,noprint,gensize] struct { uint32 count; [relative] AuthenticationInformationArray *current; [relative] AuthenticationInformationArray *previous; } trustAuthInOutBlob; - typedef [public] struct { - uint8 confounder[512]; - trustAuthInOutBlob outgoing; - trustAuthInOutBlob incoming; - [value(ndr_size_trustAuthInOutBlob(&outgoing, ndr->flags))] uint32 outgoing_size; - [value(ndr_size_trustAuthInOutBlob(&incoming, ndr->flags))] uint32 incoming_size; - } trustAuthInAndOutBlob; - void decode_trustAuthInOut( [in] trustAuthInOutBlob blob ); + typedef [public,gensize] struct { + uint32 count; + [relative] AuthenticationInformation *current[count]; + } trustCurrentPasswords; + + typedef [public,nopull] struct { + uint8 confounder[512]; + [subcontext(0),subcontext_size(outgoing_size)] trustCurrentPasswords outgoing; + [subcontext(0),subcontext_size(incoming_size)] trustCurrentPasswords incoming; + [value(ndr_size_trustCurrentPasswords(&outgoing, ndr->flags))] uint32 outgoing_size; + [value(ndr_size_trustCurrentPasswords(&incoming, ndr->flags))] uint32 incoming_size; + } trustDomainPasswords; + + void decode_trustDomainPasswords( + [in] trustDomainPasswords blob + ); + typedef [public] struct { uint32 marker; DATA_BLOB data; diff --git a/source3/librpc/idl/drsuapi.idl b/librpc/idl/drsuapi.idl similarity index 97% rename from source3/librpc/idl/drsuapi.idl rename to librpc/idl/drsuapi.idl index 56dd483054..e4b5dc1fd9 100644 --- a/source3/librpc/idl/drsuapi.idl +++ b/librpc/idl/drsuapi.idl @@ -2,13 +2,13 @@ import "security.idl", "misc.idl", "samr.idl"; -[ +[ uuid("e3514235-4b06-11d1-ab04-00c04fc2dcd2"), version(4.0), endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]", "ncacn_ip_tcp:", "ncalrpc:"), authservice("ldap"), helpstring("Active Directory Replication"), - helper("librpc/ndr/ndr_drsuapi.h"), + helper("../librpc/ndr/ndr_drsuapi.h"), pointer_default(unique) ] interface drsuapi @@ -115,11 +115,11 @@ interface drsuapi } drsuapi_DsBindInfoCtr; /* this is a magic guid you need to pass to DsBind to make drsuapi_DsWriteAccountSpn() work - * + * * maybe the bind_guid could also be the invocation_id see drsuapi_DsReplicaConnection04 */ const char *DRSUAPI_DS_BIND_GUID = "e24d201a-4fd6-11d1-a3da-0000f875ae0d"; - /* + /* * this magic guid are needed to fetch the whole tree with drsuapi_DsGetNCChanges() * as administrator and this values are also used in the destination_dsa_guid field * of drsuapi_DsGetNCChangesReq5/8 and the source_dsa_guid is zero. @@ -232,7 +232,7 @@ interface drsuapi DRSUAPI_DS_REPLICA_NEIGHBOUR_PREEMPTED = 0x01000000, DRSUAPI_DS_REPLICA_NEIGHBOUR_IGNORE_CHANGE_NOTIFICATIONS = 0x04000000, DRSUAPI_DS_REPLICA_NEIGHBOUR_DISABLE_SCHEDULED_SYNC = 0x08000000, - /* + /* * the following NOTE applies to DsGetNCChangesRequest5: * - the data is only compressed when 10 or more objects are replicated * - but there could also be a size limit of 35 KBytes or something like that @@ -454,7 +454,7 @@ interface drsuapi DRSUAPI_ATTRIBUTE_objectCategory = 0x0009030e, DRSUAPI_ATTRIBUTE_gPLink = 0x0009037b, DRSUAPI_ATTRIBUTE_msDS_Behavior_Version = 0x000905b3, - DRSUAPI_ATTRIBUTE_msDS_KeyVersionNumber = 0x000906f6, + DRSUAPI_ATTRIBUTE_msDS_KeyVersionNumber = 0x000906f6, DRSUAPI_ATTRIBUTE_msDS_HasDomainNCs = 0x0009071c, DRSUAPI_ATTRIBUTE_msDS_hasMasterNCs = 0x0009072c } drsuapi_DsAttributeId; @@ -629,36 +629,44 @@ interface drsuapi WERROR drs_error; } drsuapi_DsGetNCChangesCtr6; - typedef struct { + typedef [public] struct { + [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr1 ctr1; + } drsuapi_DsGetNCChangesCtr1TS; + + typedef [public] struct { + [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr6 ctr6; + } drsuapi_DsGetNCChangesCtr6TS; + + typedef [nopush] struct { uint32 decompressed_length; uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1 *ctr1; + drsuapi_DsGetNCChangesCtr1TS *ts; } drsuapi_DsGetNCChangesMSZIPCtr1; - typedef struct { + typedef [nopush] struct { uint32 decompressed_length; uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6 *ctr6; + drsuapi_DsGetNCChangesCtr6TS *ts; } drsuapi_DsGetNCChangesMSZIPCtr6; - typedef struct { + typedef [nopush] struct { uint32 decompressed_length; uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1 *ctr1; + drsuapi_DsGetNCChangesCtr1TS *ts; } drsuapi_DsGetNCChangesXPRESSCtr1; - typedef struct { + typedef [nopush] struct { uint32 decompressed_length; uint32 compressed_length; [subcontext(4),subcontext_size(compressed_length), compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6 *ctr6; + drsuapi_DsGetNCChangesCtr6TS *ts; } drsuapi_DsGetNCChangesXPRESSCtr6; typedef [enum16bit] enum { @@ -674,13 +682,7 @@ interface drsuapi } drsuapi_DsGetNCChangesCompressedCtr; typedef struct { - /* - * this is a bit ugly, as the compression depends on the flags - * in the DsBind(), but only w2k uses DsGetNCChangesReq5 - * and will get DsGetNCChangesCtr2 replies, and w2k only knowns - * about MSZIP and level 1 replies - */ - [switch_is(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesCompressedCtr ctr; + drsuapi_DsGetNCChangesMSZIPCtr1 mszip1; } drsuapi_DsGetNCChangesCtr2; typedef struct { @@ -739,7 +741,7 @@ interface drsuapi /* TODO ... */ } drsuapi_DsReplicaAddOptions; - WERROR DRSUAPI_REPLICA_ADD(); + [todo] WERROR DRSUAPI_REPLICA_ADD(); /*****************/ /* Function 0x06 */ @@ -749,7 +751,7 @@ interface drsuapi /* TODO ... */ } drsuapi_DsReplicaDeleteOptions; - WERROR DRSUAPI_REPLICA_DEL(); + [todo] WERROR DRSUAPI_REPLICA_DEL(); /*****************/ /* Function 0x07 */ @@ -758,11 +760,11 @@ interface drsuapi DRSUAPI_DS_REPLICA_MODIFY_WRITEABLE = 0x00000002 } drsuapi_DsReplicaModifyOptions; - WERROR DRSUAPI_REPLICA_MODIFY(); + [todo] WERROR DRSUAPI_REPLICA_MODIFY(); /*****************/ /* Function 0x08 */ - WERROR DRSUAPI_VERIFY_NAMES(); + [todo] WERROR DRSUAPI_VERIFY_NAMES(); /*****************/ /* Function 0x09 */ @@ -805,7 +807,7 @@ interface drsuapi [case(1)] drsuapi_DsGetMembershipsRequest1 req1; } drsuapi_DsGetMembershipsRequest; - WERROR drsuapi_DsGetMemberships( + [todo] WERROR drsuapi_DsGetMemberships( [in] policy_handle *bind_handle, [in] int32 level, [in,ref] [switch_is(level)] drsuapi_DsGetMembershipsRequest *req, @@ -815,7 +817,7 @@ interface drsuapi /*****************/ /* Function 0x0a */ - WERROR DRSUAPI_INTER_DOMAIN_MOVE(); + [todo] WERROR DRSUAPI_INTER_DOMAIN_MOVE(); /*****************/ /* Function 0x0b */ @@ -848,7 +850,7 @@ interface drsuapi [case(1)] drsuapi_DsGetNT4ChangeLogInfo1 info1; } drsuapi_DsGetNT4ChangeLogInfo; - WERROR drsuapi_DsGetNT4ChangeLog( + [todo] WERROR drsuapi_DsGetNT4ChangeLog( [in] policy_handle *bind_handle, [in] uint32 level, [in,ref] [switch_is(level)] drsuapi_DsGetNT4ChangeLogRequest *req, @@ -878,7 +880,7 @@ interface drsuapi } drsuapi_DsNameFlags; typedef [v1_enum] enum { - DRSUAPI_DS_NAME_FORMAT_UKNOWN = 0, + DRSUAPI_DS_NAME_FORMAT_UNKNOWN = 0, DRSUAPI_DS_NAME_FORMAT_FQDN_1779 = 1, DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT = 2, DRSUAPI_DS_NAME_FORMAT_DISPLAY = 3, @@ -973,7 +975,7 @@ interface drsuapi typedef struct { [charset(UTF16),string] uint16 *server_dn; [charset(UTF16),string] uint16 *domain_dn; - uint32 unknown; /* 0x000000001 */ + boolean32 commit; } drsuapi_DsRemoveDSServerRequest1; typedef [switch_type(int32)] union { @@ -981,7 +983,7 @@ interface drsuapi } drsuapi_DsRemoveDSServerRequest; typedef struct { - WERROR status; + boolean32 last_dc_in_domain; } drsuapi_DsRemoveDSServerResult1; typedef [switch_type(int32)] union { @@ -998,7 +1000,7 @@ interface drsuapi /*****************/ /* Function 0x0f */ - WERROR DRSUAPI_REMOVE_DS_DOMAIN(); + [todo] WERROR DRSUAPI_REMOVE_DS_DOMAIN(); /*****************/ /* Function 0x10 */ @@ -1142,7 +1144,7 @@ interface drsuapi /* * please note the the current idl - * for DsAddEntry does only parse + * for DsAddEntry does only parse * what I saw between 2 w2k3 boxes * in my dssync experiments I got some other replies * so all I want to say is that this is very incomplete yet... @@ -1242,7 +1244,7 @@ interface drsuapi /*****************/ /* Function 0x12 */ - WERROR DRSUAPI_EXECUTE_KCC(); + [todo] WERROR DRSUAPI_EXECUTE_KCC(); /*****************/ /* Function 0x13 */ @@ -1523,7 +1525,7 @@ interface drsuapi /*****************/ /* Function 0x14 */ - WERROR DRSUAPI_ADD_SID_HISTORY(); + [todo] WERROR DRSUAPI_ADD_SID_HISTORY(); /*****************/ /* Function 0x15 */ @@ -1554,14 +1556,13 @@ interface drsuapi [out,ref] [switch_is(*level_out)] drsuapi_DsGetMemberships2Ctr *ctr ); - /*****************/ /* Function 0x16 */ - WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS(); + [todo] WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS(); /*****************/ /* Function 0x17 */ - WERROR DRSUAPI_GET_OBJECT_EXISTENCE(); + [todo] WERROR DRSUAPI_GET_OBJECT_EXISTENCE(); /*****************/ /* Function 0x18 */ diff --git a/source4/librpc/idl/dsbackup.idl b/librpc/idl/dsbackup.idl similarity index 100% rename from source4/librpc/idl/dsbackup.idl rename to librpc/idl/dsbackup.idl diff --git a/source4/librpc/idl/dssetup.idl b/librpc/idl/dssetup.idl similarity index 100% rename from source4/librpc/idl/dssetup.idl rename to librpc/idl/dssetup.idl diff --git a/source4/librpc/idl/echo.idl b/librpc/idl/echo.idl similarity index 100% rename from source4/librpc/idl/echo.idl rename to librpc/idl/echo.idl diff --git a/source4/librpc/idl/efs.idl b/librpc/idl/efs.idl similarity index 100% rename from source4/librpc/idl/efs.idl rename to librpc/idl/efs.idl diff --git a/source4/librpc/idl/epmapper.idl b/librpc/idl/epmapper.idl similarity index 100% rename from source4/librpc/idl/epmapper.idl rename to librpc/idl/epmapper.idl diff --git a/source4/librpc/idl/eventlog.idl b/librpc/idl/eventlog.idl similarity index 90% rename from source4/librpc/idl/eventlog.idl rename to librpc/idl/eventlog.idl index ee42300c7c..ce25dd65ff 100644 --- a/source4/librpc/idl/eventlog.idl +++ b/librpc/idl/eventlog.idl @@ -8,7 +8,6 @@ import "lsa.idl", "security.idl"; [ uuid("82273fdc-e32a-18c3-3f78-827929dc23ea"), version(0.0), - pointer_default(unique), helpstring("Event Logger") ] interface eventlog { @@ -60,7 +59,7 @@ import "lsa.idl", "security.idl"; /* Function: 0x00 */ NTSTATUS eventlog_ClearEventLogW( [in] policy_handle *handle, - [in,unique] lsa_String *unknown + [in,unique] lsa_String *backupfile ); /******************/ @@ -86,7 +85,10 @@ import "lsa.idl", "security.idl"; /******************/ /* Function: 0x05 */ - [todo] NTSTATUS eventlog_GetOldestRecord(); + NTSTATUS eventlog_GetOldestRecord( + [in] policy_handle *handle, + [out,ref] uint32 *oldest_entry + ); /******************/ /* Function: 0x06 */ @@ -96,8 +98,8 @@ import "lsa.idl", "security.idl"; /* Function: 0x07 */ NTSTATUS eventlog_OpenEventLogW( [in,unique] eventlog_OpenUnknown0 *unknown0, - [in] lsa_String logname, - [in] lsa_String servername, + [in,ref] lsa_String *logname, + [in,ref] lsa_String *servername, [in] uint32 unknown2, [in] uint32 unknown3, [out] policy_handle *handle @@ -117,10 +119,10 @@ import "lsa.idl", "security.idl"; [in] policy_handle *handle, [in] uint32 flags, [in] uint32 offset, - [in] uint32 number_of_bytes, - [out,size_is(number_of_bytes)] uint8 *data, - [out] uint32 *sent_size, - [out] uint32 *real_size + [in] [range(0,0x7FFFF)] uint32 number_of_bytes, + [out,ref,size_is(number_of_bytes)] uint8 *data, + [out,ref] uint32 *sent_size, + [out,ref] uint32 *real_size ); /*****************/ diff --git a/source4/librpc/idl/frsapi.idl b/librpc/idl/frsapi.idl similarity index 100% rename from source4/librpc/idl/frsapi.idl rename to librpc/idl/frsapi.idl diff --git a/source4/librpc/idl/frsrpc.idl b/librpc/idl/frsrpc.idl similarity index 100% rename from source4/librpc/idl/frsrpc.idl rename to librpc/idl/frsrpc.idl diff --git a/source4/librpc/idl/idl_types.h b/librpc/idl/idl_types.h similarity index 100% rename from source4/librpc/idl/idl_types.h rename to librpc/idl/idl_types.h diff --git a/source4/librpc/idl/initshutdown.idl b/librpc/idl/initshutdown.idl similarity index 94% rename from source4/librpc/idl/initshutdown.idl rename to librpc/idl/initshutdown.idl index ac30be70dd..02b2501c1d 100644 --- a/source4/librpc/idl/initshutdown.idl +++ b/librpc/idl/initshutdown.idl @@ -23,7 +23,7 @@ import "lsa.idl"; [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, - [in] uint8 reboot + [in] uint8 do_reboot ); WERROR initshutdown_Abort( @@ -39,7 +39,7 @@ import "lsa.idl"; [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, - [in] uint8 reboot, + [in] uint8 do_reboot, [in] uint32 reason ); } diff --git a/source4/librpc/idl/keysvc.idl b/librpc/idl/keysvc.idl similarity index 100% rename from source4/librpc/idl/keysvc.idl rename to librpc/idl/keysvc.idl diff --git a/source4/librpc/idl/krb5pac.idl b/librpc/idl/krb5pac.idl similarity index 95% rename from source4/librpc/idl/krb5pac.idl rename to librpc/idl/krb5pac.idl index bddba04165..a498b795f8 100644 --- a/source4/librpc/idl/krb5pac.idl +++ b/librpc/idl/krb5pac.idl @@ -29,7 +29,7 @@ interface krb5pac netr_SamInfo3 info3; dom_sid2 *res_group_dom_sid; samr_RidWithAttributeArray res_groups; - } PAC_LOGON_INFO; + } PAC_LOGON_INFO; typedef struct { [value(2*strlen_m(upn_name))] uint16 upn_size; @@ -46,7 +46,7 @@ interface krb5pac typedef [public] struct { PAC_LOGON_INFO *info; - } PAC_LOGON_INFO_CTR; + } PAC_LOGON_INFO_CTR; typedef [public,v1_enum] enum { PAC_TYPE_LOGON_INFO = 1, @@ -126,5 +126,9 @@ interface krb5pac [in] PAC_Validate pac_validate ); - + /* used for samba3 netsamlogon cache */ + typedef [public] struct { + time_t timestamp; + netr_SamInfo3 info3; + } netsamlogoncache_entry; } diff --git a/source4/librpc/idl/mgmt.idl b/librpc/idl/mgmt.idl similarity index 100% rename from source4/librpc/idl/mgmt.idl rename to librpc/idl/mgmt.idl diff --git a/source3/librpc/idl/misc.idl b/librpc/idl/misc.idl similarity index 87% rename from source3/librpc/idl/misc.idl rename to librpc/idl/misc.idl index 132a81f138..ff548fe804 100644 --- a/source3/librpc/idl/misc.idl +++ b/librpc/idl/misc.idl @@ -30,9 +30,11 @@ interface misc /* Only SEC_CHAN_WKSTA can forward requests to other domains. */ typedef [public] enum { - SEC_CHAN_WKSTA = 2, - SEC_CHAN_DOMAIN = 4, - SEC_CHAN_BDC = 6 + SEC_CHAN_NULL = 0, + SEC_CHAN_WKSTA = 2, + SEC_CHAN_DNS_DOMAIN = 3, + SEC_CHAN_DOMAIN = 4, + SEC_CHAN_BDC = 6 } netr_SchannelType; /* SAM database types */ @@ -48,4 +50,5 @@ interface misc SAMR_REJECT_IN_HISTORY = 2, SAMR_REJECT_COMPLEXITY = 5 } samr_RejectReason; + } diff --git a/source4/librpc/idl/msgsvc.idl b/librpc/idl/msgsvc.idl similarity index 100% rename from source4/librpc/idl/msgsvc.idl rename to librpc/idl/msgsvc.idl diff --git a/source4/librpc/idl/nbt.idl b/librpc/idl/nbt.idl similarity index 90% rename from source4/librpc/idl/nbt.idl rename to librpc/idl/nbt.idl index 63be489e0d..f3590fcf2b 100644 --- a/source4/librpc/idl/nbt.idl +++ b/librpc/idl/nbt.idl @@ -10,7 +10,7 @@ import "misc.idl", "security.idl", "svcctl.idl", "samr.idl"; [ - helper("libcli/netlogon.h", "libcli/nbt/libnbt.h") + helper("../libcli/netlogon.h", "../libcli/nbt/libnbt.h") ] interface nbt { @@ -262,8 +262,8 @@ interface nbt uint8 pad2; uint16 opcode; uint16 priority; - uint16 class; - [value(strlen(mailslot_name)+1+data.length)] + uint16 _class; + [value(strlen(mailslot_name)+1+data.length)] uint16 byte_count; astring mailslot_name; [flag(NDR_REMAINING)] DATA_BLOB data; @@ -291,7 +291,7 @@ interface nbt [switch_is(smb_command)] smb_body body; } dgram_smb_packet; - const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */ + const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */ typedef [nodiscriminant] union { [case(DGRAM_SMB)] dgram_smb_packet smb; @@ -334,58 +334,54 @@ interface nbt /****************************************** * \MAILSLOT\NET\NETLOGON mailslot requests - * and - * \MAILSLOT\NET\NTLOGON mailslot requests + * and + * \MAILSLOT\NET\NTLOGON mailslot requests */ typedef [public,gensize] struct { - uint32 sa_family; + uint32 sockaddr_family; [flag(NDR_BIG_ENDIAN)] ipv4address pdc_ip; [flag(NDR_REMAINING)] DATA_BLOB remaining; } nbt_sockaddr; typedef [bitmap32bit,public] bitmap { - NBT_SERVER_PDC = 0x00000001, - NBT_SERVER_GC = 0x00000004, - NBT_SERVER_LDAP = 0x00000008, - NBT_SERVER_DS = 0x00000010, - NBT_SERVER_KDC = 0x00000020, - NBT_SERVER_TIMESERV = 0x00000040, - NBT_SERVER_CLOSEST = 0x00000080, - NBT_SERVER_WRITABLE = 0x00000100, - NBT_SERVER_GOOD_TIMESERV = 0x00000200, - NBT_SERVER_NDNC = 0x00000400, - NBT_SERVER_SEL_SEC_DOM_6 = 0x00000800, - NBT_SERVER_FUL_SEC_DOM_6 = 0x00001000, - NBT_SERVER_DS_DNS_CONTR = 0x04000000, - NBT_SERVER_DS_DNS_DOMAIN = 0x02000000, - NBT_SERVER_DS_DNS_FOREST = 0x01000000 + NBT_SERVER_PDC = 0x00000001, + NBT_SERVER_GC = 0x00000004, + NBT_SERVER_LDAP = 0x00000008, + NBT_SERVER_DS = 0x00000010, + NBT_SERVER_KDC = 0x00000020, + NBT_SERVER_TIMESERV = 0x00000040, + NBT_SERVER_CLOSEST = 0x00000080, + NBT_SERVER_WRITABLE = 0x00000100, + NBT_SERVER_GOOD_TIMESERV = 0x00000200, + NBT_SERVER_NDNC = 0x00000400, + NBT_SERVER_SELECT_SECRET_DOMAIN_6 = 0x00000800, + NBT_SERVER_FULL_SECRET_DOMAIN_6 = 0x00001000 } nbt_server_type; typedef [bitmap32bit,public] bitmap { - NETLOGON_NT_VERSION_1 = 0x00000001, - NETLOGON_NT_VERSION_5 = 0x00000002, - NETLOGON_NT_VERSION_5EX = 0x00000004, - NETLOGON_NT_VERSION_5EX_WITH_IP = 0x00000008, - NETLOGON_NT_VERSION_WITH_CLOSEST_SITE = 0x00000010, - NETLOGON_NT_VERSION_AVIOD_NT4EMUL = 0x01000000, - NETLOGON_NT_VERSION_PDC = 0x10000000, - NETLOGON_NT_VERSION_IP = 0x20000000, - NETLOGON_NT_VERSION_LOCAL = 0x40000000, - NETLOGON_NT_VERSION_GC = 0x80000000 + NETLOGON_NT_VERSION_1 = 0x00000001, + NETLOGON_NT_VERSION_5 = 0x00000002, + NETLOGON_NT_VERSION_5EX = 0x00000004, + NETLOGON_NT_VERSION_5EX_WITH_IP = 0x00000008, + NETLOGON_NT_VERSION_WITH_CLOSEST_SITE = 0x00000010, + NETLOGON_NT_VERSION_AVIOD_NT4EMUL = 0x01000000, + NETLOGON_NT_VERSION_PDC = 0x10000000, + NETLOGON_NT_VERSION_IP = 0x20000000, + NETLOGON_NT_VERSION_LOCAL = 0x40000000, + NETLOGON_NT_VERSION_GC = 0x80000000 } netlogon_nt_version_flags; - typedef [enum16bit,public] enum { LOGON_PRIMARY_QUERY = 7, /* Was also NETLOGON_QUERY_FOR_PDC */ NETLOGON_ANNOUNCE_UAS = 10, NETLOGON_RESPONSE_FROM_PDC = 12, LOGON_SAM_LOGON_REQUEST = 18, /* Was also NETLOGON_QUERY_FOR_PDC2, NTLOGON_SAM_LOGON */ LOGON_SAM_LOGON_RESPONSE = 19, /* Was also NTLOGON_SAM_LOGON_REPLY */ - LOGON_SAM_LOGON_PAUSE_RESPONSE = 20, + LOGON_SAM_LOGON_PAUSE_RESPONSE = 20, LOGON_SAM_LOGON_USER_UNKNOWN = 21, /* Was also NTLOGON_SAM_LOGON_REPLY15 */ LOGON_SAM_LOGON_RESPONSE_EX = 23, /* was NETLOGON_RESPONSE_FROM_PDC2 */ - LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24, + LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24, LOGON_SAM_LOGON_USER_UNKNOWN_EX = 25 /* was NETLOGON_RESPONSE_FROM_PDC_USER */ } netlogon_command; @@ -402,12 +398,12 @@ interface nbt [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; /* The manual alignment is required because this * structure is marked flag(NDR_NOALIGN) via the - * nbt_netlogon_packet below. + * nbt_netlogon_packet below. * - * However, both MUST only be present if sid_size > 0 + * However, both MUST only be present if sid_size > 0 */ - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; + [flag(NDR_ALIGN4)] DATA_BLOB _pad; + [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; netlogon_nt_version_flags nt_version; uint16 lmnt_token; uint16 lm20_token; @@ -437,7 +433,7 @@ interface nbt nbt_server_type server_type; netlogon_nt_version_flags nt_version; uint16 lmnt_token; - uint16 lm20_token; + uint16 lm20_token; } NETLOGON_SAM_LOGON_RESPONSE; /* response from pdc hand marshaled (we have an additional @@ -458,11 +454,11 @@ interface nbt nbt_string client_site; /* Optional on NETLOGON_NT_VERSION_5EX_WITH_IP */ - [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->flags))] uint8 sockaddr_size; - [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr; - + [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->flags))] uint8 sockaddr_size; + [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr; + /* Optional on NETLOGON_NT_VERSION_WITH_CLOSEST_SITE */ - nbt_string next_closest_site; + nbt_string next_closest_site; netlogon_nt_version_flags nt_version; uint16 lmnt_token; @@ -548,7 +544,7 @@ interface nbt /********************************************************/ typedef bitmap svcctl_ServerType svcctl_ServerType; - typedef [enum8bit] enum { + typedef [enum8bit] enum { HostAnnouncement = 1, AnnouncementRequest = 2, Election = 8, @@ -576,7 +572,7 @@ interface nbt typedef struct { uint8 Unused; - astring ResponseName; + astring ResponseName; } nbt_browse_announcement_request; typedef struct { @@ -584,7 +580,7 @@ interface nbt uint32 Criteria; uint32 UpTime; /* In milliseconds */ uint32 Reserved; /* Must be zero */ - astring ServerName; + astring ServerName; } nbt_browse_election_request; typedef struct { @@ -649,6 +645,6 @@ interface nbt typedef [public,flag(NDR_NOALIGN)] struct { nbt_browse_opcode opcode; - [switch_is(opcode)] nbt_browse_payload payload; + [switch_is(opcode)] nbt_browse_payload payload; } nbt_browse_packet; } diff --git a/source4/librpc/idl/notify.idl b/librpc/idl/notify.idl similarity index 98% rename from source4/librpc/idl/notify.idl rename to librpc/idl/notify.idl index 6f9ad25f09..3ce2f40ed8 100644 --- a/source4/librpc/idl/notify.idl +++ b/librpc/idl/notify.idl @@ -7,7 +7,7 @@ the change notify buffers */ -import "misc.idl"; +import "security.idl"; [ pointer_default(unique) diff --git a/source3/librpc/idl/ntsvcs.idl b/librpc/idl/ntsvcs.idl similarity index 63% rename from source3/librpc/idl/ntsvcs.idl rename to librpc/idl/ntsvcs.idl index bac2549c73..809ead90c3 100644 --- a/source3/librpc/idl/ntsvcs.idl +++ b/librpc/idl/ntsvcs.idl @@ -1,6 +1,7 @@ /* plug and play services */ + [ uuid("8d9f4e40-a03d-11ce-8f69-08003e30051b"), version(1.0), @@ -11,12 +12,12 @@ interface ntsvcs /******************/ /* Function: 0x00 */ - WERROR PNP_Disconnect(); + [todo] WERROR PNP_Disconnect(); /******************/ /* Function: 0x01 */ - WERROR PNP_Connect(); + [todo] WERROR PNP_Connect(); /******************/ /* Function: 0x02 */ @@ -28,17 +29,17 @@ interface ntsvcs /******************/ /* Function: 0x03 */ - WERROR PNP_GetGlobalState(); + [todo] WERROR PNP_GetGlobalState(); /******************/ /* Function: 0x04 */ - WERROR PNP_InitDetection(); + [todo] WERROR PNP_InitDetection(); /******************/ /* Function: 0x05 */ - WERROR PNP_ReportLogOn(); + [todo] WERROR PNP_ReportLogOn(); /******************/ /* Function: 0x06 */ @@ -51,22 +52,27 @@ interface ntsvcs /******************/ /* Function: 0x07 */ - WERROR PNP_GetRootDeviceInstance(); + [todo] WERROR PNP_GetRootDeviceInstance(); /******************/ /* Function: 0x08 */ - WERROR PNP_GetRelatedDeviceInstance(); + [todo] WERROR PNP_GetRelatedDeviceInstance(); /******************/ /* Function: 0x09 */ - WERROR PNP_EnumerateSubKeys(); + [todo] WERROR PNP_EnumerateSubKeys(); /******************/ /* Function: 0x0a */ - WERROR PNP_GetDeviceList(); + [todo] WERROR PNP_GetDeviceList( + [in,unique] [string,charset(UTF16)] uint16 *filter, + [out,ref] [size_is(*length),length_is(*length)] uint16 *buffer, + [in,out,ref] uint32 *length, + [in] uint32 flags + ); /******************/ /* Function: 0x0b */ @@ -80,7 +86,7 @@ interface ntsvcs /******************/ /* Function: 0x0c */ - WERROR PNP_GetDepth(); + [todo] WERROR PNP_GetDepth(); /******************/ /* Function: 0x0d */ @@ -90,142 +96,142 @@ interface ntsvcs WERROR PNP_GetDeviceRegProp( [in,ref] [string,charset(UTF16)] uint16 *devicepath, [in] uint32 property, - [in,out,ref] uint32 *unknown1, + [in,out,ref] uint32 *reg_data_type, [out,ref] [size_is(*buffer_size)] [length_is(*buffer_size)] uint8 *buffer, [in,out,ref] uint32 *buffer_size, [in,out,ref] uint32 *needed, - [in] uint32 unknown3 + [in] uint32 flags ); /******************/ /* Function: 0x0e */ - WERROR PNP_SetDeviceRegProp(); + [todo] WERROR PNP_SetDeviceRegProp(); /******************/ /* Function: 0x0f */ - WERROR PNP_GetClassInstance(); + [todo] WERROR PNP_GetClassInstance(); /******************/ /* Function: 0x10 */ - WERROR PNP_CreateKey(); + [todo] WERROR PNP_CreateKey(); /******************/ /* Function: 0x11 */ - WERROR PNP_DeleteRegistryKey(); + [todo] WERROR PNP_DeleteRegistryKey(); /******************/ /* Function: 0x12 */ - WERROR PNP_GetClassCount(); + [todo] WERROR PNP_GetClassCount(); /******************/ /* Function: 0x13 */ - WERROR PNP_GetClassName(); + [todo] WERROR PNP_GetClassName(); /******************/ /* Function: 0x14 */ - WERROR PNP_DeleteClassKey(); + [todo] WERROR PNP_DeleteClassKey(); /******************/ /* Function: 0x15 */ - WERROR PNP_GetInterfaceDeviceAlias(); + [todo] WERROR PNP_GetInterfaceDeviceAlias(); /******************/ /* Function: 0x16 */ - WERROR PNP_GetInterfaceDeviceList(); + [todo] WERROR PNP_GetInterfaceDeviceList(); /******************/ /* Function: 0x17 */ - WERROR PNP_GetInterfaceDeviceListSize(); + [todo] WERROR PNP_GetInterfaceDeviceListSize(); /******************/ /* Function: 0x18 */ - WERROR PNP_RegisterDeviceClassAssociation(); + [todo] WERROR PNP_RegisterDeviceClassAssociation(); /******************/ /* Function: 0x19 */ - WERROR PNP_UnregisterDeviceClassAssociation(); + [todo] WERROR PNP_UnregisterDeviceClassAssociation(); /******************/ /* Function: 0x1a */ - WERROR PNP_GetClassRegProp(); + [todo] WERROR PNP_GetClassRegProp(); /******************/ /* Function: 0x1b */ - WERROR PNP_SetClassRegProp(); + [todo] WERROR PNP_SetClassRegProp(); /******************/ /* Function: 0x1c */ - WERROR PNP_CreateDevInst(); + [todo] WERROR PNP_CreateDevInst(); /******************/ /* Function: 0x1d */ - WERROR PNP_DeviceInstanceAction(); + [todo] WERROR PNP_DeviceInstanceAction(); /******************/ /* Function: 0x1e */ - WERROR PNP_GetDeviceStatus(); + [todo] WERROR PNP_GetDeviceStatus(); /******************/ /* Function: 0x1f */ - WERROR PNP_SetDeviceProblem(); + [todo] WERROR PNP_SetDeviceProblem(); /******************/ /* Function: 0x20 */ - WERROR PNP_DisableDevInst(); + [todo] WERROR PNP_DisableDevInst(); /******************/ /* Function: 0x21 */ - WERROR PNP_UninstallDevInst(); + [todo] WERROR PNP_UninstallDevInst(); /******************/ /* Function: 0x22 */ - WERROR PNP_AddID(); + [todo] WERROR PNP_AddID(); /******************/ /* Function: 0x23 */ - WERROR PNP_RegisterDriver(); + [todo] WERROR PNP_RegisterDriver(); /******************/ /* Function: 0x24 */ - WERROR PNP_QueryRemove(); + [todo] WERROR PNP_QueryRemove(); /******************/ /* Function: 0x25 */ - WERROR PNP_RequestDeviceEject(); + [todo] WERROR PNP_RequestDeviceEject(); /******************/ /* Function: 0x26 */ - WERROR PNP_IsDockStationPresent(); + [todo] WERROR PNP_IsDockStationPresent(); /******************/ /* Function: 0x27 */ - WERROR PNP_RequestEjectPC(); + [todo] WERROR PNP_RequestEjectPC(); /******************/ /* Function: 0x28 */ @@ -261,115 +267,115 @@ interface ntsvcs /******************/ /* Function: 0x2a */ - WERROR PNP_AddEmptyLogConf(); + [todo] WERROR PNP_AddEmptyLogConf(); /******************/ /* Function: 0x2b */ - WERROR PNP_FreeLogConf(); + [todo] WERROR PNP_FreeLogConf(); /******************/ /* Function: 0x2c */ - WERROR PNP_GetFirstLogConf(); + [todo] WERROR PNP_GetFirstLogConf(); /******************/ /* Function: 0x2d */ - WERROR PNP_GetNextLogConf(); + [todo] WERROR PNP_GetNextLogConf(); /******************/ /* Function: 0x2e */ - WERROR PNP_GetLogConfPriority(); + [todo] WERROR PNP_GetLogConfPriority(); /******************/ /* Function: 0x2f */ - WERROR PNP_AddResDes(); + [todo] WERROR PNP_AddResDes(); /******************/ /* Function: 0x30 */ - WERROR PNP_FreeResDes(); + [todo] WERROR PNP_FreeResDes(); /******************/ /* Function: 0x31 */ - WERROR PNP_GetNextResDes(); + [todo] WERROR PNP_GetNextResDes(); /******************/ /* Function: 0x32 */ - WERROR PNP_GetResDesData(); + [todo] WERROR PNP_GetResDesData(); /******************/ /* Function: 0x33 */ - WERROR PNP_GetResDesDataSize(); + [todo] WERROR PNP_GetResDesDataSize(); /******************/ /* Function: 0x34 */ - WERROR PNP_ModifyResDes(); + [todo] WERROR PNP_ModifyResDes(); /******************/ /* Function: 0x35 */ - WERROR PNP_DetectResourceLimit(); + [todo] WERROR PNP_DetectResourceLimit(); /******************/ /* Function: 0x36 */ - WERROR PNP_QueryResConfList(); + [todo] WERROR PNP_QueryResConfList(); /******************/ /* Function: 0x37 */ - WERROR PNP_SetHwProf(); + [todo] WERROR PNP_SetHwProf(); /******************/ /* Function: 0x38 */ - WERROR PNP_QueryArbitratorFreeData(); + [todo] WERROR PNP_QueryArbitratorFreeData(); /******************/ /* Function: 0x39 */ - WERROR PNP_QueryArbitratorFreeSize(); + [todo] WERROR PNP_QueryArbitratorFreeSize(); /******************/ /* Function: 0x3a */ - WERROR PNP_RunDetection(); + [todo] WERROR PNP_RunDetection(); /******************/ /* Function: 0x3b */ - WERROR PNP_RegisterNotification(); + [todo] WERROR PNP_RegisterNotification(); /******************/ /* Function: 0x3c */ - WERROR PNP_UnregisterNotification(); + [todo] WERROR PNP_UnregisterNotification(); /******************/ /* Function: 0x3d */ - WERROR PNP_GetCustomDevProp(); + [todo] WERROR PNP_GetCustomDevProp(); /******************/ /* Function: 0x3e */ - WERROR PNP_GetVersionInternal(); + [todo] WERROR PNP_GetVersionInternal(); /******************/ /* Function: 0x3f */ - WERROR PNP_GetBlockedDriverInfo(); + [todo] WERROR PNP_GetBlockedDriverInfo(); /******************/ /* Function: 0x40 */ - WERROR PNP_GetServerSideDeviceInstallFlags(); + [todo] WERROR PNP_GetServerSideDeviceInstallFlags(); } diff --git a/source4/librpc/idl/orpc.idl b/librpc/idl/orpc.idl similarity index 100% rename from source4/librpc/idl/orpc.idl rename to librpc/idl/orpc.idl diff --git a/source4/librpc/idl/oxidresolver.idl b/librpc/idl/oxidresolver.idl similarity index 100% rename from source4/librpc/idl/oxidresolver.idl rename to librpc/idl/oxidresolver.idl diff --git a/source4/librpc/idl/policyagent.idl b/librpc/idl/policyagent.idl similarity index 100% rename from source4/librpc/idl/policyagent.idl rename to librpc/idl/policyagent.idl diff --git a/source4/librpc/idl/protected_storage.idl b/librpc/idl/protected_storage.idl similarity index 100% rename from source4/librpc/idl/protected_storage.idl rename to librpc/idl/protected_storage.idl diff --git a/source4/librpc/idl/remact.idl b/librpc/idl/remact.idl similarity index 100% rename from source4/librpc/idl/remact.idl rename to librpc/idl/remact.idl diff --git a/source4/librpc/idl/rot.idl b/librpc/idl/rot.idl similarity index 100% rename from source4/librpc/idl/rot.idl rename to librpc/idl/rot.idl diff --git a/source3/librpc/idl/security.idl b/librpc/idl/security.idl similarity index 95% rename from source3/librpc/idl/security.idl rename to librpc/idl/security.idl index c1dfe272e9..6704e300a5 100644 --- a/source3/librpc/idl/security.idl +++ b/librpc/idl/security.idl @@ -106,6 +106,9 @@ interface security const int SEC_ADS_LIST_OBJECT = 0x00000080; const int SEC_ADS_CONTROL_ACCESS = 0x00000100; + /* invalid bits */ + const int SEC_MASK_INVALID = 0x0ce0fe00; + /* generic->specific mappings for files */ const int SEC_RIGHTS_FILE_READ = SEC_STD_READ_CONTROL | SEC_STD_SYNCHRONIZE | @@ -150,6 +153,7 @@ interface security const string SID_CREATOR_OWNER_DOMAIN = "S-1-3"; const string SID_CREATOR_OWNER = "S-1-3-0"; const string SID_CREATOR_GROUP = "S-1-3-1"; + const string SID_OWNER_RIGHTS = "S-1-3-4"; /* SECURITY_NT_AUTHORITY */ const string NAME_NT_AUTHORITY = "NT AUTHORITY"; @@ -169,9 +173,14 @@ interface security const string SID_NT_TERMINAL_SERVER_USERS = "S-1-5-13"; const string SID_NT_REMOTE_INTERACTIVE = "S-1-5-14"; const string SID_NT_THIS_ORGANISATION = "S-1-5-15"; + const string SID_NT_IUSR = "S-1-5-17"; const string SID_NT_SYSTEM = "S-1-5-18"; const string SID_NT_LOCAL_SERVICE = "S-1-5-19"; const string SID_NT_NETWORK_SERVICE = "S-1-5-20"; + const string SID_NT_DIGEST_AUTHENTICATION = "S-1-5-64-21"; + const string SID_NT_NTLM_AUTHENTICATION = "S-1-5-64-10"; + const string SID_NT_SCHANNEL_AUTHENTICATION = "S-1-5-64-14"; + const string SID_NT_OTHER_ORGANISATION = "S-1-5-1000"; /* SECURITY_BUILTIN_DOMAIN_RID */ const string NAME_BUILTIN = "BUILTIN"; @@ -233,6 +242,7 @@ interface security SEC_PRIV_REMOTE_INTERACTIVE_LOGON = 24 } sec_privilege; + typedef [bitmap8bit] bitmap { SEC_ACE_FLAG_OBJECT_INHERIT = 0x01, SEC_ACE_FLAG_CONTAINER_INHERIT = 0x02, @@ -373,4 +383,12 @@ interface security SECINFO_PROTECTED_SACL = 0x40000000, SECINFO_PROTECTED_DACL = 0x80000000 } security_secinfo; + + typedef [public,bitmap32bit] bitmap { + KERB_ENCTYPE_DES_CBC_CRC = 0x00000001, + KERB_ENCTYPE_DES_CBC_MD5 = 0x00000002, + KERB_ENCTYPE_RC4_HMAC_MD5 = 0x00000004, + KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96 = 0x00000008, + KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96 = 0x00000010 + } kerb_EncTypes; } diff --git a/source4/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl similarity index 100% rename from source4/librpc/idl/spoolss.idl rename to librpc/idl/spoolss.idl diff --git a/source3/librpc/idl/svcctl.idl b/librpc/idl/svcctl.idl similarity index 94% rename from source3/librpc/idl/svcctl.idl rename to librpc/idl/svcctl.idl index 5a843d04ef..3eb686fe15 100644 --- a/source3/librpc/idl/svcctl.idl +++ b/librpc/idl/svcctl.idl @@ -4,6 +4,7 @@ svcctl interface definitions */ +import "misc.idl"; [ uuid("367abb81-9844-35f1-ad32-98f038001003"), version(2.0), pointer_default(unique), @@ -91,7 +92,7 @@ typedef enum { FIXME=1 } SERVICE_CONTROL; - + WERROR svcctl_ControlService( [in,ref] policy_handle *handle, [in] uint32 control, @@ -140,7 +141,7 @@ /*****************/ /* Function 0x07 */ - WERROR svcctl_SetServiceStatus( + [todo] WERROR svcctl_SetServiceStatus( ); /*****************/ @@ -151,7 +152,7 @@ /*****************/ /* Function 0x09 */ - WERROR svcctl_NotifyBootConfigStatus( + [todo] WERROR svcctl_NotifyBootConfigStatus( ); /*****************/ @@ -265,11 +266,24 @@ /*****************/ /* Function 0x11 */ + + typedef [public,gensize] struct { + uint32 service_type; + uint32 start_type; + uint32 error_control; + [string,charset(UTF16)] [range(0,8192)] uint16 *executablepath; + [string,charset(UTF16)] [range(0,8192)] uint16 *loadordergroup; + uint32 tag_id; + [string,charset(UTF16)] [range(0,8192)] uint16 *dependencies; + [string,charset(UTF16)] [range(0,8192)] uint16 *startname; + [string,charset(UTF16)] [range(0,8192)] uint16 *displayname; + } QUERY_SERVICE_CONFIG; + WERROR svcctl_QueryServiceConfigW( [in,ref] policy_handle *handle, - [out] uint8 query[buf_size], /*QUERY_SERVICE_CONFIG */ - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed + [out] QUERY_SERVICE_CONFIG *query, + [in] [range(0,8192)] uint32 buf_size, + [out,ref] [range(0,8192)] uint32 *bytes_needed ); /*****************/ @@ -296,7 +310,7 @@ [in,unique] [string,charset(UTF16)] uint16 *service_name, [out,ref] [string,charset(UTF16)] uint16 **display_name, [in,out,unique] uint32 *display_name_length - ); + ); /*****************/ /* Function 0x15 */ @@ -373,7 +387,7 @@ [out,ref] uint32 *services_returned, [in,out,unique] uint32 *resume_handle ); - + /*****************/ /* Function 0x1b */ WERROR svcctl_OpenSCManagerA( @@ -424,7 +438,7 @@ [in,unique] [string,charset(UTF16)] uint16 *service_name, [out,ref] [string,charset(UTF16)] uint16 **display_name, [in,out,unique] uint32 *display_name_length - ); + ); /*****************/ /* Function 0x21 */ @@ -437,12 +451,12 @@ /*****************/ /* Function 0x22 */ - WERROR svcctl_GetCurrentGroupeStateW( + [todo] WERROR svcctl_GetCurrentGroupeStateW( ); /*****************/ /* Function 0x23 */ - WERROR svcctl_EnumServiceGroupW( + [todo] WERROR svcctl_EnumServiceGroupW( ); /*****************/ @@ -523,6 +537,6 @@ /*****************/ /* Function 0x2b */ - WERROR svcctl_SCSendTSMessage( + [todo] WERROR svcctl_SCSendTSMessage( ); } diff --git a/source4/librpc/idl/trkwks.idl b/librpc/idl/trkwks.idl similarity index 100% rename from source4/librpc/idl/trkwks.idl rename to librpc/idl/trkwks.idl diff --git a/source4/librpc/idl/unixinfo.idl b/librpc/idl/unixinfo.idl similarity index 100% rename from source4/librpc/idl/unixinfo.idl rename to librpc/idl/unixinfo.idl diff --git a/source4/librpc/idl/w32time.idl b/librpc/idl/w32time.idl similarity index 100% rename from source4/librpc/idl/w32time.idl rename to librpc/idl/w32time.idl diff --git a/source4/librpc/idl/winreg.cnf b/librpc/idl/winreg.cnf similarity index 100% rename from source4/librpc/idl/winreg.cnf rename to librpc/idl/winreg.cnf diff --git a/source4/librpc/idl/winreg.idl b/librpc/idl/winreg.idl similarity index 97% rename from source4/librpc/idl/winreg.idl rename to librpc/idl/winreg.idl index 1e01a91197..9216f9893b 100644 --- a/source4/librpc/idl/winreg.idl +++ b/librpc/idl/winreg.idl @@ -228,7 +228,7 @@ import "lsa.idl", "security.idl"; [in,out,ref] winreg_String *classname, [out,ref] uint32 *num_subkeys, [out,ref] uint32 *max_subkeylen, - [out,ref] uint32 *max_subkeysize, + [out,ref] uint32 *max_classlen, [out,ref] uint32 *num_values, [out,ref] uint32 *max_valnamelen, [out,ref] uint32 *max_valbufsize, @@ -240,11 +240,11 @@ import "lsa.idl", "security.idl"; /* Function: 0x11 */ [public] WERROR winreg_QueryValue( [in,ref] policy_handle *handle, - [in] winreg_String value_name, + [in,ref] winreg_String *value_name, [in,out,unique] winreg_Type *type, - [in,out,unique,size_is(*size),length_is(*length)] uint8 *data, - [in,out,unique] uint32 *size, - [in,out,unique] uint32 *length + [in,out,unique,size_is(*data_size),length_is(*data_length)] uint8 *data, + [in,out,unique] uint32 *data_size, + [in,out,unique] uint32 *data_length ); /******************/ @@ -309,7 +309,7 @@ import "lsa.idl", "security.idl"; [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, - [in] uint8 reboot + [in] uint8 do_reboot ); /******************/ @@ -369,7 +369,7 @@ import "lsa.idl", "security.idl"; [in,unique] lsa_StringLarge *message, [in] uint32 timeout, [in] uint8 force_apps, - [in] uint8 reboot, + [in] uint8 do_reboot, [in] uint32 reason ); diff --git a/source3/librpc/idl/wkssvc.idl b/librpc/idl/wkssvc.idl similarity index 100% rename from source3/librpc/idl/wkssvc.idl rename to librpc/idl/wkssvc.idl diff --git a/librpc/idl/wmi.idl b/librpc/idl/wmi.idl new file mode 100644 index 0000000000..1f7b5ca1cf --- /dev/null +++ b/librpc/idl/wmi.idl @@ -0,0 +1,716 @@ +/* + * WMI IDL. + * See http://en.wikipedia.org/wiki/Windows_Management_Instrumentation for more information. + */ +#include "idl_types.h" + +import "dcom.idl"; +import "misc.idl"; + +[ + helper("librpc/ndr/ndr_wmi.h"), + uuid("8BC3F05E-D86B-11d0-A075-00C04FB68820") +] coclass WbemLevel1Login +{ + interface IWbemLevel1Login; + +}; + +[ + local, + object, + uuid("dc12a681-737f-11cf-884d-00aa004b2e24") +] +interface IWbemClassObject : IUnknown +{ + + typedef [noprint] struct { + [value(0x72657355)] uint32 flags; + [string, charset(UTF16)] uint16 data[]; + } BSTR; + + WERROR Delete( + [in, string, charset(UTF16)] uint16 *wszName + ); + +}; + +[ + uuid(9A653086-174F-11d2-B5F9-00104B703EFD) +] +coclass WbemClassObject +{ + interface IWbemClassObject; +}; + + +[ + uuid("9556dc99-828c-11cf-a37e-00aa003240c7"), + object, + pointer_default(unique) +] interface IWbemServices : IUnknown +{ + typedef [v1_enum] enum + { + RPC_S_CALL_FAILED = 1726, + + WBEM_NO_ERROR = 0, + WBEM_S_NO_ERROR = 0, + WBEM_S_SAME = 0, + WBEM_S_FALSE = 1, + WBEM_S_ALREADY_EXISTS = 0x40001, + WBEM_S_RESET_TO_DEFAULT = 0x40002, + WBEM_S_DIFFERENT = 0x40003, + WBEM_S_TIMEDOUT = 0x40004, + WBEM_S_NO_MORE_DATA = 0x40005, + WBEM_S_OPERATION_CANCELLED = 0x40006, + WBEM_S_PENDING = 0x40007, + WBEM_S_DUPLICATE_OBJECTS = 0x40008, + WBEM_S_ACCESS_DENIED = 0x40009, + WBEM_S_PARTIAL_RESULTS = 0x40010, + WBEM_S_NO_POSTHOOK = 0x40011, + WBEM_S_POSTHOOK_WITH_BOTH = 0x40012, + WBEM_S_POSTHOOK_WITH_NEW = 0x40013, + WBEM_S_POSTHOOK_WITH_STATUS = 0x40014, + WBEM_S_POSTHOOK_WITH_OLD = 0x40015, + WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT = 0x40016, + WBEM_S_SOURCE_NOT_AVAILABLE = 0x40017, + WBEM_E_FAILED = 0x80041001, + WBEM_E_NOT_FOUND = 0x80041002, + WBEM_E_ACCESS_DENIED = 0x80041003, + WBEM_E_PROVIDER_FAILURE = 0x80041004, + WBEM_E_TYPE_MISMATCH = 0x80041005, + WBEM_E_OUT_OF_MEMORY = 0x80041006, + WBEM_E_INVALID_CONTEXT = 0x80041007, + WBEM_E_INVALID_PARAMETER = 0x80041008, + WBEM_E_NOT_AVAILABLE = 0x80041009, + WBEM_E_CRITICAL_ERROR = 0x8004100A, + WBEM_E_INVALID_STREAM = 0x8004100B, + WBEM_E_NOT_SUPPORTED = 0x8004100C, + WBEM_E_INVALID_SUPERCLASS = 0x8004100D, + WBEM_E_INVALID_NAMESPACE = 0x8004100E, + WBEM_E_INVALID_OBJECT = 0x8004100F, + WBEM_E_INVALID_CLASS = 0x80041010, + WBEM_E_PROVIDER_NOT_FOUND = 0x80041011, + WBEM_E_INVALID_PROVIDER_REGISTRATION = 0x80041012, + WBEM_E_PROVIDER_LOAD_FAILURE = 0x80041013, + WBEM_E_INITIALIZATION_FAILURE = 0x80041014, + WBEM_E_TRANSPORT_FAILURE = 0x80041015, + WBEM_E_INVALID_OPERATION = 0x80041016, + WBEM_E_INVALID_QUERY = 0x80041017, + WBEM_E_INVALID_QUERY_TYPE = 0x80041018, + WBEM_E_ALREADY_EXISTS = 0x80041019, + WBEM_E_OVERRIDE_NOT_ALLOWED = 0x8004101A, + WBEM_E_PROPAGATED_QUALIFIER = 0x8004101B, + WBEM_E_PROPAGATED_PROPERTY = 0x8004101C, + WBEM_E_UNEXPECTED = 0x8004101D, + WBEM_E_ILLEGAL_OPERATION = 0x8004101E, + WBEM_E_CANNOT_BE_KEY = 0x8004101F, + WBEM_E_INCOMPLETE_CLASS = 0x80041020, + WBEM_E_INVALID_SYNTAX = 0x80041021, + WBEM_E_NONDECORATED_OBJECT = 0x80041022, + WBEM_E_READ_ONLY = 0x80041023, + WBEM_E_PROVIDER_NOT_CAPABLE = 0x80041024, + WBEM_E_CLASS_HAS_CHILDREN = 0x80041025, + WBEM_E_CLASS_HAS_INSTANCES = 0x80041026, + WBEM_E_QUERY_NOT_IMPLEMENTED = 0x80041027, + WBEM_E_ILLEGAL_NULL = 0x80041028, + WBEM_E_INVALID_QUALIFIER_TYPE = 0x80041029, + WBEM_E_INVALID_PROPERTY_TYPE = 0x8004102A, + WBEM_E_VALUE_OUT_OF_RANGE = 0x8004102B, + WBEM_E_CANNOT_BE_SINGLETON = 0x8004102C, + WBEM_E_INVALID_CIM_TYPE = 0x8004102D, + WBEM_E_INVALID_METHOD = 0x8004102E, + WBEM_E_INVALID_METHOD_PARAMETERS = 0x8004102F, + WBEM_E_SYSTEM_PROPERTY = 0x80041030, + WBEM_E_INVALID_PROPERTY = 0x80041031, + WBEM_E_CALL_CANCELLED = 0x80041032, + WBEM_E_SHUTTING_DOWN = 0x80041033, + WBEM_E_PROPAGATED_METHOD = 0x80041034, + WBEM_E_UNSUPPORTED_PARAMETER = 0x80041035, + WBEM_E_MISSING_PARAMETER_ID = 0x80041036, + WBEM_E_INVALID_PARAMETER_ID = 0x80041037, + WBEM_E_NONCONSECUTIVE_PARAMETER_IDS = 0x80041038, + WBEM_E_PARAMETER_ID_ON_RETVAL = 0x80041039, + WBEM_E_INVALID_OBJECT_PATH = 0x8004103A, + WBEM_E_OUT_OF_DISK_SPACE = 0x8004103B, + WBEM_E_BUFFER_TOO_SMALL = 0x8004103C, + WBEM_E_UNSUPPORTED_PUT_EXTENSION = 0x8004103D, + WBEM_E_UNKNOWN_OBJECT_TYPE = 0x8004103E, + WBEM_E_UNKNOWN_PACKET_TYPE = 0x8004103F, + WBEM_E_MARSHAL_VERSION_MISMATCH = 0x80041040, + WBEM_E_MARSHAL_INVALID_SIGNATURE = 0x80041041, + WBEM_E_INVALID_QUALIFIER = 0x80041042, + WBEM_E_INVALID_DUPLICATE_PARAMETER = 0x80041043, + WBEM_E_TOO_MUCH_DATA = 0x80041044, + WBEM_E_SERVER_TOO_BUSY = 0x80041045, + WBEM_E_INVALID_FLAVOR = 0x80041046, + WBEM_E_CIRCULAR_REFERENCE = 0x80041047, + WBEM_E_UNSUPPORTED_CLASS_UPDATE = 0x80041048, + WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE = 0x80041049, + WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE = 0x80041050, + WBEM_E_TOO_MANY_PROPERTIES = 0x80041051, + WBEM_E_UPDATE_TYPE_MISMATCH = 0x80041052, + WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED = 0x80041053, + WBEM_E_UPDATE_PROPAGATED_METHOD = 0x80041054, + WBEM_E_METHOD_NOT_IMPLEMENTED = 0x80041055, + WBEM_E_METHOD_DISABLED = 0x80041056, + WBEM_E_REFRESHER_BUSY = 0x80041057, + WBEM_E_UNPARSABLE_QUERY = 0x80041058, + WBEM_E_NOT_EVENT_CLASS = 0x80041059, + WBEM_E_MISSING_GROUP_WITHIN = 0x8004105A, + WBEM_E_MISSING_AGGREGATION_LIST = 0x8004105B, + WBEM_E_PROPERTY_NOT_AN_OBJECT = 0x8004105C, + WBEM_E_AGGREGATING_BY_OBJECT = 0x8004105D, + WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY = 0x8004105F, + WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING = 0x80041060, + WBEM_E_QUEUE_OVERFLOW = 0x80041061, + WBEM_E_PRIVILEGE_NOT_HELD = 0x80041062, + WBEM_E_INVALID_OPERATOR = 0x80041063, + WBEM_E_LOCAL_CREDENTIALS = 0x80041064, + WBEM_E_CANNOT_BE_ABSTRACT = 0x80041065, + WBEM_E_AMENDED_OBJECT = 0x80041066, + WBEM_E_CLIENT_TOO_SLOW = 0x80041067, + WBEM_E_NULL_SECURITY_DESCRIPTOR = 0x80041068, + WBEM_E_TIMED_OUT = 0x80041069, + WBEM_E_INVALID_ASSOCIATION = 0x8004106A, + WBEM_E_AMBIGUOUS_OPERATION = 0x8004106B, + WBEM_E_QUOTA_VIOLATION = 0x8004106C, + WBEM_E_RESERVED_001 = 0x8004106D, + WBEM_E_RESERVED_002 = 0x8004106E, + WBEM_E_UNSUPPORTED_LOCALE = 0x8004106F, + WBEM_E_HANDLE_OUT_OF_DATE = 0x80041070, + WBEM_E_CONNECTION_FAILED = 0x80041071, + WBEM_E_INVALID_HANDLE_REQUEST = 0x80041072, + WBEM_E_PROPERTY_NAME_TOO_WIDE = 0x80041073, + WBEM_E_CLASS_NAME_TOO_WIDE = 0x80041074, + WBEM_E_METHOD_NAME_TOO_WIDE = 0x80041075, + WBEM_E_QUALIFIER_NAME_TOO_WIDE = 0x80041076, + WBEM_E_RERUN_COMMAND = 0x80041077, + WBEM_E_DATABASE_VER_MISMATCH = 0x80041078, + WBEM_E_VETO_DELETE = 0x80041079, + WBEM_E_VETO_PUT = 0x8004107A, + WBEM_E_INVALID_LOCALE = 0x80041080, + WBEM_E_PROVIDER_SUSPENDED = 0x80041081, + WBEM_E_SYNCHRONIZATION_REQUIRED = 0x80041082, + WBEM_E_NO_SCHEMA = 0x80041083, + WBEM_E_PROVIDER_ALREADY_REGISTERED = 0x80041084, + WBEM_E_PROVIDER_NOT_REGISTERED = 0x80041085, + WBEM_E_FATAL_TRANSPORT_ERROR = 0x80041086, + WBEM_E_ENCRYPTED_CONNECTION_REQUIRED = 0x80041087, + WBEM_E_PROVIDER_TIMED_OUT = 0x80041088, + WBEM_E_NO_KEY = 0x80041089, + WBEM_E_PROVIDER_DISABLED = 0x8004108a + } WBEMSTATUS; + + typedef [public,noprint] enum + { + WBEM_FLAG_RETURN_WBEM_COMPLETE = 0, + WBEM_FLAG_BIDIRECTIONAL = 0, + WBEM_FLAG_RETURN_IMMEDIATELY = 0x000010, + WBEM_FLAG_FORWARD_ONLY = 0x000020, + WBEM_FLAG_NO_ERROR_OBJECT = 0x000040, + WBEM_FLAG_SEND_STATUS = 0x000080, + WBEM_FLAG_ENSURE_LOCATABLE = 0x000100, + WBEM_FLAG_DIRECT_READ = 0x000200, + WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x020000, + WBEM_FLAG_STRONG_VALIDATION = 0x100000, + WBEM_FLAG_RETURN_ERROR_OBJECT = 0, + WBEM_FLAG_DONT_SEND_STATUS = 0, + WBEM_FLAG_SEND_ONLY_SELECTED = 0, + + WBEM_RETURN_WHEN_COMPLETE = 0, + WBEM_RETURN_IMMEDIATELY = WBEM_FLAG_RETURN_IMMEDIATELY, + + WBEM_MASK_RESERVED_FLAGS = 0x001F000 + } WBEM_GENERIC_FLAG_TYPE; + + typedef [public,noprint,v1_enum] enum tag_WBEM_TIMEOUT_TYPE + { + WBEM_NO_WAIT = 0, + WBEM_INFINITE = 0xFFFFFFFF + } WBEM_TIMEOUT_TYPE; + + typedef [public,v1_enum] enum + { + CIM_EMPTY = 0, + CIM_SINT16 = 2, + CIM_SINT32 = 3, + CIM_REAL32 = 4, + CIM_REAL64 = 5, + CIM_STRING = 8, + + CIM_BOOLEAN = 11, + CIM_OBJECT = 13, + CIM_SINT8 = 16, + CIM_UINT8 = 17, + CIM_UINT16 = 18, + CIM_UINT32 = 19, + CIM_SINT64 = 20, + CIM_UINT64 = 21, + CIM_DATETIME = 101, + CIM_REFERENCE = 102, + CIM_CHAR16 = 103, + + CIM_FLAG_ARRAY = 0x2000, + CIM_ILLEGAL = 0x0fff, + CIM_TYPEMASK = 0x2fff, + + CIM_ARR_SINT8 = CIM_FLAG_ARRAY | CIM_SINT8, + CIM_ARR_UINT8 = CIM_FLAG_ARRAY | CIM_UINT8, + CIM_ARR_SINT16 = CIM_FLAG_ARRAY | CIM_SINT16, + CIM_ARR_UINT16 = CIM_FLAG_ARRAY | CIM_UINT16, + CIM_ARR_SINT32 = CIM_FLAG_ARRAY | CIM_SINT32, + CIM_ARR_UINT32 = CIM_FLAG_ARRAY | CIM_UINT32, + CIM_ARR_SINT64 = CIM_FLAG_ARRAY | CIM_SINT64, + CIM_ARR_UINT64 = CIM_FLAG_ARRAY | CIM_UINT64, + CIM_ARR_REAL32 = CIM_FLAG_ARRAY | CIM_REAL32, + CIM_ARR_REAL64 = CIM_FLAG_ARRAY | CIM_REAL64, + CIM_ARR_BOOLEAN = CIM_FLAG_ARRAY | CIM_BOOLEAN, + CIM_ARR_STRING = CIM_FLAG_ARRAY | CIM_STRING, + CIM_ARR_DATETIME = CIM_FLAG_ARRAY | CIM_DATETIME, + CIM_ARR_REFERENCE = CIM_FLAG_ARRAY | CIM_REFERENCE, + CIM_ARR_CHAR16 = CIM_FLAG_ARRAY | CIM_CHAR16, + CIM_ARR_OBJECT = CIM_FLAG_ARRAY | CIM_OBJECT + + } CIMTYPE_ENUMERATION; + + typedef [public,bitmap8bit] bitmap + { + WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE = 0x1, + WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS = 0x2, +// WBEM_FLAVOR_MASK_PROPAGATION = 0x0F, + + WBEM_FLAVOR_NOT_OVERRIDABLE = 0x10, +// WBEM_FLAVOR_MASK_PERMISSIONS = 0x10, + + WBEM_FLAVOR_ORIGIN_PROPAGATED = 0x20, + WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40, +// WBEM_FLAVOR_MASK_ORIGIN = 0x60, + + WBEM_FLAVOR_AMENDED = 0x80 +// WBEM_FLAVOR_MASK_AMENDED = 0x80 + + } WBEM_FLAVOR_TYPE; + + typedef [public,bitmap8bit] bitmap + { + WCF_DECORATIONS = 1, + WCF_INSTANCE = 2, + WCF_CLASS = 4, + WCF_CLASS_PART_INTERNAL = 8 + // WCF_CLASS_PART_SHARED = 0x104 + } WCO_FLAGS; + + typedef [public,nopull,nopush] struct + { + uint32 count; + [ref,charset(UTF16)] uint16 *item[count]; + } CIMSTRINGS; + + typedef [public,bitmap8bit] bitmap { + DEFAULT_FLAG_EMPTY = 1, + DEFAULT_FLAG_INHERITED = 2 + } DEFAULT_FLAGS; + + WERROR OpenNamespace( + [in] BSTR strNamespace, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemServices** ppWorkingNamespace, + [out, in, unique] IWbemCallResult** ppResult + ); + + WERROR CancelAsyncCall( + [in] IWbemObjectSink* pSink + ); + + WERROR QueryObjectSink( + [in] long lFlags, + [out] IWbemObjectSink** ppResponseHandler + ); + + WERROR GetObject( + [in] BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemClassObject** ppObject, + [out, in, unique] IWbemCallResult** ppCallResult + ); + + + WERROR GetObjectAsync( + [in] BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR PutClass( + [in] IWbemClassObject* pObject, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemCallResult** ppCallResult + ); + + WERROR PutClassAsync( + [in] IWbemClassObject* pObject, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR DeleteClass( + [in] BSTR strClass, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemCallResult** ppCallResult + ); + + WERROR DeleteClassAsync( + [in] BSTR strClass, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR CreateClassEnum( + [in] BSTR strSuperclass, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR CreateClassEnumAsync( + [in] BSTR strSuperclass, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR PutInstance( + [in] IWbemClassObject* pInst, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemCallResult** ppCallResult + ); + + WERROR PutInstanceAsync( + [in] IWbemClassObject* pInst, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + + WERROR DeleteInstance( + [in] BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemCallResult** ppCallResult + ); + + + WERROR DeleteInstanceAsync( + [in] BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + + WERROR CreateInstanceEnum( + [in] BSTR strFilter, // allow more things than a class name + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR CreateInstanceEnumAsync( + [in] BSTR strSuperClass, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR ExecQuery( + [in] BSTR strQueryLanguage, + [in] BSTR strQuery, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR ExecQueryAsync( + [in] BSTR strQueryLanguage, + [in] BSTR strQuery, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR ExecNotificationQuery( + [in] BSTR strQueryLanguage, + [in] BSTR strQuery, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR ExecNotificationQueryAsync( + [in] BSTR strQueryLanguage, + [in] BSTR strQuery, + [in] long lFlags, + [in] IWbemContext* pCtx, + [in] IWbemObjectSink* pResponseHandler + ); + + WERROR ExecMethod( + [in] BSTR strObjectPath, + [in] BSTR strMethodName, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [in,unique] IWbemClassObject* pInParams, + [in,out,unique] IWbemClassObject** ppOutParams, + [in,out,unique] IWbemCallResult** ppCallResult + ); + + WERROR ExecMethodAsync( + [in] BSTR strObjectPath, + [in] BSTR strMethodName, + [in] uint32 lFlags, + [in] IWbemContext* pCtx, + [in] IWbemClassObject* pInParams, + [in] IWbemObjectSink* pResponseHandler + ); +} + +[ + object, + uuid(027947e1-d731-11ce-a357-000000000001), + pointer_default(unique) +] interface IEnumWbemClassObject : IUnknown +{ + WERROR Reset(); + + [call_as(Next)] WERROR IEnumWbemClassObject_Next( + [in] int32 lTimeout, + [in] uint32 uCount, + [out, size_is(uCount), length_is(*puReturned)] IWbemClassObject** apObjects, + [out] uint32* puReturned + ); + + WERROR NextAsync( + [in] uint32 uCount, + [in] IWbemObjectSink* pSink + ); + + WERROR IEnumWbemClassObject_Clone( + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR Skip( + [in] int32 lTimeout, + [in] uint32 nCount + ); +}; + +[ + object, + local, + uuid("44aca674-e8fc-11d0-a07c-00c04fb68820"), + pointer_default(unique) +] interface IWbemContext : IUnknown +{ + WERROR Clone([out] IWbemContext** ppNewCopy); + + WERROR GetNames( +// [in] long lFlags, +// [out] SAFEARRAY (BSTR)* pNames + ); + + WERROR BeginEnumeration([in] long lFlags); + + WERROR Next( +// [in] long lFlags, +// [out] BSTR* pstrName, +// [out] VARIANT* pValue + ); + + WERROR EndEnumeration(); + + + WERROR SetValue( +// [in, string] LPCWSTR wszName, +// [in] long lFlags +// [in] VARIANT* pValue + ); + + WERROR GetValue( +// [in, string] LPCWSTR wszName, +// [in] long lFlags, +// [out] VARIANT* pValue + ); + + WERROR DeleteValue( +// [in, string] LPCWSTR wszName, +// [in] long lFlags + ); + + WERROR DeleteAll(); +} + +[ + object, + uuid("F309AD18-D86A-11d0-A075-00C04FB68820"), + pointer_default(unique) +] interface IWbemLevel1Login : IUnknown +{ + WERROR EstablishPosition( + [in, unique, string, charset(UTF16)] uint16* wszLocaleList, + [in] DWORD dwNumLocales, + [out] DWORD* reserved + ); + WERROR RequestChallenge( + [in, unique, string, charset(UTF16)] uint16* wszNetworkResource, + [in, unique, string, charset(UTF16)] uint16* wszUser, + [out, size_is(16), length_is(16)] uint8 * Nonce + ); + WERROR WBEMLogin( + [in, unique, string, charset(UTF16)] uint16* wszPreferredLocale, + [in, size_is(16), length_is(16), unique] uint8 * AccessToken, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out] IWbemServices** ppNamespace + ); + + + WERROR NTLMLogin( + [in,unique,string,charset(UTF16)] uint16 *wszNetworkResource, + [in,unique,string,charset(UTF16)] uint16 *wszPreferredLocale, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out,ref] IWbemServices** ppNamespace + ); + +} + +[ + object, + uuid("423ec01e-2e35-11d2-b604-00104b703efd"), + pointer_default(unique) +] interface IWbemWCOSmartEnum : IUnknown +{ + typedef struct { + uint32 size; + char data[size]; + } WBEMDATA; + + typedef enum { + WTYPE_SCHEMA = 1, + WTYPE_CLASS = 2, + WTYPE_OBJECT = 3 + } WTYPES; + + typedef [relative_base] struct { + // [relative] WBEMDATA4 *data; /* 0x9 */ + uint32 data_size; + uint8 wtype; + } WBEMDATA4; + + typedef [relative_base] struct { + [relative] WBEMDATA4 *data; /* 0x9 */ + uint32 data_size; + uint8 wtype; + } WBEMDATA3; + + typedef [relative_base] struct { + [relative,size_is(obj_num)] WBEMDATA3 *data; /* 0x8 */ + uint32 data_size; + uint32 obj_num; + } WBEMDATA2; + + typedef [relative_base] struct { + [relative] WBEMDATA2 *data; /* 0x8 */ + uint32 data_size; + } WBEMDATA1; + + typedef [relative_base] struct { + uint32 u1_0; /* 0 */ + hyper signature; /* 'WBEMDATA' */ + [relative] WBEMDATA1 *data; /* 0x1A */ + uint32 data_size; + uint32 u2_0; /* 0 */ + uint8 ver_major; /* 1 */ + uint8 ver_minor; /* 0 - Win2000, 1 - WinXP/2003 */ + } WBEMDATA0; + + WERROR IWbemWCOSmartEnum_Next( + [in,ref] GUID *gEWCO, + [in] uint32 lTimeOut, + [in] uint32 uCount, + [in] uint32 unknown, + [in,ref] GUID *gWCO, + [out,ref] uint32 *puReturned, + [out,ref] uint32 *pSize, + [out,ref,noprint,size_is(,*pSize)] uint8 **pData + ); +} + +[ + object, + uuid("1c1c45ee-4395-11d2-b60b-00104b703efd"), + pointer_default(unique) +] interface IWbemFetchSmartEnum : IUnknown +{ + WERROR Fetch([out] IWbemWCOSmartEnum** ppEnum); + WERROR Test([out] IWbemClassObject** ppEnum); +} + +[ + object, + // restricted, + uuid(44aca675-e8fc-11d0-a07c-00c04fb68820) +] interface IWbemCallResult : IUnknown +{ + WERROR GetResultObject( + [in] long lTimeout, + [out] IWbemClassObject** ppResultObject + ); + + WERROR GetResultString( + [in] long lTimeout, + [out] BSTR* pstrResultString + ); + + WERROR GetResultServices( + [in] long lTimeout, + [out] IWbemServices** ppServices + ); + + WERROR GetCallStatus( + [in] long lTimeout, + [out] long* plStatus + ); +} + + +[ + object, + restricted, + uuid(7c857801-7381-11cf-884d-00aa004b2e24) +] +interface IWbemObjectSink : IUnknown +{ + WERROR SetStatus( + [in] long lFlags, + [in] WERROR hResult, + [in] BSTR strParam, + [in] IWbemClassObject* pObjParam + ); + WERROR Indicate( + [in] long lObjectCount, + [in, size_is(lObjectCount)] IWbemClassObject** apObjArray + ); +}; + diff --git a/source4/librpc/idl/wzcsvc.idl b/librpc/idl/wzcsvc.idl similarity index 100% rename from source4/librpc/idl/wzcsvc.idl rename to librpc/idl/wzcsvc.idl diff --git a/source4/librpc/idl/xattr.idl b/librpc/idl/xattr.idl similarity index 95% rename from source4/librpc/idl/xattr.idl rename to librpc/idl/xattr.idl index ba0123aed0..c1af4791ae 100644 --- a/source4/librpc/idl/xattr.idl +++ b/librpc/idl/xattr.idl @@ -75,6 +75,12 @@ interface xattr [size_is(num_eas)] xattr_EA *eas; } xattr_DosEAs; + /* Slightly different version, used by the vfs_xattr_tdb module */ + typedef [public] struct { + uint32 num_eas; + xattr_EA eas[num_eas]; + } tdb_xattrs; + /* we store stream information in this xattr structure. Then the streams themselves are stored in user.DosStream.STREAMNAME or in external files, according diff --git a/source4/librpc/ndr.pc.in b/librpc/ndr.pc.in similarity index 100% rename from source4/librpc/ndr.pc.in rename to librpc/ndr.pc.in diff --git a/source4/librpc/ndr/libndr.h b/librpc/ndr/libndr.h similarity index 95% rename from source4/librpc/ndr/libndr.h rename to librpc/ndr/libndr.h index b719be2bab..63b89e17f4 100644 --- a/source4/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -26,9 +26,11 @@ #define __LIBNDR_H__ #include -#include "lib/util/util.h" /* for discard_const */ #include +#if _SAMBA_BUILD_ == 4 +#include "../lib/util/util.h" /* for discard_const */ #include "lib/charset/charset.h" +#endif /* this provides definitions for the libcli/rpc/ MSRPC library @@ -152,6 +154,14 @@ struct ndr_print { #define NDR_PRINT_OUT_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_OUT, p) #define NDR_PRINT_IN_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_IN | NDR_SET_VALUES, p) +/* useful macro for debugging in strings */ +#define NDR_PRINT_STRUCT_STRING(ctx, type, p) ndr_print_struct_string(ctx, (ndr_print_fn_t)ndr_print_ ##type, #p, p) +#define NDR_PRINT_UNION_STRING(ctx, type, level, p) ndr_print_union_string(ctx, (ndr_print_fn_t)ndr_print_ ##type, #p, level, p) +#define NDR_PRINT_FUNCTION_STRING(ctx, type, flags, p) ndr_print_function_string(ctx, (ndr_print_function_t)ndr_print_ ##type, #type, flags, p) +#define NDR_PRINT_BOTH_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_BOTH, p) +#define NDR_PRINT_OUT_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_OUT, p) +#define NDR_PRINT_IN_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_IN | NDR_SET_VALUES, p) + #define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) enum ndr_err_code { @@ -292,7 +302,9 @@ typedef enum ndr_err_code (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flag typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, const void *); typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, const void *); +#if _SAMBA_BUILD_ == 4 #include "libcli/util/error.h" +#endif #include "librpc/gen_ndr/misc.h" extern const struct ndr_syntax_id ndr_transfer_syntax; @@ -342,6 +354,7 @@ void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct do size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags); void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip); void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); +bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2); enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn); enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, void *p, uint32_t level, ndr_push_flags_fn_t fn); size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push); diff --git a/source4/librpc/ndr/ndr.c b/librpc/ndr/ndr.c similarity index 98% rename from source4/librpc/ndr/ndr.c rename to librpc/ndr/ndr.c index c5e4c44794..2f1daeaeb5 100644 --- a/source4/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -28,9 +28,10 @@ #include "includes.h" #include "librpc/ndr/libndr.h" -#include "lib/util/dlinklist.h" -#include "librpc/gen_ndr/dcerpc.h" +#include "../lib/util/dlinklist.h" +#if _SAMBA_BUILD_ == 4 #include "param/param.h" +#endif #define NDR_BASE_MARSHALL_SIZE 1024 @@ -163,16 +164,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_ return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) +_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) { va_list ap; char *s = NULL; - int i; + int i, ret; va_start(ap, format); - vasprintf(&s, format, ap); + ret = vasprintf(&s, format, ap); va_end(ap); + if (ret == -1) { + return; + } + for (i=0;idepth;i++) { DEBUGADD(0,(" ")); } @@ -350,12 +355,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, { char *s=NULL; va_list ap; + int ret; va_start(ap, format); - vasprintf(&s, format, ap); + ret = vasprintf(&s, format, ap); va_end(ap); - DEBUG(3,("ndr_pull_error(%u): %s\n", ndr_err, s)); + if (ret == -1) { + return NDR_ERR_ALLOC; + } + + DEBUG(1,("ndr_pull_error(%u): %s\n", ndr_err, s)); free(s); @@ -367,16 +377,21 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, */ _PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr, enum ndr_err_code ndr_err, - const char *format, ...) + const char *format, ...) { char *s=NULL; va_list ap; + int ret; va_start(ap, format); - vasprintf(&s, format, ap); + ret = vasprintf(&s, format, ap); va_end(ap); - DEBUG(3,("ndr_push_error(%u): %s\n", ndr_err, s)); + if (ret == -1) { + return NDR_ERR_ALLOC; + } + + DEBUG(1,("ndr_push_error(%u): %s\n", ndr_err, s)); free(s); diff --git a/source4/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c similarity index 100% rename from source4/librpc/ndr/ndr_basic.c rename to librpc/ndr/ndr_basic.c diff --git a/source4/librpc/ndr/ndr_compression.c b/librpc/ndr/ndr_compression.c similarity index 98% rename from source4/librpc/ndr/ndr_compression.c rename to librpc/ndr/ndr_compression.c index 92c5b049df..c73c3bb6fa 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/librpc/ndr/ndr_compression.c @@ -21,9 +21,9 @@ */ #include "includes.h" -#include "lib/compression/lzxpress.h" +#include "../lib/compression/lzxpress.h" #include "librpc/ndr/libndr.h" -#include "librpc/ndr/ndr_compression.h" +#include "../librpc/ndr/ndr_compression.h" #include static voidpf ndr_zlib_alloc(voidpf opaque, uInt items, uInt size) @@ -260,7 +260,9 @@ static enum ndr_err_code ndr_push_compression_mszip_chunk(struct ndr_push *ndrpu ndrpush->offset = tmp_offset; DEBUG(9,("MSZIP comp plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", - plain_chunk.length, plain_chunk.length, comp_chunk_size, comp_chunk_size)); + (unsigned int)plain_chunk.length, + (unsigned int)plain_chunk.length, + comp_chunk_size, comp_chunk_size)); ndrpush->offset += comp_chunk_size; return NDR_ERR_SUCCESS; @@ -307,7 +309,7 @@ static enum ndr_err_code ndr_pull_compression_xpress_chunk(struct ndr_pull *ndrp if (ret < 0) { return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, "XPRESS lzxpress_decompress() returned %d\n", - ret); + (int)ret); } plain_chunk.length = ret; @@ -361,7 +363,7 @@ static enum ndr_err_code ndr_push_compression_xpress_chunk(struct ndr_push *ndrp if (ret < 0) { return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, "XPRESS lzxpress_compress() returned %d\n", - ret); + (int)ret); } comp_chunk.length = ret; diff --git a/source3/librpc/ndr/ndr_compression.h b/librpc/ndr/ndr_compression.h similarity index 78% rename from source3/librpc/ndr/ndr_compression.h rename to librpc/ndr/ndr_compression.h index 4cebbe190c..b939f6a42b 100644 --- a/source3/librpc/ndr/ndr_compression.h +++ b/librpc/ndr/ndr_compression.h @@ -5,25 +5,9 @@ #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) /* This file was automatically generated by mkproto.pl. DO NOT EDIT */ -#ifndef _PUBLIC_ -#define _PUBLIC_ -#endif - -#ifndef _PURE_ -#define _PURE_ -#endif - -#ifndef _NORETURN_ -#define _NORETURN_ -#endif - -#ifndef _DEPRECATED_ -#define _DEPRECATED_ -#endif - -#ifndef _WARN_UNUSED_RESULT_ -#define _WARN_UNUSED_RESULT_ -#endif +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ /* The following definitions come from librpc/ndr/ndr_compression.c */ @@ -37,11 +21,11 @@ enum ndr_err_code ndr_pull_compression_end(struct ndr_pull *subndr, enum ndr_compression_alg compression_alg, ssize_t decompressed_len); enum ndr_err_code ndr_push_compression_start(struct ndr_push *subndr, - struct ndr_push **_comndr, + struct ndr_push **_uncomndr, enum ndr_compression_alg compression_alg, ssize_t decompressed_len); enum ndr_err_code ndr_push_compression_end(struct ndr_push *subndr, - struct ndr_push *comndr, + struct ndr_push *uncomndr, enum ndr_compression_alg compression_alg, ssize_t decompressed_len); #undef _PRINTF_ATTRIBUTE diff --git a/source4/libcli/drsblobs.c b/librpc/ndr/ndr_drsblobs.c similarity index 82% rename from source4/libcli/drsblobs.c rename to librpc/ndr/ndr_drsblobs.c index 126f2ccc40..aecb0c3b16 100644 --- a/source4/libcli/drsblobs.c +++ b/librpc/ndr/ndr_drsblobs.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "libcli/drsblobs.h" +#include "librpc/gen_ndr/ndr_drsblobs.h" /* parser auto-generated by pidl, then hand-modified by abartlet */ @@ -176,4 +176,38 @@ _PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *na ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r) +{ + if (ndr_flags & NDR_SCALARS) { + uint32_t offset; + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 8); + + offset = ndr->offset; + ndr->offset = ndr->data_size - 8; + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size)); + + ndr->offset = offset; + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512)); + { + struct ndr_pull *_ndr_outgoing; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size)); + NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size)); + } + { + struct ndr_pull *_ndr_incoming; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size)); + NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size)); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} diff --git a/source4/librpc/ndr/ndr_drsuapi.c b/librpc/ndr/ndr_drsuapi.c similarity index 98% rename from source4/librpc/ndr/ndr_drsuapi.c rename to librpc/ndr/ndr_drsuapi.c index e77ab54071..4d1ae8b163 100644 --- a/source4/librpc/ndr/ndr_drsuapi.c +++ b/librpc/ndr/ndr_drsuapi.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. routines for printing some linked list structs in DRSUAPI @@ -9,12 +9,12 @@ 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 . */ @@ -23,10 +23,12 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_misc.h" -#include "lib/util/asn1.h" +#include "../lib/util/asn1.h" #include "librpc/ndr/ndr_compression.h" +/* We don't need multibyte if we're just comparing to 'ff' */ +#undef strncasecmp -void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, +void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaObjectListItem *r) { ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItem"); @@ -92,7 +94,7 @@ enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_fl DATA_BLOB blob; if (strncasecmp("ff", r->oid, 2) == 0) { - blob = strhex_to_data_blob(r->oid); + blob = strhex_to_data_blob(ndr, r->oid); if (!blob.data) { return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "HEX String Conversion Error: %s\n", @@ -101,7 +103,6 @@ enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_fl } else { _OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid)); } - talloc_steal(ndr, blob.data); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length)); NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length)); @@ -165,7 +166,7 @@ size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags) if (!oid) return 0; if (strncasecmp("ff", oid, 2) == 0) { - _blob = strhex_to_data_blob(oid); + _blob = strhex_to_data_blob(NULL, oid); if (_blob.data) { ret = _blob.length; } diff --git a/source4/librpc/ndr/ndr_drsuapi.h b/librpc/ndr/ndr_drsuapi.h similarity index 97% rename from source4/librpc/ndr/ndr_drsuapi.h rename to librpc/ndr/ndr_drsuapi.h index c663eadd7a..12c2c78bde 100644 --- a/source4/librpc/ndr/ndr_drsuapi.h +++ b/librpc/ndr/ndr_drsuapi.h @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. routines for printing some linked list structs in DRSUAPI @@ -9,12 +9,12 @@ 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 . */ @@ -22,7 +22,7 @@ #ifndef _LIBRPC_NDR_NDR_DRSUAPI_H #define _LIBRPC_NDR_NDR_DRSUAPI_H -void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, +void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaObjectListItem *r); void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, diff --git a/source4/librpc/ndr/ndr_krb5pac.c b/librpc/ndr/ndr_krb5pac.c similarity index 100% rename from source4/librpc/ndr/ndr_krb5pac.c rename to librpc/ndr/ndr_krb5pac.c diff --git a/source4/librpc/ndr/ndr_misc.c b/librpc/ndr/ndr_misc.c similarity index 84% rename from source4/librpc/ndr/ndr_misc.c rename to librpc/ndr/ndr_misc.c index be7dab93d2..c4a1adb3ea 100644 --- a/source4/librpc/ndr/ndr_misc.c +++ b/librpc/ndr/ndr_misc.c @@ -24,17 +24,14 @@ #include "system/network.h" #include "librpc/ndr/libndr.h" -_PUBLIC_ void ndr_print_in_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip) -{ - struct in_addr ip; - - ip.s_addr = htonl(_ip->s_addr); - - ndr->print(ndr, "%-25s: %s", name, inet_ntoa(ip)); -} - _PUBLIC_ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); } +bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, + const struct ndr_syntax_id *i2) +{ + return GUID_equal(&i1->uuid, &i2->uuid) + && (i1->if_version == i2->if_version); +} diff --git a/source4/librpc/ndr/ndr_orpc.c b/librpc/ndr/ndr_orpc.c similarity index 100% rename from source4/librpc/ndr/ndr_orpc.c rename to librpc/ndr/ndr_orpc.c diff --git a/source4/librpc/ndr/ndr_table.c b/librpc/ndr/ndr_table.c similarity index 97% rename from source4/librpc/ndr/ndr_table.c rename to librpc/ndr/ndr_table.c index d73e82bb71..7ca04173f7 100644 --- a/source4/librpc/ndr/ndr_table.c +++ b/librpc/ndr/ndr_table.c @@ -21,9 +21,10 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/ndr/libndr.h" #include "librpc/ndr/ndr_table.h" +#undef strcasecmp static struct ndr_interface_list *ndr_interfaces; @@ -119,8 +120,6 @@ const struct ndr_interface_list *ndr_table_list(void) } -NTSTATUS ndr_table_register_builtin_tables(void); - NTSTATUS ndr_table_init(void) { static bool initialized = false; diff --git a/librpc/ndr/ndr_table.h b/librpc/ndr/ndr_table.h new file mode 100644 index 0000000000..9e8fea1db6 --- /dev/null +++ b/librpc/ndr/ndr_table.h @@ -0,0 +1,14 @@ +#ifndef _NDR_TABLE_PROTO_H_ +#define _NDR_TABLE_PROTO_H_ + +NTSTATUS ndr_table_register(const struct ndr_interface_table *table); +const char *ndr_interface_name(const struct GUID *uuid, uint32_t if_version); +int ndr_interface_num_calls(const struct GUID *uuid, uint32_t if_version); +const struct ndr_interface_table *ndr_table_by_name(const char *name); +const struct ndr_interface_table *ndr_table_by_uuid(const struct GUID *uuid); +const struct ndr_interface_list *ndr_table_list(void); +NTSTATUS ndr_table_init(void); +NTSTATUS ndr_table_register_builtin_tables(void); + +#endif /* _NDR_TABLE_PROTO_H_ */ + diff --git a/librpc/ndr/ndr_wmi.c b/librpc/ndr/ndr_wmi.c new file mode 100644 index 0000000000..2c122decf4 --- /dev/null +++ b/librpc/ndr/ndr_wmi.c @@ -0,0 +1,60 @@ +/* + Unix SMB/CIFS implementation. + + routines for marshalling/unmarshalling DCOM string arrays + + Copyright (C) Jelmer Vernooij 2004 + + 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. +*/ +//#define NDR_CHECK_DEBUG +#include "includes.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/gen_ndr/ndr_wmi.h" +#include "librpc/ndr/ndr_wmi.h" + +// Just for debugging +int NDR_CHECK_depth = 0; +int NDR_CHECK_shift = 0x18; + +enum ndr_err_code ndr_push_BSTR(struct ndr_push *ndr, int ndr_flags, const struct BSTR *r) +{ + uint32_t len; + uint32_t flags; + enum ndr_err_code status; + len = strlen(r->data); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x72657355)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, len)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2*len)); + flags = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM | LIBNDR_FLAG_STR_SIZE4); + status = ndr_push_string(ndr, NDR_SCALARS, r->data); + ndr->flags = flags; + return status; + } + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_BSTR(struct ndr_pull *ndr, int ndr_flags, struct BSTR *r) +{ + return NDR_ERR_BAD_SWITCH; +} + +void ndr_print_BSTR(struct ndr_print *ndr, const char *name, const struct BSTR *r) +{ + ndr->print(ndr, "%-25s: BSTR(\"%s\")", name, r->data); +} diff --git a/librpc/ndr/ndr_wmi.h b/librpc/ndr/ndr_wmi.h new file mode 100644 index 0000000000..539b9e882b --- /dev/null +++ b/librpc/ndr/ndr_wmi.h @@ -0,0 +1,3 @@ +typedef const char *CIMSTRING; +enum ndr_err_code ndr_pull_CIMSTRING(struct ndr_pull *ndr, int ndr_flags, CIMSTRING *r); +enum ndr_err_code ndr_push_CIMSTRING(struct ndr_push *ndr, int ndr_flags, const CIMSTRING *r); diff --git a/source4/librpc/ndr/uuid.c b/librpc/ndr/uuid.c similarity index 100% rename from source4/librpc/ndr/uuid.c rename to librpc/ndr/uuid.c diff --git a/source4/librpc/rpc/binding.c b/librpc/rpc/binding.c similarity index 99% rename from source4/librpc/rpc/binding.c rename to librpc/rpc/binding.c index bfe62c4054..b755431034 100644 --- a/source4/librpc/rpc/binding.c +++ b/librpc/rpc/binding.c @@ -23,10 +23,10 @@ */ #include "includes.h" -#include "lib/events/events.h" -#include "librpc/gen_ndr/ndr_epmapper_c.h" -#include "librpc/gen_ndr/ndr_dcerpc.h" +#include "librpc/gen_ndr/ndr_epmapper.h" #include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/rpc/dcerpc.h" +#undef strcasecmp #define MAX_PROTSEQ 10 diff --git a/source4/librpc/tables.pl b/librpc/tables.pl similarity index 100% rename from source4/librpc/tables.pl rename to librpc/tables.pl diff --git a/source4/librpc/tools/ndrdump.1.xml b/librpc/tools/ndrdump.1.xml similarity index 100% rename from source4/librpc/tools/ndrdump.1.xml rename to librpc/tools/ndrdump.1.xml diff --git a/source4/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c similarity index 94% rename from source4/librpc/tools/ndrdump.c rename to librpc/tools/ndrdump.c index bc1436916f..69b304dc9c 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -19,12 +19,12 @@ */ #include "includes.h" -#if (_SAMBA_BUILD_ >= 4) -#include "lib/cmdline/popt_common.h" #include "system/filesys.h" #include "system/locale.h" #include "librpc/ndr/libndr.h" #include "librpc/ndr/ndr_table.h" +#if (_SAMBA_BUILD_ >= 4) +#include "lib/cmdline/popt_common.h" #include "param/param.h" #endif @@ -49,8 +49,6 @@ static const struct ndr_interface_call *find_function( return &p->calls[i]; } -#if (_SAMBA_BUILD_ >= 4) - _NORETURN_ static void show_pipes(void) { const struct ndr_interface_list *l; @@ -66,8 +64,6 @@ _NORETURN_ static void show_pipes(void) exit(1); } -#endif - _NORETURN_ static void show_functions(const struct ndr_interface_table *p) { int i; @@ -174,9 +170,8 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) { NULL } }; -#if (_SAMBA_BUILD_ >= 4) ndr_table_init(); -#else + /* Initialise samba stuff */ load_case_tables(); @@ -184,8 +179,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) dbf = x_stderr; - setup_logging(argv[0],True); -#endif + setup_logging(argv[0], true); pc = poptGetContext("ndrdump", argc, argv, long_options, 0); @@ -213,21 +207,13 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) if (!pipe_name) { poptPrintUsage(pc, stderr, 0); -#if (_SAMBA_BUILD_ >= 4) show_pipes(); -#endif exit(1); } if (plugin != NULL) { p = load_iface_from_plugin(plugin, pipe_name); } -#if (_SAMBA_BUILD_ <= 3) - else { - fprintf(stderr, "Only loading from DSO's supported in Samba 3\n"); - exit(1); - } -#else if (!p) { p = ndr_table_by_name(pipe_name); } @@ -241,7 +227,6 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) p = ndr_table_by_uuid(&uuid); } } -#endif if (!p) { printf("Unknown pipe or UUID '%s'\n", pipe_name); @@ -291,11 +276,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) exit(1); } -#if (_SAMBA_BUILD_ >= 4) - data = (uint8_t *)file_load(ctx_filename, &size, mem_ctx); -#else - data = (uint8_t *)file_load(ctx_filename, &size, 0); -#endif + data = (uint8_t *)file_load(ctx_filename, &size, 0, mem_ctx); if (!data) { perror(ctx_filename); exit(1); @@ -322,11 +303,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) } if (filename) -#if (_SAMBA_BUILD_ >= 4) - data = (uint8_t *)file_load(filename, &size, mem_ctx); -#else - data = (uint8_t *)file_load(filename, &size, 0); -#endif + data = (uint8_t *)file_load(filename, &size, 0, mem_ctx); else data = (uint8_t *)stdin_load(mem_ctx, &size); diff --git a/packaging4/README.Debian b/packaging4/README.Debian new file mode 100644 index 0000000000..2eedd7a1ec --- /dev/null +++ b/packaging4/README.Debian @@ -0,0 +1,2 @@ +Please see http://wiki.samba.org/index.php/Samba4/Debian for instructions +on building the Samba 4 Debian packages. diff --git a/packaging4/debian/README b/packaging4/debian/README deleted file mode 100644 index fb4f88e63e..0000000000 --- a/packaging4/debian/README +++ /dev/null @@ -1,30 +0,0 @@ -The Debian packaging for Samba 4 is maintained in the SVN -repository of the Debian Samba packaging team. - -(parts of this file are from their README.building) - -To build: - -: Check out the official Debian packaging: - - svn co svn://svn.debian.org/pkg-samba/branches/samba4 samba4/debian - -: Samba is not a native Debian package, so you will need to create -: an .orig.tar.gz tarball. Do something along the lines of: - - VER=$( dpkg-parsechangelog -lsamba4/debian/changelog | sed -n 's/^Version: \(.*:\|\)//p' | sed 's/-[0-9.]\+$//' ) - svn export samba4 samba-$VER - ( cd samba-$VER/source && ./autogen.sh ) - ( cd samba-$VER/source && ./script/mkversion.sh VERSION include/version.h ../../samba4/source/ ) - tar zcf samba_$VER.orig.tar.gz samba-$VER - -: With the .orig.tar.gz in place, you can now also export the debian/ -: directory: - - svn export samba4/debian samba-$VER/debian - -: Finally, build the package using whatever method you prefer: - - cd samba-$VER - debuild - diff --git a/source4/pidl/MANIFEST b/pidl/MANIFEST similarity index 100% rename from source4/pidl/MANIFEST rename to pidl/MANIFEST diff --git a/source4/pidl/META.yml b/pidl/META.yml similarity index 100% rename from source4/pidl/META.yml rename to pidl/META.yml diff --git a/source4/pidl/Makefile.PL b/pidl/Makefile.PL similarity index 100% rename from source4/pidl/Makefile.PL rename to pidl/Makefile.PL diff --git a/source4/pidl/README b/pidl/README similarity index 100% rename from source4/pidl/README rename to pidl/README diff --git a/source4/pidl/TODO b/pidl/TODO similarity index 96% rename from source4/pidl/TODO rename to pidl/TODO index bc5c49a46f..87ae0c5fd3 100644 --- a/source4/pidl/TODO +++ b/pidl/TODO @@ -1,3 +1,5 @@ +- warn when union instances don't have a discriminant + - true multiple dimension array / strings in arrays support - compatibility mode for generating MIDL-readable data: diff --git a/source4/pidl/config.m4 b/pidl/config.m4 similarity index 100% rename from source4/pidl/config.m4 rename to pidl/config.m4 diff --git a/source4/pidl/config.mk b/pidl/config.mk similarity index 88% rename from source4/pidl/config.mk rename to pidl/config.mk index 07c8647ecd..45582f5d56 100644 --- a/source4/pidl/config.mk +++ b/pidl/config.mk @@ -1,13 +1,13 @@ PIDL = $(PERL) $(pidldir)/pidl $(pidldir)/Makefile: $(pidldir)/Makefile.PL - cd $(pidldir) && $(PERL) Makefile.PL PREFIX=$(prefix) + @cd $(pidldir) && $(PERL) Makefile.PL PREFIX=$(prefix) pidl-testcov: $(pidldir)/Makefile cd $(pidldir) && cover -test installpidl:: $(pidldir)/Makefile - $(MAKE) -C $(pidldir) install_vendor VENDORPREFIX=$(prefix) \ + @$(MAKE) -C $(pidldir) install_vendor VENDORPREFIX=$(prefix) \ INSTALLVENDORLIB=$(datarootdir)/perl5 \ INSTALLVENDORBIN=$(bindir) \ INSTALLVENDORSCRIPT=$(bindir) \ diff --git a/source4/pidl/expr.yp b/pidl/expr.yp similarity index 100% rename from source4/pidl/expr.yp rename to pidl/expr.yp diff --git a/source4/pidl/idl.yp b/pidl/idl.yp similarity index 96% rename from source4/pidl/idl.yp rename to pidl/idl.yp index a0323af8ee..d557590494 100644 --- a/source4/pidl/idl.yp +++ b/pidl/idl.yp @@ -67,17 +67,24 @@ interface_names: | interface_names 'interface' identifier ';' { push(@{$_[1]}, $_[2]); $_[1] } ; -interface: property_list 'interface' identifier '{' definitions '}' optional_semicolon +interface: property_list 'interface' identifier base_interface '{' definitions '}' optional_semicolon {{ "TYPE" => "INTERFACE", "PROPERTIES" => $_[1], "NAME" => $_[3], - "DATA" => $_[5], + "BASE" => $_[4], + "DATA" => $_[6], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; +base_interface: + #empty + | ':' identifier { $_[2] } +; + + cpp_quote: 'cpp_quote' '(' text ')' {{ "TYPE" => "CPP_QUOTE", @@ -269,11 +276,16 @@ element_list1: | element_list1 base_element ';' { push(@{$_[1]}, $_[2]); $_[1] } ; +optional_const: + #empty + | 'const' +; + element_list2: #empty | 'void' - | base_element { [ $_[1] ] } - | element_list2 ',' base_element { push(@{$_[1]}, $_[3]); $_[1] } + | optional_const base_element { [ $_[2] ] } + | element_list2 ',' optional_const base_element { push(@{$_[1]}, $_[4]); $_[1] } ; array_len: diff --git a/source4/pidl/lib/Parse/Pidl.pm b/pidl/lib/Parse/Pidl.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl.pm rename to pidl/lib/Parse/Pidl.pm diff --git a/source4/pidl/lib/Parse/Pidl/CUtil.pm b/pidl/lib/Parse/Pidl/CUtil.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/CUtil.pm rename to pidl/lib/Parse/Pidl/CUtil.pm diff --git a/source4/pidl/lib/Parse/Pidl/Compat.pm b/pidl/lib/Parse/Pidl/Compat.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Compat.pm rename to pidl/lib/Parse/Pidl/Compat.pm diff --git a/source4/pidl/lib/Parse/Pidl/Dump.pm b/pidl/lib/Parse/Pidl/Dump.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Dump.pm rename to pidl/lib/Parse/Pidl/Dump.pm diff --git a/source4/pidl/lib/Parse/Pidl/Expr.pm b/pidl/lib/Parse/Pidl/Expr.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Expr.pm rename to pidl/lib/Parse/Pidl/Expr.pm diff --git a/source4/pidl/lib/Parse/Pidl/IDL.pm b/pidl/lib/Parse/Pidl/IDL.pm similarity index 66% rename from source4/pidl/lib/Parse/Pidl/IDL.pm rename to pidl/lib/Parse/Pidl/IDL.pm index 4adb4dcea8..06d54fb4b5 100644 --- a/source4/pidl/lib/Parse/Pidl/IDL.pm +++ b/pidl/lib/Parse/Pidl/IDL.pm @@ -38,7 +38,7 @@ sub new { "import" => 7, "include" => 13 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { 'cpp_quote' => 11, 'importlib' => 10, @@ -124,7 +124,7 @@ sub new { } }, {#State 16 - DEFAULT => -114 + DEFAULT => -116 }, {#State 17 DEFAULT => -11 @@ -184,7 +184,7 @@ sub new { } }, {#State 26 - DEFAULT => -110 + DEFAULT => -112 }, {#State 27 ACTIONS => { @@ -193,23 +193,27 @@ sub new { }, {#State 28 ACTIONS => { - "{" => 37 + ":" => 37 + }, + DEFAULT => -17, + GOTOS => { + 'base_interface' => 38 } }, {#State 29 ACTIONS => { - "," => 38, - "]" => 39 + "," => 39, + "]" => 40 } }, {#State 30 ACTIONS => { - "(" => 40 + "(" => 41 }, - DEFAULT => -87 + DEFAULT => -89 }, {#State 31 - DEFAULT => -85 + DEFAULT => -87 }, {#State 32 DEFAULT => -8 @@ -218,7 +222,7 @@ sub new { DEFAULT => -9 }, {#State 34 - DEFAULT => -17 + DEFAULT => -19 }, {#State 35 DEFAULT => -12 @@ -226,1457 +230,1473 @@ sub new { {#State 36 DEFAULT => -14, GOTOS => { - 'interface_names' => 41 + 'interface_names' => 42 } }, {#State 37 ACTIONS => { - "const" => 51 + 'IDENTIFIER' => 26 }, - DEFAULT => -83, GOTOS => { - 'typedecl' => 42, - 'function' => 43, - 'definitions' => 45, - 'bitmap' => 44, - 'definition' => 48, - 'property_list' => 47, - 'usertype' => 46, - 'const' => 50, - 'struct' => 49, - 'typedef' => 53, - 'enum' => 52, - 'union' => 54 + 'identifier' => 43 } }, {#State 38 + ACTIONS => { + "{" => 44 + } + }, + {#State 39 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { 'identifier' => 30, - 'property' => 55 + 'property' => 45 } }, - {#State 39 - DEFAULT => -84 - }, {#State 40 + DEFAULT => -86 + }, + {#State 41 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'text' => 61, - 'anytext' => 56, - 'constant' => 57, - 'commalisttext' => 59 + 'identifier' => 50, + 'text' => 51, + 'anytext' => 46, + 'constant' => 47, + 'commalisttext' => 49 } }, - {#State 41 + {#State 42 ACTIONS => { - "}" => 62, - "interface" => 63 + "}" => 52, + "interface" => 53 } }, - {#State 42 - DEFAULT => -23 - }, {#State 43 - DEFAULT => -20 + DEFAULT => -18 }, {#State 44 - DEFAULT => -31 - }, - {#State 45 ACTIONS => { - "}" => 64, - "const" => 51 + "const" => 63 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'typedecl' => 42, - 'function' => 43, - 'bitmap' => 44, - 'definition' => 65, - 'property_list' => 47, - 'usertype' => 46, - 'struct' => 49, - 'const' => 50, - 'typedef' => 53, - 'enum' => 52, - 'union' => 54 + 'typedecl' => 54, + 'function' => 55, + 'definitions' => 57, + 'bitmap' => 56, + 'definition' => 60, + 'property_list' => 59, + 'usertype' => 58, + 'const' => 62, + 'struct' => 61, + 'typedef' => 65, + 'enum' => 64, + 'union' => 66 } }, + {#State 45 + DEFAULT => -88 + }, {#State 46 ACTIONS => { - ";" => 66 - } + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -91 }, {#State 47 - ACTIONS => { - "typedef" => 67, - 'IDENTIFIER' => 26, - "signed" => 75, - "union" => 68, - "enum" => 77, - "bitmap" => 78, - 'void' => 69, - "unsigned" => 79, - "[" => 20, - "struct" => 74 - }, - GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 80, - 'union' => 54, - 'sign' => 73 - } + DEFAULT => -95 }, {#State 48 - DEFAULT => -18 + DEFAULT => -115 }, {#State 49 - DEFAULT => -28 + ACTIONS => { + "," => 82, + ")" => 83 + } }, {#State 50 - DEFAULT => -21 + DEFAULT => -94 }, {#State 51 + DEFAULT => -96 + }, + {#State 52 ACTIONS => { - 'IDENTIFIER' => 26 + ";" => 85 }, + DEFAULT => -117, GOTOS => { - 'identifier' => 81 + 'optional_semicolon' => 84 } }, - {#State 52 - DEFAULT => -30 - }, {#State 53 - DEFAULT => -22 + ACTIONS => { + 'IDENTIFIER' => 26 + }, + GOTOS => { + 'identifier' => 86 + } }, {#State 54 - DEFAULT => -29 + DEFAULT => -25 }, {#State 55 - DEFAULT => -86 + DEFAULT => -22 }, {#State 56 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -89 + DEFAULT => -33 }, {#State 57 - DEFAULT => -93 + ACTIONS => { + "}" => 87, + "const" => 63 + }, + DEFAULT => -85, + GOTOS => { + 'typedecl' => 54, + 'function' => 55, + 'bitmap' => 56, + 'definition' => 88, + 'property_list' => 59, + 'usertype' => 58, + 'struct' => 61, + 'const' => 62, + 'typedef' => 65, + 'enum' => 64, + 'union' => 66 + } }, {#State 58 - DEFAULT => -113 + ACTIONS => { + ";" => 89 + } }, {#State 59 ACTIONS => { - "," => 97, - ")" => 98 + "typedef" => 90, + 'IDENTIFIER' => 26, + "signed" => 98, + "union" => 91, + "enum" => 100, + "bitmap" => 101, + 'void' => 92, + "unsigned" => 102, + "[" => 20, + "struct" => 97 + }, + GOTOS => { + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 103, + 'union' => 66, + 'sign' => 96 } }, {#State 60 - DEFAULT => -92 + DEFAULT => -20 }, {#State 61 - DEFAULT => -94 + DEFAULT => -30 }, {#State 62 - ACTIONS => { - ";" => 99 - }, - DEFAULT => -115, - GOTOS => { - 'optional_semicolon' => 100 - } + DEFAULT => -23 }, {#State 63 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 101 + 'identifier' => 104 } }, {#State 64 - ACTIONS => { - ";" => 99 - }, - DEFAULT => -115, - GOTOS => { - 'optional_semicolon' => 102 - } + DEFAULT => -32 }, {#State 65 - DEFAULT => -19 + DEFAULT => -24 }, {#State 66 - DEFAULT => -32 + DEFAULT => -31 }, {#State 67 ACTIONS => { - 'IDENTIFIER' => 26, - "signed" => 75, - 'void' => 69, - "unsigned" => 79 - }, - DEFAULT => -83, - GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 103, - 'union' => 54, - 'sign' => 73 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -93, + GOTOS => { + 'identifier' => 50, + 'anytext' => 105, + 'text' => 51, + 'constant' => 47 } }, {#State 68 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 105 + 'identifier' => 50, + 'anytext' => 106, + 'text' => 51, + 'constant' => 47 } }, {#State 69 - DEFAULT => -39 - }, - {#State 70 - ACTIONS => { - "union" => 68, - "enum" => 77, - "bitmap" => 78, - "[" => 20, - "struct" => 74 - } - }, - {#State 71 - DEFAULT => -37 - }, - {#State 72 - DEFAULT => -36 - }, - {#State 73 ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, 'IDENTIFIER' => 26 }, + DEFAULT => -93, GOTOS => { - 'identifier' => 106 + 'identifier' => 50, + 'anytext' => 107, + 'text' => 51, + 'constant' => 47 } }, - {#State 74 + {#State 70 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 107 + 'identifier' => 50, + 'anytext' => 108, + 'text' => 51, + 'constant' => 47 } }, - {#State 75 - DEFAULT => -33 - }, - {#State 76 - DEFAULT => -38 - }, - {#State 77 + {#State 71 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 108 + 'identifier' => 50, + 'anytext' => 109, + 'text' => 51, + 'constant' => 47 } }, - {#State 78 + {#State 72 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 109 + 'identifier' => 50, + 'anytext' => 110, + 'text' => 51, + 'constant' => 47 } }, - {#State 79 - DEFAULT => -34 - }, - {#State 80 + {#State 73 ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, 'IDENTIFIER' => 26 }, + DEFAULT => -93, GOTOS => { - 'identifier' => 110 + 'identifier' => 50, + 'anytext' => 46, + 'text' => 51, + 'constant' => 47, + 'commalisttext' => 111 } }, - {#State 81 - DEFAULT => -72, - GOTOS => { - 'pointers' => 111 - } - }, - {#State 82 + {#State 74 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 112, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 83 + {#State 75 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 113, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 84 + {#State 76 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 114, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 85 + {#State 77 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 115, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 46, + 'text' => 51, + 'constant' => 47, + 'commalisttext' => 115 } }, - {#State 86 + {#State 78 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 116, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 87 + {#State 79 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 117, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 88 + {#State 80 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 118, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 89 + {#State 81 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 56, - 'text' => 61, - 'constant' => 57, - 'commalisttext' => 119 + 'identifier' => 50, + 'anytext' => 119, + 'text' => 51, + 'constant' => 47 } }, - {#State 90 + {#State 82 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 120, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 91 + {#State 83 + DEFAULT => -90 + }, + {#State 84 + DEFAULT => -13 + }, + {#State 85 + DEFAULT => -118 + }, + {#State 86 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 - }, - DEFAULT => -91, - GOTOS => { - 'identifier' => 60, - 'anytext' => 121, - 'text' => 61, - 'constant' => 57 + ";" => 121 } }, - {#State 92 + {#State 87 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + ";" => 85 }, - DEFAULT => -91, + DEFAULT => -117, GOTOS => { - 'identifier' => 60, - 'anytext' => 122, - 'text' => 61, - 'constant' => 57 + 'optional_semicolon' => 122 } }, - {#State 93 + {#State 88 + DEFAULT => -21 + }, + {#State 89 + DEFAULT => -34 + }, + {#State 90 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + 'IDENTIFIER' => 26, + "signed" => 98, + 'void' => 92, + "unsigned" => 102 }, - DEFAULT => -91, + DEFAULT => -85, GOTOS => { - 'identifier' => 60, - 'anytext' => 56, - 'text' => 61, - 'constant' => 57, - 'commalisttext' => 123 + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 123, + 'union' => 66, + 'sign' => 96 } }, - {#State 94 + {#State 91 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + 'IDENTIFIER' => 124 }, - DEFAULT => -91, + DEFAULT => -114, GOTOS => { - 'identifier' => 60, - 'anytext' => 124, - 'text' => 61, - 'constant' => 57 + 'optional_identifier' => 125 } }, - {#State 95 + {#State 92 + DEFAULT => -41 + }, + {#State 93 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 - }, - DEFAULT => -91, - GOTOS => { - 'identifier' => 60, - 'anytext' => 125, - 'text' => 61, - 'constant' => 57 + "union" => 91, + "enum" => 100, + "bitmap" => 101, + "[" => 20, + "struct" => 97 } }, + {#State 94 + DEFAULT => -39 + }, + {#State 95 + DEFAULT => -38 + }, {#State 96 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, GOTOS => { - 'identifier' => 60, - 'anytext' => 126, - 'text' => 61, - 'constant' => 57 + 'identifier' => 126 } }, {#State 97 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + 'IDENTIFIER' => 124 }, - DEFAULT => -91, + DEFAULT => -114, GOTOS => { - 'identifier' => 60, - 'anytext' => 127, - 'text' => 61, - 'constant' => 57 + 'optional_identifier' => 127 } }, {#State 98 - DEFAULT => -88 + DEFAULT => -35 }, {#State 99 - DEFAULT => -116 + DEFAULT => -40 }, {#State 100 - DEFAULT => -13 + ACTIONS => { + 'IDENTIFIER' => 124 + }, + DEFAULT => -114, + GOTOS => { + 'optional_identifier' => 128 + } }, {#State 101 ACTIONS => { - ";" => 128 + 'IDENTIFIER' => 124 + }, + DEFAULT => -114, + GOTOS => { + 'optional_identifier' => 129 } }, {#State 102 - DEFAULT => -16 + DEFAULT => -36 }, {#State 103 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 129 + 'identifier' => 130 } }, {#State 104 - DEFAULT => -111 + DEFAULT => -74, + GOTOS => { + 'pointers' => 131 + } }, {#State 105 ACTIONS => { - "{" => 131 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -68, - GOTOS => { - 'union_body' => 132, - 'opt_union_body' => 130 - } + DEFAULT => -106 }, {#State 106 - DEFAULT => -35 + ACTIONS => { + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -97 }, {#State 107 ACTIONS => { - "{" => 134 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -58, - GOTOS => { - 'struct_body' => 133, - 'opt_struct_body' => 135 - } + DEFAULT => -105 }, {#State 108 ACTIONS => { - "{" => 136 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -41, - GOTOS => { - 'opt_enum_body' => 138, - 'enum_body' => 137 - } + DEFAULT => -101 }, {#State 109 ACTIONS => { - "{" => 140 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -49, - GOTOS => { - 'bitmap_body' => 141, - 'opt_bitmap_body' => 139 - } + DEFAULT => -109 }, {#State 110 ACTIONS => { - "(" => 142 - } + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -108 }, {#State 111 ACTIONS => { - 'IDENTIFIER' => 26, - "*" => 144 - }, - GOTOS => { - 'identifier' => 143 + "}" => 132, + "," => 82 } }, {#State 112 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -104 + DEFAULT => -103 }, {#State 113 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -95 + DEFAULT => -104 }, {#State 114 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -99 + DEFAULT => -107 }, {#State 115 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -107 + "," => 82, + ")" => 133 + } }, {#State 116 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -106 + DEFAULT => -102 }, {#State 117 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -97 + DEFAULT => -99 }, {#State 118 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -103 + DEFAULT => -98 }, {#State 119 ACTIONS => { - "}" => 145, - "," => 97 - } + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -100 }, {#State 120 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -101 + DEFAULT => -92 }, {#State 121 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -102 + DEFAULT => -15 }, {#State 122 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -105 + DEFAULT => -16 }, {#State 123 ACTIONS => { - "," => 97, - ")" => 146 + 'IDENTIFIER' => 26 + }, + GOTOS => { + 'identifier' => 134 } }, {#State 124 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -100 + DEFAULT => -113 }, {#State 125 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + "{" => 136 }, - DEFAULT => -96 + DEFAULT => -70, + GOTOS => { + 'union_body' => 137, + 'opt_union_body' => 135 + } }, {#State 126 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -98 + DEFAULT => -37 }, {#State 127 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + "{" => 139 }, - DEFAULT => -90 + DEFAULT => -60, + GOTOS => { + 'struct_body' => 138, + 'opt_struct_body' => 140 + } }, {#State 128 - DEFAULT => -15 + ACTIONS => { + "{" => 141 + }, + DEFAULT => -43, + GOTOS => { + 'opt_enum_body' => 143, + 'enum_body' => 142 + } }, {#State 129 ACTIONS => { - "[" => 147 + "{" => 145 }, - DEFAULT => -80, + DEFAULT => -51, GOTOS => { - 'array_len' => 148 + 'bitmap_body' => 146, + 'opt_bitmap_body' => 144 } }, {#State 130 - DEFAULT => -70 + ACTIONS => { + "(" => 147 + } }, {#State 131 - DEFAULT => -65, + ACTIONS => { + 'IDENTIFIER' => 26, + "*" => 149 + }, GOTOS => { - 'union_elements' => 149 + 'identifier' => 148 } }, {#State 132 - DEFAULT => -69 + ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -93, + GOTOS => { + 'identifier' => 50, + 'anytext' => 150, + 'text' => 51, + 'constant' => 47 + } }, {#State 133 - DEFAULT => -59 + ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -93, + GOTOS => { + 'identifier' => 50, + 'anytext' => 151, + 'text' => 51, + 'constant' => 47 + } }, {#State 134 - DEFAULT => -74, + ACTIONS => { + "[" => 152 + }, + DEFAULT => -82, GOTOS => { - 'element_list1' => 150 + 'array_len' => 153 } }, {#State 135 - DEFAULT => -60 + DEFAULT => -72 }, {#State 136 - ACTIONS => { - 'IDENTIFIER' => 26 - }, + DEFAULT => -67, GOTOS => { - 'identifier' => 151, - 'enum_element' => 152, - 'enum_elements' => 153 + 'union_elements' => 154 } }, {#State 137 - DEFAULT => -42 + DEFAULT => -71 }, {#State 138 - DEFAULT => -43 + DEFAULT => -61 }, {#State 139 - DEFAULT => -51 + DEFAULT => -76, + GOTOS => { + 'element_list1' => 155 + } }, {#State 140 + DEFAULT => -62 + }, + {#State 141 ACTIONS => { 'IDENTIFIER' => 26 }, - DEFAULT => -54, GOTOS => { 'identifier' => 156, - 'bitmap_element' => 155, - 'bitmap_elements' => 154, - 'opt_bitmap_elements' => 157 + 'enum_element' => 157, + 'enum_elements' => 158 } }, - {#State 141 - DEFAULT => -50 - }, {#State 142 - ACTIONS => { - "," => -76, - "void" => 161, - ")" => -76 - }, - DEFAULT => -83, - GOTOS => { - 'base_element' => 158, - 'element_list2' => 160, - 'property_list' => 159 - } + DEFAULT => -44 }, {#State 143 - ACTIONS => { - "[" => 147, - "=" => 163 - }, - GOTOS => { - 'array_len' => 162 - } + DEFAULT => -45 }, {#State 144 - DEFAULT => -73 + DEFAULT => -53 }, {#State 145 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -56, GOTOS => { - 'identifier' => 60, - 'anytext' => 164, - 'text' => 61, - 'constant' => 57 + 'identifier' => 161, + 'bitmap_element' => 160, + 'bitmap_elements' => 159, + 'opt_bitmap_elements' => 162 } }, {#State 146 + DEFAULT => -52 + }, + {#State 147 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + "," => -78, + "void" => 166, + ")" => -78 }, - DEFAULT => -91, + DEFAULT => -85, GOTOS => { - 'identifier' => 60, - 'anytext' => 165, - 'text' => 61, - 'constant' => 57 + 'base_element' => 163, + 'element_list2' => 165, + 'property_list' => 164 } }, - {#State 147 + {#State 148 + ACTIONS => { + "[" => 152, + "=" => 168 + }, + GOTOS => { + 'array_len' => 167 + } + }, + {#State 149 + DEFAULT => -75 + }, + {#State 150 + ACTIONS => { + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -111 + }, + {#State 151 ACTIONS => { - 'CONSTANT' => 58, + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -110 + }, + {#State 152 + ACTIONS => { + 'CONSTANT' => 48, 'TEXT' => 16, - "]" => 166, + "]" => 169, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 167, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 170, + 'text' => 51, + 'constant' => 47 } }, - {#State 148 + {#State 153 ACTIONS => { - ";" => 168 + ";" => 171 } }, - {#State 149 + {#State 154 ACTIONS => { - "}" => 169 + "}" => 172 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'optional_base_element' => 171, - 'property_list' => 170 + 'optional_base_element' => 174, + 'property_list' => 173 } }, - {#State 150 + {#State 155 ACTIONS => { - "}" => 172 + "}" => 175 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'base_element' => 173, - 'property_list' => 159 + 'base_element' => 176, + 'property_list' => 164 } }, - {#State 151 + {#State 156 ACTIONS => { - "=" => 174 + "=" => 177 }, - DEFAULT => -46 + DEFAULT => -48 }, - {#State 152 - DEFAULT => -44 + {#State 157 + DEFAULT => -46 }, - {#State 153 + {#State 158 ACTIONS => { - "}" => 175, - "," => 176 + "}" => 178, + "," => 179 } }, - {#State 154 + {#State 159 ACTIONS => { - "," => 177 + "," => 180 }, - DEFAULT => -55 + DEFAULT => -57 }, - {#State 155 - DEFAULT => -52 + {#State 160 + DEFAULT => -54 }, - {#State 156 + {#State 161 ACTIONS => { - "=" => 178 + "=" => 181 } }, - {#State 157 + {#State 162 ACTIONS => { - "}" => 179 + "}" => 182 } }, - {#State 158 - DEFAULT => -78 + {#State 163 + DEFAULT => -80 }, - {#State 159 + {#State 164 ACTIONS => { 'IDENTIFIER' => 26, - "signed" => 75, - 'void' => 69, - "unsigned" => 79, + "signed" => 98, + 'void' => 92, + "unsigned" => 102, "[" => 20 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 180, - 'union' => 54, - 'sign' => 73 + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 183, + 'union' => 66, + 'sign' => 96 } }, - {#State 160 + {#State 165 ACTIONS => { - "," => 181, - ")" => 182 + "," => 184, + ")" => 185 } }, - {#State 161 - DEFAULT => -77 + {#State 166 + DEFAULT => -79 }, - {#State 162 + {#State 167 ACTIONS => { - "=" => 183 + "=" => 186 } }, - {#State 163 + {#State 168 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 184, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 187, + 'text' => 51, + 'constant' => 47 } }, - {#State 164 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -109 - }, - {#State 165 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -108 - }, - {#State 166 + {#State 169 ACTIONS => { - "[" => 147 + "[" => 152 }, - DEFAULT => -80, + DEFAULT => -82, GOTOS => { - 'array_len' => 185 + 'array_len' => 188 } }, - {#State 167 + {#State 170 ACTIONS => { - "-" => 83, - ":" => 82, - "?" => 88, - "<" => 84, - "+" => 86, - "~" => 85, - "&" => 90, - "{" => 89, - "/" => 91, - "=" => 92, - "|" => 94, - "(" => 93, - "*" => 87, - "." => 95, - "]" => 186, - ">" => 96 + "-" => 68, + ":" => 67, + "?" => 69, + "<" => 70, + "+" => 72, + "~" => 71, + "&" => 74, + "{" => 73, + "/" => 75, + "=" => 76, + "|" => 78, + "(" => 77, + "*" => 79, + "." => 80, + "]" => 189, + ">" => 81 } }, - {#State 168 - DEFAULT => -27 + {#State 171 + DEFAULT => -29 }, - {#State 169 - DEFAULT => -67 + {#State 172 + DEFAULT => -69 }, - {#State 170 + {#State 173 ACTIONS => { "[" => 20 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'base_or_empty' => 187, - 'base_element' => 188, - 'empty_element' => 189, - 'property_list' => 190 + 'base_or_empty' => 190, + 'base_element' => 191, + 'empty_element' => 192, + 'property_list' => 193 } }, - {#State 171 - DEFAULT => -66 + {#State 174 + DEFAULT => -68 }, - {#State 172 - DEFAULT => -57 + {#State 175 + DEFAULT => -59 }, - {#State 173 + {#State 176 ACTIONS => { - ";" => 191 + ";" => 194 } }, - {#State 174 + {#State 177 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 192, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 195, + 'text' => 51, + 'constant' => 47 } }, - {#State 175 - DEFAULT => -40 + {#State 178 + DEFAULT => -42 }, - {#State 176 + {#State 179 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 151, - 'enum_element' => 193 + 'identifier' => 156, + 'enum_element' => 196 } }, - {#State 177 + {#State 180 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 156, - 'bitmap_element' => 194 + 'identifier' => 161, + 'bitmap_element' => 197 } }, - {#State 178 + {#State 181 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 195, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 198, + 'text' => 51, + 'constant' => 47 } }, - {#State 179 - DEFAULT => -48 + {#State 182 + DEFAULT => -50 }, - {#State 180 - DEFAULT => -72, + {#State 183 + DEFAULT => -74, GOTOS => { - 'pointers' => 196 + 'pointers' => 199 } }, - {#State 181 - DEFAULT => -83, + {#State 184 + DEFAULT => -85, GOTOS => { - 'base_element' => 197, - 'property_list' => 159 + 'base_element' => 200, + 'property_list' => 164 } }, - {#State 182 + {#State 185 ACTIONS => { - ";" => 198 + ";" => 201 } }, - {#State 183 + {#State 186 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 199, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 202, + 'text' => 51, + 'constant' => 47 } }, - {#State 184 + {#State 187 ACTIONS => { - "-" => 83, - ":" => 82, - "?" => 88, - "<" => 84, - ";" => 200, - "+" => 86, - "~" => 85, - "&" => 90, - "{" => 89, - "/" => 91, - "=" => 92, - "|" => 94, - "(" => 93, - "*" => 87, - "." => 95, - ">" => 96 + "-" => 68, + ":" => 67, + "?" => 69, + "<" => 70, + ";" => 203, + "+" => 72, + "~" => 71, + "&" => 74, + "{" => 73, + "/" => 75, + "=" => 76, + "|" => 78, + "(" => 77, + "*" => 79, + "." => 80, + ">" => 81 } }, - {#State 185 - DEFAULT => -81 + {#State 188 + DEFAULT => -83 }, - {#State 186 + {#State 189 ACTIONS => { - "[" => 147 + "[" => 152 }, - DEFAULT => -80, + DEFAULT => -82, GOTOS => { - 'array_len' => 201 + 'array_len' => 204 } }, - {#State 187 - DEFAULT => -64 + {#State 190 + DEFAULT => -66 }, - {#State 188 + {#State 191 ACTIONS => { - ";" => 202 + ";" => 205 } }, - {#State 189 - DEFAULT => -63 + {#State 192 + DEFAULT => -65 }, - {#State 190 + {#State 193 ACTIONS => { 'IDENTIFIER' => 26, - "signed" => 75, - ";" => 203, - 'void' => 69, - "unsigned" => 79, + "signed" => 98, + ";" => 206, + 'void' => 92, + "unsigned" => 102, "[" => 20 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 180, - 'union' => 54, - 'sign' => 73 + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 183, + 'union' => 66, + 'sign' => 96 } }, - {#State 191 - DEFAULT => -75 - }, - {#State 192 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -47 - }, - {#State 193 - DEFAULT => -45 - }, {#State 194 - DEFAULT => -53 + DEFAULT => -77 }, {#State 195 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -56 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -49 }, {#State 196 - ACTIONS => { - 'IDENTIFIER' => 26, - "*" => 144 - }, - GOTOS => { - 'identifier' => 204 - } + DEFAULT => -47 }, {#State 197 - DEFAULT => -79 + DEFAULT => -55 }, {#State 198 - DEFAULT => -26 + ACTIONS => { + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -58 }, {#State 199 ACTIONS => { - "-" => 83, - ":" => 82, - "?" => 88, - "<" => 84, - ";" => 205, - "+" => 86, - "~" => 85, - "&" => 90, - "{" => 89, - "/" => 91, - "=" => 92, - "|" => 94, - "(" => 93, - "*" => 87, - "." => 95, - ">" => 96 + 'IDENTIFIER' => 26, + "*" => 149 + }, + GOTOS => { + 'identifier' => 207 } }, {#State 200 - DEFAULT => -24 + DEFAULT => -81 }, {#State 201 - DEFAULT => -82 + DEFAULT => -28 }, {#State 202 - DEFAULT => -62 + ACTIONS => { + "-" => 68, + ":" => 67, + "?" => 69, + "<" => 70, + ";" => 208, + "+" => 72, + "~" => 71, + "&" => 74, + "{" => 73, + "/" => 75, + "=" => 76, + "|" => 78, + "(" => 77, + "*" => 79, + "." => 80, + ">" => 81 + } }, {#State 203 - DEFAULT => -61 + DEFAULT => -26 }, {#State 204 + DEFAULT => -84 + }, + {#State 205 + DEFAULT => -64 + }, + {#State 206 + DEFAULT => -63 + }, + {#State 207 ACTIONS => { - "[" => 147 + "[" => 152 }, - DEFAULT => -80, + DEFAULT => -82, GOTOS => { - 'array_len' => 206 + 'array_len' => 209 } }, - {#State 205 - DEFAULT => -25 + {#State 208 + DEFAULT => -27 }, - {#State 206 - DEFAULT => -71 + {#State 209 + DEFAULT => -73 } ], yyrules => @@ -1791,22 +1811,32 @@ sub { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 16 - 'interface', 7, + 'interface', 8, sub #line 71 "pidl/idl.yp" {{ "TYPE" => "INTERFACE", "PROPERTIES" => $_[1], "NAME" => $_[3], - "DATA" => $_[5], + "BASE" => $_[4], + "DATA" => $_[6], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 17 + 'base_interface', 0, undef + ], + [#Rule 18 + 'base_interface', 2, +sub +#line 84 "pidl/idl.yp" +{ $_[2] } + ], + [#Rule 19 'cpp_quote', 4, sub -#line 82 "pidl/idl.yp" +#line 89 "pidl/idl.yp" {{ "TYPE" => "CPP_QUOTE", "FILE" => $_[0]->YYData->{FILE}, @@ -1814,34 +1844,34 @@ sub "DATA" => $_[3] }} ], - [#Rule 18 + [#Rule 20 'definitions', 1, sub -#line 91 "pidl/idl.yp" +#line 98 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 19 + [#Rule 21 'definitions', 2, sub -#line 92 "pidl/idl.yp" +#line 99 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 20 + [#Rule 22 'definition', 1, undef ], - [#Rule 21 + [#Rule 23 'definition', 1, undef ], - [#Rule 22 + [#Rule 24 'definition', 1, undef ], - [#Rule 23 + [#Rule 25 'definition', 1, undef ], - [#Rule 24 + [#Rule 26 'const', 7, sub -#line 100 "pidl/idl.yp" +#line 107 "pidl/idl.yp" {{ "TYPE" => "CONST", "DTYPE" => $_[2], @@ -1852,10 +1882,10 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 25 + [#Rule 27 'const', 8, sub -#line 110 "pidl/idl.yp" +#line 117 "pidl/idl.yp" {{ "TYPE" => "CONST", "DTYPE" => $_[2], @@ -1867,10 +1897,10 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 26 + [#Rule 28 'function', 7, sub -#line 124 "pidl/idl.yp" +#line 131 "pidl/idl.yp" {{ "TYPE" => "FUNCTION", "NAME" => $_[3], @@ -1881,10 +1911,10 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 27 + [#Rule 29 'typedef', 6, sub -#line 136 "pidl/idl.yp" +#line 143 "pidl/idl.yp" {{ "TYPE" => "TYPEDEF", "PROPERTIES" => $_[1], @@ -1895,67 +1925,67 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 28 + [#Rule 30 'usertype', 1, undef ], - [#Rule 29 + [#Rule 31 'usertype', 1, undef ], - [#Rule 30 + [#Rule 32 'usertype', 1, undef ], - [#Rule 31 + [#Rule 33 'usertype', 1, undef ], - [#Rule 32 + [#Rule 34 'typedecl', 2, sub -#line 149 "pidl/idl.yp" +#line 156 "pidl/idl.yp" { $_[1] } ], - [#Rule 33 + [#Rule 35 'sign', 1, undef ], - [#Rule 34 + [#Rule 36 'sign', 1, undef ], - [#Rule 35 + [#Rule 37 'existingtype', 2, sub -#line 154 "pidl/idl.yp" +#line 161 "pidl/idl.yp" { ($_[1]?$_[1]:"signed") ." $_[2]" } ], - [#Rule 36 + [#Rule 38 'existingtype', 1, undef ], - [#Rule 37 + [#Rule 39 'type', 1, undef ], - [#Rule 38 + [#Rule 40 'type', 1, undef ], - [#Rule 39 + [#Rule 41 'type', 1, sub -#line 158 "pidl/idl.yp" +#line 165 "pidl/idl.yp" { "void" } ], - [#Rule 40 + [#Rule 42 'enum_body', 3, sub -#line 160 "pidl/idl.yp" +#line 167 "pidl/idl.yp" { $_[2] } ], - [#Rule 41 + [#Rule 43 'opt_enum_body', 0, undef ], - [#Rule 42 + [#Rule 44 'opt_enum_body', 1, undef ], - [#Rule 43 + [#Rule 45 'enum', 4, sub -#line 163 "pidl/idl.yp" +#line 170 "pidl/idl.yp" {{ "TYPE" => "ENUM", "PROPERTIES" => $_[1], @@ -1963,43 +1993,43 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 44 + [#Rule 46 'enum_elements', 1, sub -#line 172 "pidl/idl.yp" +#line 179 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 45 + [#Rule 47 'enum_elements', 3, sub -#line 173 "pidl/idl.yp" +#line 180 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 46 + [#Rule 48 'enum_element', 1, undef ], - [#Rule 47 + [#Rule 49 'enum_element', 3, sub -#line 177 "pidl/idl.yp" +#line 184 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 48 + [#Rule 50 'bitmap_body', 3, sub -#line 180 "pidl/idl.yp" +#line 187 "pidl/idl.yp" { $_[2] } ], - [#Rule 49 + [#Rule 51 'opt_bitmap_body', 0, undef ], - [#Rule 50 + [#Rule 52 'opt_bitmap_body', 1, undef ], - [#Rule 51 + [#Rule 53 'bitmap', 4, sub -#line 183 "pidl/idl.yp" +#line 190 "pidl/idl.yp" {{ "TYPE" => "BITMAP", "PROPERTIES" => $_[1], @@ -2007,46 +2037,46 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 52 + [#Rule 54 'bitmap_elements', 1, sub -#line 192 "pidl/idl.yp" +#line 199 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 53 + [#Rule 55 'bitmap_elements', 3, sub -#line 193 "pidl/idl.yp" +#line 200 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 54 + [#Rule 56 'opt_bitmap_elements', 0, undef ], - [#Rule 55 + [#Rule 57 'opt_bitmap_elements', 1, undef ], - [#Rule 56 + [#Rule 58 'bitmap_element', 3, sub -#line 198 "pidl/idl.yp" +#line 205 "pidl/idl.yp" { "$_[1] ( $_[3] )" } ], - [#Rule 57 + [#Rule 59 'struct_body', 3, sub -#line 201 "pidl/idl.yp" +#line 208 "pidl/idl.yp" { $_[2] } ], - [#Rule 58 + [#Rule 60 'opt_struct_body', 0, undef ], - [#Rule 59 + [#Rule 61 'opt_struct_body', 1, undef ], - [#Rule 60 + [#Rule 62 'struct', 4, sub -#line 205 "pidl/idl.yp" +#line 212 "pidl/idl.yp" {{ "TYPE" => "STRUCT", "PROPERTIES" => $_[1], @@ -2054,10 +2084,10 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 61 + [#Rule 63 'empty_element', 2, sub -#line 214 "pidl/idl.yp" +#line 221 "pidl/idl.yp" {{ "NAME" => "", "TYPE" => "EMPTY", @@ -2068,43 +2098,43 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 62 + [#Rule 64 'base_or_empty', 2, undef ], - [#Rule 63 + [#Rule 65 'base_or_empty', 1, undef ], - [#Rule 64 + [#Rule 66 'optional_base_element', 2, sub -#line 228 "pidl/idl.yp" +#line 235 "pidl/idl.yp" { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } ], - [#Rule 65 + [#Rule 67 'union_elements', 0, undef ], - [#Rule 66 + [#Rule 68 'union_elements', 2, sub -#line 233 "pidl/idl.yp" +#line 240 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 67 + [#Rule 69 'union_body', 3, sub -#line 236 "pidl/idl.yp" +#line 243 "pidl/idl.yp" { $_[2] } ], - [#Rule 68 + [#Rule 70 'opt_union_body', 0, undef ], - [#Rule 69 + [#Rule 71 'opt_union_body', 1, undef ], - [#Rule 70 + [#Rule 72 'union', 4, sub -#line 240 "pidl/idl.yp" +#line 247 "pidl/idl.yp" {{ "TYPE" => "UNION", "PROPERTIES" => $_[1], @@ -2112,10 +2142,10 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 71 + [#Rule 73 'base_element', 5, sub -#line 249 "pidl/idl.yp" +#line 256 "pidl/idl.yp" {{ "NAME" => $_[4], "TYPE" => $_[2], @@ -2126,232 +2156,232 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 72 + [#Rule 74 'pointers', 0, sub -#line 263 "pidl/idl.yp" +#line 270 "pidl/idl.yp" { 0 } ], - [#Rule 73 + [#Rule 75 'pointers', 2, sub -#line 264 "pidl/idl.yp" +#line 271 "pidl/idl.yp" { $_[1]+1 } ], - [#Rule 74 + [#Rule 76 'element_list1', 0, sub -#line 268 "pidl/idl.yp" +#line 275 "pidl/idl.yp" { [] } ], - [#Rule 75 + [#Rule 77 'element_list1', 3, sub -#line 269 "pidl/idl.yp" +#line 276 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 76 + [#Rule 78 'element_list2', 0, undef ], - [#Rule 77 + [#Rule 79 'element_list2', 1, undef ], - [#Rule 78 + [#Rule 80 'element_list2', 1, sub -#line 275 "pidl/idl.yp" +#line 282 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 79 + [#Rule 81 'element_list2', 3, sub -#line 276 "pidl/idl.yp" +#line 283 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 80 + [#Rule 82 'array_len', 0, undef ], - [#Rule 81 + [#Rule 83 'array_len', 3, sub -#line 281 "pidl/idl.yp" +#line 288 "pidl/idl.yp" { push(@{$_[3]}, "*"); $_[3] } ], - [#Rule 82 + [#Rule 84 'array_len', 4, sub -#line 282 "pidl/idl.yp" +#line 289 "pidl/idl.yp" { push(@{$_[4]}, "$_[2]"); $_[4] } ], - [#Rule 83 + [#Rule 85 'property_list', 0, undef ], - [#Rule 84 + [#Rule 86 'property_list', 4, sub -#line 288 "pidl/idl.yp" +#line 295 "pidl/idl.yp" { FlattenHash([$_[1],$_[3]]); } ], - [#Rule 85 + [#Rule 87 'properties', 1, sub -#line 291 "pidl/idl.yp" +#line 298 "pidl/idl.yp" { $_[1] } ], - [#Rule 86 + [#Rule 88 'properties', 3, sub -#line 292 "pidl/idl.yp" +#line 299 "pidl/idl.yp" { FlattenHash([$_[1], $_[3]]); } ], - [#Rule 87 + [#Rule 89 'property', 1, sub -#line 295 "pidl/idl.yp" +#line 302 "pidl/idl.yp" {{ "$_[1]" => "1" }} ], - [#Rule 88 + [#Rule 90 'property', 4, sub -#line 296 "pidl/idl.yp" +#line 303 "pidl/idl.yp" {{ "$_[1]" => "$_[3]" }} ], - [#Rule 89 + [#Rule 91 'commalisttext', 1, undef ], - [#Rule 90 + [#Rule 92 'commalisttext', 3, sub -#line 301 "pidl/idl.yp" +#line 308 "pidl/idl.yp" { "$_[1],$_[3]" } ], - [#Rule 91 + [#Rule 93 'anytext', 0, sub -#line 305 "pidl/idl.yp" +#line 312 "pidl/idl.yp" { "" } ], - [#Rule 92 - 'anytext', 1, undef - ], - [#Rule 93 - 'anytext', 1, undef - ], [#Rule 94 'anytext', 1, undef ], [#Rule 95 - 'anytext', 3, -sub -#line 307 "pidl/idl.yp" -{ "$_[1]$_[2]$_[3]" } + 'anytext', 1, undef ], [#Rule 96 - 'anytext', 3, -sub -#line 308 "pidl/idl.yp" -{ "$_[1]$_[2]$_[3]" } + 'anytext', 1, undef ], [#Rule 97 'anytext', 3, sub -#line 309 "pidl/idl.yp" +#line 314 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 98 'anytext', 3, sub -#line 310 "pidl/idl.yp" +#line 315 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 99 'anytext', 3, sub -#line 311 "pidl/idl.yp" +#line 316 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 100 'anytext', 3, sub -#line 312 "pidl/idl.yp" +#line 317 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 101 'anytext', 3, sub -#line 313 "pidl/idl.yp" +#line 318 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 102 'anytext', 3, sub -#line 314 "pidl/idl.yp" +#line 319 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 103 'anytext', 3, sub -#line 315 "pidl/idl.yp" +#line 320 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 104 'anytext', 3, sub -#line 316 "pidl/idl.yp" +#line 321 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 105 'anytext', 3, sub -#line 317 "pidl/idl.yp" +#line 322 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 106 'anytext', 3, sub -#line 318 "pidl/idl.yp" +#line 323 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 107 'anytext', 3, sub -#line 319 "pidl/idl.yp" +#line 324 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 108 + 'anytext', 3, +sub +#line 325 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]" } + ], + [#Rule 109 + 'anytext', 3, +sub +#line 326 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]" } + ], + [#Rule 110 'anytext', 5, sub -#line 320 "pidl/idl.yp" +#line 327 "pidl/idl.yp" { "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], - [#Rule 109 + [#Rule 111 'anytext', 5, sub -#line 321 "pidl/idl.yp" +#line 328 "pidl/idl.yp" { "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], - [#Rule 110 + [#Rule 112 'identifier', 1, undef ], - [#Rule 111 + [#Rule 113 'optional_identifier', 1, undef ], - [#Rule 112 + [#Rule 114 'optional_identifier', 0, undef ], - [#Rule 113 + [#Rule 115 'constant', 1, undef ], - [#Rule 114 + [#Rule 116 'text', 1, sub -#line 335 "pidl/idl.yp" +#line 342 "pidl/idl.yp" { "\"$_[1]\"" } ], - [#Rule 115 + [#Rule 117 'optional_semicolon', 0, undef ], - [#Rule 116 + [#Rule 118 'optional_semicolon', 1, undef ] ], @@ -2359,7 +2389,7 @@ sub bless($self,$class); } -#line 346 "pidl/idl.yp" +#line 353 "pidl/idl.yp" use Parse::Pidl qw(error); diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm similarity index 98% rename from source4/pidl/lib/Parse/Pidl/NDR.pm rename to pidl/lib/Parse/Pidl/NDR.pm index 10bd29715b..9b61a370e2 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/pidl/lib/Parse/Pidl/NDR.pm @@ -856,6 +856,7 @@ my %property_list = ( "pointer_default" => ["INTERFACE"], "helper" => ["INTERFACE"], "authservice" => ["INTERFACE"], + "restricted" => ["INTERFACE"], # dcom "object" => ["INTERFACE"], @@ -876,6 +877,7 @@ my %property_list = ( "unique" => ["ELEMENT"], "ignore" => ["ELEMENT"], "relative" => ["ELEMENT"], + "null_is_ffffffff" => ["ELEMENT"], "relative_base" => ["TYPEDEF", "STRUCT", "UNION"], "gensize" => ["TYPEDEF", "STRUCT", "UNION"], @@ -1080,8 +1082,9 @@ sub ValidUnion($) ValidProperties($union,"UNION"); - if (has_property($union->{PARENT}, "nodiscriminant") and has_property($union->{PARENT}, "switch_type")) { - fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type() on union without discriminant"); + if (has_property($union->{PARENT}, "nodiscriminant") and + has_property($union->{PARENT}, "switch_type")) { + fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type(" . $union->{PARENT}->{PROPERTIES}->{switch_type} . ") on union without discriminant"); } return unless defined($union->{ELEMENTS}); @@ -1100,7 +1103,7 @@ sub ValidUnion($) } if (has_property($e, "ref")) { - fatal($e, el_name($e) . " : embedded ref pointers are not supported yet\n"); + fatal($e, el_name($e) . ": embedded ref pointers are not supported yet\n"); } diff --git a/pidl/lib/Parse/Pidl/ODL.pm b/pidl/lib/Parse/Pidl/ODL.pm new file mode 100644 index 0000000000..b323a6a98a --- /dev/null +++ b/pidl/lib/Parse/Pidl/ODL.pm @@ -0,0 +1,128 @@ +########################################## +# Converts ODL stuctures to IDL structures +# (C) 2004-2005, 2008 Jelmer Vernooij + +package Parse::Pidl::ODL; + +use Parse::Pidl qw(error); +use Parse::Pidl::IDL; +use Parse::Pidl::Util qw(has_property unmake_str); +use Parse::Pidl::Typelist qw(hasType getType); +use strict; + +use vars qw($VERSION); +$VERSION = '0.01'; + +sub FunctionAddObjArgs($) +{ + my $e = shift; + + unshift(@{$e->{ELEMENTS}}, { + 'NAME' => 'ORPCthis', + 'POINTERS' => 0, + 'PROPERTIES' => { 'in' => '1' }, + 'TYPE' => 'ORPCTHIS', + 'FILE' => $e->{FILE}, + 'LINE' => $e->{LINE} + }); + unshift(@{$e->{ELEMENTS}}, { + 'NAME' => 'ORPCthat', + 'POINTERS' => 1, + 'PROPERTIES' => { 'out' => '1', 'ref' => '1' }, + 'TYPE' => 'ORPCTHAT', + 'FILE' => $e->{FILE}, + 'LINE' => $e->{LINE} + }); +} + +sub ReplaceInterfacePointers($) +{ + my ($e) = @_; + foreach my $x (@{$e->{ELEMENTS}}) { + next unless (hasType($x->{TYPE})); + next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE"; + + $x->{TYPE} = "MInterfacePointer"; + } +} + +# Add ORPC specific bits to an interface. +sub ODL2IDL +{ + my ($odl, $basedir, $opt_incdirs) = (@_); + my $addedorpc = 0; + my $interfaces = {}; + + foreach my $x (@$odl) { + if ($x->{TYPE} eq "IMPORT") { + foreach my $idl_file (@{$x->{PATHS}}) { + $idl_file = unmake_str($idl_file); + my $idl_path = undef; + foreach ($basedir, @$opt_incdirs) { + if (-f "$_/$idl_file") { + $idl_path = "$_/$idl_file"; + last; + } + } + unless ($idl_path) { + error($x, "Unable to open include file `$idl_file'"); + next; + } + my $podl = Parse::Pidl::IDL::parse_file($idl_path, $opt_incdirs); + if (defined(@$podl)) { + require Parse::Pidl::Typelist; + + Parse::Pidl::Typelist::LoadIdl($podl); + my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs); + + foreach my $y (@$pidl) { + if ($y->{TYPE} eq "INTERFACE") { + $interfaces->{$y->{NAME}} = $y; + } + } + } else { + error($x, "Failed to parse $idl_path"); + } + } + } + + if ($x->{TYPE} eq "INTERFACE") { + $interfaces->{$x->{NAME}} = $x; + # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that + # and replace interfacepointers with MInterfacePointer + # for 'object' interfaces + if (has_property($x, "object")) { + foreach my $e (@{$x->{DATA}}) { + ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e); + ReplaceInterfacePointers($e); + } + $addedorpc = 1; + } + + if ($x->{BASE}) { + my $base = $interfaces->{$x->{BASE}}; + + unless (defined($base)) { + error($x, "Undefined base interface `$x->{BASE}'"); + } else { + foreach my $fn (reverse @{$base->{DATA}}) { + next unless ($fn->{TYPE} eq "FUNCTION"); + push (@{$x->{INHERITED_FUNCTIONS}}, $fn); + } + } + } + } + } + + unshift (@$odl, { + TYPE => "IMPORT", + PATHS => [ "\"orpc.idl\"" ], + FILE => undef, + LINE => undef + }) if ($addedorpc); + + + return $odl; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm similarity index 96% rename from source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm rename to pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm index d2ab407eb0..2a23fad4a7 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm +++ b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm @@ -13,9 +13,7 @@ use Exporter; use strict; use Parse::Pidl qw(fatal warning); -use Parse::Pidl::Typelist qw(hasType getType mapTypeName scalar_is_reference); -use Parse::Pidl::Util qw(has_property is_constant ParseExpr); -use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred); +use Parse::Pidl::Util qw(has_property ParseExpr); use Parse::Pidl::Samba4 qw(DeclLong); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv); diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm similarity index 98% rename from source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm rename to pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm index b21d3f4bbc..6034fb6f16 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm +++ b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm @@ -110,7 +110,7 @@ sub ParseFunction($$) pidl "\treturn false;"; pidl "}"; pidl ""; - pidl "pull = ndr_pull_init_blob(&blob, r);"; + pidl "pull = ndr_pull_init_blob(&blob, r, NULL);"; pidl "if (pull == NULL) {"; pidl "\ttalloc_free(r);"; pidl "\treturn false;"; @@ -171,7 +171,7 @@ sub ParseFunction($$) pidl "\tNDR_PRINT_OUT_DEBUG($fn->{NAME}, r);"; pidl "}"; pidl ""; - pidl "push = ndr_push_init_ctx(r);"; + pidl "push = ndr_push_init_ctx(r, NULL);"; pidl "if (push == NULL) {"; pidl "\ttalloc_free(r);"; pidl "\treturn false;"; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4.pm b/pidl/lib/Parse/Pidl/Samba4.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4.pm rename to pidl/lib/Parse/Pidl/Samba4.pm diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm new file mode 100644 index 0000000000..996689b4b6 --- /dev/null +++ b/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm @@ -0,0 +1,155 @@ +# COM Header generation +# (C) 2005 Jelmer Vernooij + +package Parse::Pidl::Samba4::COM::Header; + +use Parse::Pidl::Typelist qw(mapTypeName); +use Parse::Pidl::Util qw(has_property is_constant); + +use vars qw($VERSION); +$VERSION = '0.01'; + +use strict; + +sub GetArgumentProtoList($) +{ + my $f = shift; + my $res = ""; + + foreach my $a (@{$f->{ELEMENTS}}) { + + $res .= ", " . mapTypeName($a->{TYPE}) . " "; + + my $l = $a->{POINTERS}; + $l-- if (Parse::Pidl::Typelist::scalar_is_reference($a->{TYPE})); + foreach my $i (1..$l) { + $res .= "*"; + } + + if (defined $a->{ARRAY_LEN}[0] && !is_constant($a->{ARRAY_LEN}[0]) && + !$a->{POINTERS}) { + $res .= "*"; + } + $res .= $a->{NAME}; + if (defined $a->{ARRAY_LEN}[0] && is_constant($a->{ARRAY_LEN}[0])) { + $res .= "[$a->{ARRAY_LEN}[0]]"; + } + } + + return $res; +} + +sub GetArgumentList($) +{ + my $f = shift; + my $res = ""; + + foreach (@{$f->{ELEMENTS}}) { $res .= ", $_->{NAME}"; } + + return $res; +} + +##################################################################### +# generate vtable structure for COM interface +sub HeaderVTable($) +{ + my $interface = shift; + my $res; + $res .= "#define " . uc($interface->{NAME}) . "_METHODS \\\n"; + if (defined($interface->{BASE})) { + $res .= "\t" . uc($interface->{BASE} . "_METHODS") . "\\\n"; + } + + my $data = $interface->{DATA}; + foreach my $d (@{$data}) { + $res .= "\t" . mapTypeName($d->{RETURN_TYPE}) . " (*$d->{NAME}) (struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . GetArgumentProtoList($d) . ");\\\n" if ($d->{TYPE} eq "FUNCTION"); + } + $res .= "\n"; + $res .= "struct $interface->{NAME}_vtable {\n"; + $res .= "\tstruct GUID iid;\n"; + $res .= "\t" . uc($interface->{NAME}) . "_METHODS\n"; + $res .= "};\n\n"; + + return $res; +} + +sub ParseInterface($) +{ + my $if = shift; + my $res; + + $res .= "\n#ifndef _$if->{NAME}_\n"; + $res .= "#define _$if->{NAME}_\n"; + + $res .="\n\n/* $if->{NAME} */\n"; + + $res .="#define COM_" . uc($if->{NAME}) . "_UUID $if->{PROPERTIES}->{uuid}\n\n"; + + $res .="struct $if->{NAME}_vtable;\n\n"; + + $res .="struct $if->{NAME} { + struct OBJREF obj; + struct com_context *ctx; + struct $if->{NAME}_vtable *vtable; + void *object_data; +};\n\n"; + + $res.=HeaderVTable($if); + + foreach my $d (@{$if->{DATA}}) { + next if ($d->{TYPE} ne "FUNCTION"); + + $res .= "#define $if->{NAME}_$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . ") "; + + $res .= "((interface)->vtable->$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . "))"; + + $res .="\n"; + } + + $res .= "#endif\n"; + + return $res; +} + +sub ParseCoClass($) +{ + my ($c) = @_; + my $res = ""; + $res .= "#define CLSID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{uuid}\n"; + if (has_property($c, "progid")) { + $res .= "#define PROGID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{progid}\n"; + } + $res .= "\n"; + return $res; +} + +sub Parse($$) +{ + my ($idl,$ndr_header) = @_; + my $res = ""; + + $res .= "#include \"librpc/gen_ndr/orpc.h\"\n" . + "#include \"$ndr_header\"\n\n"; + + foreach (@{$idl}) + { + if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) { + $res .="struct $_->{NAME};\n"; + } + } + + foreach (@{$idl}) + { + if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) { + $res.=ParseInterface($_); + } + + if ($_->{TYPE} eq "COCLASS") { + $res.=ParseCoClass($_); + } + } + + return $res; +} + +1; diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm new file mode 100644 index 0000000000..ca9f37a053 --- /dev/null +++ b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm @@ -0,0 +1,221 @@ +################################################### +# DCOM parser for Samba +# Basically the glue between COM and DCE/RPC with NDR +# Copyright jelmer@samba.org 2003-2005 +# released under the GNU GPL + +package Parse::Pidl::Samba4::COM::Proxy; + +use Parse::Pidl::Samba4::COM::Header; +use Parse::Pidl::Typelist qw(mapTypeName); +use Parse::Pidl::Util qw(has_property); + +use vars qw($VERSION); +$VERSION = '0.01'; + +use strict; + +my($res); + +sub ParseVTable($$) +{ + my ($interface, $name) = @_; + + # Generate the vtable + $res .="\tstruct $interface->{NAME}_vtable $name = {"; + + if (defined($interface->{BASE})) { + $res .= "\n\t\t{},"; + } + + my $data = $interface->{DATA}; + + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { + $res .= "\n\t\tdcom_proxy_$interface->{NAME}_$d->{NAME}"; + $res .= ","; + } + } + + $res .= "\n\t};\n\n"; +} + +sub ParseRegFunc($) +{ + my $interface = shift; + + $res .= "static NTSTATUS dcom_proxy_$interface->{NAME}_init(void) +{ + struct $interface->{NAME}_vtable *proxy_vtable = talloc(talloc_autofree_context(), struct $interface->{NAME}_vtable); +"; + + if (defined($interface->{BASE})) { + $res.= " + struct GUID base_iid; + const void *base_vtable; + + base_iid = ndr_table_$interface->{BASE}.syntax_id.uuid; + + base_vtable = dcom_proxy_vtable_by_iid(&base_iid); + if (base_vtable == NULL) { + DEBUG(0, (\"No proxy registered for base interface '$interface->{BASE}'\\n\")); + return NT_STATUS_FOOBAR; + } + + memcpy(&proxy_vtable, base_vtable, sizeof(struct $interface->{BASE}_vtable)); + +"; + } + foreach my $x (@{$interface->{DATA}}) { + next unless ($x->{TYPE} eq "FUNCTION"); + + $res .= "\tproxy_vtable->$x->{NAME} = dcom_proxy_$interface->{NAME}_$x->{NAME};\n"; + } + + $res.= " + proxy_vtable->iid = ndr_table_$interface->{NAME}.syntax_id.uuid; + + return dcom_register_proxy((struct IUnknown_vtable *)proxy_vtable); +}\n\n"; +} + +##################################################################### +# parse a function +sub ParseFunction($$) +{ + my ($interface, $fn) = @_; + my $name = $fn->{NAME}; + my $uname = uc $name; + + my $tn = mapTypeName($fn->{RETURN_TYPE}); + + $res.=" +static $tn dcom_proxy_$interface->{NAME}_$name(struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . Parse::Pidl::Samba4::COM::Header::GetArgumentProtoList($fn) . ") +{ + struct dcerpc_pipe *p; + NTSTATUS status = dcom_get_pipe(d, &p); + struct $name r; + struct rpc_request *req; + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + ZERO_STRUCT(r.in.ORPCthis); + r.in.ORPCthis.version.MajorVersion = COM_MAJOR_VERSION; + r.in.ORPCthis.version.MinorVersion = COM_MINOR_VERSION; +"; + + # Put arguments into r + foreach my $a (@{$fn->{ELEMENTS}}) { + next unless (has_property($a, "in")); + if (Parse::Pidl::Typelist::typeIs($a->{TYPE}, "INTERFACE")) { + $res .="\tNDR_CHECK(dcom_OBJREF_from_IUnknown(mem_ctx, &r.in.$a->{NAME}.obj, $a->{NAME}));\n"; + } else { + $res .= "\tr.in.$a->{NAME} = $a->{NAME};\n"; + } + } + + $res .=" + if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) { + NDR_PRINT_IN_DEBUG($name, &r); + } + + status = dcerpc_ndr_request(p, &d->ipid, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, &r); + + if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { + NDR_PRINT_OUT_DEBUG($name, r); + } + +"; + + # Put r info back into arguments + foreach my $a (@{$fn->{ELEMENTS}}) { + next unless (has_property($a, "out")); + + if (Parse::Pidl::Typelist::typeIs($a->{TYPE}, "INTERFACE")) { + $res .="\tNDR_CHECK(dcom_IUnknown_from_OBJREF(d->ctx, &$a->{NAME}, r.out.$a->{NAME}.obj));\n"; + } else { + $res .= "\t*$a->{NAME} = r.out.$a->{NAME};\n"; + } + + } + + if ($fn->{RETURN_TYPE} eq "NTSTATUS") { + $res .= "\tif (NT_STATUS_IS_OK(status)) status = r.out.result;\n"; + } + + $res .= + " + return r.out.result; +}\n\n"; +} + +##################################################################### +# parse the interface definitions +sub ParseInterface($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + $res = "/* DCOM proxy for $interface->{NAME} generated by pidl */\n\n"; + foreach my $d (@{$data}) { + ($d->{TYPE} eq "FUNCTION") && + ParseFunction($interface, $d); + } + + ParseRegFunc($interface); +} + +sub RegistrationFunction($$) +{ + my $idl = shift; + my $basename = shift; + + my $res = "\n\nNTSTATUS dcom_$basename\_init(void)\n"; + $res .= "{\n"; + $res .="\tNTSTATUS status = NT_STATUS_OK;\n"; + foreach my $interface (@{$idl}) { + next if $interface->{TYPE} ne "INTERFACE"; + next if not has_property($interface, "object"); + + my $data = $interface->{DATA}; + my $count = 0; + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { $count++; } + } + + next if ($count == 0); + + $res .= "\tstatus = dcom_$interface->{NAME}_init();\n"; + $res .= "\tif (NT_STATUS_IS_ERR(status)) {\n"; + $res .= "\t\treturn status;\n"; + $res .= "\t}\n\n"; + } + $res .= "\treturn status;\n"; + $res .= "}\n\n"; + + return $res; +} + +sub Parse($$) +{ + my ($pidl,$comh_filename) = @_; + my $res = ""; + + $res .= "#include \"includes.h\"\n" . + "#include \"lib/com/dcom/dcom.h\"\n" . + "#include \"$comh_filename\"\n" . + "#include \"librpc/rpc/dcerpc.h\"\n"; + + foreach (@{$pidl}) { + next if ($_->{TYPE} ne "INTERFACE"); + next if has_property($_, "local"); + next unless has_property($_, "object"); + + $res .= ParseInterface($_); + } + + return $res; +} + +1; diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm new file mode 100644 index 0000000000..150acbfde9 --- /dev/null +++ b/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm @@ -0,0 +1,327 @@ +################################################### +# DCOM stub boilerplate generator +# Copyright jelmer@samba.org 2004-2005 +# Copyright tridge@samba.org 2003 +# Copyright metze@samba.org 2004 +# released under the GNU GPL + +package Parse::Pidl::Samba4::COM::Stub; + +use Parse::Pidl::Util qw(has_property); +use strict; + +use vars qw($VERSION); +$VERSION = '0.01'; + +my($res); + +sub pidl($) +{ + $res .= shift; +} + +##################################################### +# generate the switch statement for function dispatch +sub gen_dispatch_switch($) +{ + my $data = shift; + + my $count = 0; + foreach my $d (@{$data}) { + next if ($d->{TYPE} ne "FUNCTION"); + + pidl "\tcase $count: {\n"; + if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") { + pidl "\t\tNTSTATUS result;\n"; + } + pidl "\t\tstruct $d->{NAME} *r2 = r;\n"; + pidl "\t\tif (DEBUGLEVEL > 10) {\n"; + pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_IN, r2);\n"; + pidl "\t\t}\n"; + if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") { + pidl "\t\tresult = vtable->$d->{NAME}(iface, mem_ctx, r2);\n"; + } else { + pidl "\t\tvtable->$d->{NAME}(iface, mem_ctx, r2);\n"; + } + pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n"; + pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} will reply async\\n\"));\n"; + pidl "\t\t}\n"; + pidl "\t\tbreak;\n\t}\n"; + $count++; + } +} + +##################################################### +# generate the switch statement for function reply +sub gen_reply_switch($) +{ + my $data = shift; + + my $count = 0; + foreach my $d (@{$data}) { + next if ($d->{TYPE} ne "FUNCTION"); + + pidl "\tcase $count: {\n"; + pidl "\t\tstruct $d->{NAME} *r2 = r;\n"; + pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n"; + pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} replied async\\n\"));\n"; + pidl "\t\t}\n"; + pidl "\t\tif (DEBUGLEVEL > 10 && dce_call->fault_code == 0) {\n"; + pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);\n"; + pidl "\t\t}\n"; + pidl "\t\tif (dce_call->fault_code != 0) {\n"; + pidl "\t\t\tDEBUG(2,(\"dcerpc_fault %s in $d->{NAME}\\n\", dcerpc_errstr(mem_ctx, dce_call->fault_code)));\n"; + pidl "\t\t}\n"; + pidl "\t\tbreak;\n\t}\n"; + $count++; + } +} + +##################################################################### +# produce boilerplate code for a interface +sub Boilerplate_Iface($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + my $name = $interface->{NAME}; + my $uname = uc $name; + my $uuid = Parse::Pidl::Util::make_str($interface->{PROPERTIES}->{uuid}); + my $if_version = $interface->{PROPERTIES}->{version}; + + pidl " +static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface) +{ +#ifdef DCESRV_INTERFACE_$uname\_BIND + return DCESRV_INTERFACE_$uname\_BIND(dce_call,iface); +#else + return NT_STATUS_OK; +#endif +} + +static void $name\__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface) +{ +#ifdef DCESRV_INTERFACE_$uname\_UNBIND + DCESRV_INTERFACE_$uname\_UNBIND(context, iface); +#else + return; +#endif +} + +static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r) +{ + NTSTATUS status; + uint16_t opnum = dce_call->pkt.u.request.opnum; + + dce_call->fault_code = 0; + + if (opnum >= dcerpc_table_$name.num_calls) { + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NET_WRITE_FAULT; + } + + *r = talloc_size(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size); + NT_STATUS_HAVE_NO_MEMORY(*r); + + /* unravel the NDR for the packet */ + status = dcerpc_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, *r); + if (!NT_STATUS_IS_OK(status)) { + dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + dce_call->fault_code = DCERPC_FAULT_NDR; + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) +{ + uint16_t opnum = dce_call->pkt.u.request.opnum; + struct GUID ipid = dce_call->pkt.u.request.object.object; + struct dcom_interface_p *iface = dcom_get_local_iface_p(&ipid); + const struct dcom_$name\_vtable *vtable = iface->vtable; + + switch (opnum) { +"; + gen_dispatch_switch($data); + +pidl " + default: + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + break; + } + + if (dce_call->fault_code != 0) { + dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) +{ + uint16_t opnum = dce_call->pkt.u.request.opnum; + + switch (opnum) { +"; + gen_reply_switch($data); + +pidl " + default: + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + break; + } + + if (dce_call->fault_code != 0) { + dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r) +{ + NTSTATUS status; + uint16_t opnum = dce_call->pkt.u.request.opnum; + + status = dcerpc_table_$name.calls[opnum].ndr_push(push, NDR_OUT, r); + if (!NT_STATUS_IS_OK(status)) { + dce_call->fault_code = DCERPC_FAULT_NDR; + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static const struct dcesrv_interface $name\_interface = { + .name = \"$name\", + .uuid = $uuid, + .if_version = $if_version, + .bind = $name\__op_bind, + .unbind = $name\__op_unbind, + .ndr_pull = $name\__op_ndr_pull, + .dispatch = $name\__op_dispatch, + .reply = $name\__op_reply, + .ndr_push = $name\__op_ndr_push +}; + +"; +} + +##################################################################### +# produce boilerplate code for an endpoint server +sub Boilerplate_Ep_Server($) +{ + my($interface) = shift; + my $name = $interface->{NAME}; + my $uname = uc $name; + + pidl " +static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server) +{ + int i; + + for (i=0;icount;i++) { + NTSTATUS ret; + const char *name = dcerpc_table_$name.endpoints->names[i]; + + ret = dcesrv_interface_register(dce_ctx, name, &$name\_interface, NULL); + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(1,(\"$name\_op_init_server: failed to register endpoint \'%s\'\\n\",name)); + return ret; + } + } + + return NT_STATUS_OK; +} + +static BOOL $name\__op_interface_by_uuid(struct dcesrv_interface *iface, const char *uuid, uint32_t if_version) +{ + if (dcerpc_table_$name.if_version == if_version && + strcmp(dcerpc_table_$name.uuid, uuid)==0) { + memcpy(iface,&dcerpc_table_$name, sizeof(*iface)); + return True; + } + + return False; +} + +static BOOL $name\__op_interface_by_name(struct dcesrv_interface *iface, const char *name) +{ + if (strcmp(dcerpc_table_$name.name, name)==0) { + memcpy(iface,&dcerpc_table_$name, sizeof(*iface)); + return True; + } + + return False; +} + +NTSTATUS dcerpc_server_$name\_init(void) +{ + NTSTATUS ret; + struct dcesrv_endpoint_server ep_server; + + /* fill in our name */ + ep_server.name = \"$name\"; + + /* fill in all the operations */ + ep_server.init_server = $name\__op_init_server; + + ep_server.interface_by_uuid = $name\__op_interface_by_uuid; + ep_server.interface_by_name = $name\__op_interface_by_name; + + /* register ourselves with the DCERPC subsystem. */ + ret = dcerpc_register_ep_server(&ep_server); + + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(0,(\"Failed to register \'$name\' endpoint server!\\n\")); + return ret; + } + + return ret; +} + +"; +} + +##################################################################### +# dcom interface stub from a parsed IDL structure +sub ParseInterface($) +{ + my($interface) = shift; + + return "" if has_property($interface, "local"); + + my($data) = $interface->{DATA}; + my $count = 0; + + $res = ""; + + if (!defined $interface->{PROPERTIES}->{uuid}) { + return $res; + } + + if (!defined $interface->{PROPERTIES}->{version}) { + $interface->{PROPERTIES}->{version} = "0.0"; + } + + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { $count++; } + } + + if ($count == 0) { + return $res; + } + + $res = "/* dcom interface stub generated by pidl */\n\n"; + Boilerplate_Iface($interface); + Boilerplate_Ep_Server($interface); + + return $res; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm b/pidl/lib/Parse/Pidl/Samba4/EJS.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm rename to pidl/lib/Parse/Pidl/Samba4/EJS.pm diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm similarity index 98% rename from source4/pidl/lib/Parse/Pidl/Samba4/Header.pm rename to pidl/lib/Parse/Pidl/Samba4/Header.pm index 2e77ff01b8..611f0adb92 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -334,10 +334,10 @@ sub HeaderFunction($) sub HeaderImport { my @imports = @_; - foreach (@imports) { - s/\.idl\"$//; - s/^\"//; - pidl choose_header("librpc/gen_ndr/$_\.h", "gen_ndr/$_.h") . "\n"; + foreach my $import (@imports) { + $import = unmake_str($import); + $import =~ s/\.idl$//; + pidl choose_header("librpc/gen_ndr/$import\.h", "gen_ndr/$import.h") . "\n"; } } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm rename to pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm similarity index 99% rename from source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm rename to pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 745777d012..fb73075f1a 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -13,7 +13,7 @@ require Exporter; use strict; use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); -use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid); +use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str); use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::Samba4 qw(is_intree choose_header); @@ -2225,6 +2225,20 @@ sub AuthServiceStruct($$$) $self->pidl(""); } +sub FunctionCallEntry($$) +{ + my ($self, $d) = @_; + return if not defined($d->{OPNUM}); + $self->pidl("\t{"); + $self->pidl("\t\t\"$d->{NAME}\","); + $self->pidl("\t\tsizeof(struct $d->{NAME}),"); + $self->pidl("\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},"); + $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},"); + $self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},"); + $self->pidl("\t\t".($d->{ASYNC}?"true":"false").","); + $self->pidl("\t},"); +} + ##################################################################### # produce a function call table sub FunctionTable($$) @@ -2237,16 +2251,9 @@ sub FunctionTable($$) return unless defined ($interface->{PROPERTIES}->{uuid}); $self->pidl("static const struct ndr_interface_call $interface->{NAME}\_calls[] = {"); - foreach my $d (@{$interface->{FUNCTIONS}}) { - next if not defined($d->{OPNUM}); - $self->pidl("\t{"); - $self->pidl("\t\t\"$d->{NAME}\","); - $self->pidl("\t\tsizeof(struct $d->{NAME}),"); - $self->pidl("\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},"); - $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},"); - $self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},"); - $self->pidl("\t\t".($d->{ASYNC}?"true":"false").","); - $self->pidl("\t},"); + + foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) { + $self->FunctionCallEntry($d); $count++; } $self->pidl("\t{ NULL, 0, NULL, NULL, NULL, false }"); @@ -2298,8 +2305,8 @@ sub HeaderImport my $self = shift; my @imports = @_; foreach (@imports) { - s/\.idl\"$//; - s/^\"//; + $_ = unmake_str($_); + s/\.idl$//; $self->pidl(choose_header("librpc/gen_ndr/ndr_$_\.h", "gen_ndr/ndr_$_.h")); } } @@ -2355,7 +2362,7 @@ sub HeaderInterface($$$) foreach (@{$interface->{FUNCTIONS}}) { next if has_property($_, "noopnum"); - next if grep(/$_->{NAME}/,@{$interface->{INHERITED_FUNCTIONS}}); + next if grep(/^$_->{NAME}$/,@{$interface->{INHERITED_FUNCTIONS}}); my $u_name = uc $_->{NAME}; my $val = sprintf("0x%02x", $count); diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm rename to pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm similarity index 97% rename from source4/pidl/lib/Parse/Pidl/Samba4/Python.pm rename to pidl/lib/Parse/Pidl/Samba4/Python.pm index 60d0dafc8a..fc64c35fca 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -9,8 +9,9 @@ use Exporter; @ISA = qw(Exporter); use strict; +use Parse::Pidl qw(warning fatal); use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias); -use Parse::Pidl::Util qw(has_property ParseExpr); +use Parse::Pidl::Util qw(has_property ParseExpr unmake_str); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::CUtil qw(get_value_of get_pointer_to); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); @@ -59,8 +60,8 @@ sub Import my $self = shift; my @imports = @_; foreach (@imports) { - s/\.idl\"$//; - s/^\"//; + $_ = unmake_str($_); + s/\.idl$//; $self->pidl_hdr("#include \"librpc/gen_ndr/py_$_\.h\"\n"); } } @@ -846,7 +847,7 @@ sub ConvertObjectFromPythonData($$$$$$) return; } - if ($actual_ctype->{TYPE} eq "STRUCT") { + if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { $self->pidl("PY_CHECK_TYPE($ctype->{NAME}, $cvar, $fail);"); $self->assign($target, "py_talloc_get_ptr($cvar)"); return; @@ -889,7 +890,7 @@ sub ConvertObjectFromPythonData($$$$$$) return; } - die("unknown type ".mapTypeName($ctype) . ": $cvar"); + fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); } @@ -1025,11 +1026,13 @@ sub ConvertObjectToPythonData($$$$$) return $self->ConvertScalarToPython(Parse::Pidl::Typelist::bitmap_type_fn($actual_ctype), $cvar); } elsif ($actual_ctype->{TYPE} eq "SCALAR") { return $self->ConvertScalarToPython($actual_ctype->{NAME}, $cvar); - } elsif ($actual_ctype->{TYPE} eq "STRUCT") { + } elsif ($actual_ctype->{TYPE} eq "UNION") { + fatal($ctype, "union without discriminant: " . mapTypeName($ctype) . ": $cvar"); + } elsif ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { return "py_talloc_import_ex(&$ctype->{NAME}_Type, $mem_ctx, $cvar)"; } - die("unknown type ".mapTypeName($ctype) . ": $cvar"); + fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); } sub fail_on_null($$$) @@ -1170,6 +1173,7 @@ sub Parse($$$$$) $self->pidl("{"); $self->indent; $self->pidl("PyObject *m;"); + $self->pidl("NTSTATUS status;"); $self->pidl(""); foreach (@{$self->{ready_types}}) { @@ -1205,6 +1209,15 @@ sub Parse($$$$$) $self->pidl("PyModule_AddObject(m, \"$object_name\", $c_name);"); } + $self->pidl(""); + $self->pidl("status = dcerpc_init();"); + $self->pidl("if (!NT_STATUS_IS_OK(status)) {"); + $self->indent; + $self->pidl("PyErr_SetNTSTATUS(status);"); + $self->pidl("return;"); + $self->deindent; + $self->pidl("}"); + $self->deindent; $self->pidl("}"); return ($self->{res_hdr}, $self->{res}); diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm b/pidl/lib/Parse/Pidl/Samba4/SWIG.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm rename to pidl/lib/Parse/Pidl/Samba4/SWIG.pm diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/pidl/lib/Parse/Pidl/Samba4/TDR.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4/TDR.pm rename to pidl/lib/Parse/Pidl/Samba4/TDR.pm diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Template.pm b/pidl/lib/Parse/Pidl/Samba4/Template.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Samba4/Template.pm rename to pidl/lib/Parse/Pidl/Samba4/Template.pm diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm similarity index 96% rename from source4/pidl/lib/Parse/Pidl/Typelist.pm rename to pidl/lib/Parse/Pidl/Typelist.pm index 8ba1ae47af..c5c458ac6b 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/pidl/lib/Parse/Pidl/Typelist.pm @@ -245,7 +245,7 @@ sub mapType($$) return mapType($t->{DATA}, $n) if ($t->{TYPE} eq "TYPEDEF"); return mapScalarType($n) if ($t->{TYPE} eq "SCALAR"); return "enum $n" if ($t->{TYPE} eq "ENUM"); - return "struct $n" if ($t->{TYPE} eq "STRUCT"); + return "struct $n" if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "INTERFACE"); return "union $n" if ($t->{TYPE} eq "UNION"); return mapScalarType(bitmap_type_fn($t)) if ($t->{TYPE} eq "BITMAP"); die("Unknown type $t->{TYPE}"); @@ -273,6 +273,13 @@ sub LoadIdl($) foreach my $x (@{$idl}) { next if $x->{TYPE} ne "INTERFACE"; + # DCOM interfaces can be types as well + addType({ + NAME => $x->{NAME}, + TYPE => "TYPEDEF", + DATA => $x + }) if (has_property($x, "object")); + foreach my $y (@{$x->{DATA}}) { addType($y) if ( $y->{TYPE} eq "TYPEDEF" diff --git a/source4/pidl/lib/Parse/Pidl/Util.pm b/pidl/lib/Parse/Pidl/Util.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Util.pm rename to pidl/lib/Parse/Pidl/Util.pm diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm rename to pidl/lib/Parse/Pidl/Wireshark/Conformance.pm diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm similarity index 100% rename from source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm rename to pidl/lib/Parse/Pidl/Wireshark/NDR.pm diff --git a/source4/pidl/lib/Parse/Yapp/Driver.pm b/pidl/lib/Parse/Yapp/Driver.pm similarity index 100% rename from source4/pidl/lib/Parse/Yapp/Driver.pm rename to pidl/lib/Parse/Yapp/Driver.pm diff --git a/source4/pidl/pidl b/pidl/pidl similarity index 94% rename from source4/pidl/pidl rename to pidl/pidl index b7a22f0499..577db0a53f 100755 --- a/source4/pidl/pidl +++ b/pidl/pidl @@ -17,7 +17,7 @@ pidl - An IDL compiler written in Perl pidl --help -pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--ejs[=OUTPUT]] [--python[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [--typelib=[OUTPUT]] [.idl]... +pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--python[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [--typelib=[OUTPUT]] [.idl]... =head1 DESCRIPTION @@ -409,6 +409,7 @@ use Getopt::Long; use File::Basename; use Parse::Pidl qw ( $VERSION ); use Parse::Pidl::Util; +use Parse::Pidl::ODL; ##################################################################### # save a data structure into a file @@ -477,12 +478,13 @@ my($opt_ndr_parser); my($opt_tdr_parser); my($opt_ws_parser); my($opt_swig); -my($opt_ejs); my($opt_python); my($opt_quiet) = 0; my($opt_outputdir) = '.'; my($opt_verbose) = 0; my($opt_warn_compat) = 0; +my($opt_dcom_proxy); +my($opt_com_header); ######################################### # display help text @@ -518,11 +520,12 @@ Samba 4 output: --ndr-parser[=OUTFILE] create a C NDR parser [ndr_BASENAME.c] --client[=OUTFILE] create a C NDR client [ndr_BASENAME_c.c] --tdr-parser[=OUTFILE] create a C TDR parser [tdr_BASENAME.c] - --ejs[=OUTFILE] create ejs wrapper file [BASENAME_ejs.c] --python[=OUTFILE] create python wrapper file [py_BASENAME.c] --swig[=OUTFILE] create swig wrapper file [BASENAME.i] --server[=OUTFILE] create server boilerplate [ndr_BASENAME_s.c] --template print a template for a pipe + --dcom-proxy[=OUTFILE] create DCOM proxy [ndr_BASENAME_p.c] + --com-header[=OUTFILE] create header for COM [com_BASENAME.h] Samba 3 output: --samba3-ndr-client[=OUTF] create client calls for Samba3 @@ -562,10 +565,11 @@ my $result = GetOptions ( 'ndr-parser:s' => \$opt_ndr_parser, 'client:s' => \$opt_client, 'ws-parser:s' => \$opt_ws_parser, - 'ejs' => \$opt_ejs, 'python' => \$opt_python, 'diff' => \$opt_diff, 'swig:s' => \$opt_swig, + 'dcom-proxy:s' => \$opt_dcom_proxy, + 'com-header:s' => \$opt_com_header, 'quiet' => \$opt_quiet, 'verbose' => \$opt_verbose, 'warn-compat' => \$opt_warn_compat, @@ -605,10 +609,11 @@ sub process_file($) $pidl = Parse::Pidl::IDL::parse_file($idl_file, \@opt_incdirs); defined @$pidl || die "Failed to parse $idl_file"; - require Parse::Pidl::Typelist; - Parse::Pidl::Typelist::LoadIdl($pidl); } - + + require Parse::Pidl::Typelist; + Parse::Pidl::Typelist::LoadIdl($pidl); + if (defined($opt_dump_idl_tree)) { my($pidl_file) = ($opt_dump_idl_tree or "$outputdir/$basename.pidl"); SaveStructure($pidl_file, $pidl) or die "Failed to save $pidl_file\n"; @@ -626,17 +631,36 @@ sub process_file($) unlink($tempfile); } + my $comh_filename = ($opt_com_header or "$outputdir/com_$basename.h"); + if (defined($opt_com_header)) { + require Parse::Pidl::Samba4::COM::Header; + my $res = Parse::Pidl::Samba4::COM::Header::Parse($pidl,"$outputdir/ndr_$basename.h"); + if ($res) { + FileSave($comh_filename, $res); + } + } + + if (defined($opt_dcom_proxy)) { + require Parse::Pidl::Samba4::COM::Proxy; + my $res = Parse::Pidl::Samba4::COM::Proxy::Parse($pidl,$comh_filename); + if ($res) { + my ($client) = ($opt_dcom_proxy or "$outputdir/$basename\_p.c"); + FileSave($client, $res); + } + } + if ($opt_warn_compat) { require Parse::Pidl::Compat; Parse::Pidl::Compat::Check($pidl); } + $pidl = Parse::Pidl::ODL::ODL2IDL($pidl, dirname($idl_file), \@opt_incdirs); + if (defined($opt_ws_parser) or defined($opt_client) or defined($opt_server) or defined($opt_header) or defined($opt_ndr_parser) or - defined($opt_ejs) or defined($opt_python) or defined($opt_dump_ndr_tree) or defined($opt_samba3_header) or @@ -681,14 +705,6 @@ sub process_file($) FileSave($filename, $code); } - if (defined($opt_ejs)) { - require Parse::Pidl::Samba4::EJS; - my $generator = new Parse::Pidl::Samba4::EJS(); - my ($hdr,$prsr) = $generator->Parse($ndr, $h_filename); - FileSave("$outputdir/ndr_$basename\_ejs.c", $prsr); - FileSave("$outputdir/ndr_$basename\_ejs.h", $hdr); - } - if (defined($opt_python)) { require Parse::Pidl::Samba4::Python; my $generator = new Parse::Pidl::Samba4::Python(); diff --git a/source4/pidl/tests/Util.pm b/pidl/tests/Util.pm similarity index 100% rename from source4/pidl/tests/Util.pm rename to pidl/tests/Util.pm diff --git a/source4/pidl/tests/cutil.pl b/pidl/tests/cutil.pl similarity index 100% rename from source4/pidl/tests/cutil.pl rename to pidl/tests/cutil.pl diff --git a/source4/pidl/tests/dump.pl b/pidl/tests/dump.pl similarity index 100% rename from source4/pidl/tests/dump.pl rename to pidl/tests/dump.pl diff --git a/source4/pidl/tests/header.pl b/pidl/tests/header.pl similarity index 100% rename from source4/pidl/tests/header.pl rename to pidl/tests/header.pl diff --git a/source4/pidl/tests/ndr.pl b/pidl/tests/ndr.pl similarity index 100% rename from source4/pidl/tests/ndr.pl rename to pidl/tests/ndr.pl diff --git a/source4/pidl/tests/ndr_align.pl b/pidl/tests/ndr_align.pl similarity index 100% rename from source4/pidl/tests/ndr_align.pl rename to pidl/tests/ndr_align.pl diff --git a/source4/pidl/tests/ndr_alloc.pl b/pidl/tests/ndr_alloc.pl similarity index 100% rename from source4/pidl/tests/ndr_alloc.pl rename to pidl/tests/ndr_alloc.pl diff --git a/source4/pidl/tests/ndr_array.pl b/pidl/tests/ndr_array.pl similarity index 100% rename from source4/pidl/tests/ndr_array.pl rename to pidl/tests/ndr_array.pl diff --git a/source4/pidl/tests/ndr_compat.pl b/pidl/tests/ndr_compat.pl similarity index 100% rename from source4/pidl/tests/ndr_compat.pl rename to pidl/tests/ndr_compat.pl diff --git a/source4/pidl/tests/ndr_deprecations.pl b/pidl/tests/ndr_deprecations.pl similarity index 100% rename from source4/pidl/tests/ndr_deprecations.pl rename to pidl/tests/ndr_deprecations.pl diff --git a/source4/pidl/tests/ndr_fullptr.pl b/pidl/tests/ndr_fullptr.pl similarity index 100% rename from source4/pidl/tests/ndr_fullptr.pl rename to pidl/tests/ndr_fullptr.pl diff --git a/source4/pidl/tests/ndr_refptr.pl b/pidl/tests/ndr_refptr.pl similarity index 100% rename from source4/pidl/tests/ndr_refptr.pl rename to pidl/tests/ndr_refptr.pl diff --git a/source4/pidl/tests/ndr_represent.pl b/pidl/tests/ndr_represent.pl similarity index 100% rename from source4/pidl/tests/ndr_represent.pl rename to pidl/tests/ndr_represent.pl diff --git a/source4/pidl/tests/ndr_simple.pl b/pidl/tests/ndr_simple.pl similarity index 100% rename from source4/pidl/tests/ndr_simple.pl rename to pidl/tests/ndr_simple.pl diff --git a/source4/pidl/tests/ndr_string.pl b/pidl/tests/ndr_string.pl similarity index 100% rename from source4/pidl/tests/ndr_string.pl rename to pidl/tests/ndr_string.pl diff --git a/source4/pidl/tests/ndr_tagtype.pl b/pidl/tests/ndr_tagtype.pl similarity index 100% rename from source4/pidl/tests/ndr_tagtype.pl rename to pidl/tests/ndr_tagtype.pl diff --git a/source4/pidl/tests/parse_idl.pl b/pidl/tests/parse_idl.pl similarity index 100% rename from source4/pidl/tests/parse_idl.pl rename to pidl/tests/parse_idl.pl diff --git a/source4/pidl/tests/samba-ejs.pl b/pidl/tests/samba-ejs.pl similarity index 100% rename from source4/pidl/tests/samba-ejs.pl rename to pidl/tests/samba-ejs.pl diff --git a/source4/pidl/tests/samba-ndr.pl b/pidl/tests/samba-ndr.pl similarity index 100% rename from source4/pidl/tests/samba-ndr.pl rename to pidl/tests/samba-ndr.pl diff --git a/source4/pidl/tests/samba3-cli.pl b/pidl/tests/samba3-cli.pl similarity index 100% rename from source4/pidl/tests/samba3-cli.pl rename to pidl/tests/samba3-cli.pl diff --git a/source4/pidl/tests/samba3-srv.pl b/pidl/tests/samba3-srv.pl old mode 100644 new mode 100755 similarity index 100% rename from source4/pidl/tests/samba3-srv.pl rename to pidl/tests/samba3-srv.pl diff --git a/source4/pidl/tests/tdr.pl b/pidl/tests/tdr.pl similarity index 100% rename from source4/pidl/tests/tdr.pl rename to pidl/tests/tdr.pl diff --git a/source4/pidl/tests/test_util.pl b/pidl/tests/test_util.pl similarity index 100% rename from source4/pidl/tests/test_util.pl rename to pidl/tests/test_util.pl diff --git a/source4/pidl/tests/typelist.pl b/pidl/tests/typelist.pl similarity index 100% rename from source4/pidl/tests/typelist.pl rename to pidl/tests/typelist.pl diff --git a/source4/pidl/tests/util.pl b/pidl/tests/util.pl similarity index 100% rename from source4/pidl/tests/util.pl rename to pidl/tests/util.pl diff --git a/source4/pidl/tests/wireshark-conf.pl b/pidl/tests/wireshark-conf.pl similarity index 100% rename from source4/pidl/tests/wireshark-conf.pl rename to pidl/tests/wireshark-conf.pl diff --git a/source4/pidl/tests/wireshark-ndr.pl b/pidl/tests/wireshark-ndr.pl similarity index 100% rename from source4/pidl/tests/wireshark-ndr.pl rename to pidl/tests/wireshark-ndr.pl diff --git a/prog_guide4.txt b/prog_guide4.txt index bba58b31b3..8d6ff56964 100644 --- a/prog_guide4.txt +++ b/prog_guide4.txt @@ -5,7 +5,9 @@ FROM A FEW PEOPLE. DON'T TAKE THIS AS THE FINAL VERSION YET. Samba4 Programming Guide ------------------------- +======================== + +.. contents:: The internals of Samba4 are quite different from previous versions of Samba, so even if you are an experienced Samba developer please take @@ -144,8 +146,7 @@ data is a bug waiting to happen. Static data is evil as it has the following consequences: - it makes code much less likely to be thread-safe - it makes code much less likely to be recursion-safe -- it leads to subtle side effects when the same code is called from - multiple places +- it leads to subtle side effects when the same code is called from multiple places - doesn't play well with shared libraries or plugins Static data is particularly evil in library code (such as our internal @@ -194,7 +195,7 @@ in the data and bss columns in "size" anyway (it will be included in How to use talloc ----------------- -Please see the separate document, source/lib/talloc/talloc_guide.txt +Please see the separate document, lib/talloc/talloc_guide.txt You _must_ read this if you want to program in Samba4. @@ -273,9 +274,9 @@ generating the right offsets. The same rule applies to strings. In many places in the SMB and MSRPC protocols complex strings are used on the wire, with complex rules about padding, format, alighment, termination etc. None of that -information is useful to a high level calling routine or to a backend -- its all just so much wire fluff. So, in Samba4 these strings are -just "char *" and are always in our internal multi-byte format (which +information is useful to a high level calling routine or to a backend - its +all just so much wire fluff. So, in Samba4 these strings are +just "char \*" and are always in our internal multi-byte format (which is usually UTF8). It is up to the parse functions to worry about translating the format and getting the padding right. @@ -580,13 +581,17 @@ DCERPC Handles The various handles that are used in the RPC servers should be created and fetch using the dcesrv_handle_* functions. -Use dcesrv_handle_new(struct dcesrv_connection *, uint8 handle_type) to obtain +Use dcesrv_handle_new(struct dcesrv_connection \*, uint8 handle_type) to obtain a new handle of the specified type. Handle types are unique within each pipe. -The handle can later be fetched again using -struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, struct policy_handle *p, uint8 handle_type) -and destroyed by dcesrv_handle_destroy(struct dcesrv_handle *). +The handle can later be fetched again using:: + + struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, struct policy_handle *p, uint8 handle_type) + +and destroyed by:: + + dcesrv_handle_destroy(struct dcesrv_handle *). User data should be stored in the 'data' member of the dcesrv_handle struct. @@ -646,7 +651,7 @@ file cannot be deleted until you reboot trans2 qpathinfo doesn't see the delete_pending flag correctly, but qfileinfo does! -get rid of pstring, fstring, strtok +get rid of strtok add programming documentation note about lp_set_cmdline() @@ -765,12 +770,10 @@ BUGS: no 137 resolution not possible should not fallback to anon when pass supplied should check pass-thu cap bit, and skip lots of tests - possibly allow the test suite to say "allow oversized replies" for - trans2 and other calls + possibly allow the test suite to say "allow oversized replies" for trans2 and other calls handle servers that don't have the setattre call in torture add max file coponent length test and max path len test - check for alloc failure in all core reply.c and trans2.c code where - allocation size depends on client parameter + check for alloc failure in all core reply.c and trans2.c code where allocation size depends on client parameter case-insenstive idea: all filenames on disk lowercase diff --git a/release-scripts/create-tarball b/release-scripts/create-tarball index 3463f012a5..04728d835d 100755 --- a/release-scripts/create-tarball +++ b/release-scripts/create-tarball @@ -7,7 +7,7 @@ OPT_TAG="" OPT_KEYID="" TOPDIR="`dirname $0`/.." -VER_H="${TOPDIR}/source/include/version.h" +VER_H="${TOPDIR}/source3/include/version.h" function exitOnError { @@ -38,7 +38,7 @@ function printUsage } ## -## Parse the command line options +## Parse the command line options ## function parseOptions @@ -115,7 +115,7 @@ function buildDocs rsync -av "${OPT_DOCSDIR}"/ docs/ exitOnError $? "Failed top copy docs from ${OPT_DOCSDIR}" - + return 0 fi @@ -163,23 +163,23 @@ function createReleaseTag ## ## Main driver ## -function main +function main { parseOptions "$@" exitOnError $? "Failed to parse options" - + cd $TOPDIR git-checkout ${OPT_BRANCH} exitOnError $? "Invalid branch name \"${OPT_BRANCH}\"" - (cd source && ./script/mkversion.sh) + (cd source3 && ./script/mkversion.sh) if [ ! -f $VER_H ]; then exitOnError 1 "Failed to find ${VER_H}!" fi - version=`grep SAMBA_VERSION_OFFICIAL_STRING $VER_H | awk '{print $3}'` - vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX $VER_H | awk '{print $3}'` + version=`grep "define SAMBA_VERSION_OFFICIAL_STRING" $VER_H | awk '{print $3}'` + vendor_version=`grep "define SAMBA_VERSION_VENDOR_SUFFIX" $VER_H | awk '{print $3}'` if [ -n "$vendor_version" ]; then version="$version-$vendor_version" fi @@ -198,7 +198,7 @@ function main buildDocs exitOnError $? "Failed to build documentation" - ( cd source && ./autogen.sh ) + ( cd source3 && ./autogen.sh ) cd .. tar cf samba-${version}.tar --exclude=.git* --exclude=CVS --exclude=.svn samba-${version} diff --git a/source4/selftest/README b/selftest/README similarity index 100% rename from source4/selftest/README rename to selftest/README diff --git a/source4/selftest/SocketWrapper.pm b/selftest/SocketWrapper.pm similarity index 100% rename from source4/selftest/SocketWrapper.pm rename to selftest/SocketWrapper.pm diff --git a/source4/selftest/Subunit.pm b/selftest/Subunit.pm similarity index 100% rename from source4/selftest/Subunit.pm rename to selftest/Subunit.pm diff --git a/source4/selftest/TODO b/selftest/TODO similarity index 100% rename from source4/selftest/TODO rename to selftest/TODO diff --git a/source4/selftest/output/buildfarm.pm b/selftest/output/buildfarm.pm similarity index 100% rename from source4/selftest/output/buildfarm.pm rename to selftest/output/buildfarm.pm diff --git a/source4/selftest/output/html.pm b/selftest/output/html.pm similarity index 100% rename from source4/selftest/output/html.pm rename to selftest/output/html.pm diff --git a/source4/selftest/output/plain.pm b/selftest/output/plain.pm similarity index 86% rename from source4/selftest/output/plain.pm rename to selftest/output/plain.pm index 4bec4e0fdc..82a73ab932 100644 --- a/source4/selftest/output/plain.pm +++ b/selftest/output/plain.pm @@ -48,10 +48,7 @@ sub start_testsuite($$) if ($self->{immediate}) { print "$out\n"; } else { - require Term::ReadKey; - my ($wchar, $hchar, $wpixels, $hpixels) = Term::ReadKey::GetTerminalSize(); - foreach (1..$wchar) { $out.= " "; } - print "\r".substr($out, 0, $wchar); + print "$out: "; } } @@ -94,6 +91,13 @@ sub end_testsuite($$$$$) $out .= $self->{test_output}->{$name}; } + if (not $self->{immediate}) { + if (not $unexpected) { + $out .= " ok\n"; + } else { + $out .= " " . uc($result) . "\n"; + } + } print $out; } @@ -120,6 +124,12 @@ sub end_test($$$$$) unless ($unexpected) { $self->{test_output}->{$self->{NAME}} = ""; + if (not $self->{immediate}) { + if ($result eq "failure") { print "f"; } + elsif ($result eq "skip") { print "s"; } + elsif ($result eq "success") { print "."; } + else { print "?($result)"; } + } return; } @@ -133,6 +143,13 @@ sub end_test($$$$$) print $self->{test_output}->{$self->{NAME}}; $self->{test_output}->{$self->{NAME}} = ""; } + + if (not $self->{immediate}) { + if ($result eq "error") { print "E"; } + elsif ($result eq "failure") { print "F"; } + elsif ($result eq "success") { print "S"; } + else { print "?"; } + } } sub summary($) @@ -171,7 +188,7 @@ sub summary($) } close(SUMMARY); - print "\nA summary with detailed informations can be found in:\n $self->{summaryfile}\n"; + print "\nA summary with detailed information can be found in:\n $self->{summaryfile}\n"; if ($#{$self->{suitesfailed}} == -1) { my $ok = $self->{statistics}->{TESTS_EXPECTED_OK} + diff --git a/source4/selftest/output/testresults.css b/selftest/output/testresults.css similarity index 100% rename from source4/selftest/output/testresults.css rename to selftest/output/testresults.css diff --git a/source4/selftest/selftest.pl b/selftest/selftest.pl similarity index 93% rename from source4/selftest/selftest.pl rename to selftest/selftest.pl index e86ccbe468..60eabe41d6 100755 --- a/source4/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -283,12 +283,12 @@ sub ShowHelp() print "Samba test runner Copyright (C) Jelmer Vernooij -Usage: $Script [OPTIONS] PREFIX +Usage: $Script [OPTIONS] TESTNAME-REGEX Generic options: --help this help page --target=samba[34]|win|kvm Samba version to target - --testlist=FILE file to read available tests from + --testlist=FILE file to read available tests from Paths: --prefix=DIR prefix to run tests in [st] @@ -296,14 +296,14 @@ Paths: --builddir=DIR output directory [.] Target Specific: - --socket-wrapper-pcap save traffic to pcap directories + --socket-wrapper-pcap save traffic to pcap directories --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that failed --socket-wrapper enable socket wrapper --expected-failures=FILE specify list of tests that is guaranteed to fail Samba4 Specific: - --ldap=openldap|fedora-ds back smbd onto specified ldap server + --ldap=openldap|fedora-ds back samba onto specified ldap server Samba3 Specific: --bindir=PATH path to binaries @@ -405,8 +405,8 @@ if (defined($ENV{RUN_FROM_BUILD_FARM}) and my $tls_enabled = not $opt_quick; $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no"); -$ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb"; -$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules"; +$ENV{LDB_MODULES_PATH} = "$old_pwd/source4/bin/modules/ldb"; +$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/source4/bin/modules"; sub prefix_pathvar($$) { my ($name, $newpath) = @_; @@ -416,10 +416,8 @@ sub prefix_pathvar($$) $ENV{$name} = $newpath; } } -prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig"); -# Required for smbscript: -prefix_pathvar("PATH", "$old_pwd/bin"); -prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python"); +prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/source4/bin/pkgconfig"); +prefix_pathvar("PYTHONPATH", "$old_pwd/source4/bin/python"); if ($opt_socket_wrapper_keep_pcap) { # Socket wrapper keep pcap implies socket wrapper pcap @@ -535,6 +533,7 @@ my $interfaces = join(',', ("127.0.0.6/8", "127.0.0.11/8")); my $conffile = "$prefix_abs/client/client.conf"; +$ENV{SMB_CONF_PATH} = $conffile; sub write_clientconf($$) { @@ -576,7 +575,6 @@ sub write_clientconf($$) } print CF " private dir = $prefix_abs/client/private - js include = $srcdir_abs/scripting/libjs name resolve order = bcast panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\% max xmit = 32K @@ -591,24 +589,9 @@ sub write_clientconf($$) close(CF); } -my @torture_options = (); -push (@torture_options, "--configfile=$conffile"); -# ensure any one smbtorture call doesn't run too long -push (@torture_options, "--maximum-runtime=$torture_maxtime"); -push (@torture_options, "--target=$opt_target"); -push (@torture_options, "--basedir=$prefix_abs"); -push (@torture_options, "--option=torture:progress=no") unless ($opt_verbose); -push (@torture_options, "--format=subunit"); -push (@torture_options, "--option=torture:quick=yes") if ($opt_quick); - -$ENV{TORTURE_OPTIONS} = join(' ', @torture_options); -print "OPTIONS $ENV{TORTURE_OPTIONS}\n"; - my @todo = (); my $testsdir = "$srcdir/selftest"; -$ENV{SMB_CONF_PATH} = "$conffile"; -$ENV{CONFIGURATION} = "--configfile=$conffile"; my %required_envs = (); @@ -643,6 +626,26 @@ if ($#testlists == -1) { die("No testlists specified"); } +$ENV{SELFTEST_PREFIX} = "$prefix_abs"; +if ($opt_socket_wrapper) { + $ENV{SELFTEST_INTERFACES} = $interfaces; +} else { + $ENV{SELFTEST_INTERFACES} = ""; +} +if ($opt_verbose) { + $ENV{SELFTEST_VERBOSE} = "1"; +} else { + $ENV{SELFTEST_VERBOSE} = ""; +} +if ($opt_quick) { + $ENV{SELFTEST_QUICK} = "1"; +} else { + $ENV{SELFTEST_QUICK} = ""; +} +$ENV{SELFTEST_TARGET} = $opt_target; +$ENV{SELFTEST_MAXTIME} = $torture_maxtime; +$ENV{SELFTEST_CONFFILE} = $conffile; + my @available = (); foreach my $fn (@testlists) { foreach (read_testlist($fn)) { @@ -812,7 +815,7 @@ if ($opt_testenv) { Welcome to the Samba4 Test environment '$testenv_name' This matches the client environment used in make test -smbd is pid `cat \$PIDDIR/smbd.pid` +server is pid `cat \$PIDDIR/samba.pid` Some useful environment variables: TORTURE_OPTIONS=\$TORTURE_OPTIONS diff --git a/source4/selftest/target/Kvm.pm b/selftest/target/Kvm.pm similarity index 100% rename from source4/selftest/target/Kvm.pm rename to selftest/target/Kvm.pm diff --git a/source4/selftest/target/Samba3.pm b/selftest/target/Samba3.pm similarity index 100% rename from source4/selftest/target/Samba3.pm rename to selftest/target/Samba3.pm diff --git a/source4/selftest/target/Samba4.pm b/selftest/target/Samba4.pm similarity index 97% rename from source4/selftest/target/Samba4.pm rename to selftest/target/Samba4.pm index 8835f69c6c..9364008ee2 100644 --- a/source4/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -116,20 +116,20 @@ sub check_or_start($$$) if (defined($ENV{SMBD_OPTIONS})) { $optarg.= " $ENV{SMBD_OPTIONS}"; } - my $ret = system("$valgrind $self->{bindir}/smbd $optarg $env_vars->{CONFIGURATION} -M single -i --leak-report-full"); + my $ret = system("$valgrind $self->{bindir}/samba $optarg $env_vars->{CONFIGURATION} -M single -i --leak-report-full"); if ($? == -1) { - print "Unable to start smbd: $ret: $!\n"; + print "Unable to start samba: $ret: $!\n"; exit 1; } unlink($env_vars->{SMBD_TEST_FIFO}); my $exit = $? >> 8; if ( $ret == 0 ) { - print "smbd exits with status $exit\n"; + print "samba exits with status $exit\n"; } elsif ( $ret & 127 ) { - print "smbd got signal ".($ret & 127)." and exits with $exit!\n"; + print "samba got signal ".($ret & 127)." and exits with $exit!\n"; } else { $ret = $? >> 8; - print "smbd failed with status $exit!\n"; + print "samba failed with status $exit!\n"; } exit $exit; } @@ -498,7 +498,7 @@ sub provision($$$$$$) { my ($self, $prefix, $server_role, $netbiosname, $netbiosalias, $swiface, $password) = @_; - my $smbd_loglevel = 1; + my $server_loglevel = 1; my $username = "administrator"; my $domain = "SAMBADOMAIN"; my $realm = "SAMBA.EXAMPLE.COM"; @@ -555,7 +555,6 @@ sub provision($$$$$$) lock dir = $lockdir setup directory = $self->{setupdir} modules dir = $self->{bindir}/modules - js include = $srcdir/scripting/libjs winbindd socket directory = $winbindd_socket_dir winbindd privileged socket directory = $winbindd_privileged_socket_dir ntp signd socket directory = $ntp_signd_socket_dir @@ -572,7 +571,7 @@ sub provision($$$$$$) ldb:nosync = true #We don't want to pass our self-tests if the PAC code is wrong gensec:require_pac = true - log level = $smbd_loglevel + log level = $server_loglevel [tmp] path = $tmpdir @@ -607,7 +606,7 @@ sub provision($$$$$$) cifs:server = $netbiosname cifs:share = tmp #There is no username specified here, instead the client is expected -#to log in with kerberos, and smbd will used delegated credentials. +#to log in with kerberos, and the serverwill use delegated credentials. [simple] path = $tmpdir @@ -829,8 +828,8 @@ sub provision_dc($$) $self->add_wins_config("$prefix/private") or die("Unable to add wins configuration"); - $ret->{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo"; - $ret->{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; + $ret->{SMBD_TEST_FIFO} = "$prefix/server_test.fifo"; + $ret->{SMBD_TEST_LOG} = "$prefix/server_test.log"; $ret->{SMBD_TEST_LOG_POS} = 0; return $ret; } @@ -842,8 +841,8 @@ sub teardown_env($$) close(DATA); - if (-f "$envvars->{PIDDIR}/smbd.pid" ) { - open(IN, "<$envvars->{PIDDIR}/smbd.pid") or die("unable to open smbd pid file"); + if (-f "$envvars->{PIDDIR}/samba.pid" ) { + open(IN, "<$envvars->{PIDDIR}/samba.pid") or die("unable to open server pid file"); $pid = ; close(IN); @@ -859,7 +858,7 @@ sub teardown_env($$) # If it is still around, kill it if ($count > 20) { - print "smbd process $pid took more than $count seconds to exit, killing\n"; + print "server process $pid took more than $count seconds to exit, killing\n"; kill 9, $pid; } } diff --git a/source4/selftest/target/Windows.pm b/selftest/target/Windows.pm similarity index 100% rename from source4/selftest/target/Windows.pm rename to selftest/target/Windows.pm diff --git a/source4/selftest/test_samba4.pl b/selftest/test_samba4.pl similarity index 100% rename from source4/selftest/test_samba4.pl rename to selftest/test_samba4.pl diff --git a/source4/selftest/test_subunit.pl b/selftest/test_subunit.pl similarity index 100% rename from source4/selftest/test_subunit.pl rename to selftest/test_subunit.pl diff --git a/source3/Makefile.in b/source3/Makefile.in index b67cfe8bb8..0e1d17f29e 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -56,6 +56,7 @@ PIDL_ARGS=@PIDL_ARGS@ TERMLDFLAGS=@TERMLDFLAGS@ TERMLIBS=@TERMLIBS@ PRINT_LIBS=@PRINT_LIBS@ +ZLIB_LIBS=@ZLIB_LIBS@ AUTH_LIBS=@AUTH_LIBS@ ACL_LIBS=@ACL_LIBS@ PASSDB_LIBS=@PASSDB_LIBS@ @@ -127,6 +128,7 @@ LOGFILEBASE = @logfilebase@ CONFIGFILE = $(CONFIGDIR)/smb.conf LMHOSTSFILE = $(CONFIGDIR)/lmhosts CTDBDIR = @ctdbdir@ +NCALRPCDIR = @ncalrpcdir@ # This is where smbpasswd et al go PRIVATEDIR = @privatedir@ @@ -150,12 +152,7 @@ CODEPAGEDIR = @codepagedir@ # the directory where pid files go PIDDIR = @piddir@ -FLAGS1 = $(CFLAGS) @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS) -FLAGS2 = -FLAGS3 = -FLAGS4 = -I$(CTDBDIR)/include -FLAGS5 = $(FLAGS1) $(FLAGS2) $(FLAGS3) $(FLAGS4) -FLAGS = $(ISA) $(FLAGS5) -I$(srcdir)/lib -D_SAMBA_BUILD_=3 +FLAGS = -I. -I$(srcdir) @FLAGS1@ @SAMBA_CPPFLAGS@ $(CPPFLAGS) -I$(CTDBDIR)/include $(ISA) -I$(srcdir)/lib -I.. -D_SAMBA_BUILD_=3 -I../source4 PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \ -DPRIVATE_DIR=\"$(PRIVATE_DIR)\" \ @@ -171,6 +168,7 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \ -DLOGFILEBASE=\"$(LOGFILEBASE)\" \ -DSHLIBEXT=\"@SHLIBEXT@\" \ -DCTDBDIR=\"$(CTDBDIR)\" \ + -DNCALRPCDIR=\"$(NCALRPCDIR)\" \ -DCONFIGDIR=\"$(CONFIGDIR)\" \ -DCODEPAGEDIR=\"$(CODEPAGEDIR)\" \ -DCACHEDIR=\"$(CACHEDIR)\" \ @@ -198,7 +196,7 @@ TORTURE_PROGS = bin/smbtorture@EXEEXT@ bin/msgtest@EXEEXT@ \ bin/locktest2@EXEEXT@ bin/nsstest@EXEEXT@ bin/vfstest@EXEEXT@ \ bin/pdbtest@EXEEXT@ bin/talloctort@EXEEXT@ bin/replacetort@EXEEXT@ \ bin/tdbtorture@EXEEXT@ \ - bin/smbconftort@EXEEXT@ + bin/smbconftort@EXEEXT@ bin/vlp@EXEEXT@ BIN_PROGS = @EXTRA_BIN_PROGS@ \ $(BIN_PROGS1) $(BIN_PROGS2) $(BIN_PROGS3) $(BIN_PROGS4) @@ -230,7 +228,7 @@ MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(IDMAP_MODULES) \ # object file lists ###################################################################### -TDB_LIB_OBJ = lib/util_tdb.o \ +TDB_LIB_OBJ = lib/util_tdb.o ../lib/util/util_tdb.o \ lib/dbwrap.o lib/dbwrap_tdb.o \ lib/dbwrap_ctdb.o \ lib/dbwrap_rbt.o @LIBTDB_STATIC@ @@ -249,25 +247,31 @@ SERVER_MUTEX_OBJ = lib/server_mutex.o PASSCHANGE_OBJ = libsmb/passchange.o -LIBNDR_DRSUAPI_OBJ = librpc/ndr/ndr_drsuapi.o \ - librpc/ndr/ndr_compression.o \ +LIBNDR_DRSUAPI_OBJ = ../librpc/ndr/ndr_drsuapi.o \ + ../librpc/ndr/ndr_compression.o \ librpc/gen_ndr/ndr_drsuapi.o \ + ../librpc/ndr/ndr_drsblobs.o \ librpc/gen_ndr/ndr_drsblobs.o -COMPRESSION_OBJ = lib/compression/mszip.o +ZLIB_OBJ = @ZLIB_OBJS@ + +COMPRESSION_OBJ = ../lib/compression/mszip.o \ + ../lib/compression/lzxpress.o \ + $(ZLIB_OBJ) DRSUAPI_OBJ = $(LIBNDR_DRSUAPI_OBJ) \ $(COMPRESSION_OBJ) -LIBNDR_OBJ = librpc/ndr/ndr_basic.o \ - librpc/ndr/ndr.o \ - librpc/ndr/ndr_misc.o \ +LIBNDR_OBJ = ../librpc/ndr/ndr_basic.o \ + ../librpc/ndr/ndr.o \ + ../librpc/ndr/ndr_misc.o \ librpc/gen_ndr/ndr_misc.o \ librpc/gen_ndr/ndr_security.o \ librpc/ndr/ndr_sec_helper.o \ librpc/ndr/ndr_string.o \ librpc/ndr/sid.o \ - librpc/ndr/uuid.o + ../librpc/ndr/uuid.o \ + librpc/ndr/util.o RPCCLIENT_NDR_OBJ = rpc_client/ndr.o @@ -312,29 +316,37 @@ LIBSAMBAUTIL_OBJ = @LIBTALLOC_STATIC@ \ $(SOCKET_WRAPPER_OBJ) \ $(NSS_WRAPPER_OBJ) -LIB_OBJ = $(LIBSAMBAUTIL_OBJ) \ +UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \ + ../lib/util/xfile.o ../lib/util/util_strlist.o \ + ../lib/util/util_file.o ../lib/util/data_blob.o \ + ../lib/util/util.o ../lib/util/fsusage.o \ + ../lib/util/params.o + +CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \ + ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \ + ../lib/crypto/md4.o + +LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \ lib/messages.o librpc/gen_ndr/ndr_messaging.o lib/messages_local.o \ lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o lib/talloc_stack.o \ - lib/interfaces.o lib/rbtree.o lib/memcache.o \ + lib/interfaces.o lib/memcache.o \ lib/util_transfer_file.o lib/async_req.o \ lib/async_sock.o \ $(TDB_LIB_OBJ) \ $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \ - lib/interface.o lib/md4.o \ - lib/pidfile.o \ - lib/signal.o lib/system.o lib/sendfile.o lib/recvfile.o lib/time.o \ - lib/ufc.o lib/genrand.o lib/username.o \ + lib/interface.o lib/pidfile.o \ + lib/system.o lib/sendfile.o lib/recvfile.o lib/time.o \ + lib/genrand.o lib/username.o \ lib/util_pw.o lib/access.o lib/smbrun.o \ - lib/bitmap.o lib/crc32.o lib/dprintf.o \ - lib/xfile.o lib/wins_srv.o $(UTIL_REG_OBJ) \ + lib/bitmap.o lib/dprintf.o $(UTIL_REG_OBJ) \ + lib/wins_srv.o \ lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \ - lib/util_unistr.o lib/util_file.o lib/data_blob.o \ + lib/util_unistr.o lib/util_file.o \ lib/util.o lib/util_sock.o lib/sock_exec.o lib/util_sec.o \ - lib/substitute.o lib/fsusage.o lib/dbwrap_util.o \ + lib/substitute.o lib/dbwrap_util.o \ lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \ lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \ - lib/md5.o lib/hmacmd5.o lib/arc4.o lib/iconv.o \ - lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \ + lib/iconv.o lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \ lib/adt_tree.o lib/gencache.o \ lib/module.o lib/events.o lib/ldap_escape.o @CHARSET_STATIC@ \ lib/secdesc.o lib/util_seaccess.o lib/secace.o lib/secacl.o \ @@ -350,7 +362,7 @@ READLINE_OBJ = lib/readline.o # Be sure to include them into your application POPT_LIB_OBJ = lib/popt_common.o -PARAM_WITHOUT_REG_OBJ = dynconfig.o param/loadparm.o param/params.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o +PARAM_WITHOUT_REG_OBJ = dynconfig.o param/loadparm.o param/util.o lib/sharesec.o lib/ldap_debug_handler.o PARAM_REG_ADD_OBJ = $(REG_SMBCONF_OBJ) $(LIBSMBCONF_OBJ) $(PRIVILEGES_BASIC_OBJ) PARAM_OBJ = $(PARAM_WITHOUT_REG_OBJ) $(PARAM_REG_ADD_OBJ) @@ -376,12 +388,14 @@ LIBADS_OBJ = libads/ldap.o libads/ldap_printer.o \ libads/ldap_schema.o libads/util.o libads/ndr.o LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o \ - librpc/ndr/ndr_krb5pac.o \ + ../librpc/ndr/ndr_krb5pac.o \ librpc/gen_ndr/ndr_krb5pac.o SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o -LIBNBT_OBJ = libcli/nbt/nbtname.o \ +LIBNBT_OBJ = ../libcli/nbt/nbtname.o \ + ../libcli/netlogon.o \ + ../libcli/ndr_netlogon.o \ librpc/gen_ndr/ndr_nbt.o \ librpc/gen_ndr/ndr_svcctl.o @@ -433,7 +447,7 @@ LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \ rpc_client/cli_svcctl.o \ rpc_client/init_samr.o \ librpc/rpc/dcerpc.o \ - librpc/rpc/binding.o + ../librpc/rpc/binding.o LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \ librpc/gen_ndr/cli_dfs.o \ @@ -623,6 +637,8 @@ VFS_TSMSM_OBJ = modules/vfs_tsmsm.o VFS_FILEID_OBJ = modules/vfs_fileid.o VFS_AIO_FORK_OBJ = modules/vfs_aio_fork.o VFS_SYNCOPS_OBJ = modules/vfs_syncops.o +VFS_ACL_XATTR_OBJ = modules/vfs_acl_xattr.o +VFS_SMB_TRAFFIC_ANALYZER_OBJ = modules/vfs_smb_traffic_analyzer.o PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o @@ -637,6 +653,7 @@ AUTH_SERVER_OBJ = auth/auth_server.o AUTH_UNIX_OBJ = auth/auth_unix.o AUTH_WINBIND_OBJ = auth/auth_winbind.o AUTH_SCRIPT_OBJ = auth/auth_script.o +AUTH_NETLOGOND_OBJ = auth/auth_netlogond.o AUTH_OBJ = auth/auth.o @AUTH_STATIC@ auth/auth_util.o auth/token_util.o \ auth/auth_compat.o auth/auth_ntlmssp.o \ @@ -731,7 +748,7 @@ SMBCONTROL_OBJ = utils/smbcontrol.o $(LOCKING_OBJ) $(PARAM_OBJ) \ SMBTREE_OBJ = utils/smbtree.o $(PARAM_OBJ) \ $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) \ $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \ - rpc_client/cli_pipe.o librpc/rpc/binding.o $(RPC_PARSE_OBJ2) \ + rpc_client/cli_pipe.o ../librpc/rpc/binding.o $(RPC_PARSE_OBJ2) \ $(RPC_CLIENT_OBJ1) \ $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(SMBLDAP_OBJ) $(LDB_OBJ) $(GROUPDB_OBJ) \ $(LIBMSRPC_GEN_OBJ) @@ -740,6 +757,10 @@ TESTPARM_OBJ = utils/testparm.o \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ $(LIBSAMBA_OBJ) +TEST_LP_LOAD_OBJ = param/test_lp_load.o \ + $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ + $(POPT_LIB_OBJ) $(LIBSAMBA_OBJ) + PASSWD_UTIL_OBJ = utils/passwd_util.o SMBPASSWD_OBJ = utils/smbpasswd.o $(PASSWD_UTIL_OBJ) $(PASSCHANGE_OBJ) \ @@ -811,7 +832,7 @@ LIBBIGBALLOFMUD_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(GROUPDB_OBJ) $(KRBCLIENT_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ) CLIENT_OBJ1 = client/client.o client/clitar.o rpc_client/cli_pipe.o \ - librpc/rpc/binding.o \ + ../librpc/rpc/binding.o \ client/dnsbrowse.o \ $(RPC_CLIENT_OBJ1) \ $(RPC_PARSE_OBJ2) @@ -899,7 +920,7 @@ SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) \ MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIB_NONSMBD_OBJ) \ - $(LIBNDR_GEN_OBJ0) + $(LIBNDR_GEN_OBJ0) $(ZLIB_LIBS) MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIB_NONSMBD_OBJ) \ @@ -907,7 +928,7 @@ MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ LOCKTEST_OBJ = torture/locktest.o $(PARAM_OBJ) $(LOCKING_OBJ) $(KRBCLIENT_OBJ) \ $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) \ - $(LIBNDR_GEN_OBJ0) + $(LIBNDR_GEN_OBJ0) $(ZLIB_LIBS) NSSTEST_OBJ = torture/nsstest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(LIB_NONSMBD_OBJ) \ @@ -926,7 +947,7 @@ LOG2PCAP_OBJ = utils/log2pcaphex.o LOCKTEST2_OBJ = torture/locktest2.o $(PARAM_OBJ) $(LOCKING_OBJ) $(LIBSMB_OBJ) \ $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \ - $(LIBNDR_GEN_OBJ0) + $(LIBNDR_GEN_OBJ0) $(ZLIB_LIBS) SMBCACLS_OBJ = utils/smbcacls.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(RPC_PARSE_OBJ) \ @@ -950,19 +971,24 @@ SHARESEC_OBJ = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSAMBA_OBJ) \ $(POPT_LIB_OBJ) -TALLOCTORT_OBJ = @tallocdir@/testsuite.o $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ - $(LIBSAMBA_OBJ) +TALLOCTORT_OBJ = @tallocdir@/testsuite.o @tallocdir@/testsuite_main.o \ + $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSAMBA_OBJ) -REPLACETORT_OBJ = lib/replace/test/testsuite.o \ - lib/replace/test/getifaddrs.o \ - lib/replace/test/os2_delete.o \ - lib/replace/test/strptime.o \ +REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \ + @libreplacedir@/test/getifaddrs.o \ + @libreplacedir@/test/os2_delete.o \ + @libreplacedir@/test/strptime.o \ + @libreplacedir@/test/main.o \ $(LIBREPLACE_OBJ) -NDRDUMP_OBJ = librpc/tools/ndrdump.o \ +NDRDUMP_OBJ = ../librpc/tools/ndrdump.o \ $(PARAM_OBJ) $(LIBNDR_GEN_OBJ) \ $(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \ - librpc/gen_ndr/ndr_svcctl.o + $(LIBNDR_DRSUAPI_OBJ) $(COMPRESSION_OBJ) \ + librpc/gen_ndr/ndr_svcctl.o \ + librpc/gen_ndr/tables.o ../librpc/ndr/ndr_table.o \ + ../librpc/ndr/ndr_krb5pac.o \ + librpc/gen_ndr/ndr_krb5pac.o libsmb/asn1.o DEBUG2HTML_OBJ = utils/debug2html.o utils/debugparse.o @@ -984,6 +1010,18 @@ IDMAP_OBJ = winbindd/idmap.o winbindd/idmap_util.o @IDMAP_STATIC@ NSS_INFO_OBJ = winbindd/nss_info.o @NSS_INFO_STATIC@ +IDMAP_HASH_OBJ = \ + winbindd/idmap_hash/idmap_hash.o \ + winbindd/idmap_hash/mapfile.o + +IDMAP_ADEX_OBJ = \ + winbindd/idmap_adex/idmap_adex.o \ + winbindd/idmap_adex/cell_util.o \ + winbindd/idmap_adex/likewise_cell.o \ + winbindd/idmap_adex/provider_unified.o \ + winbindd/idmap_adex/gc_util.o \ + winbindd/idmap_adex/domain_util.o + WINBINDD_OBJ1 = \ winbindd/winbindd.o \ winbindd/winbindd_user.o \ @@ -1059,10 +1097,10 @@ LDBDEL_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbdel.o LDBMODIFY_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbmodify.o WINBIND_KRB5_LOCATOR_OBJ1 = nsswitch/winbind_krb5_locator.o -WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(WBCOMMON_OBJ) $(LIBREPLACE_OBJ) +WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(LIBREPLACE_OBJ) -POPT_OBJ=popt/findme.o popt/popt.o popt/poptconfig.o \ - popt/popthelp.o popt/poptparse.o +POPT_OBJ=../lib/popt/findme.o ../lib/popt/popt.o ../lib/popt/poptconfig.o \ + ../lib/popt/popthelp.o ../lib/popt/poptparse.o INIPARSER_OBJ = iniparser_build/iniparser.o iniparser_build/dictionary.o \ iniparser_build/strlib.o @@ -1091,7 +1129,7 @@ NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \ $(LIBNDR_GEN_OBJ0) $(LIBNDR_GEN_OBJ1) -VLP_OBJ1 = ../testsuite/printing/vlp.o $(RPC_CLIENT_OBJ1) $(RPC_PARSE_OBJ2) $(RPC_CLIENT_OBJ) librpc/rpc/binding.o +VLP_OBJ1 = printing/tests/vlp.o $(RPC_CLIENT_OBJ1) $(RPC_PARSE_OBJ2) $(RPC_CLIENT_OBJ) ../librpc/rpc/binding.o VLP_OBJ = $(VLP_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(LIBMSRPC_GEN_OBJ) \ @@ -1109,7 +1147,7 @@ RPC_OPEN_TCP_OBJ = torture/rpc_open_tcp.o \ $(RPC_PARSE_OBJ2) \ $(RPC_CLIENT_OBJ1) \ rpc_client/cli_pipe.o \ - librpc/rpc/binding.o \ + ../librpc/rpc/binding.o \ $(LIBMSRPC_GEN_OBJ) @@ -1127,7 +1165,9 @@ pam_smbpass: SHOWFLAGS bin/pam_smbpass.@SHLIBEXT@ pam_winbind: SHOWFLAGS bin/pam_winbind.@SHLIBEXT@ -torture:: SHOWFLAGS $(TORTURE_PROGS) +gpext_modules:: $(GPEXT_MODULES) + +torture:: SHOWFLAGS $(TORTURE_PROGS) smbtorture : SHOWFLAGS bin/smbtorture@EXEEXT@ @@ -1169,16 +1209,21 @@ modules:: SHOWFLAGS $(MODULES) ##################################################################### ## Perl IDL Compiler -IDL_FILES = lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ - srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \ - epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \ - dssetup.idl krb5pac.idl ntsvcs.idl libnetapi.idl drsuapi.idl drsblobs.idl \ - nbt.idl - -idl:: - @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ - srcdir="$(srcdir)" $(srcdir)/script/build_idl.sh $(PIDL_ARGS) - +samba3-idl:: + @PIDL_ARGS="$(PIDL_ARGS)" CPP="$(CPP)" PIDL="../pidl/pidl" \ + srcdir="$(srcdir)" $(srcdir)/script/build_idl.sh librpc/idl/lsa.idl \ + ../librpc/idl/dfs.idl ../librpc/idl/echo.idl ../librpc/idl/winreg.idl \ + ../librpc/idl/initshutdown.idl librpc/idl/srvsvc.idl ../librpc/idl/svcctl.idl \ + ../librpc/idl/eventlog.idl ../librpc/idl/wkssvc.idl librpc/idl/netlogon.idl \ + ../librpc/idl/notify.idl ../librpc/idl/epmapper.idl librpc/idl/messaging.idl \ + ../librpc/idl/xattr.idl ../librpc/idl/misc.idl librpc/idl/samr.idl \ + ../librpc/idl/security.idl ../librpc/idl/dssetup.idl ../librpc/idl/krb5pac.idl \ + ../librpc/idl/ntsvcs.idl librpc/idl/libnetapi.idl ../librpc/idl/drsuapi.idl \ + ../librpc/idl/drsblobs.idl ../librpc/idl/nbt.idl + +librpc/gen_ndr/tables.c:: librpc/gen_ndr/*.h + @echo "Generating $@" + @$(PERL) ../librpc/tables.pl $^ > $@ ##################################################################### @@ -1190,7 +1235,7 @@ everything:: all libtalloc libsmbclient libnetapi debug2html smbfilter talloctor .SUFFIXES: .c .o .lo SHOWFLAGS:: - @echo "Using FLAGS = $(FLAGS)" + @echo "Using CFLAGS = $(CFLAGS)" @echo " PICFLAG = $(PICFLAG)" @echo " LIBS = $(LIBS)" @echo " LDFLAGS = $(LDFLAGS)" @@ -1208,11 +1253,11 @@ MAKEDIR = || exec false; \ exec false; fi || exec false # Run a static checker. -CHECK_CC = $(CC_CHECKER) -I. -I$(srcdir) $(FLAGS) $(PICFLAG) -c $< -o $@ +CHECK_CC = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) -c $< -o $@ # Compile a source file. -COMPILE_CC = $(CC) -I. -I$(srcdir) $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC = $(CC) $(CFLAGS) $(PICFLAG) -c $< -o $@ # Compile a source file with the installation paths defined. -COMPILE_CC_PATH = $(CC) -I. -I$(srcdir) $(PATH_FLAGS) $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC_PATH = $(CC) $(PATH_FLAGS) $(CFLAGS) $(PICFLAG) -c $< -o $@ COMPILE = $(COMPILE_CC) @@ -1226,7 +1271,7 @@ COMPILE = $(COMPILE_CC) @echo Compiling $*.c @$(COMPILE) && exit 0;\ echo "The following command failed:" 1>&2;\ - echo "$(COMPILE_CC)" 1>&2;\ + echo "$(subst ",\",$(COMPILE_CC))" 1>&2;\ $(COMPILE_CC) >/dev/null 2>&1 @BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@ @@ -1292,40 +1337,41 @@ bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARE $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) \ $(POPT_LIBS) @SMBD_LIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ - $(WINBIND_LIBS) + $(WINBIND_LIBS) $(ZLIB_LIBS) bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(POPT_LIBS) \ - $(KRB5LIBS) $(LDAP_LIBS) + $(KRB5LIBS) $(LDAP_LIBS) $(ZLIB_LIBS) bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINT_LIBS) \ $(AUTH_LIBS) $(LIBS) $(PASSDB_LIBS) $(POPT_LIBS) $(KRB5LIBS) \ - $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ - $(WINBIND_LIBS) + $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(DNSSD_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @LIBNETAPI_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ - @INIPARSERLIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(LIBNETAPI_LIBS) + @INIPARSERLIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(LIBNETAPI_LIBS) \ + $(ZLIB_LIBS) bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1335,7 +1381,7 @@ bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_ bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ @@ -1373,13 +1419,13 @@ bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTALLOC_SH @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(PASSDB_LIBS) \ $(DYNEXP) $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1391,7 +1437,7 @@ bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHAR @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBGET_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1402,7 +1448,7 @@ bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTAL @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) \ - $(LIBTDB_LIBS) + $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1425,25 +1471,25 @@ bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1459,19 +1505,19 @@ bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ - $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1479,7 +1525,7 @@ bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SH $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ @SMBD_LIBS@ $(NSCD_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ - $(WINBIND_LIBS) + $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @@ -1496,12 +1542,12 @@ bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTALLO @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/ndrdump@EXEEXT@: $(BINARY_PREREQS) $(NDRDUMP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NDRDUMP_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ - $(POPT_LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(POPT_LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ @@ -1512,7 +1558,7 @@ bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTALLO @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @@ -1698,6 +1744,7 @@ LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \ nsswitch/libwbclient/wbc_pwd.o \ nsswitch/libwbclient/wbc_idmap.o \ nsswitch/libwbclient/wbc_sid.o \ + nsswitch/libwbclient/wbc_guid.o \ nsswitch/libwbclient/wbc_pam.o LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) \ $(WBCOMMON_OBJ) \ @@ -2135,14 +2182,16 @@ bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTALLOC_ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ - $(PASSDB_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(PASSDB_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) \ + $(ZLIB_LIBS) bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ - $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) + $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) \ + $(ZLIB_LIBS) @WINBIND_NSS@: $(BINARY_PREREQS) $(WINBIND_NSS_OBJ) @echo "Linking $@" @@ -2156,15 +2205,15 @@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ -bin/winbind_krb5_locator.@SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) +bin/winbind_krb5_locator.@SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) @LIBWBCLIENT_SHARED@ @echo "Linking $@" - @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_KRB5_LOCATOR_OBJ) \ + @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_KRB5_LOCATOR_OBJ) $(WINBIND_LIBS) \ @SONAMEFLAG@`basename $@` -bin/pam_winbind.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_WINBIND_OBJ) +bin/pam_winbind.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_WINBIND_OBJ) @LIBTALLOC_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking shared library $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_WINBIND_OBJ) -lpam @INIPARSERLIBS@ \ - $(PAM_WINBIND_EXTRA_LIBS) @SONAMEFLAG@`basename $@` + $(PAM_WINBIND_EXTRA_LIBS) $(LIBTALLOC_LIBS) $(WINBIND_LIBS) @SONAMEFLAG@`basename $@` bin/builtin.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_BUILTIN_OBJ) @echo "Building plugin $@" @@ -2178,6 +2227,10 @@ bin/script.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_SCRIPT_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) $(AUTH_SCRIPT_OBJ) +bin/netlogond.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_NETLOGOND_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(AUTH_NETLOGOND_OBJ) + bin/smbserver.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_SERVER_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) $(AUTH_SERVER_OBJ) @@ -2214,6 +2267,14 @@ bin/ad.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_ad.o @echo "Building plugin $@" @$(SHLD_MODULE) winbindd/idmap_ad.o +bin/hash.@SHLIBEXT@: $(BINARY_PREREQS) $(IDMAP_HASH_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(IDMAP_HASH_OBJ) + +bin/adex.@SHLIBEXT@: $(BINARY_PREREQS) $(IDMAP_ADEX_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(IDMAP_ADEX_OBJ) + bin/tdb2.@SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_tdb2.o @echo "Building plugin $@" @$(SHLD_MODULE) winbindd/idmap_tdb2.o @@ -2381,6 +2442,14 @@ bin/aio_fork.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_AIO_FORK_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) $(VFS_AIO_FORK_OBJ) +bin/acl_xattr.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_ACL_XATTR_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(VFS_ACL_XATTR_OBJ) + +bin/smb_traffic_analyzer.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_SMB_TRAFFIC_ANALYZER_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(VFS_SMB_TRAFFIC_ANALYZER_OBJ) + bin/registry.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/registry.o @echo "Building plugin $@" @$(SHLD_MODULE) libgpo/gpext/registry.o @@ -2389,6 +2458,10 @@ bin/scripts.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/scripts.o @echo "Building plugin $@" @$(SHLD_MODULE) libgpo/gpext/scripts.o +bin/security.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/security.o + @echo "Building plugin $@" + @$(SHLD_MODULE) libgpo/gpext/security.o + ######################################################### ## IdMap NSS plugins @@ -2461,6 +2534,13 @@ bin/rpc_open_tcp@EXEEXT@: $(BINARY_PREREQS) $(RPC_OPEN_TCP_OBJ) @LIBTALLOC_SHARE $(LIBS) $(LIBTALLOC_LIBS) @LIBTDB_SHARED@ $(WINBIND_LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) +bin/test_lp_load@EXEEXT@: $(BINARY_PREREQS) $(TEST_LP_LOAD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ + @echo "Linking $@" + @$(CC) $(FLAGS) -o $@ $(TEST_LP_LOAD_OBJ) \ + $(LDFLAGS) $(DYNEEXP) $(LIBS) \ + $(LDAP_LIBS) \ + $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) + install:: installservers installbin @INSTALL_CIFSMOUNT@ @INSTALL_CIFSUPCALL@ installman \ installscripts installdat installmodules @SWAT_INSTALL_TARGETS@ \ @INSTALL_PAM_MODULES@ installlibs @@ -2511,6 +2591,8 @@ installmodules:: modules installdirs @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(AUTHLIBDIR) domain.@SHLIBEXT@ trustdomain.@SHLIBEXT@ ntdomain.@SHLIBEXT@ @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(AUTHLIBDIR) builtin.@SHLIBEXT@ guest.@SHLIBEXT@ fixed_challenge.@SHLIBEXT@ name_to_ntstatus.@SHLIBEXT@ @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(NSSINFOLIBDIR) ../idmap/ad.@SHLIBEXT@ rfc2307.@SHLIBEXT@ sfu.@SHLIBEXT@ sfu20.@SHLIBEXT@ + @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(NSSINFOLIBDIR) ../idmap/adex.@SHLIBEXT@ adex.@SHLIBEXT@ + @$(SHELL) $(srcdir)/script/linkmodules.sh $(DESTDIR)$(NSSINFOLIBDIR) ../idmap/hash.@SHLIBEXT@ hash.@SHLIBEXT@ installscripts:: installdirs @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS_BIN) $(DESTDIR)$(BINDIR) $(SCRIPTS) @@ -2606,6 +2688,10 @@ uninstallpammodules:: # Toplevel clean files TOPFILES=dynconfig.o +cleanlibs:: + -rm -f ../lib/*/*.o ../lib/*/*/*.o \ + ../libcli/*.o ../libcli/*/*.o + clean:: cleanlibs -rm -f include/build_env.h -rm -f smbd/build_options.c @@ -2618,7 +2704,10 @@ clean:: cleanlibs $(MODULES) $(TORTURE_PROGS) \ $(EVERYTHING_PROGS) \ bin/timelimit \ - .headers.stamp */src/*.o + .headers.stamp */src/*.o \ + ../lib/*/*.o \ + ../libcli/*.o ../libcli/*/*.o \ + ../librpc/*/*.o -rm -rf t_dir include/build_env.h: script/build_env.sh @@ -2627,18 +2716,14 @@ include/build_env.h: script/build_env.sh > $(builddir)/include/build_env.h proto:: - @echo - @echo "NOTE: 'proto' is no longer a valid make target as proto.h" - @echo "and other prototype headers are not generated anymore." - @echo - -.PHONY: proto -etags: +etags:: etags `find $(srcdir) -name "*.[ch]"` + etags --append `find $(srcdir)/../lib -name "*.[ch]"` + etags --append `find $(srcdir)/../source4 -name "*.[ch]"` -ctags: - ctags `find $(srcdir) -name "*.[ch]"` +ctags:: + ctags `find $(srcdir)/.. -name "*.[ch]"` realclean:: clean -rm -f config.log bin/.dummy script/findsmb script/gen-8bit-gap.sh @@ -2722,13 +2807,23 @@ valgrindtest:: all torture timelimit VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all "${smbtorture4_path}" +# Check for Winbind struct 32/64bit padding +test_wbpad: + @echo "Testing winbind request/response structure for 32/64bit padding" + @./script/tests/wb_pad.sh || exit 1; ## ## Examples: ## -libsmbclient_examples: +libsmbclient_examples: libsmbclient $(MAKE) -C ../examples/libsmbclient -f Makefile.internal clean_libsmbclient_examples: $(MAKE) -C ../examples/libsmbclient -f Makefile.internal clean + +libnetapi_examples: libnetapi + $(MAKE) -C lib/netapi/examples + +clean_libnetapi_examples: + $(MAKE) -C lib/netapi/examples clean diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 754cb7a508..7f95656bef 100644 --- a/source3/auth/auth.c +++ b/source3/auth/auth.c @@ -459,8 +459,8 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) NTSTATUS nt_status; if (lp_auth_methods() - && !str_list_copy(talloc_tos(), &auth_method_list, - lp_auth_methods())) { + && !(auth_method_list = str_list_copy(talloc_tos(), + lp_auth_methods()))) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index c25e62ab80..f11dbe60ee 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -26,6 +26,71 @@ extern bool global_machine_password_needs_changing; static struct named_mutex *mutex; +/* + * Change machine password (called from main loop + * idle timeout. Must be done as root. + */ + +void attempt_machine_password_change(void) +{ + unsigned char trust_passwd_hash[16]; + time_t lct; + void *lock; + + if (!global_machine_password_needs_changing) { + return; + } + + if (lp_security() != SEC_DOMAIN) { + return; + } + + /* + * We're in domain level security, and the code that + * read the machine password flagged that the machine + * password needs changing. + */ + + /* + * First, open the machine password file with an exclusive lock. + */ + + lock = secrets_get_trust_account_lock(NULL, lp_workgroup()); + + if (lock == NULL) { + DEBUG(0,("attempt_machine_password_change: unable to lock " + "the machine account password for machine %s in " + "domain %s.\n", + global_myname(), lp_workgroup() )); + return; + } + + if(!secrets_fetch_trust_account_password(lp_workgroup(), + trust_passwd_hash, &lct, NULL)) { + DEBUG(0,("attempt_machine_password_change: unable to read the " + "machine account password for %s in domain %s.\n", + global_myname(), lp_workgroup())); + TALLOC_FREE(lock); + return; + } + + /* + * Make sure someone else hasn't already done this. + */ + + if(time(NULL) < lct + lp_machine_password_timeout()) { + global_machine_password_needs_changing = false; + TALLOC_FREE(lock); + return; + } + + /* always just contact the PDC here */ + + change_trust_account_password( lp_workgroup(), NULL); + global_machine_password_needs_changing = false; + TALLOC_FREE(lock); +} + /** * Connect to a remote server for (inter)domain security authenticaion. * diff --git a/source3/auth/auth_netlogond.c b/source3/auth/auth_netlogond.c new file mode 100644 index 0000000000..a57f3b74a3 --- /dev/null +++ b/source3/auth/auth_netlogond.c @@ -0,0 +1,321 @@ +/* + Unix SMB/CIFS implementation. + Authenticate against a netlogon pipe listening on a unix domain socket + 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 . +*/ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_AUTH + +static NTSTATUS netlogond_validate(TALLOC_CTX *mem_ctx, + const struct auth_context *auth_context, + const char *ncalrpc_sockname, + uint8_t schannel_key[16], + const auth_usersupplied_info *user_info, + struct netr_SamInfo3 **pinfo3, + NTSTATUS *schannel_bind_result) +{ + struct rpc_pipe_client *p; + struct cli_pipe_auth_data *auth; + struct netr_SamInfo3 *info3 = NULL; + NTSTATUS status; + + *schannel_bind_result = NT_STATUS_OK; + + status = rpc_pipe_open_ncalrpc(talloc_tos(), ncalrpc_sockname, + &ndr_table_netlogon.syntax_id, &p); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpc_pipe_open_ncalrpc failed: %s\n", + nt_errstr(status))); + return status; + } + + status = rpccli_schannel_bind_data(p, lp_workgroup(), + PIPE_AUTH_LEVEL_PRIVACY, + schannel_key, &auth); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpccli_schannel_bind_data failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(p); + return status; + } + + status = rpc_pipe_bind(p, auth); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpc_pipe_bind failed: %s\n", nt_errstr(status))); + TALLOC_FREE(p); + *schannel_bind_result = status; + return status; + } + + /* + * We have to fake a struct dcinfo, so that + * rpccli_netlogon_sam_network_logon_ex can decrypt the session keys. + */ + + p->dc = talloc(p, struct dcinfo); + if (p->dc == NULL) { + DEBUG(0, ("talloc failed\n")); + TALLOC_FREE(p); + return NT_STATUS_NO_MEMORY; + } + + memcpy(p->dc->sess_key, schannel_key, 16); + + status = rpccli_netlogon_sam_network_logon_ex( + p, p, + user_info->logon_parameters,/* flags such as 'allow + * workstation logon' */ + global_myname(), /* server name */ + user_info->smb_name, /* user name logging on. */ + user_info->client_domain, /* domain name */ + user_info->wksta_name, /* workstation name */ + (uchar *)auth_context->challenge.data, /* 8 byte challenge. */ + user_info->lm_resp, /* lanman 24 byte response */ + user_info->nt_resp, /* nt 24 byte response */ + &info3); /* info3 out */ + + DEBUG(10, ("rpccli_netlogon_sam_network_logon_ex returned %s\n", + nt_errstr(status))); + + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(p); + return status; + } + + *pinfo3 = talloc_move(mem_ctx, &info3); + + TALLOC_FREE(p); + return NT_STATUS_OK; +} + +static char *mymachinepw(TALLOC_CTX *mem_ctx) +{ + fstring pwd; + const char *script; + char *to_free = NULL; + ssize_t nread; + int ret, fd; + + script = lp_parm_const_string( + GLOBAL_SECTION_SNUM, "auth_netlogond", "machinepwscript", + NULL); + + if (script == NULL) { + to_free = talloc_asprintf(talloc_tos(), "%s/%s", + get_dyn_SBINDIR(), "mymachinepw"); + script = to_free; + } + if (script == NULL) { + return NULL; + } + + ret = smbrun(script, &fd); + DEBUG(ret ? 0 : 3, ("mymachinepw: Running the command `%s' gave %d\n", + script, ret)); + TALLOC_FREE(to_free); + + if (ret != 0) { + return NULL; + } + + pwd[sizeof(pwd)-1] = '\0'; + + nread = read(fd, pwd, sizeof(pwd)-1); + close(fd); + + if (nread <= 0) { + DEBUG(3, ("mymachinepwd: Could not read password\n")); + return NULL; + } + + DEBUG(0, ("pwd: %d [%s]\n", (int)nread, pwd)); + + if (pwd[nread-1] == '\n') { + pwd[nread-1] = '\0'; + } + + return talloc_strdup(mem_ctx, pwd); +} + +static NTSTATUS check_netlogond_security(const struct auth_context *auth_context, + void *my_private_data, + TALLOC_CTX *mem_ctx, + const auth_usersupplied_info *user_info, + auth_serversupplied_info **server_info) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct netr_SamInfo3 *info3 = NULL; + struct rpc_pipe_client *p; + struct cli_pipe_auth_data *auth; + uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS; + char *plaintext_machinepw; + uint8_t machine_password[16]; + uint8_t schannel_key[16]; + NTSTATUS schannel_bind_result, status; + struct named_mutex *mutex; + const char *ncalrpcsock; + + ncalrpcsock = lp_parm_const_string( + GLOBAL_SECTION_SNUM, "auth_netlogond", "socket", NULL); + + if (ncalrpcsock == NULL) { + ncalrpcsock = talloc_asprintf(talloc_tos(), "%s/%s", + get_dyn_NCALRPCDIR(), "DEFAULT"); + } + + if (ncalrpcsock == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + if (!secrets_fetch_local_schannel_key(schannel_key)) { + goto new_key; + } + + status = netlogond_validate(talloc_tos(), auth_context, ncalrpcsock, + schannel_key, user_info, &info3, + &schannel_bind_result); + + DEBUG(10, ("netlogond_validate returned %s\n", nt_errstr(status))); + + if (NT_STATUS_IS_OK(status)) { + goto okay; + } + + if (NT_STATUS_IS_OK(schannel_bind_result)) { + /* + * This is a real failure from the DC + */ + goto done; + } + + new_key: + + mutex = grab_named_mutex(talloc_tos(), "LOCAL_SCHANNEL_KEY", 60); + if (mutex == NULL) { + DEBUG(10, ("Could not get mutex LOCAL_SCHANNEL_KEY\n")); + status = NT_STATUS_ACCESS_DENIED; + goto done; + } + + DEBUG(10, ("schannel bind failed, setting up new key\n")); + + status = rpc_pipe_open_ncalrpc(talloc_tos(), ncalrpcsock, + &ndr_table_netlogon.syntax_id, &p); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpc_pipe_open_ncalrpc failed: %s\n", + nt_errstr(status))); + goto done; + } + + status = rpccli_anon_bind_data(p, &auth); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpccli_anon_bind_data failed: %s\n", + nt_errstr(status))); + goto done; + } + + status = rpc_pipe_bind(p, auth); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpc_pipe_bind failed: %s\n", nt_errstr(status))); + goto done; + } + + TALLOC_FREE(auth); + + plaintext_machinepw = mymachinepw(talloc_tos()); + if (plaintext_machinepw == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + E_md4hash(plaintext_machinepw, machine_password); + + TALLOC_FREE(plaintext_machinepw); + + status = rpccli_netlogon_setup_creds( + p, global_myname(), lp_workgroup(), global_myname(), + global_myname(), machine_password, SEC_CHAN_BDC, &neg_flags); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("rpccli_netlogon_setup_creds failed: %s\n", + nt_errstr(status))); + goto done; + } + + memcpy(schannel_key, p->dc->sess_key, 16); + secrets_store_local_schannel_key(schannel_key); + + TALLOC_FREE(p); + + /* + * Retry the authentication with the mutex held. This way nobody else + * can step on our toes. + */ + + status = netlogond_validate(talloc_tos(), auth_context, ncalrpcsock, + schannel_key, user_info, &info3, + &schannel_bind_result); + + DEBUG(10, ("netlogond_validate returned %s\n", nt_errstr(status))); + + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + okay: + + status = make_server_info_info3(mem_ctx, user_info->smb_name, + user_info->domain, server_info, + info3); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("make_server_info_info3 failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(frame); + return status; + } + + status = NT_STATUS_OK; + + done: + TALLOC_FREE(frame); + return status; +} + +/* module initialisation */ +static NTSTATUS auth_init_netlogond(struct auth_context *auth_context, + const char *param, + auth_methods **auth_method) +{ + if (!make_auth_methods(auth_context, auth_method)) { + return NT_STATUS_NO_MEMORY; + } + + (*auth_method)->name = "netlogond"; + (*auth_method)->auth = check_netlogond_security; + return NT_STATUS_OK; +} + +NTSTATUS auth_netlogond_init(void) +{ + smb_register_auth(AUTH_INTERFACE_VERSION, "netlogond", + auth_init_netlogond); + return NT_STATUS_OK; +} diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c index 50bf15318b..7fe76fbfd6 100644 --- a/source3/auth/auth_sam.c +++ b/source3/auth/auth_sam.c @@ -176,7 +176,7 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx, /* check for expired password */ if (must_change_time < time(NULL) && must_change_time != 0) { DEBUG(1,("sam_account_ok: Account for user '%s' password expired!.\n", pdb_get_username(sampass))); - DEBUG(1,("sam_account_ok: Password expired at '%s' (%ld) unix time.\n", http_timestring(must_change_time), (long)must_change_time)); + DEBUG(1,("sam_account_ok: Password expired at '%s' (%ld) unix time.\n", http_timestring(talloc_tos(), must_change_time), (long)must_change_time)); return NT_STATUS_PASSWORD_EXPIRED; } } diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c index d6cd2ea3a8..e739fdaabe 100644 --- a/source3/auth/token_util.c +++ b/source3/auth/token_util.c @@ -84,7 +84,7 @@ NT_USER_TOKEN *get_root_nt_token( void ) cache_data = memcache_lookup_talloc( NULL, SINGLETON_CACHE_TALLOC, - data_blob_string_const("root_nt_token")); + data_blob_string_const_null("root_nt_token")); if (cache_data != NULL) { return talloc_get_type_abort( @@ -109,7 +109,7 @@ NT_USER_TOKEN *get_root_nt_token( void ) memcache_add_talloc( NULL, SINGLETON_CACHE_TALLOC, - data_blob_string_const("root_nt_token"), token); + data_blob_string_const_null("root_nt_token"), token); return token; } diff --git a/source3/autogen.sh b/source3/autogen.sh index 018944e684..61316a8f70 100755 --- a/source3/autogen.sh +++ b/source3/autogen.sh @@ -2,6 +2,18 @@ # Run this script to build samba from GIT. +while true; do + case $1 in + (--version-file) + VERSION_FILE=$2 + shift 2 + ;; + (*) + break + ;; + esac +done + ## insert all possible names (only works with ## autoconf 2.x) TESTAUTOHEADER="autoheader autoheader-2.53 autoheader2.50 autoheader259 autoheader253" @@ -48,12 +60,12 @@ if test "$AUTOCONFFOUND" = "0" -o "$AUTOHEADERFOUND" = "0"; then fi echo "$0: running script/mkversion.sh" -./script/mkversion.sh || exit 1 +./script/mkversion.sh $VERSION_FILE || exit 1 rm -rf autom4te*.cache rm -f configure include/config.h* -IPATHS="-Im4 -Ilib/replace" +IPATHS="-Im4 -I../lib/replace -I../source4" echo "$0: running $AUTOHEADER $IPATHS" $AUTOHEADER $IPATHS || exit 1 diff --git a/source3/client/client.c b/source3/client/client.c index 1c05c4035d..26badc4051 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -84,9 +84,9 @@ static struct sockaddr_storage dest_ss; static bool abort_mget = true; /* timing globals */ -SMB_BIG_UINT get_total_size = 0; +uint64_t get_total_size = 0; unsigned int get_total_time_ms = 0; -static SMB_BIG_UINT put_total_size = 0; +static uint64_t put_total_size = 0; static unsigned int put_total_time_ms = 0; /* totals globals */ @@ -1203,7 +1203,7 @@ static void do_mget(file_info *finfo, const char *dir) strlower_m(finfo->name); } - if (!directory_exist(finfo->name,NULL) && + if (!directory_exist(finfo->name) && mkdir(finfo->name,0777) != 0) { d_printf("failed to create directory %s\n",finfo->name); client_set_cur_dir(saved_curdir); @@ -1752,7 +1752,7 @@ static int cmd_put(void) SMB_STRUCT_STAT st; /* allow '-' to represent stdin jdblair, 24.jun.98 */ - if (!file_exist(lname,&st) && + if (!file_exist_stat(lname,&st) && (strcmp(lname,"-"))) { d_printf("%s does not exist\n",lname); return 1; @@ -2555,7 +2555,7 @@ static int cmd_lock(void) { TALLOC_CTX *ctx = talloc_tos(); char *buf = NULL; - SMB_BIG_UINT start, len; + uint64_t start, len; enum brl_type lock_type; int fnum; @@ -2584,14 +2584,14 @@ static int cmd_lock(void) return 1; } - start = (SMB_BIG_UINT)strtol(buf, (char **)NULL, 16); + start = (uint64_t)strtol(buf, (char **)NULL, 16); if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { d_printf("lock [r|w] \n"); return 1; } - len = (SMB_BIG_UINT)strtol(buf, (char **)NULL, 16); + len = (uint64_t)strtol(buf, (char **)NULL, 16); if (!cli_posix_lock(cli, fnum, start, len, true, lock_type)) { d_printf("lock failed %d: %s\n", fnum, cli_errstr(cli)); @@ -2604,7 +2604,7 @@ static int cmd_unlock(void) { TALLOC_CTX *ctx = talloc_tos(); char *buf = NULL; - SMB_BIG_UINT start, len; + uint64_t start, len; int fnum; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2618,14 +2618,14 @@ static int cmd_unlock(void) return 1; } - start = (SMB_BIG_UINT)strtol(buf, (char **)NULL, 16); + start = (uint64_t)strtol(buf, (char **)NULL, 16); if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { d_printf("unlock \n"); return 1; } - len = (SMB_BIG_UINT)strtol(buf, (char **)NULL, 16); + len = (uint64_t)strtol(buf, (char **)NULL, 16); if (!cli_posix_unlock(cli, fnum, start, len)) { d_printf("unlock failed %d: %s\n", fnum, cli_errstr(cli)); @@ -3038,7 +3038,7 @@ static int cmd_getfacl(void) break; case SMB_POSIX_ACL_GROUP: uorg = IVAL(retbuf,SMB_POSIX_ACL_HEADER_SIZE+(i*SMB_POSIX_ACL_ENTRY_SIZE)+2); - d_printf("group:%u", uorg); + d_printf("group:%u:", uorg); break; case SMB_POSIX_ACL_MASK: d_printf("mask::"); @@ -3075,7 +3075,7 @@ static int cmd_getfacl(void) break; case SMB_POSIX_ACL_GROUP: uorg = IVAL(retbuf,SMB_POSIX_ACL_HEADER_SIZE+((i+num_file_acls)*SMB_POSIX_ACL_ENTRY_SIZE)+2); - d_printf("default:group:%u", uorg); + d_printf("default:group:%u:", uorg); break; case SMB_POSIX_ACL_MASK: d_printf("default:mask::"); @@ -3566,7 +3566,7 @@ static int cmd_reput(void) return 1; } - if (!file_exist(local_name, &st)) { + if (!file_exist_stat(local_name, &st)) { d_printf("%s does not exist\n", local_name); return 1; } @@ -4345,6 +4345,8 @@ cleanup: } } +static bool finished; + /**************************************************************************** Make sure we swallow keepalives during idle time. ****************************************************************************/ @@ -4391,6 +4393,8 @@ static void readline_callback(void) DEBUG(0, ("Read from server failed, maybe it closed " "the connection\n")); + finished = true; + smb_readline_done(); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { set_smb_read_error(&cli->smb_rw_error, SMB_READ_EOF); @@ -4417,9 +4421,17 @@ static void readline_callback(void) /* Ping the server to keep the connection alive using SMBecho. */ { + NTSTATUS status; unsigned char garbage[16]; memset(garbage, 0xf0, sizeof(garbage)); - cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage))); + status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage))); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("SMBecho failed. Maybe server has closed " + "the connection\n")); + finished = true; + smb_readline_done(); + } } } @@ -4431,7 +4443,7 @@ static int process_stdin(void) { int rc = 0; - while (1) { + while (!finished) { TALLOC_CTX *frame = talloc_stackframe(); char *tok = NULL; char *the_prompt = NULL; diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 084f87e399..7ad8a73e9c 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -112,11 +112,11 @@ extern int get_total_size; static int blocksize=20; static int tarhandle; -static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t mtime, +static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime, const char *amode, unsigned char ftype); static void do_atar(const char *rname_in,char *lname,file_info *finfo1); static void do_tar(file_info *finfo, const char *dir); -static void oct_it(SMB_BIG_UINT value, int ndgs, char *p); +static void oct_it(uint64_t value, int ndgs, char *p); static void fixtarname(char *tptr, const char *fp, size_t l); static int dotarbuf(int f, char *b, int n); static void dozerobuf(int f, int n); @@ -154,7 +154,7 @@ static char *string_create_s(int size) Write a tar header to buffer ****************************************************************************/ -static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t mtime, +static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime, const char *amode, unsigned char ftype) { union hblock hb; @@ -195,10 +195,10 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m hb.dbuf.name[NAMSIZ-1]='\0'; safe_strcpy(hb.dbuf.mode, amode, sizeof(hb.dbuf.mode)-1); - oct_it((SMB_BIG_UINT)0, 8, hb.dbuf.uid); - oct_it((SMB_BIG_UINT)0, 8, hb.dbuf.gid); - oct_it((SMB_BIG_UINT) size, 13, hb.dbuf.size); - if (size > (SMB_BIG_UINT)077777777777LL) { + oct_it((uint64_t)0, 8, hb.dbuf.uid); + oct_it((uint64_t)0, 8, hb.dbuf.gid); + oct_it((uint64_t) size, 13, hb.dbuf.size); + if (size > (uint64_t)077777777777LL) { /* This is a non-POSIX compatible extention to store files greater than 8GB. */ @@ -207,7 +207,7 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m for (i = 8, jp=(char*)&size; i; i--) hb.dbuf.size[i+3] = *(jp++); } - oct_it((SMB_BIG_UINT) mtime, 13, hb.dbuf.mtime); + oct_it((uint64_t) mtime, 13, hb.dbuf.mtime); memcpy(hb.dbuf.chksum, " ", sizeof(hb.dbuf.chksum)); memset(hb.dbuf.linkname, 0, NAMSIZ); hb.dbuf.linkflag=ftype; @@ -215,7 +215,7 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m for (chk=0, i=sizeof(hb.dummy), jp=hb.dummy; --i>=0;) chk+=(0xFF & *jp++); - oct_it((SMB_BIG_UINT) chk, 8, hb.dbuf.chksum); + oct_it((uint64_t) chk, 8, hb.dbuf.chksum); hb.dbuf.chksum[6] = '\0'; (void) dotarbuf(f, hb.dummy, sizeof(hb.dummy)); @@ -431,7 +431,7 @@ static void fixtarname(char *tptr, const char *fp, size_t l) Convert from decimal to octal string ****************************************************************************/ -static void oct_it (SMB_BIG_UINT value, int ndgs, char *p) +static void oct_it (uint64_t value, int ndgs, char *p) { /* Converts long to octal string, pads with leading zeros */ @@ -567,7 +567,7 @@ static bool ensurepath(const char *fname) return True; } -static int padit(char *buf, SMB_BIG_UINT bufsize, SMB_BIG_UINT padsize) +static int padit(char *buf, uint64_t bufsize, uint64_t padsize) { int berr= 0; int bytestowrite; @@ -607,7 +607,7 @@ append one remote file to the tar file static void do_atar(const char *rname_in,char *lname,file_info *finfo1) { int fnum = -1; - SMB_BIG_UINT nread=0; + uint64_t nread=0; char ftype; file_info2 finfo; bool shallitime=True; @@ -738,7 +738,7 @@ static void do_atar(const char *rname_in,char *lname,file_info *finfo1) if (nread < finfo.size) { DEBUG(0, ("Didn't get entire file. size=%.0f, nread=%d\n", (double)finfo.size, (int)nread)); - if (padit(data, (SMB_BIG_UINT)sizeof(data), finfo.size - nread)) + if (padit(data, (uint64_t)sizeof(data), finfo.size - nread)) DEBUG(0,("Error writing tar file - %s\n", strerror(errno))); } @@ -992,7 +992,7 @@ static int skip_file(int skipsize) static int get_file(file_info2 finfo) { int fnum = -1, pos = 0, dsize = 0, bpos = 0; - SMB_BIG_UINT rsize = 0; + uint64_t rsize = 0; DEBUG(5, ("get_file: file: %s, size %.0f\n", finfo.name, (double)finfo.size)); diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c index 3b56e5f861..fd8014cf9f 100644 --- a/source3/client/mount.cifs.c +++ b/source3/client/mount.cifs.c @@ -56,6 +56,10 @@ #endif /* _SAMBA_BUILD_ */ #endif /* MOUNT_CIFS_VENDOR_SUFFIX */ +#ifdef _SAMBA_BUILD_ +#include "include/config.h" +#endif + #ifndef MS_MOVE #define MS_MOVE 8192 #endif @@ -75,6 +79,15 @@ #define MOUNT_PASSWD_SIZE 64 #define DOMAIN_SIZE 64 +/* exit status - bits below are ORed */ +#define EX_USAGE 1 /* incorrect invocation or permission */ +#define EX_SYSERR 2 /* out of memory, cannot fork, ... */ +#define EX_SOFTWARE 4 /* internal mount bug or wrong version */ +#define EX_USER 8 /* user interrupt */ +#define EX_FILEIO 16 /* problems writing, locking, ... mtab/fstab */ +#define EX_FAIL 32 /* mount failure */ +#define EX_SOMEOK 64 /* some mount succeeded */ + const char *thisprogram; int verboseflag = 0; static int got_password = 0; @@ -94,6 +107,8 @@ char * prefixpath = NULL; /* like strncpy but does not 0 fill the buffer and always null * terminates. bufsize is the size of the destination buffer */ + +#ifndef HAVE_STRLCPY static size_t strlcpy(char *d, const char *s, size_t bufsize) { size_t len = strlen(s); @@ -104,10 +119,13 @@ static size_t strlcpy(char *d, const char *s, size_t bufsize) d[len] = 0; return ret; } +#endif /* like strncat but does not 0 fill the buffer and always null * terminates. bufsize is the length of the buffer, which should * be one more than the maximum resulting string length */ + +#ifndef HAVE_STRLCAT static size_t strlcat(char *d, const char *s, size_t bufsize) { size_t len1 = strlen(d); @@ -126,6 +144,7 @@ static size_t strlcat(char *d, const char *s, size_t bufsize) } return ret; } +#endif /* BB finish BB @@ -164,7 +183,7 @@ static void mount_cifs_usage(void) printf("\n\t%s -V\n",thisprogram); SAFE_FREE(mountpassword); - exit(1); + exit(EX_USAGE); } /* caller frees username if necessary */ @@ -223,7 +242,7 @@ static int open_cred_file(char * file_name) if(length > 4086) { printf("mount.cifs failed due to malformed username in credentials file"); memset(line_buf,0,4096); - exit(1); + exit(EX_USAGE); } else { got_user = 1; user_name = (char *)calloc(1 + length,1); @@ -247,7 +266,7 @@ static int open_cred_file(char * file_name) if(length > MOUNT_PASSWD_SIZE) { printf("mount.cifs failed: password in credentials file too long\n"); memset(line_buf,0, 4096); - exit(1); + exit(EX_USAGE); } else { if(mountpassword == NULL) { mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); @@ -275,7 +294,7 @@ static int open_cred_file(char * file_name) } if(length > DOMAIN_SIZE) { printf("mount.cifs failed: domain in credentials file too long\n"); - exit(1); + exit(EX_USAGE); } else { if(domain_name == NULL) { domain_name = (char *)calloc(DOMAIN_SIZE+1,1); @@ -308,7 +327,7 @@ static int get_password_from_file(int file_descript, char * filename) if (mountpassword == NULL) { printf("malloc failed\n"); - exit(1); + exit(EX_SYSERR); } if(filename != NULL) { @@ -316,7 +335,7 @@ static int get_password_from_file(int file_descript, char * filename) if(file_descript < 0) { printf("mount.cifs failed. %s attempting to open password file %s\n", strerror(errno),filename); - exit(1); + exit(EX_SYSERR); } } /* else file already open and fd provided */ @@ -327,7 +346,7 @@ static int get_password_from_file(int file_descript, char * filename) printf("mount.cifs failed. Error %s reading password file\n",strerror(errno)); if(filename != NULL) close(file_descript); - exit(1); + exit(EX_SYSERR); } else if(rc == 0) { if(mountpassword[0] == 0) { if(verboseflag) @@ -553,7 +572,7 @@ static int parse_options(char ** optionsp, int * filesys_flags) if (!(pw = getpwnam(value))) { printf("bad user name \"%s\"\n", value); - exit(1); + exit(EX_USAGE); } snprintf(user, sizeof(user), "%u", pw->pw_uid); } else { @@ -569,7 +588,7 @@ static int parse_options(char ** optionsp, int * filesys_flags) if (!(gr = getgrnam(value))) { printf("bad group name \"%s\"\n", value); - exit(1); + exit(EX_USAGE); } snprintf(group, sizeof(group), "%u", gr->gr_gid); } else { @@ -664,7 +683,7 @@ static int parse_options(char ** optionsp, int * filesys_flags) out = (char *)realloc(out, out_len + word_len + 2); if (out == NULL) { perror("malloc"); - exit(1); + exit(EX_SYSERR); } if (out_len) { @@ -689,7 +708,7 @@ nocopy: out = (char *)realloc(out, out_len + word_len + 6); if (out == NULL) { perror("malloc"); - exit(1); + exit(EX_SYSERR); } if (out_len) { @@ -705,7 +724,7 @@ nocopy: out = (char *)realloc(out, out_len + 1 + word_len + 6); if (out == NULL) { perror("malloc"); - exit(1); + exit(EX_SYSERR); } if (out_len) { @@ -986,12 +1005,12 @@ static struct option longopts[] = { }; /* convert a string to uppercase. return false if the string - * wasn't ASCII or was a NULL ptr */ + * wasn't ASCII. Return success on a NULL ptr */ static int uppercase_string(char *string) { if (!string) - return 0; + return 1; while (*string) { /* check for unicode */ @@ -1040,7 +1059,7 @@ int main(int argc, char ** argv) thisprogram = argv[0]; } else { mount_cifs_usage(); - exit(1); + exit(EX_USAGE); } if(thisprogram == NULL) @@ -1057,12 +1076,12 @@ int main(int argc, char ** argv) share_name = strndup(argv[1], MAX_UNC_LEN); if (share_name == NULL) { fprintf(stderr, "%s: %s", argv[0], strerror(ENOMEM)); - exit(1); + exit(EX_SYSERR); } mountpoint = argv[2]; } else { mount_cifs_usage(); - exit(1); + exit(EX_USAGE); } /* add sharename in opts string as unc= parm */ @@ -1084,7 +1103,7 @@ int main(int argc, char ** argv) case '?': case 'h': /* help */ mount_cifs_usage (); - exit(1); + exit(EX_USAGE); case 'n': ++nomtab; break; @@ -1138,14 +1157,14 @@ int main(int argc, char ** argv) uid = strtoul(optarg, &ep, 10); if (*ep) { printf("bad uid value \"%s\"\n", optarg); - exit(1); + exit(EX_USAGE); } } else { struct passwd *pw; if (!(pw = getpwnam(optarg))) { printf("bad user name \"%s\"\n", optarg); - exit(1); + exit(EX_USAGE); } uid = pw->pw_uid; endpwent(); @@ -1158,14 +1177,14 @@ int main(int argc, char ** argv) gid = strtoul(optarg, &ep, 10); if (*ep) { printf("bad gid value \"%s\"\n", optarg); - exit(1); + exit(EX_USAGE); } } else { struct group *gr; if (!(gr = getgrnam(optarg))) { printf("bad user name \"%s\"\n", optarg); - exit(1); + exit(EX_USAGE); } gid = gr->gr_gid; endpwent(); @@ -1195,13 +1214,13 @@ int main(int argc, char ** argv) default: printf("unknown mount option %c\n",c); mount_cifs_usage(); - exit(1); + exit(EX_USAGE); } } if((argc < 3) || (dev_name == NULL) || (mountpoint == NULL)) { mount_cifs_usage(); - exit(1); + exit(EX_USAGE); } if (getenv("PASSWD")) { @@ -1218,13 +1237,13 @@ int main(int argc, char ** argv) } if (orgoptions && parse_options(&orgoptions, &flags)) { - rc = -1; + rc = EX_USAGE; goto mount_exit; } ipaddr = parse_server(&share_name); if((ipaddr == NULL) && (got_ip == 0)) { printf("No ip address specified and hostname not found\n"); - rc = -1; + rc = EX_USAGE; goto mount_exit; } @@ -1239,19 +1258,19 @@ int main(int argc, char ** argv) } if(chdir(mountpoint)) { printf("mount error: can not change directory into mount target %s\n",mountpoint); - rc = -1; + rc = EX_USAGE; goto mount_exit; } if(stat (".", &statbuf)) { printf("mount error: mount point %s does not exist\n",mountpoint); - rc = -1; + rc = EX_USAGE; goto mount_exit; } if (S_ISDIR(statbuf.st_mode) == 0) { printf("mount error: mount point %s is not a directory\n",mountpoint); - rc = -1; + rc = EX_USAGE; goto mount_exit; } @@ -1264,7 +1283,7 @@ int main(int argc, char ** argv) #endif } else { printf("mount error: permission denied or not superuser and mount.cifs not installed SUID\n"); - return -1; + exit(EX_USAGE); } } @@ -1279,7 +1298,7 @@ int main(int argc, char ** argv) mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); if (!tmp_pass || !mountpassword) { printf("Password not entered, exiting\n"); - return -1; + exit(EX_USAGE); } strlcpy(mountpassword, tmp_pass, MOUNT_PASSWD_SIZE+1); got_password = 1; @@ -1297,7 +1316,7 @@ mount_retry: else { printf("No server share name specified\n"); printf("\nMounting the DFS root for server not implemented yet\n"); - exit(1); + exit(EX_USAGE); } if(user_name) optlen += strlen(user_name) + 6; @@ -1311,7 +1330,7 @@ mount_retry: if(options == NULL) { printf("Could not allocate memory for mount options\n"); - return -1; + exit(EX_SYSERR); } options[0] = 0; @@ -1390,8 +1409,7 @@ mount_retry: printf("mount error %d = %s\n",errno,strerror(errno)); } printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n"); - rc = -1; - goto mount_exit; + rc = EX_FAIL; } else { pmntfile = setmntent(MOUNTED, "a+"); if(pmntfile) { @@ -1429,11 +1447,13 @@ mount_retry: rc = addmntent(pmntfile,&mountent); endmntent(pmntfile); SAFE_FREE(mountent.mnt_opts); + if (rc) + rc = EX_FILEIO; } else { - printf("could not update mount table\n"); + printf("could not update mount table\n"); + rc = EX_FILEIO; } } - rc = 0; mount_exit: if(mountpassword) { int len = strlen(mountpassword); @@ -1445,5 +1465,5 @@ mount_exit: SAFE_FREE(orgoptions); SAFE_FREE(resolved_path); SAFE_FREE(share_name); - return rc; + exit(rc); } diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c index 4a173714fe..1910ccd4fe 100644 --- a/source3/client/smbspool.c +++ b/source3/client/smbspool.c @@ -482,7 +482,7 @@ smb_connect(const char *workgroup, /* I - Workgroup */ /* * Get the names and addresses of the client and server... */ - myname = get_myname(talloc_tos()); + myname = talloc_get_myname(talloc_tos()); if (!myname) { return NULL; } diff --git a/source3/configure.in b/source3/configure.in index f813e87fb7..a97d535c77 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -23,7 +23,7 @@ m4_include(m4/check_path.m4) AC_LIBREPLACE_CC_CHECKS -m4_include(lib/talloc/libtalloc.m4) +m4_include(../lib/talloc/libtalloc.m4) LIBTALLOC_OBJ0="" for obj in ${TALLOC_OBJ}; do @@ -33,7 +33,7 @@ AC_SUBST(LIBTALLOC_OBJ0) # TODO: These should come from m4_include(lib/tdb/libtdb.m4) # but currently this fails: things have to get merged from s4. -tdbdir="lib/tdb" +tdbdir="../lib/tdb" AC_SUBST(tdbdir) TDB_CFLAGS="-I${srcdir-.}/$tdbdir/include" AC_SUBST(TDB_CFLAGS) @@ -43,18 +43,18 @@ for o in common/tdb.o common/dump.o common/transaction.o common/error.o \ common/traverse.o common/freelist.o common/freelistcheck.o \ common/io.o common/lock.o common/open.o; do - LIBTDB_OBJ0="$LIBTDB_OBJ0 lib/tdb/$o" + LIBTDB_OBJ0="$LIBTDB_OBJ0 $tdbdir/$o" done AC_SUBST(LIBTDB_OBJ0) SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include -I. -I${srcdir-.}" -SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace" +SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc" -SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/popt" +SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt" ## cleanup the $(srcdir) in the Makefile if we are outside of the tree if test "x${srcdir-.}" != "x."; then @@ -128,13 +128,11 @@ fi if test "x$debug" = "xyes" ; then CFLAGS="${CFLAGS} -g" else - CFLAGS="-O" + CFLAGS="${CFLAGS} -O" fi -CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3" - -m4_include(lib/socket_wrapper/config.m4) -m4_include(lib/nss_wrapper/config.m4) +m4_include(../lib/socket_wrapper/config.m4) +m4_include(../lib/nss_wrapper/config.m4) m4_include(m4/swat.m4) @@ -352,7 +350,7 @@ AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_C ], samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv__CC_NEGATIVE_ENUM_VALUES=no)]) if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then - AC_MSG_WARN([using --unit-enums for pidl]) + AC_MSG_WARN([using --uint-enums for pidl]) PIDL_ARGS="$PIDL_ARGS --uint-enums" fi @@ -406,10 +404,10 @@ AC_SUBST(DYNEXP) dnl Add modules that have to be built by default here dnl These have to be built static: -default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template" +default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template" dnl These are preferably build shared, and static if dlopen() is not available -default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr" +default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr vfs_acl_xattr vfs_smb_traffic_analyzer" if test "x$developer" = xyes; then default_static_modules="$default_static_modules rpc_rpcecho" @@ -659,6 +657,8 @@ AC_SUBST(LIBREPLACE_OBJS) # add -ldl to the global LIBS LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}" +AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}" + AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h) AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h) @@ -878,6 +878,21 @@ if test x"$samba_cv_sig_atomic_t" = x"yes"; then AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) fi +AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [ + AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include ],[struct sigevent s;], + samba_cv_struct_sigevent=yes,samba_cv_struct_sigevent=no)]) +if test x"$samba_cv_struct_sigevent" = x"yes"; then + AC_DEFINE(HAVE_STRUCT_SIGEVENT,1,[Whether we have the struct sigevent]) + AC_CHECK_MEMBERS([struct sigevent.sigev_value.sival_ptr,struct sigevent.sigev_value.sigval_ptr], , , + [#include ]) +fi + AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [ AC_TRY_COMPILE([ #include @@ -4305,12 +4320,6 @@ AC_ARG_WITH(pam_smbpass, ) -############################################### -# test for where we get crypt() from -AC_SEARCH_LIBS(crypt, [crypt], - [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS" - AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])]) - ## ## moved after the check for -lcrypt in order to ## ensure that the necessary libraries are included @@ -5859,7 +5868,7 @@ if test x"$INCLUDED_POPT" = x"yes"; then AC_MSG_RESULT(yes) BUILD_POPT='$(POPT_OBJ)' POPTLIBS='$(POPT_OBJ)' - FLAGS1="-I\$(srcdir)/popt" + FLAGS1="-I\$(srcdir)/../lib/popt" else AC_MSG_RESULT(no) BUILD_POPT="" @@ -6044,6 +6053,8 @@ SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP) SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP) SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP) SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP) +SMB_MODULE(idmap_hash, \$(IDMAP_HASH_OBJ), "bin/hash.$SHLIBEXT", IDMAP) +SMB_MODULE(idmap_adex, \$(IDMAP_ADEX_OBJ), "bin/adex.$SHLIBEXT", IDMAP) SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o) SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO) @@ -6062,6 +6073,7 @@ SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH) SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH) SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH) SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH) +SMB_MODULE(auth_netlogond, \$(AUTH_NETLOGOND_OBJ), "bin/netlogond.$SHLIBEXT", AUTH) SMB_SUBSYSTEM(AUTH,auth/auth.o) SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS) @@ -6100,12 +6112,14 @@ SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS) SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS) SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS) SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS) - +SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS) +SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_traffic_analyzer.$SHLIBEXT", VFS) SMB_SUBSYSTEM(VFS,smbd/vfs.o) SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT) SMB_MODULE(gpext_scripts, libgpo/gpext/scripts.o, "bin/scripts.$SHLIBEXT", GPEXT) +SMB_MODULE(gpext_security, libgpo/gpext/security.o, "bin/security.$SHLIBEXT", GPEXT) SMB_SUBSYSTEM(GPEXT, libgpo/gpext/gpext.o) AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) @@ -6200,6 +6214,50 @@ MSG fi +AC_ARG_ENABLE(merged-build, +[AS_HELP_STRING([--enable-merged-build], [Build Samba 4 as well])], +[ enable_merged_build=$enableval ], [ enable_merged_build=auto ]) + +if test x$enable_merged_build = xauto; then + merged_build_possible=yes + + # Check for GNU make + m4_include(../source4/build/m4/check_make.m4) + AC_SAMBA_GNU_MAKE([true], [merged_build_possible=no]) + + # Check for perl + m4_include(../source4/build/m4/check_perl.m4) + AC_SAMBA_PERL([true], [merged_build_possible=no]) + + # Check for python + m4_include(../source4/build/m4/check_python.m4) + AC_SAMBA_PYTHON_DEVEL([true], [merged_build_possible=no]) + + AC_MSG_CHECKING([whether it would be possible to do a merged build]) + AC_MSG_RESULT([$merged_build_possible]) + + dnl FIXME: enable_merged_build=$merged_build_possible +fi + +if test x$enable_merged_build = xyes; then + MERGED_BUILD=1 + m4_include(samba4.m4) +fi + +m4_include(../lib/zlib/zlib.m4) +AC_SUBST(ZLIB_LIBS) +AC_SUBST(ZLIB_OBJS) +AC_ZLIB([ZLIB_OBJS=""], [ + ZLIB_LIBS="" + for o in adler32.o compress.o crc32.o gzio.o uncompr.o \ + deflate.o trees.o zutil.o inflate.o infback.o \ + inftrees.o inffast.o + do + ZLIB_OBJS="$ZLIB_OBJS ../lib/zlib/$o" + done + CFLAGS="$CFLAGS -I../lib/zlib" +]) + dnl Remove -L/usr/lib/? from LDFLAGS and LIBS LIB_REMOVE_USR_LIB(LDFLAGS) LIB_REMOVE_USR_LIB(LIBS) @@ -6248,6 +6306,16 @@ fi SMBD_LIBS="$samba_dmapi_libs" AC_SUBST(SMBD_LIBS) +CFLAGS="${CFLAGS} \$(FLAGS)" + +if test x$MERGED_BUILD != x1; then + CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3" +else + if test x"$BLDSHARED" = x"true" ; then + LDFLAGS="$LDFLAGS -L./bin" + fi +fi + AC_OUTPUT(Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh lib/netapi/examples/Makefile diff --git a/source3/dynconfig.c b/source3/dynconfig.c index 3a54507599..6125f9944c 100644 --- a/source3/dynconfig.c +++ b/source3/dynconfig.c @@ -77,6 +77,7 @@ DEFINE_DYN_CONFIG_PARAM(MODULESDIR) DEFINE_DYN_CONFIG_PARAM(SHLIBEXT) DEFINE_DYN_CONFIG_PARAM(LOCKDIR) DEFINE_DYN_CONFIG_PARAM(PIDDIR) +DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR) DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE) DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR) diff --git a/source3/groupdb/mapping_ldb.c b/source3/groupdb/mapping_ldb.c index 7ce879fb6e..1a6b99fa18 100644 --- a/source3/groupdb/mapping_ldb.c +++ b/source3/groupdb/mapping_ldb.c @@ -63,7 +63,7 @@ static bool init_group_mapping(void) /* Ensure this db is created read/write for root only. */ ldb_set_create_perms(ldb, 0600); - existed = file_exist(db_path, NULL); + existed = file_exist(db_path); if (lp_parm_bool(-1, "groupmap", "nosync", False)) { flags |= LDB_FLG_NOSYNC; @@ -99,7 +99,7 @@ static bool init_group_mapping(void) /* possibly upgrade */ tdb_path = state_path("group_mapping.tdb"); - if (file_exist(tdb_path, NULL) && !mapping_upgrade(tdb_path)) { + if (file_exist(tdb_path) && !mapping_upgrade(tdb_path)) { unlink(state_path("group_mapping.ldb")); goto failed; } diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c index 7cee53a968..29927eb592 100644 --- a/source3/groupdb/mapping_tdb.c +++ b/source3/groupdb/mapping_tdb.c @@ -666,8 +666,7 @@ static NTSTATUS del_aliasmem(const DOM_SID *alias, const DOM_SID *member) if (num == 0) { status = dbwrap_delete_bystring(db, key); - TALLOC_FREE(sids); - goto cancel; + goto commit; } member_string = talloc_strdup(sids, ""); @@ -693,7 +692,7 @@ static NTSTATUS del_aliasmem(const DOM_SID *alias, const DOM_SID *member) status = dbwrap_store_bystring( db, key, string_term_tdb_data(member_string), 0); - + commit: TALLOC_FREE(sids); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/include/ads.h b/source3/include/ads.h index 97faf0b6eb..b72d250940 100644 --- a/source3/include/ads.h +++ b/source3/include/ads.h @@ -133,6 +133,7 @@ struct posix_schema { char *posix_uidnumber_attr; char *posix_gidnumber_attr; char *posix_gecos_attr; + char *posix_uid_attr; }; @@ -179,6 +180,7 @@ typedef void **ADS_MODLIST; #define ADS_ATTR_SFU_HOMEDIR_OID "1.2.840.113556.1.6.18.1.344" #define ADS_ATTR_SFU_SHELL_OID "1.2.840.113556.1.6.18.1.312" #define ADS_ATTR_SFU_GECOS_OID "1.2.840.113556.1.6.18.1.337" +#define ADS_ATTR_SFU_UID_OID "1.2.840.113556.1.6.18.1.309" /* ldap attribute oids (Services for Unix 2.0) */ #define ADS_ATTR_SFU20_UIDNUMBER_OID "1.2.840.113556.1.4.7000.187.70" @@ -186,6 +188,8 @@ typedef void **ADS_MODLIST; #define ADS_ATTR_SFU20_HOMEDIR_OID "1.2.840.113556.1.4.7000.187.106" #define ADS_ATTR_SFU20_SHELL_OID "1.2.840.113556.1.4.7000.187.72" #define ADS_ATTR_SFU20_GECOS_OID "1.2.840.113556.1.4.7000.187.97" +#define ADS_ATTR_SFU20_UID_OID "1.2.840.113556.1.4.7000.187.102" + /* ldap attribute oids (RFC2307) */ #define ADS_ATTR_RFC2307_UIDNUMBER_OID "1.3.6.1.1.1.1.0" @@ -193,6 +197,7 @@ typedef void **ADS_MODLIST; #define ADS_ATTR_RFC2307_HOMEDIR_OID "1.3.6.1.1.1.1.3" #define ADS_ATTR_RFC2307_SHELL_OID "1.3.6.1.1.1.1.4" #define ADS_ATTR_RFC2307_GECOS_OID "1.3.6.1.1.1.1.2" +#define ADS_ATTR_RFC2307_UID_OID "0.9.2342.19200300.100.1.1" /* ldap bitwise searches */ #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803" diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h deleted file mode 100644 index 9ced9cea3a..0000000000 --- a/source3/include/byteorder.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB Byte handling - Copyright (C) Andrew Tridgell 1992-1998 - - 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 . -*/ - -#ifndef _BYTEORDER_H -#define _BYTEORDER_H - -/* - This file implements macros for machine independent short and - int manipulation - -Here is a description of this file that I emailed to the samba list once: - -> I am confused about the way that byteorder.h works in Samba. I have -> looked at it, and I would have thought that you might make a distinction -> between LE and BE machines, but you only seem to distinguish between 386 -> and all other architectures. -> -> Can you give me a clue? - -sure. - -The distinction between 386 and other architectures is only there as -an optimisation. You can take it out completely and it will make no -difference. The routines (macros) in byteorder.h are totally byteorder -independent. The 386 optimsation just takes advantage of the fact that -the x86 processors don't care about alignment, so we don't have to -align ints on int boundaries etc. If there are other processors out -there that aren't alignment sensitive then you could also define -CAREFUL_ALIGNMENT=0 on those processors as well. - -Ok, now to the macros themselves. I'll take a simple example, say we -want to extract a 2 byte integer from a SMB packet and put it into a -type called uint16 that is in the local machines byte order, and you -want to do it with only the assumption that uint16 is _at_least_ 16 -bits long (this last condition is very important for architectures -that don't have any int types that are 2 bytes long) - -You do this: - -#define CVAL(buf,pos) (((unsigned char *)(buf))[pos]) -#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos)) -#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) - -then to extract a uint16 value at offset 25 in a buffer you do this: - -char *buffer = foo_bar(); -uint16 xx = SVAL(buffer,25); - -We are using the byteoder independence of the ANSI C bitshifts to do -the work. A good optimising compiler should turn this into efficient -code, especially if it happens to have the right byteorder :-) - -I know these macros can be made a bit tidier by removing some of the -casts, but you need to look at byteorder.h as a whole to see the -reasoning behind them. byteorder.h defines the following macros: - -SVAL(buf,pos) - extract a 2 byte SMB value -IVAL(buf,pos) - extract a 4 byte SMB value -SVALS(buf,pos) signed version of SVAL() -IVALS(buf,pos) signed version of IVAL() - -SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer -SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer -SSVALS(buf,pos,val) - signed version of SSVAL() -SIVALS(buf,pos,val) - signed version of SIVAL() - -RSVAL(buf,pos) - like SVAL() but for NMB byte ordering -RSVALS(buf,pos) - like SVALS() but for NMB byte ordering -RIVAL(buf,pos) - like IVAL() but for NMB byte ordering -RIVALS(buf,pos) - like IVALS() but for NMB byte ordering -RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering -RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering -RSIVALS(buf,pos,val) - like SIVALS() but for NMB ordering - -it also defines lots of intermediate macros, just ignore those :-) - -*/ - -#undef CAREFUL_ALIGNMENT - -/* we know that the 386 can handle misalignment and has the "right" - byteorder */ -#ifdef __i386__ -#define CAREFUL_ALIGNMENT 0 -#endif - -#ifndef CAREFUL_ALIGNMENT -#define CAREFUL_ALIGNMENT 1 -#endif - -#define CVAL(buf,pos) ((unsigned)(((const unsigned char *)(buf))[pos])) -#define CVAL_NC(buf,pos) (((unsigned char *)(buf))[pos]) /* Non-const version of CVAL */ -#define PVAL(buf,pos) (CVAL(buf,pos)) -#define SCVAL(buf,pos,val) (CVAL_NC(buf,pos) = (val)) - - -#if CAREFUL_ALIGNMENT - -#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) -#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16) -#define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(unsigned char)((val)&0xFF),CVAL_NC(buf,pos+1)=(unsigned char)((val)>>8)) -#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16)) -#define SVALS(buf,pos) ((int16)SVAL(buf,pos)) -#define IVALS(buf,pos) ((int32)IVAL(buf,pos)) -#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val))) -#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val))) -#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val))) -#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val))) - -#else /* CAREFUL_ALIGNMENT */ - -/* this handles things for architectures like the 386 that can handle - alignment errors */ -/* - WARNING: This section is dependent on the length of int16 and int32 - being correct -*/ - -/* get single value from an SMB buffer */ -#define SVAL(buf,pos) (*(const uint16 *)((const char *)(buf) + (pos))) -#define SVAL_NC(buf,pos) (*(uint16 *)((char *)(buf) + (pos))) /* Non const version of above. */ -#define IVAL(buf,pos) (*(const uint32 *)((const char *)(buf) + (pos))) -#define IVAL_NC(buf,pos) (*(uint32 *)((char *)(buf) + (pos))) /* Non const version of above. */ -#define SVALS(buf,pos) (*(const int16 *)((const char *)(buf) + (pos))) -#define SVALS_NC(buf,pos) (*(int16 *)((char *)(buf) + (pos))) /* Non const version of above. */ -#define IVALS(buf,pos) (*(const int32 *)((const char *)(buf) + (pos))) -#define IVALS_NC(buf,pos) (*(int32 *)((char *)(buf) + (pos))) /* Non const version of above. */ - -/* store single value in an SMB buffer */ -#define SSVAL(buf,pos,val) SVAL_NC(buf,pos)=((uint16)(val)) -#define SIVAL(buf,pos,val) IVAL_NC(buf,pos)=((uint32)(val)) -#define SSVALS(buf,pos,val) SVALS_NC(buf,pos)=((int16)(val)) -#define SIVALS(buf,pos,val) IVALS_NC(buf,pos)=((int32)(val)) - -#endif /* CAREFUL_ALIGNMENT */ - -/* now the reverse routines - these are used in nmb packets (mostly) */ -#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) -#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16))) - -#define RSVAL(buf,pos) SREV(SVAL(buf,pos)) -#define RSVALS(buf,pos) SREV(SVALS(buf,pos)) -#define RIVAL(buf,pos) IREV(IVAL(buf,pos)) -#define RIVALS(buf,pos) IREV(IVALS(buf,pos)) -#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val)) -#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val)) -#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val)) -#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val)) - -/* Alignment macros. */ -#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 */ diff --git a/source3/include/charset.h b/source3/include/charset.h index 4d04b5a1a6..1c2a5fb5f0 100644 --- a/source3/include/charset.h +++ b/source3/include/charset.h @@ -18,6 +18,8 @@ along with this program. If not, see . */ +struct smb_iconv_convenience; + /* this defines the charset types used in samba */ typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t; diff --git a/source3/include/client.h b/source3/include/client.h index 70b0421c6d..8d57fe1eed 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -232,7 +232,7 @@ struct cli_state { typedef struct file_info { struct cli_state *cli; - SMB_BIG_UINT size; + uint64_t size; uint16 mode; uid_t uid; gid_t gid; diff --git a/source3/include/dcerpc.h b/source3/include/dcerpc.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/source3/include/debug.h b/source3/include/debug.h index d1716320b3..56d0237c3f 100644 --- a/source3/include/debug.h +++ b/source3/include/debug.h @@ -40,11 +40,13 @@ int Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2); /* PRINTFLIKE1 */ bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2); -bool dbghdr( int level, int cls, const char *file, const char *func, int line ); +bool dbghdrclass( int level, int cls, const char *location, const char *func); +bool dbghdr( int level, const char *location, const char *func); #if defined(sgi) && (_COMPILER_VERSION >= 730) #pragma mips_frequency_hint NEVER Debug1 #pragma mips_frequency_hint NEVER dbgtext +#pragma mips_frequency_hint NEVER dbghdrclass #pragma mips_frequency_hint NEVER dbghdr #endif @@ -192,7 +194,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET; #define DEBUGLVL( level ) \ ( CHECK_DEBUGLVL(level) \ - && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) ) + && dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO ) ) #define DEBUGLVLC( dbgc_class, level ) \ @@ -200,7 +202,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET; unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) ) + && dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO) ) #define DEBUG( level, body ) \ @@ -208,7 +210,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET; unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \ DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \ + && (dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO )) \ && (dbgtext body) ) #define DEBUGC( dbgc_class, level, body ) \ @@ -216,7 +218,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET; unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \ + && (dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO)) \ && (dbgtext body) ) #define DEBUGADD( level, body ) \ diff --git a/source3/include/dynconfig.h b/source3/include/dynconfig.h index 758bde33cc..8267064f23 100644 --- a/source3/include/dynconfig.h +++ b/source3/include/dynconfig.h @@ -71,6 +71,10 @@ const char *get_dyn_PIDDIR(void); const char *set_dyn_PIDDIR(const char *newpath); bool is_default_dyn_PIDDIR(void); +const char *get_dyn_NCALRPCDIR(void); +const char *set_dyn_NCALRPCDIR(const char *newpath); +bool is_default_dyn_NCALRPCDIR(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); diff --git a/source3/include/fake_file.h b/source3/include/fake_file.h index 93da106030..c4b271f85d 100644 --- a/source3/include/fake_file.h +++ b/source3/include/fake_file.h @@ -22,7 +22,8 @@ enum FAKE_FILE_TYPE { FAKE_FILE_TYPE_NONE = 0, - FAKE_FILE_TYPE_QUOTA + FAKE_FILE_TYPE_QUOTA, + FAKE_FILE_TYPE_NAMED_PIPE }; /* diff --git a/source3/include/hmacmd5.h b/source3/include/hmacmd5.h deleted file mode 100644 index ae588fb889..0000000000 --- a/source3/include/hmacmd5.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Interface header: Scheduler service - Copyright (C) Luke Kenneth Casson Leighton 1996-1999 - Copyright (C) Andrew Tridgell 1992-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 . -*/ - -#ifndef _HMAC_MD5_H - -typedef struct { - struct MD5Context ctx; - unsigned char k_ipad[65]; - unsigned char k_opad[65]; -} HMACMD5Context; - -#endif /* _HMAC_MD5_H */ diff --git a/source3/include/idmap.h b/source3/include/idmap.h index 95c3e4c0c2..4322192155 100644 --- a/source3/include/idmap.h +++ b/source3/include/idmap.h @@ -31,8 +31,9 @@ Updated to 3 for enum types by JRA. */ /* Updated to 4, completely new interface, SSS */ +/* Updated to 5, simplified interface by Volker */ -#define SMB_IDMAP_INTERFACE_VERSION 4 +#define SMB_IDMAP_INTERFACE_VERSION 5 struct idmap_domain { const char *name; diff --git a/source3/include/includes.h b/source3/include/includes.h index 9c5ea08f6d..c164d285c1 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -25,7 +25,7 @@ #undef SIZEOF_LONG #endif -#include "lib/replace/replace.h" +#include "../replace/replace.h" /* make sure we have included the correct config.h */ #ifndef NO_CONFIG_H /* for some tests */ @@ -71,23 +71,6 @@ #undef HAVE_TERMIOS_H #endif -#ifndef _PUBLIC_ -#ifdef HAVE_VISIBILITY_ATTR -# define _PUBLIC_ __attribute__((visibility("default"))) -#else -# define _PUBLIC_ -#endif -#endif - -#if defined(__GNUC__) && !defined(__cplusplus) -/** gcc attribute used on function parameters so that it does not emit - * warnings about them being unused. **/ -# define UNUSED(param) param __attribute__ ((unused)) -#else -# define UNUSED(param) param -/** Feel free to add definitions for other compilers here. */ -#endif - #ifdef RELIANTUNIX /* * has to be included before any other to get @@ -285,37 +268,19 @@ typedef int ber_int_t; #define HAVE_ADS #endif -/* - * Define VOLATILE if needed. - */ - -#if defined(HAVE_VOLATILE) -#define VOLATILE volatile -#else -#define VOLATILE -#endif - /* * Define additional missing types */ -#if defined(HAVE_SIG_ATOMIC_T_TYPE) && defined(AIX) +#if defined(AIX) typedef sig_atomic_t SIG_ATOMIC_T; -#elif defined(HAVE_SIG_ATOMIC_T_TYPE) && !defined(AIX) -typedef sig_atomic_t VOLATILE SIG_ATOMIC_T; #else -typedef int VOLATILE SIG_ATOMIC_T; +typedef sig_atomic_t volatile SIG_ATOMIC_T; #endif #ifndef uchar #define uchar unsigned char #endif -#ifdef HAVE_UNSIGNED_CHAR -#define schar signed char -#else -#define schar char -#endif - /* Samba needs type definitions for int16, int32, uint16 and uint32. @@ -326,15 +291,11 @@ typedef int VOLATILE SIG_ATOMIC_T; */ #ifndef uint8 -#define uint8 unsigned char +#define uint8 uint8_t #endif #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H) -# if (SIZEOF_SHORT == 4) -# define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16; -# else /* SIZEOF_SHORT != 4 */ -# define int16 short -# endif /* SIZEOF_SHORT != 4 */ +# define int16 int16_t /* needed to work around compile issue on HP-UX 11.x */ # define _INT16 1 #endif @@ -344,25 +305,13 @@ typedef int VOLATILE SIG_ATOMIC_T; * case as int16 may be a typedef from rpc/rpc.h */ + #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H) -#if (SIZEOF_SHORT == 4) -#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16; -#else /* SIZEOF_SHORT != 4 */ -#define uint16 unsigned short -#endif /* SIZEOF_SHORT != 4 */ +# define uint16 uint16_t #endif #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H) -# if (SIZEOF_INT == 4) -# define int32 int -# elif (SIZEOF_LONG == 4) -# define int32 long -# elif (SIZEOF_SHORT == 4) -# define int32 short -# else - /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */ -# define int32 int -# endif +# define int32 int32_t /* needed to work around compile issue on HP-UX 11.x */ # define _INT32 1 #endif @@ -373,16 +322,7 @@ typedef int VOLATILE SIG_ATOMIC_T; */ #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H) -#if (SIZEOF_INT == 4) -#define uint32 unsigned int -#elif (SIZEOF_LONG == 4) -#define uint32 unsigned long -#elif (SIZEOF_SHORT == 4) -#define uint32 unsigned short -#else -/* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */ -#define uint32 unsigned -#endif +# define uint32 uint32_t #endif /* @@ -390,19 +330,11 @@ typedef int VOLATILE SIG_ATOMIC_T; */ #if !defined(uint64) -#if (SIZEOF_LONG == 8) -#define uint64 unsigned long -#elif (SIZEOF_LONG_LONG == 8) -#define uint64 unsigned long long -#endif /* don't lie. If we don't have it, then don't use it */ +# define uint64 uint64_t #endif #if !defined(int64) -#if (SIZEOF_LONG == 8) -#define int64 long -#elif (SIZEOF_LONG_LONG == 8) -#define int64 long long -#endif /* don't lie. If we don't have it, then don't use it */ +# define int64 int64_t #endif @@ -426,7 +358,7 @@ typedef int VOLATILE SIG_ATOMIC_T; #ifdef LARGE_SMB_DEV_T #define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32)) -#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(((SMB_BIG_UINT)(IVAL((p),(ofs))))| (((SMB_BIG_UINT)(IVAL((p),(ofs)+4))) << 32))) +#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(((uint64_t)(IVAL((p),(ofs))))| (((uint64_t)(IVAL((p),(ofs)+4))) << 32))) #else #define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),v),SIVAL((p),(ofs)+4,0)) #define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(IVAL((p),(ofs)))) @@ -452,7 +384,7 @@ typedef int VOLATILE SIG_ATOMIC_T; #ifdef LARGE_SMB_INO_T #define SINO_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32)) -#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((SMB_BIG_UINT)(IVAL(p,ofs)))| (((SMB_BIG_UINT)(IVAL(p,(ofs)+4))) << 32))) +#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((uint64_t)(IVAL(p,ofs)))| (((uint64_t)(IVAL(p,(ofs)+4))) << 32))) #else #define SINO_T_VAL(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0)) #define INO_T_VAL(p, ofs) ((SMB_INO_T)(IVAL((p),(ofs)))) @@ -466,20 +398,13 @@ typedef int VOLATILE SIG_ATOMIC_T; # endif #endif -#if defined(HAVE_LONGLONG) -#define SMB_BIG_UINT unsigned long long -#define SMB_BIG_INT long long #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32)) -#else -#define SMB_BIG_UINT unsigned long -#define SMB_BIG_INT long -#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0)) -#endif +#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF)) | \ + (( ((uint64_t)(IVAL((buf),(off+4)))) & ((uint64_t)0xFFFFFFFF) ) << 32 ) ) -#define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8) /* this should really be a 64 bit type if possible */ -#define br_off SMB_BIG_UINT +typedef uint64_t br_off; #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8) @@ -497,15 +422,11 @@ typedef int VOLATILE SIG_ATOMIC_T; #ifdef LARGE_SMB_OFF_T #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32)) #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32)) -#define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ))) -#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \ - (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) ) +#define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF) ))) #else #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0)) #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,v),SIVAL(p,ofs,0)) #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint32)(IVAL((buf),(off)))) & 0xFFFFFFFF ))) -#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \ - (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) ) #endif /* @@ -645,14 +566,24 @@ struct timespec { typedef char fstring[FSTRING_LEN]; #endif +/* Samba 3 doesn't use iconv_convenience: */ +extern void *global_loadparm; +extern void *cmdline_lp_ctx; +struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx); + /* Lists, trees, caching, database... */ -#include "xfile.h" +#include "../lib/util/xfile.h" +#include "../lib/util/memory.h" +#include "../lib/util/attr.h" #include "intl.h" -#include "dlinklist.h" +#include "../lib/util/dlinklist.h" #include "tdb.h" #include "util_tdb.h" -#include "lib/talloc/talloc.h" +#include "../talloc/talloc.h" + +#include "../lib/util/data_blob.h" +#include "../lib/util/time.h" /* And a little extension. Abort on type mismatch */ #define talloc_get_type_abort(ptr, type) \ (type *)talloc_check_name_abort(ptr, #type) @@ -675,7 +606,7 @@ typedef char fstring[FSTRING_LEN]; #include "smb.h" #include "nameserv.h" #include "secrets.h" -#include "byteorder.h" +#include "../lib/util/byteorder.h" #include "privileges.h" #include "rpc_misc.h" #include "rpc_dce.h" @@ -686,8 +617,10 @@ typedef char fstring[FSTRING_LEN]; #include "authdata.h" #include "msdfs.h" #include "rap.h" -#include "md5.h" -#include "hmacmd5.h" +#include "../lib/crypto/md5.h" +#include "../lib/crypto/arcfour.h" +#include "../lib/crypto/crc32.h" +#include "../lib/crypto/hmacmd5.h" #include "ntlmssp.h" #include "auth.h" #include "ntdomain.h" @@ -703,6 +636,7 @@ typedef char fstring[FSTRING_LEN]; #include "librpc/gen_ndr/notify.h" #include "librpc/gen_ndr/xattr.h" #include "librpc/gen_ndr/messaging.h" +#include "librpc/gen_ndr/ndr_nbt.h" #include "librpc/rpc/dcerpc.h" #include "nt_printing.h" #include "idmap.h" @@ -782,14 +716,6 @@ enum flush_reason_enum { #include "modules/nfs4_acls.h" #include "nsswitch/libwbclient/wbclient.h" -/* generated rpc server implementation functions */ -#include "librpc/gen_ndr/srv_echo.h" -#include "librpc/gen_ndr/srv_svcctl.h" -#include "librpc/gen_ndr/srv_lsa.h" -#include "librpc/gen_ndr/srv_eventlog.h" -#include "librpc/gen_ndr/srv_winreg.h" -#include "librpc/gen_ndr/srv_initshutdown.h" - /***** automatically generated prototypes *****/ #ifndef NO_PROTO_H #include "proto.h" @@ -830,14 +756,6 @@ enum flush_reason_enum { /* prototypes from lib/util_transfer_file.c */ #include "transfer_file.h" -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif - #ifndef DEFAULT_PRINTING #ifdef HAVE_CUPS #define DEFAULT_PRINTING PRINT_CUPS @@ -887,26 +805,6 @@ enum flush_reason_enum { #define SYNC_DNS 1 #endif -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001 -#endif - -#ifndef INADDR_NONE -#define INADDR_NONE 0xffffffff -#endif - -#ifndef HAVE_CRYPT -#define crypt ufc_crypt -#endif - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID) #define ULTRIX_AUTH 1 #endif @@ -919,26 +817,9 @@ int setresuid(uid_t ruid, uid_t euid, uid_t suid); int setresgid(gid_t rgid, gid_t egid, gid_t sgid); #endif -/* - * Some older systems seem not to have MAXHOSTNAMELEN - * defined. - */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 255 -#endif - /* yuck, I'd like a better way of doing this */ #define DIRP_SIZE (256 + 32) -/* - * glibc on linux doesn't seem to have MSG_WAITALL - * defined. I think the kernel has it though.. - */ - -#ifndef MSG_WAITALL -#define MSG_WAITALL 0 -#endif - /* default socket options. Dave Miller thinks we should default to TCP_NODELAY given the socket IO pattern that Samba uses */ #ifdef TCP_NODELAY @@ -954,84 +835,6 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid); #endif -/* Some POSIX definitions for those without */ - -#ifndef S_IFDIR -#define S_IFDIR 0x4000 -#endif -#ifndef S_ISDIR -#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR) -#endif -#ifndef S_IRWXU -#define S_IRWXU 00700 /* read, write, execute: owner */ -#endif -#ifndef S_IRUSR -#define S_IRUSR 00400 /* read permission: owner */ -#endif -#ifndef S_IWUSR -#define S_IWUSR 00200 /* write permission: owner */ -#endif -#ifndef S_IXUSR -#define S_IXUSR 00100 /* execute permission: owner */ -#endif -#ifndef S_IRWXG -#define S_IRWXG 00070 /* read, write, execute: group */ -#endif -#ifndef S_IRGRP -#define S_IRGRP 00040 /* read permission: group */ -#endif -#ifndef S_IWGRP -#define S_IWGRP 00020 /* write permission: group */ -#endif -#ifndef S_IXGRP -#define S_IXGRP 00010 /* execute permission: group */ -#endif -#ifndef S_IRWXO -#define S_IRWXO 00007 /* read, write, execute: other */ -#endif -#ifndef S_IROTH -#define S_IROTH 00004 /* read permission: other */ -#endif -#ifndef S_IWOTH -#define S_IWOTH 00002 /* write permission: other */ -#endif -#ifndef S_IXOTH -#define S_IXOTH 00001 /* execute permission: other */ -#endif - -/* For sys_adminlog(). */ -#ifndef LOG_EMERG -#define LOG_EMERG 0 /* system is unusable */ -#endif - -#ifndef LOG_ALERT -#define LOG_ALERT 1 /* action must be taken immediately */ -#endif - -#ifndef LOG_CRIT -#define LOG_CRIT 2 /* critical conditions */ -#endif - -#ifndef LOG_ERR -#define LOG_ERR 3 /* error conditions */ -#endif - -#ifndef LOG_WARNING -#define LOG_WARNING 4 /* warning conditions */ -#endif - -#ifndef LOG_NOTICE -#define LOG_NOTICE 5 /* normal but significant condition */ -#endif - -#ifndef LOG_INFO -#define LOG_INFO 6 /* informational */ -#endif - -#ifndef LOG_DEBUG -#define LOG_DEBUG 7 /* debug-level messages */ -#endif - #if HAVE_KERNEL_SHARE_MODES #ifndef LOCK_MAND #define LOCK_MAND 32 /* This is a mandatory flock */ @@ -1059,19 +862,6 @@ extern int DEBUGLEVEL; #endif -/* Needed for sys_dlopen/sys_dlsym/sys_dlclose */ -#ifndef RTLD_GLOBAL -#define RTLD_GLOBAL 0 -#endif - -#ifndef RTLD_LAZY -#define RTLD_LAZY 0 -#endif - -#ifndef RTLD_NOW -#define RTLD_NOW 0 -#endif - /* needed for some systems without iconv. Doesn't really matter what error code we use */ #ifndef EILSEQ @@ -1104,17 +894,6 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATT #define slprintf snprintf #define vslprintf vsnprintf -/* we need to use __va_copy() on some platforms */ -#ifdef HAVE_VA_COPY -#define VA_COPY(dest, src) va_copy(dest, src) -#else -#ifdef HAVE___VA_COPY -#define VA_COPY(dest, src) __va_copy(dest, src) -#else -#define VA_COPY(dest, src) (dest) = (src) -#endif -#endif - /* * Veritas File System. Often in addition to native. * Quotas different. @@ -1270,10 +1049,6 @@ LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int to); ssize_t readahead(int fd, off64_t offset, size_t count); #endif -/* TRUE and FALSE are part of the C99 standard and gcc, but - unfortunately many vendor compilers don't support them. Use True - and False instead. */ - #ifdef TRUE #undef TRUE #endif @@ -1292,21 +1067,12 @@ ssize_t readahead(int fd, off64_t offset, size_t count); #endif #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) -#define CONST_ADD(type, ptr) ((type) ((const void *) (ptr))) - -#ifndef NORETURN_ATTRIBUTE -#if (__GNUC__ >= 3) -#define NORETURN_ATTRIBUTE __attribute__ ((noreturn)) -#else -#define NORETURN_ATTRIBUTE -#endif -#endif -void smb_panic( const char *why ) NORETURN_ATTRIBUTE ; -void dump_core(void) NORETURN_ATTRIBUTE ; -void exit_server(const char *const reason) NORETURN_ATTRIBUTE ; -void exit_server_cleanly(const char *const reason) NORETURN_ATTRIBUTE ; -void exit_server_fault(void) NORETURN_ATTRIBUTE ; +void smb_panic( const char *why ) _NORETURN_; +void dump_core(void) _NORETURN_; +void exit_server(const char *const reason) _NORETURN_; +void exit_server_cleanly(const char *const reason) _NORETURN_; +void exit_server_fault(void) _NORETURN_; #ifdef HAVE_LIBNSCD #include "libnscd.h" diff --git a/source3/include/interfaces.h b/source3/include/interfaces.h index 84501cee41..9a19c33b57 100644 --- a/source3/include/interfaces.h +++ b/source3/include/interfaces.h @@ -24,8 +24,8 @@ #ifndef _INTERFACES_H #define _INTERFACES_H -#include "lib/replace/replace.h" -#include "lib/replace/system/network.h" +#include "../replace/replace.h" +#include "../replace/system/network.h" #define MAX_INTERFACES 128 diff --git a/source3/include/libmsrpc.h b/source3/include/libmsrpc.h deleted file mode 100644 index 3f2a7260ca..0000000000 --- a/source3/include/libmsrpc.h +++ /dev/null @@ -1,3045 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * MS-RPC client library API definitions/prototypes - * - * Copyright (C) Chris Nicholls 2005. - * - * 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 . - */ - -#ifndef LIBMSRPC_H -#define LIBMSRPC_H - - -#include "includes.h" -#include "libsmbclient.h" -#include "libsmb_internal.h" - -/*server capability levels*/ -#define SRV_WIN_NT4 1 -#define SRV_WIN_2K 2 -#define SRV_WIN_2K_SP3 3 -#define SRV_WIN_2K3 4 - -/**@defgroup handle Server Handle*/ -/**@defgroup Library_Functions Library/Utility Functions*/ -/**@defgroup lsa_defs LSA Definitions*/ -/**@defgroup LSA_Functions LSA Functions*/ -/**@defgroup reg_defs Registry Definitions*/ -/**@defgroup Reg_Functions Registry Functions*/ -/**@defgroup sam_defs SAM Definitions*/ -/**@defgroup SAM_Functions SAM Functions*/ -/**@defgroup svc_defs Service Control Definitions*/ -/**@defgroup SCM_Functions Service Control Functions*/ - -/**Operation was unsuccessful*/ -#define CAC_FAILURE 0 -/**Operation was successful*/ -#define CAC_SUCCESS 1 -/**Operation was only partially successful - * an example of this is if you try to lookup a list of accounts to SIDs and not all accounts can be resolved*/ -#define CAC_PARTIAL_SUCCESS 2 - -/**@ingroup CAC_errors Use this to see if the last operation failed - useful for enumeration functions that use multiple calls*/ -#define CAC_OP_FAILED(status) !NT_STATUS_IS_OK(status) && \ - NT_STATUS_V(status) != NT_STATUS_V(STATUS_SOME_UNMAPPED) && \ - NT_STATUS_V(status) != NT_STATUS_V(STATUS_NO_MORE_FILES) && \ - NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_NO_MORE_ENTRIES) && \ - NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_NONE_MAPPED) && \ - NT_STATUS_V(status) != NT_STATUS_V(NT_STATUS_GUIDS_EXHAUSTED) - - -/**Privilege string constants*/ -#define CAC_SE_CREATE_TOKEN "SeCreateTokenPrivilege" -#define CAC_SE_ASSIGN_PRIMARY_TOKEN "SeAssignPrimaryTokenPrivilege" -#define CAC_SE_LOCK_MEMORY "SeLockMemoryPrivilege" -#define CAC_SE_INCREASE_QUOTA "SeIncreaseQuotaPrivilege" -#define CAC_SE_MACHINE_ACCOUNT "SeMachineAccountPrivilege" -#define CAC_SE_TCB "SeTcbPrivilege" -#define CAC_SE_SECURITY "SeSecurityPrivilege" -#define CAC_SE_TAKE_OWNERSHIP "SeTakeOwnershipPrivilege" -#define CAC_SE_LOAD_DRIVER "SeLoadDriverPrivilege" -#define CAC_SE_SYSTEM_PROFILE "SeSystemProfilePrivilege" -#define CAC_SE_SYSTEM_TIME "SeSystemtimePrivilege" -#define CAC_SE_PROFILE_SINGLE_PROC "SeProfileSingleProcessPrivilege" -#define CAC_SE_INCREASE_BASE_PRIORITY "SeIncreaseBasePriorityPrivilege" -#define CAC_SE_CREATE_PAGEFILE "SeCreatePagefilePrivilege" -#define CAC_SE_CREATE_PERMANENT "SeCreatePermanentPrivilege" -#define CAC_SE_BACKUP "SeBackupPrivilege" -#define CAC_SE_RESTORE "SeRestorePrivilege" -#define CAC_SE_SHUTDOWN "SeShutdownPrivilege" -#define CAC_SE_DEBUG "SeDebugPrivilege" -#define CAC_SE_AUDIT "SeAuditPrivilege" -#define CAC_SE_SYSTEM_ENV "SeSystemEnvironmentPrivilege" -#define CAC_SE_CHANGE_NOTIFY "SeChangeNotifyPrivilege" -#define CAC_SE_REMOTE_SHUTDOWN "SeRemoteShutdownPrivilege" -#define CAC_SE_UNDOCK "SeUndockPrivilege" -#define CAC_SE_SYNC_AGENT "SeSyncAgentPrivilege" -#define CAC_SE_ENABLE_DELEGATION "SeEnableDelegationPrivilege" -#define CAC_SE_MANAGE_VOLUME "SeManageVolumePrivilege" -#define CAC_SE_IMPERSONATE "SeImpersonatePrivilege" -#define CAC_SE_CREATE_GLOBAL "SeCreateGlobalPrivilege" -#define CAC_SE_PRINT_OPERATOR "SePrintOperatorPrivilege" -#define CAC_SE_NETWORK_LOGON "SeNetworkLogonRight" -#define CAC_SE_INTERACTIVE_LOGON "SeInteractiveLogonRight" -#define CAC_SE_BATCH_LOGON "SeBatchLogonRight" -#define CAC_SE_SERVICE_LOGON "SeServiceLogonRight" -#define CAC_SE_ADD_USERS "SeAddUsersPrivilege" -#define CAC_SE_DISK_OPERATOR "SeDiskOperatorPrivilege" - -/** - * @addtogroup lsa_defs - * @{ - */ -/**used to specify what data to retrieve using cac_LsaQueryTrustedDomainInformation*/ -#define CAC_INFO_TRUSTED_DOMAIN_NAME 0x1 -#define CAC_INFO_TRUSTED_DOMAIN_POSIX_OFFSET 0x3 -#define CAC_INFO_TRUSTED_DOMAIN_PASSWORD 0x4 - -/**Used when requesting machine domain information*/ -#define CAC_DOMAIN_INFO 0x0003 - -/**Used when requesting machine local information*/ -#define CAC_LOCAL_INFO 0x0005 - -/**Stores information about a SID*/ -typedef struct _CACSIDINFO { - /**The actual SID*/ - DOM_SID sid; - - /**The name of the object which maps to this SID*/ - char *name; - - /**The domain the SID belongs to*/ - char *domain; -} CacSidInfo; -/* @} */ - -/** - * @addtogroup reg_defs - * @{ - */ -/**Null terminated string*/ -typedef char* REG_SZ_DATA; - -/**Null terminated string with windows environment variables that should be expanded*/ -typedef char* REG_EXPAND_SZ_DATA; - -/**Binary data of some kind*/ -typedef struct _REGBINARYDATA { - uint32 data_length; - uint8 * data; -} REG_BINARY_DATA; - -/**32-bit (little endian) number*/ -typedef uint32 REG_DWORD_DATA; - -/**32-bit big endian number*/ -typedef uint32 REG_DWORD_BE_DATA; - -/**array of strings*/ -typedef struct _REGMULTISZDATA { - uint32 num_strings; - - char **strings; -} REG_MULTI_SZ_DATA; - -typedef union _REGVALUEDATA { - REG_SZ_DATA reg_sz; - REG_EXPAND_SZ_DATA reg_expand_sz; - REG_BINARY_DATA reg_binary; - REG_DWORD_DATA reg_dword; - REG_DWORD_BE_DATA reg_dword_be; - REG_MULTI_SZ_DATA reg_multi_sz; -} REG_VALUE_DATA; -/**@}*/ - -/** - * @addtogroup sam_defs - * @{ - */ - -#define CAC_USER_RID 0x1 -#define CAC_GROUP_RID 0x2 - -typedef struct _CACLOOKUPRIDSRECORD { - char *name; - uint32 rid; - - /**If found, this will be one of: - * - CAC_USER_RID - * - CAC_GROUP_RID - */ - uint32 type; - - /*if the name or RID was looked up, then found = True*/ - bool found; -} CacLookupRidsRecord; - -typedef struct _CACUSERINFO { - /**Last logon time*/ - time_t logon_time; - - /**Last logoff time*/ - time_t logoff_time; - - /**Last kickoff time*/ - time_t kickoff_time; - - /**Last password set time*/ - time_t pass_last_set_time; - - /**Time password can change*/ - time_t pass_can_change_time; - - /**Time password must change*/ - time_t pass_must_change_time; - - /**LM user password*/ - uint8 lm_password[8]; - - /**NT user password*/ - uint8 nt_password[8]; - - /**User's RID*/ - uint32 rid; - - /**RID of primary group*/ - uint32 group_rid; - - /**User's ACB mask*/ - uint32 acb_mask; - - /**Bad password count*/ - uint16 bad_passwd_count; - - /**Number of logons*/ - uint16 logon_count; - - /**Change password at next logon?*/ - bool pass_must_change; - - /**Username*/ - char *username; - - /**User's full name*/ - char *full_name; - - /**User's home directory*/ - char *home_dir; - - /**Home directory drive*/ - char *home_drive; - - /**Logon script*/ - char *logon_script; - - /**Path to profile*/ - char *profile_path; - - /**Account description*/ - char *description; - - /**Login from workstations*/ - char *workstations; - - char *dial; - - /**Possible logon hours*/ - LOGON_HRS *logon_hours; - -} CacUserInfo; - -typedef struct _CACGROUPINFO { - /**Group name*/ - char *name; - - /**Description*/ - char *description; - - /**Number of members*/ - uint32 num_members; -} CacGroupInfo, CacAliasInfo; - -/**Represents a period (duration) of time*/ -typedef struct _CACTIME { - /**Number of days*/ - uint32 days; - - /**Number of hours*/ - uint32 hours; - - /**Number of minutes*/ - uint32 minutes; - - /**number of seconds*/ - uint32 seconds; -} CacTime; - - -typedef struct _CACDOMINFO { - /**The server role. Should be one of: - * ROLE_STANDALONE - * ROLE_DOMAIN_MEMBER - * ROLE_DOMAIN_BDC - * ROLE_DOMAIN_PDC - * see include/smb.h - */ - uint32 server_role; - - /**Number of domain users*/ - uint32 num_users; - - /**Number of domain groups*/ - uint32 num_domain_groups; - - /**Number of local groups*/ - uint32 num_local_groups; - - /**Comment*/ - char *comment; - - /**Domain name*/ - char *domain_name; - - /**Server name*/ - char *server_name; - - /**Minimum password length*/ - uint16 min_pass_length; - - /**How many previous passwords to remember - ie, password cannot be the same as N previous passwords*/ - uint16 pass_history; - - /**How long (from now) before passwords expire*/ - CacTime expire; - - /**How long (from now) before passwords can be changed*/ - CacTime min_pass_age; - - /**How long users are locked out for too many bad password attempts*/ - CacTime lockout_duration; - - /**How long before lockouts are reset*/ - CacTime lockout_reset; - - /**How many bad password attempts before lockout occurs*/ - uint16 num_bad_attempts; -} CacDomainInfo; - -/**@}*/ /*sam_defs*/ - -/**@addtogroup svc_defs - * @{ - */ -typedef struct _CACSERVICE { - /**The service name*/ - char *service_name; - - /**The display name of the service*/ - char *display_name; - - /**Current status of the service - see include/rpc_svcctl.h for SERVICE_STATUS definition*/ - SERVICE_STATUS status; -} CacService; - -typedef struct __CACSERVICECONFIG { - /**The service type*/ - uint32 type; - - /**The start type. Should be one of: - * - SVCCTL_BOOT_START - * - SVCCTL_SYSTEM_START - * - SVCCTL_AUTO_START - * - SVCCTL_DEMAND_START - */ - uint32 start_type; - - uint32 error_control; - - /**Path to executable*/ - char *exe_path; - - /***/ - char *load_order_group; - - uint32 tag_id; - - /**Any dependencies for the service*/ - char *dependencies; - - /**Run as...*/ - char *start_name; - - /**Service display name*/ - char *display_name; - -} CacServiceConfig; -/**@}*/ /*svc_defs*/ - -#include "libmsrpc_internal.h" - -/** - * @addtogroup handle - * @{ - */ - -/** - * Server handle used to keep track of client/server/pipe information. Use cac_NewServerHandle() to allocate. - * Initiliaze as many values as possible before calling cac_Connect(). - * - * @note When allocating memory for the fields, use SMB_MALLOC() (or equivalent) instead of talloc() (or equivalent) - - * If memory is not allocated for a field, cac_Connect will allocate sizeof(fstring) bytes for it. - * - * @note It may be wise to allocate large buffers for these fields and strcpy data into them. - * - * @see cac_NewServerHandle() - * @see cac_FreeHandle() - */ -typedef struct _CACSERVERHANDLE { - /** debug level - */ - int debug; - - /** netbios name used to make connections - */ - char *netbios_name; - - /** domain name used to make connections - */ - char *domain; - - /** username used to make connections - */ - char *username; - - /** user's password plain text string - */ - char *password; - - /** name or IP address of server we are currently working with - */ - char *server; - - /**stores the latest NTSTATUS code - */ - NTSTATUS status; - - /** internal. do not modify! - */ - struct CacServerHandleInternal _internal; - -} CacServerHandle; - -/*@}*/ - -/**internal function. do not call this function*/ -SMBCSRV *cac_GetServer(CacServerHandle *hnd); - - -/** @addtogroup Library_Functions - * @{ - */ -/** - * Initializes the library - do not need to call this function. Open's smb.conf as well as initializes logging. - * @param debug Debug level for library to use - */ - -void cac_Init(int debug); - -/** - * Creates an un-initialized CacServerHandle - * @param allocate_fields If True, the function will allocate sizeof(fstring) bytes for all char * fields in the handle - * @return - un-initialized server handle - * - NULL if no memory could be allocated - */ -CacServerHandle * cac_NewServerHandle(bool allocate_fields); - -/** - * Specifies the smbc_get_auth_data_fn to use if you do not want to use the default. - * @param hnd non-NULL server handle - * @param auth_fn auth_data_fn to set in server handle - */ - -void cac_SetAuthDataFn(CacServerHandle *hnd, smbc_get_auth_data_fn auth_fn); - -/** Use your own libsmbclient context - not necessary. - * @note You must still call cac_Connect() after specifying your own libsmbclient context - * @param hnd Initialized, but not connected CacServerHandle - * @param ctx The libsmbclient context you would like to use. - */ -void cac_SetSmbcContext(CacServerHandle *hnd, SMBCCTX *ctx); - -/** Connects to a specified server. If there is already a connection to a different server, - * it will be cleaned up before connecting to the new server. - * @param hnd Pre-initialized CacServerHandle - * @param srv (Optional) Name or IP of the server to connect to. If NULL, server from the CacServerHandle will be used. - * - * @return CAC_FAILURE if the operation could not be completed successfully (hnd->status will also be set with a NTSTATUS code) - * @return CAC_SUCCESS if the operation succeeded - */ -int cac_Connect(CacServerHandle *hnd, const char *srv); - - -/** - * Cleans up any data used by the CacServerHandle. If the libsmbclient context was set using cac_SetSmbcContext(), it will not be free'd. - * @param hnd the CacServerHandle to destroy - */ -void cac_FreeHandle(CacServerHandle * hnd); - -/** - * Initializes a CacTime structure based on an NTTIME structure - * If the function fails, then the CacTime structure will be zero'd out - */ -void cac_InitCacTime(CacTime *cactime, NTTIME nttime); - -/** - * Called by cac_NewServerHandle() if allocate_fields = True. You can call this if you want to, allocates sizeof(fstring) char's for every char * field - * @param hnd Uninitialized server handle - * @return CAC_FAILURE Memory could not be allocated - * @return CAC_SUCCESS Memory was allocated - */ -int cac_InitHandleMem(CacServerHandle *hnd); - -/** - * Default smbc_get_auth_data_fn for libmsrpc. This function is called when libmsrpc needs to get more information about the - * client (username/password, workgroup). - * This function provides simple prompts to the user to enter the information. This description his here so you know how to re-define this function. - * @see cac_SetAuthDataFn() - * @param pServer Name/IP of the server to connect to. - * @param pShare Share name to connect to - * @param pWorkgroup libmsrpc passes in the workgroup/domain name from hnd->domain. It can be modified in the function. - * @param maxLenWorkgroup The maximum length of a string pWogroup can hold. - * @param pUsername libmsrpc passes in the username from hnd->username. It can be modified in the function. - * @param maxLenUsername The maximum length of a string pUsername can hold. - * @param pPassword libmsrpc pass in the password from hnd->password. It can be modified in the function. - * @param maxLenPassword The maximum length of a string pPassword can hold. - */ -void cac_GetAuthDataFn(const char * pServer, - const char * pShare, - char * pWorkgroup, - int maxLenWorkgroup, - char * pUsername, - int maxLenUsername, - char * pPassword, - int maxLenPassword); - - -/**@}*/ - -/***************** - * LSA Functions * - *****************/ - -/** @addtogroup LSA_Functions - * @{ - */ - -struct LsaOpenPolicy { - /**Inputs*/ - struct { - /**Access Mask. Refer to Security Access Masks in include/rpc_secdes.h*/ - uint32 access; - - /**Use security quality of service? (True/False)*/ - bool security_qos; - } in; - - /**Outputs*/ - struct { - /**Handle to the open policy (needed for all other operations)*/ - POLICY_HND *pol; - } out; -}; - -/** - * Opens a policy handle on a remote machine. - * @param hnd fully initialized CacServerHandle for remote machine - * @param mem_ctx Talloc context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE if the policy could not be opened. hnd->status set with appropriate NTSTATUS - * @return CAC_SUCCESS if the policy could be opened, the policy handle can be found - */ -int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op); - - -/** - * Closes an LSA policy handle (Retrieved using cac_LsaOpenPolicy). - * If successful, the handle will be closed on the server, and memory for pol will be freed - * @param hnd - An initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param pol - the policy handle to close - * @return CAC_FAILURE could not close the policy handle, hnd->status is set to the appropriate NTSTATUS error code - * @return CAC_SUCCESS the policy handle was closed - */ -int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *pol); - - -struct LsaGetNamesFromSids { - struct { - /**handle to and open LSA policy*/ - POLICY_HND *pol; - - /**the number of SIDs to lookup*/ - uint32 num_sids; - - /**array of SIDs to lookup*/ - DOM_SID *sids; - } in; - - struct { - /**The number of names returned (in case of CAC_PARTIAL_SUCCESS)*/ - uint32 num_found; - - /**array of SID info each index is one sid */ - CacSidInfo *sids; - - /**in case of partial success, an array of SIDs that could not be looked up (NULL if all sids were looked up)*/ - DOM_SID *unknown; - } out; -}; - -/** - * Looks up the names for a list of SIDS - * @param hnd initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op input and output parameters - * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code - * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output - * @return CAC_PARTIAL_SUCCESS not all of the SIDs were translated, as a result the number of returned names is less than the original list of SIDs - */ -int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetNamesFromSids *op); - -struct LsaGetSidsFromNames { - struct { - /**handle to an open LSA policy*/ - POLICY_HND *pol; - - /**number of SIDs to lookup*/ - uint32 num_names; - - /**array of strings listing the names*/ - char **names; - } in; - - struct { - /**The number of SIDs returned (in case of partial success*/ - uint32 num_found; - - /**array of SID info for the looked up names*/ - CacSidInfo *sids; - - /**in case of partial success, the names that were not looked up*/ - char **unknown; - } out; -}; - -/** - * Looks up the SIDs for a list of names - * @param hnd initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op input and output parameters - * @return CAC_FAILURE none of the SIDs could be looked up hnd->status is set with appropriate NTSTATUS error code - * @return CAC_SUCCESS all of the SIDs were translated and a list of names has been output - * @return CAC_PARTIAL_SUCCESS not all of the SIDs were translated, as a result the number of returned names is less than the original list of SIDs - */ -int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSidsFromNames *op); - -struct LsaFetchSid { - struct { - /**handle to an open LSA policy*/ - POLICY_HND *pol; - - /**can be CAC_LOCAL_INFO, CAC_DOMAIN_INFO, or (CAC_LOCAL_INFO | CAC_DOMAIN_INFO)*/ - uint16 info_class; - } in; - - struct { - /**the machine's local SID and domain name (NULL if not asked for)*/ - CacSidInfo *local_sid; - - /**the machine's domain SID and name (NULL if not asked for)*/ - CacSidInfo *domain_sid; - - } out; -}; - -/** - * Looks up the domain or local sid of a machine with an open LSA policy handle - * @param hnd initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op input and output parameters - * @return CAC_FAILURE if the SID could not be fetched - * @return CAC_SUCCESS if the SID was fetched - * @return CAC_PARTIAL_SUCCESS if you asked for both local and domain sids but only one was returned - */ -int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSid *op); - -struct LsaQueryInfoPolicy { - struct { - /**Open LSA policy handle on remote server*/ - POLICY_HND *pol; - } in; - - struct { - /**remote server's domain name*/ - char *domain_name; - - /**remote server's dns name*/ - char *dns_name; - - /**remote server's forest name*/ - char *forest_name; - - /**remote server's domain guid*/ - struct GUID *domain_guid; - - /**remote server's domain SID*/ - DOM_SID *domain_sid; - } out; -}; - -/** - * Retrieves information about the LSA machine/domain - * @param hnd initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op input and output parameters - * Note: for pre-Windows 2000 machines, only op->out.SID and op->out.domain will be set. @see cac_LsaFetchSid - * @return - CAC_FAILURE if the operation was not successful. hnd->status will be set with an accurate NT_STATUS code - * @return CAC_SUCCESS the operation was successful. - */ -int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryInfoPolicy *op); - -struct LsaEnumSids { - struct { - /**Open LSA Policy handle*/ - POLICY_HND *pol; - - /**The prefered maximum number of SIDs returned per call*/ - uint32 pref_max_sids; - } in; - - struct { - /**used to keep track of how many sids have been retrieved over multiple calls - * should be set to zero via ZERO_STRUCT() befrore the first call. Use the same struct LsaEnumSids for multiple calls*/ - uint32 resume_idx; - - /**The number of sids returned this call*/ - uint32 num_sids; - - /**Array of sids returned*/ - DOM_SID *sids; - - } out; -}; - -/** - * Enumerates the SIDs in the LSA. Can be enumerated in blocks by calling the function multiple times. - * Example: while(cac_LsaEnumSids(hnd, mem_ctx, op) { ... } - * @param hnd - An initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE there was an error during operations OR there are no more results - * @return CAC_SUCCESS the operation completed and results were returned - */ -int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSids *op); - -struct LsaEnumAccountRights { - struct { - /**Open LSA Policy handle*/ - POLICY_HND *pol; - - /**(Optional) SID of the account - must supply either sid or name*/ - DOM_SID *sid; - - /**(Optional) name of the account - must supply either sid or name*/ - char *name; - } in; - - struct { - /**Count of rights for this account*/ - uint32 num_privs; - - /**array of privilege names*/ - char **priv_names; - } out; -}; - -/** - * Enumerates rights assigned to a given account. Takes a SID instead of account handle as input - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE the rights could not be retrieved. hnd->status is set with NT_STATUS code - * @return CAC_SUCCESS the operation was successful. - */ - -int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumAccountRights *op); - -struct LsaEnumTrustedDomains { - struct { - /**Open LSA policy handle*/ - POLICY_HND *pol; - } in; - - struct { - /**used to keep track of how many domains have been retrieved over multiple calls - * should be set to zero via ZERO_STRUCT() before the first call. Use the same struct LsaEnumSids for multiple calls*/ - uint32 resume_idx; - - /**The number of domains returned by the remote server this call*/ - uint32 num_domains; - - /**array of trusted domain names returned by the remote server*/ - char **domain_names; - - /**array of trusted domain sids returned by the remote server*/ - DOM_SID *domain_sids; - } out; -}; - -/** - * Enumerates the trusted domains in the LSA. - * @param hnd - An initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op - initialized parameters - * @return CAC_FAILURE there was an error during operations OR there are no more results - * @return CAC_SUCCESS the operation completed and results were returned - */ -int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumTrustedDomains *op); - -struct LsaOpenTrustedDomain { - struct { - /**an open LSA policy handle*/ - POLICY_HND *pol; - - /**SID of the trusted domain to open*/ - DOM_SID *domain_sid; - - /**Desired access on the open domain*/ - uint32 access; - } in; - - struct { - /**A handle to the policy that is opened*/ - POLICY_HND *domain_pol; - } out; -}; - -/** - * Opens a trusted domain by SID. - * @param hnd An initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op initialized I/O parameters - * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code - * @return CAC_SUCCESS the domain was opened successfully - */ -int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenTrustedDomain *op); - -struct LsaQueryTrustedDomainInfo { - struct { - /**Open LSA policy handle*/ - POLICY_HND *pol; - - /**Info class of returned data*/ - uint16 info_class; - - /**(Optional)SID of trusted domain to query (must specify either SID or name of trusted domain)*/ - DOM_SID *domain_sid; - - /**(Optional)Name of trusted domain to query (must specify either SID or name of trusted domain)*/ - char *domain_name; - } in; - - struct { - /**information about the trusted domain*/ - LSA_TRUSTED_DOMAIN_INFO *info; - } out; -}; - -/** - * Retrieves information a trusted domain. - * @param hnd An initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op initialized I/O parameters - * @return CAC_FAILURE a handle to the domain could not be opened. hnd->status is set with approriate NT_STATUS code - * @return CAC_SUCCESS the domain was opened successfully - */ - -int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryTrustedDomainInfo *op); - -struct LsaEnumPrivileges { - struct { - /**An open LSA policy handle*/ - POLICY_HND *pol; - - /**The _preferred_ maxinum number of privileges returned per call*/ - uint32 pref_max_privs; - } in; - - struct { - /**Used to keep track of how many privileges have been retrieved over multiple calls. Do not modify this value between calls*/ - uint32 resume_idx; - - /**The number of privileges returned this call*/ - uint32 num_privs; - - /**Array of privilege names*/ - char **priv_names; - - /**Array of high bits for privilege LUID*/ - uint32 *high_bits; - - /**Array of low bits for privilege LUID*/ - uint32 *low_bits; - } out; -}; - -/** - * Enumerates the Privileges supported by the LSA. Can be enumerated in blocks by calling the function multiple times. - * Example: while(cac_LsaEnumPrivileges(hnd, mem_ctx, op) { ... } - * @param hnd An initialized and connected server handle - * @param mem_ctx Talloc context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE there was an error during operations OR there are no more results - * @return CAC_SUCCESS the operation completed and results were returned - * @see CAC_OP_FAILED() - */ -int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumPrivileges *op); - -struct LsaOpenAccount { - struct { - /**An open LSA policy handle*/ - POLICY_HND *pol; - - /**(Optional) account SID - must supply either sid or name*/ - DOM_SID *sid; - - /**(Optional) account name - must supply either sid or name*/ - char *name; - - /**desired access for the handle*/ - uint32 access; - } in; - - struct { - /**A handle to the opened user*/ - POLICY_HND *user; - } out; -}; - -/** - * Opens a handle to an account in the LSA - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE the account could not be opened. hnd->status has appropriate NT_STATUS code - * @return CAC_SUCCESS the account was opened - */ -int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenAccount *op); - -struct LsaAddPrivileges { - struct { - /**An open LSA policy handle*/ - POLICY_HND *pol; - - /**(Optional) The user's SID (must specify at least sid or name)*/ - DOM_SID *sid; - - /**(Optional) The user's name (must specify at least sid or name)*/ - char *name; - - /**The privilege names of the privileges to add for the account*/ - char **priv_names; - - /**The number of privileges in the priv_names array*/ - uint32 num_privs; - - } in; -}; - -/** - * Adds Privileges an account. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE the privileges could not be set. hnd->status has appropriate NT_STATUS code - * @return CAC_SUCCESS the privileges were set. - */ -int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op); - -struct LsaRemovePrivileges { - struct { - /**An open handle to the LSA*/ - POLICY_HND *pol; - - /**(Optional) The account SID (must specify at least sid or name)*/ - DOM_SID *sid; - - /**(Optional) The account name (must specify at least sid or name)*/ - char *name; - - /**The privilege names of the privileges to remove from the account*/ - char **priv_names; - - /**The number of privileges in the priv_names array*/ - uint32 num_privs; - - } in; - -}; - -/** - * Removes a _specific_ set of privileges from an account - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE the privileges could not be removed. hnd->status is set with NT_STATUS code - * @return CAC_SUCCESS the privileges were removed - */ -int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaRemovePrivileges *op); - -struct LsaClearPrivileges { - struct { - /**An open handle to the LSA*/ - POLICY_HND *pol; - - /**(Optional) The user's SID (must specify at least sid or name)*/ - DOM_SID *sid; - - /**(Optional) The user's name (must specify at least sid or name)*/ - char *name; - } in; - -}; - -/** - * Removes ALL privileges from an account - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE the operation was not successful, hnd->status set with NT_STATUS code - * @return CAC_SUCCESS the opeartion was successful. - */ -int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaClearPrivileges *op); - -/** - * Sets an accounts priviliges. Removes all privileges and then adds specified privileges. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE The operation could not complete successfully - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op); - -struct LsaGetSecurityObject { - struct { - /**Open LSA policy handle*/ - POLICY_HND *pol; - } in; - - struct { - /**Returned security descriptor information*/ - SEC_DESC_BUF *sec; - } out; -}; - -/** - * Retrieves Security Descriptor information about the LSA - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE The operation could not complete successfully - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_LsaGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSecurityObject *op); - - -/**@}*/ /*LSA_Functions*/ - -/********************** - * Registry Functions * - *********************/ - -/**@addtogroup Reg_Functions - * @{ - */ - -struct RegConnect { - struct { - /** must be one of : - * HKEY_CLASSES_ROOT, - * HKEY_LOCAL_MACHINE, - * HKEY_USERS, - * HKEY_PERFORMANCE_DATA, - */ - int root; - - /**desired access on the root key - * combination of: - * REG_KEY_READ, - * REG_KEY_WRITE, - * REG_KEY_EXECUTE, - * REG_KEY_ALL, - * found in include/rpc_secdes.h*/ - uint32 access; - } in; - - struct { - POLICY_HND *key; - } out; -}; - -/** - * Opens a handle to the registry on the server - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op); - -/** - * Closes an open registry handle - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param key The Key/Handle to close - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key); - -struct RegOpenKey { - struct { - /**(Optional)parent key. - * If this is NULL, then cac_RegOpenKey() will attempt to connect to the registry, name MUST start with something like:
- * HKEY_LOCAL_MACHINE\ or an abbreviation like HKCR\ - * - * supported root names: - * - HKEY_LOCAL_MACHINE\ or HKLM\ - * - HKEY_CLASSES_ROOT\ or HKCR\ - * - HKEY_USERS\ or HKU\ - * - HKEY_PERFORMANCE_DATA or HKPD\ - */ - POLICY_HND *parent_key; - - /**name/path of key*/ - char *name; - - /**desired access on this key*/ - uint32 access; - } in; - - struct { - POLICY_HND *key; - } out; -}; - -/** - * Opens a registry key - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey *op); - -struct RegEnumKeys { - struct { - /**enumerate subkeys of this key*/ - POLICY_HND *key; - - /**maximum number of keys to enumerate each call*/ - uint32 max_keys; - } in; - - struct { - /**keeps track of the index to resume enumerating*/ - uint32 resume_idx; - - /**the number of keys returned this call*/ - uint32 num_keys; - - /**array of key names*/ - char **key_names; - - /**class names of the keys*/ - char **class_names; - - /**last modification time of the key*/ - time_t *mod_times; - } out; -}; - -/** - * Enumerates Subkeys of a given key. Can be run in a loop. Example: while(cac_RegEnumKeys(hnd, mem_ctx, op)) { ... } - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @see CAC_OP_FAILED() - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op); - - -struct RegCreateKey { - struct { - /**create a subkey of parent_key*/ - POLICY_HND *parent_key; - - /**name of the key to create*/ - char *key_name; - - /**class of the key*/ - char *class_name; - - /**Access mask to open the key with. See REG_KEY_* in include/rpc_secdes.h*/ - uint32 access; - } in; - - struct { - /**Open handle to the key*/ - POLICY_HND *key; - } out; -}; - -/** - * Creates a registry key, if the key already exists, it will be opened __Creating keys is not currently working__. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parmeters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op); - -struct RegDeleteKey { - struct { - /**handle to open registry key*/ - POLICY_HND *parent_key; - - /**name of the key to delete*/ - char *name; - - /**delete recursively. WARNING: this might not always work as planned*/ - bool recursive; - } in; - -}; - -/** - * Deletes a subkey of an open key. Note: if you run this with op->in.recursive == True, and the operation fails, it may leave the key in an inconsistent state. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op); - -struct RegDeleteValue { - struct { - /**handle to open registry key*/ - POLICY_HND *parent_key; - - /**name of the value to delete*/ - char *name; - } in; -}; - -/** - * Deletes a registry value. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op); - -struct RegQueryKeyInfo { - struct { - /**Open handle to the key to query*/ - POLICY_HND *key; - } in; - - struct { - /**name of the key class*/ - char *class_name; - - /**number of subkeys of the key*/ - uint32 num_subkeys; - - /**length (in characters) of the longest subkey name*/ - uint32 longest_subkey; - - /**length (in characters) of the longest class name*/ - uint32 longest_class; - - /**number of values in this key*/ - uint32 num_values; - - /**length (in characters) of the longest value name*/ - uint32 longest_value_name; - - /**length (in bytes) of the biggest value data*/ - uint32 longest_value_data; - - /**size (in bytes) of the security descriptor*/ - uint32 security_desc_size; - - /**time of the last write*/ - time_t last_write_time; - } out; -}; - -/** - * Retrieves information about an open key - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryKeyInfo *op); - -struct RegSaveKey { - struct { - /**Open key to be saved*/ - POLICY_HND *key; - - /**The path (on the remote computer) to save the file to*/ - char *filename; - } in; -}; - -/** - * Saves a key to a file on the remote machine __Not currently working__. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op); - -struct RegQueryValue { - struct { - /**handle to open registry key*/ - POLICY_HND *key; - - /**name of the value to query*/ - char *val_name; - } in; - - struct { - /**Value type. - * One of: - * - REG_DWORD (equivalent to REG_DWORD_LE) - * - REG_DWORD_BE - * - REG_SZ - * - REG_EXPAND_SZ - * - REG_MULTI_SZ - * - REG_BINARY - */ - uint32 type; - - /**The value*/ - REG_VALUE_DATA *data; - } out; -}; - -/** - * Retrieves a value (type and data) _not currently working_. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op); - -struct RegEnumValues { - struct { - /**handle to open key*/ - POLICY_HND *key; - - /**max number of values returned per call*/ - uint32 max_values; - - } in; - - struct { - /**keeps track of the index to resume from - used over multiple calls*/ - uint32 resume_idx; - - /**the number of values that were returned this call*/ - uint32 num_values; - - /**Array of value types. A type can be one of: - * - REG_DWORD (equivalent to REG_DWORD_LE) - * - REG_DWORD_BE - * - REG_SZ - * - REG_EXPAND_SZ - * - REG_MULTI_SZ - * - REG_BINARY - */ - uint32 *types; - - /**array of strings storing the names of the values*/ - char **value_names; - - /**array of pointers to the value data returned*/ - REG_VALUE_DATA **values; - } out; -}; - -/** - * Enumerates a number of Registry values in an open registry key. - * Can be run in a loop. Example: while(cac_RegEnumValues(hnd, mem_ctx, op)) { ... } - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @see CAC_OP_FAILED() - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op); - -struct RegSetValue { - struct { - /**Handle to open registry key*/ - POLICY_HND *key; - - /**Name of the value*/ - char *val_name; - - /**Value type. - * One of: - * - REG_DWORD (equivalent to REG_DWORD_LE) - * - REG_DWORD_BE - * - REG_SZ - * - REG_EXPAND_SZ - * - REG_MULTI_SZ - * - REG_BINARY - */ - uint32 type; - - /**the value*/ - REG_VALUE_DATA value; - } in; -}; - -/** - * Sets or creates value (type and data). - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op); - -struct RegGetVersion { - struct { - /**open registry key*/ - POLICY_HND *key; - } in; - - struct { - /**version number*/ - uint32 version; - } out; -}; - -/** - * Retrieves the registry version number - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op); - -struct RegGetKeySecurity { - struct { - /**Handle to key to query*/ - POLICY_HND *key; - - /**Info that you want. Should be a combination of (1 or more or'd): - * - OWNER_SECURITY_INFORMATION - * - GROUP_SECURITY_INFORMATION - * - DACL_SECURITY_INFORMATION - * - SACL_SECURITY_INFORMATION - * - UNPROTECTED_SACL_SECURITY_INFORMATION - * - UNPROTECTED_DACL_SECURITY_INFORMATION - * - PROTECTED_SACL_SECURITY_INFORMATION - * - PROTECTED_DACL_SECURITY_INFORMATION - * - * or use: - * - ALL_SECURITY_INFORMATION - * - * all definitions from include/rpc_secdes.h - */ - uint32 info_type; - } in; - - struct { - /**size of the data returned*/ - uint32 size; - - /**Security descriptor*/ - SEC_DESC *descriptor; - } out; -}; - -/** - * Retrieves a key security descriptor. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op); - -struct RegSetKeySecurity { - struct { - /**Handle to key to query*/ - POLICY_HND *key; - - /**Info that you want. Should be a combination of (1 or more or'd): - * - OWNER_SECURITY_INFORMATION - * - GROUP_SECURITY_INFORMATION - * - DACL_SECURITY_INFORMATION - * - SACL_SECURITY_INFORMATION - * - UNPROTECTED_SACL_SECURITY_INFORMATION - * - UNPROTECTED_DACL_SECURITY_INFORMATION - * - PROTECTED_SACL_SECURITY_INFORMATION - * - PROTECTED_DACL_SECURITY_INFORMATION - * - * or use: - * - ALL_SECURITY_INFORMATION - * - * all definitions from include/rpc_secdes.h - */ - uint32 info_type; - - /**size of the descriptor*/ - size_t size; - - /**Security descriptor*/ - SEC_DESC *descriptor; - } in; -}; - -/** - * Sets the key security descriptor. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op); - -/**@}*/ /*Reg_Functions*/ - -struct Shutdown { - struct { - /**the message to display (can be NULL)*/ - char *message; - - /**timeout in seconds*/ - uint32 timeout; - - /**False = shutdown, True = reboot*/ - bool reboot; - - /**force the*/ - bool force; - - /*FIXME: make this useful*/ - uint32 reason; - } in; -}; - - -/** - * Shutdown the server _not currently working_. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op); - -/** - * Attempt to abort initiated shutdown on the server _not currently working_. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx); - -/***************** - * SAM Functions * - *****************/ - -/**@addtogroup SAM_Functions - * @{ - */ -struct SamConnect { - struct { - /**Access mask to open with - * see generic access masks in include/smb.h*/ - uint32 access; - } in; - - struct { - POLICY_HND *sam; - } out; -}; - -/** - * Connects to the SAM. This can be skipped by just calling cac_SamOpenDomain() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect *op); - - -/** - * Closes any (SAM, domain, user, group, etc.) SAM handle. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param sam Handle to close - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sam); - -struct SamOpenDomain { - struct { - /**The desired access. See generic access masks - include/smb.h*/ - uint32 access; - - /**(Optional) An open handle to the SAM. If it is NULL, the function will connect to the SAM with the access mask above*/ - POLICY_HND *sam; - - /**(Optional) The SID of the domain to open. - * If this this is NULL, the function will attempt to open the domain specified in hnd->domain */ - DOM_SID *sid; - } in; - - struct { - /**handle to the open domain*/ - POLICY_HND *dom_hnd; - - /**Handle to the open SAM*/ - POLICY_HND *sam; - } out; -}; - -/** - * Opens a handle to a domain. This must be called before any other SAM functions - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenDomain *op); - -struct SamCreateUser { - struct { - /**Open domain handle*/ - POLICY_HND *dom_hnd; - - /**Username*/ - char *name; - - /**See Allowable account control bits in include/smb.h*/ - uint32 acb_mask; - } in; - - struct { - /**handle to the user*/ - POLICY_HND *user_hnd; - - /**rid of the user*/ - uint32 rid; - } out; -}; - -/** - * Creates a new domain user, if the account already exists it will _not_ be opened and hnd->status will be NT_STATUS_USER_EXISTS - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamCreateUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateUser *op); - -struct SamOpenUser { - struct { - /**Handle to open SAM connection*/ - POLICY_HND *dom_hnd; - - /**desired access - see generic access masks in include/smb.h*/ - uint32 access; - - /**RID of the user*/ - uint32 rid; - - /**(Optional) name of the user - must supply either RID or user name*/ - char *name; - } in; - - struct { - /**Handle to the user*/ - POLICY_HND *user_hnd; - } out; -}; - -/** - * Opens a domain user. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUser *op); - -/** - * Deletes a domain user. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param user_hnd Open handle to the user - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamDeleteUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd); - - -struct SamEnumUsers { - struct { - /**Open handle to a domain*/ - POLICY_HND *dom_hnd; - - /**Enumerate users with specific ACB. If 0, all users will be enumerated*/ - uint32 acb_mask; - } in; - - struct { - /**where to resume from. Used over multiple calls*/ - uint32 resume_idx; - - /**the number of users returned this call*/ - uint32 num_users; - - /**Array storing the rids of the returned users*/ - uint32 *rids; - - /**Array storing the names of all the users returned*/ - char **names; - - bool done; - } out; -}; - -/** - * Enumerates domain users. Can be used as a loop condition. Example: while(cac_SamEnumUsers(hnd, mem_ctx, op)) { ... } - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamEnumUsers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUsers *op); - -struct SamGetNamesFromRids { - struct { - /**An open handle to the domain SAM from cac_SamOpenDomain()*/ - POLICY_HND *dom_hnd; - - /**Number of RIDs to resolve*/ - uint32 num_rids; - - /**Array of RIDs to resolve*/ - uint32 *rids; - } in; - - struct { - /**the number of names returned - if this is 0, the map is NULL*/ - uint32 num_names; - - /**array contiaing the Names and RIDs*/ - CacLookupRidsRecord *map; - } out; -}; - -/** - * Returns a list of names which map to a list of RIDs. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetNamesFromRids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetNamesFromRids *op); - -struct SamGetRidsFromNames { - struct { - /**An open handle to the domain SAM from cac_SamOpenDomain()*/ - POLICY_HND *dom_hnd; - - /**Number of names to resolve*/ - uint32 num_names; - - /**Array of names to resolve*/ - char **names; - } in; - - struct { - /**the number of names returned - if this is 0, then map is NULL*/ - uint32 num_rids; - - /**array contiaing the Names and RIDs*/ - CacLookupRidsRecord *map; - } out; -}; - -/** - * Returns a list of RIDs which map to a list of names. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetRidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetRidsFromNames *op); - -struct SamGetGroupsForUser { - struct { - /**An open handle to the user*/ - POLICY_HND *user_hnd; - } in; - - struct { - /**The number of groups the user is a member of*/ - uint32 num_groups; - - /**The RIDs of the groups*/ - uint32 *rids; - - /**The attributes of the groups*/ - uint32 *attributes; - } out; -}; -/** - * Retrieves a list of groups that a user is a member of. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetGroupsForUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupsForUser *op); - -struct SamOpenGroup { - struct { - /**Open handle to the domain SAM*/ - POLICY_HND *dom_hnd; - - /**Desired access to open the group with. See Generic access masks in include/smb.h*/ - uint32 access; - - /**rid of the group*/ - uint32 rid; - } in; - - struct { - /**Handle to the group*/ - POLICY_HND *group_hnd; - } out; -}; - -/** - * Opens a domain group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamOpenGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGroup *op); - -struct SamCreateGroup { - struct { - /**Open handle to the domain SAM*/ - POLICY_HND *dom_hnd; - - /**Desired access to open the group with. See Generic access masks in include/smb.h*/ - uint32 access; - - /**The name of the group*/ - char *name; - } in; - - struct { - /**Handle to the group*/ - POLICY_HND *group_hnd; - } out; -}; - -/** - * Creates a group. If the group already exists it will not be opened. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamCreateGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateGroup *op); - -/** - * Deletes a domain group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param group_hnd Open handle to the group. - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamDeleteGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd); - -struct SamGetGroupMembers { - struct { - /**Open handle to a group*/ - POLICY_HND *group_hnd; - } in; - - struct { - /**The number of members in the group*/ - uint32 num_members; - - /**An array storing the RIDs of the users*/ - uint32 *rids; - - /**The attributes*/ - uint32 *attributes; - } out; -}; - -/** - * Retrives a list of users in a group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupMembers *op); - -struct SamAddGroupMember { - struct { - /**Open handle to a group*/ - POLICY_HND *group_hnd; - - /**RID of new member*/ - uint32 rid; - } in; -}; - -/** - * Adds a user to a group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamAddGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddGroupMember *op); - -struct SamRemoveGroupMember { - struct { - /**Open handle to a group*/ - POLICY_HND *group_hnd; - - /**RID of member to remove*/ - uint32 rid; - } in; -}; - -/** - * Removes a user from a group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamRemoveGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveGroupMember *op); - -/** - * Removes all the members of a group - warning: if this function fails is is possible that some but not all members were removed - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param group_hnd Open handle to the group to clear - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd); - -struct SamSetGroupMembers { - struct { - /**Open handle to the group*/ - POLICY_HND *group_hnd; - - /**Number of members in the group - if this is 0, all members of the group will be removed*/ - uint32 num_members; - - /**The RIDs of the users to add*/ - uint32 *rids; - } in; -}; - -/** - * Clears the members of a group and adds a list of members to the group - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamSetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupMembers *op); - -struct SamEnumGroups { - struct { - /**Open handle to a domain*/ - POLICY_HND *dom_hnd; - } in; - - struct { - /**Where to resume from _do not_ modify this value. Used over multiple calls.*/ - uint32 resume_idx; - - /**the number of users returned this call*/ - uint32 num_groups; - - /**Array storing the rids of the returned groups*/ - uint32 *rids; - - /**Array storing the names of all the groups returned*/ - char **names; - - /**Array storing the descriptions of all the groups returned*/ - char **descriptions; - - bool done; - } out; -}; - -/** - * Enumerates domain groups. Can be used as a loop condition. Example: while(cac_SamEnumGroups(hnd, mem_ctx, op)) { ... } - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamEnumGroups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumGroups *op); - -struct SamEnumAliases { - struct { - /**Open handle to a domain*/ - POLICY_HND *dom_hnd; - } in; - - struct { - /**where to resume from. Used over multiple calls*/ - uint32 resume_idx; - - /**the number of users returned this call*/ - uint32 num_aliases; - - /**Array storing the rids of the returned groups*/ - uint32 *rids; - - /**Array storing the names of all the groups returned*/ - char **names; - - /**Array storing the descriptions of all the groups returned*/ - char **descriptions; - - bool done; - } out; -}; - -/** - * Enumerates domain aliases. Can be used as a loop condition. Example: while(cac_SamEnumAliases(hnd, mem_ctx, op)) { ... } - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumAliases *op); - -struct SamCreateAlias { - struct { - /**Open handle to the domain SAM*/ - POLICY_HND *dom_hnd; - - /**The name of the alias*/ - char *name; - } in; - - struct { - /**Handle to the group*/ - POLICY_HND *alias_hnd; - } out; -}; - -/** - * Creates an alias. If the alias already exists it will not be opened. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op); - -struct SamOpenAlias { - struct { - /**Open handle to the domain SAM*/ - POLICY_HND *dom_hnd; - - /**Desired access to open the group with. See Generic access masks in include/smb.h*/ - uint32 access; - - /**rid of the alias*/ - uint32 rid; - } in; - - struct { - /**Handle to the alias*/ - POLICY_HND *alias_hnd; - } out; -}; - -/** - * Opens a handle to an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op); - -/** - * Deletes an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param alias_hnd Open handle to the alias - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd); - -struct SamAddAliasMember { - struct { - /**Open handle to a alias*/ - POLICY_HND *alias_hnd; - - /**SID of new member*/ - DOM_SID *sid; - } in; -}; - -/** - * Adds an account to an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op); - -struct SamRemoveAliasMember { - struct { - /**Open handle to the alias*/ - POLICY_HND *alias_hnd; - - /**The SID of the member*/ - DOM_SID *sid; - } in; -}; - -/** - * Removes an account from an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamRemoveAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveAliasMember *op); - -struct SamGetAliasMembers { - struct { - /**Open handle to the alias*/ - POLICY_HND *alias_hnd; - } in; - - struct { - /**The number of members*/ - uint32 num_members; - - /**An array storing the SIDs of the accounts*/ - DOM_SID *sids; - } out; -}; - -/** - * Retrieves a list of all accounts in an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasMembers *op); - -/** - * Removes all the members of an alias - warning: if this function fails is is possible that some but not all members were removed - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param alias_hnd Handle to the alias to clear - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd); - -struct SamSetAliasMembers { - struct { - /**Open handle to the group*/ - POLICY_HND *alias_hnd; - - /**Number of members in the group - if this is 0, all members of the group will be removed*/ - uint32 num_members; - - /**The SIDs of the accounts to add*/ - DOM_SID *sids; - } in; -}; - -/** - * Clears the members of an alias and adds a list of members to the alias - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamSetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasMembers *op); - - -struct SamUserChangePasswd { - struct { - /**The username*/ - char *username; - - /**The current password*/ - char *password; - - /**The new password*/ - char *new_password; - } in; -}; -/**Used by a user to change their password*/ -int cac_SamUserChangePasswd(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamUserChangePasswd *op); - -/** - * Enables a user - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param user_hnd Open handle to the user to enable - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd); - -/** - * Disables a user - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param user_hnd Open handle to the user to disables - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd); - -struct SamSetPassword { - struct { - /**Open handle to a user*/ - POLICY_HND *user_hnd; - - /**The new password*/ - char *password; - } in; -}; - -/** - * Sets a user's password - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetPassword *op); - -struct SamGetUserInfo { - struct { - /**Open Handle to a user*/ - POLICY_HND *user_hnd; - } in; - - struct { - CacUserInfo *info; - } out; -}; - -/** - * Retrieves user information using a CacUserInfo structure. If you would like to use a SAM_USERINFO_CTR directly, use cac_SamGetUserInfoCtr() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @see cac_SamGetUserInfoCtr() - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfo *op); - -struct SamSetUserInfo { - struct { - /**Open handle to a user*/ - POLICY_HND *user_hnd; - - /**Structure containing the data you would like to set*/ - CacUserInfo *info; - } in; -}; - -/** - * Sets the user info using a CacUserInfo structure. If you would like to use a SAM_USERINFO_CTR directly use cac_SamSetUserInfoCtr(). - * @note All fields in the CacUserInfo structure will be set. Best to call cac_GetUserInfo() modify fields that you want, and then call cac_SetUserInfo(). - * @note When calling this, you _must_ set the user's password. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @see cac_SamSetUserInfoCtr() - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamSetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfo *op); - -struct SamGetUserInfoCtr { - struct { - /**Open handle to a user*/ - POLICY_HND *user_hnd; - - /**What USER_INFO structure you want. See include/rpc_samr.h*/ - uint16 info_class; - } in; - - struct { - /**returned user info*/ - SAM_USERINFO_CTR *ctr; - } out; -}; - -/** - * Retrieves user information using a SAM_USERINFO_CTR structure. If you don't want to use this structure, user SamGetUserInfo() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @see cac_SamGetUserInfo() - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfoCtr *op); - -struct SamSetUserInfoCtr { - struct { - /**Open handle to a user*/ - POLICY_HND *user_hnd; - - /**user info - make sure ctr->switch_value is set properly*/ - SAM_USERINFO_CTR *ctr; - } in; -}; - -/** - * Sets the user info using a SAM_USERINFO_CTR structure. If you don't want to use this structure, use cac_SamSetUserInfo() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @see cac_SamSetUserInfo() - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamSetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfoCtr *op); - -struct SamRenameUser { - struct { - /**Open handle to user*/ - POLICY_HND *user_hnd; - - /**New user name*/ - char *new_name; - } in; -}; - -/** - * Changes the name of a user. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameUser *op); - -struct SamGetGroupInfo { - struct { - /**Open handle to a group*/ - POLICY_HND *group_hnd; - } in; - - struct { - /**Returned info about the group*/ - CacGroupInfo *info; - } out; -}; - -/** - * Retrieves information about a group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupInfo *op); - -struct SamSetGroupInfo { - struct { - /**Open handle to a group*/ - POLICY_HND *group_hnd; - - /**group info*/ - CacGroupInfo *info; - } in; -}; - -/** - * Sets information about a group. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamSetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupInfo *op); - -struct SamRenameGroup { - struct { - /**Open handle to a group*/ - POLICY_HND *group_hnd; - - /**New name*/ - char *new_name; - } in; -}; - -/** - * Changes the name of a group - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ - -int cac_SamRenameGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameGroup *op); - -struct SamGetAliasInfo { - struct { - /**Open handle to an alias*/ - POLICY_HND *alias_hnd; - } in; - - struct { - /**Returned alias info*/ - CacAliasInfo *info; - } out; -}; - -/** - * Retrieves information about an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamGetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasInfo *op); - -struct SamSetAliasInfo { - struct { - /**Open handle to an alias*/ - POLICY_HND *alias_hnd; - - /**Returned alias info*/ - CacAliasInfo *info; - } in; -}; - -/** - * Sets information about an alias. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE The operation could not complete successfully. hnd->status is set with appropriate NTSTATUS code - * @return CAC_SUCCESS The operation completed successfully - */ -int cac_SamSetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasInfo *op); - -struct SamGetDomainInfo { - struct { - /**Open handle to the domain SAM*/ - POLICY_HND *dom_hnd; - } in; - - struct { - /**Returned domain info*/ - CacDomainInfo *info; - } out; -}; - -/** - * Gets domain information in the form of a CacDomainInfo structure. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @see SamGetDomainInfoCtr() - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - * @return CAC_PARTIAL_SUCCESS - This function makes 3 rpc calls, if one or two fail and the rest succeed, - * not all fields in the CacDomainInfo structure will be filled - */ -int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfo *op); - -struct SamGetDomainInfoCtr { - struct { - /**Open handle to domain*/ - POLICY_HND *dom_hnd; - - /**What info level you want*/ - uint16 info_class; - } in; - - struct { - SAM_UNK_CTR *info; - } out; -}; - -/** - * Gets domain information in the form of a SAM_UNK_CTR structure. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @see SamGetDomainInfo() - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SamGetDomainInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfoCtr *op); - -struct SamGetDisplayInfo { - struct { - /**Open handle to domain*/ - POLICY_HND *dom_hnd; - - /**What type of data*/ - uint16 info_class; - - /**(Optional)If 0, max_entries and max_size will be filled in by the function*/ - uint32 max_entries; - - /**(Optional)If 0, max_entries and max_size will be filled in by the function*/ - uint32 max_size; - } in; - - struct { - /**Do not modify this value, use the same value between multiple calls (ie in while loop)*/ - uint32 resume_idx; - - /**Number of entries returned*/ - uint32 num_entries; - - /**Returned display info*/ - SAM_DISPINFO_CTR ctr; - - /**Internal value. Do not modify.*/ - uint32 loop_count; - - bool done; - } out; -}; - -/** - * Gets dislpay information using a SAM_DISPINFO_CTR. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDisplayInfo *op); - -struct SamLookupDomain { - struct { - /**Open handle to the sam (opened with cac_SamConnect() or cac_SamOpenDomain()*/ - POLICY_HND *sam; - - /**Name of the domain to lookup*/ - char *name; - } in; - - struct { - /**SID of the domain*/ - DOM_SID *sid; - } out; -}; - -/** - * Looks up a Domain SID given it's name. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SamLookupDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLookupDomain *op); - -struct SamGetSecurityObject { - struct { - /**An open handle (SAM, domain or user)*/ - POLICY_HND *pol; - } in; - - struct { - SEC_DESC_BUF *sec; - } out; -}; - -/** - * Retrievies Security descriptor information for a SAM/Domain/user - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SamGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetSecurityObject *op); - -struct SamFlush { - struct { - /**Open handle to the domain SAM*/ - POLICY_HND *dom_hnd; - - /**(Optional)Domain SID. If NULL, the domain in hnd->domain will be opened*/ - DOM_SID *sid; - - /**(Optional)Desired access to re-open the domain with. If 0, MAXIMUM_ALLOWED_ACCESS is used.*/ - uint32 access; - } in; -}; - -/** - * Closes the domain handle, then re-opens it - effectively flushing any changes made. - * WARNING: if this fails you will no longer have an open handle to the domain SAM. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SamFlush(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op); - -/**@}*/ /*SAM_Functions*/ - -/**@addtogroup SCM_Functions - * @{ - */ - -struct SvcOpenScm { - struct { - /**Desired access to open the Handle with. See SC_RIGHT_MGR_* or SC_MANAGER_* in include/rpc_secdes.h*/ - uint32 access; - } in; - - struct { - /**Handle to the SCM*/ - POLICY_HND *scm_hnd; - } out; -}; - -/** - * Opens a handle to the SCM on the remote machine. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm *op); - -/** - * Closes an Svc handle (SCM or Service) - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param scm_hnd The handle to close - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd); - -struct SvcEnumServices { - struct { - /**Open handle to the SCM*/ - POLICY_HND *scm_hnd; - - /**(Optional)Type of service to enumerate. Possible values: - * - SVCCTL_TYPE_WIN32 - * - SVCCTL_TYPE_DRIVER - * If this is 0, (SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32) is assumed. - */ - uint32 type; - - /**(Optional)State of service to enumerate. Possible values: - * - SVCCTL_STATE_ACTIVE - * - SVCCTL_STATE_INACTIVE - * - SVCCTL_STATE_ALL - * If this is 0, SVCCTL_STATE_ALL is assumed. - */ - uint32 state; - } in; - - struct { - /**Number of services returned*/ - uint32 num_services; - - /**Array of service structures*/ - CacService *services; - } out; -}; - -/** - * Enumerates services on the remote machine. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnumServices *op); - -struct SvcOpenService { - struct { - /**Handle to the Service Control Manager*/ - POLICY_HND *scm_hnd; - - /**Access mask to open service with see SERVICE_* or SC_RIGHT_SVC_* in include/rpc_secdes.h*/ - uint32 access; - - /**The name of the service. _not_ the display name*/ - char *name; - } in; - - struct { - /**Handle to the open service*/ - POLICY_HND *svc_hnd; - } out; -}; - -/** - * Opens a handle to a service. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ - -int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenService *op); - -struct SvcGetStatus { - struct { - /**Open handle to the service to query*/ - POLICY_HND *svc_hnd; - } in; - - struct { - /**The status of the service. See include/rpc_svcctl.h for SERVICE_STATUS definition.*/ - SERVICE_STATUS status; - } out; -}; - -/** - * Retrieves the status of a service. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetStatus *op); - -struct SvcStartService { - struct { - /**open handle to the service*/ - POLICY_HND *svc_hnd; - - /**Array of parameters to start the service with. Can be NULL if num_parms is 0*/ - char **parms; - - /**Number of parameters in the parms array*/ - uint32 num_parms; - - /**Number of seconds to wait for the service to actually start. If this is 0, then the status will not be checked after the initial call*/ - uint32 timeout; - } in; -}; - -/** - * Attempts to start a service. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ - -int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStartService *op); - -struct SvcControlService { - struct { - /**Open handle to the service to control*/ - POLICY_HND *svc_hnd; - - /**The control operation to perform. Possible values (from include/rpc_svcctl.h): - * - SVCCTL_CONTROL_STOP - * - SVCCTL_CONTROL_PAUSE - * - SVCCTL_CONTROL_CONTINUE - * - SVCCTL_CONTROL_SHUTDOWN - */ - uint32 control; - } in; - - struct { - /**The returned status of the service, _immediately_ after the call*/ - SERVICE_STATUS *status; - } out; -}; - -/** - * Performs a control operation on a service and _immediately_ returns. - * @see cac_SvcStopService() - * @see cac_SvcPauseService() - * @see cac_SvcContinueService() - * @see cac_SvcShutdownService() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcControlService *op); - -struct SvcStopService { - struct { - /**Open handle to the service*/ - POLICY_HND *svc_hnd; - - /**Number of seconds to wait for the service to actually start. - * If this is 0, then the status will not be checked after the initial call and CAC_SUCCESS might be returned if the status isn't actually started - */ - uint32 timeout; - } in; - - struct { - /**Status of the service after the operation*/ - SERVICE_STATUS status; - } out; -}; - -/** - * Attempts to stop a service. - * @see cacSvcControlService() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured. - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStopService *op); - -struct SvcPauseService { - struct { - /**Open handle to the service*/ - POLICY_HND *svc_hnd; - - /**Number of seconds to wait for the service to actually start. - * If this is 0, then the status will not be checked after the initial call and CAC_SUCCESS might be returned if the status isn't actually started - */ - uint32 timeout; - } in; - - struct { - /**Status of the service after the operation*/ - SERVICE_STATUS status; - } out; -}; - -/** - * Attempts to pause a service. - * @see cacSvcControlService() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured. - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPauseService *op); - -struct SvcContinueService { - struct { - /**Open handle to the service*/ - POLICY_HND *svc_hnd; - - /**Number of seconds to wait for the service to actually start. - * If this is 0, then the status will not be checked after the initial call and CAC_SUCCESS might be returned if the status isn't actually started - */ - uint32 timeout; - } in; - - struct { - /**Status of the service after the operation*/ - SERVICE_STATUS status; - } out; -}; - -/** - * Attempts to continue a paused service. - * @see cacSvcControlService() - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful. If hnd->status is NT_STATUS_OK, then a timeout occured. - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcContinueService *op); - -struct SvcGetDisplayName { - struct { - /**Open handle to the service*/ - POLICY_HND *svc_hnd; - } in; - - struct { - /**The returned display name of the service*/ - char *display_name; - } out; -}; - -/** - * Retrieves the display name of a service _not currently working_ - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetDisplayName *op); - -struct SvcGetServiceConfig { - struct { - /**Open handle to the service*/ - POLICY_HND *svc_hnd; - } in; - - struct { - /**Returned Configuration information*/ - CacServiceConfig config; - } out; -}; - -/** - * Retrieves configuration information about a service. - * @param hnd Initialized and connected server handle - * @param mem_ctx Context for memory allocation - * @param op Initialized Parameters - * @return CAC_FAILURE - the operation was not successful hnd->status is set appropriately - * @return CAC_SUCCESS - the operation was successful - */ -int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetServiceConfig *op); - -/**@}*/ /*SCM_Functions*/ - -struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx); - -#endif /* LIBMSRPC_H */ - - diff --git a/source3/include/libmsrpc_internal.h b/source3/include/libmsrpc_internal.h deleted file mode 100644 index 623c43f9c3..0000000000 --- a/source3/include/libmsrpc_internal.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * MS-RPC client internal definitions - * Copyright (C) Chris Nicholls 2005. - * - * 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 . - */ - -#ifndef LIBMSRPC_INTERNAL_H -#define LIBMSRPC_INTERNAL_H - -#include "libmsrpc.h" - -/*definitions*/ - -struct CacServerHandleInternal { - /*stores the os type of the server*/ - uint16 srv_level; - - /*stores the initialized/active pipes*/ - bool pipes[PI_MAX_PIPES]; - - /*underlying smbc context*/ - SMBCCTX *ctx; - - /*did the user supply this SMBCCTX?*/ - bool user_supplied_ctx; -}; - -/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/ - -/*nessecary prototypes*/ -bool rid_in_list(uint32 rid, uint32 *list, uint32 list_len); - -int cac_ParseRegPath(char *path, uint32 *reg_type, char **key_name); - -REG_VALUE_DATA *cac_MakeRegValueData(TALLOC_CTX *mem_ctx, uint32 data_type, REGVAL_BUFFER buf); - -RPC_DATA_BLOB *cac_MakeRpcDataBlob(TALLOC_CTX *mem_ctx, uint32 data_type, REG_VALUE_DATA data); - -SAM_USERINFO_CTR *cac_MakeUserInfoCtr(TALLOC_CTX *mem_ctx, CacUserInfo *info); - -CacUserInfo *cac_MakeUserInfo(TALLOC_CTX *mem_ctx, SAM_USERINFO_CTR *ctr); -CacGroupInfo *cac_MakeGroupInfo(TALLOC_CTX *mem_ctx, GROUP_INFO_CTR *ctr); -GROUP_INFO_CTR *cac_MakeGroupInfoCtr(TALLOC_CTX *mem_ctx, CacGroupInfo *info); -CacAliasInfo *cac_MakeAliasInfo(TALLOC_CTX *mem_ctx, ALIAS_INFO_CTR ctr); -ALIAS_INFO_CTR *cac_MakeAliasInfoCtr(TALLOC_CTX *mem_ctx, CacAliasInfo *info); -CacDomainInfo *cac_MakeDomainInfo(TALLOC_CTX *mem_ctx, SAM_UNK_INFO_1 *info1, SAM_UNK_INFO_2 *info2, SAM_UNK_INFO_12 *info12); -CacService *cac_MakeServiceArray(TALLOC_CTX *mem_ctx, ENUM_SERVICES_STATUS *svc, uint32 num_services); -int cac_InitCacServiceConfig(TALLOC_CTX *mem_ctx, SERVICE_CONFIG *src, CacServiceConfig *dest); - -/*moved to libmsrpc.h*/ -/*struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx);*/ - -SMBCSRV *smbc_attr_server(SMBCCTX *context, - const char *server, const char *share, - fstring workgroup, - fstring username, fstring password, - POLICY_HND *pol); - - -#endif /* LIBMSRPC_INTERNAL_H */ diff --git a/source3/include/md5.h b/source3/include/md5.h deleted file mode 100644 index e4cd08ed5e..0000000000 --- a/source3/include/md5.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MD5_H -#define MD5_H -#ifndef HEADER_MD5_H -/* Try to avoid clashes with OpenSSL */ -#define HEADER_MD5_H -#endif - -struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - unsigned char in[64]; -}; - -void MD5Init(struct MD5Context *context); -void MD5Update(struct MD5Context *context, unsigned char const *buf, - unsigned len); -void MD5Final(unsigned char digest[16], struct MD5Context *context); - -#endif /* !MD5_H */ diff --git a/source3/include/messages.h b/source3/include/messages.h index db805a2093..785f116e1c 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -82,7 +82,6 @@ struct server_id { struct messaging_context; struct messaging_rec; -struct data_blob; /* * struct messaging_context belongs to messages.c, but because we still have @@ -102,7 +101,7 @@ struct messaging_context { struct messaging_backend { NTSTATUS (*send_fn)(struct messaging_context *msg_ctx, struct server_id pid, int msg_type, - const struct data_blob *data, + const DATA_BLOB *data, struct messaging_backend *backend); void *private_data; }; @@ -138,12 +137,12 @@ NTSTATUS messaging_register(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id server_id, - struct data_blob *data)); + DATA_BLOB *data)); void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type, void *private_data); NTSTATUS messaging_send(struct messaging_context *msg_ctx, struct server_id server, - uint32_t msg_type, const struct data_blob *data); + uint32_t msg_type, const DATA_BLOB *data); NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx, struct server_id server, uint32_t msg_type, const uint8 *buf, size_t len); diff --git a/source3/include/module.h b/source3/include/module.h index 20dbaba6b4..52245e01d2 100644 --- a/source3/include/module.h +++ b/source3/include/module.h @@ -23,6 +23,7 @@ /* Module support */ typedef NTSTATUS (init_module_function) (void); +NTSTATUS init_samba_module(void); typedef int smb_event_id_t; #define SMB_EVENT_ID_INVALID (-1) diff --git a/source3/include/msdfs.h b/source3/include/msdfs.h index 4551325843..800393c75d 100644 --- a/source3/include/msdfs.h +++ b/source3/include/msdfs.h @@ -64,12 +64,4 @@ struct dfs_path { bool posix_path; }; -#define init_dfsroot(conn, inbuf, outbuf) \ -{ if (lp_msdfs_root(SNUM(conn)) && lp_host_msdfs()) { \ - DEBUG(2,("Serving %s as a Dfs root\n", \ - lp_servicename(SNUM(conn)) )); \ - SSVAL(outbuf, smb_vwv2, SMB_SHARE_IN_DFS \ - | SVAL(outbuf, smb_vwv2)); \ -} } - #endif /* _MSDFS_H */ diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h index 4377e3330a..496d87e2db 100644 --- a/source3/include/nameserv.h +++ b/source3/include/nameserv.h @@ -208,7 +208,7 @@ struct nmb_data { time_t death_time; /* The time the record must be removed (do not remove if 0). */ time_t refresh_time; /* The time the record should be refreshed. */ - SMB_BIG_UINT id; /* unique id */ + uint64_t id; /* unique id */ struct in_addr wins_ip; /* the adress of the wins server this record comes from */ int wins_flags; /* similar to the netbios flags but different ! */ @@ -539,17 +539,6 @@ struct packet_struct } packet; }; -/* NETLOGON opcodes */ - -#define QUERYFORPDC 7 /* Query for PDC. */ -#define SAM_UAS_CHANGE 10 /* Announce change to UAS or SAM. */ -#define QUERYFORPDC_R 12 /* Response to Query for PDC. */ -#define SAMLOGON 18 -#define SAMLOGON_R 19 -#define SAMLOGON_UNK_R 21 -#define SAMLOGON_AD_UNK_R 23 -#define SAMLOGON_AD_R 25 - /* Ids for netbios packet types. */ #define ANN_HostAnnouncement 1 @@ -617,7 +606,7 @@ typedef struct _WINS_RECORD { char type; int nb_flags; int wins_flags; - SMB_BIG_UINT id; + uint64_t id; int num_ips; struct in_addr ip[25]; struct in_addr wins_ip; diff --git a/source3/include/ndr.h b/source3/include/ndr.h deleted file mode 100644 index a416866ef2..0000000000 --- a/source3/include/ndr.h +++ /dev/null @@ -1 +0,0 @@ -/* dummy file to deal with pidl autogenerated ndr files */ diff --git a/source3/include/nss_info.h b/source3/include/nss_info.h index 1ff9ebcd55..e756136b76 100644 --- a/source3/include/nss_info.h +++ b/source3/include/nss_info.h @@ -66,6 +66,10 @@ struct nss_info_methods { TALLOC_CTX *ctx, ADS_STRUCT *ads, LDAPMessage *msg, char **homedir, char **shell, char **gecos, gid_t *p_gid); + NTSTATUS (*map_to_alias)( TALLOC_CTX *mem_ctx, const char *domain, + const char *name, char **alias ); + NTSTATUS (*map_from_alias)( TALLOC_CTX *mem_ctx, const char *domain, + const char *alias, char **name ); NTSTATUS (*close_fn)( void ); }; @@ -84,6 +88,12 @@ NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid, char **homedir, char **shell, char **gecos, gid_t *p_gid); +NTSTATUS nss_map_to_alias( TALLOC_CTX *mem_ctx, const char *domain, + const char *name, char **alias ); + +NTSTATUS nss_map_from_alias( TALLOC_CTX *mem_ctx, const char *domain, + const char *alias, char **name ); + NTSTATUS nss_close( const char *parameters ); #endif /* _IDMAP_NSS_H_ */ diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h index de0a313609..e6c97c69dc 100644 --- a/source3/include/ntdomain.h +++ b/source3/include/ntdomain.h @@ -287,63 +287,6 @@ typedef struct pipes_struct { } pipes_struct; -typedef struct smb_np_struct { - struct smb_np_struct *next, *prev; - int pnum; - connection_struct *conn; - uint16 vuid; /* points to the unauthenticated user that opened this pipe. */ - bool open; /* open connection */ - uint16 device_state; - uint16 priority; - char *name; - - /* When replying to an SMBtrans, this is the maximum amount of - data that can be sent in the initial reply. */ - int max_trans_reply; - - /* - * NamedPipe state information. - */ - struct pipes_struct *np_state; - - /* - * NamedPipe functions, to be called to perform - * Named Pipe transactions on request from an - * SMB client. - */ - - /* call to create a named pipe connection. - * returns: state information representing the connection. - * is stored in np_state, above. - */ - struct pipes_struct *(*namedpipe_create)( - const char *pipe_name, - const char *client_address, - struct auth_serversupplied_info *server_info, - uint16_t vuid); - - /* call to perform a write namedpipe operation - */ - ssize_t (*namedpipe_write)(struct pipes_struct *p, - char *data, size_t n); - - /* call to perform a read namedpipe operation. - * - * NOTE: the only reason that the pipe_outstanding - * argument is here is because samba does not use - * the namedpipe_transact function yet: instead, - * it performs the same as what namedpipe_transact - * does - a write, followed by a read. - * - * when samba is modified to use namedpipe_transact, - * the pipe_outstanding argument may be removed. - */ - ssize_t (*namedpipe_read)(struct pipes_struct *p, - char *data, size_t max_len, - bool *pipe_outstanding); - -} smb_np_struct; - struct api_struct { const char *name; uint8 opnum; diff --git a/source3/include/ntlmssp.h b/source3/include/ntlmssp.h index 3fb41c5613..b014b2170c 100644 --- a/source3/include/ntlmssp.h +++ b/source3/include/ntlmssp.h @@ -157,14 +157,14 @@ typedef struct ntlmssp_state unsigned char recv_sign_key[16]; unsigned char recv_seal_key[16]; - unsigned char send_seal_arc4_state[258]; - unsigned char recv_seal_arc4_state[258]; + struct arcfour_state send_seal_arc4_state; + struct arcfour_state recv_seal_arc4_state; uint32 ntlm2_send_seq_num; uint32 ntlm2_recv_seq_num; /* ntlmv1 */ - unsigned char ntlmv1_arc4_state[258]; + struct arcfour_state ntlmv1_arc4_state; uint32 ntlmv1_seq_num; /* it turns out that we don't always get the diff --git a/source3/include/ntquotas.h b/source3/include/ntquotas.h index ed503b3854..9aa8b9139e 100644 --- a/source3/include/ntquotas.h +++ b/source3/include/ntquotas.h @@ -47,16 +47,16 @@ #define QUOTAS_4000 0x4000 #define QUOTAS_8000 0x8000 -#define SMB_NTQUOTAS_NO_LIMIT ((SMB_BIG_UINT)(-1)) -#define SMB_NTQUOTAS_NO_ENTRY ((SMB_BIG_UINT)(-2)) -#define SMB_NTQUOTAS_NO_SPACE ((SMB_BIG_UINT)(0)) -#define SMB_NTQUOTAS_1_B (SMB_BIG_UINT)0x0000000000000001 -#define SMB_NTQUOTAS_1KB (SMB_BIG_UINT)0x0000000000000400 -#define SMB_NTQUOTAS_1MB (SMB_BIG_UINT)0x0000000000100000 -#define SMB_NTQUOTAS_1GB (SMB_BIG_UINT)0x0000000040000000 -#define SMB_NTQUOTAS_1TB (SMB_BIG_UINT)0x0000010000000000 -#define SMB_NTQUOTAS_1PB (SMB_BIG_UINT)0x0004000000000000 -#define SMB_NTQUOTAS_1EB (SMB_BIG_UINT)0x1000000000000000 +#define SMB_NTQUOTAS_NO_LIMIT ((uint64_t)(-1)) +#define SMB_NTQUOTAS_NO_ENTRY ((uint64_t)(-2)) +#define SMB_NTQUOTAS_NO_SPACE ((uint64_t)(0)) +#define SMB_NTQUOTAS_1_B (uint64_t)0x0000000000000001 +#define SMB_NTQUOTAS_1KB (uint64_t)0x0000000000000400 +#define SMB_NTQUOTAS_1MB (uint64_t)0x0000000000100000 +#define SMB_NTQUOTAS_1GB (uint64_t)0x0000000040000000 +#define SMB_NTQUOTAS_1TB (uint64_t)0x0000010000000000 +#define SMB_NTQUOTAS_1PB (uint64_t)0x0004000000000000 +#define SMB_NTQUOTAS_1EB (uint64_t)0x1000000000000000 enum SMB_QUOTA_TYPE { SMB_INVALID_QUOTA_TYPE = -1, @@ -68,9 +68,9 @@ enum SMB_QUOTA_TYPE { typedef struct _SMB_NTQUOTA_STRUCT { enum SMB_QUOTA_TYPE qtype; - SMB_BIG_UINT usedspace; - SMB_BIG_UINT softlim; - SMB_BIG_UINT hardlim; + uint64_t usedspace; + uint64_t softlim; + uint64_t hardlim; uint32 qflags; DOM_SID sid; } SMB_NTQUOTA_STRUCT; diff --git a/source3/include/packet.h b/source3/include/packet.h index d5174229ca..05974da8fc 100644 --- a/source3/include/packet.h +++ b/source3/include/packet.h @@ -46,10 +46,10 @@ NTSTATUS packet_fd_read_sync(struct packet_context *ctx); * Otherwise return True and store the callback result in *status */ bool packet_handler(struct packet_context *ctx, - bool (*full_req)(const struct data_blob *data, + bool (*full_req)(const DATA_BLOB *data, size_t *length, void *private_data), - NTSTATUS (*callback)(const struct data_blob *data, + NTSTATUS (*callback)(const DATA_BLOB *data, void *private_data), void *private_data, NTSTATUS *status); diff --git a/source3/include/printing.h b/source3/include/printing.h index 2788143cc5..d91917b528 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -77,6 +77,7 @@ extern struct printif iprint_printif; #define NEXT_JOBID(j) ((j+1) % PRINT_MAX_JOBID > 0 ? (j+1) % PRINT_MAX_JOBID : 1) #define MAX_CACHE_VALID_TIME 3600 +#define CUPS_DEFAULT_CONNECTION_TIMEOUT 30 #ifndef PRINT_SPOOL_PREFIX #define PRINT_SPOOL_PREFIX "smbprn." diff --git a/source3/include/proto.h b/source3/include/proto.h index 2901911c70..9b3950229e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -43,7 +43,10 @@ bool password_ok(const char *smb_name, DATA_BLOB password_blob); /* The following definitions come from auth/auth_domain.c */ -NTSTATUS auth_domain_init(void) ; +void attempt_machine_password_change(void); +NTSTATUS auth_domain_init(void); + +NTSTATUS auth_netlogond_init(void); /* The following definitions come from auth/auth_ntlmssp.c */ @@ -312,11 +315,6 @@ int afs_syscall( int subcall, bool afs_settoken_str(const char *token_string); bool afs_settoken_str(const char *token_string); -/* The following definitions come from lib/arc4.c */ - -void smb_arc4_init(unsigned char arc4_state_out[258], const unsigned char *key, size_t keylen); -void smb_arc4_crypt(unsigned char arc4_state_inout[258], unsigned char *data, size_t len); - /* The following definitions come from lib/audit.c */ const char *audit_category_str(uint32 category); @@ -437,22 +435,6 @@ int connections_forall(int (*fn)(struct db_record *rec, void *private_data); bool connections_init(bool rw); -/* The following definitions come from lib/crc32.c */ - -uint32 crc32_calc_buffer(const char *buf, size_t size); - -/* The following definitions come from lib/data_blob.c */ - -DATA_BLOB data_blob(const void *p, size_t length); -DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length); -void data_blob_free(DATA_BLOB *d); -void data_blob_clear(DATA_BLOB *d); -void data_blob_clear_free(DATA_BLOB *d); -DATA_BLOB data_blob_string_const(const char *str); -DATA_BLOB data_blob_const(const void *p, size_t length); -DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length); -_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob); - /* The following definitions come from lib/dbwrap_util.c */ int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr); @@ -492,13 +474,14 @@ void force_check_log_size( void ); bool need_to_check_log_size( void ); void check_log_size( void ); void dbgflush( void ); -bool dbghdr(int level, int cls, const char *file, const char *func, int line); +bool dbghdrclass(int level, int cls, const char *location, const char *func); +bool dbghdr(int level, const char *location, const char *func); TALLOC_CTX *debug_ctx(void); /* The following definitions come from lib/display_sec.c */ char *get_sec_mask_str(TALLOC_CTX *ctx, uint32 type); -void display_sec_access(SEC_ACCESS *info); +void display_sec_access(uint32_t *info); void display_sec_ace_flags(uint8_t flags); void display_sec_ace(SEC_ACE *ace); void display_sec_acl(SEC_ACL *sec_acl); @@ -516,6 +499,7 @@ void display_set_stderr(void); /* The following definitions come from lib/errmap_unix.c */ NTSTATUS map_nt_error_from_unix(int unix_error); +int map_errno_from_nt_status(NTSTATUS status); /* The following definitions come from lib/events.c */ @@ -573,7 +557,7 @@ void pull_file_id_16(char *buf, struct file_id *id); /* The following definitions come from lib/fsusage.c */ -int sys_fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); +int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize); /* The following definitions come from lib/gencache.c */ @@ -593,18 +577,8 @@ void gencache_unlock_entry( const char *key ); void set_rand_reseed_callback(void (*fn)(int *)); void set_need_random_reseed(void); -void generate_random_buffer( unsigned char *out, int len); -char *generate_random_str(size_t len); - -/* The following definitions come from lib/hmacmd5.c */ - -void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context *ctx); -void hmac_md5_init_limK_to_64(const unsigned char* key, int key_len, - HMACMD5Context *ctx); -void hmac_md5_update(const unsigned char *text, int text_len, HMACMD5Context *ctx); -void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx); -void hmac_md5( unsigned char key[16], const unsigned char *data, int data_len, - unsigned char *digest); +void generate_random_buffer(uint8_t *out, int len); +char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len); /* The following definitions come from lib/iconv.c */ @@ -649,12 +623,6 @@ char *escape_rdn_val_string_alloc(const char *s); void mdfour(unsigned char *out, const unsigned char *in, int n); -/* The following definitions come from lib/md5.c */ - -void MD5Init(struct MD5Context *ctx); -void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len); -void MD5Final(unsigned char digest[16], struct MD5Context *ctx); - /* The following definitions come from lib/module.c */ NTSTATUS smb_load_module(const char *module_name); @@ -727,6 +695,7 @@ bool privilege_set_to_se_priv( SE_PRIV *mask, struct lsa_PrivilegeSet *privset ) /* The following definitions come from lib/readline.c */ +void smb_readline_done(void); char *smb_readline(const char *prompt, void (*callback)(void), char **(completion_fn)(const char *text, int start, int end)); const char *smb_readline_get_line_buffer(void); @@ -791,7 +760,6 @@ NTSTATUS sec_desc_mod_sid(SEC_DESC *sd, DOM_SID *sid, uint32 mask); NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, size_t *sd_size); SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, bool child_container); -void init_sec_access(uint32 *t, uint32 mask); /* The following definitions come from lib/select.c */ @@ -801,12 +769,6 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf /* The following definitions come from lib/sendfile.c */ -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); -ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count); /* The following definitions come from lib/server_mutex.c */ @@ -1147,11 +1109,9 @@ void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset); time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset); time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset); time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset); -char *http_timestring(time_t t); char *timestring(TALLOC_CTX *mem_ctx, time_t t); const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt); NTTIME nttime_from_string(const char *s); -int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2); struct timeval timeval_zero(void); bool timeval_is_zero(const struct timeval *tv); struct timeval timeval_current(void); @@ -1224,10 +1184,6 @@ const char *time_to_asc(const time_t t); const char *display_time(NTTIME nttime); bool nt_time_is_set(const NTTIME *nt); -/* The following definitions come from lib/ufc.c */ - -char *ufc_crypt(const char *key,const char *salt); - /* The following definitions come from lib/username.c */ char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user); @@ -1235,6 +1191,7 @@ struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user); /* The following definitions come from lib/util.c */ +bool all_zero(const uint8_t *ptr, size_t size); bool set_global_myname(const char *myname); const char *global_myname(void); bool set_global_myworkgroup(const char *myworkgroup); @@ -1266,10 +1223,12 @@ const char *tmpdir(void); bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid, gid_t **gids, size_t *num_gids); const char *get_numlist(const char *p, uint32 **num, int *count); -bool file_exist(const char *fname,SMB_STRUCT_STAT *sbuf); +bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf); +bool file_exist(const char *fname); bool socket_exist(const char *fname); time_t file_modtime(const char *fname); -bool directory_exist(char *dname,SMB_STRUCT_STAT *st); +bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st); +bool directory_exist(const char *dname); SMB_OFF_T get_file_size(char *file_name); char *attrib_string(uint16 mode); void show_msg(char *buf); @@ -1297,7 +1256,7 @@ void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size, void *element, void *_array, uint32 *num_elements, ssize_t *array_size); void safe_free(void *p); -char *get_myname(TALLOC_CTX *ctx); +char *talloc_get_myname(TALLOC_CTX *ctx); char *get_mydnsdomname(TALLOC_CTX *ctx); int interpret_protocol(const char *str,int def); char *automount_lookup(TALLOC_CTX *ctx, const char *user_name); @@ -1325,6 +1284,7 @@ enum remote_arch_types get_remote_arch(void); void print_asc(int level, const unsigned char *buf,int len); void dump_data(int level, const unsigned char *buf1,int len); void dump_data_pw(const char *msg, const uchar * data, size_t len); +void dump_data_skip_zeros(int level, const uint8_t *buf, int len); const char *tab_depth(int level, int depth); int str_checksum(const char *s); void zero_free(void *p, size_t size); @@ -1396,16 +1356,16 @@ const char *strip_hostname(const char *s); /* The following definitions come from lib/util_file.c */ char *fgets_slash(char *s2,int maxlen,XFILE *f); -char *fd_load(int fd, size_t *psize, size_t maxsize); -char *file_load(const char *fname, size_t *size, size_t maxsize); +char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx); +char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx); bool unmap_file(void* start, size_t size); -void *map_file(char *fname, size_t size); -char **file_lines_load(const char *fname, int *numlines, size_t maxsize); -char **fd_lines_load(int fd, int *numlines, size_t maxsize); -char **file_lines_pload(char *syscmd, int *numlines); +void *map_file(const char *fname, size_t size); +char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx); +char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx); +char **file_lines_pload(const char *syscmd, int *numlines); void file_lines_free(char **lines); void file_lines_slashcont(char **lines); -bool file_save(const char *fname, void *packet, size_t length); +bool file_save(const char *fname, const void *packet, size_t length); /* The following definitions come from lib/util_nscd.c */ @@ -1446,6 +1406,7 @@ WERROR registry_push_value(TALLOC_CTX *mem_ctx, /* The following definitions come from lib/util_seaccess.c */ void se_map_generic(uint32 *access_mask, const struct generic_mapping *mapping); +void security_acl_map_generic(struct security_acl *sa, const struct generic_mapping *mapping); void se_map_standard(uint32 *access_mask, struct standard_mapping *mapping); bool se_access_check(const SEC_DESC *sd, const NT_USER_TOKEN *token, uint32 acc_desired, uint32 *acc_granted, @@ -1644,7 +1605,7 @@ char *alpha_strcpy_fn(const char *fn, char *StrnCpy_fn(const char *fn, int line,char *dest,const char *src,size_t n); size_t strhex_to_str(char *buf, size_t buf_len, const char *strhex, size_t strhex_len); DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex); -char *hex_encode(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len); +char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len); bool in_list(const char *s, const char *list, bool casesensitive); void string_free(char **s); bool string_set(char **dest,const char *src); @@ -1693,9 +1654,9 @@ char *binary_string_rfc2254(char *buf, int len); char *binary_string(char *buf, int len); int fstr_sprintf(fstring s, const char *fmt, ...); char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep); -bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src); -bool str_list_compare(char **list1, char **list2); -int str_list_count( const char **list ); +char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list); +bool str_list_equal(const char **list1, const char **list2); +size_t str_list_length( const char * const*list ); bool str_list_sub_basic( char **list, const char *smb_name, const char *domain_name ); bool str_list_substitute(char **list, const char *pattern, const char *insert); @@ -1708,7 +1669,7 @@ void rfc1738_unescape(char *buf); DATA_BLOB base64_decode_data_blob(const char *s); void base64_decode_inplace(char *s); char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data); -SMB_BIG_UINT STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr); +uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr); SMB_OFF_T conv_str_size(const char * str); void string_append(char **left, const char *right); bool add_string_to_array(TALLOC_CTX *mem_ctx, @@ -1794,9 +1755,6 @@ int islower_ascii(int c); void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr); void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu); -void smb_uuid_generate_random(struct GUID *uu); -const char *smb_uuid_string(TALLOC_CTX *mem_ctx, const struct GUID uu); -bool smb_string_to_uuid(const char *in, struct GUID* uu); char *guid_binstring(const struct GUID *guid); /* The following definitions come from lib/version.c */ @@ -1927,20 +1885,15 @@ NTSTATUS kerberos_return_info3_from_pac(TALLOC_CTX *mem_ctx, struct netr_SamInfo3 **info3); /* The following definitions come from libads/cldap.c */ - bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *server, const char *realm, - uint32_t *nt_version, - union nbt_cldap_netlogon **reply); + uint32_t nt_version, + struct netlogon_samlogon_response **reply); bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx, const char *server, const char *realm, - struct nbt_cldap_netlogon_5 *reply5); -bool pull_mailslot_cldap_reply(TALLOC_CTX *mem_ctx, - const DATA_BLOB *blob, - union nbt_cldap_netlogon *r, - uint32_t *nt_version); + struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5); /* The following definitions come from libads/disp_sec.c */ @@ -2204,23 +2157,6 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads, char **returned_principal); -/* The following definitions come from libcli/nbt/nbtname.c */ - -_PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r); -_PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname); -_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name); -_PUBLIC_ NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name); -_PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx, - struct nbt_name *n, const char *name, int type); -_PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name); -_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r); -_PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r); -_PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r); - /* The following definitions come from libgpo/gpext/gpext.c */ struct gp_extension *get_gp_extension_list(void); @@ -2444,1652 +2380,48 @@ ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads, const char *dn, struct nt_user_token **token); -/* The following definitions come from librpc/gen_ndr/ndr_dfs.c */ - -_PUBLIC_ void ndr_print_dfs_ManagerVersion(struct ndr_print *ndr, const char *name, enum dfs_ManagerVersion r); -_PUBLIC_ void ndr_print_dfs_Info0(struct ndr_print *ndr, const char *name, const struct dfs_Info0 *r); -_PUBLIC_ void ndr_print_dfs_Info1(struct ndr_print *ndr, const char *name, const struct dfs_Info1 *r); -_PUBLIC_ enum ndr_err_code ndr_push_dfs_VolumeState(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_dfs_VolumeState(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_dfs_VolumeState(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_dfs_Info2(struct ndr_print *ndr, const char *name, const struct dfs_Info2 *r); -_PUBLIC_ enum ndr_err_code ndr_push_dfs_StorageState(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_dfs_StorageState(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_dfs_StorageState(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_dfs_StorageInfo(struct ndr_print *ndr, const char *name, const struct dfs_StorageInfo *r); -_PUBLIC_ void ndr_print_dfs_Info3(struct ndr_print *ndr, const char *name, const struct dfs_Info3 *r); -_PUBLIC_ void ndr_print_dfs_Info4(struct ndr_print *ndr, const char *name, const struct dfs_Info4 *r); -_PUBLIC_ enum ndr_err_code ndr_push_dfs_PropertyFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_dfs_PropertyFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_dfs_PropertyFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_dfs_Info5(struct ndr_print *ndr, const char *name, const struct dfs_Info5 *r); -_PUBLIC_ void ndr_print_dfs_Target_PriorityClass(struct ndr_print *ndr, const char *name, enum dfs_Target_PriorityClass r); -_PUBLIC_ void ndr_print_dfs_Target_Priority(struct ndr_print *ndr, const char *name, const struct dfs_Target_Priority *r); -_PUBLIC_ void ndr_print_dfs_StorageInfo2(struct ndr_print *ndr, const char *name, const struct dfs_StorageInfo2 *r); -_PUBLIC_ void ndr_print_dfs_Info6(struct ndr_print *ndr, const char *name, const struct dfs_Info6 *r); -_PUBLIC_ void ndr_print_dfs_Info7(struct ndr_print *ndr, const char *name, const struct dfs_Info7 *r); -_PUBLIC_ void ndr_print_dfs_Info100(struct ndr_print *ndr, const char *name, const struct dfs_Info100 *r); -_PUBLIC_ void ndr_print_dfs_Info101(struct ndr_print *ndr, const char *name, const struct dfs_Info101 *r); -_PUBLIC_ void ndr_print_dfs_Info102(struct ndr_print *ndr, const char *name, const struct dfs_Info102 *r); -_PUBLIC_ void ndr_print_dfs_Info103(struct ndr_print *ndr, const char *name, const struct dfs_Info103 *r); -_PUBLIC_ void ndr_print_dfs_Info104(struct ndr_print *ndr, const char *name, const struct dfs_Info104 *r); -_PUBLIC_ void ndr_print_dfs_Info105(struct ndr_print *ndr, const char *name, const struct dfs_Info105 *r); -_PUBLIC_ void ndr_print_dfs_Info106(struct ndr_print *ndr, const char *name, const struct dfs_Info106 *r); -_PUBLIC_ void ndr_print_dfs_Info200(struct ndr_print *ndr, const char *name, const struct dfs_Info200 *r); -_PUBLIC_ void ndr_print_dfs_VolumeFlavor(struct ndr_print *ndr, const char *name, enum dfs_VolumeFlavor r); -_PUBLIC_ void ndr_print_dfs_Info300(struct ndr_print *ndr, const char *name, const struct dfs_Info300 *r); -_PUBLIC_ void ndr_print_dfs_Info(struct ndr_print *ndr, const char *name, const union dfs_Info *r); -_PUBLIC_ void ndr_print_dfs_EnumArray1(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray1 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray2(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray2 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray3(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray3 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray4(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray4 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray5(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray5 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray6(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray6 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray200(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray200 *r); -_PUBLIC_ void ndr_print_dfs_EnumArray300(struct ndr_print *ndr, const char *name, const struct dfs_EnumArray300 *r); -_PUBLIC_ void ndr_print_dfs_EnumInfo(struct ndr_print *ndr, const char *name, const union dfs_EnumInfo *r); -_PUBLIC_ void ndr_print_dfs_EnumStruct(struct ndr_print *ndr, const char *name, const struct dfs_EnumStruct *r); -_PUBLIC_ void ndr_print_dfs_UnknownStruct(struct ndr_print *ndr, const char *name, const struct dfs_UnknownStruct *r); -_PUBLIC_ enum ndr_err_code ndr_push_dfs_GetManagerVersion(struct ndr_push *ndr, int flags, const struct dfs_GetManagerVersion *r); -_PUBLIC_ enum ndr_err_code ndr_pull_dfs_GetManagerVersion(struct ndr_pull *ndr, int flags, struct dfs_GetManagerVersion *r); -_PUBLIC_ void ndr_print_dfs_GetManagerVersion(struct ndr_print *ndr, const char *name, int flags, const struct dfs_GetManagerVersion *r); -_PUBLIC_ void ndr_print_dfs_Add(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Add *r); -_PUBLIC_ void ndr_print_dfs_Remove(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Remove *r); -_PUBLIC_ void ndr_print_dfs_SetInfo(struct ndr_print *ndr, const char *name, int flags, const struct dfs_SetInfo *r); -_PUBLIC_ void ndr_print_dfs_GetInfo(struct ndr_print *ndr, const char *name, int flags, const struct dfs_GetInfo *r); -_PUBLIC_ void ndr_print_dfs_Enum(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Enum *r); -_PUBLIC_ void ndr_print_dfs_Rename(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Rename *r); -_PUBLIC_ void ndr_print_dfs_Move(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Move *r); -_PUBLIC_ void ndr_print_dfs_ManagerGetConfigInfo(struct ndr_print *ndr, const char *name, int flags, const struct dfs_ManagerGetConfigInfo *r); -_PUBLIC_ void ndr_print_dfs_ManagerSendSiteInfo(struct ndr_print *ndr, const char *name, int flags, const struct dfs_ManagerSendSiteInfo *r); -_PUBLIC_ void ndr_print_dfs_AddFtRoot(struct ndr_print *ndr, const char *name, int flags, const struct dfs_AddFtRoot *r); -_PUBLIC_ void ndr_print_dfs_RemoveFtRoot(struct ndr_print *ndr, const char *name, int flags, const struct dfs_RemoveFtRoot *r); -_PUBLIC_ void ndr_print_dfs_AddStdRoot(struct ndr_print *ndr, const char *name, int flags, const struct dfs_AddStdRoot *r); -_PUBLIC_ void ndr_print_dfs_RemoveStdRoot(struct ndr_print *ndr, const char *name, int flags, const struct dfs_RemoveStdRoot *r); -_PUBLIC_ void ndr_print_dfs_ManagerInitialize(struct ndr_print *ndr, const char *name, int flags, const struct dfs_ManagerInitialize *r); -_PUBLIC_ void ndr_print_dfs_AddStdRootForced(struct ndr_print *ndr, const char *name, int flags, const struct dfs_AddStdRootForced *r); -_PUBLIC_ void ndr_print_dfs_GetDcAddress(struct ndr_print *ndr, const char *name, int flags, const struct dfs_GetDcAddress *r); -_PUBLIC_ void ndr_print_dfs_SetDcAddress(struct ndr_print *ndr, const char *name, int flags, const struct dfs_SetDcAddress *r); -_PUBLIC_ void ndr_print_dfs_FlushFtTable(struct ndr_print *ndr, const char *name, int flags, const struct dfs_FlushFtTable *r); -_PUBLIC_ void ndr_print_dfs_Add2(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Add2 *r); -_PUBLIC_ void ndr_print_dfs_Remove2(struct ndr_print *ndr, const char *name, int flags, const struct dfs_Remove2 *r); -_PUBLIC_ enum ndr_err_code ndr_push_dfs_EnumEx(struct ndr_push *ndr, int flags, const struct dfs_EnumEx *r); -_PUBLIC_ enum ndr_err_code ndr_pull_dfs_EnumEx(struct ndr_pull *ndr, int flags, struct dfs_EnumEx *r); -_PUBLIC_ void ndr_print_dfs_EnumEx(struct ndr_print *ndr, const char *name, int flags, const struct dfs_EnumEx *r); -_PUBLIC_ void ndr_print_dfs_SetInfo2(struct ndr_print *ndr, const char *name, int flags, const struct dfs_SetInfo2 *r); - -/* The following definitions come from librpc/gen_ndr/ndr_dssetup.c */ - -_PUBLIC_ void ndr_print_dssetup_DsRole(struct ndr_print *ndr, const char *name, enum dssetup_DsRole r); -_PUBLIC_ void ndr_print_dssetup_DsRoleFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_dssetup_DsRolePrimaryDomInfoBasic(struct ndr_print *ndr, const char *name, const struct dssetup_DsRolePrimaryDomInfoBasic *r); -_PUBLIC_ void ndr_print_dssetup_DsUpgrade(struct ndr_print *ndr, const char *name, enum dssetup_DsUpgrade r); -_PUBLIC_ void ndr_print_dssetup_DsPrevious(struct ndr_print *ndr, const char *name, enum dssetup_DsPrevious r); -_PUBLIC_ void ndr_print_dssetup_DsRoleUpgradeStatus(struct ndr_print *ndr, const char *name, const struct dssetup_DsRoleUpgradeStatus *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleOp(struct ndr_print *ndr, const char *name, enum dssetup_DsRoleOp r); -_PUBLIC_ void ndr_print_dssetup_DsRoleOpStatus(struct ndr_print *ndr, const char *name, const struct dssetup_DsRoleOpStatus *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleInfoLevel(struct ndr_print *ndr, const char *name, enum dssetup_DsRoleInfoLevel r); -_PUBLIC_ void ndr_print_dssetup_DsRoleInfo(struct ndr_print *ndr, const char *name, const union dssetup_DsRoleInfo *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleGetPrimaryDomainInformation(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleGetPrimaryDomainInformation *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleDnsNameToFlatName(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleDnsNameToFlatName *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleDcAsDc(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleDcAsDc *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleDcAsReplica(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleDcAsReplica *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleDemoteDc(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleDemoteDc *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleGetDcOperationProgress(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleGetDcOperationProgress *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleGetDcOperationResults(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleGetDcOperationResults *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleCancel(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleCancel *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleServerSaveStateForUpgrade(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleServerSaveStateForUpgrade *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleUpgradeDownlevelServer(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleUpgradeDownlevelServer *r); -_PUBLIC_ void ndr_print_dssetup_DsRoleAbortDownlevelServerUpgrade(struct ndr_print *ndr, const char *name, int flags, const struct dssetup_DsRoleAbortDownlevelServerUpgrade *r); - -/* The following definitions come from librpc/gen_ndr/ndr_echo.c */ - -_PUBLIC_ void ndr_print_echo_info1(struct ndr_print *ndr, const char *name, const struct echo_info1 *r); -_PUBLIC_ void ndr_print_echo_info2(struct ndr_print *ndr, const char *name, const struct echo_info2 *r); -_PUBLIC_ void ndr_print_echo_info3(struct ndr_print *ndr, const char *name, const struct echo_info3 *r); -_PUBLIC_ void ndr_print_STRUCT_echo_info4(struct ndr_print *ndr, const char *name, const struct echo_info4 *r); -_PUBLIC_ void ndr_print_echo_info5(struct ndr_print *ndr, const char *name, const struct echo_info5 *r); -_PUBLIC_ void ndr_print_echo_info6(struct ndr_print *ndr, const char *name, const struct echo_info6 *r); -_PUBLIC_ void ndr_print_echo_info7(struct ndr_print *ndr, const char *name, const struct echo_info7 *r); -_PUBLIC_ void ndr_print_echo_Info(struct ndr_print *ndr, const char *name, const union echo_Info *r); -_PUBLIC_ void ndr_print_echo_Enum1(struct ndr_print *ndr, const char *name, enum echo_Enum1 r); -_PUBLIC_ void ndr_print_echo_Enum1_32(struct ndr_print *ndr, const char *name, enum echo_Enum1_32 r); -_PUBLIC_ void ndr_print_echo_Enum2(struct ndr_print *ndr, const char *name, const struct echo_Enum2 *r); -_PUBLIC_ void ndr_print_echo_Enum3(struct ndr_print *ndr, const char *name, const union echo_Enum3 *r); -_PUBLIC_ void ndr_print_echo_Surrounding(struct ndr_print *ndr, const char *name, const struct echo_Surrounding *r); -_PUBLIC_ void ndr_print_echo_AddOne(struct ndr_print *ndr, const char *name, int flags, const struct echo_AddOne *r); -_PUBLIC_ void ndr_print_echo_EchoData(struct ndr_print *ndr, const char *name, int flags, const struct echo_EchoData *r); -_PUBLIC_ void ndr_print_echo_SinkData(struct ndr_print *ndr, const char *name, int flags, const struct echo_SinkData *r); -_PUBLIC_ void ndr_print_echo_SourceData(struct ndr_print *ndr, const char *name, int flags, const struct echo_SourceData *r); -_PUBLIC_ void ndr_print_echo_TestCall(struct ndr_print *ndr, const char *name, int flags, const struct echo_TestCall *r); -_PUBLIC_ void ndr_print_echo_TestCall2(struct ndr_print *ndr, const char *name, int flags, const struct echo_TestCall2 *r); -_PUBLIC_ void ndr_print_echo_TestSleep(struct ndr_print *ndr, const char *name, int flags, const struct echo_TestSleep *r); -_PUBLIC_ void ndr_print_echo_TestEnum(struct ndr_print *ndr, const char *name, int flags, const struct echo_TestEnum *r); -_PUBLIC_ void ndr_print_echo_TestSurrounding(struct ndr_print *ndr, const char *name, int flags, const struct echo_TestSurrounding *r); -_PUBLIC_ void ndr_print_echo_TestDoublePointer(struct ndr_print *ndr, const char *name, int flags, const struct echo_TestDoublePointer *r); - -/* The following definitions come from librpc/gen_ndr/ndr_eventlog.c */ - -_PUBLIC_ void ndr_print_eventlog_OpenUnknown0(struct ndr_print *ndr, const char *name, const struct eventlog_OpenUnknown0 *r); -_PUBLIC_ enum ndr_err_code ndr_push_eventlog_Record(struct ndr_push *ndr, int ndr_flags, const struct eventlog_Record *r); -_PUBLIC_ enum ndr_err_code ndr_pull_eventlog_Record(struct ndr_pull *ndr, int ndr_flags, struct eventlog_Record *r); -_PUBLIC_ void ndr_print_eventlog_Record(struct ndr_print *ndr, const char *name, const struct eventlog_Record *r); -_PUBLIC_ void ndr_print_eventlog_ClearEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ClearEventLogW *r); -_PUBLIC_ void ndr_print_eventlog_BackupEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_BackupEventLogW *r); -_PUBLIC_ void ndr_print_eventlog_CloseEventLog(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_CloseEventLog *r); -_PUBLIC_ void ndr_print_eventlog_DeregisterEventSource(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_DeregisterEventSource *r); -_PUBLIC_ void ndr_print_eventlog_GetNumRecords(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_GetNumRecords *r); -_PUBLIC_ void ndr_print_eventlog_GetOldestRecord(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_GetOldestRecord *r); -_PUBLIC_ void ndr_print_eventlog_ChangeNotify(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ChangeNotify *r); -_PUBLIC_ void ndr_print_eventlog_OpenEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_OpenEventLogW *r); -_PUBLIC_ void ndr_print_eventlog_RegisterEventSourceW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_RegisterEventSourceW *r); -_PUBLIC_ void ndr_print_eventlog_OpenBackupEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_OpenBackupEventLogW *r); -_PUBLIC_ void ndr_print_eventlog_ReadEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ReadEventLogW *r); -_PUBLIC_ void ndr_print_eventlog_ReportEventW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ReportEventW *r); -_PUBLIC_ void ndr_print_eventlog_ClearEventLogA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ClearEventLogA *r); -_PUBLIC_ void ndr_print_eventlog_BackupEventLogA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_BackupEventLogA *r); -_PUBLIC_ void ndr_print_eventlog_OpenEventLogA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_OpenEventLogA *r); -_PUBLIC_ void ndr_print_eventlog_RegisterEventSourceA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_RegisterEventSourceA *r); -_PUBLIC_ void ndr_print_eventlog_OpenBackupEventLogA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_OpenBackupEventLogA *r); -_PUBLIC_ void ndr_print_eventlog_ReadEventLogA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ReadEventLogA *r); -_PUBLIC_ void ndr_print_eventlog_ReportEventA(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ReportEventA *r); -_PUBLIC_ void ndr_print_eventlog_RegisterClusterSvc(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_RegisterClusterSvc *r); -_PUBLIC_ void ndr_print_eventlog_DeregisterClusterSvc(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_DeregisterClusterSvc *r); -_PUBLIC_ void ndr_print_eventlog_WriteClusterEvents(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_WriteClusterEvents *r); -_PUBLIC_ void ndr_print_eventlog_GetLogIntormation(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_GetLogIntormation *r); -_PUBLIC_ void ndr_print_eventlog_FlushEventLog(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_FlushEventLog *r); - -/* The following definitions come from librpc/gen_ndr/ndr_initshutdown.c */ - -_PUBLIC_ void ndr_print_initshutdown_String_sub(struct ndr_print *ndr, const char *name, const struct initshutdown_String_sub *r); -_PUBLIC_ enum ndr_err_code ndr_push_initshutdown_String(struct ndr_push *ndr, int ndr_flags, const struct initshutdown_String *r); -_PUBLIC_ enum ndr_err_code ndr_pull_initshutdown_String(struct ndr_pull *ndr, int ndr_flags, struct initshutdown_String *r); -_PUBLIC_ void ndr_print_initshutdown_String(struct ndr_print *ndr, const char *name, const struct initshutdown_String *r); -_PUBLIC_ void ndr_print_initshutdown_Init(struct ndr_print *ndr, const char *name, int flags, const struct initshutdown_Init *r); -_PUBLIC_ void ndr_print_initshutdown_Abort(struct ndr_print *ndr, const char *name, int flags, const struct initshutdown_Abort *r); -_PUBLIC_ void ndr_print_initshutdown_InitEx(struct ndr_print *ndr, const char *name, int flags, const struct initshutdown_InitEx *r); - -/* The following definitions come from librpc/gen_ndr/ndr_krb5pac.c */ - -_PUBLIC_ void ndr_print_PAC_LOGON_NAME(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_NAME *r); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_SIGNATURE_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_SIGNATURE_DATA *r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_SIGNATURE_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_SIGNATURE_DATA *r); -_PUBLIC_ void ndr_print_PAC_SIGNATURE_DATA(struct ndr_print *ndr, const char *name, const struct PAC_SIGNATURE_DATA *r); -_PUBLIC_ void ndr_print_PAC_LOGON_INFO(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO *r); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO_CTR *r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_LOGON_INFO_CTR(struct ndr_pull *ndr, int ndr_flags, struct PAC_LOGON_INFO_CTR *r); -_PUBLIC_ void ndr_print_PAC_LOGON_INFO_CTR(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_INFO_CTR *r); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_TYPE(struct ndr_push *ndr, int ndr_flags, enum PAC_TYPE r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_TYPE(struct ndr_pull *ndr, int ndr_flags, enum PAC_TYPE *r); -_PUBLIC_ void ndr_print_PAC_TYPE(struct ndr_print *ndr, const char *name, enum PAC_TYPE r); -_PUBLIC_ void ndr_print_DATA_BLOB_REM(struct ndr_print *ndr, const char *name, const struct DATA_BLOB_REM *r); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags, const union PAC_INFO *r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags, union PAC_INFO *r); -_PUBLIC_ void ndr_print_PAC_INFO(struct ndr_print *ndr, const char *name, const union PAC_INFO *r); -_PUBLIC_ size_t ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA *r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA *r); -_PUBLIC_ void ndr_print_PAC_DATA(struct ndr_print *ndr, const char *name, const struct PAC_DATA *r); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_BUFFER_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER_RAW *r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_BUFFER_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER_RAW *r); -_PUBLIC_ void ndr_print_PAC_BUFFER_RAW(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER_RAW *r); -_PUBLIC_ enum ndr_err_code ndr_push_PAC_DATA_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA_RAW *r); -_PUBLIC_ enum ndr_err_code ndr_pull_PAC_DATA_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA_RAW *r); -_PUBLIC_ void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, const struct PAC_DATA_RAW *r); -_PUBLIC_ enum ndr_err_code ndr_push_netsamlogoncache_entry(struct ndr_push *ndr, int ndr_flags, const struct netsamlogoncache_entry *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netsamlogoncache_entry(struct ndr_pull *ndr, int ndr_flags, struct netsamlogoncache_entry *r); -_PUBLIC_ void ndr_print_netsamlogoncache_entry(struct ndr_print *ndr, const char *name, const struct netsamlogoncache_entry *r); -_PUBLIC_ void ndr_print_decode_pac(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac *r); -_PUBLIC_ void ndr_print_decode_pac_raw(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac_raw *r); -_PUBLIC_ void ndr_print_decode_login_info(struct ndr_print *ndr, const char *name, int flags, const struct decode_login_info *r); - -/* The following definitions come from librpc/gen_ndr/ndr_lsa.c */ - -_PUBLIC_ enum ndr_err_code ndr_push_lsa_String(struct ndr_push *ndr, int ndr_flags, const struct lsa_String *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_String(struct ndr_pull *ndr, int ndr_flags, struct lsa_String *r); -_PUBLIC_ void ndr_print_lsa_String(struct ndr_print *ndr, const char *name, const struct lsa_String *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_StringLarge(struct ndr_push *ndr, int ndr_flags, const struct lsa_StringLarge *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_StringLarge(struct ndr_pull *ndr, int ndr_flags, struct lsa_StringLarge *r); -_PUBLIC_ void ndr_print_lsa_StringLarge(struct ndr_print *ndr, const char *name, const struct lsa_StringLarge *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_Strings(struct ndr_push *ndr, int ndr_flags, const struct lsa_Strings *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_Strings(struct ndr_pull *ndr, int ndr_flags, struct lsa_Strings *r); -_PUBLIC_ void ndr_print_lsa_Strings(struct ndr_print *ndr, const char *name, const struct lsa_Strings *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_AsciiString(struct ndr_push *ndr, int ndr_flags, const struct lsa_AsciiString *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_AsciiString(struct ndr_pull *ndr, int ndr_flags, struct lsa_AsciiString *r); -_PUBLIC_ void ndr_print_lsa_AsciiString(struct ndr_print *ndr, const char *name, const struct lsa_AsciiString *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_AsciiStringLarge(struct ndr_push *ndr, int ndr_flags, const struct lsa_AsciiStringLarge *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_AsciiStringLarge(struct ndr_pull *ndr, int ndr_flags, struct lsa_AsciiStringLarge *r); -_PUBLIC_ void ndr_print_lsa_AsciiStringLarge(struct ndr_print *ndr, const char *name, const struct lsa_AsciiStringLarge *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_BinaryString(struct ndr_push *ndr, int ndr_flags, const struct lsa_BinaryString *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_BinaryString(struct ndr_pull *ndr, int ndr_flags, struct lsa_BinaryString *r); -_PUBLIC_ void ndr_print_lsa_BinaryString(struct ndr_print *ndr, const char *name, const struct lsa_BinaryString *r); -_PUBLIC_ void ndr_print_lsa_LUID(struct ndr_print *ndr, const char *name, const struct lsa_LUID *r); -_PUBLIC_ void ndr_print_lsa_PrivEntry(struct ndr_print *ndr, const char *name, const struct lsa_PrivEntry *r); -_PUBLIC_ void ndr_print_lsa_PrivArray(struct ndr_print *ndr, const char *name, const struct lsa_PrivArray *r); -_PUBLIC_ void ndr_print_lsa_QosInfo(struct ndr_print *ndr, const char *name, const struct lsa_QosInfo *r); -_PUBLIC_ void ndr_print_lsa_ObjectAttribute(struct ndr_print *ndr, const char *name, const struct lsa_ObjectAttribute *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_PolicyAccessMask(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_PolicyAccessMask(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_lsa_PolicyAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_lsa_AuditLogInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditLogInfo *r); -_PUBLIC_ void ndr_print_lsa_PolicyAuditPolicy(struct ndr_print *ndr, const char *name, enum lsa_PolicyAuditPolicy r); -_PUBLIC_ void ndr_print_lsa_AuditEventsInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditEventsInfo *r); -_PUBLIC_ void ndr_print_lsa_DomainInfo(struct ndr_print *ndr, const char *name, const struct lsa_DomainInfo *r); -_PUBLIC_ void ndr_print_lsa_PDAccountInfo(struct ndr_print *ndr, const char *name, const struct lsa_PDAccountInfo *r); -_PUBLIC_ void ndr_print_lsa_ServerRole(struct ndr_print *ndr, const char *name, const struct lsa_ServerRole *r); -_PUBLIC_ void ndr_print_lsa_ReplicaSourceInfo(struct ndr_print *ndr, const char *name, const struct lsa_ReplicaSourceInfo *r); -_PUBLIC_ void ndr_print_lsa_DefaultQuotaInfo(struct ndr_print *ndr, const char *name, const struct lsa_DefaultQuotaInfo *r); -_PUBLIC_ void ndr_print_lsa_ModificationInfo(struct ndr_print *ndr, const char *name, const struct lsa_ModificationInfo *r); -_PUBLIC_ void ndr_print_lsa_AuditFullSetInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditFullSetInfo *r); -_PUBLIC_ void ndr_print_lsa_AuditFullQueryInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditFullQueryInfo *r); -_PUBLIC_ void ndr_print_lsa_DnsDomainInfo(struct ndr_print *ndr, const char *name, const struct lsa_DnsDomainInfo *r); -_PUBLIC_ void ndr_print_lsa_PolicyInfo(struct ndr_print *ndr, const char *name, enum lsa_PolicyInfo r); -_PUBLIC_ void ndr_print_lsa_PolicyInformation(struct ndr_print *ndr, const char *name, const union lsa_PolicyInformation *r); -_PUBLIC_ void ndr_print_lsa_SidPtr(struct ndr_print *ndr, const char *name, const struct lsa_SidPtr *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_SidArray(struct ndr_push *ndr, int ndr_flags, const struct lsa_SidArray *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_SidArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_SidArray *r); -_PUBLIC_ void ndr_print_lsa_SidArray(struct ndr_print *ndr, const char *name, const struct lsa_SidArray *r); -_PUBLIC_ void ndr_print_lsa_DomainList(struct ndr_print *ndr, const char *name, const struct lsa_DomainList *r); -_PUBLIC_ void ndr_print_lsa_SidType(struct ndr_print *ndr, const char *name, enum lsa_SidType r); -_PUBLIC_ void ndr_print_lsa_TranslatedSid(struct ndr_print *ndr, const char *name, const struct lsa_TranslatedSid *r); -_PUBLIC_ void ndr_print_lsa_TransSidArray(struct ndr_print *ndr, const char *name, const struct lsa_TransSidArray *r); -_PUBLIC_ void ndr_print_lsa_RefDomainList(struct ndr_print *ndr, const char *name, const struct lsa_RefDomainList *r); -_PUBLIC_ void ndr_print_lsa_LookupNamesLevel(struct ndr_print *ndr, const char *name, enum lsa_LookupNamesLevel r); -_PUBLIC_ void ndr_print_lsa_TranslatedName(struct ndr_print *ndr, const char *name, const struct lsa_TranslatedName *r); -_PUBLIC_ void ndr_print_lsa_TransNameArray(struct ndr_print *ndr, const char *name, const struct lsa_TransNameArray *r); -_PUBLIC_ void ndr_print_lsa_LUIDAttribute(struct ndr_print *ndr, const char *name, const struct lsa_LUIDAttribute *r); -_PUBLIC_ void ndr_print_lsa_PrivilegeSet(struct ndr_print *ndr, const char *name, const struct lsa_PrivilegeSet *r); -_PUBLIC_ void ndr_print_lsa_DATA_BUF(struct ndr_print *ndr, const char *name, const struct lsa_DATA_BUF *r); -_PUBLIC_ void ndr_print_lsa_DATA_BUF2(struct ndr_print *ndr, const char *name, const struct lsa_DATA_BUF2 *r); -_PUBLIC_ void ndr_print_lsa_TrustDomInfoEnum(struct ndr_print *ndr, const char *name, enum lsa_TrustDomInfoEnum r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoName(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoName *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoPosixOffset(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoPosixOffset *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoPassword(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoPassword *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoBasic(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoBasic *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoInfoEx(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoEx *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoBuffer(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoBuffer *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoAuthInfo(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoAuthInfo *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoFullInfo(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoFullInfo *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfo11(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfo11 *r); -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoInfoAll(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoAll *r); -_PUBLIC_ void ndr_print_lsa_TrustedDomainInfo(struct ndr_print *ndr, const char *name, const union lsa_TrustedDomainInfo *r); -_PUBLIC_ void ndr_print_lsa_DATA_BUF_PTR(struct ndr_print *ndr, const char *name, const struct lsa_DATA_BUF_PTR *r); -_PUBLIC_ void ndr_print_lsa_RightSet(struct ndr_print *ndr, const char *name, const struct lsa_RightSet *r); -_PUBLIC_ void ndr_print_lsa_DomainListEx(struct ndr_print *ndr, const char *name, const struct lsa_DomainListEx *r); -_PUBLIC_ void ndr_print_lsa_DomainInfoKerberos(struct ndr_print *ndr, const char *name, const struct lsa_DomainInfoKerberos *r); -_PUBLIC_ void ndr_print_lsa_DomainInfoEfs(struct ndr_print *ndr, const char *name, const struct lsa_DomainInfoEfs *r); -_PUBLIC_ void ndr_print_lsa_DomainInformationPolicy(struct ndr_print *ndr, const char *name, const union lsa_DomainInformationPolicy *r); -_PUBLIC_ void ndr_print_lsa_TranslatedName2(struct ndr_print *ndr, const char *name, const struct lsa_TranslatedName2 *r); -_PUBLIC_ void ndr_print_lsa_TransNameArray2(struct ndr_print *ndr, const char *name, const struct lsa_TransNameArray2 *r); -_PUBLIC_ void ndr_print_lsa_TranslatedSid2(struct ndr_print *ndr, const char *name, const struct lsa_TranslatedSid2 *r); -_PUBLIC_ void ndr_print_lsa_TransSidArray2(struct ndr_print *ndr, const char *name, const struct lsa_TransSidArray2 *r); -_PUBLIC_ void ndr_print_lsa_TranslatedSid3(struct ndr_print *ndr, const char *name, const struct lsa_TranslatedSid3 *r); -_PUBLIC_ void ndr_print_lsa_TransSidArray3(struct ndr_print *ndr, const char *name, const struct lsa_TransSidArray3 *r); -_PUBLIC_ void ndr_print_lsa_ForestTrustBinaryData(struct ndr_print *ndr, const char *name, const struct lsa_ForestTrustBinaryData *r); -_PUBLIC_ void ndr_print_lsa_ForestTrustDomainInfo(struct ndr_print *ndr, const char *name, const struct lsa_ForestTrustDomainInfo *r); -_PUBLIC_ void ndr_print_lsa_ForestTrustData(struct ndr_print *ndr, const char *name, const union lsa_ForestTrustData *r); -_PUBLIC_ void ndr_print_lsa_ForestTrustRecordType(struct ndr_print *ndr, const char *name, enum lsa_ForestTrustRecordType r); -_PUBLIC_ void ndr_print_lsa_ForestTrustRecord(struct ndr_print *ndr, const char *name, const struct lsa_ForestTrustRecord *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_ForestTrustInformation(struct ndr_push *ndr, int ndr_flags, const struct lsa_ForestTrustInformation *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_ForestTrustInformation(struct ndr_pull *ndr, int ndr_flags, struct lsa_ForestTrustInformation *r); -_PUBLIC_ void ndr_print_lsa_ForestTrustInformation(struct ndr_print *ndr, const char *name, const struct lsa_ForestTrustInformation *r); -_PUBLIC_ void ndr_print_lsa_Close(struct ndr_print *ndr, const char *name, int flags, const struct lsa_Close *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_Delete(struct ndr_push *ndr, int flags, const struct lsa_Delete *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_Delete(struct ndr_pull *ndr, int flags, struct lsa_Delete *r); -_PUBLIC_ void ndr_print_lsa_Delete(struct ndr_print *ndr, const char *name, int flags, const struct lsa_Delete *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_EnumPrivs(struct ndr_push *ndr, int flags, const struct lsa_EnumPrivs *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_EnumPrivs(struct ndr_pull *ndr, int flags, struct lsa_EnumPrivs *r); -_PUBLIC_ void ndr_print_lsa_EnumPrivs(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumPrivs *r); -_PUBLIC_ void ndr_print_lsa_QuerySecurity(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QuerySecurity *r); -_PUBLIC_ void ndr_print_lsa_SetSecObj(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetSecObj *r); -_PUBLIC_ void ndr_print_lsa_ChangePassword(struct ndr_print *ndr, const char *name, int flags, const struct lsa_ChangePassword *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenPolicy(struct ndr_push *ndr, int flags, const struct lsa_OpenPolicy *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenPolicy(struct ndr_pull *ndr, int flags, struct lsa_OpenPolicy *r); -_PUBLIC_ void ndr_print_lsa_OpenPolicy(struct ndr_print *ndr, const char *name, int flags, const struct lsa_OpenPolicy *r); -_PUBLIC_ void ndr_print_lsa_QueryInfoPolicy(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QueryInfoPolicy *r); -_PUBLIC_ void ndr_print_lsa_SetInfoPolicy(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetInfoPolicy *r); -_PUBLIC_ void ndr_print_lsa_ClearAuditLog(struct ndr_print *ndr, const char *name, int flags, const struct lsa_ClearAuditLog *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateAccount(struct ndr_push *ndr, int flags, const struct lsa_CreateAccount *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateAccount(struct ndr_pull *ndr, int flags, struct lsa_CreateAccount *r); -_PUBLIC_ void ndr_print_lsa_CreateAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CreateAccount *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_EnumAccounts(struct ndr_push *ndr, int flags, const struct lsa_EnumAccounts *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_EnumAccounts(struct ndr_pull *ndr, int flags, struct lsa_EnumAccounts *r); -_PUBLIC_ void ndr_print_lsa_EnumAccounts(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumAccounts *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateTrustedDomain(struct ndr_push *ndr, int flags, const struct lsa_CreateTrustedDomain *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateTrustedDomain(struct ndr_pull *ndr, int flags, struct lsa_CreateTrustedDomain *r); -_PUBLIC_ void ndr_print_lsa_CreateTrustedDomain(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CreateTrustedDomain *r); -_PUBLIC_ void ndr_print_lsa_EnumTrustDom(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumTrustDom *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames(struct ndr_push *ndr, int flags, const struct lsa_LookupNames *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames(struct ndr_pull *ndr, int flags, struct lsa_LookupNames *r); -_PUBLIC_ void ndr_print_lsa_LookupNames(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupNames *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids(struct ndr_push *ndr, int flags, const struct lsa_LookupSids *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids(struct ndr_pull *ndr, int flags, struct lsa_LookupSids *r); -_PUBLIC_ void ndr_print_lsa_LookupSids(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupSids *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateSecret(struct ndr_push *ndr, int flags, const struct lsa_CreateSecret *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateSecret(struct ndr_pull *ndr, int flags, struct lsa_CreateSecret *r); -_PUBLIC_ void ndr_print_lsa_CreateSecret(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CreateSecret *r); -_PUBLIC_ void ndr_print_lsa_OpenAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_OpenAccount *r); -_PUBLIC_ void ndr_print_lsa_EnumPrivsAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumPrivsAccount *r); -_PUBLIC_ void ndr_print_lsa_AddPrivilegesToAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_AddPrivilegesToAccount *r); -_PUBLIC_ void ndr_print_lsa_RemovePrivilegesFromAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_RemovePrivilegesFromAccount *r); -_PUBLIC_ void ndr_print_lsa_GetQuotasForAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_GetQuotasForAccount *r); -_PUBLIC_ void ndr_print_lsa_SetQuotasForAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetQuotasForAccount *r); -_PUBLIC_ void ndr_print_lsa_GetSystemAccessAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_GetSystemAccessAccount *r); -_PUBLIC_ void ndr_print_lsa_SetSystemAccessAccount(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetSystemAccessAccount *r); -_PUBLIC_ void ndr_print_lsa_OpenTrustedDomain(struct ndr_print *ndr, const char *name, int flags, const struct lsa_OpenTrustedDomain *r); -_PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfo(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QueryTrustedDomainInfo *r); -_PUBLIC_ void ndr_print_lsa_SetInformationTrustedDomain(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetInformationTrustedDomain *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenSecret(struct ndr_push *ndr, int flags, const struct lsa_OpenSecret *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenSecret(struct ndr_pull *ndr, int flags, struct lsa_OpenSecret *r); -_PUBLIC_ void ndr_print_lsa_OpenSecret(struct ndr_print *ndr, const char *name, int flags, const struct lsa_OpenSecret *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_SetSecret(struct ndr_push *ndr, int flags, const struct lsa_SetSecret *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_SetSecret(struct ndr_pull *ndr, int flags, struct lsa_SetSecret *r); -_PUBLIC_ void ndr_print_lsa_SetSecret(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetSecret *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_QuerySecret(struct ndr_push *ndr, int flags, const struct lsa_QuerySecret *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_QuerySecret(struct ndr_pull *ndr, int flags, struct lsa_QuerySecret *r); -_PUBLIC_ void ndr_print_lsa_QuerySecret(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QuerySecret *r); -_PUBLIC_ void ndr_print_lsa_LookupPrivValue(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupPrivValue *r); -_PUBLIC_ void ndr_print_lsa_LookupPrivName(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupPrivName *r); -_PUBLIC_ void ndr_print_lsa_LookupPrivDisplayName(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupPrivDisplayName *r); -_PUBLIC_ void ndr_print_lsa_DeleteObject(struct ndr_print *ndr, const char *name, int flags, const struct lsa_DeleteObject *r); -_PUBLIC_ void ndr_print_lsa_EnumAccountsWithUserRight(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumAccountsWithUserRight *r); -_PUBLIC_ void ndr_print_lsa_EnumAccountRights(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumAccountRights *r); -_PUBLIC_ void ndr_print_lsa_AddAccountRights(struct ndr_print *ndr, const char *name, int flags, const struct lsa_AddAccountRights *r); -_PUBLIC_ void ndr_print_lsa_RemoveAccountRights(struct ndr_print *ndr, const char *name, int flags, const struct lsa_RemoveAccountRights *r); -_PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfoBySid(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QueryTrustedDomainInfoBySid *r); -_PUBLIC_ void ndr_print_lsa_SetTrustedDomainInfo(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetTrustedDomainInfo *r); -_PUBLIC_ void ndr_print_lsa_DeleteTrustedDomain(struct ndr_print *ndr, const char *name, int flags, const struct lsa_DeleteTrustedDomain *r); -_PUBLIC_ void ndr_print_lsa_StorePrivateData(struct ndr_print *ndr, const char *name, int flags, const struct lsa_StorePrivateData *r); -_PUBLIC_ void ndr_print_lsa_RetrievePrivateData(struct ndr_print *ndr, const char *name, int flags, const struct lsa_RetrievePrivateData *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenPolicy2(struct ndr_push *ndr, int flags, const struct lsa_OpenPolicy2 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenPolicy2(struct ndr_pull *ndr, int flags, struct lsa_OpenPolicy2 *r); -_PUBLIC_ void ndr_print_lsa_OpenPolicy2(struct ndr_print *ndr, const char *name, int flags, const struct lsa_OpenPolicy2 *r); -_PUBLIC_ void ndr_print_lsa_GetUserName(struct ndr_print *ndr, const char *name, int flags, const struct lsa_GetUserName *r); -_PUBLIC_ void ndr_print_lsa_QueryInfoPolicy2(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QueryInfoPolicy2 *r); -_PUBLIC_ void ndr_print_lsa_SetInfoPolicy2(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetInfoPolicy2 *r); -_PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfoByName(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QueryTrustedDomainInfoByName *r); -_PUBLIC_ void ndr_print_lsa_SetTrustedDomainInfoByName(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetTrustedDomainInfoByName *r); -_PUBLIC_ void ndr_print_lsa_EnumTrustedDomainsEx(struct ndr_print *ndr, const char *name, int flags, const struct lsa_EnumTrustedDomainsEx *r); -_PUBLIC_ void ndr_print_lsa_CreateTrustedDomainEx(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CreateTrustedDomainEx *r); -_PUBLIC_ void ndr_print_lsa_CloseTrustedDomainEx(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CloseTrustedDomainEx *r); -_PUBLIC_ void ndr_print_lsa_QueryDomainInformationPolicy(struct ndr_print *ndr, const char *name, int flags, const struct lsa_QueryDomainInformationPolicy *r); -_PUBLIC_ void ndr_print_lsa_SetDomainInformationPolicy(struct ndr_print *ndr, const char *name, int flags, const struct lsa_SetDomainInformationPolicy *r); -_PUBLIC_ void ndr_print_lsa_OpenTrustedDomainByName(struct ndr_print *ndr, const char *name, int flags, const struct lsa_OpenTrustedDomainByName *r); -_PUBLIC_ void ndr_print_lsa_TestCall(struct ndr_print *ndr, const char *name, int flags, const struct lsa_TestCall *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids2(struct ndr_push *ndr, int flags, const struct lsa_LookupSids2 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids2(struct ndr_pull *ndr, int flags, struct lsa_LookupSids2 *r); -_PUBLIC_ void ndr_print_lsa_LookupSids2(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupSids2 *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames2(struct ndr_push *ndr, int flags, const struct lsa_LookupNames2 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames2(struct ndr_pull *ndr, int flags, struct lsa_LookupNames2 *r); -_PUBLIC_ void ndr_print_lsa_LookupNames2(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupNames2 *r); -_PUBLIC_ void ndr_print_lsa_CreateTrustedDomainEx2(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CreateTrustedDomainEx2 *r); -_PUBLIC_ void ndr_print_lsa_CREDRWRITE(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRWRITE *r); -_PUBLIC_ void ndr_print_lsa_CREDRREAD(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRREAD *r); -_PUBLIC_ void ndr_print_lsa_CREDRENUMERATE(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRENUMERATE *r); -_PUBLIC_ void ndr_print_lsa_CREDRWRITEDOMAINCREDENTIALS(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRWRITEDOMAINCREDENTIALS *r); -_PUBLIC_ void ndr_print_lsa_CREDRREADDOMAINCREDENTIALS(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRREADDOMAINCREDENTIALS *r); -_PUBLIC_ void ndr_print_lsa_CREDRDELETE(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRDELETE *r); -_PUBLIC_ void ndr_print_lsa_CREDRGETTARGETINFO(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRGETTARGETINFO *r); -_PUBLIC_ void ndr_print_lsa_CREDRPROFILELOADED(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRPROFILELOADED *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int flags, const struct lsa_LookupNames3 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int flags, struct lsa_LookupNames3 *r); -_PUBLIC_ void ndr_print_lsa_LookupNames3(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupNames3 *r); -_PUBLIC_ void ndr_print_lsa_CREDRGETSESSIONTYPES(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRGETSESSIONTYPES *r); -_PUBLIC_ void ndr_print_lsa_LSARREGISTERAUDITEVENT(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARREGISTERAUDITEVENT *r); -_PUBLIC_ void ndr_print_lsa_LSARGENAUDITEVENT(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARGENAUDITEVENT *r); -_PUBLIC_ void ndr_print_lsa_LSARUNREGISTERAUDITEVENT(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARUNREGISTERAUDITEVENT *r); -_PUBLIC_ void ndr_print_lsa_lsaRQueryForestTrustInformation(struct ndr_print *ndr, const char *name, int flags, const struct lsa_lsaRQueryForestTrustInformation *r); -_PUBLIC_ void ndr_print_lsa_LSARSETFORESTTRUSTINFORMATION(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARSETFORESTTRUSTINFORMATION *r); -_PUBLIC_ void ndr_print_lsa_CREDRRENAME(struct ndr_print *ndr, const char *name, int flags, const struct lsa_CREDRRENAME *r); -_PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids3(struct ndr_push *ndr, int flags, const struct lsa_LookupSids3 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids3(struct ndr_pull *ndr, int flags, struct lsa_LookupSids3 *r); -_PUBLIC_ void ndr_print_lsa_LookupSids3(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupSids3 *r); -_PUBLIC_ void ndr_print_lsa_LookupNames4(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LookupNames4 *r); -_PUBLIC_ void ndr_print_lsa_LSAROPENPOLICYSCE(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSAROPENPOLICYSCE *r); -_PUBLIC_ void ndr_print_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r); -_PUBLIC_ void ndr_print_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r); -_PUBLIC_ void ndr_print_lsa_LSARADTREPORTSECURITYEVENT(struct ndr_print *ndr, const char *name, int flags, const struct lsa_LSARADTREPORTSECURITYEVENT *r); - -/* The following definitions come from librpc/gen_ndr/ndr_misc.c */ - -_PUBLIC_ enum ndr_err_code ndr_push_GUID(struct ndr_push *ndr, int ndr_flags, const struct GUID *r); -_PUBLIC_ enum ndr_err_code ndr_pull_GUID(struct ndr_pull *ndr, int ndr_flags, struct GUID *r); -_PUBLIC_ size_t ndr_size_GUID(const struct GUID *r, int flags); -_PUBLIC_ enum ndr_err_code ndr_push_ndr_syntax_id(struct ndr_push *ndr, int ndr_flags, const struct ndr_syntax_id *r); -_PUBLIC_ enum ndr_err_code ndr_pull_ndr_syntax_id(struct ndr_pull *ndr, int ndr_flags, struct ndr_syntax_id *r); -_PUBLIC_ void ndr_print_ndr_syntax_id(struct ndr_print *ndr, const char *name, const struct ndr_syntax_id *r); -_PUBLIC_ enum ndr_err_code ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r); -_PUBLIC_ enum ndr_err_code ndr_pull_policy_handle(struct ndr_pull *ndr, int ndr_flags, struct policy_handle *r); -_PUBLIC_ void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, const struct policy_handle *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_SchannelType(struct ndr_push *ndr, int ndr_flags, enum netr_SchannelType r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_SchannelType(struct ndr_pull *ndr, int ndr_flags, enum netr_SchannelType *r); -_PUBLIC_ void ndr_print_netr_SchannelType(struct ndr_print *ndr, const char *name, enum netr_SchannelType r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_SamDatabaseID(struct ndr_push *ndr, int ndr_flags, enum netr_SamDatabaseID r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_SamDatabaseID(struct ndr_pull *ndr, int ndr_flags, enum netr_SamDatabaseID *r); -_PUBLIC_ void ndr_print_netr_SamDatabaseID(struct ndr_print *ndr, const char *name, enum netr_SamDatabaseID r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_RejectReason(struct ndr_push *ndr, int ndr_flags, enum samr_RejectReason r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_RejectReason(struct ndr_pull *ndr, int ndr_flags, enum samr_RejectReason *r); -_PUBLIC_ void ndr_print_samr_RejectReason(struct ndr_print *ndr, const char *name, enum samr_RejectReason r); - -/* The following definitions come from librpc/gen_ndr/ndr_nbt.c */ - -_PUBLIC_ void ndr_print_nbt_operation(struct ndr_print *ndr, const char *name, uint16_t r); -_PUBLIC_ void ndr_print_nbt_name_type(struct ndr_print *ndr, const char *name, enum nbt_name_type r); -_PUBLIC_ void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r); -_PUBLIC_ void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum nbt_qclass r); -_PUBLIC_ void ndr_print_nbt_qtype(struct ndr_print *ndr, const char *name, enum nbt_qtype r); -_PUBLIC_ void ndr_print_nbt_name_question(struct ndr_print *ndr, const char *name, const struct nbt_name_question *r); -_PUBLIC_ void ndr_print_nb_flags(struct ndr_print *ndr, const char *name, uint16_t r); -_PUBLIC_ void ndr_print_nbt_rdata_address(struct ndr_print *ndr, const char *name, const struct nbt_rdata_address *r); -_PUBLIC_ void ndr_print_nbt_rdata_netbios(struct ndr_print *ndr, const char *name, const struct nbt_rdata_netbios *r); -_PUBLIC_ void ndr_print_nbt_statistics(struct ndr_print *ndr, const char *name, const struct nbt_statistics *r); -_PUBLIC_ void ndr_print_nbt_status_name(struct ndr_print *ndr, const char *name, const struct nbt_status_name *r); -_PUBLIC_ void ndr_print_nbt_rdata_status(struct ndr_print *ndr, const char *name, const struct nbt_rdata_status *r); -_PUBLIC_ void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name, const struct nbt_rdata_data *r); -_PUBLIC_ void ndr_print_nbt_rdata(struct ndr_print *ndr, const char *name, const union nbt_rdata *r); -_PUBLIC_ void ndr_print_nbt_res_rec(struct ndr_print *ndr, const char *name, const struct nbt_res_rec *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_name_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_name_packet *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_name_packet *r); -_PUBLIC_ void ndr_print_nbt_name_packet(struct ndr_print *ndr, const char *name, const struct nbt_name_packet *r); -_PUBLIC_ void ndr_print_dgram_msg_type(struct ndr_print *ndr, const char *name, enum dgram_msg_type r); -_PUBLIC_ void ndr_print_dgram_flags(struct ndr_print *ndr, const char *name, uint8_t r); -_PUBLIC_ void ndr_print_smb_command(struct ndr_print *ndr, const char *name, enum smb_command r); -_PUBLIC_ void ndr_print_smb_trans_body(struct ndr_print *ndr, const char *name, const struct smb_trans_body *r); -_PUBLIC_ void ndr_print_smb_body(struct ndr_print *ndr, const char *name, const union smb_body *r); -_PUBLIC_ enum ndr_err_code ndr_push_dgram_smb_packet(struct ndr_push *ndr, int ndr_flags, const struct dgram_smb_packet *r); -_PUBLIC_ enum ndr_err_code ndr_pull_dgram_smb_packet(struct ndr_pull *ndr, int ndr_flags, struct dgram_smb_packet *r); -_PUBLIC_ void ndr_print_dgram_smb_packet(struct ndr_print *ndr, const char *name, const struct dgram_smb_packet *r); -_PUBLIC_ void ndr_print_dgram_message_body(struct ndr_print *ndr, const char *name, const union dgram_message_body *r); -_PUBLIC_ void ndr_print_dgram_message(struct ndr_print *ndr, const char *name, const struct dgram_message *r); -_PUBLIC_ void ndr_print_dgram_err_code(struct ndr_print *ndr, const char *name, enum dgram_err_code r); -_PUBLIC_ void ndr_print_dgram_data(struct ndr_print *ndr, const char *name, const union dgram_data *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_dgram_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_dgram_packet *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_dgram_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_dgram_packet *r); -_PUBLIC_ void ndr_print_nbt_dgram_packet(struct ndr_print *ndr, const char *name, const struct nbt_dgram_packet *r); -_PUBLIC_ void ndr_print_nbt_netlogon_command(struct ndr_print *ndr, const char *name, enum nbt_netlogon_command r); -_PUBLIC_ void ndr_print_nbt_netlogon_version(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc *r); -_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc2 *r); -_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r); -_PUBLIC_ void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_nbt_dc_sock_addr(struct ndr_print *ndr, const char *name, const struct nbt_dc_sock_addr *r); -_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc2 *r); -_PUBLIC_ void ndr_print_nbt_db_change(struct ndr_print *ndr, const char *name, const struct nbt_db_change *r); -_PUBLIC_ void ndr_print_nbt_netlogon_announce_uas(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_announce_uas *r); -_PUBLIC_ void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r); -_PUBLIC_ void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_1(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_1 *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_3(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_3 *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_5(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_5 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_5(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_5 *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_5(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_5 *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_13 *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_15(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_15 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_15(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_15 *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_15(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_15 *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_29(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_29 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_29(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_29 *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_29(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_29 *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon(struct ndr_push *ndr, int ndr_flags, const union nbt_cldap_netlogon *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon(struct ndr_pull *ndr, int ndr_flags, union nbt_cldap_netlogon *r); -_PUBLIC_ void ndr_print_nbt_cldap_netlogon(struct ndr_print *ndr, const char *name, const union nbt_cldap_netlogon *r); -_PUBLIC_ void ndr_print_nbt_ntlogon_command(struct ndr_print *ndr, const char *name, enum nbt_ntlogon_command r); -_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon *r); -_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon_reply(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon_reply *r); -_PUBLIC_ void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *name, const union nbt_ntlogon_request *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_ntlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_packet *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_ntlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_packet *r); -_PUBLIC_ void ndr_print_nbt_ntlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_packet *r); -_PUBLIC_ void ndr_print_nbt_browse_opcode(struct ndr_print *ndr, const char *name, enum nbt_browse_opcode r); -_PUBLIC_ void ndr_print_nbt_browse_host_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_host_announcement *r); -_PUBLIC_ void ndr_print_nbt_browse_announcement_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_announcement_request *r); -_PUBLIC_ void ndr_print_nbt_browse_election_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_election_request *r); -_PUBLIC_ void ndr_print_nbt_browse_backup_list_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_request *r); -_PUBLIC_ void ndr_print_nbt_browse_backup_list_response(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_response *r); -_PUBLIC_ void ndr_print_nbt_browse_become_backup(struct ndr_print *ndr, const char *name, const struct nbt_browse_become_backup *r); -_PUBLIC_ void ndr_print_nbt_browse_domain_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_domain_announcement *r); -_PUBLIC_ void ndr_print_nbt_browse_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_master_announcement *r); -_PUBLIC_ void ndr_print_nbt_browse_reset_state(struct ndr_print *ndr, const char *name, const struct nbt_browse_reset_state *r); -_PUBLIC_ void ndr_print_nbt_browse_local_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_local_master_announcement *r); -_PUBLIC_ void ndr_print_nbt_browse_payload(struct ndr_print *ndr, const char *name, const union nbt_browse_payload *r); -_PUBLIC_ enum ndr_err_code ndr_push_nbt_browse_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_packet *r); -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_browse_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_packet *r); -_PUBLIC_ void ndr_print_nbt_browse_packet(struct ndr_print *ndr, const char *name, const struct nbt_browse_packet *r); - -/* The following definitions come from librpc/gen_ndr/ndr_netlogon.c */ - -_PUBLIC_ void ndr_print_netr_UasInfo(struct ndr_print *ndr, const char *name, const struct netr_UasInfo *r); -_PUBLIC_ void ndr_print_netr_UasLogoffInfo(struct ndr_print *ndr, const char *name, const struct netr_UasLogoffInfo *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_AcctLockStr(struct ndr_push *ndr, int ndr_flags, const struct netr_AcctLockStr *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_AcctLockStr(struct ndr_pull *ndr, int ndr_flags, struct netr_AcctLockStr *r); -_PUBLIC_ void ndr_print_netr_AcctLockStr(struct ndr_print *ndr, const char *name, const struct netr_AcctLockStr *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_LogonParameterControl(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonParameterControl(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_netr_LogonParameterControl(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_IdentityInfo(struct ndr_print *ndr, const char *name, const struct netr_IdentityInfo *r); -_PUBLIC_ void ndr_print_netr_PasswordInfo(struct ndr_print *ndr, const char *name, const struct netr_PasswordInfo *r); -_PUBLIC_ void ndr_print_netr_ChallengeResponse(struct ndr_print *ndr, const char *name, const struct netr_ChallengeResponse *r); -_PUBLIC_ void ndr_print_netr_NetworkInfo(struct ndr_print *ndr, const char *name, const struct netr_NetworkInfo *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_LogonInfo(struct ndr_push *ndr, int ndr_flags, const union netr_LogonInfo *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr_flags, union netr_LogonInfo *r); -_PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, const union netr_LogonInfo *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_UserSessionKey(struct ndr_push *ndr, int ndr_flags, const struct netr_UserSessionKey *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_UserSessionKey(struct ndr_pull *ndr, int ndr_flags, struct netr_UserSessionKey *r); -_PUBLIC_ void ndr_print_netr_UserSessionKey(struct ndr_print *ndr, const char *name, const struct netr_UserSessionKey *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_LMSessionKey(struct ndr_push *ndr, int ndr_flags, const struct netr_LMSessionKey *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_LMSessionKey(struct ndr_pull *ndr, int ndr_flags, struct netr_LMSessionKey *r); -_PUBLIC_ void ndr_print_netr_LMSessionKey(struct ndr_print *ndr, const char *name, const struct netr_LMSessionKey *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_UserFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_UserFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_netr_UserFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_SamBaseInfo(struct ndr_print *ndr, const char *name, const struct netr_SamBaseInfo *r); -_PUBLIC_ void ndr_print_netr_SamInfo2(struct ndr_print *ndr, const char *name, const struct netr_SamInfo2 *r); -_PUBLIC_ void ndr_print_netr_SidAttr(struct ndr_print *ndr, const char *name, const struct netr_SidAttr *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_SamInfo3(struct ndr_push *ndr, int ndr_flags, const struct netr_SamInfo3 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_SamInfo3(struct ndr_pull *ndr, int ndr_flags, struct netr_SamInfo3 *r); -_PUBLIC_ void ndr_print_netr_SamInfo3(struct ndr_print *ndr, const char *name, const struct netr_SamInfo3 *r); -_PUBLIC_ void ndr_print_netr_SamInfo6(struct ndr_print *ndr, const char *name, const struct netr_SamInfo6 *r); -_PUBLIC_ void ndr_print_netr_PacInfo(struct ndr_print *ndr, const char *name, const struct netr_PacInfo *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_Validation(struct ndr_push *ndr, int ndr_flags, const union netr_Validation *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int ndr_flags, union netr_Validation *r); -_PUBLIC_ void ndr_print_netr_Validation(struct ndr_print *ndr, const char *name, const union netr_Validation *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_Credential(struct ndr_push *ndr, int ndr_flags, const struct netr_Credential *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_Credential(struct ndr_pull *ndr, int ndr_flags, struct netr_Credential *r); -_PUBLIC_ void ndr_print_netr_Credential(struct ndr_print *ndr, const char *name, const struct netr_Credential *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_Authenticator(struct ndr_push *ndr, int ndr_flags, const struct netr_Authenticator *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_Authenticator(struct ndr_pull *ndr, int ndr_flags, struct netr_Authenticator *r); -_PUBLIC_ void ndr_print_netr_Authenticator(struct ndr_print *ndr, const char *name, const struct netr_Authenticator *r); -_PUBLIC_ void ndr_print_netr_LogonLevel(struct ndr_print *ndr, const char *name, enum netr_LogonLevel r); -_PUBLIC_ void ndr_print_netr_DELTA_DELETE_USER(struct ndr_print *ndr, const char *name, const struct netr_DELTA_DELETE_USER *r); -_PUBLIC_ void ndr_print_netr_USER_KEY16(struct ndr_print *ndr, const char *name, const struct netr_USER_KEY16 *r); -_PUBLIC_ void ndr_print_netr_PasswordHistory(struct ndr_print *ndr, const char *name, const struct netr_PasswordHistory *r); -_PUBLIC_ void ndr_print_netr_USER_KEYS2(struct ndr_print *ndr, const char *name, const struct netr_USER_KEYS2 *r); -_PUBLIC_ void ndr_print_netr_USER_KEY_UNION(struct ndr_print *ndr, const char *name, const struct netr_USER_KEY_UNION *r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_USER_KEYS(struct ndr_push *ndr, int ndr_flags, const struct netr_USER_KEYS *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_USER_KEYS(struct ndr_pull *ndr, int ndr_flags, struct netr_USER_KEYS *r); -_PUBLIC_ void ndr_print_netr_USER_KEYS(struct ndr_print *ndr, const char *name, const struct netr_USER_KEYS *r); -_PUBLIC_ void ndr_print_netr_USER_PRIVATE_INFO(struct ndr_print *ndr, const char *name, const struct netr_USER_PRIVATE_INFO *r); -_PUBLIC_ void ndr_print_netr_DELTA_USER(struct ndr_print *ndr, const char *name, const struct netr_DELTA_USER *r); -_PUBLIC_ void ndr_print_netr_DELTA_DOMAIN(struct ndr_print *ndr, const char *name, const struct netr_DELTA_DOMAIN *r); -_PUBLIC_ void ndr_print_netr_DELTA_GROUP(struct ndr_print *ndr, const char *name, const struct netr_DELTA_GROUP *r); -_PUBLIC_ void ndr_print_netr_DELTA_RENAME(struct ndr_print *ndr, const char *name, const struct netr_DELTA_RENAME *r); -_PUBLIC_ void ndr_print_netr_DELTA_GROUP_MEMBER(struct ndr_print *ndr, const char *name, const struct netr_DELTA_GROUP_MEMBER *r); -_PUBLIC_ void ndr_print_netr_DELTA_ALIAS(struct ndr_print *ndr, const char *name, const struct netr_DELTA_ALIAS *r); -_PUBLIC_ void ndr_print_netr_DELTA_ALIAS_MEMBER(struct ndr_print *ndr, const char *name, const struct netr_DELTA_ALIAS_MEMBER *r); -_PUBLIC_ void ndr_print_netr_QUOTA_LIMITS(struct ndr_print *ndr, const char *name, const struct netr_QUOTA_LIMITS *r); -_PUBLIC_ void ndr_print_netr_DELTA_POLICY(struct ndr_print *ndr, const char *name, const struct netr_DELTA_POLICY *r); -_PUBLIC_ void ndr_print_netr_DELTA_TRUSTED_DOMAIN(struct ndr_print *ndr, const char *name, const struct netr_DELTA_TRUSTED_DOMAIN *r); -_PUBLIC_ void ndr_print_netr_DELTA_DELETE_TRUST(struct ndr_print *ndr, const char *name, const struct netr_DELTA_DELETE_TRUST *r); -_PUBLIC_ void ndr_print_netr_DELTA_ACCOUNT(struct ndr_print *ndr, const char *name, const struct netr_DELTA_ACCOUNT *r); -_PUBLIC_ void ndr_print_netr_DELTA_DELETE_ACCOUNT(struct ndr_print *ndr, const char *name, const struct netr_DELTA_DELETE_ACCOUNT *r); -_PUBLIC_ void ndr_print_netr_DELTA_DELETE_SECRET(struct ndr_print *ndr, const char *name, const struct netr_DELTA_DELETE_SECRET *r); -_PUBLIC_ void ndr_print_netr_CIPHER_VALUE(struct ndr_print *ndr, const char *name, const struct netr_CIPHER_VALUE *r); -_PUBLIC_ void ndr_print_netr_DELTA_SECRET(struct ndr_print *ndr, const char *name, const struct netr_DELTA_SECRET *r); -_PUBLIC_ void ndr_print_netr_DeltaEnum(struct ndr_print *ndr, const char *name, enum netr_DeltaEnum r); -_PUBLIC_ void ndr_print_netr_DELTA_UNION(struct ndr_print *ndr, const char *name, const union netr_DELTA_UNION *r); -_PUBLIC_ void ndr_print_netr_DELTA_ID_UNION(struct ndr_print *ndr, const char *name, const union netr_DELTA_ID_UNION *r); -_PUBLIC_ void ndr_print_netr_DELTA_ENUM(struct ndr_print *ndr, const char *name, const struct netr_DELTA_ENUM *r); -_PUBLIC_ void ndr_print_netr_DELTA_ENUM_ARRAY(struct ndr_print *ndr, const char *name, const struct netr_DELTA_ENUM_ARRAY *r); -_PUBLIC_ void ndr_print_netr_UAS_INFO_0(struct ndr_print *ndr, const char *name, const struct netr_UAS_INFO_0 *r); -_PUBLIC_ void ndr_print_netr_AccountBuffer(struct ndr_print *ndr, const char *name, const struct netr_AccountBuffer *r); -_PUBLIC_ void ndr_print_netr_InfoFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_NETLOGON_INFO_1(struct ndr_print *ndr, const char *name, const struct netr_NETLOGON_INFO_1 *r); -_PUBLIC_ void ndr_print_netr_NETLOGON_INFO_2(struct ndr_print *ndr, const char *name, const struct netr_NETLOGON_INFO_2 *r); -_PUBLIC_ void ndr_print_netr_NETLOGON_INFO_3(struct ndr_print *ndr, const char *name, const struct netr_NETLOGON_INFO_3 *r); -_PUBLIC_ void ndr_print_netr_CONTROL_QUERY_INFORMATION(struct ndr_print *ndr, const char *name, const union netr_CONTROL_QUERY_INFORMATION *r); -_PUBLIC_ void ndr_print_netr_LogonControlCode(struct ndr_print *ndr, const char *name, enum netr_LogonControlCode r); -_PUBLIC_ void ndr_print_netr_CONTROL_DATA_INFORMATION(struct ndr_print *ndr, const char *name, const union netr_CONTROL_DATA_INFORMATION *r); -_PUBLIC_ void ndr_print_netr_NegotiateFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_Blob(struct ndr_print *ndr, const char *name, const struct netr_Blob *r); -_PUBLIC_ void ndr_print_netr_DsRGetDCName_flags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_DsRGetDCNameInfo_AddressType(struct ndr_print *ndr, const char *name, enum netr_DsRGetDCNameInfo_AddressType r); -_PUBLIC_ void ndr_print_netr_DsR_DcFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_push_netr_DsRGetDCNameInfo(struct ndr_push *ndr, int ndr_flags, const struct netr_DsRGetDCNameInfo *r); -_PUBLIC_ enum ndr_err_code ndr_pull_netr_DsRGetDCNameInfo(struct ndr_pull *ndr, int ndr_flags, struct netr_DsRGetDCNameInfo *r); -_PUBLIC_ void ndr_print_netr_DsRGetDCNameInfo(struct ndr_print *ndr, const char *name, const struct netr_DsRGetDCNameInfo *r); -_PUBLIC_ void ndr_print_netr_BinaryString(struct ndr_print *ndr, const char *name, const struct netr_BinaryString *r); -_PUBLIC_ void ndr_print_netr_DomainQuery1(struct ndr_print *ndr, const char *name, const struct netr_DomainQuery1 *r); -_PUBLIC_ void ndr_print_netr_DomainQuery(struct ndr_print *ndr, const char *name, const union netr_DomainQuery *r); -_PUBLIC_ void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char *name, const struct netr_DomainTrustInfo *r); -_PUBLIC_ void ndr_print_netr_DomainInfo1(struct ndr_print *ndr, const char *name, const struct netr_DomainInfo1 *r); -_PUBLIC_ void ndr_print_netr_DomainInfo(struct ndr_print *ndr, const char *name, const union netr_DomainInfo *r); -_PUBLIC_ void ndr_print_netr_CryptPassword(struct ndr_print *ndr, const char *name, const struct netr_CryptPassword *r); -_PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesWCtr(struct ndr_print *ndr, const char *name, const struct netr_DsRAddressToSitenamesWCtr *r); -_PUBLIC_ void ndr_print_netr_DsRAddress(struct ndr_print *ndr, const char *name, const struct netr_DsRAddress *r); -_PUBLIC_ void ndr_print_netr_TrustFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_TrustType(struct ndr_print *ndr, const char *name, enum netr_TrustType r); -_PUBLIC_ void ndr_print_netr_TrustAttributes(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_netr_DomainTrust(struct ndr_print *ndr, const char *name, const struct netr_DomainTrust *r); -_PUBLIC_ void ndr_print_netr_DomainTrustList(struct ndr_print *ndr, const char *name, const struct netr_DomainTrustList *r); -_PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesExWCtr(struct ndr_print *ndr, const char *name, const struct netr_DsRAddressToSitenamesExWCtr *r); -_PUBLIC_ void ndr_print_DcSitesCtr(struct ndr_print *ndr, const char *name, const struct DcSitesCtr *r); -_PUBLIC_ void ndr_print_netr_LogonUasLogon(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonUasLogon *r); -_PUBLIC_ void ndr_print_netr_LogonUasLogoff(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonUasLogoff *r); -_PUBLIC_ void ndr_print_netr_LogonSamLogon(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonSamLogon *r); -_PUBLIC_ void ndr_print_netr_LogonSamLogoff(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonSamLogoff *r); -_PUBLIC_ void ndr_print_netr_ServerReqChallenge(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerReqChallenge *r); -_PUBLIC_ void ndr_print_netr_ServerAuthenticate(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerAuthenticate *r); -_PUBLIC_ void ndr_print_netr_ServerPasswordSet(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerPasswordSet *r); -_PUBLIC_ void ndr_print_netr_DatabaseDeltas(struct ndr_print *ndr, const char *name, int flags, const struct netr_DatabaseDeltas *r); -_PUBLIC_ void ndr_print_netr_DatabaseSync(struct ndr_print *ndr, const char *name, int flags, const struct netr_DatabaseSync *r); -_PUBLIC_ void ndr_print_netr_AccountDeltas(struct ndr_print *ndr, const char *name, int flags, const struct netr_AccountDeltas *r); -_PUBLIC_ void ndr_print_netr_AccountSync(struct ndr_print *ndr, const char *name, int flags, const struct netr_AccountSync *r); -_PUBLIC_ void ndr_print_netr_GetDcName(struct ndr_print *ndr, const char *name, int flags, const struct netr_GetDcName *r); -_PUBLIC_ void ndr_print_netr_LogonControl(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonControl *r); -_PUBLIC_ void ndr_print_netr_GetAnyDCName(struct ndr_print *ndr, const char *name, int flags, const struct netr_GetAnyDCName *r); -_PUBLIC_ void ndr_print_netr_LogonControl2(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonControl2 *r); -_PUBLIC_ void ndr_print_netr_ServerAuthenticate2(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerAuthenticate2 *r); -_PUBLIC_ void ndr_print_netr_DatabaseSync2(struct ndr_print *ndr, const char *name, int flags, const struct netr_DatabaseSync2 *r); -_PUBLIC_ void ndr_print_netr_DatabaseRedo(struct ndr_print *ndr, const char *name, int flags, const struct netr_DatabaseRedo *r); -_PUBLIC_ void ndr_print_netr_LogonControl2Ex(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonControl2Ex *r); -_PUBLIC_ void ndr_print_netr_NetrEnumerateTrustedDomains(struct ndr_print *ndr, const char *name, int flags, const struct netr_NetrEnumerateTrustedDomains *r); -_PUBLIC_ void ndr_print_netr_DsRGetDCName(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRGetDCName *r); -_PUBLIC_ void ndr_print_netr_NETRLOGONDUMMYROUTINE1(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRLOGONDUMMYROUTINE1 *r); -_PUBLIC_ void ndr_print_netr_NETRLOGONSETSERVICEBITS(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRLOGONSETSERVICEBITS *r); -_PUBLIC_ void ndr_print_netr_LogonGetTrustRid(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonGetTrustRid *r); -_PUBLIC_ void ndr_print_netr_NETRLOGONCOMPUTESERVERDIGEST(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRLOGONCOMPUTESERVERDIGEST *r); -_PUBLIC_ void ndr_print_netr_NETRLOGONCOMPUTECLIENTDIGEST(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r); -_PUBLIC_ void ndr_print_netr_ServerAuthenticate3(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerAuthenticate3 *r); -_PUBLIC_ void ndr_print_netr_DsRGetDCNameEx(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRGetDCNameEx *r); -_PUBLIC_ void ndr_print_netr_DsRGetSiteName(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRGetSiteName *r); -_PUBLIC_ void ndr_print_netr_LogonGetDomainInfo(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonGetDomainInfo *r); -_PUBLIC_ void ndr_print_netr_ServerPasswordSet2(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerPasswordSet2 *r); -_PUBLIC_ void ndr_print_netr_ServerPasswordGet(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerPasswordGet *r); -_PUBLIC_ void ndr_print_netr_NETRLOGONSENDTOSAM(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRLOGONSENDTOSAM *r); -_PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesW(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRAddressToSitenamesW *r); -_PUBLIC_ void ndr_print_netr_DsRGetDCNameEx2(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRGetDCNameEx2 *r); -_PUBLIC_ void ndr_print_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r); -_PUBLIC_ void ndr_print_netr_NetrEnumerateTrustedDomainsEx(struct ndr_print *ndr, const char *name, int flags, const struct netr_NetrEnumerateTrustedDomainsEx *r); -_PUBLIC_ void ndr_print_netr_DsRAddressToSitenamesExW(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRAddressToSitenamesExW *r); -_PUBLIC_ void ndr_print_netr_DsrGetDcSiteCoverageW(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsrGetDcSiteCoverageW *r); -_PUBLIC_ void ndr_print_netr_LogonSamLogonEx(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonSamLogonEx *r); -_PUBLIC_ void ndr_print_netr_DsrEnumerateDomainTrusts(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsrEnumerateDomainTrusts *r); -_PUBLIC_ void ndr_print_netr_DsrDeregisterDNSHostRecords(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsrDeregisterDNSHostRecords *r); -_PUBLIC_ void ndr_print_netr_ServerTrustPasswordsGet(struct ndr_print *ndr, const char *name, int flags, const struct netr_ServerTrustPasswordsGet *r); -_PUBLIC_ void ndr_print_netr_DsRGetForestTrustInformation(struct ndr_print *ndr, const char *name, int flags, const struct netr_DsRGetForestTrustInformation *r); -_PUBLIC_ void ndr_print_netr_GetForestTrustInformation(struct ndr_print *ndr, const char *name, int flags, const struct netr_GetForestTrustInformation *r); -_PUBLIC_ void ndr_print_netr_LogonSamLogonWithFlags(struct ndr_print *ndr, const char *name, int flags, const struct netr_LogonSamLogonWithFlags *r); -_PUBLIC_ void ndr_print_netr_NETRSERVERGETTRUSTINFO(struct ndr_print *ndr, const char *name, int flags, const struct netr_NETRSERVERGETTRUSTINFO *r); - -/* The following definitions come from librpc/gen_ndr/ndr_notify.c */ - -_PUBLIC_ enum ndr_err_code ndr_push_notify_entry(struct ndr_push *ndr, int ndr_flags, const struct notify_entry *r); -_PUBLIC_ enum ndr_err_code ndr_pull_notify_entry(struct ndr_pull *ndr, int ndr_flags, struct notify_entry *r); -_PUBLIC_ void ndr_print_notify_entry(struct ndr_print *ndr, const char *name, const struct notify_entry *r); -_PUBLIC_ void ndr_print_notify_depth(struct ndr_print *ndr, const char *name, const struct notify_depth *r); -_PUBLIC_ enum ndr_err_code ndr_push_notify_array(struct ndr_push *ndr, int ndr_flags, const struct notify_array *r); -_PUBLIC_ enum ndr_err_code ndr_pull_notify_array(struct ndr_pull *ndr, int ndr_flags, struct notify_array *r); -_PUBLIC_ void ndr_print_notify_array(struct ndr_print *ndr, const char *name, const struct notify_array *r); -_PUBLIC_ enum ndr_err_code ndr_push_notify_event(struct ndr_push *ndr, int ndr_flags, const struct notify_event *r); -_PUBLIC_ enum ndr_err_code ndr_pull_notify_event(struct ndr_pull *ndr, int ndr_flags, struct notify_event *r); -_PUBLIC_ void ndr_print_notify_event(struct ndr_print *ndr, const char *name, const struct notify_event *r); - -/* The following definitions come from librpc/gen_ndr/ndr_ntsvcs.c */ - -_PUBLIC_ void ndr_print_PNP_HwProfInfo(struct ndr_print *ndr, const char *name, const struct PNP_HwProfInfo *r); -_PUBLIC_ void ndr_print_PNP_Disconnect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Disconnect *r); -_PUBLIC_ void ndr_print_PNP_Connect(struct ndr_print *ndr, const char *name, int flags, const struct PNP_Connect *r); -_PUBLIC_ void ndr_print_PNP_GetVersion(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersion *r); -_PUBLIC_ void ndr_print_PNP_GetGlobalState(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetGlobalState *r); -_PUBLIC_ void ndr_print_PNP_InitDetection(struct ndr_print *ndr, const char *name, int flags, const struct PNP_InitDetection *r); -_PUBLIC_ void ndr_print_PNP_ReportLogOn(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ReportLogOn *r); -_PUBLIC_ void ndr_print_PNP_ValidateDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ValidateDeviceInstance *r); -_PUBLIC_ void ndr_print_PNP_GetRootDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetRootDeviceInstance *r); -_PUBLIC_ void ndr_print_PNP_GetRelatedDeviceInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetRelatedDeviceInstance *r); -_PUBLIC_ void ndr_print_PNP_EnumerateSubKeys(struct ndr_print *ndr, const char *name, int flags, const struct PNP_EnumerateSubKeys *r); -_PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceList *r); -_PUBLIC_ void ndr_print_PNP_GetDeviceListSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceListSize *r); -_PUBLIC_ void ndr_print_PNP_GetDepth(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDepth *r); -_PUBLIC_ void ndr_print_PNP_GetDeviceRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceRegProp *r); -_PUBLIC_ void ndr_print_PNP_SetDeviceRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetDeviceRegProp *r); -_PUBLIC_ void ndr_print_PNP_GetClassInstance(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassInstance *r); -_PUBLIC_ void ndr_print_PNP_CreateKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_CreateKey *r); -_PUBLIC_ void ndr_print_PNP_DeleteRegistryKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeleteRegistryKey *r); -_PUBLIC_ void ndr_print_PNP_GetClassCount(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassCount *r); -_PUBLIC_ void ndr_print_PNP_GetClassName(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassName *r); -_PUBLIC_ void ndr_print_PNP_DeleteClassKey(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeleteClassKey *r); -_PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceAlias(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceAlias *r); -_PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceList *r); -_PUBLIC_ void ndr_print_PNP_GetInterfaceDeviceListSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetInterfaceDeviceListSize *r); -_PUBLIC_ void ndr_print_PNP_RegisterDeviceClassAssociation(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterDeviceClassAssociation *r); -_PUBLIC_ void ndr_print_PNP_UnregisterDeviceClassAssociation(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UnregisterDeviceClassAssociation *r); -_PUBLIC_ void ndr_print_PNP_GetClassRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetClassRegProp *r); -_PUBLIC_ void ndr_print_PNP_SetClassRegProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetClassRegProp *r); -_PUBLIC_ void ndr_print_PNP_CreateDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_CreateDevInst *r); -_PUBLIC_ void ndr_print_PNP_DeviceInstanceAction(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DeviceInstanceAction *r); -_PUBLIC_ void ndr_print_PNP_GetDeviceStatus(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceStatus *r); -_PUBLIC_ void ndr_print_PNP_SetDeviceProblem(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetDeviceProblem *r); -_PUBLIC_ void ndr_print_PNP_DisableDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DisableDevInst *r); -_PUBLIC_ void ndr_print_PNP_UninstallDevInst(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UninstallDevInst *r); -_PUBLIC_ void ndr_print_PNP_AddID(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddID *r); -_PUBLIC_ void ndr_print_PNP_RegisterDriver(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterDriver *r); -_PUBLIC_ void ndr_print_PNP_QueryRemove(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryRemove *r); -_PUBLIC_ void ndr_print_PNP_RequestDeviceEject(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RequestDeviceEject *r); -_PUBLIC_ void ndr_print_PNP_IsDockStationPresent(struct ndr_print *ndr, const char *name, int flags, const struct PNP_IsDockStationPresent *r); -_PUBLIC_ void ndr_print_PNP_RequestEjectPC(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RequestEjectPC *r); -_PUBLIC_ void ndr_print_PNP_HwProfFlags(struct ndr_print *ndr, const char *name, int flags, const struct PNP_HwProfFlags *r); -_PUBLIC_ void ndr_print_PNP_GetHwProfInfo(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetHwProfInfo *r); -_PUBLIC_ void ndr_print_PNP_AddEmptyLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddEmptyLogConf *r); -_PUBLIC_ void ndr_print_PNP_FreeLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_FreeLogConf *r); -_PUBLIC_ void ndr_print_PNP_GetFirstLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetFirstLogConf *r); -_PUBLIC_ void ndr_print_PNP_GetNextLogConf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetNextLogConf *r); -_PUBLIC_ void ndr_print_PNP_GetLogConfPriority(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetLogConfPriority *r); -_PUBLIC_ void ndr_print_PNP_AddResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_AddResDes *r); -_PUBLIC_ void ndr_print_PNP_FreeResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_FreeResDes *r); -_PUBLIC_ void ndr_print_PNP_GetNextResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetNextResDes *r); -_PUBLIC_ void ndr_print_PNP_GetResDesData(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetResDesData *r); -_PUBLIC_ void ndr_print_PNP_GetResDesDataSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetResDesDataSize *r); -_PUBLIC_ void ndr_print_PNP_ModifyResDes(struct ndr_print *ndr, const char *name, int flags, const struct PNP_ModifyResDes *r); -_PUBLIC_ void ndr_print_PNP_DetectResourceLimit(struct ndr_print *ndr, const char *name, int flags, const struct PNP_DetectResourceLimit *r); -_PUBLIC_ void ndr_print_PNP_QueryResConfList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryResConfList *r); -_PUBLIC_ void ndr_print_PNP_SetHwProf(struct ndr_print *ndr, const char *name, int flags, const struct PNP_SetHwProf *r); -_PUBLIC_ void ndr_print_PNP_QueryArbitratorFreeData(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryArbitratorFreeData *r); -_PUBLIC_ void ndr_print_PNP_QueryArbitratorFreeSize(struct ndr_print *ndr, const char *name, int flags, const struct PNP_QueryArbitratorFreeSize *r); -_PUBLIC_ void ndr_print_PNP_RunDetection(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RunDetection *r); -_PUBLIC_ void ndr_print_PNP_RegisterNotification(struct ndr_print *ndr, const char *name, int flags, const struct PNP_RegisterNotification *r); -_PUBLIC_ void ndr_print_PNP_UnregisterNotification(struct ndr_print *ndr, const char *name, int flags, const struct PNP_UnregisterNotification *r); -_PUBLIC_ void ndr_print_PNP_GetCustomDevProp(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetCustomDevProp *r); -_PUBLIC_ void ndr_print_PNP_GetVersionInternal(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetVersionInternal *r); -_PUBLIC_ void ndr_print_PNP_GetBlockedDriverInfo(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetBlockedDriverInfo *r); -_PUBLIC_ void ndr_print_PNP_GetServerSideDeviceInstallFlags(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetServerSideDeviceInstallFlags *r); - -/* The following definitions come from librpc/gen_ndr/ndr_samr.c */ - -_PUBLIC_ enum ndr_err_code ndr_push_samr_AcctFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_AcctFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_samr_AcctFlags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_ConnectAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_UserAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_DomainAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_GroupAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_AliasAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_SamEntry(struct ndr_print *ndr, const char *name, const struct samr_SamEntry *r); -_PUBLIC_ void ndr_print_samr_SamArray(struct ndr_print *ndr, const char *name, const struct samr_SamArray *r); -_PUBLIC_ void ndr_print_samr_Role(struct ndr_print *ndr, const char *name, enum samr_Role r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_PasswordProperties(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_PasswordProperties(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_samr_PasswordProperties(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_DomInfo1(struct ndr_print *ndr, const char *name, const struct samr_DomInfo1 *r); -_PUBLIC_ void ndr_print_samr_DomInfo2(struct ndr_print *ndr, const char *name, const struct samr_DomInfo2 *r); -_PUBLIC_ void ndr_print_samr_DomInfo3(struct ndr_print *ndr, const char *name, const struct samr_DomInfo3 *r); -_PUBLIC_ void ndr_print_samr_DomInfo4(struct ndr_print *ndr, const char *name, const struct samr_DomInfo4 *r); -_PUBLIC_ void ndr_print_samr_DomInfo5(struct ndr_print *ndr, const char *name, const struct samr_DomInfo5 *r); -_PUBLIC_ void ndr_print_samr_DomInfo6(struct ndr_print *ndr, const char *name, const struct samr_DomInfo6 *r); -_PUBLIC_ void ndr_print_samr_DomInfo7(struct ndr_print *ndr, const char *name, const struct samr_DomInfo7 *r); -_PUBLIC_ void ndr_print_samr_DomInfo8(struct ndr_print *ndr, const char *name, const struct samr_DomInfo8 *r); -_PUBLIC_ void ndr_print_samr_DomInfo9(struct ndr_print *ndr, const char *name, const struct samr_DomInfo9 *r); -_PUBLIC_ void ndr_print_samr_DomInfo11(struct ndr_print *ndr, const char *name, const struct samr_DomInfo11 *r); -_PUBLIC_ void ndr_print_samr_DomInfo12(struct ndr_print *ndr, const char *name, const struct samr_DomInfo12 *r); -_PUBLIC_ void ndr_print_samr_DomInfo13(struct ndr_print *ndr, const char *name, const struct samr_DomInfo13 *r); -_PUBLIC_ void ndr_print_samr_DomainInfo(struct ndr_print *ndr, const char *name, const union samr_DomainInfo *r); -_PUBLIC_ void ndr_print_samr_Ids(struct ndr_print *ndr, const char *name, const struct samr_Ids *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_GroupAttrs(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_GroupAttrs(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_samr_GroupAttrs(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_GroupInfoAll(struct ndr_print *ndr, const char *name, const struct samr_GroupInfoAll *r); -_PUBLIC_ void ndr_print_samr_GroupInfoAttributes(struct ndr_print *ndr, const char *name, const struct samr_GroupInfoAttributes *r); -_PUBLIC_ void ndr_print_samr_GroupInfoEnum(struct ndr_print *ndr, const char *name, enum samr_GroupInfoEnum r); -_PUBLIC_ void ndr_print_samr_GroupInfo(struct ndr_print *ndr, const char *name, const union samr_GroupInfo *r); -_PUBLIC_ void ndr_print_samr_RidTypeArray(struct ndr_print *ndr, const char *name, const struct samr_RidTypeArray *r); -_PUBLIC_ void ndr_print_samr_AliasInfoAll(struct ndr_print *ndr, const char *name, const struct samr_AliasInfoAll *r); -_PUBLIC_ void ndr_print_samr_AliasInfoEnum(struct ndr_print *ndr, const char *name, enum samr_AliasInfoEnum r); -_PUBLIC_ void ndr_print_samr_AliasInfo(struct ndr_print *ndr, const char *name, const union samr_AliasInfo *r); -_PUBLIC_ void ndr_print_samr_UserInfo1(struct ndr_print *ndr, const char *name, const struct samr_UserInfo1 *r); -_PUBLIC_ void ndr_print_samr_UserInfo2(struct ndr_print *ndr, const char *name, const struct samr_UserInfo2 *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_LogonHours(struct ndr_push *ndr, int ndr_flags, const struct samr_LogonHours *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_LogonHours(struct ndr_pull *ndr, int ndr_flags, struct samr_LogonHours *r); -_PUBLIC_ void ndr_print_samr_LogonHours(struct ndr_print *ndr, const char *name, const struct samr_LogonHours *r); -_PUBLIC_ void ndr_print_samr_UserInfo3(struct ndr_print *ndr, const char *name, const struct samr_UserInfo3 *r); -_PUBLIC_ void ndr_print_samr_UserInfo4(struct ndr_print *ndr, const char *name, const struct samr_UserInfo4 *r); -_PUBLIC_ void ndr_print_samr_UserInfo5(struct ndr_print *ndr, const char *name, const struct samr_UserInfo5 *r); -_PUBLIC_ void ndr_print_samr_UserInfo6(struct ndr_print *ndr, const char *name, const struct samr_UserInfo6 *r); -_PUBLIC_ void ndr_print_samr_UserInfo7(struct ndr_print *ndr, const char *name, const struct samr_UserInfo7 *r); -_PUBLIC_ void ndr_print_samr_UserInfo8(struct ndr_print *ndr, const char *name, const struct samr_UserInfo8 *r); -_PUBLIC_ void ndr_print_samr_UserInfo9(struct ndr_print *ndr, const char *name, const struct samr_UserInfo9 *r); -_PUBLIC_ void ndr_print_samr_UserInfo10(struct ndr_print *ndr, const char *name, const struct samr_UserInfo10 *r); -_PUBLIC_ void ndr_print_samr_UserInfo11(struct ndr_print *ndr, const char *name, const struct samr_UserInfo11 *r); -_PUBLIC_ void ndr_print_samr_UserInfo12(struct ndr_print *ndr, const char *name, const struct samr_UserInfo12 *r); -_PUBLIC_ void ndr_print_samr_UserInfo13(struct ndr_print *ndr, const char *name, const struct samr_UserInfo13 *r); -_PUBLIC_ void ndr_print_samr_UserInfo14(struct ndr_print *ndr, const char *name, const struct samr_UserInfo14 *r); -_PUBLIC_ void ndr_print_samr_UserInfo16(struct ndr_print *ndr, const char *name, const struct samr_UserInfo16 *r); -_PUBLIC_ void ndr_print_samr_UserInfo17(struct ndr_print *ndr, const char *name, const struct samr_UserInfo17 *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_Password(struct ndr_push *ndr, int ndr_flags, const struct samr_Password *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_Password(struct ndr_pull *ndr, int ndr_flags, struct samr_Password *r); -_PUBLIC_ void ndr_print_samr_Password(struct ndr_print *ndr, const char *name, const struct samr_Password *r); -_PUBLIC_ void ndr_print_samr_UserInfo18(struct ndr_print *ndr, const char *name, const struct samr_UserInfo18 *r); -_PUBLIC_ void ndr_print_samr_UserInfo20(struct ndr_print *ndr, const char *name, const struct samr_UserInfo20 *r); -_PUBLIC_ void ndr_print_samr_FieldsPresent(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_UserInfo21(struct ndr_print *ndr, const char *name, const struct samr_UserInfo21 *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_CryptPassword(struct ndr_push *ndr, int ndr_flags, const struct samr_CryptPassword *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_CryptPassword(struct ndr_pull *ndr, int ndr_flags, struct samr_CryptPassword *r); -_PUBLIC_ void ndr_print_samr_CryptPassword(struct ndr_print *ndr, const char *name, const struct samr_CryptPassword *r); -_PUBLIC_ void ndr_print_samr_UserInfo23(struct ndr_print *ndr, const char *name, const struct samr_UserInfo23 *r); -_PUBLIC_ void ndr_print_samr_UserInfo24(struct ndr_print *ndr, const char *name, const struct samr_UserInfo24 *r); -_PUBLIC_ void ndr_print_samr_CryptPasswordEx(struct ndr_print *ndr, const char *name, const struct samr_CryptPasswordEx *r); -_PUBLIC_ void ndr_print_samr_UserInfo25(struct ndr_print *ndr, const char *name, const struct samr_UserInfo25 *r); -_PUBLIC_ void ndr_print_samr_UserInfo26(struct ndr_print *ndr, const char *name, const struct samr_UserInfo26 *r); -_PUBLIC_ void ndr_print_samr_UserInfo(struct ndr_print *ndr, const char *name, const union samr_UserInfo *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_RidWithAttribute(struct ndr_push *ndr, int ndr_flags, const struct samr_RidWithAttribute *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_RidWithAttribute(struct ndr_pull *ndr, int ndr_flags, struct samr_RidWithAttribute *r); -_PUBLIC_ void ndr_print_samr_RidWithAttribute(struct ndr_print *ndr, const char *name, const struct samr_RidWithAttribute *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_RidWithAttributeArray(struct ndr_push *ndr, int ndr_flags, const struct samr_RidWithAttributeArray *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_RidWithAttributeArray(struct ndr_pull *ndr, int ndr_flags, struct samr_RidWithAttributeArray *r); -_PUBLIC_ void ndr_print_samr_RidWithAttributeArray(struct ndr_print *ndr, const char *name, const struct samr_RidWithAttributeArray *r); -_PUBLIC_ void ndr_print_samr_DispEntryGeneral(struct ndr_print *ndr, const char *name, const struct samr_DispEntryGeneral *r); -_PUBLIC_ void ndr_print_samr_DispInfoGeneral(struct ndr_print *ndr, const char *name, const struct samr_DispInfoGeneral *r); -_PUBLIC_ void ndr_print_samr_DispEntryFull(struct ndr_print *ndr, const char *name, const struct samr_DispEntryFull *r); -_PUBLIC_ void ndr_print_samr_DispInfoFull(struct ndr_print *ndr, const char *name, const struct samr_DispInfoFull *r); -_PUBLIC_ void ndr_print_samr_DispEntryFullGroup(struct ndr_print *ndr, const char *name, const struct samr_DispEntryFullGroup *r); -_PUBLIC_ void ndr_print_samr_DispInfoFullGroups(struct ndr_print *ndr, const char *name, const struct samr_DispInfoFullGroups *r); -_PUBLIC_ void ndr_print_samr_DispEntryAscii(struct ndr_print *ndr, const char *name, const struct samr_DispEntryAscii *r); -_PUBLIC_ void ndr_print_samr_DispInfoAscii(struct ndr_print *ndr, const char *name, const struct samr_DispInfoAscii *r); -_PUBLIC_ void ndr_print_samr_DispInfo(struct ndr_print *ndr, const char *name, const union samr_DispInfo *r); -_PUBLIC_ void ndr_print_samr_PwInfo(struct ndr_print *ndr, const char *name, const struct samr_PwInfo *r); -_PUBLIC_ void ndr_print_samr_ConnectVersion(struct ndr_print *ndr, const char *name, enum samr_ConnectVersion r); -_PUBLIC_ void ndr_print_samr_ChangeReject(struct ndr_print *ndr, const char *name, const struct samr_ChangeReject *r); -_PUBLIC_ void ndr_print_samr_ConnectInfo1(struct ndr_print *ndr, const char *name, const struct samr_ConnectInfo1 *r); -_PUBLIC_ void ndr_print_samr_ConnectInfo(struct ndr_print *ndr, const char *name, const union samr_ConnectInfo *r); -_PUBLIC_ void ndr_print_samr_ValidateFieldsPresent(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordLevel(struct ndr_print *ndr, const char *name, enum samr_ValidatePasswordLevel r); -_PUBLIC_ void ndr_print_samr_ValidationStatus(struct ndr_print *ndr, const char *name, enum samr_ValidationStatus r); -_PUBLIC_ void ndr_print_samr_ValidationBlob(struct ndr_print *ndr, const char *name, const struct samr_ValidationBlob *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordInfo(struct ndr_print *ndr, const char *name, const struct samr_ValidatePasswordInfo *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordRepCtr(struct ndr_print *ndr, const char *name, const struct samr_ValidatePasswordRepCtr *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordRep(struct ndr_print *ndr, const char *name, const union samr_ValidatePasswordRep *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordReq3(struct ndr_print *ndr, const char *name, const struct samr_ValidatePasswordReq3 *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordReq2(struct ndr_print *ndr, const char *name, const struct samr_ValidatePasswordReq2 *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordReq1(struct ndr_print *ndr, const char *name, const struct samr_ValidatePasswordReq1 *r); -_PUBLIC_ void ndr_print_samr_ValidatePasswordReq(struct ndr_print *ndr, const char *name, const union samr_ValidatePasswordReq *r); -_PUBLIC_ void ndr_print_samr_Connect(struct ndr_print *ndr, const char *name, int flags, const struct samr_Connect *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_Close(struct ndr_push *ndr, int flags, const struct samr_Close *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_Close(struct ndr_pull *ndr, int flags, struct samr_Close *r); -_PUBLIC_ void ndr_print_samr_Close(struct ndr_print *ndr, const char *name, int flags, const struct samr_Close *r); -_PUBLIC_ void ndr_print_samr_SetSecurity(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetSecurity *r); -_PUBLIC_ void ndr_print_samr_QuerySecurity(struct ndr_print *ndr, const char *name, int flags, const struct samr_QuerySecurity *r); -_PUBLIC_ void ndr_print_samr_Shutdown(struct ndr_print *ndr, const char *name, int flags, const struct samr_Shutdown *r); -_PUBLIC_ void ndr_print_samr_LookupDomain(struct ndr_print *ndr, const char *name, int flags, const struct samr_LookupDomain *r); -_PUBLIC_ void ndr_print_samr_EnumDomains(struct ndr_print *ndr, const char *name, int flags, const struct samr_EnumDomains *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_OpenDomain(struct ndr_push *ndr, int flags, const struct samr_OpenDomain *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_OpenDomain(struct ndr_pull *ndr, int flags, struct samr_OpenDomain *r); -_PUBLIC_ void ndr_print_samr_OpenDomain(struct ndr_print *ndr, const char *name, int flags, const struct samr_OpenDomain *r); -_PUBLIC_ void ndr_print_samr_QueryDomainInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryDomainInfo *r); -_PUBLIC_ void ndr_print_samr_SetDomainInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetDomainInfo *r); -_PUBLIC_ void ndr_print_samr_CreateDomainGroup(struct ndr_print *ndr, const char *name, int flags, const struct samr_CreateDomainGroup *r); -_PUBLIC_ void ndr_print_samr_EnumDomainGroups(struct ndr_print *ndr, const char *name, int flags, const struct samr_EnumDomainGroups *r); -_PUBLIC_ void ndr_print_samr_CreateUser(struct ndr_print *ndr, const char *name, int flags, const struct samr_CreateUser *r); -_PUBLIC_ void ndr_print_samr_EnumDomainUsers(struct ndr_print *ndr, const char *name, int flags, const struct samr_EnumDomainUsers *r); -_PUBLIC_ void ndr_print_samr_CreateDomAlias(struct ndr_print *ndr, const char *name, int flags, const struct samr_CreateDomAlias *r); -_PUBLIC_ void ndr_print_samr_EnumDomainAliases(struct ndr_print *ndr, const char *name, int flags, const struct samr_EnumDomainAliases *r); -_PUBLIC_ void ndr_print_samr_GetAliasMembership(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetAliasMembership *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_LookupNames(struct ndr_push *ndr, int flags, const struct samr_LookupNames *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_LookupNames(struct ndr_pull *ndr, int flags, struct samr_LookupNames *r); -_PUBLIC_ void ndr_print_samr_LookupNames(struct ndr_print *ndr, const char *name, int flags, const struct samr_LookupNames *r); -_PUBLIC_ void ndr_print_samr_LookupRids(struct ndr_print *ndr, const char *name, int flags, const struct samr_LookupRids *r); -_PUBLIC_ void ndr_print_samr_OpenGroup(struct ndr_print *ndr, const char *name, int flags, const struct samr_OpenGroup *r); -_PUBLIC_ void ndr_print_samr_QueryGroupInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryGroupInfo *r); -_PUBLIC_ void ndr_print_samr_SetGroupInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetGroupInfo *r); -_PUBLIC_ void ndr_print_samr_AddGroupMember(struct ndr_print *ndr, const char *name, int flags, const struct samr_AddGroupMember *r); -_PUBLIC_ void ndr_print_samr_DeleteDomainGroup(struct ndr_print *ndr, const char *name, int flags, const struct samr_DeleteDomainGroup *r); -_PUBLIC_ void ndr_print_samr_DeleteGroupMember(struct ndr_print *ndr, const char *name, int flags, const struct samr_DeleteGroupMember *r); -_PUBLIC_ void ndr_print_samr_QueryGroupMember(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryGroupMember *r); -_PUBLIC_ void ndr_print_samr_SetMemberAttributesOfGroup(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetMemberAttributesOfGroup *r); -_PUBLIC_ void ndr_print_samr_OpenAlias(struct ndr_print *ndr, const char *name, int flags, const struct samr_OpenAlias *r); -_PUBLIC_ void ndr_print_samr_QueryAliasInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryAliasInfo *r); -_PUBLIC_ void ndr_print_samr_SetAliasInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetAliasInfo *r); -_PUBLIC_ void ndr_print_samr_DeleteDomAlias(struct ndr_print *ndr, const char *name, int flags, const struct samr_DeleteDomAlias *r); -_PUBLIC_ void ndr_print_samr_AddAliasMember(struct ndr_print *ndr, const char *name, int flags, const struct samr_AddAliasMember *r); -_PUBLIC_ void ndr_print_samr_DeleteAliasMember(struct ndr_print *ndr, const char *name, int flags, const struct samr_DeleteAliasMember *r); -_PUBLIC_ void ndr_print_samr_GetMembersInAlias(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetMembersInAlias *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_OpenUser(struct ndr_push *ndr, int flags, const struct samr_OpenUser *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_OpenUser(struct ndr_pull *ndr, int flags, struct samr_OpenUser *r); -_PUBLIC_ void ndr_print_samr_OpenUser(struct ndr_print *ndr, const char *name, int flags, const struct samr_OpenUser *r); -_PUBLIC_ void ndr_print_samr_DeleteUser(struct ndr_print *ndr, const char *name, int flags, const struct samr_DeleteUser *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_QueryUserInfo(struct ndr_push *ndr, int flags, const struct samr_QueryUserInfo *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_QueryUserInfo(struct ndr_pull *ndr, int flags, struct samr_QueryUserInfo *r); -_PUBLIC_ void ndr_print_samr_QueryUserInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryUserInfo *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_SetUserInfo(struct ndr_push *ndr, int flags, const struct samr_SetUserInfo *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_SetUserInfo(struct ndr_pull *ndr, int flags, struct samr_SetUserInfo *r); -_PUBLIC_ void ndr_print_samr_SetUserInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetUserInfo *r); -_PUBLIC_ void ndr_print_samr_ChangePasswordUser(struct ndr_print *ndr, const char *name, int flags, const struct samr_ChangePasswordUser *r); -_PUBLIC_ void ndr_print_samr_GetGroupsForUser(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetGroupsForUser *r); -_PUBLIC_ void ndr_print_samr_QueryDisplayInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryDisplayInfo *r); -_PUBLIC_ void ndr_print_samr_GetDisplayEnumerationIndex(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetDisplayEnumerationIndex *r); -_PUBLIC_ void ndr_print_samr_TestPrivateFunctionsDomain(struct ndr_print *ndr, const char *name, int flags, const struct samr_TestPrivateFunctionsDomain *r); -_PUBLIC_ void ndr_print_samr_TestPrivateFunctionsUser(struct ndr_print *ndr, const char *name, int flags, const struct samr_TestPrivateFunctionsUser *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_GetUserPwInfo(struct ndr_push *ndr, int flags, const struct samr_GetUserPwInfo *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_GetUserPwInfo(struct ndr_pull *ndr, int flags, struct samr_GetUserPwInfo *r); -_PUBLIC_ void ndr_print_samr_GetUserPwInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetUserPwInfo *r); -_PUBLIC_ void ndr_print_samr_RemoveMemberFromForeignDomain(struct ndr_print *ndr, const char *name, int flags, const struct samr_RemoveMemberFromForeignDomain *r); -_PUBLIC_ void ndr_print_samr_QueryDomainInfo2(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryDomainInfo2 *r); -_PUBLIC_ void ndr_print_samr_QueryUserInfo2(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryUserInfo2 *r); -_PUBLIC_ void ndr_print_samr_QueryDisplayInfo2(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryDisplayInfo2 *r); -_PUBLIC_ void ndr_print_samr_GetDisplayEnumerationIndex2(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetDisplayEnumerationIndex2 *r); -_PUBLIC_ void ndr_print_samr_CreateUser2(struct ndr_print *ndr, const char *name, int flags, const struct samr_CreateUser2 *r); -_PUBLIC_ void ndr_print_samr_QueryDisplayInfo3(struct ndr_print *ndr, const char *name, int flags, const struct samr_QueryDisplayInfo3 *r); -_PUBLIC_ void ndr_print_samr_AddMultipleMembersToAlias(struct ndr_print *ndr, const char *name, int flags, const struct samr_AddMultipleMembersToAlias *r); -_PUBLIC_ void ndr_print_samr_RemoveMultipleMembersFromAlias(struct ndr_print *ndr, const char *name, int flags, const struct samr_RemoveMultipleMembersFromAlias *r); -_PUBLIC_ void ndr_print_samr_OemChangePasswordUser2(struct ndr_print *ndr, const char *name, int flags, const struct samr_OemChangePasswordUser2 *r); -_PUBLIC_ void ndr_print_samr_ChangePasswordUser2(struct ndr_print *ndr, const char *name, int flags, const struct samr_ChangePasswordUser2 *r); -_PUBLIC_ void ndr_print_samr_GetDomPwInfo(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetDomPwInfo *r); -_PUBLIC_ void ndr_print_samr_Connect2(struct ndr_print *ndr, const char *name, int flags, const struct samr_Connect2 *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_SetUserInfo2(struct ndr_push *ndr, int flags, const struct samr_SetUserInfo2 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_SetUserInfo2(struct ndr_pull *ndr, int flags, struct samr_SetUserInfo2 *r); -_PUBLIC_ void ndr_print_samr_SetUserInfo2(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetUserInfo2 *r); -_PUBLIC_ void ndr_print_samr_SetBootKeyInformation(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetBootKeyInformation *r); -_PUBLIC_ void ndr_print_samr_GetBootKeyInformation(struct ndr_print *ndr, const char *name, int flags, const struct samr_GetBootKeyInformation *r); -_PUBLIC_ void ndr_print_samr_Connect3(struct ndr_print *ndr, const char *name, int flags, const struct samr_Connect3 *r); -_PUBLIC_ void ndr_print_samr_Connect4(struct ndr_print *ndr, const char *name, int flags, const struct samr_Connect4 *r); -_PUBLIC_ void ndr_print_samr_ChangePasswordUser3(struct ndr_print *ndr, const char *name, int flags, const struct samr_ChangePasswordUser3 *r); -_PUBLIC_ enum ndr_err_code ndr_push_samr_Connect5(struct ndr_push *ndr, int flags, const struct samr_Connect5 *r); -_PUBLIC_ enum ndr_err_code ndr_pull_samr_Connect5(struct ndr_pull *ndr, int flags, struct samr_Connect5 *r); -_PUBLIC_ void ndr_print_samr_Connect5(struct ndr_print *ndr, const char *name, int flags, const struct samr_Connect5 *r); -_PUBLIC_ void ndr_print_samr_RidToSid(struct ndr_print *ndr, const char *name, int flags, const struct samr_RidToSid *r); -_PUBLIC_ void ndr_print_samr_SetDsrmPassword(struct ndr_print *ndr, const char *name, int flags, const struct samr_SetDsrmPassword *r); -_PUBLIC_ void ndr_print_samr_ValidatePassword(struct ndr_print *ndr, const char *name, int flags, const struct samr_ValidatePassword *r); - -/* The following definitions come from librpc/gen_ndr/ndr_security.c */ - -_PUBLIC_ void ndr_print_security_ace_flags(struct ndr_print *ndr, const char *name, uint8_t r); -_PUBLIC_ void ndr_print_security_ace_type(struct ndr_print *ndr, const char *name, enum security_ace_type r); -_PUBLIC_ void ndr_print_security_ace_object_flags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_security_ace_object_type(struct ndr_print *ndr, const char *name, const union security_ace_object_type *r); -_PUBLIC_ void ndr_print_security_ace_object_inherited_type(struct ndr_print *ndr, const char *name, const union security_ace_object_inherited_type *r); -_PUBLIC_ void ndr_print_security_ace_object(struct ndr_print *ndr, const char *name, const struct security_ace_object *r); -_PUBLIC_ void ndr_print_security_ace_object_ctr(struct ndr_print *ndr, const char *name, const union security_ace_object_ctr *r); -_PUBLIC_ enum ndr_err_code ndr_push_security_ace(struct ndr_push *ndr, int ndr_flags, const struct security_ace *r); -_PUBLIC_ enum ndr_err_code ndr_pull_security_ace(struct ndr_pull *ndr, int ndr_flags, struct security_ace *r); -_PUBLIC_ void ndr_print_security_ace(struct ndr_print *ndr, const char *name, const struct security_ace *r); -_PUBLIC_ void ndr_print_security_acl_revision(struct ndr_print *ndr, const char *name, enum security_acl_revision r); -_PUBLIC_ enum ndr_err_code ndr_push_security_acl(struct ndr_push *ndr, int ndr_flags, const struct security_acl *r); -_PUBLIC_ enum ndr_err_code ndr_pull_security_acl(struct ndr_pull *ndr, int ndr_flags, struct security_acl *r); -_PUBLIC_ void ndr_print_security_acl(struct ndr_print *ndr, const char *name, const struct security_acl *r); -_PUBLIC_ void ndr_print_security_descriptor_revision(struct ndr_print *ndr, const char *name, enum security_descriptor_revision r); -_PUBLIC_ void ndr_print_security_descriptor_type(struct ndr_print *ndr, const char *name, uint16_t r); -_PUBLIC_ enum ndr_err_code ndr_push_security_descriptor(struct ndr_push *ndr, int ndr_flags, const struct security_descriptor *r); -_PUBLIC_ enum ndr_err_code ndr_pull_security_descriptor(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor *r); -_PUBLIC_ void ndr_print_security_descriptor(struct ndr_print *ndr, const char *name, const struct security_descriptor *r); -_PUBLIC_ enum ndr_err_code ndr_push_sec_desc_buf(struct ndr_push *ndr, int ndr_flags, const struct sec_desc_buf *r); -_PUBLIC_ enum ndr_err_code ndr_pull_sec_desc_buf(struct ndr_pull *ndr, int ndr_flags, struct sec_desc_buf *r); -_PUBLIC_ void ndr_print_sec_desc_buf(struct ndr_print *ndr, const char *name, const struct sec_desc_buf *r); -_PUBLIC_ enum ndr_err_code ndr_push_security_token(struct ndr_push *ndr, int ndr_flags, const struct security_token *r); -_PUBLIC_ enum ndr_err_code ndr_pull_security_token(struct ndr_pull *ndr, int ndr_flags, struct security_token *r); -_PUBLIC_ void ndr_print_security_token(struct ndr_print *ndr, const char *name, const struct security_token *r); -_PUBLIC_ enum ndr_err_code ndr_push_security_secinfo(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_security_secinfo(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_security_secinfo(struct ndr_print *ndr, const char *name, uint32_t r); - -/* The following definitions come from librpc/gen_ndr/ndr_srvsvc.c */ - -_PUBLIC_ void ndr_print_srvsvc_NetCharDevInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevCtr0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevCtr0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevInfo1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevInfo1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevCtr1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevCtr1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevInfo(struct ndr_print *ndr, const char *name, const union srvsvc_NetCharDevInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetCharDevCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevQInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQCtr0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevQCtr0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQInfo1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevQInfo1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQCtr1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetCharDevQCtr1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQInfo(struct ndr_print *ndr, const char *name, const union srvsvc_NetCharDevQInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetCharDevQCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetConnInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnCtr0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetConnCtr0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnInfo1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetConnInfo1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnCtr1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetConnCtr1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetConnCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnInfoCtr(struct ndr_print *ndr, const char *name, const struct srvsvc_NetConnInfoCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileInfo2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetFileInfo2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileCtr2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetFileCtr2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileInfo3(struct ndr_print *ndr, const char *name, const struct srvsvc_NetFileInfo3 *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileCtr3(struct ndr_print *ndr, const char *name, const struct srvsvc_NetFileCtr3 *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileInfo(struct ndr_print *ndr, const char *name, const union srvsvc_NetFileInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetFileCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileInfoCtr(struct ndr_print *ndr, const char *name, const struct srvsvc_NetFileInfoCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessCtr0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessCtr0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessInfo1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessInfo1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessCtr1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessCtr1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessInfo2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessInfo2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessCtr2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessCtr2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessInfo10(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessInfo10 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessCtr10(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessCtr10 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessInfo502(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessInfo502 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessCtr502(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessCtr502 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetSessCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessInfoCtr(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSessInfoCtr *r); -_PUBLIC_ void ndr_print_srvsvc_ShareType(struct ndr_print *ndr, const char *name, enum srvsvc_ShareType r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo501(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo501 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr501(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr501 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo502(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo502 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr502(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr502 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo1004(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo1004 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr1004(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr1004 *r); -_PUBLIC_ void ndr_print_NetShareInfo1005Flags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo1005(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo1005 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr1005(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr1005 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo1006(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo1006 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr1006(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr1006 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo1007(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfo1007 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr1007(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr1007 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr1501(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareCtr1501 *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfo(struct ndr_print *ndr, const char *name, const union srvsvc_NetShareInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetShareCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareInfoCtr(struct ndr_print *ndr, const char *name, const struct srvsvc_NetShareInfoCtr *r); -_PUBLIC_ enum ndr_err_code ndr_push_srvsvc_PlatformId(struct ndr_push *ndr, int ndr_flags, enum srvsvc_PlatformId r); -_PUBLIC_ enum ndr_err_code ndr_pull_srvsvc_PlatformId(struct ndr_pull *ndr, int ndr_flags, enum srvsvc_PlatformId *r); -_PUBLIC_ void ndr_print_srvsvc_PlatformId(struct ndr_print *ndr, const char *name, enum srvsvc_PlatformId r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo100(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo100 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo101(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo101 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo102(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo102 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo402(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo402 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo403(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo403 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo502(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo502 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo503(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo503 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo599(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo599 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1005(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1005 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1010(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1010 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1016(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1016 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1017(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1017 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1018(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1018 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1107(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1107 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1501(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1501 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1502(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1502 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1503(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1503 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1506(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1506 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1509(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1509 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1510(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1510 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1511(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1511 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1512(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1512 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1513(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1513 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1514(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1514 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1515(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1515 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1516(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1516 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1518(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1518 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1520(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1520 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1521(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1521 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1522(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1522 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1523(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1523 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1524(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1524 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1525(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1525 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1528(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1528 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1529(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1529 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1530(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1530 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1533(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1533 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1534(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1534 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1535(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1535 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1536(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1536 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1537(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1537 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1538(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1538 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1539(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1539 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1540(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1540 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1541(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1541 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1542(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1542 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1543(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1543 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1544(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1544 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1545(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1545 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1546(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1546 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1547(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1547 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1548(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1548 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1549(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1549 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1550(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1550 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1552(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1552 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1553(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1553 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1554(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1554 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1555(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1555 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo1556(struct ndr_print *ndr, const char *name, const struct srvsvc_NetSrvInfo1556 *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvInfo(struct ndr_print *ndr, const char *name, const union srvsvc_NetSrvInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetDiskInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetDiskInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetDiskInfo(struct ndr_print *ndr, const char *name, const struct srvsvc_NetDiskInfo *r); -_PUBLIC_ void ndr_print_srvsvc_Statistics(struct ndr_print *ndr, const char *name, const struct srvsvc_Statistics *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportInfo0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportInfo0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportCtr0(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportCtr0 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportInfo1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportInfo1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportCtr1(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportCtr1 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportInfo2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportInfo2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportCtr2(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportCtr2 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportInfo3(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportInfo3 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportCtr3(struct ndr_print *ndr, const char *name, const struct srvsvc_NetTransportCtr3 *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportCtr(struct ndr_print *ndr, const char *name, const union srvsvc_NetTransportCtr *r); -_PUBLIC_ void ndr_print_srvsvc_NetRemoteTODInfo(struct ndr_print *ndr, const char *name, const struct srvsvc_NetRemoteTODInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportInfo(struct ndr_print *ndr, const char *name, const union srvsvc_NetTransportInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevGetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevControl(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevControl *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevQEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevQGetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQSetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevQSetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQPurge(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevQPurge *r); -_PUBLIC_ void ndr_print_srvsvc_NetCharDevQPurgeSelf(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetCharDevQPurgeSelf *r); -_PUBLIC_ void ndr_print_srvsvc_NetConnEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetConnEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetFileEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetFileGetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetFileClose(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetFileClose *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetSessEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetSessDel(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetSessDel *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareAdd(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareAdd *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareEnumAll(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareEnumAll *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareGetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareSetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareSetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareDel(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareDel *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareDelSticky(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareDelSticky *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareCheck(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareCheck *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetSrvGetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetSrvSetInfo(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetSrvSetInfo *r); -_PUBLIC_ void ndr_print_srvsvc_NetDiskEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetDiskEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetServerStatisticsGet(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetServerStatisticsGet *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportAdd(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetTransportAdd *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetTransportEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetTransportDel(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetTransportDel *r); -_PUBLIC_ void ndr_print_srvsvc_NetRemoteTOD(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetRemoteTOD *r); -_PUBLIC_ void ndr_print_srvsvc_NetSetServiceBits(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetSetServiceBits *r); -_PUBLIC_ void ndr_print_srvsvc_NetPathType(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetPathType *r); -_PUBLIC_ void ndr_print_srvsvc_NetPathCanonicalize(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetPathCanonicalize *r); -_PUBLIC_ void ndr_print_srvsvc_NetPathCompare(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetPathCompare *r); -_PUBLIC_ void ndr_print_srvsvc_NetNameValidate(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetNameValidate *r); -_PUBLIC_ void ndr_print_srvsvc_NETRPRNAMECANONICALIZE(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRPRNAMECANONICALIZE *r); -_PUBLIC_ void ndr_print_srvsvc_NetPRNameCompare(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetPRNameCompare *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareEnum(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareEnum *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareDelStart(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareDelStart *r); -_PUBLIC_ void ndr_print_srvsvc_NetShareDelCommit(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetShareDelCommit *r); -_PUBLIC_ void ndr_print_srvsvc_NetGetFileSecurity(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetGetFileSecurity *r); -_PUBLIC_ void ndr_print_srvsvc_NetSetFileSecurity(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetSetFileSecurity *r); -_PUBLIC_ void ndr_print_srvsvc_NetServerTransportAddEx(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetServerTransportAddEx *r); -_PUBLIC_ void ndr_print_srvsvc_NetServerSetServiceBitsEx(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NetServerSetServiceBitsEx *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSGETVERSION(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSGETVERSION *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSCREATELOCALPARTITION(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSCREATELOCALPARTITION *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSDELETELOCALPARTITION(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSDELETELOCALPARTITION *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSSETLOCALVOLUMESTATE(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSSETSERVERINFO(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSSETSERVERINFO *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSCREATEEXITPOINT(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSCREATEEXITPOINT *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSDELETEEXITPOINT(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSDELETEEXITPOINT *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSMODIFYPREFIX(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSMODIFYPREFIX *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSFIXLOCALVOLUME(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSFIXLOCALVOLUME *r); -_PUBLIC_ void ndr_print_srvsvc_NETRDFSMANAGERREPORTSITEINFO(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r); -_PUBLIC_ void ndr_print_srvsvc_NETRSERVERTRANSPORTDELEX(struct ndr_print *ndr, const char *name, int flags, const struct srvsvc_NETRSERVERTRANSPORTDELEX *r); - -/* The following definitions come from librpc/gen_ndr/ndr_svcctl.c */ - -_PUBLIC_ void ndr_print_SERVICE_LOCK_STATUS(struct ndr_print *ndr, const char *name, const struct SERVICE_LOCK_STATUS *r); -_PUBLIC_ void ndr_print_SERVICE_STATUS(struct ndr_print *ndr, const char *name, const struct SERVICE_STATUS *r); -_PUBLIC_ void ndr_print_ENUM_SERVICE_STATUS(struct ndr_print *ndr, const char *name, const struct ENUM_SERVICE_STATUS *r); -_PUBLIC_ enum ndr_err_code ndr_push_svcctl_ServerType(struct ndr_push *ndr, int ndr_flags, uint32_t r); -_PUBLIC_ enum ndr_err_code ndr_pull_svcctl_ServerType(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); -_PUBLIC_ void ndr_print_svcctl_ServerType(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_svcctl_MgrAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_svcctl_ServiceAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_svcctl_CloseServiceHandle(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_CloseServiceHandle *r); -_PUBLIC_ void ndr_print_svcctl_ControlService(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_ControlService *r); -_PUBLIC_ void ndr_print_svcctl_DeleteService(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_DeleteService *r); -_PUBLIC_ void ndr_print_svcctl_LockServiceDatabase(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_LockServiceDatabase *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceObjectSecurity(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceObjectSecurity *r); -_PUBLIC_ void ndr_print_svcctl_SetServiceObjectSecurity(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_SetServiceObjectSecurity *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceStatus(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceStatus *r); -_PUBLIC_ void ndr_print_svcctl_SetServiceStatus(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_SetServiceStatus *r); -_PUBLIC_ void ndr_print_svcctl_UnlockServiceDatabase(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_UnlockServiceDatabase *r); -_PUBLIC_ void ndr_print_svcctl_NotifyBootConfigStatus(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_NotifyBootConfigStatus *r); -_PUBLIC_ void ndr_print_svcctl_SCSetServiceBitsW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_SCSetServiceBitsW *r); -_PUBLIC_ void ndr_print_svcctl_ChangeServiceConfigW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_ChangeServiceConfigW *r); -_PUBLIC_ void ndr_print_svcctl_CreateServiceW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_CreateServiceW *r); -_PUBLIC_ void ndr_print_svcctl_EnumDependentServicesW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_EnumDependentServicesW *r); -_PUBLIC_ void ndr_print_svcctl_EnumServicesStatusW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_EnumServicesStatusW *r); -_PUBLIC_ void ndr_print_svcctl_OpenSCManagerW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_OpenSCManagerW *r); -_PUBLIC_ void ndr_print_svcctl_OpenServiceW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_OpenServiceW *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceConfigW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceConfigW *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceLockStatusW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceLockStatusW *r); -_PUBLIC_ void ndr_print_svcctl_StartServiceW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_StartServiceW *r); -_PUBLIC_ void ndr_print_svcctl_GetServiceDisplayNameW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_GetServiceDisplayNameW *r); -_PUBLIC_ void ndr_print_svcctl_GetServiceKeyNameW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_GetServiceKeyNameW *r); -_PUBLIC_ void ndr_print_svcctl_SCSetServiceBitsA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_SCSetServiceBitsA *r); -_PUBLIC_ void ndr_print_svcctl_ChangeServiceConfigA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_ChangeServiceConfigA *r); -_PUBLIC_ void ndr_print_svcctl_CreateServiceA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_CreateServiceA *r); -_PUBLIC_ void ndr_print_svcctl_EnumDependentServicesA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_EnumDependentServicesA *r); -_PUBLIC_ void ndr_print_svcctl_EnumServicesStatusA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_EnumServicesStatusA *r); -_PUBLIC_ void ndr_print_svcctl_OpenSCManagerA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_OpenSCManagerA *r); -_PUBLIC_ void ndr_print_svcctl_OpenServiceA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_OpenServiceA *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceConfigA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceConfigA *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceLockStatusA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceLockStatusA *r); -_PUBLIC_ void ndr_print_svcctl_StartServiceA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_StartServiceA *r); -_PUBLIC_ void ndr_print_svcctl_GetServiceDisplayNameA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_GetServiceDisplayNameA *r); -_PUBLIC_ void ndr_print_svcctl_GetServiceKeyNameA(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_GetServiceKeyNameA *r); -_PUBLIC_ void ndr_print_svcctl_GetCurrentGroupeStateW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_GetCurrentGroupeStateW *r); -_PUBLIC_ void ndr_print_svcctl_EnumServiceGroupW(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_EnumServiceGroupW *r); -_PUBLIC_ void ndr_print_svcctl_ChangeServiceConfig2A(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_ChangeServiceConfig2A *r); -_PUBLIC_ void ndr_print_svcctl_ChangeServiceConfig2W(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_ChangeServiceConfig2W *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceConfig2A(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceConfig2A *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceConfig2W(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceConfig2W *r); -_PUBLIC_ void ndr_print_svcctl_QueryServiceStatusEx(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_QueryServiceStatusEx *r); -_PUBLIC_ void ndr_print_EnumServicesStatusExA(struct ndr_print *ndr, const char *name, int flags, const struct EnumServicesStatusExA *r); -_PUBLIC_ void ndr_print_EnumServicesStatusExW(struct ndr_print *ndr, const char *name, int flags, const struct EnumServicesStatusExW *r); -_PUBLIC_ void ndr_print_svcctl_SCSendTSMessage(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_SCSendTSMessage *r); - -/* The following definitions come from librpc/gen_ndr/ndr_winreg.c */ - -_PUBLIC_ void ndr_print_winreg_AccessMask(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_winreg_Type(struct ndr_print *ndr, const char *name, enum winreg_Type r); -_PUBLIC_ enum ndr_err_code ndr_push_winreg_String(struct ndr_push *ndr, int ndr_flags, const struct winreg_String *r); -_PUBLIC_ enum ndr_err_code ndr_pull_winreg_String(struct ndr_pull *ndr, int ndr_flags, struct winreg_String *r); -_PUBLIC_ void ndr_print_winreg_String(struct ndr_print *ndr, const char *name, const struct winreg_String *r); -_PUBLIC_ void ndr_print_KeySecurityData(struct ndr_print *ndr, const char *name, const struct KeySecurityData *r); -_PUBLIC_ void ndr_print_winreg_SecBuf(struct ndr_print *ndr, const char *name, const struct winreg_SecBuf *r); -_PUBLIC_ void ndr_print_winreg_CreateAction(struct ndr_print *ndr, const char *name, enum winreg_CreateAction r); -_PUBLIC_ void ndr_print_winreg_StringBuf(struct ndr_print *ndr, const char *name, const struct winreg_StringBuf *r); -_PUBLIC_ void ndr_print_winreg_ValNameBuf(struct ndr_print *ndr, const char *name, const struct winreg_ValNameBuf *r); -_PUBLIC_ void ndr_print_KeySecurityAttribute(struct ndr_print *ndr, const char *name, const struct KeySecurityAttribute *r); -_PUBLIC_ void ndr_print_QueryMultipleValue(struct ndr_print *ndr, const char *name, const struct QueryMultipleValue *r); -_PUBLIC_ void ndr_print_winreg_OpenHKCR(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKCR *r); -_PUBLIC_ void ndr_print_winreg_OpenHKCU(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKCU *r); -_PUBLIC_ void ndr_print_winreg_OpenHKLM(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKLM *r); -_PUBLIC_ void ndr_print_winreg_OpenHKPD(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKPD *r); -_PUBLIC_ void ndr_print_winreg_OpenHKU(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKU *r); -_PUBLIC_ void ndr_print_winreg_CloseKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_CloseKey *r); -_PUBLIC_ void ndr_print_winreg_CreateKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_CreateKey *r); -_PUBLIC_ void ndr_print_winreg_DeleteKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_DeleteKey *r); -_PUBLIC_ void ndr_print_winreg_DeleteValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_DeleteValue *r); -_PUBLIC_ void ndr_print_winreg_EnumKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_EnumKey *r); -_PUBLIC_ void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_EnumValue *r); -_PUBLIC_ void ndr_print_winreg_FlushKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_FlushKey *r); -_PUBLIC_ void ndr_print_winreg_GetKeySecurity(struct ndr_print *ndr, const char *name, int flags, const struct winreg_GetKeySecurity *r); -_PUBLIC_ void ndr_print_winreg_LoadKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_LoadKey *r); -_PUBLIC_ void ndr_print_winreg_NotifyChangeKeyValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_NotifyChangeKeyValue *r); -_PUBLIC_ void ndr_print_winreg_OpenKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenKey *r); -_PUBLIC_ void ndr_print_winreg_QueryInfoKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryInfoKey *r); -_PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryValue *r); -_PUBLIC_ void ndr_print_winreg_ReplaceKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_ReplaceKey *r); -_PUBLIC_ void ndr_print_winreg_RestoreKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_RestoreKey *r); -_PUBLIC_ void ndr_print_winreg_SaveKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_SaveKey *r); -_PUBLIC_ void ndr_print_winreg_SetKeySecurity(struct ndr_print *ndr, const char *name, int flags, const struct winreg_SetKeySecurity *r); -_PUBLIC_ void ndr_print_winreg_SetValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_SetValue *r); -_PUBLIC_ void ndr_print_winreg_UnLoadKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_UnLoadKey *r); -_PUBLIC_ void ndr_print_winreg_InitiateSystemShutdown(struct ndr_print *ndr, const char *name, int flags, const struct winreg_InitiateSystemShutdown *r); -_PUBLIC_ void ndr_print_winreg_AbortSystemShutdown(struct ndr_print *ndr, const char *name, int flags, const struct winreg_AbortSystemShutdown *r); -_PUBLIC_ void ndr_print_winreg_GetVersion(struct ndr_print *ndr, const char *name, int flags, const struct winreg_GetVersion *r); -_PUBLIC_ void ndr_print_winreg_OpenHKCC(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKCC *r); -_PUBLIC_ void ndr_print_winreg_OpenHKDD(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKDD *r); -_PUBLIC_ void ndr_print_winreg_QueryMultipleValues(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryMultipleValues *r); -_PUBLIC_ void ndr_print_winreg_InitiateSystemShutdownEx(struct ndr_print *ndr, const char *name, int flags, const struct winreg_InitiateSystemShutdownEx *r); -_PUBLIC_ void ndr_print_winreg_SaveKeyEx(struct ndr_print *ndr, const char *name, int flags, const struct winreg_SaveKeyEx *r); -_PUBLIC_ void ndr_print_winreg_OpenHKPT(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKPT *r); -_PUBLIC_ void ndr_print_winreg_OpenHKPN(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKPN *r); -_PUBLIC_ void ndr_print_winreg_QueryMultipleValues2(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryMultipleValues2 *r); - -/* The following definitions come from librpc/gen_ndr/ndr_wkssvc.c */ - -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo100(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo100 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo101(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo101 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo102(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo102 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo502(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo502 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1010(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1010 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1011(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1011 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1012(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1012 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1013(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1013 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1018(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1018 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1023(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1023 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1027(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1027 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1028(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1028 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1032(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1032 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1033(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1033 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1041(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1041 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1042(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1042 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1043(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1043 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1044(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1044 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1045(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1045 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1046(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1046 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1047(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1047 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1048(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1048 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1049(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1049 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1050(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1050 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1051(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1051 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1052(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1052 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1053(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1053 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1054(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1054 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1055(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1055 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1056(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1056 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1057(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1057 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1058(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1058 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1059(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1059 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1060(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1060 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1061(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1061 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo1062(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaInfo1062 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaInfo(struct ndr_print *ndr, const char *name, const union wkssvc_NetWkstaInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaUserInfo0(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrWkstaUserInfo0 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsersCtr0(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaEnumUsersCtr0 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaUserInfo1(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrWkstaUserInfo1 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsersCtr1(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaEnumUsersCtr1 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsersCtr(struct ndr_print *ndr, const char *name, const union wkssvc_NetWkstaEnumUsersCtr *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsersInfo(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaEnumUsersInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaUserInfo1101(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrWkstaUserInfo1101 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaUserInfo(struct ndr_print *ndr, const char *name, const union wkssvc_NetrWkstaUserInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaTransportInfo0(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaTransportInfo0 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaTransportCtr0(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaTransportCtr0 *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaTransportCtr(struct ndr_print *ndr, const char *name, const union wkssvc_NetWkstaTransportCtr *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaTransportInfo(struct ndr_print *ndr, const char *name, const struct wkssvc_NetWkstaTransportInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseInfo3(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseInfo3 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseInfo2(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseInfo2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseInfo1(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseInfo1 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseInfo0(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseInfo0 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseGetInfoCtr(struct ndr_print *ndr, const char *name, const union wkssvc_NetrUseGetInfoCtr *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr2(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseEnumCtr2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr1(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseEnumCtr1 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr0(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseEnumCtr0 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseEnumCtr(struct ndr_print *ndr, const char *name, const union wkssvc_NetrUseEnumCtr *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseEnumInfo(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrUseEnumInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWorkstationStatistics(struct ndr_print *ndr, const char *name, const struct wkssvc_NetrWorkstationStatistics *r); -_PUBLIC_ void ndr_print_wkssvc_renameflags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_wkssvc_NetValidateNameType(struct ndr_print *ndr, const char *name, enum wkssvc_NetValidateNameType r); -_PUBLIC_ void ndr_print_wkssvc_NetJoinStatus(struct ndr_print *ndr, const char *name, enum wkssvc_NetJoinStatus r); -_PUBLIC_ void ndr_print_wkssvc_PasswordBuffer(struct ndr_print *ndr, const char *name, const struct wkssvc_PasswordBuffer *r); -_PUBLIC_ void ndr_print_wkssvc_joinflags(struct ndr_print *ndr, const char *name, uint32_t r); -_PUBLIC_ void ndr_print_wkssvc_ComputerNameType(struct ndr_print *ndr, const char *name, enum wkssvc_ComputerNameType r); -_PUBLIC_ void ndr_print_wkssvc_ComputerNamesCtr(struct ndr_print *ndr, const char *name, const struct wkssvc_ComputerNamesCtr *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetWkstaGetInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaSetInfo(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetWkstaSetInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaEnumUsers(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetWkstaEnumUsers *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaUserGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrWkstaUserGetInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaUserSetInfo(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrWkstaUserSetInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetWkstaTransportEnum(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetWkstaTransportEnum *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaTransportAdd(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrWkstaTransportAdd *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWkstaTransportDel(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrWkstaTransportDel *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseAdd(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrUseAdd *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrUseGetInfo *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseDel(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrUseDel *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUseEnum(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrUseEnum *r); -_PUBLIC_ void ndr_print_wkssvc_NetrMessageBufferSend(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrMessageBufferSend *r); -_PUBLIC_ void ndr_print_wkssvc_NetrWorkstationStatisticsGet(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrWorkstationStatisticsGet *r); -_PUBLIC_ void ndr_print_wkssvc_NetrLogonDomainNameAdd(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrLogonDomainNameAdd *r); -_PUBLIC_ void ndr_print_wkssvc_NetrLogonDomainNameDel(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrLogonDomainNameDel *r); -_PUBLIC_ void ndr_print_wkssvc_NetrJoinDomain(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrJoinDomain *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUnjoinDomain(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrUnjoinDomain *r); -_PUBLIC_ void ndr_print_wkssvc_NetrRenameMachineInDomain(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrRenameMachineInDomain *r); -_PUBLIC_ void ndr_print_wkssvc_NetrValidateName(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrValidateName *r); -_PUBLIC_ void ndr_print_wkssvc_NetrGetJoinInformation(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrGetJoinInformation *r); -_PUBLIC_ void ndr_print_wkssvc_NetrGetJoinableOus(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrGetJoinableOus *r); -_PUBLIC_ void ndr_print_wkssvc_NetrJoinDomain2(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrJoinDomain2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrUnjoinDomain2(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrUnjoinDomain2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrRenameMachineInDomain2(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrRenameMachineInDomain2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrValidateName2(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrValidateName2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrGetJoinableOus2(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrGetJoinableOus2 *r); -_PUBLIC_ void ndr_print_wkssvc_NetrAddAlternateComputerName(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrAddAlternateComputerName *r); -_PUBLIC_ void ndr_print_wkssvc_NetrRemoveAlternateComputerName(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrRemoveAlternateComputerName *r); -_PUBLIC_ void ndr_print_wkssvc_NetrSetPrimaryComputername(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrSetPrimaryComputername *r); -_PUBLIC_ void ndr_print_wkssvc_NetrEnumerateComputerNames(struct ndr_print *ndr, const char *name, int flags, const struct wkssvc_NetrEnumerateComputerNames *r); - -/* The following definitions come from librpc/gen_ndr/ndr_xattr.c */ - -_PUBLIC_ enum ndr_err_code ndr_push_tdb_xattr(struct ndr_push *ndr, int ndr_flags, const struct tdb_xattr *r); -_PUBLIC_ enum ndr_err_code ndr_pull_tdb_xattr(struct ndr_pull *ndr, int ndr_flags, struct tdb_xattr *r); -_PUBLIC_ void ndr_print_tdb_xattr(struct ndr_print *ndr, const char *name, const struct tdb_xattr *r); -_PUBLIC_ enum ndr_err_code ndr_push_tdb_xattrs(struct ndr_push *ndr, int ndr_flags, const struct tdb_xattrs *r); -_PUBLIC_ enum ndr_err_code ndr_pull_tdb_xattrs(struct ndr_pull *ndr, int ndr_flags, struct tdb_xattrs *r); -_PUBLIC_ void ndr_print_tdb_xattrs(struct ndr_print *ndr, const char *name, const struct tdb_xattrs *r); - -/* The following definitions come from librpc/gen_ndr/srv_dfs.c */ - -void netdfs_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_netdfs_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_dssetup.c */ - -void dssetup_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_dssetup_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_echo.c */ - -void rpcecho_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_rpcecho_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_eventlog.c */ - -void eventlog_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_eventlog_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_initshutdown.c */ - -void initshutdown_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_initshutdown_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_lsa.c */ - -void lsarpc_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_lsarpc_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_netlogon.c */ - -void netlogon_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_netlogon_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_ntsvcs.c */ - -void ntsvcs_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_ntsvcs_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_samr.c */ - -void samr_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_samr_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_srvsvc.c */ - -void srvsvc_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_srvsvc_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_svcctl.c */ - -void svcctl_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_svcctl_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_winreg.c */ - -void winreg_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_winreg_init(void); - -/* The following definitions come from librpc/gen_ndr/srv_wkssvc.c */ - -void wkssvc_get_pipe_fns(struct api_struct **fns, int *n_fns); -NTSTATUS rpc_wkssvc_init(void); +#include "librpc/gen_ndr/ndr_dfs.h" +#include "librpc/gen_ndr/ndr_dssetup.h" +#include "librpc/gen_ndr/ndr_echo.h" +#include "librpc/gen_ndr/ndr_eventlog.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" +#include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/gen_ndr/ndr_netlogon.h" +#include "librpc/gen_ndr/ndr_notify.h" +#include "librpc/gen_ndr/ndr_ntsvcs.h" +#include "librpc/gen_ndr/ndr_samr.h" +#include "librpc/gen_ndr/ndr_security.h" +#include "librpc/gen_ndr/ndr_srvsvc.h" +#include "librpc/gen_ndr/ndr_svcctl.h" +#include "librpc/gen_ndr/ndr_winreg.h" +#include "librpc/gen_ndr/ndr_wkssvc.h" + +#include "librpc/gen_ndr/srv_dfs.h" +#include "librpc/gen_ndr/srv_dssetup.h" +#include "librpc/gen_ndr/srv_echo.h" +#include "librpc/gen_ndr/srv_eventlog.h" +#include "librpc/gen_ndr/srv_initshutdown.h" +#include "librpc/gen_ndr/srv_lsa.h" +#include "librpc/gen_ndr/srv_netlogon.h" +#include "librpc/gen_ndr/srv_ntsvcs.h" +#include "librpc/gen_ndr/srv_samr.h" +#include "librpc/gen_ndr/srv_srvsvc.h" +#include "librpc/gen_ndr/srv_svcctl.h" +#include "librpc/gen_ndr/srv_winreg.h" +#include "librpc/gen_ndr/srv_wkssvc.h" + +#include "librpc/ndr/libndr.h" + +/* The following definitions come from librpc/ndr/util.c */ -/* The following definitions come from librpc/ndr/ndr.c */ - -_PUBLIC_ size_t ndr_align_size(uint32_t offset, size_t n); -_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx); -_PUBLIC_ enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size); -_PUBLIC_ void ndr_pull_save(struct ndr_pull *ndr, struct ndr_pull_save *save); -_PUBLIC_ void ndr_pull_restore(struct ndr_pull *ndr, struct ndr_pull_save *save); -_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx); -_PUBLIC_ DATA_BLOB ndr_push_blob(struct ndr_push *ndr); -_PUBLIC_ enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size); -_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3); -_PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3); -_PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr); -_PUBLIC_ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr); -_PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr); -_PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, void *ptr); -_PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr); -_PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx, - ndr_print_function_t fn, const char *name, - int flags, void *ptr); -_PUBLIC_ void ndr_set_flags(uint32_t *pflags, uint32_t new_flags); NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err); -const char *ndr_errstr(enum ndr_err_code err); -_PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, - enum ndr_err_code ndr_err, - const char *format, ...) _PRINTF_ATTRIBUTE(3,4); -_PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr, - enum ndr_err_code ndr_err, - const char *format, ...) _PRINTF_ATTRIBUTE(3,4); -_PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, - struct ndr_pull **_subndr, - size_t header_size, - ssize_t size_is); -_PUBLIC_ enum ndr_err_code ndr_pull_subcontext_end(struct ndr_pull *ndr, - struct ndr_pull *subndr, - size_t header_size, - ssize_t size_is); -_PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr, - struct ndr_push **_subndr, - size_t header_size, - ssize_t size_is); -_PUBLIC_ enum ndr_err_code ndr_push_subcontext_end(struct ndr_push *ndr, - struct ndr_push *subndr, - size_t header_size, - ssize_t size_is); -_PUBLIC_ enum ndr_err_code ndr_token_store(TALLOC_CTX *mem_ctx, - struct ndr_token_list **list, - const void *key, - uint32_t value); -_PUBLIC_ enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v, - comparison_fn_t _cmp_fn, bool _remove_tok); -_PUBLIC_ enum ndr_err_code ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v); -_PUBLIC_ uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key); -_PUBLIC_ enum ndr_err_code ndr_pull_array_size(struct ndr_pull *ndr, const void *p); -_PUBLIC_ uint32_t ndr_get_array_size(struct ndr_pull *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t size); -_PUBLIC_ enum ndr_err_code ndr_pull_array_length(struct ndr_pull *ndr, const void *p); -_PUBLIC_ uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length); -_PUBLIC_ enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val); -_PUBLIC_ enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val); -_PUBLIC_ enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val); -_PUBLIC_ uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, const void *p); -_PUBLIC_ uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p); -_PUBLIC_ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - ndr_pull_flags_fn_t fn); -_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - ndr_pull_flags_fn_t fn); -_PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - uint32_t level, ndr_pull_flags_fn_t fn); -_PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - uint32_t level, ndr_pull_flags_fn_t fn); -_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, - ndr_push_flags_fn_t fn); -_PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - uint32_t level, ndr_push_flags_fn_t fn); -_PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push); -_PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push); -_PUBLIC_ uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr); -_PUBLIC_ void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset); -_PUBLIC_ enum ndr_err_code ndr_push_setup_relative_base_offset1(struct ndr_push *ndr, const void *p, uint32_t offset); -_PUBLIC_ enum ndr_err_code ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2(struct ndr_push *ndr, const void *p); -_PUBLIC_ uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr); -_PUBLIC_ void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset); -_PUBLIC_ enum ndr_err_code ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *p, uint32_t offset); -_PUBLIC_ enum ndr_err_code ndr_pull_setup_relative_base_offset2(struct ndr_pull *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset); -_PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p); - -/* The following definitions come from librpc/ndr/ndr_basic.c */ - -_PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n); -_PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v); -_PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v); -_PUBLIC_ enum ndr_err_code ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status); -_PUBLIC_ enum ndr_err_code ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status); -_PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r); -_PUBLIC_ enum ndr_err_code ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status); -_PUBLIC_ enum ndr_err_code ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status); -_PUBLIC_ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r); -_PUBLIC_ enum ndr_err_code ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n); -_PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n); -_PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v); -_PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v); -_PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v); -_PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v); -_PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v); -_PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v); -_PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v); -_PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v); -_PUBLIC_ enum ndr_err_code ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v); -_PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v); -_PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v); -_PUBLIC_ enum ndr_err_code ndr_push_align(struct ndr_push *ndr, size_t size); -_PUBLIC_ enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size); -_PUBLIC_ enum ndr_err_code ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n); -_PUBLIC_ enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, uint32_t n); -_PUBLIC_ enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n); -_PUBLIC_ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save); -_PUBLIC_ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save); -_PUBLIC_ enum ndr_err_code ndr_push_unique_ptr(struct ndr_push *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p); -_PUBLIC_ enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr); -_PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t); -_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t); -_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t); -_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t); -_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t); -_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t); -_PUBLIC_ enum ndr_err_code ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t); -_PUBLIC_ enum ndr_err_code ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t); -_PUBLIC_ enum ndr_err_code ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address); -_PUBLIC_ enum ndr_err_code ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address); -_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name, - const char *address); -_PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type); -_PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, - const char *val, uint32_t value); -_PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value); -_PUBLIC_ void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v); -_PUBLIC_ void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v); -_PUBLIC_ void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v); -_PUBLIC_ void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v); -_PUBLIC_ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v); -_PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v); -_PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v); -_PUBLIC_ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v); -_PUBLIC_ void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v); -_PUBLIC_ void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v); -_PUBLIC_ void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v); -_PUBLIC_ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p); -_PUBLIC_ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t); -_PUBLIC_ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t); -_PUBLIC_ void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t); -_PUBLIC_ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t); -_PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type); -_PUBLIC_ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level); -_PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, - const uint8_t *data, uint32_t count); -_PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r); -_PUBLIC_ enum ndr_err_code ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob); -_PUBLIC_ enum ndr_err_code ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob); -_PUBLIC_ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags); -_PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b); -_PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss); - -/* The following definitions come from librpc/ndr/ndr_krb5pac.c */ - -enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r); -enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r); -void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r); - -/* The following definitions come from librpc/ndr/ndr_misc.c */ - -bool all_zero(const uint8_t *ptr, size_t size); -void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); -bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, - const struct ndr_syntax_id *i2); enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r); enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r); void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r); +_PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b); +_PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss); +const char *ndr_errstr(enum ndr_err_code err); /* The following definitions come from librpc/ndr/ndr_sec_helper.c */ @@ -4104,22 +2436,6 @@ void ndr_print_dom_sid2(struct ndr_print *ndr, const char *name, const struct do void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid); void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid); -/* The following definitions come from librpc/ndr/ndr_string.c */ - -_PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s); -_PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s); -_PUBLIC_ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s); -_PUBLIC_ void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s); -_PUBLIC_ uint32_t ndr_size_string(int ret, const char * const* string, int flags) ; -_PUBLIC_ enum ndr_err_code ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char ***_a); -_PUBLIC_ enum ndr_err_code ndr_push_string_array(struct ndr_push *ndr, int ndr_flags, const char **a); -_PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a); -_PUBLIC_ uint32_t ndr_string_length(const void *_var, uint32_t element_size); -_PUBLIC_ enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size); -_PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset); -_PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset); -_PUBLIC_ uint32_t ndr_charset_length(const void *var, charset_t chset); - /* The following definitions come from librpc/ndr/sid.c */ enum ndr_err_code ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *r); @@ -4132,20 +2448,6 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid); enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid); -/* The following definitions come from librpc/ndr/uuid.c */ - -_PUBLIC_ NTSTATUS GUID_from_string(const char *s, struct GUID *guid); -_PUBLIC_ NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid); -struct GUID GUID_random(void); -_PUBLIC_ struct GUID GUID_zero(void); -_PUBLIC_ bool GUID_all_zero(const struct GUID *u); -_PUBLIC_ bool GUID_equal(const struct GUID *u1, const struct GUID *u2); -_PUBLIC_ int GUID_compare(const struct GUID *u1, const struct GUID *u2); -_PUBLIC_ char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid); -_PUBLIC_ char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid); -_PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid); -_PUBLIC_ bool policy_handle_empty(struct policy_handle *h) ; - /* The following definitions come from librpc/rpc/binding.c */ const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor); @@ -4313,7 +2615,7 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, const char *domain_name, uint32_t *nt_version, const char **dc_name, - union nbt_cldap_netlogon **reply); + struct netlogon_samlogon_response **reply); /* The following definitions come from libsmb/clientgen.c */ @@ -4400,13 +2702,13 @@ bool cli_lock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout, enum brl_type lock_type); bool cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len); bool cli_lock64(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type); -bool cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len); + uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type); +bool cli_unlock64(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len); bool cli_posix_lock(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, + uint64_t offset, uint64_t len, bool wait_lock, enum brl_type lock_type); -bool cli_posix_unlock(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len); -bool cli_posix_getlock(struct cli_state *cli, int fnum, SMB_BIG_UINT *poffset, SMB_BIG_UINT *plen); +bool cli_posix_unlock(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len); +bool cli_posix_getlock(struct cli_state *cli, int fnum, uint64_t *poffset, uint64_t *plen); bool cli_getattrE(struct cli_state *cli, int fd, uint16 *attr, SMB_OFF_T *size, time_t *change_time, @@ -4452,7 +2754,6 @@ NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli, const char *pass, const char *domain); NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli); -NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli); NTSTATUS cli_force_encryption(struct cli_state *c, const char *username, const char *password, @@ -5258,20 +3559,20 @@ const char *lock_type_name(enum brl_type lock_type); const char *lock_flav_name(enum brl_flavour lock_flav); bool is_locked(files_struct *fsp, uint32 smbpid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_type lock_type); NTSTATUS query_lock(files_struct *fsp, uint32 *psmbpid, - SMB_BIG_UINT *pcount, - SMB_BIG_UINT *poffset, + uint64_t *pcount, + uint64_t *poffset, enum brl_type *plock_type, enum brl_flavour lock_flav); struct byte_range_lock *do_lock(struct messaging_context *msg_ctx, files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_type lock_type, enum brl_flavour lock_flav, bool blocking_lock, @@ -5280,13 +3581,13 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx, NTSTATUS do_unlock(struct messaging_context *msg_ctx, files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_flavour lock_flav); NTSTATUS do_lock_cancel(files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_flavour lock_flav); void locking_close_file(struct messaging_context *msg_ctx, files_struct *fsp); @@ -5338,8 +3639,8 @@ int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *, /* The following definitions come from locking/posix.c */ bool is_posix_locked(files_struct *fsp, - SMB_BIG_UINT *pu_offset, - SMB_BIG_UINT *pu_count, + uint64_t *pu_offset, + uint64_t *pu_count, enum brl_type *plock_type, enum brl_flavour lock_flav); bool posix_locking_init(bool read_only); @@ -5347,28 +3648,28 @@ bool posix_locking_end(void); void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount); int fd_close_posix(struct files_struct *fsp); bool set_posix_lock_windows_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, enum brl_type lock_type, const struct lock_context *lock_ctx, const struct lock_struct *plocks, int num_locks, int *errno_ret); bool release_posix_lock_windows_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, enum brl_type deleted_lock_type, const struct lock_context *lock_ctx, const struct lock_struct *plocks, int num_locks); bool set_posix_lock_posix_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, enum brl_type lock_type, int *errno_ret); bool release_posix_lock_posix_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, const struct lock_context *lock_ctx, const struct lock_struct *plocks, int num_locks); @@ -5954,6 +4255,7 @@ const char **lp_svcctl_list(void); char *lp_cups_options(int ); char *lp_cups_server(void); char *lp_iprint_server(void); +int lp_cups_connection_timeout(void); const char *lp_ctdbd_socket(void); const char **lp_cluster_addresses(void); bool lp_clustering(void); @@ -6119,7 +4421,7 @@ bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal); struct parm_struct *lp_get_parameter(const char *param_name); struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters); bool lp_snum_ok(int iService); -void lp_add_one_printer(char *name, char *comment); +void lp_add_one_printer(const char *name, const char *comment, void *pdata); bool lp_loaded(void); void lp_killunused(bool (*snumused) (int)); void lp_kill_all_services(void); @@ -6548,6 +4850,8 @@ bool secrets_restore_schannel_session_info(TALLOC_CTX *mem_ctx, struct dcinfo **ppdc); bool secrets_store_generic(const char *owner, const char *key, const char *secret); char *secrets_fetch_generic(const char *owner, const char *key); +bool secrets_store_local_schannel_key(uint8_t schannel_key[16]); +bool secrets_fetch_local_schannel_key(uint8_t schannel_key[16]); /* The following definitions come from passdb/util_builtin.c */ @@ -6690,11 +4994,15 @@ char* get_server_name( Printer_entry *printer ); /* The following definitions come from printing/pcap.c */ +bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment); +void pcap_cache_destroy_specific(struct pcap_cache **ppcache); bool pcap_cache_add(const char *name, const char *comment); bool pcap_cache_loaded(void); +void pcap_cache_replace(const struct pcap_cache *cache); void pcap_cache_reload(void); bool pcap_printername_ok(const char *printername); -void pcap_printer_fn(void (*fn)(char *, char *)); +void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *); +void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *); /* The following definitions come from printing/print_aix.c */ @@ -6718,7 +5026,8 @@ bool sysv_cache_reload(void); /* The following definitions come from printing/printfsp.c */ -NTSTATUS print_fsp_open(connection_struct *conn, const char *fname, +NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn, + const char *fname, uint16_t current_vuid, files_struct **result); void print_fsp_end(files_struct *fsp, enum file_close_type close_type); @@ -7049,6 +5358,12 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, DATA_BLOB lm_response, DATA_BLOB nt_response, struct netr_SamInfo3 **info3); +NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const unsigned char orig_trust_passwd_hash[16], + const char *new_trust_pwd_cleartext, + const unsigned char new_trust_passwd_hash[16], + uint32_t sec_channel_type); /* The following definitions come from rpc_client/cli_pipe.c */ @@ -7313,8 +5628,6 @@ WERROR rpccli_spoolss_rffpcnex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hSCM, uint32 type, uint32 state, uint32 *returned, ENUM_SERVICES_STATUS **service_array ); -WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, SERVICE_CONFIG *config ); /* The following definitions come from rpc_client/init_lsa.c */ @@ -7427,6 +5740,9 @@ void init_netr_PasswordInfo(struct netr_PasswordInfo *r, const char *workstation, struct samr_Password lmpassword, struct samr_Password ntpassword); +void init_netr_CryptPassword(const char *pwd, + unsigned char session_key[16], + struct netr_CryptPassword *pwd_buf); /* The following definitions come from rpc_client/init_samr.c */ @@ -7436,22 +5752,22 @@ void init_samr_DomInfo1(struct samr_DomInfo1 *r, uint32_t password_properties, int64_t max_password_age, int64_t min_password_age); -void init_samr_DomInfo2(struct samr_DomInfo2 *r, - NTTIME force_logoff_time, - const char *comment, - const char *domain_name, - const char *primary, - uint64_t sequence_num, - uint32_t unknown2, - enum samr_Role role, - uint32_t unknown3, - uint32_t num_users, - uint32_t num_groups, - uint32_t num_aliases); +void init_samr_DomGeneralInformation(struct samr_DomGeneralInformation *r, + NTTIME force_logoff_time, + const char *oem_information, + const char *domain_name, + const char *primary, + uint64_t sequence_num, + uint32_t unknown2, + enum samr_Role role, + uint32_t unknown3, + uint32_t num_users, + uint32_t num_groups, + uint32_t num_aliases); void init_samr_DomInfo3(struct samr_DomInfo3 *r, NTTIME force_logoff_time); -void init_samr_DomInfo4(struct samr_DomInfo4 *r, - const char *comment); +void init_samr_DomOEMInformation(struct samr_DomOEMInformation *r, + const char *oem_information); void init_samr_DomInfo5(struct samr_DomInfo5 *r, const char *domain_name); void init_samr_DomInfo6(struct samr_DomInfo6 *r, @@ -8304,11 +6620,8 @@ bool convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf ) ; bool svcctl_io_enum_services_status( const char *desc, ENUM_SERVICES_STATUS *enum_status, RPC_BUFFER *buffer, int depth ); bool svcctl_io_service_status_process( const char *desc, SERVICE_STATUS_PROCESS *status, RPC_BUFFER *buffer, int depth ); uint32 svcctl_sizeof_enum_services_status( ENUM_SERVICES_STATUS *status ); -uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config ); bool svcctl_io_q_enum_services_status(const char *desc, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, prs_struct *ps, int depth); bool svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_STATUS *r_u, prs_struct *ps, int depth); -bool svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth); -bool svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u, prs_struct *ps, int depth); bool svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth); void init_service_description_buffer(SERVICE_DESCRIPTION *desc, const char *service_desc ); bool svcctl_io_service_description( const char *desc, SERVICE_DESCRIPTION *description, RPC_BUFFER *buffer, int depth ); @@ -8827,26 +7140,16 @@ bool api_pipe_request(pipes_struct *p); pipes_struct *get_first_internal_pipe(void); pipes_struct *get_next_internal_pipe(pipes_struct *p); void set_pipe_handle_offset(int max_open_files); -void reset_chain_p(void); void init_rpc_pipe_hnd(void); -smb_np_struct *open_rpc_pipe_p(const char *pipe_name, - connection_struct *conn, uint16 vuid); -ssize_t write_to_pipe(smb_np_struct *p, char *data, size_t n); -ssize_t read_from_pipe(smb_np_struct *p, char *data, size_t n, - bool *is_data_outstanding); -bool wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority); -bool set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state); -bool close_rpc_pipe_hnd(smb_np_struct *p); -void pipe_close_conn(connection_struct *conn); -smb_np_struct *get_rpc_pipe_p(uint16 pnum); -smb_np_struct *get_rpc_pipe(int pnum); -struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name, - const char *client_address, - struct auth_serversupplied_info *server_info, - uint16_t vuid); -ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, size_t n, - bool *is_data_outstanding); -ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n); + +bool fsp_is_np(struct files_struct *fsp); +NTSTATUS np_open(struct smb_request *smb_req, struct connection_struct *conn, + const char *name, struct files_struct **pfsp); +NTSTATUS np_write(struct files_struct *fsp, uint8_t *data, size_t len, + ssize_t *nwritten); +NTSTATUS np_read(struct files_struct *fsp, uint8_t *data, size_t len, + ssize_t *nread, bool *is_data_outstanding); + /* The following definitions come from rpc_server/srv_samr_nt.c */ @@ -9244,7 +7547,6 @@ WERROR _svcctl_ControlService(pipes_struct *p, WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, struct svcctl_EnumDependentServicesW *r); WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u ); -WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ); WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u ); WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r); @@ -9467,16 +7769,16 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck, uint32 lock_pid, enum brl_type lock_type, enum brl_flavour lock_flav, - SMB_BIG_UINT offset, - SMB_BIG_UINT count, + uint64_t offset, + uint64_t count, uint32 blocking_pid); void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lock *br_lck); void remove_pending_lock_requests_by_mid(int mid); bool blocking_lock_was_deferred(int mid); bool blocking_lock_cancel(files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT offset, - SMB_BIG_UINT count, + uint64_t offset, + uint64_t count, enum brl_flavour lock_flav, unsigned char locktype, NTSTATUS err); @@ -9505,7 +7807,8 @@ NTSTATUS change_oem_password(struct samu *hnd, char *old_passwd, char *new_passw /* The following definitions come from smbd/close.c */ void set_close_write_time(struct files_struct *fsp, struct timespec ts); -NTSTATUS close_file(files_struct *fsp, enum file_close_type close_type); +NTSTATUS close_file(struct smb_request *req, files_struct *fsp, + enum file_close_type close_type); void msg_close_file(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, @@ -9538,19 +7841,17 @@ int count_all_current_connections(void); bool claim_connection(connection_struct *conn, const char *name, uint32 msg_flags); bool register_message_flags(bool doreg, uint32 msg_flags); -bool store_pipe_opendb( smb_np_struct *p ); -bool delete_pipe_opendb( smb_np_struct *p ); /* The following definitions come from smbd/dfree.c */ -SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small_query, - SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize); -SMB_BIG_UINT get_dfree_info(connection_struct *conn, +uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_query, + uint64_t *bsize,uint64_t *dfree,uint64_t *dsize); +uint64_t get_dfree_info(connection_struct *conn, const char *path, bool small_query, - SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, - SMB_BIG_UINT *dsize); + uint64_t *bsize, + uint64_t *dfree, + uint64_t *dsize); /* The following definitions come from smbd/dir.c */ @@ -9664,14 +7965,13 @@ void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode, /* The following definitions come from smbd/fake_file.c */ enum FAKE_FILE_TYPE is_fake_file(const char *fname); -NTSTATUS open_fake_file(connection_struct *conn, +NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn, uint16_t current_vuid, enum FAKE_FILE_TYPE fake_file_type, const char *fname, uint32 access_mask, files_struct **result); -void destroy_fake_file_handle(struct fake_file_handle **fh); -NTSTATUS close_fake_file(files_struct *fsp); +NTSTATUS close_fake_file(struct smb_request *req, files_struct *fsp); /* The following definitions come from smbd/file_access.c */ @@ -9712,7 +8012,8 @@ NTSTATUS check_name(connection_struct *conn, const char *name); /* The following definitions come from smbd/files.c */ -NTSTATUS file_new(connection_struct *conn, files_struct **result); +NTSTATUS file_new(struct smb_request *req, connection_struct *conn, + files_struct **result); void file_close_conn(connection_struct *conn); void file_close_pid(uint16 smbpid, int vuid); void file_init(void); @@ -9725,15 +8026,12 @@ files_struct *file_find_di_first(struct file_id id); files_struct *file_find_di_next(files_struct *start_fsp); files_struct *file_find_print(void); void file_sync_all(connection_struct *conn); -void file_free(files_struct *fsp); +void file_free(struct smb_request *req, files_struct *fsp); files_struct *file_fnum(uint16 fnum); -files_struct *file_fsp(uint16 fid); -void file_chain_reset(void); -NTSTATUS dup_file_fsp(files_struct *fsp, - uint32 access_mask, - uint32 share_access, - uint32 create_options, - files_struct **result); +files_struct *file_fsp(struct smb_request *req, uint16 fid); +NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *fsp, + uint32 access_mask, uint32 share_access, + uint32 create_options, files_struct **result); /* The following definitions come from smbd/ipc.c */ @@ -9925,9 +8223,10 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, /* Information (FILE_EXISTS etc.) */ int *pinfo, files_struct **result); -NTSTATUS open_file_fchmod(connection_struct *conn, const char *fname, +NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn, + const char *fname, SMB_STRUCT_STAT *psbuf, files_struct **result); -NTSTATUS close_file_fchmod(files_struct *fsp); +NTSTATUS close_file_fchmod(struct smb_request *req, files_struct *fsp); NTSTATUS open_directory(connection_struct *conn, struct smb_request *req, const char *fname, @@ -9954,7 +8253,7 @@ NTSTATUS create_file_unixpath(connection_struct *conn, uint32_t create_options, uint32_t file_attributes, uint32_t oplock_request, - SMB_BIG_UINT allocation_size, + uint64_t allocation_size, struct security_descriptor *sd, struct ea_list *ea_list, @@ -9971,7 +8270,7 @@ NTSTATUS create_file(connection_struct *conn, uint32_t create_options, uint32_t file_attributes, uint32_t oplock_request, - SMB_BIG_UINT allocation_size, + uint64_t allocation_size, struct security_descriptor *sd, struct ea_list *ea_list, @@ -10036,14 +8335,17 @@ void reply_pipe_close(connection_struct *conn, struct smb_request *req); /* The following definitions come from smbd/posix_acls.c */ -NTSTATUS unpack_nt_owners(int snum, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, SEC_DESC *psd); +NTSTATUS unpack_nt_owners(int snum, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, const SEC_DESC *psd); SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl); NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info, SEC_DESC **ppdesc); NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name, uint32_t security_info, SEC_DESC **ppdesc); int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid); -NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd); +NTSTATUS append_parent_acl(files_struct *fsp, + const SEC_DESC *pcsd, + SEC_DESC **pp_new_sd); +NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd); int get_acl_group_bits( connection_struct *conn, const char *fname, mode_t *mode ); int chmod_acl(connection_struct *conn, const char *name, mode_t mode); int inherit_access_posix_acl(connection_struct *conn, const char *inherit_from_dir, @@ -10095,18 +8397,18 @@ void smbd_process(void); /* The following definitions come from smbd/quotas.c */ -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); bool disk_quotas(const char *path, - SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, - SMB_BIG_UINT *dsize); -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); -bool disk_quotas_vxfs(const char *name, char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); -bool disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize); -bool disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize); + uint64_t *bsize, + uint64_t *dfree, + uint64_t *dsize); +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); +bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); +bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize); +bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize); /* The following definitions come from smbd/reply.c */ @@ -10216,8 +8518,8 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, bool target_is_directory); void reply_copy(struct smb_request *req); uint32 get_lock_pid( char *data, int data_offset, bool large_file_format); -SMB_BIG_UINT get_lock_count( char *data, int data_offset, bool large_file_format); -SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err); +uint64_t get_lock_count( char *data, int data_offset, bool large_file_format); +uint64_t get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err); void reply_lockingX(struct smb_request *req); void reply_readbmpx(struct smb_request *req); void reply_readbs(struct smb_request *req); @@ -10335,8 +8637,8 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf); /* The following definitions come from smbd/trans2.c */ -SMB_BIG_UINT smb_roundup(connection_struct *conn, SMB_BIG_UINT val); -SMB_BIG_UINT get_allocation_size(connection_struct *conn, files_struct *fsp, const SMB_STRUCT_STAT *sbuf); +uint64_t smb_roundup(connection_struct *conn, uint64_t val); +uint64_t get_allocation_size(connection_struct *conn, files_struct *fsp, const SMB_STRUCT_STAT *sbuf); NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp, const char *fname, const char *ea_name, struct ea_struct *pea); @@ -10420,7 +8722,7 @@ ssize_t vfs_pwrite_data(struct smb_request *req, const char *buffer, size_t N, SMB_OFF_T offset); -int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len); +int vfs_allocate_file_space(files_struct *fsp, uint64_t len); int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len); int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len); SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n); diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index b4021afd0a..1dc5ba4a7b 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -39,6 +39,7 @@ #define LSA_POLICY_READ ( STANDARD_RIGHTS_READ_ACCESS |\ + LSA_POLICY_VIEW_LOCAL_INFORMATION |\ LSA_POLICY_VIEW_AUDIT_INFORMATION |\ LSA_POLICY_GET_PRIVATE_INFORMATION) diff --git a/source3/include/rpc_secdes.h b/source3/include/rpc_secdes.h index 83103b7386..71fba41fe9 100644 --- a/source3/include/rpc_secdes.h +++ b/source3/include/rpc_secdes.h @@ -70,9 +70,6 @@ PROTECTED_SACL_SECURITY_INFORMATION|\ PROTECTED_DACL_SECURITY_INFORMATION) -/* SEC_ACCESS */ -typedef uint32 SEC_ACCESS; - /* SEC_ACE */ typedef struct security_ace SEC_ACE; #define SEC_ACE_HEADER_SIZE (2 * sizeof(uint8) + sizeof(uint16) + sizeof(uint32)) diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h index aa1d1662c8..0e31a53e32 100644 --- a/source3/include/rpc_svcctl.h +++ b/source3/include/rpc_svcctl.h @@ -141,18 +141,6 @@ typedef struct { SERVICE_STATUS status; } ENUM_SERVICES_STATUS; -typedef struct { - uint32 service_type; - uint32 start_type; - uint32 error_control; - UNISTR2 *executablepath; - UNISTR2 *loadordergroup; - uint32 tag_id; - UNISTR2 *dependencies; - UNISTR2 *startname; - UNISTR2 *displayname; -} SERVICE_CONFIG; - typedef struct { uint32 unknown; UNISTR description; @@ -212,20 +200,6 @@ typedef struct { WERROR status; } SVCCTL_R_ENUM_SERVICES_STATUS; -/**************************/ - -typedef struct { - POLICY_HND handle; - uint32 buffer_size; -} SVCCTL_Q_QUERY_SERVICE_CONFIG; - -typedef struct { - SERVICE_CONFIG config; - uint32 needed; - WERROR status; -} SVCCTL_R_QUERY_SERVICE_CONFIG; - - /**************************/ typedef struct { diff --git a/source3/include/secrets.h b/source3/include/secrets.h index d9f457558b..3c8e2ccf81 100644 --- a/source3/include/secrets.h +++ b/source3/include/secrets.h @@ -45,6 +45,8 @@ #define SECRETS_LDAP_BIND_PW "SECRETS/LDAP_BIND_PW" +#define SECRETS_LOCAL_SCHANNEL_KEY "SECRETS/LOCAL_SCHANNEL_KEY" + /* Authenticated user info is stored in secrets.tdb under these keys */ #define SECRETS_AUTH_USER "SECRETS/AUTH_USER" diff --git a/source3/include/smb.h b/source3/include/smb.h index c8c4f8c3cc..732bef1212 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -174,9 +174,6 @@ typedef uint32 codepoint_t; /* pipe string names */ #define PIPE_LANMAN "\\PIPE\\LANMAN" -/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */ -typedef uint64_t NTTIME; - #define MAX_HOURS_LEN 32 #ifndef MAXSUBAUTHS @@ -249,15 +246,6 @@ struct id_map { enum id_mapping status; }; -/* 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" @@ -372,7 +360,7 @@ typedef struct { struct fd_handle { size_t ref_count; int fd; - SMB_BIG_UINT position_information; + uint64_t position_information; SMB_OFF_T pos; uint32 private_options; /* NT Create options, but we only look at * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and @@ -391,6 +379,7 @@ struct idle_event; struct share_mode_entry; struct uuid; struct named_mutex; +struct pcap_cache; struct vfs_fsp_data { struct vfs_fsp_data *next; @@ -447,7 +436,7 @@ typedef struct files_struct { unsigned int num_smb_operations; uint16 rap_print_jobid; struct file_id file_id; - SMB_BIG_UINT initial_allocation_size; /* Faked up initial allocation on disk. */ + uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */ mode_t mode; uint16 file_pid; uint16 vuid; @@ -558,10 +547,10 @@ struct stream_struct { struct dfree_cached_info { time_t last_dfree_time; - SMB_BIG_UINT dfree_ret; - SMB_BIG_UINT bsize; - SMB_BIG_UINT dfree; - SMB_BIG_UINT dsize; + uint64_t dfree_ret; + uint64_t bsize; + uint64_t dfree; + uint64_t dsize; }; struct dptr_struct; @@ -647,6 +636,7 @@ struct smb_request { size_t unread_bytes; bool encrypted; connection_struct *conn; + struct files_struct *chain_fsp; }; /* Defines for the sent_oplock_break field above. */ diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 20e2a9a443..d2e0aa95ac 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -75,22 +75,6 @@ return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ } while(0) -/* you must add the following extern declaration to files using this macro - * (do not add it to the macro as that causes nested extern declaration warnings) - * extern struct current_user current_user; - */ -#define CHECK_FSP(fsp,conn) do {\ - if (!(fsp) || !(conn)) \ - return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ - else if (((conn) != (fsp)->conn) || current_user.vuid != (fsp)->vuid) \ - return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ - else if ((fsp)->is_directory) \ - return ERROR_NT(NT_STATUS_INVALID_DEVICE_REQUEST); \ - else if ((fsp)->fh->fd == -1) \ - return ERROR_NT(NT_STATUS_ACCESS_DENIED); \ - (fsp)->num_smb_operations++;\ - } while(0) - #define CHECK_READ(fsp,inbuf) (((fsp)->fh->fd != -1) && ((fsp)->can_read || \ ((SVAL((inbuf),smb_flg2) & FLAGS2_READ_PERMIT_EXECUTE) && \ (fsp->access_mask & FILE_EXECUTE)))) diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h index f58a6452bf..8945708ca3 100644 --- a/source3/include/smbprofile.h +++ b/source3/include/smbprofile.h @@ -782,7 +782,7 @@ extern bool do_profile_times; extern clockid_t __profile_clock; -static inline SMB_BIG_UINT profile_timestamp(void) +static inline uint64_t profile_timestamp(void) { struct timespec ts; @@ -797,7 +797,7 @@ static inline SMB_BIG_UINT profile_timestamp(void) #else -static inline SMB_BIG_UINT profile_timestamp(void) +static inline uint64_t profile_timestamp(void) { struct timeval tv; GetTimeOfDay(&tv); @@ -830,14 +830,14 @@ static inline SMB_BIG_UINT profile_timestamp(void) } #define START_PROFILE(x) \ - SMB_BIG_UINT __profstamp_##x = 0; \ + uint64_t __profstamp_##x = 0; \ if (do_profile_flag) { \ __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\ INC_PROFILE_COUNT(x##_count); \ } #define START_PROFILE_BYTES(x,n) \ - SMB_BIG_UINT __profstamp_##x = 0; \ + uint64_t __profstamp_##x = 0; \ if (do_profile_flag) { \ __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\ INC_PROFILE_COUNT(x##_count); \ diff --git a/source3/include/sysquotas.h b/source3/include/sysquotas.h index a0754a3737..71d5e9b264 100644 --- a/source3/include/sysquotas.h +++ b/source3/include/sysquotas.h @@ -37,8 +37,8 @@ Some stuff for the sys_quota api. **************************************************/ -#define SMB_QUOTAS_NO_LIMIT ((SMB_BIG_UINT)(0)) -#define SMB_QUOTAS_NO_SPACE ((SMB_BIG_UINT)(1)) +#define SMB_QUOTAS_NO_LIMIT ((uint64_t)(0)) +#define SMB_QUOTAS_NO_SPACE ((uint64_t)(1)) #define SMB_QUOTAS_SET_NO_LIMIT(dp) \ {\ @@ -58,14 +58,14 @@ typedef struct _SMB_DISK_QUOTA { enum SMB_QUOTA_TYPE qtype; - SMB_BIG_UINT bsize; - SMB_BIG_UINT hardlimit; /* In bsize units. */ - SMB_BIG_UINT softlimit; /* In bsize units. */ - SMB_BIG_UINT curblocks; /* In bsize units. */ - SMB_BIG_UINT ihardlimit; /* inode hard limit. */ - SMB_BIG_UINT isoftlimit; /* inode soft limit. */ - SMB_BIG_UINT curinodes; /* Current used inodes. */ - uint32 qflags; + uint64_t bsize; + uint64_t hardlimit; /* In bsize units. */ + uint64_t softlimit; /* In bsize units. */ + uint64_t curblocks; /* In bsize units. */ + uint64_t ihardlimit; /* inode hard limit. */ + uint64_t isoftlimit; /* inode soft limit. */ + uint64_t curinodes; /* Current used inodes. */ + uint32_t qflags; } SMB_DISK_QUOTA; #ifndef QUOTABLOCK_SIZE diff --git a/source3/include/talloc_stack.h b/source3/include/talloc_stack.h index a2a12f8a63..bb22b8a029 100644 --- a/source3/include/talloc_stack.h +++ b/source3/include/talloc_stack.h @@ -35,7 +35,7 @@ #ifndef _TALLOC_STACK_H #define _TALLOC_STACK_H -#include "lib/talloc/talloc.h" +#include "../talloc/talloc.h" /* * Create a new talloc stack frame. diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h index fcc723c511..107d0b1bd5 100644 --- a/source3/include/util_tdb.h +++ b/source3/include/util_tdb.h @@ -48,34 +48,34 @@ struct tdb_validation_status { typedef int (*tdb_validate_data_func)(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state); -TDB_DATA make_tdb_data(const uint8 *dptr, size_t dsize); +TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize); TDB_DATA string_tdb_data(const char *string); TDB_DATA string_term_tdb_data(const char *string); TDB_LIST_NODE *tdb_search_keys(struct tdb_context*, const char*); void tdb_search_list_free(TDB_LIST_NODE*); -int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, +int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key, unsigned int timeout); int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval); -int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, +int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval, int timeout); void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval); int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout); -void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval); - -int32 tdb_fetch_int32_byblob(TDB_CONTEXT *tdb, TDB_DATA key); -int32 tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); -bool tdb_store_uint32_byblob(TDB_CONTEXT *tdb, TDB_DATA key, uint32 value); -bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32 value); -int tdb_store_int32_byblob(TDB_CONTEXT *tdb, TDB_DATA key, int32 v); -int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32 v); -bool tdb_fetch_uint32_byblob(TDB_CONTEXT *tdb, TDB_DATA key, uint32 *value); -bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32 *value); -int32 tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32 *oldval, int32 change_val); -bool tdb_change_uint32_atomic(TDB_CONTEXT *tdb, const char *keystr, - uint32 *oldval, uint32 change_val); +void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval); + +int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key); +int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); +bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value); +bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value); +int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v); +int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v); +bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value); +bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value); +int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val); +bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, + uint32_t *oldval, uint32_t change_val); int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 9b72f69328..4cedb4a9c6 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -108,8 +108,10 @@ /* Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox */ /* Changed to version 23 - remove set_nt_acl call. This can only be done via an open handle. JRA. */ +/* Changed to version 24 - make security descriptor const in fset_nt_acl. JRA. */ +/* Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t. */ -#define SMB_VFS_INTERFACE_VERSION 23 +#define SMB_VFS_INTERFACE_VERSION 25 /* to bug old modules which are trying to compile with the old functions */ @@ -281,8 +283,8 @@ struct vfs_ops { 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, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); + uint64_t (*disk_free)(struct vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize, + uint64_t *dfree, uint64_t *dsize); int (*get_quota)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt); 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); @@ -365,7 +367,7 @@ struct vfs_ops { NTSTATUS (*fset_nt_acl)(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 security_info_sent, - struct security_descriptor *psd); + const struct security_descriptor *psd); /* POSIX ACL operations. */ @@ -624,14 +626,14 @@ typedef struct vfs_statvfs_struct { if no distinction is made return the same value in each. */ - SMB_BIG_UINT TotalBlocks; - SMB_BIG_UINT BlocksAvail; /* bfree */ - SMB_BIG_UINT UserBlocksAvail; /* bavail */ + uint64_t TotalBlocks; + uint64_t BlocksAvail; /* bfree */ + uint64_t UserBlocksAvail; /* bavail */ /* For undefined Node fields or FSID return -1 */ - SMB_BIG_UINT TotalFileNodes; - SMB_BIG_UINT FreeFileNodes; - SMB_BIG_UINT FsIdentifier; /* fsid */ + uint64_t TotalFileNodes; + uint64_t FreeFileNodes; + uint64_t FsIdentifier; /* fsid */ /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */ /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */ diff --git a/source3/include/xfile.h b/source3/include/xfile.h deleted file mode 100644 index ffe4481a64..0000000000 --- a/source3/include/xfile.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Unix SMB/CIFS implementation. - stdio replacement - Copyright (C) Andrew Tridgell 2001 - - 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 . -*/ - -#ifndef _XFILE_H_ -#define _XFILE_H_ -/* - see xfile.c for explanations -*/ - -typedef struct { - int fd; - char *buf; - char *next; - int bufsize; - int bufused; - int open_flags; - int buftype; - int flags; -} XFILE; - -extern XFILE *x_stdin, *x_stdout, *x_stderr; - -/* buffering type */ -#define X_IOFBF 0 -#define X_IOLBF 1 -#define X_IONBF 2 - -#define x_getc(f) x_fgetc(f) - -int x_vfprintf(XFILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2, 0); -int x_fprintf(XFILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2, 3); -#endif /* _XFILE_H_ */ diff --git a/source3/iniparser_build/dictionary.c b/source3/iniparser_build/dictionary.c index de98a4523f..3147361746 100644 --- a/source3/iniparser_build/dictionary.c +++ b/source3/iniparser_build/dictionary.c @@ -3,5 +3,5 @@ the iniparser source code --metze */ -#include "lib/replace/replace.h" +#include "../replace/replace.h" #include "iniparser/src/dictionary.c" diff --git a/source3/iniparser_build/iniparser.c b/source3/iniparser_build/iniparser.c index 4974f373ee..3f4a1aaf1a 100644 --- a/source3/iniparser_build/iniparser.c +++ b/source3/iniparser_build/iniparser.c @@ -3,5 +3,5 @@ the iniparser source code --metze */ -#include "lib/replace/replace.h" +#include "../replace/replace.h" #include "iniparser/src/iniparser.c" diff --git a/source3/iniparser_build/strlib.c b/source3/iniparser_build/strlib.c index 685ec8e04d..4ea95b73ae 100644 --- a/source3/iniparser_build/strlib.c +++ b/source3/iniparser_build/strlib.c @@ -3,5 +3,5 @@ the iniparser source code --metze */ -#include "lib/replace/replace.h" +#include "../replace/replace.h" #include "iniparser/src/strlib.c" diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c index 499b9eb87d..ac7e9dda40 100644 --- a/source3/intl/lang_tdb.c +++ b/source3/intl/lang_tdb.c @@ -33,14 +33,14 @@ static bool load_msg(const char *msg_file) char *msgid, *msgstr; TDB_DATA data; - lines = file_lines_load(msg_file, &num_lines,0); + lines = file_lines_load(msg_file, &num_lines, 0, NULL); if (!lines) { return False; } if (tdb_lockall(tdb) != 0) { - file_lines_free(lines); + TALLOC_FREE(lines); return False; } @@ -68,7 +68,7 @@ static bool load_msg(const char *msg_file) } } - file_lines_free(lines); + TALLOC_FREE(lines); tdb_unlockall(tdb); return True; diff --git a/source3/lib/access.c b/source3/lib/access.c index 6a445f8139..966d8ce87c 100644 --- a/source3/lib/access.c +++ b/source3/lib/access.c @@ -104,7 +104,7 @@ static bool string_match(const char *tok,const char *s) if (memcache_lookup( NULL, SINGLETON_CACHE, - data_blob_string_const("yp_default_domain"), + data_blob_string_const_null("yp_default_domain"), &tmp)) { SMB_ASSERT(tmp.length > 0); @@ -116,8 +116,8 @@ static bool string_match(const char *tok,const char *s) memcache_add( NULL, SINGLETON_CACHE, - data_blob_string_const("yp_default_domain"), - data_blob_string_const(mydomain?mydomain:"")); + data_blob_string_const_null("yp_default_domain"), + data_blob_string_const_null(mydomain?mydomain:"")); } if (!mydomain) { diff --git a/source3/lib/arc4.c b/source3/lib/arc4.c deleted file mode 100644 index af2564b6c0..0000000000 --- a/source3/lib/arc4.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - An implementation of arc4. - - Copyright (C) Jeremy Allison 2005. - - 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 . -*/ - -#include "includes.h" - -/***************************************************************** - Initialize state for an arc4 crypt/decrpyt. - arc4 state is 258 bytes - last 2 bytes are the index bytes. -*****************************************************************/ - -void smb_arc4_init(unsigned char arc4_state_out[258], const unsigned char *key, size_t keylen) -{ - size_t ind; - unsigned char j = 0; - - for (ind = 0; ind < 256; ind++) { - arc4_state_out[ind] = (unsigned char)ind; - } - - for( ind = 0; ind < 256; ind++) { - unsigned char tc; - - j += (arc4_state_out[ind] + key[ind%keylen]); - - tc = arc4_state_out[ind]; - arc4_state_out[ind] = arc4_state_out[j]; - arc4_state_out[j] = tc; - } - arc4_state_out[256] = 0; - arc4_state_out[257] = 0; -} - -/***************************************************************** - Do the arc4 crypt/decrpyt. - arc4 state is 258 bytes - last 2 bytes are the index bytes. -*****************************************************************/ - -void smb_arc4_crypt(unsigned char arc4_state_inout[258], unsigned char *data, size_t len) -{ - unsigned char index_i = arc4_state_inout[256]; - unsigned char index_j = arc4_state_inout[257]; - size_t ind; - - for( ind = 0; ind < len; ind++) { - unsigned char tc; - unsigned char t; - - index_i++; - index_j += arc4_state_inout[index_i]; - - tc = arc4_state_inout[index_i]; - arc4_state_inout[index_i] = arc4_state_inout[index_j]; - arc4_state_inout[index_j] = tc; - - t = arc4_state_inout[index_i] + arc4_state_inout[index_j]; - data[ind] = data[ind] ^ arc4_state_inout[t]; - } - - arc4_state_inout[256] = index_i; - arc4_state_inout[257] = index_j; -} diff --git a/source3/lib/async_sock.c b/source3/lib/async_sock.c index 1a4c27ba20..ffba6de832 100644 --- a/source3/lib/async_sock.c +++ b/source3/lib/async_sock.c @@ -658,12 +658,13 @@ struct async_req *async_connect(TALLOC_CTX *mem_ctx, struct event_context *ev, state->fde = event_add_fd(ev, state, fd, EVENT_FD_READ | EVENT_FD_WRITE, - async_connect_callback, state); + async_connect_callback, result); if (state->fde == NULL) { sys_fcntl_long(fd, F_SETFL, p->old_sockflags); TALLOC_FREE(result); return NULL; } + result->private_data = state; state->param.param_connect.fd = fd; state->param.param_connect.address = address; diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 485212b100..3ec3220900 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -1166,7 +1166,7 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx, int flags) { char *dest = NULL; - size_t converted_size; + size_t dest_len; #ifdef DEVELOPER /* Ensure we never use the braindead "malloc" varient. */ @@ -1177,6 +1177,10 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx, *ppdest = NULL; + if (!src_len) { + return 0; + } + if (flags & STR_TERMINATE) { if (src_len == (size_t)-1) { src_len = strlen((const char *)src) + 1; @@ -1194,18 +1198,41 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx, (unsigned int)src_len); smb_panic(msg); } + } else { + /* Can't have an unlimited length + * non STR_TERMINATE'd. + */ + if (src_len == (size_t)-1) { + errno = EINVAL; + return 0; + } } + /* src_len != -1 here. */ + if (!convert_string_allocate(ctx, CH_DOS, CH_UNIX, src, src_len, &dest, - &converted_size, True)) - { - converted_size = 0; + &dest_len, True)) { + dest_len = 0; } - if (converted_size && dest) { + if (dest_len && dest) { /* Did we already process the terminating zero ? */ - if (dest[converted_size - 1] != 0) { - dest[converted_size - 1] = 0; + if (dest[dest_len-1] != 0) { + size_t size = talloc_get_size(dest); + /* Have we got space to append the '\0' ? */ + if (size <= dest_len) { + /* No, realloc. */ + dest = TALLOC_REALLOC_ARRAY(ctx, dest, char, + dest_len+1); + if (!dest) { + /* talloc fail. */ + dest_len = (size_t)-1; + return 0; + } + } + /* Yay - space ! */ + dest[dest_len] = '\0'; + dest_len++; } } else if (dest) { dest[0] = 0; @@ -1562,21 +1589,26 @@ size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx, if (src_len >= 1024*1024) { smb_panic("Bad src length in pull_ucs2_base_talloc\n"); } + } else { + /* Can't have an unlimited length + * non STR_TERMINATE'd. + */ + if (src_len == (size_t)-1) { + errno = EINVAL; + return 0; + } } + /* src_len != -1 here. */ + /* ucs2 is always a multiple of 2 bytes */ - if (src_len != (size_t)-1) { - src_len &= ~1; - } + src_len &= ~1; if (!convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, src, src_len, (void *)&dest, &dest_len, True)) { dest_len = 0; } - if (src_len == (size_t)-1) - src_len = dest_len*2; - if (dest_len) { /* Did we already process the terminating zero ? */ if (dest[dest_len-1] != 0) { diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c deleted file mode 100644 index a4ae90c469..0000000000 --- a/source3/lib/crc32.c +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or - * code or tables extracted from it, as desired without restriction. - * - * First, the polynomial itself and its table of feedback terms. The - * polynomial is - * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 - * - * Note that we take it "backwards" and put the highest-order term in - * the lowest-order bit. The X^32 term is "implied"; the LSB is the - * X^31 term, etc. The X^0 term (usually shown as "+1") results in - * the MSB being 1 - * - * Note that the usual hardware shift register implementation, which - * is what we're using (we're merely optimizing it by doing eight-bit - * chunks at a time) shifts bits into the lowest-order term. In our - * implementation, that means shifting towards the right. Why do we - * do it this way? Because the calculated CRC must be transmitted in - * order from highest-order term to lowest-order term. UARTs transmit - * characters in order from LSB to MSB. By storing the CRC this way - * we hand it to the UART in the order low-byte to high-byte; the UART - * sends each low-bit to hight-bit; and the result is transmission bit - * by bit from highest- to lowest-order term without requiring any bit - * shuffling on our part. Reception works similarly - * - * The feedback terms table consists of 256, 32-bit entries. Notes - * - * The table can be generated at runtime if desired; code to do so - * is shown later. It might not be obvious, but the feedback - * terms simply represent the results of eight shift/xor opera - * tions for all combinations of data and CRC register values - * - * The values must be right-shifted by eight bits by the "updcrc - * logic; the shift must be unsigned (bring in zeroes). On some - * hardware you could probably optimize the shift in assembler by - * using byte-swap instructions - * polynomial $edb88320 - * - * - * CRC32 code derived from work by Gary S. Brown. - */ - -#include "includes.h" - -static const uint32 crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -uint32 crc32_calc_buffer(const char *buf, size_t size) -{ - const unsigned char *p; - uint32 crc; - - p = (const unsigned char *)buf; - crc = ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 1ae23bcf82..10a65c5bcc 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -155,7 +155,7 @@ static NTSTATUS ctdbd_connect(TALLOC_CTX *mem_ctx, * Do we have a complete ctdb packet in the queue? */ -static bool ctdb_req_complete(const struct data_blob *data, +static bool ctdb_req_complete(const DATA_BLOB *data, size_t *length, void *private_data) { @@ -220,7 +220,7 @@ struct req_pull_state { * Pull a ctdb request out of the incoming packet queue */ -static NTSTATUS ctdb_req_pull(const struct data_blob *data, +static NTSTATUS ctdb_req_pull(const DATA_BLOB *data, void *private_data) { struct req_pull_state *state = (struct req_pull_state *)private_data; @@ -260,7 +260,7 @@ static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx, blob = data_blob_const(msg->data, msg->datalen); ndr_err = ndr_pull_struct_blob( - &blob, result, result, + &blob, result, NULL, result, (ndr_pull_flags_fn_t)ndr_pull_messaging_rec); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -497,7 +497,7 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx, /* * Packet handler to receive and handle a ctdb message */ -static NTSTATUS ctdb_handle_message(const struct data_blob *data, +static NTSTATUS ctdb_handle_message(const DATA_BLOB *data, void *private_data) { struct ctdbd_connection *conn = talloc_get_type_abort( @@ -636,7 +636,7 @@ NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn, } ndr_err = ndr_push_struct_blob( - &blob, mem_ctx, msg, + &blob, mem_ctx, NULL, msg, (ndr_push_flags_fn_t)ndr_push_messaging_rec); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -1025,7 +1025,7 @@ struct ctdbd_traverse_state { * Handle a traverse record coming in on the ctdbd connection */ -static NTSTATUS ctdb_traverse_handler(const struct data_blob *blob, +static NTSTATUS ctdb_traverse_handler(const DATA_BLOB *blob, void *private_data) { struct ctdbd_traverse_state *state = diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c deleted file mode 100644 index 66c5daf363..0000000000 --- a/source3/lib/data_blob.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Easy management of byte-length data - Copyright (C) Andrew Tridgell 2001 - Copyright (C) Andrew Bartlett 2001 - - 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 . -*/ - -#include "includes.h" - -const DATA_BLOB data_blob_null = { NULL, 0, NULL }; - -/******************************************************************* - Free() a data blob. -*******************************************************************/ - -static void free_data_blob(DATA_BLOB *d) -{ - if ((d) && (d->free)) { - SAFE_FREE(d->data); - } -} - -/******************************************************************* - Construct a data blob, must be freed with data_blob_free(). - You can pass NULL for p and get a blank data blob -*******************************************************************/ - -DATA_BLOB data_blob(const void *p, size_t length) -{ - DATA_BLOB ret; - - if (!length) { - ZERO_STRUCT(ret); - return ret; - } - - if (p) { - ret.data = (uint8 *)smb_xmemdup(p, length); - } else { - ret.data = SMB_XMALLOC_ARRAY(uint8, length); - } - ret.length = length; - ret.free = free_data_blob; - return ret; -} - -/******************************************************************* - Construct a data blob, using supplied TALLOC_CTX. -*******************************************************************/ - -DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) -{ - DATA_BLOB ret; - - if (!length) { - ZERO_STRUCT(ret); - return ret; - } - - if (p) { - ret.data = (uint8 *)TALLOC_MEMDUP(mem_ctx, p, length); - if (ret.data == NULL) - smb_panic("data_blob_talloc: TALLOC_MEMDUP failed"); - } else { - ret.data = (uint8 *)TALLOC(mem_ctx, length); - if (ret.data == NULL) - smb_panic("data_blob_talloc: TALLOC failed"); - } - - ret.length = length; - ret.free = NULL; - return ret; -} - -/******************************************************************* - Free a data blob. -*******************************************************************/ - -void data_blob_free(DATA_BLOB *d) -{ - if (d) { - if (d->free) { - (d->free)(d); - } - d->length = 0; - } -} - -/******************************************************************* - Clear a DATA_BLOB's contents -*******************************************************************/ - -void data_blob_clear(DATA_BLOB *d) -{ - if (d->data) { - memset(d->data, 0, d->length); - } -} - -/******************************************************************* - Free a data blob and clear its contents -*******************************************************************/ - -void data_blob_clear_free(DATA_BLOB *d) -{ - data_blob_clear(d); - data_blob_free(d); -} - -/** - useful for constructing data blobs in test suites, while - avoiding const warnings -**/ -DATA_BLOB data_blob_string_const(const char *str) -{ - DATA_BLOB blob; - blob.data = CONST_DISCARD(uint8 *, str); - blob.length = strlen(str) + 1; - blob.free = NULL; - return blob; -} - -/** - * Create a new data blob from const data - */ -DATA_BLOB data_blob_const(const void *p, size_t length) -{ - DATA_BLOB blob; - blob.data = CONST_DISCARD(uint8 *, p); - blob.length = 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; -} - -/** -print the data_blob as hex string -**/ -_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob) -{ - int i; - char *hex_string; - - hex_string = talloc_array(mem_ctx, char, (blob->length*2)+1); - if (!hex_string) { - return NULL; - } - - for (i = 0; i < blob->length; i++) - slprintf(&hex_string[i*2], 3, "%02X", blob->data[i]); - - hex_string[(blob->length*2)] = '\0'; - return hex_string; -} - - diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c index 63a5ce4de6..38daa61b33 100644 --- a/source3/lib/dbwrap_ctdb.c +++ b/source3/lib/dbwrap_ctdb.c @@ -405,8 +405,9 @@ static struct db_record *db_ctdb_fetch_locked_transaction(struct db_ctdb_ctx *ct return result; } -static int db_ctdb_record_destructor(struct db_record *rec) +static int db_ctdb_record_destructor(struct db_record **recp) { + struct db_record *rec = talloc_get_type_abort(*recp, struct db_record); struct db_ctdb_transaction_handle *h = talloc_get_type_abort( rec->private_data, struct db_ctdb_transaction_handle); int ret = h->ctx->db->transaction_commit(h->ctx->db); @@ -424,7 +425,7 @@ static struct db_record *db_ctdb_fetch_locked_persistent(struct db_ctdb_ctx *ctx TDB_DATA key) { int res; - struct db_record *rec; + struct db_record *rec, **recp; res = db_ctdb_transaction_start(ctx->db); if (res == -1) { @@ -438,7 +439,14 @@ static struct db_record *db_ctdb_fetch_locked_persistent(struct db_ctdb_ctx *ctx } /* destroy this transaction when we release the lock */ - talloc_set_destructor((struct db_record *)talloc_new(rec), db_ctdb_record_destructor); + recp = talloc(rec, struct db_record *); + if (recp == NULL) { + ctx->db->transaction_cancel(ctx->db); + talloc_free(rec); + return NULL; + } + *recp = rec; + talloc_set_destructor(recp, db_ctdb_record_destructor); return rec; } @@ -813,7 +821,7 @@ static int db_ctdb_record_destr(struct db_record* data) ? "Unlocking db %u key %s\n" : "Unlocking db %u key %.20s\n", (int)crec->ctdb_ctx->db_id, - hex_encode(data, (unsigned char *)data->key.dptr, + hex_encode_talloc(data, (unsigned char *)data->key.dptr, data->key.dsize))); if (tdb_chainunlock(crec->ctdb_ctx->wtdb->tdb, data->key) != 0) { @@ -863,7 +871,7 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx, again: if (DEBUGLEVEL >= 10) { - char *keystr = hex_encode(result, key.dptr, key.dsize); + char *keystr = hex_encode_talloc(result, key.dptr, key.dsize); DEBUG(10, (DEBUGLEVEL > 10 ? "Locking db %u key %s\n" : "Locking db %u key %.20s\n", diff --git a/source3/lib/dbwrap_file.c b/source3/lib/dbwrap_file.c index e3779de1e4..69ad8e4b20 100644 --- a/source3/lib/dbwrap_file.c +++ b/source3/lib/dbwrap_file.c @@ -105,7 +105,7 @@ static struct db_record *db_file_fetch_locked(struct db_context *db, /* Cut to 8 bits */ file->hash = fsh(key.dptr, key.dsize); - file->name = hex_encode(file, (unsigned char *)key.dptr, key.dsize); + file->name = hex_encode_talloc(file, (unsigned char *)key.dptr, key.dsize); if (file->name == NULL) { DEBUG(0, ("hex_encode failed\n")); TALLOC_FREE(result); diff --git a/source3/lib/dbwrap_rbt.c b/source3/lib/dbwrap_rbt.c index b70ce3dfa0..6e09627223 100644 --- a/source3/lib/dbwrap_rbt.c +++ b/source3/lib/dbwrap_rbt.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "rbtree.h" +#include "../lib/util/rbtree.h" #define DBWRAP_RBT_ALIGN(_size_) (((_size_)+15)&~15) diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c index 7bdadd3770..4860c61ab0 100644 --- a/source3/lib/dbwrap_tdb.c +++ b/source3/lib/dbwrap_tdb.c @@ -31,14 +31,14 @@ 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 + /* This hex_encode_talloc() 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, + hex_encode_talloc(data, (unsigned char *)data->key.dptr, data->key.dsize))); if (tdb_chainunlock(ctx->wtdb->tdb, data->key) != 0) { @@ -94,7 +94,7 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db, /* 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); + char *keystr = hex_encode_talloc(NULL, (unsigned char*)key.dptr, key.dsize); DEBUG(10, (DEBUGLEVEL > 10 ? "Locking key %s\n" : "Locking key %.20s\n", keystr)); diff --git a/source3/lib/debug.c b/source3/lib/debug.c index d835ea7c17..be2707b595 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -578,7 +578,9 @@ void setup_logging(const char *pname, bool interactive) stdout_logging = False; if (dbf) { x_fflush(dbf); - (void) x_fclose(dbf); + if (dbf != x_stdout) { + (void) x_fclose(dbf); + } } dbf = NULL; @@ -982,7 +984,7 @@ void dbgflush( void ) ****************************************************************************/ -bool dbghdr(int level, int cls, const char *file, const char *func, int line) +bool dbghdrclass(int level, int cls, const char *location, const char *func) { /* Ensure we don't lose any real errno value. */ int old_errno = errno; @@ -1044,10 +1046,10 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line) lp_debug_hires_timestamp()), level, header_str); } else { - (void)Debug1( "[%s, %2d%s] %s:%s(%d)\n", + (void)Debug1( "[%s, %2d%s] %s(%s)\n", current_timestring(debug_ctx(), lp_debug_hires_timestamp()), - level, header_str, file, func, line ); + level, header_str, location, func ); } } @@ -1055,6 +1057,12 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line) return( True ); } +bool dbghdr(int level, const char *location, const char *func) +{ + /* For compatibility with Samba 4, which doesn't have debug classes */ + return dbghdrclass(level, 0, location, func); +} + /*************************************************************************** Add text to the body of the "current" debug message via the format buffer. diff --git a/source3/lib/display_sec.c b/source3/lib/display_sec.c index 67392e4568..a0d93d6fe7 100644 --- a/source3/lib/display_sec.c +++ b/source3/lib/display_sec.c @@ -118,7 +118,7 @@ char *get_sec_mask_str(TALLOC_CTX *ctx, uint32 type) /**************************************************************************** display sec_access structure ****************************************************************************/ -void display_sec_access(SEC_ACCESS *info) +void display_sec_access(uint32_t *info) { char *mask_str = get_sec_mask_str(NULL, *info); printf("\t\tPermissions: 0x%x: %s\n", *info, mask_str ? mask_str : ""); @@ -157,13 +157,13 @@ static void disp_sec_ace_object(struct security_ace_object *object) { if (object->flags & SEC_ACE_OBJECT_PRESENT) { printf("Object type: SEC_ACE_OBJECT_PRESENT\n"); - printf("Object GUID: %s\n", smb_uuid_string(talloc_tos(), - object->type.type)); + printf("Object GUID: %s\n", GUID_string(talloc_tos(), + &object->type.type)); } if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) { printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n"); - printf("Object GUID: %s\n", smb_uuid_string(talloc_tos(), - object->inherited_type.inherited_type)); + printf("Object GUID: %s\n", GUID_string(talloc_tos(), + &object->inherited_type.inherited_type)); } } diff --git a/source3/lib/dprintf.c b/source3/lib/dprintf.c index a3bb5be43a..b3c830dd5b 100644 --- a/source3/lib/dprintf.c +++ b/source3/lib/dprintf.c @@ -41,7 +41,7 @@ msgstr = lang_msg(format); if (!msgstr) return -1; - VA_COPY(ap2, ap); + va_copy(ap2, ap); ret = vasprintf(&p, msgstr, ap2); diff --git a/source3/lib/dummysmbd.c b/source3/lib/dummysmbd.c index dbe886e3d1..5c624bdebf 100644 --- a/source3/lib/dummysmbd.c +++ b/source3/lib/dummysmbd.c @@ -51,3 +51,18 @@ NTSTATUS can_delete_directory(struct connection_struct *conn, { return NT_STATUS_OK; } + +bool change_to_root_user(void) +{ + return false; +} + +struct event_context *smbd_event_context(void) +{ + return NULL; +} + +struct messaging_context *smbd_messaging_context(void) +{ + return NULL; +} diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c index 2cd2386c5c..9adb237096 100644 --- a/source3/lib/errmap_unix.c +++ b/source3/lib/errmap_unix.c @@ -128,3 +128,139 @@ NTSTATUS map_nt_error_from_unix(int unix_error) /* Default return */ return NT_STATUS_ACCESS_DENIED; } + +/* Return a UNIX errno from a NT status code */ +static const struct { + NTSTATUS status; + int error; +} nt_errno_map[] = { + {NT_STATUS_ACCESS_VIOLATION, EACCES}, + {NT_STATUS_INVALID_HANDLE, EBADF}, + {NT_STATUS_ACCESS_DENIED, EACCES}, + {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, + {NT_STATUS_OBJECT_PATH_NOT_FOUND, ENOENT}, + {NT_STATUS_SHARING_VIOLATION, EBUSY}, + {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, + {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, + {NT_STATUS_PATH_NOT_COVERED, ENOENT}, + {NT_STATUS_UNSUCCESSFUL, EINVAL}, + {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, + {NT_STATUS_IN_PAGE_ERROR, EFAULT}, + {NT_STATUS_BAD_NETWORK_NAME, ENOENT}, +#ifdef EDQUOT + {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, + {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, + {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, + {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, +#endif +#ifdef ETIME + {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, +#endif + {NT_STATUS_INVALID_PARAMETER, EINVAL}, + {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, + {NT_STATUS_NO_SUCH_FILE, ENOENT}, +#ifdef ENODATA + {NT_STATUS_END_OF_FILE, ENODATA}, +#endif +#ifdef ENOMEDIUM + {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM}, + {NT_STATUS_NO_MEDIA, ENOMEDIUM}, +#endif + {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE}, + {NT_STATUS_NO_MEMORY, ENOMEM}, + {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE}, + {NT_STATUS_NOT_MAPPED_VIEW, EINVAL}, + {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE}, + {NT_STATUS_ACCESS_DENIED, EACCES}, + {NT_STATUS_BUFFER_TOO_SMALL, ENOBUFS}, + {NT_STATUS_WRONG_PASSWORD, EACCES}, + {NT_STATUS_LOGON_FAILURE, EACCES}, + {NT_STATUS_INVALID_WORKSTATION, EACCES}, + {NT_STATUS_INVALID_LOGON_HOURS, EACCES}, + {NT_STATUS_PASSWORD_EXPIRED, EACCES}, + {NT_STATUS_ACCOUNT_DISABLED, EACCES}, + {NT_STATUS_DISK_FULL, ENOSPC}, + {NT_STATUS_INVALID_PIPE_STATE, EPIPE}, + {NT_STATUS_PIPE_BUSY, EPIPE}, + {NT_STATUS_PIPE_DISCONNECTED, EPIPE}, + {NT_STATUS_PIPE_NOT_AVAILABLE, ENOSYS}, + {NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR}, + {NT_STATUS_NOT_SUPPORTED, ENOSYS}, + {NT_STATUS_NOT_A_DIRECTORY, ENOTDIR}, + {NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY}, + {NT_STATUS_NETWORK_UNREACHABLE, ENETUNREACH}, + {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH}, + {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED}, + {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED}, + {NT_STATUS_TOO_MANY_LINKS, EMLINK}, + {NT_STATUS_NETWORK_BUSY, EBUSY}, + {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, +#ifdef ELIBACC + {NT_STATUS_DLL_NOT_FOUND, ELIBACC}, +#endif + {NT_STATUS_PIPE_BROKEN, EPIPE}, + {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED}, + {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES}, + {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE}, +#ifdef EPROTO + {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO}, +#endif + {NT_STATUS_FLOAT_OVERFLOW, ERANGE}, + {NT_STATUS_FLOAT_UNDERFLOW, ERANGE}, + {NT_STATUS_INTEGER_OVERFLOW, ERANGE}, + {NT_STATUS_MEDIA_WRITE_PROTECTED, EROFS}, + {NT_STATUS_PIPE_CONNECTED, EISCONN}, + {NT_STATUS_MEMORY_NOT_ALLOCATED, EFAULT}, + {NT_STATUS_FLOAT_INEXACT_RESULT, ERANGE}, + {NT_STATUS_ILL_FORMED_PASSWORD, EACCES}, + {NT_STATUS_PASSWORD_RESTRICTION, EACCES}, + {NT_STATUS_ACCOUNT_RESTRICTION, EACCES}, + {NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED}, + {NT_STATUS_NAME_TOO_LONG, ENAMETOOLONG}, + {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN}, + {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED}, + {NT_STATUS_CONNECTION_RESET, ENETRESET}, +#ifdef ENOTUNIQ + {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ}, + {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ}, +#endif + {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE}, + {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT}, + {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE}, + {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, + {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, + {NT_STATUS_RETRY, EAGAIN}, +#ifdef ENOTUNIQ + {NT_STATUS_DUPLICATE_NAME, ENOTUNIQ}, +#endif +#ifdef ECOMM + {NT_STATUS_NET_WRITE_FAULT, ECOMM}, +#endif +#ifdef EXDEV + {NT_STATUS_NOT_SAME_DEVICE, EXDEV}, +#endif + {NT_STATUS(0), 0} +}; + +int map_errno_from_nt_status(NTSTATUS status) +{ + int i; + DEBUG(10,("map_errno_from_nt_status: 32 bit codes: code=%08x\n", + NT_STATUS_V(status))); + + /* Status codes without this bit set are not errors */ + + if (!(NT_STATUS_V(status) & 0xc0000000)) { + return 0; + } + + for (i=0;nt_errno_map[i].error;i++) { + if (NT_STATUS_V(nt_errno_map[i].status) == + NT_STATUS_V(status)) { + return nt_errno_map[i].error; + } + } + + /* for all other cases - a default code */ + return EINVAL; +} diff --git a/source3/lib/events.c b/source3/lib/events.c index f03138708b..8bbc9497ac 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -436,7 +436,7 @@ void dump_event_list(struct event_context *event_ctx) te->event_name, (unsigned long)te, (int)evt.tv_sec, - http_timestring(te->when.tv_sec))); + http_timestring(talloc_tos(), te->when.tv_sec))); } for (fe = event_ctx->fd_events; fe; fe = fe->next) { diff --git a/source3/lib/fsusage.c b/source3/lib/fsusage.c deleted file mode 100644 index 66ffb9f442..0000000000 --- a/source3/lib/fsusage.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - Unix SMB/CIFS implementation. - functions to calculate the free disk space - Copyright (C) Andrew Tridgell 1998-2000 - - 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 . -*/ - -#include "includes.h" - - -/* Return the number of TOSIZE-byte blocks used by - BLOCKS FROMSIZE-byte blocks, rounding away from zero. -*/ -static SMB_BIG_UINT adjust_blocks(SMB_BIG_UINT blocks, SMB_BIG_UINT fromsize, SMB_BIG_UINT tosize) -{ - if (fromsize == tosize) { /* e.g., from 512 to 512 */ - return blocks; - } else if (fromsize > tosize) { /* e.g., from 2048 to 512 */ - return blocks * (fromsize / tosize); - } else { /* e.g., from 256 to 512 */ - /* Protect against broken filesystems... */ - if (fromsize == 0) { - fromsize = tosize; - } - return (blocks + 1) / (tosize / fromsize); - } -} - -/* this does all of the system specific guff to get the free disk space. - It is derived from code in the GNU fileutils package, but has been - considerably mangled for use here - - results are returned in *dfree and *dsize, in 512 byte units -*/ -int sys_fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) -{ -#ifdef STAT_STATFS3_OSF1 -#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512) - struct statfs fsd; - - if (statfs (path, &fsd, sizeof (struct statfs)) != 0) - return -1; -#endif /* STAT_STATFS3_OSF1 */ - -#ifdef STAT_STATFS2_FS_DATA /* Ultrix */ -#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)1024, (SMB_BIG_UINT)512) - struct fs_data fsd; - - if (statfs (path, &fsd) != 1) - return -1; - - (*dsize) = CONVERT_BLOCKS (fsd.fd_req.btot); - (*dfree) = CONVERT_BLOCKS (fsd.fd_req.bfreen); -#endif /* STAT_STATFS2_FS_DATA */ - -#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ -#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) - struct statfs fsd; - - if (statfs (path, &fsd) < 0) - return -1; - -#ifdef STATFS_TRUNCATES_BLOCK_COUNTS - /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the - struct statfs are truncated to 2GB. These conditions detect that - truncation, presumably without botching the 4.1.1 case, in which - the values are not truncated. The correct counts are stored in - undocumented spare fields. */ - if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0) { - fsd.f_blocks = fsd.f_spare[0]; - fsd.f_bfree = fsd.f_spare[1]; - fsd.f_bavail = fsd.f_spare[2]; - } -#endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ -#endif /* STAT_STATFS2_BSIZE */ - - -#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ -#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512) - - struct statfs fsd; - - if (statfs (path, &fsd) < 0) - return -1; -#endif /* STAT_STATFS2_FSIZE */ - -#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ -# if _AIX || defined(_CRAY) -# define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) -# ifdef _CRAY -# define f_bavail f_bfree -# endif -# else -# define CONVERT_BLOCKS(B) ((SMB_BIG_UINT)B) -# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */ -# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */ -# define f_bavail f_bfree -# endif -# endif -# endif - - struct statfs fsd; - - if (statfs (path, &fsd, sizeof fsd, 0) < 0) - return -1; - /* Empirically, the block counts on most SVR3 and SVR3-derived - systems seem to always be in terms of 512-byte blocks, - no matter what value f_bsize has. */ - -#endif /* STAT_STATFS4 */ - -#if defined(STAT_STATVFS) || defined(STAT_STATVFS64) /* SVR4 */ -#if defined HAVE_FRSIZE -# define CONVERT_BLOCKS(B) \ - adjust_blocks ((SMB_BIG_UINT)(B), fsd.f_frsize ? (SMB_BIG_UINT)fsd.f_frsize : (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) -#else -# define CONVERT_BLOCKS(B) \ - adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) -#endif - -#ifdef STAT_STATVFS64 - struct statvfs64 fsd; - if (statvfs64(path, &fsd) < 0) return -1; -#else - struct statvfs fsd; - if (statvfs(path, &fsd) < 0) return -1; -#endif - - /* f_frsize isn't guaranteed to be supported. */ - -#endif /* STAT_STATVFS */ - -#ifndef CONVERT_BLOCKS - /* we don't have any dfree code! */ - return -1; -#else -#if !defined(STAT_STATFS2_FS_DATA) - /* !Ultrix */ - (*dsize) = CONVERT_BLOCKS (fsd.f_blocks); - (*dfree) = CONVERT_BLOCKS (fsd.f_bavail); -#endif /* not STAT_STATFS2_FS_DATA */ -#endif - - return 0; -} diff --git a/source3/lib/genrand.c b/source3/lib/genrand.c index 4590b812c5..076a2fd518 100644 --- a/source3/lib/genrand.c +++ b/source3/lib/genrand.c @@ -21,7 +21,7 @@ #include "includes.h" -static unsigned char smb_arc4_state[258]; +static struct arcfour_state smb_arc4_state; static uint32 counter; static bool done_reseed = False; @@ -89,6 +89,7 @@ static void do_filehash(const char *fname, unsigned char *the_hash) static int do_reseed(bool use_fd, int fd) { unsigned char seed_inbuf[40]; + DATA_BLOB seed_blob = { seed_inbuf, 40 }; uint32 v1, v2; struct timeval tval; pid_t mypid; struct passwd *pw; int reseed_data = 0; @@ -146,7 +147,7 @@ static int do_reseed(bool use_fd, int fd) seed_inbuf[i] ^= ((char *)(&reseed_data))[i % sizeof(reseed_data)]; } - smb_arc4_init(smb_arc4_state, seed_inbuf, sizeof(seed_inbuf)); + arcfour_init(&smb_arc4_state, &seed_blob); return -1; } @@ -155,7 +156,7 @@ static int do_reseed(bool use_fd, int fd) Interface to the (hopefully) good crypto random number generator. ********************************************************************/ -void generate_random_buffer( unsigned char *out, int len) +void generate_random_buffer(uint8_t *out, int len) { static int urand_fd = -1; unsigned char md4_buf[64]; @@ -190,7 +191,7 @@ void generate_random_buffer( unsigned char *out, int len) while(len > 0) { int copy_len = len > 16 ? 16 : len; - smb_arc4_crypt(smb_arc4_state, md4_buf, sizeof(md4_buf)); + arcfour_crypt_sbox(&smb_arc4_state, md4_buf, sizeof(md4_buf)); mdfour(tmp_buf, md4_buf, sizeof(md4_buf)); memcpy(p, tmp_buf, copy_len); p += copy_len; @@ -204,15 +205,11 @@ void generate_random_buffer( unsigned char *out, int len) static char c_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,"; -char *generate_random_str(size_t len) +char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len) { - static unsigned char retstr[256]; + unsigned char *retstr = talloc_zero_array(mem_ctx, unsigned char, len); size_t i; - memset(retstr, '\0', sizeof(retstr)); - - if (len > sizeof(retstr)-1) - len = sizeof(retstr) -1; generate_random_buffer( retstr, len); for (i = 0; i < len; i++) retstr[i] = c_list[ retstr[i] % (sizeof(c_list)-1) ]; diff --git a/source3/lib/hmacmd5.c b/source3/lib/hmacmd5.c deleted file mode 100644 index 86db3aa236..0000000000 --- a/source3/lib/hmacmd5.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - Unix SMB/CIFS implementation. - HMAC MD5 code for use in NTLMv2 - Copyright (C) Luke Kenneth Casson Leighton 1996-2000 - Copyright (C) Andrew Tridgell 1992-2000 - - 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 . -*/ - -/* taken direct from rfc2104 implementation and modified for suitable use - * for ntlmv2. - */ - -#include "includes.h" - -/*********************************************************************** - the rfc 2104 version of hmac_md5 initialisation. -***********************************************************************/ - -void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context *ctx) -{ - int i; - unsigned char tk[16]; - - /* if key is longer than 64 bytes reset it to key=MD5(key) */ - if (key_len > 64) { - struct MD5Context tctx; - - MD5Init(&tctx); - MD5Update(&tctx, key, key_len); - MD5Final(tk, &tctx); - - key = tk; - key_len = 16; - } - - /* start out by storing key in pads */ - ZERO_STRUCT(ctx->k_ipad); - ZERO_STRUCT(ctx->k_opad); - memcpy( ctx->k_ipad, key, key_len); - memcpy( ctx->k_opad, key, key_len); - - /* XOR key with ipad and opad values */ - for (i=0; i<64; i++) { - ctx->k_ipad[i] ^= 0x36; - ctx->k_opad[i] ^= 0x5c; - } - - MD5Init(&ctx->ctx); - MD5Update(&ctx->ctx, ctx->k_ipad, 64); -} - -/*********************************************************************** - the microsoft version of hmac_md5 initialisation. -***********************************************************************/ - -void hmac_md5_init_limK_to_64(const unsigned char* key, int key_len, - HMACMD5Context *ctx) -{ - int i; - - /* if key is longer than 64 bytes truncate it */ - if (key_len > 64) { - key_len = 64; - } - - /* start out by storing key in pads */ - ZERO_STRUCT(ctx->k_ipad); - ZERO_STRUCT(ctx->k_opad); - memcpy( ctx->k_ipad, key, key_len); - memcpy( ctx->k_opad, key, key_len); - - /* XOR key with ipad and opad values */ - for (i=0; i<64; i++) { - ctx->k_ipad[i] ^= 0x36; - ctx->k_opad[i] ^= 0x5c; - } - - MD5Init(&ctx->ctx); - MD5Update(&ctx->ctx, ctx->k_ipad, 64); -} - -/*********************************************************************** - update hmac_md5 "inner" buffer -***********************************************************************/ - -void hmac_md5_update(const unsigned char *text, int text_len, HMACMD5Context *ctx) -{ - MD5Update(&ctx->ctx, text, text_len); /* then text of datagram */ -} - -/*********************************************************************** - finish off hmac_md5 "inner" buffer and generate outer one. -***********************************************************************/ -void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx) - -{ - struct MD5Context ctx_o; - - MD5Final(digest, &ctx->ctx); - - MD5Init(&ctx_o); - MD5Update(&ctx_o, ctx->k_opad, 64); - MD5Update(&ctx_o, digest, 16); - MD5Final(digest, &ctx_o); -} - -/*********************************************************** - single function to calculate an HMAC MD5 digest from data. - use the microsoft hmacmd5 init method because the key is 16 bytes. -************************************************************/ - -void hmac_md5( unsigned char key[16], const unsigned char *data, int data_len, - unsigned char *digest) -{ - HMACMD5Context ctx; - hmac_md5_init_limK_to_64(key, 16, &ctx); - if (data_len != 0) - { - hmac_md5_update(data, data_len, &ctx); - } - hmac_md5_final(digest, &ctx); -} - diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index dd857ae672..4567fe457b 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -86,7 +86,7 @@ #define SOCKET_WRAPPER_NOT_REPLACE #include "interfaces.h" -#include "lib/replace/replace.h" +#include "../replace/replace.h" /**************************************************************************** Utility functions. diff --git a/source3/lib/ldb/common/ldb.c b/source3/lib/ldb/common/ldb.c index 743711b967..c8aa6afdfc 100644 --- a/source3/lib/ldb/common/ldb.c +++ b/source3/lib/ldb/common/ldb.c @@ -787,6 +787,7 @@ int ldb_search(struct ldb_context *ldb, done: if (ret != LDB_SUCCESS) { talloc_free(res); + res = NULL; } *_res = res; diff --git a/source3/lib/ldb/ldb_tdb/ldb_tdb.h b/source3/lib/ldb/ldb_tdb/ldb_tdb.h index 42f3dc2421..486d948fa0 100644 --- a/source3/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source3/lib/ldb/ldb_tdb/ldb_tdb.h @@ -6,7 +6,7 @@ #if (_SAMBA_BUILD_ >= 4) #include "lib/tdb/include/tdb.h" #elif defined(_SAMBA_BUILD_) -#include "tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #else #include "tdb.h" #endif diff --git a/source3/lib/ldb/libldb.m4 b/source3/lib/ldb/libldb.m4 index 845563b4a1..df2075d4e3 100644 --- a/source3/lib/ldb/libldb.m4 +++ b/source3/lib/ldb/libldb.m4 @@ -1,33 +1 @@ SMB_ENABLE(ldb_sqlite3,$with_sqlite3_support) - -AC_MSG_CHECKING([for Python]) - -PYTHON= - -AC_ARG_WITH(python, -[ --with-python=PYTHONNAME build Python libraries], -[ case "${withval-python}" in - yes) - PYTHON=python - ;; - no) - PYTHON= - ;; - *) - PYTHON=${withval-python} - ;; - esac ]) - -if test x"$PYTHON" != "x"; then - incdir=`python -c 'import sys; print "%s/include/python%d.%d" % (sys.prefix, sys.version_info[[0]], sys.version_info[[1]])'` - CPPFLAGS="$CPPFLAGS -I $incdir" -fi - -if test x"$PYTHON" != "x"; then - AC_MSG_RESULT([${withval-python}]) -else - AC_MSG_RESULT(no) - SMB_ENABLE(swig_ldb, NO) -fi - -AC_SUBST(PYTHON) diff --git a/source3/lib/md4.c b/source3/lib/md4.c deleted file mode 100644 index bae0091e36..0000000000 --- a/source3/lib/md4.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - Unix SMB/CIFS implementation. - a implementation of MD4 designed for use in the SMB authentication protocol - Copyright (C) Andrew Tridgell 1997-1998. - - 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 . -*/ - -#include "includes.h" - -/* NOTE: This code makes no attempt to be fast! - - It assumes that a int is at least 32 bits long -*/ - -#if 0 -static uint32 A, B, C, D; -#else -#define A (state[0]) -#define B (state[1]) -#define C (state[2]) -#define D (state[3]) -#endif - -static uint32 F(uint32 X, uint32 Y, uint32 Z) -{ - return (X&Y) | ((~X)&Z); -} - -static uint32 G(uint32 X, uint32 Y, uint32 Z) -{ - return (X&Y) | (X&Z) | (Y&Z); -} - -static uint32 H(uint32 X, uint32 Y, uint32 Z) -{ - return X^Y^Z; -} - -static uint32 lshift(uint32 x, int s) -{ - x &= 0xFFFFFFFF; - return ((x<>(32-s)); -} - -#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s) -#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s) -#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s) - -/* this applies md4 to 64 byte chunks */ -static void mdfour64(uint32_t *state, uint32 *M) -{ - int j; - uint32 AA, BB, CC, DD; - uint32 X[16]; - - for (j=0;j<16;j++) - X[j] = M[j]; - - AA = A; BB = B; CC = C; DD = D; - - ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); - ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); - ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); - ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); - ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); - ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); - ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); - ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); - - ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); - ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); - ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); - ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); - ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); - ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); - ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); - ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); - - ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); - ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); - ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); - ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); - ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); - ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); - ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); - ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); - - A += AA; B += BB; C += CC; D += DD; - - A &= 0xFFFFFFFF; B &= 0xFFFFFFFF; - C &= 0xFFFFFFFF; D &= 0xFFFFFFFF; - - for (j=0;j<16;j++) - X[j] = 0; -} - -static void copy64(uint32 *M, const unsigned char *in) -{ - int i; - - for (i=0;i<16;i++) - M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | - (in[i*4+1]<<8) | (in[i*4+0]<<0); -} - -static void copy4(unsigned char *out, uint32 x) -{ - out[0] = x&0xFF; - out[1] = (x>>8)&0xFF; - out[2] = (x>>16)&0xFF; - out[3] = (x>>24)&0xFF; -} - -/* produce a md4 message digest from data of length n bytes */ -void mdfour(unsigned char *out, const unsigned char *in, int n) -{ - unsigned char buf[128]; - uint32 M[16]; - uint32 state[4]; - uint32 b = n * 8; - int i; - - A = 0x67452301; - B = 0xefcdab89; - C = 0x98badcfe; - D = 0x10325476; - - while (n > 64) { - copy64(M, in); - mdfour64(state, M); - in += 64; - n -= 64; - } - - for (i=0;i<128;i++) - buf[i] = 0; - memcpy(buf, in, n); - buf[n] = 0x80; - - if (n <= 55) { - copy4(buf+56, b); - copy64(M, buf); - mdfour64(state, M); - } else { - copy4(buf+120, b); - copy64(M, buf); - mdfour64(state, M); - copy64(M, buf+64); - mdfour64(state, M); - } - - for (i=0;i<128;i++) - buf[i] = 0; - copy64(M, buf); - - copy4(out, A); - copy4(out+4, B); - copy4(out+8, C); - copy4(out+12, D); -} - - diff --git a/source3/lib/md5.c b/source3/lib/md5.c deleted file mode 100644 index 2121b17047..0000000000 --- a/source3/lib/md5.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which - * will fill a supplied 16-byte array with the digest. - */ - -/* This code slightly modified to fit into Samba by - abartlet@samba.org Jun 2001 */ - -#include "includes.h" - -#include "md5.h" - -static void MD5Transform(uint32 buf[4], uint32 const in[16]); - -/* - * Note: this code is harmless on little-endian machines. - */ -static void byteReverse(unsigned char *buf, unsigned longs) -{ - uint32 t; - do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; - } while (--longs); -} - -/* - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void MD5Init(struct MD5Context *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; -} - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) -{ - register uint32 t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memmove(p, buf, len); - return; - } - memmove(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memmove(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memmove(ctx->in, buf, len); -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void MD5Final(unsigned char digest[16], struct MD5Context *ctx) -{ - unsigned int count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((uint32 *) ctx->in)[14] = ctx->bits[0]; - ((uint32 *) ctx->in)[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, (uint32 *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memmove(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ -static void MD5Transform(uint32 buf[4], uint32 const in[16]) -{ - register uint32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} diff --git a/source3/lib/memcache.c b/source3/lib/memcache.c index e1426bc811..9c892fedfa 100644 --- a/source3/lib/memcache.c +++ b/source3/lib/memcache.c @@ -18,7 +18,7 @@ */ #include "memcache.h" -#include "rbtree.h" +#include "../lib/util/rbtree.h" static struct memcache *global_cache; diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c index f436afc2ff..9f7f88f783 100644 --- a/source3/lib/messages_local.c +++ b/source3/lib/messages_local.c @@ -160,7 +160,7 @@ static NTSTATUS messaging_tdb_fetch(TDB_CONTEXT *msg_tdb, blob = data_blob_const(data.dptr, data.dsize); ndr_err = ndr_pull_struct_blob( - &blob, result, result, + &blob, result, NULL, result, (ndr_pull_flags_fn_t)ndr_pull_messaging_array); SAFE_FREE(data.dptr); @@ -203,7 +203,7 @@ static NTSTATUS messaging_tdb_store(TDB_CONTEXT *msg_tdb, } ndr_err = ndr_push_struct_blob( - &blob, mem_ctx, array, + &blob, mem_ctx, NULL, array, (ndr_push_flags_fn_t)ndr_push_messaging_array); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { diff --git a/source3/lib/netapi/examples/Makefile.in b/source3/lib/netapi/examples/Makefile.in index b1c1e59be7..090bc50dee 100644 --- a/source3/lib/netapi/examples/Makefile.in +++ b/source3/lib/netapi/examples/Makefile.in @@ -5,7 +5,7 @@ KRB5LIBS=@KRB5_LIBS@ LDAP_LIBS=@LDAP_LIBS@ LIBS=@LIBS@ -lnetapi -ltdb -ltalloc DEVELOPER_CFLAGS=@DEVELOPER_CFLAGS@ -FLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) +CCFLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) CC=@CC@ PICFLAG=@PICFLAG@ LDFLAGS=@PIE_LDFLAGS@ @LDFLAGS@ @@ -14,7 +14,7 @@ NETAPI_LIBS=$(LIBS) $(KRB5LIBS) $(LDAP_LIBS) CMDLINE_LIBS=$(NETAPI_LIBS) @POPTLIBS@ # Compile a source file. -COMPILE_CC = $(CC) -I. $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC = $(CC) -I. $(CCFLAGS) $(PICFLAG) -c $< -o $@ COMPILE = $(COMPILE_CC) PROGS = bin/getdc@EXEEXT@ \ @@ -140,187 +140,187 @@ FILEENUM_OBJ = file/file_enum.o $(CMDLINE_OBJ) bin/getdc@EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/dsgetdc@EXEEXT@: $(BINARY_PREREQS) $(DSGETDC_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(DSGETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(DSGETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/getjoinableous@EXEEXT@: $(BINARY_PREREQS) $(GETJOINABLEOUS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/rename_machine@EXEEXT@: $(BINARY_PREREQS) $(RENAMEMACHINE_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(RENAMEMACHINE_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(RENAMEMACHINE_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/netdomjoin@EXEEXT@: $(BINARY_PREREQS) $(NETDOMJOIN_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NETDOMJOIN_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(NETDOMJOIN_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) 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) + @$(CC) $(CCFLAGS) $(GTK_FLAGS) -o $@ $(NETDOMJOIN_GUI_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(GTK_LIBS) bin/user_add@EXEEXT@: $(BINARY_PREREQS) $(USERADD_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_del@EXEEXT@: $(BINARY_PREREQS) $(USERDEL_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_enum@EXEEXT@: $(BINARY_PREREQS) $(USERENUM_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_dispinfo@EXEEXT@: $(BINARY_PREREQS) $(USERDISPINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERDISPINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERDISPINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_chgpwd@EXEEXT@: $(BINARY_PREREQS) $(USERCHGPWD_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERCHGPWD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERCHGPWD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_getinfo@EXEEXT@: $(BINARY_PREREQS) $(USERGETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_setinfo@EXEEXT@: $(BINARY_PREREQS) $(USERSETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERSETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERSETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_modalsget@EXEEXT@: $(BINARY_PREREQS) $(USERMODALSGET_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERMODALSGET_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERMODALSGET_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_modalsset@EXEEXT@: $(BINARY_PREREQS) $(USERMODALSSET_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERMODALSSET_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERMODALSSET_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_getgroups@EXEEXT@: $(BINARY_PREREQS) $(USERGETGROUPS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERGETGROUPS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERGETGROUPS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_setgroups@EXEEXT@: $(BINARY_PREREQS) $(USERSETGROUPS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERSETGROUPS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERSETGROUPS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/user_getlocalgroups@EXEEXT@: $(BINARY_PREREQS) $(USERGETLOCALGROUPS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(USERGETLOCALGROUPS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(USERGETLOCALGROUPS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_add@EXEEXT@: $(BINARY_PREREQS) $(GROUPADD_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_del@EXEEXT@: $(BINARY_PREREQS) $(GROUPDEL_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_enum@EXEEXT@: $(BINARY_PREREQS) $(GROUPENUM_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_setinfo@EXEEXT@: $(BINARY_PREREQS) $(GROUPSETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPSETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPSETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_getinfo@EXEEXT@: $(BINARY_PREREQS) $(GROUPGETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_adduser@EXEEXT@: $(BINARY_PREREQS) $(GROUPADDUSER_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPADDUSER_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPADDUSER_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_deluser@EXEEXT@: $(BINARY_PREREQS) $(GROUPDELUSER_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPDELUSER_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPDELUSER_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_getusers@EXEEXT@: $(BINARY_PREREQS) $(GROUPGETUSERS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPGETUSERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPGETUSERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/group_setusers@EXEEXT@: $(BINARY_PREREQS) $(GROUPSETUSERS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(GROUPSETUSERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(GROUPSETUSERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_add@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPADD_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_del@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPDEL_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_getinfo@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPGETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_setinfo@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPSETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPSETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPSETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_enum@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPENUM_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_addmembers@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPADDMEMBERS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPADDMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPADDMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_delmembers@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPDELMEMBERS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPDELMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPDELMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_setmembers@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPSETMEMBERS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPSETMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPSETMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/localgroup_getmembers@EXEEXT@: $(BINARY_PREREQS) $(LOCALGROUPGETMEMBERS_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCALGROUPGETMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(LOCALGROUPGETMEMBERS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/remote_tod@EXEEXT@: $(BINARY_PREREQS) $(REMOTETOD_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(REMOTETOD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(REMOTETOD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/server_getinfo@EXEEXT@: $(BINARY_PREREQS) $(SERVERGETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SERVERGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(SERVERGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/share_add@EXEEXT@: $(BINARY_PREREQS) $(SHAREADD_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHAREADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(SHAREADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/share_del@EXEEXT@: $(BINARY_PREREQS) $(SHAREDEL_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHAREDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(SHAREDEL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/share_enum@EXEEXT@: $(BINARY_PREREQS) $(SHAREENUM_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHAREENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(SHAREENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/share_getinfo@EXEEXT@: $(BINARY_PREREQS) $(SHAREGETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHAREGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(SHAREGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/share_setinfo@EXEEXT@: $(BINARY_PREREQS) $(SHARESETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHARESETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(SHARESETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/file_close@EXEEXT@: $(BINARY_PREREQS) $(FILECLOSE_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(FILECLOSE_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(FILECLOSE_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/file_getinfo@EXEEXT@: $(BINARY_PREREQS) $(FILEGETINFO_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(FILEGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(FILEGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) bin/file_enum@EXEEXT@: $(BINARY_PREREQS) $(FILEENUM_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(FILEENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(FILEENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) clean: -rm -f $(PROGS) diff --git a/source3/lib/netapi/examples/user/user_modalsset.c b/source3/lib/netapi/examples/user/user_modalsset.c index 57e1ef70ea..c6958a9012 100644 --- a/source3/lib/netapi/examples/user/user_modalsset.c +++ b/source3/lib/netapi/examples/user/user_modalsset.c @@ -95,6 +95,7 @@ int main(int argc, const char **argv) case 1: case 2: case 3: + break; case 1001: u1001.usrmod1001_min_passwd_len = 0; buffer = (uint8_t *)&u1001; diff --git a/source3/lib/netapi/file.c b/source3/lib/netapi/file.c index 036af32f38..0d66be0eb1 100644 --- a/source3/lib/netapi/file.c +++ b/source3/lib/netapi/file.c @@ -47,7 +47,8 @@ WERROR NetFileClose_r(struct libnetapi_ctx *ctx, r->in.server_name, r->in.fileid, &werr); - if (!W_ERROR_IS_OK(werr)) { + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); goto done; } diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 07a6544af1..76c0d0be2a 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -58,6 +58,10 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx, r->in.domain_name, (const char **)r->out.buffer, &werr); + + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); + } done: return werr; diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c index c3fccb4840..8dba4b8838 100644 --- a/source3/lib/netapi/group.c +++ b/source3/lib/netapi/group.c @@ -1224,7 +1224,7 @@ WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, } if (r->out.total_entries) { - *r->out.total_entries = domain_info->info2.num_groups; + *r->out.total_entries = domain_info->general.num_groups; } status = rpccli_samr_QueryDisplayInfo2(pipe_cli, diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c index 25a3427bc1..5e738e1262 100644 --- a/source3/lib/netapi/localgroup.c +++ b/source3/lib/netapi/localgroup.c @@ -822,7 +822,7 @@ WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx, } if (r->out.total_entries) { - *r->out.total_entries += builtin_info->info2.num_aliases; + *r->out.total_entries += builtin_info->general.num_aliases; } status = rpccli_samr_QueryDomainInfo(pipe_cli, ctx, @@ -835,7 +835,7 @@ WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx, } if (r->out.total_entries) { - *r->out.total_entries += domain_info->info2.num_aliases; + *r->out.total_entries += domain_info->general.num_aliases; } status = rpccli_samr_EnumDomainAliases(pipe_cli, ctx, diff --git a/source3/lib/netapi/share.c b/source3/lib/netapi/share.c index 1d0e1810f1..e6aed36064 100644 --- a/source3/lib/netapi/share.c +++ b/source3/lib/netapi/share.c @@ -271,7 +271,8 @@ WERROR NetShareDel_r(struct libnetapi_ctx *ctx, r->in.net_name, r->in.reserved, &werr); - if (!W_ERROR_IS_OK(werr)) { + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); goto done; } diff --git a/source3/lib/netapi/tests/Makefile.in b/source3/lib/netapi/tests/Makefile.in index d3f0663908..659f82c9d8 100644 --- a/source3/lib/netapi/tests/Makefile.in +++ b/source3/lib/netapi/tests/Makefile.in @@ -2,7 +2,7 @@ KRB5LIBS=@KRB5_LIBS@ LDAP_LIBS=@LDAP_LIBS@ LIBS=@LIBS@ -lnetapi -ltdb -ltalloc DEVELOPER_CFLAGS=@DEVELOPER_CFLAGS@ -FLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) +CCFLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS) CC=@CC@ PICFLAG=@PICFLAG@ LDFLAGS=@PIE_LDFLAGS@ @LDFLAGS@ @@ -11,7 +11,7 @@ NETAPI_LIBS=$(LIBS) $(KRB5LIBS) $(LDAP_LIBS) CMDLINE_LIBS=$(NETAPI_LIBS) @POPTLIBS@ # Compile a source file. -COMPILE_CC = $(CC) -I. $(FLAGS) $(PICFLAG) -c $< -o $@ +COMPILE_CC = $(CC) -I. $(CCFLAGS) $(PICFLAG) -c $< -o $@ COMPILE = $(COMPILE_CC) PROGS = bin/netapitest@EXEEXT@ @@ -44,11 +44,11 @@ bin/.dummy: CMDLINE_OBJ = common.o NETAPIBUFFER_OBJ = netapibuffer.o -NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o $(CMDLINE_OBJ) +NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o netfile.o $(CMDLINE_OBJ) bin/netapitest@EXEEXT@: $(BINARY_PREREQS) $(NETAPITEST_OBJ) @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NETAPITEST_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) + @$(CC) $(CCFLAGS) -o $@ $(NETAPITEST_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS) clean: -rm -f $(PROGS) diff --git a/source3/lib/netapi/tests/common.h b/source3/lib/netapi/tests/common.h index 5a320321ba..9320840909 100644 --- a/source3/lib/netapi/tests/common.h +++ b/source3/lib/netapi/tests/common.h @@ -41,6 +41,8 @@ NET_API_STATUS netapitest_display(struct libnetapi_ctx *ctx, const char *hostname); NET_API_STATUS netapitest_share(struct libnetapi_ctx *ctx, const char *hostname); +NET_API_STATUS netapitest_file(struct libnetapi_ctx *ctx, + const char *hostname); #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) diff --git a/source3/lib/netapi/tests/netapitest.c b/source3/lib/netapi/tests/netapitest.c index 87144020f5..4a38f721d8 100644 --- a/source3/lib/netapi/tests/netapitest.c +++ b/source3/lib/netapi/tests/netapitest.c @@ -84,6 +84,11 @@ int main(int argc, const char **argv) goto out; } + status = netapitest_file(ctx, hostname); + if (status) { + goto out; + } + out: if (status != 0) { printf("testsuite failed with: %s\n", diff --git a/source3/lib/netapi/tests/netfile.c b/source3/lib/netapi/tests/netfile.c new file mode 100644 index 0000000000..bee3c2ed5e --- /dev/null +++ b/source3/lib/netapi/tests/netfile.c @@ -0,0 +1,145 @@ +/* + * Unix SMB/CIFS implementation. + * NetFile testsuite + * 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 . + */ + +#include +#include +#include +#include +#include + +#include + +#include "common.h" + +static NET_API_STATUS test_netfileenum(const char *hostname, + uint32_t level) +{ + NET_API_STATUS status; + uint32_t entries_read = 0; + uint32_t total_entries = 0; + uint32_t resume_handle = 0; + uint8_t *buffer = NULL; + int i; + + struct FILE_INFO_2 *i2 = NULL; + struct FILE_INFO_3 *i3 = NULL; + + printf("testing NetFileEnum level %d\n", level); + + do { + status = NetFileEnum(hostname, + NULL, + NULL, + level, + &buffer, + (uint32_t)-1, + &entries_read, + &total_entries, + &resume_handle); + if (status == 0 || status == ERROR_MORE_DATA) { + switch (level) { + case 2: + i2 = (struct FILE_INFO_2 *)buffer; + break; + case 3: + i3 = (struct FILE_INFO_3 *)buffer; + break; + default: + return -1; + } + + for (i=0; iusriX_workstations, infoX->usriX_usr_comment, &zero_parameters, - 0, + infoX->usriX_user_id, infoX->usriX_primary_group_id, infoX->usriX_flags, fields_present, zero_logon_hours, - 0, - 0, + infoX->usriX_bad_pw_count, + infoX->usriX_num_logons, infoX->usriX_country_code, + infoX->usriX_code_page, 0, 0, - 0, - 0); + infoX->usriX_password_expired); } /**************************************************************** @@ -132,6 +132,7 @@ static NTSTATUS construct_USER_INFO_X(uint32_t level, struct USER_INFO_0 *u0 = NULL; struct USER_INFO_1 *u1 = NULL; struct USER_INFO_2 *u2 = NULL; + struct USER_INFO_3 *u3 = NULL; struct USER_INFO_1003 *u1003 = NULL; struct USER_INFO_1006 *u1006 = NULL; struct USER_INFO_1007 *u1007 = NULL; @@ -193,6 +194,37 @@ static NTSTATUS construct_USER_INFO_X(uint32_t level, uX->usriX_country_code = u2->usri2_country_code; uX->usriX_code_page = u2->usri2_code_page; break; + case 3: + u3 = (struct USER_INFO_3 *)buffer; + uX->usriX_name = u3->usri3_name; + uX->usriX_password_age = u3->usri3_password_age; + uX->usriX_priv = u3->usri3_priv; + uX->usriX_home_dir = u3->usri3_home_dir; + uX->usriX_comment = u3->usri3_comment; + uX->usriX_flags = u3->usri3_flags; + uX->usriX_script_path = u3->usri3_script_path; + uX->usriX_auth_flags = u3->usri3_auth_flags; + uX->usriX_full_name = u3->usri3_full_name; + uX->usriX_usr_comment = u3->usri3_usr_comment; + uX->usriX_parms = u3->usri3_parms; + uX->usriX_workstations = u3->usri3_workstations; + uX->usriX_last_logon = u3->usri3_last_logon; + uX->usriX_last_logoff = u3->usri3_last_logoff; + uX->usriX_acct_expires = u3->usri3_acct_expires; + uX->usriX_max_storage = u3->usri3_max_storage; + uX->usriX_units_per_week= u3->usri3_units_per_week; + uX->usriX_logon_hours = u3->usri3_logon_hours; + uX->usriX_bad_pw_count = u3->usri3_bad_pw_count; + uX->usriX_num_logons = u3->usri3_num_logons; + uX->usriX_logon_server = u3->usri3_logon_server; + uX->usriX_country_code = u3->usri3_country_code; + uX->usriX_code_page = u3->usri3_code_page; + uX->usriX_user_id = u3->usri3_user_id; + uX->usriX_primary_group_id = u3->usri3_primary_group_id; + uX->usriX_profile = u3->usri3_profile; + uX->usriX_home_dir_drive = u3->usri3_home_dir_drive; + uX->usriX_password_expired = u3->usri3_password_expired; + break; case 1003: u1003 = (struct USER_INFO_1003 *)buffer; uX->usriX_password = u1003->usri1003_password; @@ -237,7 +269,6 @@ static NTSTATUS construct_USER_INFO_X(uint32_t level, u1053 = (struct USER_INFO_1053 *)buffer; uX->usriX_home_dir_drive = u1053->usri1053_home_dir_drive; break; - case 3: case 4: default: return NT_STATUS_INVALID_INFO_CLASS; @@ -1753,9 +1784,17 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx, user_mask = SAMR_USER_ACCESS_SET_ATTRIBUTES | SAMR_USER_ACCESS_GET_GROUPS; break; + case 3: + user_mask = STD_RIGHT_READ_CONTROL_ACCESS | + STD_RIGHT_WRITE_DAC_ACCESS | + SAMR_USER_ACCESS_GET_GROUPS | + SAMR_USER_ACCESS_SET_PASSWORD | + SAMR_USER_ACCESS_SET_ATTRIBUTES | + SAMR_USER_ACCESS_GET_ATTRIBUTES | + SAMR_USER_ACCESS_SET_LOC_COM; + break; case 1: case 2: - case 3: case 4: case 21: case 22: diff --git a/source3/lib/nss_wrapper/config.mk b/source3/lib/nss_wrapper/config.mk deleted file mode 100644 index 9751d2bf73..0000000000 --- a/source3/lib/nss_wrapper/config.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################## -# Start SUBSYSTEM NSS_WRAPPER -[LIBRARY::NSS_WRAPPER] -VERSION = 0.0.1 -SO_VERSION = 0 -DESCRIPTION = Wrapper library for testing nss calls without being root -PUBLIC_HEADERS = nss_wrapper.h -OBJ_FILES = nss_wrapper.o -# End SUBSYSTEM NSS_WRAPPER -############################## diff --git a/source3/lib/packet.c b/source3/lib/packet.c index e0486165f3..e4cab6ba87 100644 --- a/source3/lib/packet.c +++ b/source3/lib/packet.c @@ -21,7 +21,7 @@ struct packet_context { int fd; - struct data_blob in, out; + DATA_BLOB in, out; }; /* @@ -120,16 +120,16 @@ NTSTATUS packet_fd_read_sync(struct packet_context *ctx) } bool packet_handler(struct packet_context *ctx, - bool (*full_req)(const struct data_blob *data, + bool (*full_req)(const DATA_BLOB *data, size_t *length, void *private_data), - NTSTATUS (*callback)(const struct data_blob *data, + NTSTATUS (*callback)(const DATA_BLOB *data, void *private_data), void *private_data, NTSTATUS *status) { size_t length; - struct data_blob data; + DATA_BLOB data; if (!full_req(&ctx->in, &length, private_data)) { return False; @@ -211,7 +211,7 @@ NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...) va_start(ap, num_blobs); for (i=0; iout.data+ctx->out.length, blob.data, blob.length); ctx->out.length += blob.length; diff --git a/source3/lib/readline.c b/source3/lib/readline.c index 254f55c86a..cafb5a9f62 100644 --- a/source3/lib/readline.c +++ b/source3/lib/readline.c @@ -45,6 +45,24 @@ # define RL_COMPLETION_CAST #endif /* HAVE_NEW_LIBREADLINE */ +static bool smb_rl_done; + +#if HAVE_LIBREADLINE +/* + * MacOS/X does not have rl_done in readline.h, but + * readline.so has it + */ +extern int rl_done; +#endif + +void smb_readline_done(void) +{ + smb_rl_done = true; +#if HAVE_LIBREADLINE + rl_done = 1; +#endif +} + /**************************************************************************** Display the prompt and wait for input. Call callback() regularly ****************************************************************************/ @@ -69,7 +87,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) return NULL; } - while (1) { + while (!smb_rl_done) { timeout.tv_sec = 5; timeout.tv_usec = 0; @@ -87,6 +105,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) callback(); } } + return NULL; } /**************************************************************************** diff --git a/source3/lib/replace/Makefile.in b/source3/lib/replace/Makefile.in deleted file mode 100644 index c989835a8d..0000000000 --- a/source3/lib/replace/Makefile.in +++ /dev/null @@ -1,63 +0,0 @@ -#!gmake -# -CC = @CC@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = @bindir@ -includedir = @includedir@ -libdir = @libdir@ -VPATH = @libreplacedir@ -srcdir = @srcdir@ -builddir = @builddir@ -INSTALL = @INSTALL@ -LIBS = @LIBS@ - -.PHONY: test all showflags install installcheck clean distclean realdistclean - -CFLAGS=-I. @CFLAGS@ -LDFLAGS=@LDFLAGS@ - -OBJS = @LIBREPLACEOBJ@ - -all: showflags libreplace.a testsuite - -showflags: - @echo 'libreplace will be compiled with flags:' - @echo ' CC = $(CC)' - @echo ' CFLAGS = $(CFLAGS)' - @echo ' LDFLAGS= $(LDFLAGS)' - @echo ' LIBS = $(LIBS)' - -install: all - mkdir -p $(libdir) - $(INSTALL) libreplace.a $(libdir) - -libreplace.a: $(OBJS) - ar -rcsv $@ $(OBJS) - -test: all - ./testsuite - -installcheck: install test - -TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o - -testsuite: libreplace.a $(TEST_OBJS) - $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS) - -.c.o: - @echo Compiling $*.c - @mkdir -p `dirname $@` - @$(CC) $(CFLAGS) -c $< -o $@ - -clean: - rm -f *.o test/*.o *.a testsuite - rm -f testfile.dat - -distclean: clean - rm -f *~ */*~ - rm -f config.log config.status config.h config.cache - rm -f Makefile - -realdistclean: distclean - rm -f configure config.h.in diff --git a/source3/lib/replace/configure.ac b/source3/lib/replace/configure.ac deleted file mode 100644 index 81997e09b7..0000000000 --- a/source3/lib/replace/configure.ac +++ /dev/null @@ -1,30 +0,0 @@ -AC_PREREQ(2.50) -AC_INIT(replace.c) -AC_CONFIG_SRCDIR([replace.c]) -AC_CONFIG_HEADER(config.h) - -CFLAGS="$CFLAGS -I$srcdir" - -AC_LIBREPLACE_ALL_CHECKS -AC_LIBREPLACE_NETWORK_CHECKS - -if test "$ac_cv_prog_gcc" = yes; then - CFLAGS="$CFLAGS -Wall" - CFLAGS="$CFLAGS -W" - CFLAGS="$CFLAGS -Wshadow" - CFLAGS="$CFLAGS -Wstrict-prototypes" - CFLAGS="$CFLAGS -Wpointer-arith" - CFLAGS="$CFLAGS -Wcast-qual" - CFLAGS="$CFLAGS -Wcast-align" - CFLAGS="$CFLAGS -Wwrite-strings" - CFLAGS="$CFLAGS -Werror-implicit-function-declaration" - CFLAGS="$CFLAGS -Wformat=2" - CFLAGS="$CFLAGS -Wno-format-y2k" -fi - -LIBS="${LIBREPLACE_NETWORK_LIBS}" -AC_SUBST(LIBS) - -AC_SUBST(LDFLAGS) - -AC_OUTPUT(Makefile) diff --git a/source3/lib/replace/libreplace.m4 b/source3/lib/replace/libreplace.m4 deleted file mode 100644 index 71fa041672..0000000000 --- a/source3/lib/replace/libreplace.m4 +++ /dev/null @@ -1,303 +0,0 @@ -AC_DEFUN_ONCE(AC_LIBREPLACE_LOCATION_CHECKS, -[ -echo "LIBREPLACE_LOCATION_CHECKS: START" - -dnl find the libreplace sources. This is meant to work both for -dnl libreplace standalone builds, and builds of packages using libreplace -libreplacedir="" -libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace" -for d in $libreplacepaths; do - if test -f "$d/replace.c"; then - libreplacedir="$d" - AC_SUBST(libreplacedir) - break; - fi -done -if test x"$libreplacedir" = "x"; then - AC_MSG_ERROR([cannot find libreplace in $libreplacepaths]) -fi -LIBREPLACEOBJ="replace.o" -AC_SUBST(LIBREPLACEOBJ) - -AC_CANONICAL_BUILD -AC_CANONICAL_HOST -AC_CANONICAL_TARGET - -echo "LIBREPLACE_LOCATION_CHECKS: END" -]) dnl end AC_LIBREPLACE_LOCATION_CHECKS - - -AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS, -[ -echo "LIBREPLACE_BROKEN_CHECKS: START" - -dnl find the libreplace sources. This is meant to work both for -dnl libreplace standalone builds, and builds of packages using libreplace -libreplacedir="" -for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do - if test -f "$d/replace.c"; then - libreplacedir="$d" - AC_SUBST(libreplacedir) - break; - fi -done -LIBREPLACEOBJ="replace.o" -AC_SUBST(LIBREPLACEOBJ) - -LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o" - -AC_TYPE_SIGNAL -AC_TYPE_UID_T -AC_TYPE_MODE_T -AC_TYPE_OFF_T -AC_TYPE_SIZE_T -AC_TYPE_PID_T -AC_STRUCT_ST_RDEV -AC_CHECK_TYPE(ino_t,unsigned) -AC_CHECK_TYPE(loff_t,off_t) -AC_CHECK_TYPE(offset_t,loff_t) - -AC_FUNC_MEMCMP - -AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp) - -AC_CHECK_HEADERS(stdbool.h stdint.h sys/select.h) -AC_CHECK_HEADERS(setjmp.h) - -LIBREPLACE_PROVIDE_HEADER([stdint.h]) -LIBREPLACE_PROVIDE_HEADER([stdbool.h]) - -AC_CHECK_TYPE(bool, -[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, -[ -AC_INCLUDES_DEFAULT -#ifdef HAVE_STDBOOL_H -#include -#endif] -) - -AC_CHECK_TYPE(_Bool, -[AC_DEFINE(HAVE__Bool, 1, [Whether the _Bool type is available])],, -[ -AC_INCLUDES_DEFAULT -#ifdef HAVE_STDBOOL_H -#include -#endif] -) - -AC_CACHE_CHECK([for working mmap],libreplace_cv_HAVE_MMAP,[ -AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], - libreplace_cv_HAVE_MMAP=yes,libreplace_cv_HAVE_MMAP=no,libreplace_cv_HAVE_MMAP=cross)]) -if test x"$libreplace_cv_HAVE_MMAP" = x"yes"; then - AC_DEFINE(HAVE_MMAP,1,[Whether mmap works]) -fi - - -AC_CHECK_HEADERS(sys/syslog.h syslog.h) -AC_CHECK_HEADERS(sys/time.h time.h) -AC_CHECK_HEADERS(stdarg.h vararg.h) -AC_CHECK_HEADERS(sys/mount.h mntent.h) -AC_CHECK_HEADERS(stropts.h) - -AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) -AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) -AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) -AC_CHECK_FUNCS(isatty) -AC_HAVE_DECL(setresuid, [#include ]) -AC_HAVE_DECL(setresgid, [#include ]) -AC_HAVE_DECL(errno, [#include ]) - -AC_CACHE_CHECK([for secure mkstemp],libreplace_cv_HAVE_SECURE_MKSTEMP,[ -AC_TRY_RUN([#include -#include -#include -#include -main() { - struct stat st; - char tpl[20]="/tmp/test.XXXXXX"; - int fd = mkstemp(tpl); - if (fd == -1) exit(1); - unlink(tpl); - if (fstat(fd, &st) != 0) exit(1); - if ((st.st_mode & 0777) != 0600) exit(1); - exit(0); -}], -libreplace_cv_HAVE_SECURE_MKSTEMP=yes, -libreplace_cv_HAVE_SECURE_MKSTEMP=no, -libreplace_cv_HAVE_SECURE_MKSTEMP=cross)]) -if test x"$libreplace_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then - AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) -fi - -dnl Provided by snprintf.c: -AC_CHECK_HEADERS(stdio.h strings.h) -AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf]) -AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) - -AC_CACHE_CHECK([for C99 vsnprintf],libreplace_cv_HAVE_C99_VSNPRINTF,[ -AC_TRY_RUN([ -#include -#include -#include -#include -void foo(const char *format, ...) { - va_list ap; - int len; - char buf[20]; - long long l = 1234567890; - l *= 100; - - va_start(ap, format); - len = vsnprintf(buf, 0, format, ap); - va_end(ap); - if (len != 5) exit(1); - - va_start(ap, format); - len = vsnprintf(0, 0, format, ap); - va_end(ap); - if (len != 5) exit(2); - - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3); - - if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4); - if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5); - if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6); - if (snprintf(buf, 20, "%s", 0) < 3) exit(7); - - exit(0); -} -main() { foo("hello"); } -], -libreplace_cv_HAVE_C99_VSNPRINTF=yes,libreplace_cv_HAVE_C99_VSNPRINTF=no,libreplace_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$libreplace_cv_HAVE_C99_VSNPRINTF" = x"yes"; then - AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) -fi - - -dnl VA_COPY -AC_CACHE_CHECK([for va_copy],libreplace_cv_HAVE_VA_COPY,[ -AC_TRY_LINK([#include -va_list ap1,ap2;], [va_copy(ap1,ap2);], -libreplace_cv_HAVE_VA_COPY=yes,libreplace_cv_HAVE_VA_COPY=no)]) -if test x"$libreplace_cv_HAVE_VA_COPY" = x"yes"; then - AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) -fi - -if test x"$libreplace_cv_HAVE_VA_COPY" != x"yes"; then -AC_CACHE_CHECK([for __va_copy],libreplace_cv_HAVE___VA_COPY,[ -AC_TRY_LINK([#include -va_list ap1,ap2;], [__va_copy(ap1,ap2);], -libreplace_cv_HAVE___VA_COPY=yes,libreplace_cv_HAVE___VA_COPY=no)]) -if test x"$libreplace_cv_HAVE___VA_COPY" = x"yes"; then - AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) -fi -fi - -dnl __FUNCTION__ macro -AC_CACHE_CHECK([for __FUNCTION__ macro],libreplace_cv_HAVE_FUNCTION_MACRO,[ -AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], -libreplace_cv_HAVE_FUNCTION_MACRO=yes,libreplace_cv_HAVE_FUNCTION_MACRO=no)]) -if test x"$libreplace_cv_HAVE_FUNCTION_MACRO" = x"yes"; then - AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) -else - dnl __func__ macro - AC_CACHE_CHECK([for __func__ macro],libreplace_cv_HAVE_func_MACRO,[ - AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], - libreplace_cv_HAVE_func_MACRO=yes,libreplace_cv_HAVE_func_MACRO=no)]) - if test x"$libreplace_cv_HAVE_func_MACRO" = x"yes"; then - AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) - fi -fi - -AC_CHECK_HEADERS([sys/param.h limits.h]) - -AC_CHECK_TYPE(comparison_fn_t, -[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) - -AC_HAVE_DECL(setenv, [#include ]) -AC_CHECK_FUNCS(setenv unsetenv) - -AC_CHECK_FUNCS(strnlen) -AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) - -# this test disabled as we don't actually need __VA_ARGS__ yet -AC_TRY_CPP([ -#define eprintf(...) fprintf(stderr, __VA_ARGS__) -eprintf("bla", "bar"); -], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available])) - - -AC_CACHE_CHECK([for sig_atomic_t type],libreplace_cv_sig_atomic_t, [ - AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include ],[sig_atomic_t i = 0], - libreplace_cv_sig_atomic_t=yes,libreplace_cv_sig_atomic_t=no)]) -if test x"$libreplace_cv_sig_atomic_t" = x"yes"; then - AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) -fi - - -AC_CACHE_CHECK([for O_DIRECT flag to open(2)],libreplace_cv_HAVE_OPEN_O_DIRECT,[ -AC_TRY_COMPILE([ -#include -#ifdef HAVE_FCNTL_H -#include -#endif], -[int fd = open("/dev/null", O_DIRECT);], -libreplace_cv_HAVE_OPEN_O_DIRECT=yes,libreplace_cv_HAVE_OPEN_O_DIRECT=no)]) -if test x"$libreplace_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then - AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT]) -fi - - -dnl Check if the C compiler understands volatile (it should, being ANSI). -AC_CACHE_CHECK([that the C compiler understands volatile],libreplace_cv_volatile, [ - AC_TRY_COMPILE([#include ],[volatile int i = 0], - libreplace_cv_volatile=yes,libreplace_cv_volatile=no)]) -if test x"$libreplace_cv_volatile" = x"yes"; then - AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) -fi - -m4_include(system/config.m4) - -m4_include(dlfcn.m4) -m4_include(getpass.m4) -m4_include(strptime.m4) -m4_include(win32.m4) -m4_include(timegm.m4) -m4_include(repdir.m4) - -AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) - -echo "LIBREPLACE_BROKEN_CHECKS: END" -]) dnl end AC_LIBREPLACE_BROKEN_CHECKS - -AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START, -[ -#LIBREPLACE_ALL_CHECKS: START" -]) -AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END, -[ -#LIBREPLACE_ALL_CHECKS: END" -]) -m4_define(AC_LIBREPLACE_ALL_CHECKS, -[ -AC__LIBREPLACE_ALL_CHECKS_START -AC_LIBREPLACE_LOCATION_CHECKS -AC_LIBREPLACE_CC_CHECKS -AC_LIBREPLACE_BROKEN_CHECKS -AC__LIBREPLACE_ALL_CHECKS_END -CFLAGS="$CFLAGS -I$libreplacedir" -]) - -m4_include(libreplace_cc.m4) -m4_include(libreplace_ld.m4) -m4_include(libreplace_network.m4) -m4_include(libreplace_macros.m4) - -m4_ifndef([AC_USE_SYSTEM_EXTENSIONS],[m4_include(autoconf-2.60.m4)]) diff --git a/source3/lib/replace/samba.m4 b/source3/lib/replace/samba.m4 deleted file mode 100644 index 07c4d38887..0000000000 --- a/source3/lib/replace/samba.m4 +++ /dev/null @@ -1,35 +0,0 @@ -AC_LIBREPLACE_BROKEN_CHECKS -AC_LIBREPLACE_NETWORK_CHECKS - -SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) -SMB_ENABLE(LIBREPLACE_EXT) - -SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}]) -SMB_ENABLE(LIBREPLACE_NETWORK) - -# remove leading ./ -LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'` - -# remove leading srcdir .. we are looking for the relative -# path within the samba source tree or wherever libreplace is. -# We need to make sure the object is not forced to end up in -# the source directory because we might be using a separate -# build directory. -LIBREPLACE_DIR=`echo ${LIBREPLACE_DIR} | sed -e "s|^$srcdir/||g"` - -LIBREPLACE_OBJS="" -for obj in ${LIBREPLACEOBJ}; do - LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}" -done - -SMB_SUBSYSTEM(LIBREPLACE, - [${LIBREPLACE_OBJS}], - [LIBREPLACE_EXT LIBREPLACE_NETWORK], - [-Ilib/replace]) - -LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'` - -SMB_SUBSYSTEM(LIBREPLACE_HOSTCC, - [${LIBREPLACE_HOSTCC_OBJS}], - [], - [-Ilib/replace]) diff --git a/source3/lib/replace/system/passwd.h b/source3/lib/replace/system/passwd.h deleted file mode 100644 index cad3197ccb..0000000000 --- a/source3/lib/replace/system/passwd.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef _system_passwd_h -#define _system_passwd_h - -/* - Unix SMB/CIFS implementation. - - passwd system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -/* this needs to be included before nss_wrapper.h on some systems */ -#include - -#ifdef HAVE_PWD_H -#include -#endif -#ifdef HAVE_GRP_H -#include -#endif -#ifdef HAVE_SYS_PRIV_H -#include -#endif -#ifdef HAVE_SYS_ID_H -#include -#endif - -#ifdef HAVE_CRYPT_H -#include -#endif - -#ifdef HAVE_SHADOW_H -#include -#endif - -#ifdef HAVE_SYS_SECURITY_H -#include -#include -#define PASSWORD_LENGTH 16 -#endif /* HAVE_SYS_SECURITY_H */ - -#ifdef HAVE_GETPWANAM -#include -#include -#include -#endif - -#ifdef HAVE_COMPAT_H -#include -#endif - -#ifdef REPLACE_GETPASS -#if defined(REPLACE_GETPASS_BY_GETPASSPHRASE) -#define getpass(prompt) getpassphrase(prompt) -#else -#define getpass(prompt) rep_getpass(prompt) -char *rep_getpass(const char *prompt); -#endif -#endif - -#ifndef NGROUPS_MAX -#define NGROUPS_MAX 32 /* Guess... */ -#endif - -/* what is the longest significant password available on your system? - Knowing this speeds up password searches a lot */ -#ifndef PASSWORD_LENGTH -#define PASSWORD_LENGTH 8 -#endif - -#if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS) -#define OSF1_ENH_SEC 1 -#endif - -#ifndef ALLOW_CHANGE_PASSWORD -#if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID)) -#define ALLOW_CHANGE_PASSWORD 1 -#endif -#endif - -#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID) -#define ULTRIX_AUTH 1 -#endif - -#ifdef NSS_WRAPPER -#ifndef NSS_WRAPPER_NOT_REPLACE -#define NSS_WRAPPER_REPLACE -#endif -#include "lib/nss_wrapper/nss_wrapper.h" -#endif - -#endif diff --git a/source3/lib/replace/test/testsuite.c b/source3/lib/replace/test/testsuite.c deleted file mode 100644 index 1e8290906e..0000000000 --- a/source3/lib/replace/test/testsuite.c +++ /dev/null @@ -1,1080 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - libreplace tests - - Copyright (C) Jelmer Vernooij 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "replace.h" - -/* - we include all the system/ include files here so that libreplace tests - them in the build farm -*/ -#include "system/capability.h" -#include "system/dir.h" -#include "system/filesys.h" -#include "system/glob.h" -#include "system/iconv.h" -#include "system/locale.h" -#include "system/network.h" -#include "system/passwd.h" -#include "system/readline.h" -#include "system/select.h" -#include "system/shmem.h" -#include "system/syslog.h" -#include "system/terminal.h" -#include "system/time.h" -#include "system/wait.h" -#include "system/aio.h" - -#define TESTFILE "testfile.dat" - -/* - test ftruncate() function - */ -static int test_ftruncate(void) -{ - struct stat st; - int fd; - const int size = 1234; - printf("test: ftruncate\n"); - unlink(TESTFILE); - fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); - if (fd == -1) { - printf("failure: ftruncate [\n" - "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno)); - return false; - } - if (ftruncate(fd, size) != 0) { - printf("failure: ftruncate [\n%s\n]\n", strerror(errno)); - return false; - } - if (fstat(fd, &st) != 0) { - printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno)); - return false; - } - if (st.st_size != size) { - printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n", - (int)st.st_size, size); - return false; - } - unlink(TESTFILE); - printf("success: ftruncate\n"); - return true; -} - -/* - test strlcpy() function. - see http://www.gratisoft.us/todd/papers/strlcpy.html - */ -static int test_strlcpy(void) -{ - char buf[4]; - const struct { - const char *src; - size_t result; - } tests[] = { - { "abc", 3 }, - { "abcdef", 6 }, - { "abcd", 4 }, - { "", 0 }, - { NULL, 0 } - }; - int i; - printf("test: strlcpy\n"); - for (i=0;tests[i].src;i++) { - if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("failure: strlcpy [\ntest %d failed\n]\n", i); - return false; - } - } - printf("success: strlcpy\n"); - return true; -} - -static int test_strlcat(void) -{ - char tmp[10]; - printf("test: strlcat\n"); - strlcpy(tmp, "", sizeof(tmp)); - if (strlcat(tmp, "bla", 3) != 3) { - printf("failure: strlcat [\ninvalid return code\n]\n"); - return false; - } - if (strcmp(tmp, "bl") != 0) { - printf("failure: strlcat [\nexpected \"bl\", got \"%s\"\n]\n", - tmp); - return false; - } - - strlcpy(tmp, "da", sizeof(tmp)); - if (strlcat(tmp, "me", 4) != 4) { - printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n", - tmp); - return false; - } - - printf("success: strlcat\n"); - return true; -} - -static int test_mktime(void) -{ - /* FIXME */ - return true; -} - -static int test_initgroups(void) -{ - /* FIXME */ - return true; -} - -static int test_memmove(void) -{ - /* FIXME */ - return true; -} - -static int test_strdup(void) -{ - char *x; - printf("test: strdup\n"); - x = strdup("bla"); - if (strcmp("bla", x) != 0) { - printf("failure: strdup [\nfailed: expected \"bla\", got \"%s\"\n]\n", - x); - return false; - } - free(x); - printf("success: strdup\n"); - return true; -} - -static int test_setlinebuf(void) -{ - printf("test: setlinebuf\n"); - setlinebuf(stdout); - printf("success: setlinebuf\n"); - return true; -} - -static int test_vsyslog(void) -{ - /* FIXME */ - return true; -} - -static int test_timegm(void) -{ - /* FIXME */ - return true; -} - -static int test_setenv(void) -{ -#define TEST_SETENV(key, value, overwrite, result) do { \ - int _ret; \ - char *_v; \ - _ret = setenv(key, value, overwrite); \ - if (_ret != 0) { \ - printf("failure: setenv [\n" \ - "setenv(%s, %s, %d) failed\n" \ - "]\n", \ - key, value, overwrite); \ - return false; \ - } \ - _v=getenv(key); \ - if (!_v) { \ - printf("failure: setenv [\n" \ - "getenv(%s) returned NULL\n" \ - "]\n", \ - key); \ - return false; \ - } \ - if (strcmp(result, _v) != 0) { \ - printf("failure: setenv [\n" \ - "getenv(%s): '%s' != '%s'\n" \ - "]\n", \ - key, result, _v); \ - return false; \ - } \ -} while(0) - -#define TEST_UNSETENV(key) do { \ - char *_v; \ - unsetenv(key); \ - _v=getenv(key); \ - if (_v) { \ - printf("failure: setenv [\n" \ - "getenv(%s): NULL != '%s'\n" \ - "]\n", \ - SETENVTEST_KEY, _v); \ - return false; \ - } \ -} while (0) - -#define SETENVTEST_KEY "SETENVTESTKEY" -#define SETENVTEST_VAL "SETENVTESTVAL" - - printf("test: setenv\n"); - TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"1", 0, SETENVTEST_VAL"1"); - TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"2", 0, SETENVTEST_VAL"1"); - TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3"); - TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4"); - TEST_UNSETENV(SETENVTEST_KEY); - TEST_UNSETENV(SETENVTEST_KEY); - TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5"); - TEST_UNSETENV(SETENVTEST_KEY); - TEST_UNSETENV(SETENVTEST_KEY); - printf("success: setenv\n"); - return true; -} - -static int test_strndup(void) -{ - char *x; - printf("test: strndup\n"); - x = strndup("bla", 0); - if (strcmp(x, "") != 0) { - printf("failure: strndup [\ninvalid\n]\n"); - return false; - } - free(x); - x = strndup("bla", 2); - if (strcmp(x, "bl") != 0) { - printf("failure: strndup [\ninvalid\n]\n"); - return false; - } - free(x); - x = strndup("bla", 10); - if (strcmp(x, "bla") != 0) { - printf("failure: strndup [\ninvalid\n]\n"); - return false; - } - free(x); - printf("success: strndup\n"); - return true; -} - -static int test_strnlen(void) -{ - printf("test: strnlen\n"); - if (strnlen("bla", 2) != 2) { - printf("failure: strnlen [\nunexpected length\n]\n"); - return false; - } - - if (strnlen("some text\n", 0) != 0) { - printf("failure: strnlen [\nunexpected length\n]\n"); - return false; - } - - if (strnlen("some text", 20) != 9) { - printf("failure: strnlen [\nunexpected length\n]\n"); - return false; - } - - printf("success: strnlen\n"); - return true; -} - -static int test_waitpid(void) -{ - /* FIXME */ - return true; -} - -static int test_seteuid(void) -{ - /* FIXME */ - return true; -} - -static int test_setegid(void) -{ - /* FIXME */ - return true; -} - -static int test_asprintf(void) -{ - char *x; - printf("test: asprintf\n"); - if (asprintf(&x, "%d", 9) != 1) { - printf("failure: asprintf [\ngenerate asprintf\n]\n"); - return false; - } - if (strcmp(x, "9") != 0) { - printf("failure: asprintf [\ngenerate asprintf\n]\n"); - return false; - } - if (asprintf(&x, "dat%s", "a") != 4) { - printf("failure: asprintf [\ngenerate asprintf\n]\n"); - return false; - } - if (strcmp(x, "data") != 0) { - printf("failure: asprintf [\ngenerate asprintf\n]\n"); - return false; - } - printf("success: asprintf\n"); - return true; -} - -static int test_snprintf(void) -{ - char tmp[10]; - printf("test: snprintf\n"); - if (snprintf(tmp, 3, "foo%d", 9) != 4) { - printf("failure: snprintf [\nsnprintf return code failed\n]\n"); - return false; - } - - if (strcmp(tmp, "fo") != 0) { - printf("failure: snprintf [\nsnprintf failed\n]\n"); - return false; - } - - printf("success: snprintf\n"); - return true; -} - -static int test_vasprintf(void) -{ - /* FIXME */ - return true; -} - -static int test_vsnprintf(void) -{ - /* FIXME */ - return true; -} - -static int test_opendir(void) -{ - /* FIXME */ - return true; -} - -extern int test_readdir_os2_delete(void); - -static int test_readdir(void) -{ - printf("test: readdir\n"); - if (test_readdir_os2_delete() != 0) { - return false; - } - printf("success: readdir\n"); - return true; -} - -static int test_telldir(void) -{ - /* FIXME */ - return true; -} - -static int test_seekdir(void) -{ - /* FIXME */ - return true; -} - -static int test_dlopen(void) -{ - /* FIXME: test dlopen, dlsym, dlclose, dlerror */ - return true; -} - - -static int test_chroot(void) -{ - /* FIXME: chroot() */ - return true; -} - -static int test_bzero(void) -{ - /* FIXME: bzero */ - return true; -} - -static int test_strerror(void) -{ - /* FIXME */ - return true; -} - -static int test_errno(void) -{ - printf("test: errno\n"); - errno = 3; - if (errno != 3) { - printf("failure: errno [\nerrno failed\n]\n"); - return false; - } - - printf("success: errno\n"); - return true; -} - -static int test_mkdtemp(void) -{ - /* FIXME */ - return true; -} - -static int test_mkstemp(void) -{ - /* FIXME */ - return true; -} - -static int test_pread(void) -{ - /* FIXME */ - return true; -} - -static int test_pwrite(void) -{ - /* FIXME */ - return true; -} - -static int test_getpass(void) -{ - /* FIXME */ - return true; -} - -static int test_inet_ntoa(void) -{ - /* FIXME */ - return true; -} - -#define TEST_STRTO_X(type,fmt,func,str,base,res,diff,rrnoo) do {\ - type _v; \ - char _s[64]; \ - char *_p = NULL;\ - char *_ep = NULL; \ - strlcpy(_s, str, sizeof(_s));\ - if (diff >= 0) { \ - _ep = &_s[diff]; \ - } \ - errno = 0; \ - _v = func(_s, &_p, base); \ - if (errno != rrnoo) { \ - printf("failure: %s [\n" \ - "\t%s\n" \ - "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \ - "\terrno: %d != %d\n" \ - "]\n", \ - __STRING(func), __location__, __STRING(func), \ - str, diff, base, res, _v, rrnoo, errno); \ - return false; \ - } else if (_v != res) { \ - printf("failure: %s [\n" \ - "\t%s\n" \ - "\t%s(\"%s\",%d,%d): " fmt " != " fmt "\n" \ - "]\n", \ - __STRING(func), __location__, __STRING(func), \ - str, diff, base, res, _v); \ - return false; \ - } else if (_p != _ep) { \ - printf("failure: %s [\n" \ - "\t%s\n" \ - "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \ - "\tptr: %p - %p = %d != %d\n" \ - "]\n", \ - __STRING(func), __location__, __STRING(func), \ - str, diff, base, res, _v, _ep, _p, (int)(diff - (_ep - _p)), diff); \ - return false; \ - } \ -} while (0) - -static int test_strtoll(void) -{ - printf("test: strtoll\n"); - -#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(long long int, "%lld", strtoll,str,base,res,diff,errnoo) - - TEST_STRTOLL("15", 10, 15LL, 2, 0); - TEST_STRTOLL(" 15", 10, 15LL, 4, 0); - TEST_STRTOLL("15", 0, 15LL, 2, 0); - TEST_STRTOLL(" 15 ", 0, 15LL, 3, 0); - TEST_STRTOLL("+15", 10, 15LL, 3, 0); - TEST_STRTOLL(" +15", 10, 15LL, 5, 0); - TEST_STRTOLL("+15", 0, 15LL, 3, 0); - TEST_STRTOLL(" +15 ", 0, 15LL, 4, 0); - TEST_STRTOLL("-15", 10, -15LL, 3, 0); - TEST_STRTOLL(" -15", 10, -15LL, 5, 0); - TEST_STRTOLL("-15", 0, -15LL, 3, 0); - TEST_STRTOLL(" -15 ", 0, -15LL, 4, 0); - TEST_STRTOLL("015", 10, 15LL, 3, 0); - TEST_STRTOLL(" 015", 10, 15LL, 5, 0); - TEST_STRTOLL("015", 0, 13LL, 3, 0); - TEST_STRTOLL(" 015", 0, 13LL, 5, 0); - TEST_STRTOLL("0x15", 10, 0LL, 1, 0); - TEST_STRTOLL(" 0x15", 10, 0LL, 3, 0); - TEST_STRTOLL("0x15", 0, 21LL, 4, 0); - TEST_STRTOLL(" 0x15", 0, 21LL, 6, 0); - - TEST_STRTOLL("10", 16, 16LL, 2, 0); - TEST_STRTOLL(" 10 ", 16, 16LL, 4, 0); - TEST_STRTOLL("0x10", 16, 16LL, 4, 0); - TEST_STRTOLL("0x10", 0, 16LL, 4, 0); - TEST_STRTOLL(" 0x10 ", 0, 16LL, 5, 0); - TEST_STRTOLL("+10", 16, 16LL, 3, 0); - TEST_STRTOLL(" +10 ", 16, 16LL, 5, 0); - TEST_STRTOLL("+0x10", 16, 16LL, 5, 0); - TEST_STRTOLL("+0x10", 0, 16LL, 5, 0); - TEST_STRTOLL(" +0x10 ", 0, 16LL, 6, 0); - TEST_STRTOLL("-10", 16, -16LL, 3, 0); - TEST_STRTOLL(" -10 ", 16, -16LL, 5, 0); - TEST_STRTOLL("-0x10", 16, -16LL, 5, 0); - TEST_STRTOLL("-0x10", 0, -16LL, 5, 0); - TEST_STRTOLL(" -0x10 ", 0, -16LL, 6, 0); - TEST_STRTOLL("010", 16, 16LL, 3, 0); - TEST_STRTOLL(" 010 ", 16, 16LL, 5, 0); - TEST_STRTOLL("-010", 16, -16LL, 4, 0); - - TEST_STRTOLL("11", 8, 9LL, 2, 0); - TEST_STRTOLL("011", 8, 9LL, 3, 0); - TEST_STRTOLL("011", 0, 9LL, 3, 0); - TEST_STRTOLL("-11", 8, -9LL, 3, 0); - TEST_STRTOLL("-011", 8, -9LL, 4, 0); - TEST_STRTOLL("-011", 0, -9LL, 4, 0); - - TEST_STRTOLL("011", 8, 9LL, 3, 0); - TEST_STRTOLL("011", 0, 9LL, 3, 0); - TEST_STRTOLL("-11", 8, -9LL, 3, 0); - TEST_STRTOLL("-011", 8, -9LL, 4, 0); - TEST_STRTOLL("-011", 0, -9LL, 4, 0); - - TEST_STRTOLL("Text", 0, 0LL, 0, 0); - - TEST_STRTOLL("9223372036854775807", 10, 9223372036854775807LL, 19, 0); - TEST_STRTOLL("9223372036854775807", 0, 9223372036854775807LL, 19, 0); - TEST_STRTOLL("9223372036854775808", 0, 9223372036854775807LL, 19, ERANGE); - TEST_STRTOLL("9223372036854775808", 10, 9223372036854775807LL, 19, ERANGE); - TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LL, 18, 0); - TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 18, 0); - TEST_STRTOLL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 16, 0); - TEST_STRTOLL("0x8000000000000000", 0, 9223372036854775807LL, 18, ERANGE); - TEST_STRTOLL("0x8000000000000000", 16, 9223372036854775807LL, 18, ERANGE); - TEST_STRTOLL("80000000000000000", 16, 9223372036854775807LL, 17, ERANGE); - TEST_STRTOLL("0777777777777777777777", 0, 9223372036854775807LL, 22, 0); - TEST_STRTOLL("0777777777777777777777", 8, 9223372036854775807LL, 22, 0); - TEST_STRTOLL("777777777777777777777", 8, 9223372036854775807LL, 21, 0); - TEST_STRTOLL("01000000000000000000000", 0, 9223372036854775807LL, 23, ERANGE); - TEST_STRTOLL("01000000000000000000000", 8, 9223372036854775807LL, 23, ERANGE); - TEST_STRTOLL("1000000000000000000000", 8, 9223372036854775807LL, 22, ERANGE); - - TEST_STRTOLL("-9223372036854775808", 10, -9223372036854775807LL -1, 20, 0); - TEST_STRTOLL("-9223372036854775808", 0, -9223372036854775807LL -1, 20, 0); - TEST_STRTOLL("-9223372036854775809", 0, -9223372036854775807LL -1, 20, ERANGE); - TEST_STRTOLL("-9223372036854775809", 10, -9223372036854775807LL -1, 20, ERANGE); - TEST_STRTOLL("-0x8000000000000000", 0, -9223372036854775807LL -1, 19, 0); - TEST_STRTOLL("-0x8000000000000000", 16, -9223372036854775807LL -1, 19, 0); - TEST_STRTOLL("-8000000000000000", 16, -9223372036854775807LL -1, 17, 0); - TEST_STRTOLL("-0x8000000000000001", 0, -9223372036854775807LL -1, 19, ERANGE); - TEST_STRTOLL("-0x8000000000000001", 16, -9223372036854775807LL -1, 19, ERANGE); - TEST_STRTOLL("-80000000000000001", 16, -9223372036854775807LL -1, 18, ERANGE); - TEST_STRTOLL("-01000000000000000000000",0, -9223372036854775807LL -1, 24, 0); - TEST_STRTOLL("-01000000000000000000000",8, -9223372036854775807LL -1, 24, 0); - TEST_STRTOLL("-1000000000000000000000", 8, -9223372036854775807LL -1, 23, 0); - TEST_STRTOLL("-01000000000000000000001",0, -9223372036854775807LL -1, 24, ERANGE); - TEST_STRTOLL("-01000000000000000000001",8, -9223372036854775807LL -1, 24, ERANGE); - TEST_STRTOLL("-1000000000000000000001", 8, -9223372036854775807LL -1, 23, ERANGE); - - printf("success: strtoll\n"); - return true; -} - -static int test_strtoull(void) -{ - printf("test: strtoull\n"); - -#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(long long unsigned int,"%llu",strtoull,str,base,res,diff,errnoo) - - TEST_STRTOULL("15", 10, 15LLU, 2, 0); - TEST_STRTOULL(" 15", 10, 15LLU, 4, 0); - TEST_STRTOULL("15", 0, 15LLU, 2, 0); - TEST_STRTOULL(" 15 ", 0, 15LLU, 3, 0); - TEST_STRTOULL("+15", 10, 15LLU, 3, 0); - TEST_STRTOULL(" +15", 10, 15LLU, 5, 0); - TEST_STRTOULL("+15", 0, 15LLU, 3, 0); - TEST_STRTOULL(" +15 ", 0, 15LLU, 4, 0); - TEST_STRTOULL("-15", 10, 18446744073709551601LLU, 3, 0); - TEST_STRTOULL(" -15", 10, 18446744073709551601LLU, 5, 0); - TEST_STRTOULL("-15", 0, 18446744073709551601LLU, 3, 0); - TEST_STRTOULL(" -15 ", 0, 18446744073709551601LLU, 4, 0); - TEST_STRTOULL("015", 10, 15LLU, 3, 0); - TEST_STRTOULL(" 015", 10, 15LLU, 5, 0); - TEST_STRTOULL("015", 0, 13LLU, 3, 0); - TEST_STRTOULL(" 015", 0, 13LLU, 5, 0); - TEST_STRTOULL("0x15", 10, 0LLU, 1, 0); - TEST_STRTOULL(" 0x15", 10, 0LLU, 3, 0); - TEST_STRTOULL("0x15", 0, 21LLU, 4, 0); - TEST_STRTOULL(" 0x15", 0, 21LLU, 6, 0); - - TEST_STRTOULL("10", 16, 16LLU, 2, 0); - TEST_STRTOULL(" 10 ", 16, 16LLU, 4, 0); - TEST_STRTOULL("0x10", 16, 16LLU, 4, 0); - TEST_STRTOULL("0x10", 0, 16LLU, 4, 0); - TEST_STRTOULL(" 0x10 ", 0, 16LLU, 5, 0); - TEST_STRTOULL("+10", 16, 16LLU, 3, 0); - TEST_STRTOULL(" +10 ", 16, 16LLU, 5, 0); - TEST_STRTOULL("+0x10", 16, 16LLU, 5, 0); - TEST_STRTOULL("+0x10", 0, 16LLU, 5, 0); - TEST_STRTOULL(" +0x10 ", 0, 16LLU, 6, 0); - TEST_STRTOULL("-10", 16, -16LLU, 3, 0); - TEST_STRTOULL(" -10 ", 16, -16LLU, 5, 0); - TEST_STRTOULL("-0x10", 16, -16LLU, 5, 0); - TEST_STRTOULL("-0x10", 0, -16LLU, 5, 0); - TEST_STRTOULL(" -0x10 ", 0, -16LLU, 6, 0); - TEST_STRTOULL("010", 16, 16LLU, 3, 0); - TEST_STRTOULL(" 010 ", 16, 16LLU, 5, 0); - TEST_STRTOULL("-010", 16, -16LLU, 4, 0); - - TEST_STRTOULL("11", 8, 9LLU, 2, 0); - TEST_STRTOULL("011", 8, 9LLU, 3, 0); - TEST_STRTOULL("011", 0, 9LLU, 3, 0); - TEST_STRTOULL("-11", 8, -9LLU, 3, 0); - TEST_STRTOULL("-011", 8, -9LLU, 4, 0); - TEST_STRTOULL("-011", 0, -9LLU, 4, 0); - - TEST_STRTOULL("011", 8, 9LLU, 3, 0); - TEST_STRTOULL("011", 0, 9LLU, 3, 0); - TEST_STRTOULL("-11", 8, -9LLU, 3, 0); - TEST_STRTOULL("-011", 8, -9LLU, 4, 0); - TEST_STRTOULL("-011", 0, -9LLU, 4, 0); - - TEST_STRTOULL("Text", 0, 0LLU, 0, 0); - - TEST_STRTOULL("9223372036854775807", 10, 9223372036854775807LLU, 19, 0); - TEST_STRTOULL("9223372036854775807", 0, 9223372036854775807LLU, 19, 0); - TEST_STRTOULL("9223372036854775808", 0, 9223372036854775808LLU, 19, 0); - TEST_STRTOULL("9223372036854775808", 10, 9223372036854775808LLU, 19, 0); - TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LLU, 18, 0); - TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 18, 0); - TEST_STRTOULL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 16, 0); - TEST_STRTOULL("0x8000000000000000", 0, 9223372036854775808LLU, 18, 0); - TEST_STRTOULL("0x8000000000000000", 16, 9223372036854775808LLU, 18, 0); - TEST_STRTOULL("8000000000000000", 16, 9223372036854775808LLU, 16, 0); - TEST_STRTOULL("0777777777777777777777", 0, 9223372036854775807LLU, 22, 0); - TEST_STRTOULL("0777777777777777777777", 8, 9223372036854775807LLU, 22, 0); - TEST_STRTOULL("777777777777777777777", 8, 9223372036854775807LLU, 21, 0); - TEST_STRTOULL("01000000000000000000000",0, 9223372036854775808LLU, 23, 0); - TEST_STRTOULL("01000000000000000000000",8, 9223372036854775808LLU, 23, 0); - TEST_STRTOULL("1000000000000000000000", 8, 9223372036854775808LLU, 22, 0); - - TEST_STRTOULL("-9223372036854775808", 10, 9223372036854775808LLU, 20, 0); - TEST_STRTOULL("-9223372036854775808", 0, 9223372036854775808LLU, 20, 0); - TEST_STRTOULL("-9223372036854775809", 0, 9223372036854775807LLU, 20, 0); - TEST_STRTOULL("-9223372036854775809", 10, 9223372036854775807LLU, 20, 0); - TEST_STRTOULL("-0x8000000000000000", 0, 9223372036854775808LLU, 19, 0); - TEST_STRTOULL("-0x8000000000000000", 16, 9223372036854775808LLU, 19, 0); - TEST_STRTOULL("-8000000000000000", 16, 9223372036854775808LLU, 17, 0); - TEST_STRTOULL("-0x8000000000000001", 0, 9223372036854775807LLU, 19, 0); - TEST_STRTOULL("-0x8000000000000001", 16, 9223372036854775807LLU, 19, 0); - TEST_STRTOULL("-8000000000000001", 16, 9223372036854775807LLU, 17, 0); - TEST_STRTOULL("-01000000000000000000000",0, 9223372036854775808LLU, 24, 0); - TEST_STRTOULL("-01000000000000000000000",8, 9223372036854775808LLU, 24, 0); - TEST_STRTOULL("-1000000000000000000000",8, 9223372036854775808LLU, 23, 0); - TEST_STRTOULL("-01000000000000000000001",0, 9223372036854775807LLU, 24, 0); - TEST_STRTOULL("-01000000000000000000001",8, 9223372036854775807LLU, 24, 0); - TEST_STRTOULL("-1000000000000000000001",8, 9223372036854775807LLU, 23, 0); - - TEST_STRTOULL("18446744073709551615", 0, 18446744073709551615LLU, 20, 0); - TEST_STRTOULL("18446744073709551615", 10, 18446744073709551615LLU, 20, 0); - TEST_STRTOULL("18446744073709551616", 0, 18446744073709551615LLU, 20, ERANGE); - TEST_STRTOULL("18446744073709551616", 10, 18446744073709551615LLU, 20, ERANGE); - TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 0, 18446744073709551615LLU, 18, 0); - TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 18, 0); - TEST_STRTOULL("FFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 16, 0); - TEST_STRTOULL("0x10000000000000000", 0, 18446744073709551615LLU, 19, ERANGE); - TEST_STRTOULL("0x10000000000000000", 16, 18446744073709551615LLU, 19, ERANGE); - TEST_STRTOULL("10000000000000000", 16, 18446744073709551615LLU, 17, ERANGE); - TEST_STRTOULL("01777777777777777777777",0, 18446744073709551615LLU, 23, 0); - TEST_STRTOULL("01777777777777777777777",8, 18446744073709551615LLU, 23, 0); - TEST_STRTOULL("1777777777777777777777", 8, 18446744073709551615LLU, 22, 0); - TEST_STRTOULL("02000000000000000000000",0, 18446744073709551615LLU, 23, ERANGE); - TEST_STRTOULL("02000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); - TEST_STRTOULL("2000000000000000000000", 8, 18446744073709551615LLU, 22, ERANGE); - - TEST_STRTOULL("-18446744073709551615", 0, 1LLU, 21, 0); - TEST_STRTOULL("-18446744073709551615", 10, 1LLU, 21, 0); - TEST_STRTOULL("-18446744073709551616", 0, 18446744073709551615LLU, 21, ERANGE); - TEST_STRTOULL("-18446744073709551616", 10, 18446744073709551615LLU, 21, ERANGE); - TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 0, 1LLU, 19, 0); - TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 16, 1LLU, 19, 0); - TEST_STRTOULL("-FFFFFFFFFFFFFFFF", 16, 1LLU, 17, 0); - TEST_STRTOULL("-0x10000000000000000", 0, 18446744073709551615LLU, 20, ERANGE); - TEST_STRTOULL("-0x10000000000000000", 16, 18446744073709551615LLU, 20, ERANGE); - TEST_STRTOULL("-10000000000000000", 16, 18446744073709551615LLU, 18, ERANGE); - TEST_STRTOULL("-01777777777777777777777",0, 1LLU, 24, 0); - TEST_STRTOULL("-01777777777777777777777",8, 1LLU, 24, 0); - TEST_STRTOULL("-1777777777777777777777",8, 1LLU, 23, 0); - TEST_STRTOULL("-02000000000000000000000",0, 18446744073709551615LLU, 24, ERANGE); - TEST_STRTOULL("-02000000000000000000000",8, 18446744073709551615LLU, 24, ERANGE); - TEST_STRTOULL("-2000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); - - printf("success: strtoull\n"); - return true; -} - -/* -FIXME: -Types: -bool -socklen_t -uint_t -uint{8,16,32,64}_t -int{8,16,32,64}_t -intptr_t - -Constants: -PATH_NAME_MAX -UINT{16,32,64}_MAX -INT32_MAX -*/ - -static int test_va_copy(void) -{ - /* FIXME */ - return true; -} - -static int test_FUNCTION(void) -{ - printf("test: FUNCTION\n"); - if (strcmp(__FUNCTION__, "test_FUNCTION") != 0) { - printf("failure: FAILURE [\nFAILURE invalid\n]\n"); - return false; - } - printf("success: FUNCTION\n"); - return true; -} - -static int test_MIN(void) -{ - printf("test: MIN\n"); - if (MIN(20, 1) != 1) { - printf("failure: MIN [\nMIN invalid\n]\n"); - return false; - } - if (MIN(1, 20) != 1) { - printf("failure: MIN [\nMIN invalid\n]\n"); - return false; - } - printf("success: MIN\n"); - return true; -} - -static int test_MAX(void) -{ - printf("test: MAX\n"); - if (MAX(20, 1) != 20) { - printf("failure: MAX [\nMAX invalid\n]\n"); - return false; - } - if (MAX(1, 20) != 20) { - printf("failure: MAX [\nMAX invalid\n]\n"); - return false; - } - printf("success: MAX\n"); - return true; -} - -static int test_socketpair(void) -{ - int sock[2]; - char buf[20]; - - printf("test: socketpair\n"); - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) { - printf("failure: socketpair [\n" - "socketpair() failed\n" - "]\n"); - return false; - } - - if (write(sock[1], "automatisch", 12) == -1) { - printf("failure: socketpair [\n" - "write() failed: %s\n" - "]\n", strerror(errno)); - return false; - } - - if (read(sock[0], buf, 12) == -1) { - printf("failure: socketpair [\n" - "read() failed: %s\n" - "]\n", strerror(errno)); - return false; - } - - if (strcmp(buf, "automatisch") != 0) { - printf("failure: socketpair [\n" - "expected: automatisch, got: %s\n" - "]\n", buf); - return false; - } - - printf("success: socketpair\n"); - - return true; -} - -extern int libreplace_test_strptime(void); - -static int test_strptime(void) -{ - return libreplace_test_strptime(); -} - -extern int getifaddrs_test(void); - -static int test_getifaddrs(void) -{ - - printf("test: getifaddrs\n"); - - if (getifaddrs_test() != 0) { - printf("failure: getifaddrs\n"); - return false; - } - - printf("success: getifaddrs\n"); - return true; -} - -static int test_utime(void) -{ - struct utimbuf u; - struct stat st1, st2, st3; - int fd; - - printf("test: utime\n"); - unlink(TESTFILE); - - fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); - if (fd == -1) { - printf("failure: utime [\n" - "creating '%s' failed - %s\n]\n", - TESTFILE, strerror(errno)); - return false; - } - - if (fstat(fd, &st1) != 0) { - printf("failure: utime [\n" - "fstat (1) failed - %s\n]\n", - strerror(errno)); - return false; - } - - u.actime = st1.st_atime + 300; - u.modtime = st1.st_mtime - 300; - if (utime(TESTFILE, &u) != 0) { - printf("failure: utime [\n" - "utime(&u) failed - %s\n]\n", - strerror(errno)); - return false; - } - - if (fstat(fd, &st2) != 0) { - printf("failure: utime [\n" - "fstat (2) failed - %s\n]\n", - strerror(errno)); - return false; - } - - if (utime(TESTFILE, NULL) != 0) { - printf("failure: utime [\n" - "utime(NULL) failed - %s\n]\n", - strerror(errno)); - return false; - } - - if (fstat(fd, &st3) != 0) { - printf("failure: utime [\n" - "fstat (3) failed - %s\n]\n", - strerror(errno)); - return false; - } - -#define CMP_VAL(a,c,b) do { \ - if (a c b) { \ - printf("failure: utime [\n" \ - "%s: %s(%d) %s %s(%d)\n]\n", \ - __location__, \ - #a, (int)a, #c, #b, (int)b); \ - return false; \ - } \ -} while(0) -#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b) -#define GREATER_VAL(a,b) CMP_VAL(a,<=,b) -#define LESSER_VAL(a,b) CMP_VAL(a,>=,b) - - EQUAL_VAL(st2.st_atime, st1.st_atime + 300); - EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); - LESSER_VAL(st3.st_atime, st2.st_atime); - GREATER_VAL(st3.st_mtime, st2.st_mtime); - -#undef CMP_VAL -#undef EQUAL_VAL -#undef GREATER_VAL -#undef LESSER_VAL - - unlink(TESTFILE); - printf("success: utime\n"); - return true; -} - -static int test_utimes(void) -{ - struct timeval tv[2]; - struct stat st1, st2; - int fd; - - printf("test: utimes\n"); - unlink(TESTFILE); - - fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); - if (fd == -1) { - printf("failure: utimes [\n" - "creating '%s' failed - %s\n]\n", - TESTFILE, strerror(errno)); - return false; - } - - if (fstat(fd, &st1) != 0) { - printf("failure: utimes [\n" - "fstat (1) failed - %s\n]\n", - strerror(errno)); - return false; - } - - ZERO_STRUCT(tv); - tv[0].tv_sec = st1.st_atime + 300; - tv[1].tv_sec = st1.st_mtime - 300; - if (utimes(TESTFILE, tv) != 0) { - printf("failure: utimes [\n" - "utimes(tv) failed - %s\n]\n", - strerror(errno)); - return false; - } - - if (fstat(fd, &st2) != 0) { - printf("failure: utimes [\n" - "fstat (2) failed - %s\n]\n", - strerror(errno)); - return false; - } - -#define EQUAL_VAL(a,b) do { \ - if (a != b) { \ - printf("failure: utimes [\n" \ - "%s: %s(%d) != %s(%d)\n]\n", \ - __location__, \ - #a, (int)a, #b, (int)b); \ - return false; \ - } \ -} while(0) - - EQUAL_VAL(st2.st_atime, st1.st_atime + 300); - EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); - -#undef EQUAL_VAL - - unlink(TESTFILE); - printf("success: utimes\n"); - return true; -} - -struct torture_context; -bool torture_local_replace(struct torture_context *ctx) -{ - bool ret = true; - ret &= test_ftruncate(); - ret &= test_strlcpy(); - ret &= test_strlcat(); - ret &= test_mktime(); - ret &= test_initgroups(); - ret &= test_memmove(); - ret &= test_strdup(); - ret &= test_setlinebuf(); - ret &= test_vsyslog(); - ret &= test_timegm(); - ret &= test_setenv(); - ret &= test_strndup(); - ret &= test_strnlen(); - ret &= test_waitpid(); - ret &= test_seteuid(); - ret &= test_setegid(); - ret &= test_asprintf(); - ret &= test_snprintf(); - ret &= test_vasprintf(); - ret &= test_vsnprintf(); - ret &= test_opendir(); - ret &= test_readdir(); - ret &= test_telldir(); - ret &= test_seekdir(); - ret &= test_dlopen(); - ret &= test_chroot(); - ret &= test_bzero(); - ret &= test_strerror(); - ret &= test_errno(); - ret &= test_mkdtemp(); - ret &= test_mkstemp(); - ret &= test_pread(); - ret &= test_pwrite(); - ret &= test_getpass(); - ret &= test_inet_ntoa(); - ret &= test_strtoll(); - ret &= test_strtoull(); - ret &= test_va_copy(); - ret &= test_FUNCTION(); - ret &= test_MIN(); - ret &= test_MAX(); - ret &= test_socketpair(); - ret &= test_strptime(); - ret &= test_getifaddrs(); - ret &= test_utime(); - ret &= test_utimes(); - - return ret; -} - -#if _SAMBA_BUILD_<4 -int main(void) -{ - bool ret = torture_local_replace(NULL); - if (ret) - return 0; - return -1; -} -#endif diff --git a/source3/lib/secace.c b/source3/lib/secace.c index 8760a6109a..9f5a0c02ba 100644 --- a/source3/lib/secace.c +++ b/source3/lib/secace.c @@ -55,7 +55,7 @@ void sec_ace_copy(SEC_ACE *ace_dest, SEC_ACE *ace_src) ********************************************************************/ void init_sec_ace(SEC_ACE *t, const DOM_SID *sid, enum security_ace_type type, - uint32 mask, uint8 flag) + uint32_t mask, uint8 flag) { t->type = type; t->flags = flag; diff --git a/source3/lib/secdesc.c b/source3/lib/secdesc.c index 44ae23271e..52ff067d6a 100644 --- a/source3/lib/secdesc.c +++ b/source3/lib/secdesc.c @@ -249,7 +249,7 @@ NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx, enum ndr_err_code ndr_err; ndr_err = ndr_push_struct_blob( - &blob, mem_ctx, secdesc, + &blob, mem_ctx, NULL, secdesc, (ndr_push_flags_fn_t)ndr_push_security_descriptor); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -285,7 +285,7 @@ NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len, blob = data_blob_const(data, len); ndr_err = ndr_pull_struct_blob( - &blob, result, result, + &blob, result, NULL, result, (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -512,7 +512,7 @@ SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, if (!inherit) continue; - init_sec_access(&new_ace->access_mask, ace->access_mask); + new_ace->access_mask = ace->access_mask; init_sec_ace(new_ace, &ace->trustee, ace->type, new_ace->access_mask, new_flags); @@ -546,14 +546,3 @@ SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, return sdb; } - -/******************************************************************* - Sets up a SEC_ACCESS structure. -********************************************************************/ - -void init_sec_access(uint32 *t, uint32 mask) -{ - *t = mask; -} - - diff --git a/source3/lib/select.c b/source3/lib/select.c index c3da6a9bba..14e59257ba 100644 --- a/source3/lib/select.c +++ b/source3/lib/select.c @@ -30,7 +30,7 @@ static pid_t initialised; static int select_pipe[2]; -static VOLATILE unsigned pipe_written, pipe_read; +static volatile unsigned pipe_written, pipe_read; /******************************************************************* Call this from all Samba signal handlers if you want to avoid a @@ -161,7 +161,7 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf errorfds_buf = *errorfds; if (ptval && (errno == EINTR)) { struct timeval now_time; - SMB_BIG_INT tdif; + int64_t tdif; GetTimeOfDay(&now_time); tdif = usec_time_diff(&end_time, &now_time); diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 33f66ca47f..298655e181 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -124,7 +124,7 @@ static bool share_info_db_init(void) SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access) { - SEC_ACCESS sa; + uint32_t sa; SEC_ACE ace; SEC_ACL *psa = NULL; SEC_DESC *psd = NULL; @@ -132,7 +132,7 @@ SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def se_map_generic(&spec_access, &file_generic_mapping); - init_sec_access(&sa, def_access | spec_access ); + sa = (def_access | spec_access ); init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &ace)) != NULL) { @@ -332,7 +332,7 @@ bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, SEC_DESC **ppsd) } for (i = 0; i < num_aces; i++) { - SEC_ACCESS sa; + uint32_t sa; uint32 g_access; uint32 s_access; DOM_SID sid; @@ -380,7 +380,7 @@ bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, SEC_DESC **ppsd) pacl++; /* Go past any ',' */ se_map_generic(&s_access, &file_generic_mapping); - init_sec_access(&sa, g_access | s_access ); + sa = (g_access | s_access); init_sec_ace(&ace_list[i], &sid, type, sa, 0); } diff --git a/source3/lib/signal.c b/source3/lib/signal.c deleted file mode 100644 index 4b1c95eb77..0000000000 --- a/source3/lib/signal.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - Unix SMB/CIFS implementation. - signal handling functions - - Copyright (C) Andrew Tridgell 1998 - - 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 . -*/ - -#include "includes.h" - -/**************************************************************************** - Catch child exits and reap the child zombie status. -****************************************************************************/ - -static void sig_cld(int signum) -{ - while (sys_waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0) - ; - - /* - * Turns out it's *really* important not to - * restore the signal handler here if we have real POSIX - * signal handling. If we do, then we get the signal re-delivered - * immediately - hey presto - instant loop ! JRA. - */ - -#if !defined(HAVE_SIGACTION) - CatchSignal(SIGCLD, sig_cld); -#endif -} - -/**************************************************************************** -catch child exits - leave status; -****************************************************************************/ - -static void sig_cld_leave_status(int signum) -{ - /* - * Turns out it's *really* important not to - * restore the signal handler here if we have real POSIX - * signal handling. If we do, then we get the signal re-delivered - * immediately - hey presto - instant loop ! JRA. - */ - -#if !defined(HAVE_SIGACTION) - CatchSignal(SIGCLD, sig_cld_leave_status); -#endif -} - -/******************************************************************* - Block sigs. -********************************************************************/ - -void BlockSignals(bool block,int signum) -{ -#ifdef HAVE_SIGPROCMASK - sigset_t set; - sigemptyset(&set); - sigaddset(&set,signum); - sigprocmask(block?SIG_BLOCK:SIG_UNBLOCK,&set,NULL); -#elif defined(HAVE_SIGBLOCK) - if (block) { - sigblock(sigmask(signum)); - } else { - sigsetmask(siggetmask() & ~sigmask(signum)); - } -#else - /* yikes! This platform can't block signals? */ - static int done; - if (!done) { - DEBUG(0,("WARNING: No signal blocking available\n")); - done=1; - } -#endif -} - -/******************************************************************* - Catch a signal. This should implement the following semantics: - - 1) The handler remains installed after being called. - 2) The signal should be blocked during handler execution. -********************************************************************/ - -void (*CatchSignal(int signum,void (*handler)(int )))(int) -{ -#ifdef HAVE_SIGACTION - struct sigaction act; - struct sigaction oldact; - - ZERO_STRUCT(act); - - act.sa_handler = handler; -#ifdef SA_RESTART - /* - * We *want* SIGALRM to interrupt a system call. - */ - if(signum != SIGALRM) - act.sa_flags = SA_RESTART; -#endif - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask,signum); - sigaction(signum,&act,&oldact); - return oldact.sa_handler; -#else /* !HAVE_SIGACTION */ - /* FIXME: need to handle sigvec and systems with broken signal() */ - return signal(signum, handler); -#endif -} - -/******************************************************************* - Ignore SIGCLD via whatever means is necessary for this OS. -********************************************************************/ - -void CatchChild(void) -{ - CatchSignal(SIGCLD, sig_cld); -} - -/******************************************************************* - Catch SIGCLD but leave the child around so it's status can be reaped. -********************************************************************/ - -void CatchChildLeaveStatus(void) -{ - CatchSignal(SIGCLD, sig_cld_leave_status); -} diff --git a/source3/lib/smbconf/smbconf_txt.c b/source3/lib/smbconf/smbconf_txt.c index 1a29f40164..1393a098d5 100644 --- a/source3/lib/smbconf/smbconf_txt.c +++ b/source3/lib/smbconf/smbconf_txt.c @@ -183,7 +183,7 @@ static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx) WERROR werr; uint64_t new_csn; - if (!file_exist(ctx->path, NULL)) { + if (!file_exist(ctx->path)) { return WERR_BADFILE; } diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c index 93494d6dad..f2161dc946 100644 --- a/source3/lib/smbldap.c +++ b/source3/lib/smbldap.c @@ -1025,13 +1025,6 @@ static int smbldap_open(struct smbldap_state *ldap_state) int rc, opt_rc; bool reopen = False; SMB_ASSERT(ldap_state); - -#ifndef NO_LDAP_SECURITY - if (geteuid() != 0) { - DEBUG(0, ("smbldap_open: cannot access LDAP when not root\n")); - return LDAP_INSUFFICIENT_ACCESS; - } -#endif if ((ldap_state->ldap_struct != NULL) && ((ldap_state->last_ping + SMBLDAP_DONT_PING_TIME) < time(NULL))) { @@ -1211,7 +1204,7 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state, if (ldap_state->last_rebind.tv_sec > 0) { struct timeval tval; - SMB_BIG_INT tdiff = 0; + int64_t tdiff = 0; int sleep_time = 0; ZERO_STRUCT(tval); diff --git a/source3/lib/socket_wrapper/config.m4 b/source3/lib/socket_wrapper/config.m4 deleted file mode 100644 index f3ffb895a9..0000000000 --- a/source3/lib/socket_wrapper/config.m4 +++ /dev/null @@ -1,22 +0,0 @@ -AC_ARG_ENABLE(socket-wrapper, -[ --enable-socket-wrapper Turn on socket wrapper library (default=no)]) - -DEFAULT_TEST_OPTIONS= -HAVE_SOCKET_WRAPPER=no - -if eval "test x$developer = xyes"; then - enable_socket_wrapper=yes -fi - -if eval "test x$enable_socket_wrapper = xyes"; then - AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library]) - DEFAULT_TEST_OPTIONS=--socket-wrapper - HAVE_SOCKET_WRAPPER=yes - - # this is only used for samba3 - SOCKET_WRAPPER_OBJS="lib/socket_wrapper/socket_wrapper.o" -fi - -AC_SUBST(DEFAULT_TEST_OPTIONS) -AC_SUBST(HAVE_SOCKET_WRAPPER) -AC_SUBST(SOCKET_WRAPPER_OBJS) diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c index 4a2d88abdf..5ee199de22 100644 --- a/source3/lib/sysquotas.c +++ b/source3/lib/sysquotas.c @@ -295,7 +295,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t dp->bsize = 1024; } - file_lines_free(lines); + TALLOC_FREE(lines); lines = NULL; DEBUG (3, ("Parsed output of get_quota, ...\n")); @@ -331,7 +331,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t invalid_param: - file_lines_free(lines); + TALLOC_FREE(lines); DEBUG(0,("The output of get_quota_command is invalid!\n")); return -1; } @@ -392,7 +392,7 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t DEBUG (3, ("Read output from set_quota, \"%s\"\n", line)); - file_lines_free(lines); + TALLOC_FREE(lines); return 0; } diff --git a/source3/lib/sysquotas_4A.c b/source3/lib/sysquotas_4A.c index f185bba6df..8a1b12238c 100644 --- a/source3/lib/sysquotas_4A.c +++ b/source3/lib/sysquotas_4A.c @@ -89,7 +89,7 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt int ret = -1; uint32 qflags = 0; struct dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); ZERO_STRUCT(*dp); @@ -162,12 +162,12 @@ int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt } dp->bsize = bsize; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = (SMB_BIG_UINT)D.dqb_curblocks; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = (uint64_t)D.dqb_curblocks; dp->qflags = qflags; @@ -184,7 +184,7 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt uint32 qflags = 0; uint32 oldqflags = 0; struct dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); diff --git a/source3/lib/sysquotas_linux.c b/source3/lib/sysquotas_linux.c index f9a0464086..5720328764 100644 --- a/source3/lib/sysquotas_linux.c +++ b/source3/lib/sysquotas_linux.c @@ -41,7 +41,7 @@ static int sys_get_linux_v1_quota(const char *path, const char *bdev, enum SMB_Q int ret = -1; uint32 qflags = 0; struct v1_kern_dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); @@ -88,12 +88,12 @@ static int sys_get_linux_v1_quota(const char *path, const char *bdev, enum SMB_Q } dp->bsize = bsize; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = (SMB_BIG_UINT)D.dqb_curblocks; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = (uint64_t)D.dqb_curblocks; dp->qflags = qflags; @@ -110,7 +110,7 @@ static int sys_set_linux_v1_quota(const char *path, const char *bdev, enum SMB_Q uint32 qflags = 0; uint32 oldqflags = 0; struct v1_kern_dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); @@ -175,7 +175,7 @@ static int sys_get_linux_v2_quota(const char *path, const char *bdev, enum SMB_Q int ret = -1; uint32 qflags = 0; struct v2_kern_dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); @@ -222,12 +222,12 @@ static int sys_get_linux_v2_quota(const char *path, const char *bdev, enum SMB_Q } dp->bsize = bsize; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = (SMB_BIG_UINT)D.dqb_curspace/bsize; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = (uint64_t)D.dqb_curspace/bsize; dp->qflags = qflags; @@ -244,7 +244,7 @@ static int sys_set_linux_v2_quota(const char *path, const char *bdev, enum SMB_Q uint32 qflags = 0; uint32 oldqflags = 0; struct v2_kern_dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); @@ -309,7 +309,7 @@ static int sys_get_linux_gen_quota(const char *path, const char *bdev, enum SMB_ int ret = -1; uint32 qflags = 0; struct if_dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); @@ -356,12 +356,12 @@ static int sys_get_linux_gen_quota(const char *path, const char *bdev, enum SMB_ } dp->bsize = bsize; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = (SMB_BIG_UINT)D.dqb_curspace/bsize; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = (uint64_t)D.dqb_curspace/bsize; dp->qflags = qflags; @@ -378,7 +378,7 @@ static int sys_set_linux_gen_quota(const char *path, const char *bdev, enum SMB_ uint32 qflags = 0; uint32 oldqflags = 0; struct if_dqblk D; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + uint64_t bsize = (uint64_t)QUOTABLOCK_SIZE; ZERO_STRUCT(D); diff --git a/source3/lib/sysquotas_xfs.c b/source3/lib/sysquotas_xfs.c index 30538c167b..1e438e9a6d 100644 --- a/source3/lib/sysquotas_xfs.c +++ b/source3/lib/sysquotas_xfs.c @@ -76,7 +76,7 @@ int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt { int ret = -1; uint32 qflags = 0; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)BBSIZE; + uint64_t bsize = (uint64_t)BBSIZE; struct fs_disk_quota D; struct fs_quota_stat F; ZERO_STRUCT(D); @@ -145,12 +145,12 @@ int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt } dp->bsize = bsize; - dp->softlimit = (SMB_BIG_UINT)D.d_blk_softlimit; - dp->hardlimit = (SMB_BIG_UINT)D.d_blk_hardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.d_ino_hardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.d_ino_softlimit; - dp->curinodes = (SMB_BIG_UINT)D.d_icount; - dp->curblocks = (SMB_BIG_UINT)D.d_bcount; + dp->softlimit = (uint64_t)D.d_blk_softlimit; + dp->hardlimit = (uint64_t)D.d_blk_hardlimit; + dp->ihardlimit = (uint64_t)D.d_ino_hardlimit; + dp->isoftlimit = (uint64_t)D.d_ino_softlimit; + dp->curinodes = (uint64_t)D.d_icount; + dp->curblocks = (uint64_t)D.d_bcount; dp->qflags = qflags; return ret; @@ -163,7 +163,7 @@ int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt { int ret = -1; uint32 qflags = 0; - SMB_BIG_UINT bsize = (SMB_BIG_UINT)BBSIZE; + uint64_t bsize = (uint64_t)BBSIZE; struct fs_disk_quota D; struct fs_quota_stat F; int q_on = 0; diff --git a/source3/lib/talloc/Makefile.in b/source3/lib/talloc/Makefile.in deleted file mode 100644 index 07b8fd4ff0..0000000000 --- a/source3/lib/talloc/Makefile.in +++ /dev/null @@ -1,43 +0,0 @@ -#!gmake -# -prefix = @prefix@ -datarootdir = @datarootdir@ -exec_prefix = @exec_prefix@ -includedir = @includedir@ -libdir = @libdir@ -mandir = @mandir@ -VPATH = @srcdir@:@libreplacedir@ -srcdir = @srcdir@ -builddir = @builddir@ -XSLTPROC = @XSLTPROC@ -INSTALLCMD = @INSTALL@ -CC = @CC@ -CFLAGS = @CFLAGS@ -DHAVE_CONFIG_H= -I. -I@srcdir@ -EXTRA_TARGETS = @DOC_TARGET@ -PICFLAG = @PICFLAG@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -SHLIBEXT = @SHLIBEXT@ -SHLD = @SHLD@ -SHLD_FLAGS = @SHLD_FLAGS@ -tallocdir = @tallocdir@ - -LIBOBJ = $(TALLOC_OBJ) @LIBREPLACEOBJ@ - -all:: showflags $(EXTRA_TARGETS) - -include $(tallocdir)/rules.mk -include $(tallocdir)/talloc.mk - -$(TALLOC_SOLIB): $(LIBOBJ) - $(SHLD) $(SHLD_FLAGS) -o $@ $(LIBOBJ) @SONAMEFLAG@$(TALLOC_SONAME) - -check: test - -installcheck:: test install - -distclean:: clean - rm -f Makefile - rm -f config.log config.status config.h config.cache - -realdistclean:: distclean - rm -f configure config.h.in diff --git a/source3/lib/talloc/configure.ac b/source3/lib/talloc/configure.ac deleted file mode 100644 index 4719aa04b5..0000000000 --- a/source3/lib/talloc/configure.ac +++ /dev/null @@ -1,24 +0,0 @@ -AC_PREREQ(2.50) -AC_INIT(talloc, 1.2.0) -AC_CONFIG_SRCDIR([talloc.c]) -AC_SUBST(datarootdir) -AC_CONFIG_HEADER(config.h) - -AC_LIBREPLACE_ALL_CHECKS - -m4_include(libtalloc.m4) - -AC_PATH_PROG(XSLTPROC,xsltproc) -DOC_TARGET="" -if test -n "$XSLTPROC"; then - DOC_TARGET=doc -fi -AC_SUBST(DOC_TARGET) - -AC_LD_PICFLAG -AC_LD_SHLIBEXT -AC_LD_SONAMEFLAG -AC_LIBREPLACE_SHLD -AC_LIBREPLACE_SHLD_FLAGS - -AC_OUTPUT(Makefile talloc.pc) diff --git a/source3/lib/talloc/libtalloc.m4 b/source3/lib/talloc/libtalloc.m4 deleted file mode 100644 index fd2b4b22cd..0000000000 --- a/source3/lib/talloc/libtalloc.m4 +++ /dev/null @@ -1,33 +0,0 @@ -dnl find the talloc sources. This is meant to work both for -dnl talloc standalone builds, and builds of packages using talloc -tallocdir="" -tallocpaths=". lib/talloc talloc ../talloc" -for d in $tallocpaths; do - if test -f "$srcdir/$d/talloc.c"; then - tallocdir="$d" - AC_SUBST(tallocdir) - break; - fi -done -if test x"$tallocdir" = "x"; then - AC_MSG_ERROR([cannot find talloc source in $tallocpaths]) -fi -TALLOC_OBJ="talloc.o" -AC_SUBST(TALLOC_OBJ) - -TALLOC_CFLAGS="-I$srcdir/$tallocdir" -AC_SUBST(TALLOC_CFLAGS) - -TALLOC_LIBS="" -AC_SUBST(TALLOC_LIBS) - -AC_CHECK_SIZEOF(size_t,cross) -AC_CHECK_SIZEOF(void *,cross) - -if test $ac_cv_sizeof_size_t -lt $ac_cv_sizeof_void_p; then - AC_WARN([size_t cannot represent the amount of used memory of a process]) - AC_WARN([please report this to ]) - AC_WARN([sizeof(size_t) = $ac_cv_sizeof_size_t]) - AC_WARN([sizeof(void *) = $ac_cv_sizeof_void_p]) - AC_ERROR([sizeof(size_t) < sizeof(void *)]) -fi diff --git a/source3/lib/talloc/talloc.mk b/source3/lib/talloc/talloc.mk deleted file mode 100644 index e1fe88c84b..0000000000 --- a/source3/lib/talloc/talloc.mk +++ /dev/null @@ -1,37 +0,0 @@ -TALLOC_OBJ = $(tallocdir)/talloc.o - -TALLOC_SOLIB = libtalloc.$(SHLIBEXT).$(PACKAGE_VERSION) -TALLOC_SONAME = libtalloc.$(SHLIBEXT).1 - -all:: libtalloc.a $(TALLOC_SOLIB) testsuite - -testsuite:: $(LIBOBJ) testsuite.o - $(CC) $(CFLAGS) -o testsuite testsuite.o $(LIBOBJ) $(LIBS) - -libtalloc.a: $(LIBOBJ) - ar -rv $@ $(LIBOBJ) - @-ranlib $@ - -install:: all - ${INSTALLCMD} -d $(DESTDIR)$(libdir) - ${INSTALLCMD} -d $(DESTDIR)$(libdir)/pkgconfig - ${INSTALLCMD} -m 755 libtalloc.a $(DESTDIR)$(libdir) - ${INSTALLCMD} -m 755 $(TALLOC_SOLIB) $(DESTDIR)$(libdir) - ${INSTALLCMD} -d $(DESTDIR)${includedir} - ${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(DESTDIR)$(includedir) - ${INSTALLCMD} -m 644 talloc.pc $(DESTDIR)$(libdir)/pkgconfig - if [ -f talloc.3 ];then ${INSTALLCMD} -d $(DESTDIR)$(mandir)/man3; fi - if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(DESTDIR)$(mandir)/man3; fi - which swig >/dev/null 2>&1 && ${INSTALLCMD} -d $(DESTDIR)`swig -swiglib` || true - which swig >/dev/null 2>&1 && ${INSTALLCMD} -m 644 talloc.i $(DESTDIR)`swig -swiglib` || true - -doc:: talloc.3 talloc.3.html - -clean:: - rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o *.gc?? talloc.3 talloc.3.html - -test:: testsuite - ./testsuite - -gcov:: - gcov talloc.c diff --git a/source3/lib/tdb/config.mk b/source3/lib/tdb/config.mk deleted file mode 100644 index b9a8f80dda..0000000000 --- a/source3/lib/tdb/config.mk +++ /dev/null @@ -1,57 +0,0 @@ -################################################ -# Start SUBSYSTEM LIBTDB -[LIBRARY::LIBTDB] -OUTPUT_TYPE = STATIC_LIBRARY -CFLAGS = -Ilib/tdb/include -# -# End SUBSYSTEM ldb -################################################ - -LIBTDB_OBJ_FILES = $(addprefix lib/tdb/common/, \ - tdb.o dump.o io.o lock.o \ - open.o traverse.o freelist.o \ - error.o transaction.o) - -################################################ -# Start BINARY tdbtool -[BINARY::tdbtool] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBTDB -# End BINARY tdbtool -################################################ - -tdbtool_OBJ_FILES = lib/tdb/tools/tdbtool.o - -################################################ -# Start BINARY tdbtorture -[BINARY::tdbtorture] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBTDB -# End BINARY tdbtorture -################################################ - -tdbtorture_OBJ_FILES = lib/tdb/tools/tdbtorture.o - -################################################ -# Start BINARY tdbdump -[BINARY::tdbdump] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBTDB -# End BINARY tdbdump -################################################ - -tdbdump_OBJ_FILES = lib/tdb/tools/tdbdump.o - -################################################ -# Start BINARY tdbbackup -[BINARY::tdbbackup] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBTDB -# End BINARY tdbbackup -################################################ - -tdbbackup_OBJ_FILES = lib/tdb/tools/tdbbackup.o diff --git a/source3/lib/tdb/libtdb.m4 b/source3/lib/tdb/libtdb.m4 deleted file mode 100644 index 1e17a7a4f2..0000000000 --- a/source3/lib/tdb/libtdb.m4 +++ /dev/null @@ -1,30 +0,0 @@ -dnl find the tdb sources. This is meant to work both for -dnl tdb standalone builds, and builds of packages using tdb -tdbdir="" -tdbpaths="$srcdir $srcdir/lib/tdb $srcdir/tdb $srcdir/../tdb" -for d in $tdbpaths; do - if test -f "$d/common/tdb.c"; then - tdbdir="$d" - AC_SUBST(tdbdir) - break; - fi -done -if test x"$tdbdir" = "x"; then - AC_MSG_ERROR([cannot find tdb source in $tdbpaths]) -fi -TDB_OBJ="common/tdb.o common/dump.o common/transaction.o common/error.o common/traverse.o" -TDB_OBJ="$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o common/lock.o common/open.o" -AC_SUBST(TDB_OBJ) -AC_SUBST(LIBREPLACEOBJ) - -TDB_LIBS="" -AC_SUBST(TDB_LIBS) - -TDB_CFLAGS="-I$tdbdir/include" -AC_SUBST(TDB_CFLAGS) - -AC_CHECK_FUNCS(mmap pread pwrite getpagesize utime) -AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h) - -AC_HAVE_DECL(pread, [#include ]) -AC_HAVE_DECL(pwrite, [#include ]) diff --git a/source3/lib/tdb/tdb.i b/source3/lib/tdb/tdb.i deleted file mode 100644 index 3d8b697732..0000000000 --- a/source3/lib/tdb/tdb.i +++ /dev/null @@ -1,323 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Swig interface to tdb. - - Copyright (C) 2004-2006 Tim Potter - Copyright (C) 2007 Jelmer Vernooij - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -%define DOCSTRING -"TDB is a simple key-value database similar to GDBM that supports multiple writers." -%enddef - -%module(docstring=DOCSTRING) tdb - -%{ - -/* This symbol is used in both includes.h and Python.h which causes an - annoying compiler warning. */ - -#ifdef HAVE_FSTAT -#undef HAVE_FSTAT -#endif - -/* Include tdb headers */ -#include -#include -#include -#include - -typedef TDB_CONTEXT tdb; -%} - -/* The tdb functions will crash if a NULL tdb context is passed */ - -%import exception.i -%import stdint.i - -%typemap(check,noblock=1) TDB_CONTEXT* { - if ($1 == NULL) - SWIG_exception(SWIG_ValueError, - "tdb context must be non-NULL"); -} - -/* In and out typemaps for the TDB_DATA structure. This is converted to - and from the Python string type which can contain arbitrary binary - data.. */ - -%typemap(in,noblock=1) TDB_DATA { - if ($input == Py_None) { - $1.dsize = 0; - $1.dptr = NULL; - } else if (!PyString_Check($input)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - $1.dsize = PyString_Size($input); - $1.dptr = (uint8_t *)PyString_AsString($input); - } -} - -%typemap(out,noblock=1) TDB_DATA { - if ($1.dptr == NULL && $1.dsize == 0) { - $result = Py_None; - } else { - $result = PyString_FromStringAndSize((const char *)$1.dptr, $1.dsize); - free($1.dptr); - } -} - -/* Treat a mode_t as an unsigned integer */ -typedef int mode_t; - -/* flags to tdb_store() */ -%constant int REPLACE = TDB_REPLACE; -%constant int INSERT = TDB_INSERT; -%constant int MODIFY = TDB_MODIFY; - -/* flags for tdb_open() */ -%constant int DEFAULT = TDB_DEFAULT; -%constant int CLEAR_IF_FIRST = TDB_CLEAR_IF_FIRST; -%constant int INTERNAL = TDB_INTERNAL; -%constant int NOLOCK = TDB_NOLOCK; -%constant int NOMMAP = TDB_NOMMAP; -%constant int CONVERT = TDB_CONVERT; -%constant int BIGENDIAN = TDB_BIGENDIAN; - -enum TDB_ERROR { - TDB_SUCCESS=0, - TDB_ERR_CORRUPT, - TDB_ERR_IO, - TDB_ERR_LOCK, - TDB_ERR_OOM, - TDB_ERR_EXISTS, - TDB_ERR_NOLOCK, - TDB_ERR_LOCK_TIMEOUT, - TDB_ERR_NOEXIST, - TDB_ERR_EINVAL, - TDB_ERR_RDONLY -}; - -%rename(lock_all) tdb_context::lockall; -%rename(unlock_all) tdb_context::unlockall; - -%rename(read_lock_all) tdb_context::lockall_read; -%rename(read_unlock_all) tdb_context::unlockall_read; - -%typemap(default,noblock=1) int tdb_flags { - $1 = TDB_DEFAULT; -} - -%typemap(default,noblock=1) int flags { - $1 = O_RDWR; -} - -%typemap(default,noblock=1) int hash_size { - $1 = 0; -} - -%typemap(default,noblock=1) mode_t mode { - $1 = 0600; -} - -%typemap(default,noblock=1) int flag { - $1 = TDB_REPLACE; -} - -%rename(Tdb) tdb_context; -%feature("docstring") tdb_context "A TDB file."; -%typemap(out,noblock=1) tdb * { - /* Throw an IOError exception from errno if tdb_open() returns NULL */ - if ($1 == NULL) { - PyErr_SetFromErrno(PyExc_IOError); - SWIG_fail; - } - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); -} - -typedef struct tdb_context { - %extend { - %feature("docstring") tdb "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n" - "Open a TDB file."; - tdb(const char *name, int hash_size, int tdb_flags, int flags, mode_t mode) { - return tdb_open(name, hash_size, tdb_flags, flags, mode); - } - %feature("docstring") error "S.error() -> int\n" - "Find last error number returned by operation on this TDB."; - enum TDB_ERROR error(); - ~tdb() { tdb_close($self); } - %feature("docstring") close "S.close() -> None\n" - "Close the TDB file."; - int close(); - int append(TDB_DATA key, TDB_DATA new_dbuf); - %feature("docstring") errorstr "S.errorstr() -> errorstring\n" - "Obtain last error message."; - const char *errorstr(); - %rename(get) fetch; - %feature("docstring") fetch "S.fetch(key) -> value\n" - "Fetch a value."; - TDB_DATA fetch(TDB_DATA key); - %feature("docstring") delete "S.delete(key) -> None\n" - "Delete an entry."; - int delete(TDB_DATA key); - %feature("docstring") store "S.store(key, value, flag=TDB_REPLACE) -> None\n" - "Store an entry."; - int store(TDB_DATA key, TDB_DATA dbuf, int flag); - %feature("docstring") exists "S.exists(key) -> bool\n" - "Check whether key exists in this database."; - int exists(TDB_DATA key); - %feature("docstring") firstkey "S.firstkey() -> data\n" - "Return the first key in this database."; - TDB_DATA firstkey(); - %feature("docstring") nextkey "S.nextkey(prev) -> data\n" - "Return the next key in this database."; - TDB_DATA nextkey(TDB_DATA key); - %feature("docstring") lockall "S.lockall() -> bool"; - int lockall(); - %feature("docstring") unlockall "S.unlockall() -> bool"; - int unlockall(); - %feature("docstring") unlockall "S.lockall_read() -> bool"; - int lockall_read(); - %feature("docstring") unlockall "S.unlockall_read() -> bool"; - int unlockall_read(); - %feature("docstring") reopen "S.reopen() -> bool\n" - "Reopen this file."; - int reopen(); - %feature("docstring") transaction_start "S.transaction_start() -> None\n" - "Start a new transaction."; - int transaction_start(); - %feature("docstring") transaction_commit "S.transaction_commit() -> None\n" - "Commit the currently active transaction."; - int transaction_commit(); - %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n" - "Cancel the currently active transaction."; - int transaction_cancel(); - int transaction_recover(); - %feature("docstring") hash_size "S.hash_size() -> int"; - int hash_size(); - %feature("docstring") map_size "S.map_size() -> int"; - size_t map_size(); - %feature("docstring") get_flags "S.get_flags() -> int"; - int get_flags(); - %feature("docstring") set_max_dead "S.set_max_dead(int) -> None"; - void set_max_dead(int max_dead); - %feature("docstring") name "S.name() -> path\n" \ - "Return filename of this TDB file."; - const char *name(); - } - - %pythoncode { - def __repr__(self): - return "Tdb('%s')" % self.name() - - # Random access to keys, values - def __getitem__(self, key): - result = self.get(key) - if result is None: - raise KeyError, '%s: %s' % (key, self.errorstr()) - return result - - def __setitem__(self, key, item): - if self.store(key, item) == -1: - raise IOError, self.errorstr() - - def __delitem__(self, key): - if not self.exists(key): - raise KeyError, '%s: %s' % (key, self.errorstr()) - self.delete(key) - - def __contains__(self, key): - return self.exists(key) != 0 - - def has_key(self, key): - return self.exists(key) != 0 - - def fetch_uint32(self, key): - data = self.get(key) - if data is None: - return None - import struct - return struct.unpack("" % (self.__class__.__module__, self.__class__.__name__, strthis,) - -import types -try: - _object = types.ObjectType - _newclass = 1 -except AttributeError: - class _object : pass - _newclass = 0 -del types - - -def _swig_setattr_nondynamic_method(set): - def set_attr(self,name,value): - if (name == "thisown"): return self.this.own(value) - if hasattr(self,name) or (name == "this"): - set(self,name,value) - else: - raise AttributeError("You cannot add attributes to %s" % self) - return set_attr - - -REPLACE = _tdb.REPLACE -INSERT = _tdb.INSERT -MODIFY = _tdb.MODIFY -DEFAULT = _tdb.DEFAULT -CLEAR_IF_FIRST = _tdb.CLEAR_IF_FIRST -INTERNAL = _tdb.INTERNAL -NOLOCK = _tdb.NOLOCK -NOMMAP = _tdb.NOMMAP -CONVERT = _tdb.CONVERT -BIGENDIAN = _tdb.BIGENDIAN -TDB_SUCCESS = _tdb.TDB_SUCCESS -TDB_ERR_CORRUPT = _tdb.TDB_ERR_CORRUPT -TDB_ERR_IO = _tdb.TDB_ERR_IO -TDB_ERR_LOCK = _tdb.TDB_ERR_LOCK -TDB_ERR_OOM = _tdb.TDB_ERR_OOM -TDB_ERR_EXISTS = _tdb.TDB_ERR_EXISTS -TDB_ERR_NOLOCK = _tdb.TDB_ERR_NOLOCK -TDB_ERR_LOCK_TIMEOUT = _tdb.TDB_ERR_LOCK_TIMEOUT -TDB_ERR_NOEXIST = _tdb.TDB_ERR_NOEXIST -TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL -TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY -class Tdb(object): - """A TDB file.""" - thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') - __repr__ = _swig_repr - def __init__(self, *args, **kwargs): - """ - S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600) - Open a TDB file. - """ - _tdb.Tdb_swiginit(self,_tdb.new_Tdb(*args, **kwargs)) - def error(*args, **kwargs): - """ - S.error() -> int - Find last error number returned by operation on this TDB. - """ - return _tdb.Tdb_error(*args, **kwargs) - - __swig_destroy__ = _tdb.delete_Tdb - def close(*args, **kwargs): - """ - S.close() -> None - Close the TDB file. - """ - return _tdb.Tdb_close(*args, **kwargs) - - def errorstr(*args, **kwargs): - """ - S.errorstr() -> errorstring - Obtain last error message. - """ - return _tdb.Tdb_errorstr(*args, **kwargs) - - def get(*args, **kwargs): - """ - S.fetch(key) -> value - Fetch a value. - """ - return _tdb.Tdb_get(*args, **kwargs) - - def delete(*args, **kwargs): - """ - S.delete(key) -> None - Delete an entry. - """ - return _tdb.Tdb_delete(*args, **kwargs) - - def store(*args, **kwargs): - """ - S.store(key, value, flag=TDB_REPLACE) -> None - Store an entry. - """ - return _tdb.Tdb_store(*args, **kwargs) - - def exists(*args, **kwargs): - """ - S.exists(key) -> bool - Check whether key exists in this database. - """ - return _tdb.Tdb_exists(*args, **kwargs) - - def firstkey(*args, **kwargs): - """ - S.firstkey() -> data - Return the first key in this database. - """ - return _tdb.Tdb_firstkey(*args, **kwargs) - - def nextkey(*args, **kwargs): - """ - S.nextkey(prev) -> data - Return the next key in this database. - """ - return _tdb.Tdb_nextkey(*args, **kwargs) - - def lock_all(*args, **kwargs): - """S.lockall() -> bool""" - return _tdb.Tdb_lock_all(*args, **kwargs) - - def unlock_all(*args, **kwargs): - """S.unlockall() -> bool""" - return _tdb.Tdb_unlock_all(*args, **kwargs) - - def reopen(*args, **kwargs): - """ - S.reopen() -> bool - Reopen this file. - """ - return _tdb.Tdb_reopen(*args, **kwargs) - - def transaction_start(*args, **kwargs): - """ - S.transaction_start() -> None - Start a new transaction. - """ - return _tdb.Tdb_transaction_start(*args, **kwargs) - - def transaction_commit(*args, **kwargs): - """ - S.transaction_commit() -> None - Commit the currently active transaction. - """ - return _tdb.Tdb_transaction_commit(*args, **kwargs) - - def transaction_cancel(*args, **kwargs): - """ - S.transaction_cancel() -> None - Cancel the currently active transaction. - """ - return _tdb.Tdb_transaction_cancel(*args, **kwargs) - - def hash_size(*args, **kwargs): - """S.hash_size() -> int""" - return _tdb.Tdb_hash_size(*args, **kwargs) - - def map_size(*args, **kwargs): - """S.map_size() -> int""" - return _tdb.Tdb_map_size(*args, **kwargs) - - def get_flags(*args, **kwargs): - """S.get_flags() -> int""" - return _tdb.Tdb_get_flags(*args, **kwargs) - - def set_max_dead(*args, **kwargs): - """S.set_max_dead(int) -> None""" - return _tdb.Tdb_set_max_dead(*args, **kwargs) - - def name(*args, **kwargs): - """ - S.name() -> path - Return filename of this TDB file. - """ - return _tdb.Tdb_name(*args, **kwargs) - - def __repr__(self): - return "Tdb('%s')" % self.name() - - - def __getitem__(self, key): - result = self.get(key) - if result is None: - raise KeyError, '%s: %s' % (key, self.errorstr()) - return result - - def __setitem__(self, key, item): - if self.store(key, item) == -1: - raise IOError, self.errorstr() - - def __delitem__(self, key): - if not self.exists(key): - raise KeyError, '%s: %s' % (key, self.errorstr()) - self.delete(key) - - def __contains__(self, key): - return self.exists(key) != 0 - - def has_key(self, key): - return self.exists(key) != 0 - - def fetch_uint32(self, key): - data = self.get(key) - if data is None: - return None - import struct - return struct.unpack(">16); - SIVAL(buf,offset,x); -} - -/** -put a dos 32 bit "unix like" date into a buffer. This routine takes -GMT and converts it to LOCAL time before putting it (most SMBs assume -localtime for this sort of date) -**/ -void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset) -{ - if (!null_time(unixdate)) { - unixdate -= zone_offset; - } - SIVAL(buf,offset,unixdate); -} - -/******************************************************************* - interpret a 32 bit dos packed date/time to some parameters -********************************************************************/ -static void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second) -{ - uint32_t p0,p1,p2,p3; - - p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF; - p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF; - - *second = 2*(p0 & 0x1F); - *minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3); - *hour = (p1>>3)&0xFF; - *day = (p2&0x1F); - *month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1; - *year = ((p3>>1)&0xFF) + 80; -} - -/** - create a unix date (int GMT) from a dos date (which is actually in - localtime) -**/ -time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset) -{ - uint32_t dos_date=0; - struct tm t; - time_t ret; - - dos_date = IVAL(date_ptr,0); - - if (dos_date == 0) return (time_t)0; - - interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon, - &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec); - t.tm_isdst = -1; - - ret = timegm(&t); - - ret += zone_offset; - - return ret; -} - -/** -like make_unix_date() but the words are reversed -**/ -time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset) -{ - uint32_t x,x2; - - x = IVAL(date_ptr,0); - x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16); - SIVAL(&x,0,x2); - - return pull_dos_date((const uint8_t *)&x, zone_offset); -} - -/** - create a unix GMT date from a dos date in 32 bit "unix like" format - these generally arrive as localtimes, with corresponding DST -**/ -time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset) -{ - time_t t = (time_t)IVAL(date_ptr,0); - if (!null_time(t)) { - t += zone_offset; - } - return t; -} - -/*************************************************************************** - Return a HTTP/1.0 time string. -***************************************************************************/ - -char *http_timestring(time_t t) -{ - fstring buf; - struct tm *tm = localtime(&t); - - if (t == TIME_T_MAX) { - fstrcpy(buf, "never"); - } else if (!tm) { - fstr_sprintf(buf, "%ld seconds since the Epoch", (long)t); - } else { -#ifndef HAVE_STRFTIME - const char *asct = asctime(tm); - fstrcpy(buf, asct ? asct : "unknown"); - } - if(buf[strlen(buf)-1] == '\n') { - buf[strlen(buf)-1] = 0; -#else /* !HAVE_STRFTIME */ - strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm); -#endif /* !HAVE_STRFTIME */ - } - return talloc_strdup(talloc_tos(), buf); -} - - -/** - Return the date and time as a string -**/ -char *timestring(TALLOC_CTX *mem_ctx, time_t t) -{ - char *TimeBuf; - char tempTime[80]; - struct tm *tm; - - tm = localtime(&t); - if (!tm) { - return talloc_asprintf(mem_ctx, - "%ld seconds since the Epoch", - (long)t); - } - -#ifdef HAVE_STRFTIME - /* some versions of gcc complain about using %c. This is a bug - in the gcc warning, not a bug in this code. See a recent - strftime() manual page for details. - */ - strftime(tempTime,sizeof(tempTime)-1,"%c %Z",tm); - TimeBuf = talloc_strdup(mem_ctx, tempTime); -#else - TimeBuf = talloc_strdup(mem_ctx, asctime(tm)); -#endif - - return TimeBuf; -} - -/** - return a talloced string representing a NTTIME for human consumption -*/ -const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt) -{ - time_t t; - if (nt == 0) { - return "NTTIME(0)"; - } - t = nt_time_to_unix(nt); - return timestring(mem_ctx, t); -} - - /** parse a nttime as a large integer in a string and return a NTTIME */ @@ -377,190 +100,6 @@ NTTIME nttime_from_string(const char *s) return strtoull(s, NULL, 0); } -/** - return (tv1 - tv2) in microseconds -*/ -int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2) -{ - int64_t sec_diff = tv1->tv_sec - tv2->tv_sec; - return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec); -} - - -/** - return a zero timeval -*/ -struct timeval timeval_zero(void) -{ - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 0; - return tv; -} - -/** - return True if a timeval is zero -*/ -bool timeval_is_zero(const struct timeval *tv) -{ - return tv->tv_sec == 0 && tv->tv_usec == 0; -} - -/** - return a timeval for the current time -*/ -struct timeval timeval_current(void) -{ - struct timeval tv; - GetTimeOfDay(&tv); - return tv; -} - -/** - return a timeval struct with the given elements -*/ -struct timeval timeval_set(uint32_t secs, uint32_t usecs) -{ - struct timeval tv; - tv.tv_sec = secs; - tv.tv_usec = usecs; - return tv; -} - - -/** - return a timeval ofs microseconds after tv -*/ -struct timeval timeval_add(const struct timeval *tv, - uint32_t secs, uint32_t usecs) -{ - struct timeval tv2 = *tv; - const unsigned int million = 1000000; - tv2.tv_sec += secs; - tv2.tv_usec += usecs; - tv2.tv_sec += tv2.tv_usec / million; - tv2.tv_usec = tv2.tv_usec % million; - return tv2; -} - -/** - return the sum of two timeval structures -*/ -struct timeval timeval_sum(const struct timeval *tv1, - const struct timeval *tv2) -{ - return timeval_add(tv1, tv2->tv_sec, tv2->tv_usec); -} - -/** - return a timeval secs/usecs into the future -*/ -struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs) -{ - struct timeval tv = timeval_current(); - return timeval_add(&tv, secs, usecs); -} - -/** - compare two timeval structures. - Return -1 if tv1 < tv2 - Return 0 if tv1 == tv2 - Return 1 if tv1 > tv2 -*/ -int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) -{ - if (tv1->tv_sec > tv2->tv_sec) return 1; - if (tv1->tv_sec < tv2->tv_sec) return -1; - if (tv1->tv_usec > tv2->tv_usec) return 1; - if (tv1->tv_usec < tv2->tv_usec) return -1; - return 0; -} - -/** - return True if a timer is in the past -*/ -bool timeval_expired(const struct timeval *tv) -{ - struct timeval tv2 = timeval_current(); - if (tv2.tv_sec > tv->tv_sec) return True; - if (tv2.tv_sec < tv->tv_sec) return False; - return (tv2.tv_usec >= tv->tv_usec); -} - -/** - return the number of seconds elapsed between two times -*/ -double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2) -{ - return (tv2->tv_sec - tv1->tv_sec) + - (tv2->tv_usec - tv1->tv_usec)*1.0e-6; -} - -/** - return the number of seconds elapsed since a given time -*/ -double timeval_elapsed(const struct timeval *tv) -{ - struct timeval tv2 = timeval_current(); - return timeval_elapsed2(tv, &tv2); -} - -/** - return the lesser of two timevals -*/ -struct timeval timeval_min(const struct timeval *tv1, - const struct timeval *tv2) -{ - if (tv1->tv_sec < tv2->tv_sec) return *tv1; - if (tv1->tv_sec > tv2->tv_sec) return *tv2; - if (tv1->tv_usec < tv2->tv_usec) return *tv1; - return *tv2; -} - -/** - return the greater of two timevals -*/ -struct timeval timeval_max(const struct timeval *tv1, - const struct timeval *tv2) -{ - if (tv1->tv_sec > tv2->tv_sec) return *tv1; - if (tv1->tv_sec < tv2->tv_sec) return *tv2; - if (tv1->tv_usec > tv2->tv_usec) return *tv1; - return *tv2; -} - -/** - return the difference between two timevals as a timeval - if tv1 comes after tv2, then return a zero timeval - (this is *tv2 - *tv1) -*/ -struct timeval timeval_until(const struct timeval *tv1, - const struct timeval *tv2) -{ - struct timeval t; - if (timeval_compare(tv1, tv2) >= 0) { - return timeval_zero(); - } - t.tv_sec = tv2->tv_sec - tv1->tv_sec; - if (tv1->tv_usec > tv2->tv_usec) { - t.tv_sec--; - t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec); - } else { - t.tv_usec = tv2->tv_usec - tv1->tv_usec; - } - return t; -} - - -/** - convert a timeval to a NTTIME -*/ -NTTIME timeval_to_nttime(const struct timeval *tv) -{ - return 10*(tv->tv_usec + - ((TIME_FIXUP_CONSTANT_INT + (uint64_t)tv->tv_sec) * 1000000)); -} - /************************************************************** Handle conversions between time_t and uint32, taking care to preserve the "special" values. @@ -592,44 +131,8 @@ time_t convert_uint32_to_time_t(uint32 u) return (time_t)u; } -/******************************************************************* - Yield the difference between *A and *B, in seconds, ignoring leap seconds. -********************************************************************/ - -static int tm_diff(struct tm *a, struct tm *b) -{ - int ay = a->tm_year + (1900 - 1); - int by = b->tm_year + (1900 - 1); - int intervening_leap_days = - (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400); - int years = ay - by; - int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday); - int hours = 24*days + (a->tm_hour - b->tm_hour); - int minutes = 60*hours + (a->tm_min - b->tm_min); - int seconds = 60*minutes + (a->tm_sec - b->tm_sec); - - return seconds; -} - int extra_time_offset=0; -/******************************************************************* - Return the UTC offset in seconds west of UTC, or 0 if it cannot be determined. -********************************************************************/ - -int get_time_zone(time_t t) -{ - struct tm *tm = gmtime(&t); - struct tm tm_utc; - if (!tm) - return 0; - tm_utc = *tm; - tm = localtime(&t); - if (!tm) - return 0; - return tm_diff(&tm_utc,tm)+60*extra_time_offset; -} - /**************************************************************************** Check if NTTIME is 0. ****************************************************************************/ @@ -1084,24 +587,6 @@ time_t srv_make_unix_date3(const void *date_ptr) return make_unix_date3(date_ptr, server_zone_offset); } -time_t convert_timespec_to_time_t(struct timespec ts) -{ - /* 1 ns == 1,000,000,000 - one thousand millionths of a second. - increment if it's greater than 500 millionth of a second. */ - if (ts.tv_nsec > 500000000) { - return ts.tv_sec + 1; - } - return ts.tv_sec; -} - -struct timespec convert_time_t_to_timespec(time_t t) -{ - struct timespec ts; - ts.tv_sec = t; - ts.tv_nsec = 0; - return ts; -} - /**************************************************************************** Convert a normalized timeval to a timespec. ****************************************************************************/ @@ -1222,49 +707,6 @@ time_t cli_make_unix_date3(struct cli_state *cli, const void *date_ptr) return make_unix_date3(date_ptr, cli->serverzone); } -/* Large integer version. */ -struct timespec nt_time_to_unix_timespec(NTTIME *nt) -{ - int64 d; - struct timespec ret; - - if (*nt == 0 || *nt == (int64)-1) { - ret.tv_sec = 0; - ret.tv_nsec = 0; - return ret; - } - - d = (int64)*nt; - /* d is now in 100ns units, since jan 1st 1601". - Save off the ns fraction. */ - - /* - * Take the last seven decimal digits and multiply by 100. - * to convert from 100ns units to 1ns units. - */ - ret.tv_nsec = (long) ((d % (1000 * 1000 * 10)) * 100); - - /* Convert to seconds */ - d /= 1000*1000*10; - - /* Now adjust by 369 years to make the secs since 1970 */ - d -= TIME_FIXUP_CONSTANT_INT; - - if (d <= (int64)TIME_T_MIN) { - ret.tv_sec = TIME_T_MIN; - ret.tv_nsec = 0; - return ret; - } - - if (d >= (int64)TIME_T_MAX) { - ret.tv_sec = TIME_T_MAX; - ret.tv_nsec = 0; - return ret; - } - - ret.tv_sec = (time_t)d; - return ret; -} /**************************************************************************** Check if two NTTIMEs are the same. ****************************************************************************/ diff --git a/source3/lib/util.c b/source3/lib/util.c index ec43ea7037..820cf376be 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -439,19 +439,6 @@ bool set_cmdline_auth_info_machine_account_creds(void) return true; } -/**************************************************************************n - Find a suitable temporary directory. The result should be copied immediately - as it may be overwritten by a subsequent call. -****************************************************************************/ - -const char *tmpdir(void) -{ - char *p; - if ((p = getenv("TMPDIR"))) - return p; - return "/tmp"; -} - /**************************************************************************** Add a gid to an array of gids if it's not already there. ****************************************************************************/ @@ -540,7 +527,7 @@ const char *get_numlist(const char *p, uint32 **num, int *count) Check if a file exists - call vfs_file_exist for samba files. ********************************************************************/ -bool file_exist(const char *fname,SMB_STRUCT_STAT *sbuf) +bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf) { SMB_STRUCT_STAT st; if (!sbuf) @@ -565,25 +552,11 @@ bool socket_exist(const char *fname) return S_ISSOCK(st.st_mode); } -/******************************************************************* - Check a files mod time. -********************************************************************/ - -time_t file_modtime(const char *fname) -{ - SMB_STRUCT_STAT st; - - if (sys_stat(fname,&st) != 0) - return(0); - - return(st.st_mtime); -} - /******************************************************************* Check if a directory exists. ********************************************************************/ -bool directory_exist(char *dname,SMB_STRUCT_STAT *st) +bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st) { SMB_STRUCT_STAT st2; bool ret; @@ -927,36 +900,6 @@ ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos #endif } -/**************************************************************************** - Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available, - else - if SYSV use O_NDELAY - if BSD use FNDELAY -****************************************************************************/ - -int set_blocking(int fd, bool set) -{ - int val; -#ifdef O_NONBLOCK -#define FLAG_TO_SET O_NONBLOCK -#else -#ifdef SYSV -#define FLAG_TO_SET O_NDELAY -#else /* BSD */ -#define FLAG_TO_SET FNDELAY -#endif -#endif - - if((val = sys_fcntl_long(fd, F_GETFL, 0)) == -1) - return -1; - if(set) /* Turn blocking on - ie. clear nonblock flag */ - val &= ~FLAG_TO_SET; - else - val |= FLAG_TO_SET; - return sys_fcntl_long( fd, F_SETFL, val); -#undef FLAG_TO_SET -} - /******************************************************************* Sleep for a specified number of milliseconds. ********************************************************************/ @@ -1129,26 +1072,6 @@ static void *realloc_(void *ptr, size_t size) #endif /* PARANOID_MALLOC_CHECKER */ -/**************************************************************************** - Type-safe malloc. -****************************************************************************/ - -void *malloc_array(size_t el_size, unsigned int count) -{ - if (count >= MAX_ALLOC_SIZE/el_size) { - return NULL; - } - - if (el_size == 0 || count == 0) { - return NULL; - } -#if defined(PARANOID_MALLOC_CHECKER) - return malloc_(el_size*count); -#else - return malloc(el_size*count); -#endif -} - /**************************************************************************** Type-safe memalign ****************************************************************************/ @@ -1249,21 +1172,6 @@ void *Realloc(void *p, size_t size, bool free_old_on_error) return(ret); } -/**************************************************************************** - Type-safe realloc. -****************************************************************************/ - -void *realloc_array(void *p, size_t el_size, unsigned int count, bool free_old_on_error) -{ - if (count >= MAX_ALLOC_SIZE/el_size) { - if (free_old_on_error) { - SAFE_FREE(p); - } - return NULL; - } - return Realloc(p, el_size*count, free_old_on_error); -} - /**************************************************************************** (Hopefully) efficient array append. ****************************************************************************/ @@ -1319,22 +1227,11 @@ void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size, *array_size = -1; } -/**************************************************************************** - Free memory, checks for NULL. - Use directly SAFE_FREE() - Exists only because we need to pass a function pointer somewhere --SSS -****************************************************************************/ - -void safe_free(void *p) -{ - SAFE_FREE(p); -} - /**************************************************************************** Get my own name and IP. ****************************************************************************/ -char *get_myname(TALLOC_CTX *ctx) +char *talloc_get_myname(TALLOC_CTX *ctx) { char *p; char hostname[HOST_NAME_MAX]; @@ -1549,14 +1446,6 @@ bool process_exists(const struct server_id pid) #endif } -bool process_exists_by_pid(pid_t pid) -{ - /* Doing kill with a non-positive pid causes messages to be - * sent to places we don't want. */ - SMB_ASSERT(pid > 0); - return(kill(pid,0) == 0 || errno != ESRCH); -} - /******************************************************************* Convert a uid into a user name. ********************************************************************/ @@ -2002,42 +1891,6 @@ void free_namearray(name_compare_entry *name_array) #undef DBGC_CLASS #define DBGC_CLASS DBGC_LOCKING -/**************************************************************************** - Simple routine to do POSIX file locking. Cruft in NFS and 64->32 bit mapping - is dealt with in posix.c - Returns True if the lock was granted, False otherwise. -****************************************************************************/ - -bool fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) -{ - SMB_STRUCT_FLOCK lock; - int ret; - - DEBUG(8,("fcntl_lock fd=%d op=%d offset=%.0f count=%.0f type=%d\n", - fd,op,(double)offset,(double)count,type)); - - lock.l_type = type; - lock.l_whence = SEEK_SET; - lock.l_start = offset; - lock.l_len = count; - lock.l_pid = 0; - - ret = sys_fcntl_ptr(fd,op,&lock); - - if (ret == -1) { - int sav = errno; - DEBUG(3,("fcntl_lock: lock failed at offset %.0f count %.0f op %d type %d (%s)\n", - (double)offset,(double)count,op,type,strerror(errno))); - errno = sav; - return False; - } - - /* everything went OK */ - DEBUG(8,("fcntl_lock: Lock call successful\n")); - - return True; -} - /**************************************************************************** Simple routine to query existing file locks. Cruft in NFS and 64->32 bit mapping is dealt with in posix.c @@ -2210,57 +2063,6 @@ enum remote_arch_types get_remote_arch(void) return ra_type; } -void print_asc(int level, const unsigned char *buf,int len) -{ - int i; - for (i=0;i8) DEBUGADD(level,(" ")); - while (n--) DEBUGADD(level,(" ")); - n = MIN(8,i%16); - print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " )); - n = (i%16) - n; - if (n>0) print_asc(level,&buf[i-n],n); - DEBUGADD(level,("\n")); - } -} - -void dump_data_pw(const char *msg, const uchar * data, size_t len) -{ -#ifdef DEBUG_PASSWORD - DEBUG(11, ("%s", msg)); - if (data != NULL && len > 0) - { - dump_data(11, data, len); - } -#endif -} - const char *tab_depth(int level, int depth) { if( CHECK_DEBUGLVL(level) ) { @@ -2425,78 +2227,6 @@ void *smb_xmalloc_array(size_t size, unsigned int count) return p; } -/** - Memdup with smb_panic on fail. -**/ - -void *smb_xmemdup(const void *p, size_t size) -{ - void *p2; - p2 = SMB_XMALLOC_ARRAY(unsigned char,size); - memcpy(p2, p, size); - return p2; -} - -/** - strdup that aborts on malloc fail. -**/ - -char *smb_xstrdup(const char *s) -{ -#if defined(PARANOID_MALLOC_CHECKER) -#ifdef strdup -#undef strdup -#endif -#endif - -#ifndef HAVE_STRDUP -#define strdup rep_strdup -#endif - - char *s1 = strdup(s); -#if defined(PARANOID_MALLOC_CHECKER) -#ifdef strdup -#undef strdup -#endif -#define strdup(s) __ERROR_DONT_USE_STRDUP_DIRECTLY -#endif - if (!s1) { - smb_panic("smb_xstrdup: malloc failed"); - } - return s1; - -} - -/** - strndup that aborts on malloc fail. -**/ - -char *smb_xstrndup(const char *s, size_t n) -{ -#if defined(PARANOID_MALLOC_CHECKER) -#ifdef strndup -#undef strndup -#endif -#endif - -#if (defined(BROKEN_STRNDUP) || !defined(HAVE_STRNDUP)) -#undef HAVE_STRNDUP -#define strndup rep_strndup -#endif - - char *s1 = strndup(s, n); -#if defined(PARANOID_MALLOC_CHECKER) -#ifdef strndup -#undef strndup -#endif -#define strndup(s,n) __ERROR_DONT_USE_STRNDUP_DIRECTLY -#endif - if (!s1) { - smb_panic("smb_xstrndup: malloc failed"); - } - return s1; -} - /* vasprintf that aborts on malloc fail */ @@ -2506,7 +2236,7 @@ char *smb_xstrndup(const char *s, size_t n) int n; va_list ap2; - VA_COPY(ap2, ap); + va_copy(ap2, ap); n = vasprintf(ptr, format, ap2); if (n == -1 || ! *ptr) { @@ -2516,22 +2246,6 @@ char *smb_xstrndup(const char *s, size_t n) return n; } -/***************************************************************** - Like strdup but for memory. -*****************************************************************/ - -void *memdup(const void *p, size_t size) -{ - void *p2; - if (size == 0) - return NULL; - p2 = SMB_MALLOC(size); - if (!p2) - return NULL; - memcpy(p2, p, size); - return p2; -} - /***************************************************************** Get local hostname and cache result. *****************************************************************/ @@ -2542,7 +2256,7 @@ char *myhostname(void) if (ret == NULL) { /* This is cached forever so * use NULL talloc ctx. */ - ret = get_myname(NULL); + ret = talloc_get_myname(NULL); } return ret; } @@ -2561,7 +2275,7 @@ static char *xx_path(const char *name, const char *rootpath) } trim_string(fname,"","/"); - if (!directory_exist(fname,NULL)) { + if (!directory_exist(fname)) { mkdir(fname,0755); } @@ -2971,25 +2685,6 @@ bool name_to_fqdn(fstring fqdn, const char *name) return true; } -/********************************************************************** - Extension to talloc_get_type: Abort on type mismatch -***********************************************************************/ - -void *talloc_check_name_abort(const void *ptr, const char *name) -{ - void *result; - - result = talloc_check_name(ptr, name); - if (result != NULL) - return result; - - DEBUG(0, ("Talloc type mismatch, expected %s, got %s\n", - name, talloc_get_name(ptr))); - smb_panic("talloc type mismatch"); - /* Keep the compiler happy */ - return NULL; -} - /********************************************************************** Append a DATA_BLOB to a talloc'ed object ***********************************************************************/ diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index b628b06cc6..c5a9b7c29a 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -19,89 +19,11 @@ #include "includes.h" -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -/**************************************************************************** - Read a line from a file with possible \ continuation chars. - Blanks at the start or end of a line are stripped. - The string will be allocated if s2 is NULL. -****************************************************************************/ - -char *fgets_slash(char *s2,int maxlen,XFILE *f) -{ - char *s=s2; - int len = 0; - int c; - bool start_of_line = True; - - if (x_feof(f)) { - return(NULL); - } - - if (maxlen <2) { - return(NULL); - } - - if (!s2) { - maxlen = MIN(maxlen,8); - s = (char *)SMB_MALLOC(maxlen); - } - - if (!s) { - return(NULL); - } - - *s = 0; - - while (len < maxlen-1) { - c = x_getc(f); - switch (c) { - case '\r': - break; - case '\n': - while (len > 0 && s[len-1] == ' ') { - s[--len] = 0; - } - if (len > 0 && s[len-1] == '\\') { - s[--len] = 0; - start_of_line = True; - break; - } - return(s); - case EOF: - if (len <= 0 && !s2) { - SAFE_FREE(s); - } - return(len>0?s:NULL); - case ' ': - if (start_of_line) { - break; - } - default: - start_of_line = False; - s[len++] = c; - s[len] = 0; - } - - if (!s2 && len > maxlen-3) { - maxlen *= 2; - s = (char *)SMB_REALLOC(s,maxlen); - if (!s) { - DEBUG(0,("fgets_slash: failed to expand buffer!\n")); - return(NULL); - } - } - } - return(s); -} - -/**************************************************************************** +/** Load from a pipe into memory. -****************************************************************************/ +**/ -static char *file_pload(char *syscmd, size_t *size) +static char *file_pload(const char *syscmd, size_t *size) { int fd, n; char *p; @@ -143,215 +65,14 @@ static char *file_pload(char *syscmd, size_t *size) return p; } -/**************************************************************************** - Load a file into memory from a fd. - Truncate at maxsize. If maxsize == 0 - no limit. -****************************************************************************/ - -char *fd_load(int fd, size_t *psize, size_t maxsize) -{ - SMB_STRUCT_STAT sbuf; - size_t size; - char *p; - - if (sys_fstat(fd, &sbuf) != 0) { - return NULL; - } - - size = sbuf.st_size; - if (maxsize) { - size = MIN(size, maxsize); - } - - p = (char *)SMB_MALLOC(size+1); - if (!p) { - return NULL; - } - - if (read(fd, p, size) != size) { - SAFE_FREE(p); - return NULL; - } - p[size] = 0; - - if (psize) { - *psize = size; - } - - return p; -} - -/**************************************************************************** - Load a file into memory. -****************************************************************************/ - -char *file_load(const char *fname, size_t *size, size_t maxsize) -{ - int fd; - char *p; - - if (!fname || !*fname) { - return NULL; - } - - fd = open(fname,O_RDONLY); - if (fd == -1) { - return NULL; - } - - p = fd_load(fd, size, maxsize); - close(fd); - return p; -} - -/******************************************************************* - unmap or free memory -*******************************************************************/ - -bool unmap_file(void* start, size_t size) -{ -#ifdef HAVE_MMAP - if ( munmap( start, size ) != 0 ) { - DEBUG( 1, ("map_file: Failed to unmap address %p " - "of size %u - %s\n", - start, (unsigned int)size, strerror(errno) )); - return False; - } - return True; -#else - SAFE_FREE( start ); - return True; -#endif -} - -/******************************************************************* - mmap (if possible) or read a file. -********************************************************************/ - -void *map_file(char *fname, size_t size) -{ - size_t s2 = 0; - void *p = NULL; -#ifdef HAVE_MMAP - int fd; - fd = open(fname, O_RDONLY, 0); - if (fd == -1) { - DEBUG(2,("map_file: Failed to load %s - %s\n", fname, strerror(errno))); - return NULL; - } - p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0); - close(fd); - if (p == MAP_FAILED) { - DEBUG(1,("map_file: Failed to mmap %s - %s\n", fname, strerror(errno))); - return NULL; - } -#endif - if (!p) { - p = file_load(fname, &s2, 0); - if (!p) { - return NULL; - } - if (s2 != size) { - DEBUG(1,("map_file: incorrect size for %s - got %lu expected %lu\n", - fname, (unsigned long)s2, (unsigned long)size)); - SAFE_FREE(p); - return NULL; - } - } - return p; -} - -/**************************************************************************** - Parse a buffer into lines. -****************************************************************************/ - -static char **file_lines_parse(char *p, size_t size, int *numlines) -{ - int i; - char *s, **ret; - - if (!p) { - return NULL; - } - - for (s = p, i=0; s < p+size; s++) { - if (s[0] == '\n') i++; - } - - ret = SMB_MALLOC_ARRAY(char *, i+2); - if (!ret) { - SAFE_FREE(p); - return NULL; - } - memset(ret, 0, sizeof(ret[0])*(i+2)); - - ret[0] = p; - for (s = p, i=0; s < p+size; s++) { - if (s[0] == '\n') { - s[0] = 0; - i++; - ret[i] = s+1; - } - if (s[0] == '\r') { - s[0] = 0; - } - } - - /* remove any blank lines at the end */ - while (i > 0 && ret[i-1][0] == 0) { - i--; - } - - if (numlines) { - *numlines = i; - } - - return ret; -} - -/**************************************************************************** - Load a file into memory and return an array of pointers to lines in the file - must be freed with file_lines_free(). -****************************************************************************/ - -char **file_lines_load(const char *fname, int *numlines, size_t maxsize) -{ - char *p; - size_t size = 0; - - p = file_load(fname, &size, maxsize); - if (!p) { - return NULL; - } - - return file_lines_parse(p, size, numlines); -} - -/**************************************************************************** - Load a fd into memory and return an array of pointers to lines in the file - must be freed with file_lines_free(). If convert is true calls unix_to_dos on - the list. -****************************************************************************/ -char **fd_lines_load(int fd, int *numlines, size_t maxsize) -{ - char *p; - size_t size; - p = fd_load(fd, &size, maxsize); - if (!p) { - return NULL; - } - - return file_lines_parse(p, size, numlines); -} - -/**************************************************************************** +/** Load a pipe into memory and return an array of pointers to lines in the data must be freed with file_lines_free(). -****************************************************************************/ +**/ -char **file_lines_pload(char *syscmd, int *numlines) +char **file_lines_pload(const char *syscmd, int *numlines) { char *p; size_t size; @@ -361,64 +82,5 @@ char **file_lines_pload(char *syscmd, int *numlines) return NULL; } - return file_lines_parse(p, size, numlines); -} - -/**************************************************************************** - Free lines loaded with file_lines_load. -****************************************************************************/ - -void file_lines_free(char **lines) -{ - if (!lines) { - return; - } - SAFE_FREE(lines[0]); - SAFE_FREE(lines); -} - -/**************************************************************************** - Take a list of lines and modify them to produce a list where \ continues - a line. -****************************************************************************/ - -void file_lines_slashcont(char **lines) -{ - int i, j; - - for (i=0; lines[i];) { - int len = strlen(lines[i]); - if (lines[i][len-1] == '\\') { - lines[i][len-1] = ' '; - if (lines[i+1]) { - char *p = &lines[i][len]; - while (p < lines[i+1]) { - *p++ = ' '; - } - for (j = i+1; lines[j]; j++) { - lines[j] = lines[j+1]; - } - } - } else { - i++; - } - } -} - -/**************************************************************************** - Save a lump of data into a file. Mostly used for debugging. -****************************************************************************/ - -bool file_save(const char *fname, void *packet, size_t length) -{ - int fd; - fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644); - if (fd == -1) { - return False; - } - if (write(fd, packet, length) != (size_t)length) { - return False; - } - close(fd); - return True; + return file_lines_parse(p, size, numlines, NULL); } diff --git a/source3/lib/util_pw.c b/source3/lib/util_pw.c index 428378505f..c0d37f1094 100644 --- a/source3/lib/util_pw.c +++ b/source3/lib/util_pw.c @@ -47,7 +47,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name) struct passwd *temp, *cached; temp = (struct passwd *)memcache_lookup_talloc( - NULL, GETPWNAM_CACHE, data_blob_string_const(name)); + NULL, GETPWNAM_CACHE, data_blob_string_const_null(name)); if (temp != NULL) { return tcopy_passwd(mem_ctx, temp); } @@ -65,7 +65,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name) return temp; } - memcache_add_talloc(NULL, GETPWNAM_CACHE, data_blob_string_const(name), + memcache_add_talloc(NULL, GETPWNAM_CACHE, data_blob_string_const_null(name), cached); return tcopy_passwd(mem_ctx, temp); } diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c index 87e70bb95b..7e461556b3 100644 --- a/source3/lib/util_seaccess.c +++ b/source3/lib/util_seaccess.c @@ -30,7 +30,7 @@ extern NT_USER_TOKEN anonymous_token; static uint32 check_ace(SEC_ACE *ace, const NT_USER_TOKEN *token, uint32 acc_desired, NTSTATUS *status) { - uint32 mask = ace->access_mask; + uint32_t mask = ace->access_mask; /* * Inherit only is ignored. @@ -176,6 +176,24 @@ void se_map_generic(uint32 *access_mask, const struct generic_mapping *mapping) } } +/* Map generic access rights to object specific rights for all the ACE's + * in a security_acl. + */ + +void security_acl_map_generic(struct security_acl *sa, + const struct generic_mapping *mapping) +{ + unsigned int i; + + if (!sa) { + return; + } + + for (i = 0; i < sa->num_aces; i++) { + se_map_generic(&sa->aces[i].access_mask, mapping); + } +} + /* Map standard access rights to object specific rights. This technique is used to give meaning to assigning read, write, execute and all access to objects. Each type of object has its own mapping of standard to object @@ -328,7 +346,6 @@ NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) DOM_SID act_sid; SEC_ACE ace[3]; - SEC_ACCESS mask; SEC_ACL *psa = NULL; @@ -339,13 +356,14 @@ NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_SAM_EXECUTE | GENERIC_RIGHTS_SAM_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, + GENERIC_RIGHTS_SAM_EXECUTE | GENERIC_RIGHTS_SAM_READ, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GENERIC_RIGHTS_SAM_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[1], &adm_sid, + SEC_ACE_TYPE_ACCESS_ALLOWED, GENERIC_RIGHTS_SAM_ALL_ACCESS, 0); + init_sec_ace(&ace[2], &act_sid, + SEC_ACE_TYPE_ACCESS_ALLOWED, GENERIC_RIGHTS_SAM_ALL_ACCESS, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e20768ed89..f3dc3fc1d1 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1706,7 +1706,7 @@ static bool lookup_nc(struct name_addr_pair *nc) if (!memcache_lookup( NULL, SINGLETON_CACHE, - data_blob_string_const("get_peer_name"), + data_blob_string_const_null("get_peer_name"), &tmp)) { return false; } @@ -1733,7 +1733,7 @@ static void store_nc(const struct name_addr_pair *nc) memcpy(tmp.data+sizeof(nc->ss), nc->name, namelen+1); memcache_add(NULL, SINGLETON_CACHE, - data_blob_string_const("get_peer_name"), + data_blob_string_const_null("get_peer_name"), tmp); data_blob_free(&tmp); } @@ -1945,7 +1945,7 @@ const char *get_mydnsfullname(void) DATA_BLOB tmp; if (memcache_lookup(NULL, SINGLETON_CACHE, - data_blob_string_const("get_mydnsfullname"), + data_blob_string_const_null("get_mydnsfullname"), &tmp)) { SMB_ASSERT(tmp.length > 0); return (const char *)tmp.data; @@ -1989,11 +1989,11 @@ const char *get_mydnsfullname(void) */ memcache_add(NULL, SINGLETON_CACHE, - data_blob_string_const("get_mydnsfullname"), - data_blob_string_const(res->ai_canonname)); + data_blob_string_const_null("get_mydnsfullname"), + data_blob_string_const_null(res->ai_canonname)); if (!memcache_lookup(NULL, SINGLETON_CACHE, - data_blob_string_const("get_mydnsfullname"), + data_blob_string_const_null("get_mydnsfullname"), &tmp)) { tmp = data_blob_talloc(talloc_tos(), res->ai_canonname, strlen(res->ai_canonname) + 1); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 9f952abf10..046ce61ea3 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -557,47 +557,6 @@ bool trim_char(char *s,char cfront,char cback) return ret; } -/** - Trim the specified elements off the front and back of a string. -**/ - -bool trim_string(char *s,const char *front,const char *back) -{ - bool ret = false; - size_t front_len; - size_t back_len; - size_t len; - - /* Ignore null or empty strings. */ - if (!s || (s[0] == '\0')) - return false; - - front_len = front? strlen(front) : 0; - back_len = back? strlen(back) : 0; - - len = strlen(s); - - if (front_len) { - while (len && strncmp(s, front, front_len)==0) { - /* Must use memmove here as src & dest can - * easily overlap. Found by valgrind. JRA. */ - memmove(s, s+front_len, (len-front_len)+1); - len -= front_len; - ret=true; - } - } - - if (back_len) { - while ((len >= back_len) && - strncmp(s+len-back_len,back,back_len)==0) { - s[len-back_len]='\0'; - len -= back_len; - ret=true; - } - } - return ret; -} - /** Does a string have any uppercase chars in it? **/ @@ -648,29 +607,6 @@ bool strhaslower(const char *s) return ret; } -/** - Find the number of 'c' chars in a string -**/ - -size_t count_chars(const char *s,char c) -{ - smb_ucs2_t *ptr; - int count; - smb_ucs2_t *alloc_tmpbuf = NULL; - size_t converted_size; - - if (!push_ucs2_allocate(&alloc_tmpbuf, s, &converted_size)) { - return 0; - } - - for(count=0,ptr=alloc_tmpbuf;*ptr;ptr++) - if(*ptr==UCS2_CHAR(c)) - count++; - - SAFE_FREE(alloc_tmpbuf); - return(count); -} - /** Safe string copy into a known length string. maxlength does not include the terminating zero. @@ -870,88 +806,6 @@ static char *strncpyn(char *dest, const char *src, size_t n, char c) } #endif -/** - Routine to get hex characters and turn them into a 16 byte array. - the array can be variable length, and any non-hex-numeric - characters are skipped. "0xnn" or "0Xnn" is specially catered - for. - - valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n" - -**/ - -size_t strhex_to_str(char *buf, size_t buf_len, const char *strhex, size_t strhex_len) -{ - size_t i; - size_t num_chars = 0; - unsigned char lonybble, hinybble; - const char *hexchars = "0123456789ABCDEF"; - char *p1 = NULL, *p2 = NULL; - - for (i = 0; i < strhex_len && strhex[i] != 0; i++) { - if (strnequal(hexchars, "0x", 2)) { - i++; /* skip two chars */ - continue; - } - - if (!(p1 = strchr_m(hexchars, toupper_ascii(strhex[i])))) - break; - - i++; /* next hex digit */ - - if (!(p2 = strchr_m(hexchars, toupper_ascii(strhex[i])))) - break; - - /* get the two nybbles */ - hinybble = PTR_DIFF(p1, hexchars); - lonybble = PTR_DIFF(p2, hexchars); - - if (num_chars >= buf_len) { - break; - } - buf[num_chars] = (hinybble << 4) | lonybble; - num_chars++; - - p1 = NULL; - p2 = NULL; - } - return num_chars; -} - -DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) -{ - DATA_BLOB ret_blob; - - if (mem_ctx != NULL) - ret_blob = data_blob_talloc(mem_ctx, NULL, strlen(strhex)/2+1); - else - ret_blob = data_blob(NULL, strlen(strhex)/2+1); - - ret_blob.length = strhex_to_str((char*)ret_blob.data, - ret_blob.length, - strhex, - strlen(strhex)); - - return ret_blob; -} - -/** - * Routine to print a buffer as HEX digits, into an allocated string. - */ - -char *hex_encode(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len) -{ - int i; - char *hex_buffer; - - hex_buffer = TALLOC_ARRAY(mem_ctx, char, (len*2)+1); - - for (i = 0; i < len; i++) - slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); - - return hex_buffer; -} - /** Check if a string is part of a list. **/ @@ -1843,136 +1697,6 @@ int fstr_sprintf(fstring s, const char *fmt, ...) #define S_LIST_ABS 16 /* List Allocation Block Size */ -char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) -{ - char **list; - const char *str; - char *s; - int num, lsize; - char *tok; - - if (!string || !*string) - return NULL; - - list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1); - if (list == NULL) { - return NULL; - } - lsize = S_LIST_ABS; - - s = talloc_strdup(list, string); - if (s == NULL) { - DEBUG(0,("str_list_make: Unable to allocate memory")); - TALLOC_FREE(list); - return NULL; - } - if (!sep) sep = LIST_SEP; - - num = 0; - str = s; - - while (next_token_talloc(list, &str, &tok, sep)) { - - if (num == lsize) { - char **tmp; - - lsize += S_LIST_ABS; - - tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *, - lsize + 1); - if (tmp == NULL) { - DEBUG(0,("str_list_make: " - "Unable to allocate memory")); - TALLOC_FREE(list); - return NULL; - } - - list = tmp; - - memset (&list[num], 0, - ((sizeof(char**)) * (S_LIST_ABS +1))); - } - - list[num] = tok; - num += 1; - } - - list[num] = NULL; - - TALLOC_FREE(s); - return list; -} - -bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src) -{ - char **list; - int i, num; - - *dest = NULL; - if (!src) - return false; - - num = 0; - while (src[num] != NULL) { - num += 1; - } - - list = TALLOC_ARRAY(mem_ctx, char *, num+1); - if (list == NULL) { - return false; - } - - for (i=0; i= '0' && c1 <= '9') - c1 = c1 - '0'; - else if (c1 >= 'A' && c1 <= 'F') - c1 = 10 + c1 - 'A'; - else if (c1 >= 'a' && c1 <= 'f') - c1 = 10 + c1 - 'a'; - else {p++; continue;} - - if (c2 >= '0' && c2 <= '9') - c2 = c2 - '0'; - else if (c2 >= 'A' && c2 <= 'F') - c2 = 10 + c2 - 'A'; - else if (c2 >= 'a' && c2 <= 'f') - c2 = 10 + c2 - 'a'; - else {p++; continue;} - - *p = (c1<<4) | c2; - - memmove(p+1, p+3, strlen(p+3)+1); - p++; - } -} - static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** @@ -2386,10 +2075,10 @@ char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data) } /* read a SMB_BIG_UINT from a string */ -SMB_BIG_UINT STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr) +uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr) { - SMB_BIG_UINT val = -1; + uint64_t val = -1; const char *p = nptr; if (!p) { @@ -2402,11 +2091,7 @@ SMB_BIG_UINT STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr) while (*p && isspace(*p)) p++; -#ifdef LARGE_SMB_OFF_T - sscanf(p,"%llu",&val); -#else /* LARGE_SMB_OFF_T */ - sscanf(p,"%lu",&val); -#endif /* LARGE_SMB_OFF_T */ + sscanf(p,"%"PRIu64,&val); if (entptr) { while (*p && isdigit(*p)) p++; @@ -2684,54 +2369,6 @@ bool validate_net_name( const char *name, } -/** -return the number of bytes occupied by a buffer in ASCII format -the result includes the null termination -limited by 'n' bytes -**/ -size_t ascii_len_n(const char *src, size_t n) -{ - size_t len; - - len = strnlen(src, n); - if (len+1 <= n) { - len += 1; - } - - return len; -} - -/** -return the number of bytes occupied by a buffer in CH_UTF16 format -the result includes the null termination -**/ -size_t utf16_len(const void *buf) -{ - size_t len; - - for (len = 0; SVAL(buf,len); len += 2) ; - - return len + 2; -} - -/** -return the number of bytes occupied by a buffer in CH_UTF16 format -the result includes the null termination -limited by 'n' bytes -**/ -size_t utf16_len_n(const void *src, size_t n) -{ - size_t len; - - for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ; - - if (len+2 <= n) { - len += 2; - } - - return len; -} - /******************************************************************* Add a shell escape character '\' to any character not in a known list of characters. UNIX charset format. diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index 8257232667..bb568bc22e 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -39,28 +39,6 @@ static void gotalarm_sig(void) gotalarm = 1; } -/*************************************************************** - Make a TDB_DATA and keep the const warning in one place -****************************************************************/ - -TDB_DATA make_tdb_data(const uint8 *dptr, size_t dsize) -{ - TDB_DATA ret; - ret.dptr = CONST_DISCARD(uint8 *, dptr); - ret.dsize = dsize; - return ret; -} - -TDB_DATA string_tdb_data(const char *string) -{ - return make_tdb_data((const uint8 *)string, string ? strlen(string) : 0 ); -} - -TDB_DATA string_term_tdb_data(const char *string) -{ - return make_tdb_data((const uint8 *)string, string ? strlen(string) + 1 : 0); -} - /**************************************************************************** Lock a chain with timeout (in seconds). ****************************************************************************/ @@ -109,17 +87,6 @@ int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int tim return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_WRLCK); } -/**************************************************************************** - Lock a chain by string. Return -1 if timeout or lock failed. -****************************************************************************/ - -int tdb_lock_bystring(TDB_CONTEXT *tdb, const char *keyval) -{ - TDB_DATA key = string_term_tdb_data(keyval); - - return tdb_chainlock(tdb, key); -} - int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, int timeout) { @@ -128,17 +95,6 @@ int tdb_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, return tdb_chainlock_with_timeout(tdb, key, timeout); } -/**************************************************************************** - Unlock a chain by string. -****************************************************************************/ - -void tdb_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval) -{ - TDB_DATA key = string_term_tdb_data(keyval); - - tdb_chainunlock(tdb, key); -} - /**************************************************************************** Read lock a chain by string. Return -1 if timeout or lock failed. ****************************************************************************/ @@ -150,155 +106,8 @@ int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, un return tdb_chainlock_with_timeout_internal(tdb, key, timeout, F_RDLCK); } -/**************************************************************************** - Read unlock a chain by string. -****************************************************************************/ - -void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, const char *keyval) -{ - TDB_DATA key = string_term_tdb_data(keyval); - - tdb_chainunlock_read(tdb, key); -} - - -/**************************************************************************** - Fetch a int32 value by a arbitrary blob key, return -1 if not found. - Output is int32 in native byte order. -****************************************************************************/ - -int32 tdb_fetch_int32_byblob(TDB_CONTEXT *tdb, TDB_DATA key) -{ - TDB_DATA data; - int32 ret; - - data = tdb_fetch(tdb, key); - if (!data.dptr || data.dsize != sizeof(int32)) { - SAFE_FREE(data.dptr); - return -1; - } - - ret = IVAL(data.dptr,0); - SAFE_FREE(data.dptr); - return ret; -} - -/**************************************************************************** - Fetch a int32 value by string key, return -1 if not found. - Output is int32 in native byte order. -****************************************************************************/ - -int32 tdb_fetch_int32(TDB_CONTEXT *tdb, const char *keystr) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_fetch_int32_byblob(tdb, key); -} - -/**************************************************************************** - Store a int32 value by an arbitary blob key, return 0 on success, -1 on failure. - Input is int32 in native byte order. Output in tdb is in little-endian. -****************************************************************************/ - -int tdb_store_int32_byblob(TDB_CONTEXT *tdb, TDB_DATA key, int32 v) -{ - TDB_DATA data; - int32 v_store; - - SIVAL(&v_store,0,v); - data.dptr = (uint8 *)&v_store; - data.dsize = sizeof(int32); - - return tdb_store(tdb, key, data, TDB_REPLACE); -} - -/**************************************************************************** - Store a int32 value by string key, return 0 on success, -1 on failure. - Input is int32 in native byte order. Output in tdb is in little-endian. -****************************************************************************/ - -int tdb_store_int32(TDB_CONTEXT *tdb, const char *keystr, int32 v) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_store_int32_byblob(tdb, key, v); -} - -/**************************************************************************** - Fetch a uint32 value by a arbitrary blob key, return -1 if not found. - Output is uint32 in native byte order. -****************************************************************************/ - -bool tdb_fetch_uint32_byblob(TDB_CONTEXT *tdb, TDB_DATA key, uint32 *value) -{ - TDB_DATA data; - - data = tdb_fetch(tdb, key); - if (!data.dptr || data.dsize != sizeof(uint32)) { - SAFE_FREE(data.dptr); - return False; - } - - *value = IVAL(data.dptr,0); - SAFE_FREE(data.dptr); - return True; -} - -/**************************************************************************** - Fetch a uint32 value by string key, return -1 if not found. - Output is uint32 in native byte order. -****************************************************************************/ - -bool tdb_fetch_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32 *value) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_fetch_uint32_byblob(tdb, key, value); -} - -/**************************************************************************** - Store a uint32 value by an arbitary blob key, return 0 on success, -1 on failure. - Input is uint32 in native byte order. Output in tdb is in little-endian. -****************************************************************************/ - -bool tdb_store_uint32_byblob(TDB_CONTEXT *tdb, TDB_DATA key, uint32 value) -{ - TDB_DATA data; - uint32 v_store; - bool ret = True; - - SIVAL(&v_store, 0, value); - data.dptr = (uint8 *)&v_store; - data.dsize = sizeof(uint32); - if (tdb_store(tdb, key, data, TDB_REPLACE) == -1) - ret = False; - return ret; -} - -/**************************************************************************** - Store a uint32 value by string key, return 0 on success, -1 on failure. - Input is uint32 in native byte order. Output in tdb is in little-endian. -****************************************************************************/ - -bool tdb_store_uint32(TDB_CONTEXT *tdb, const char *keystr, uint32 value) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_store_uint32_byblob(tdb, key, value); -} -/**************************************************************************** - Store a buffer by a null terminated string key. Return 0 on success, -1 - on failure. -****************************************************************************/ - -int tdb_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_store(tdb, key, data, flags); -} int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags) @@ -308,112 +117,6 @@ int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr, return tdb_trans_store(tdb, key, data, flags); } -/**************************************************************************** - Fetch a buffer using a null terminated string key. Don't forget to call - free() on the result dptr. -****************************************************************************/ - -TDB_DATA tdb_fetch_bystring(TDB_CONTEXT *tdb, const char *keystr) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_fetch(tdb, key); -} - -/**************************************************************************** - Delete an entry using a null terminated string key. -****************************************************************************/ - -int tdb_delete_bystring(TDB_CONTEXT *tdb, const char *keystr) -{ - TDB_DATA key = string_term_tdb_data(keystr); - - return tdb_delete(tdb, key); -} - -/**************************************************************************** - Atomic integer change. Returns old value. To create, set initial value in *oldval. -****************************************************************************/ - -int32 tdb_change_int32_atomic(TDB_CONTEXT *tdb, const char *keystr, int32 *oldval, int32 change_val) -{ - int32 val; - int32 ret = -1; - - if (tdb_lock_bystring(tdb, keystr) == -1) - return -1; - - if ((val = tdb_fetch_int32(tdb, keystr)) == -1) { - /* The lookup failed */ - if (tdb_error(tdb) != TDB_ERR_NOEXIST) { - /* but not because it didn't exist */ - goto err_out; - } - - /* Start with 'old' value */ - val = *oldval; - - } else { - /* It worked, set return value (oldval) to tdb data */ - *oldval = val; - } - - /* Increment value for storage and return next time */ - val += change_val; - - if (tdb_store_int32(tdb, keystr, val) == -1) - goto err_out; - - ret = 0; - - err_out: - - tdb_unlock_bystring(tdb, keystr); - return ret; -} - -/**************************************************************************** - Atomic unsigned integer change. Returns old value. To create, set initial value in *oldval. -****************************************************************************/ - -bool tdb_change_uint32_atomic(TDB_CONTEXT *tdb, const char *keystr, uint32 *oldval, uint32 change_val) -{ - uint32 val; - bool ret = False; - - if (tdb_lock_bystring(tdb, keystr) == -1) - return False; - - if (!tdb_fetch_uint32(tdb, keystr, &val)) { - /* It failed */ - if (tdb_error(tdb) != TDB_ERR_NOEXIST) { - /* and not because it didn't exist */ - goto err_out; - } - - /* Start with 'old' value */ - val = *oldval; - - } else { - /* it worked, set return value (oldval) to tdb data */ - *oldval = val; - - } - - /* get a new value to store */ - val += change_val; - - if (!tdb_store_uint32(tdb, keystr, val)) - goto err_out; - - ret = True; - - err_out: - - tdb_unlock_bystring(tdb, keystr); - return ret; -} - /**************************************************************************** Useful pair of routines for packing/unpacking data consisting of integers and strings. diff --git a/source3/lib/util_uuid.c b/source3/lib/util_uuid.c index 3a8f7b3f4f..c681b66d34 100644 --- a/source3/lib/util_uuid.c +++ b/source3/lib/util_uuid.c @@ -20,12 +20,6 @@ #include "includes.h" -/* - * Offset between 15-Oct-1582 and 1-Jan-70 - */ -#define TIME_OFFSET_HIGH 0x01B21DD2 -#define TIME_OFFSET_LOW 0x13814000 - void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr) { SIVAL(ptr->info, 0, uu.time_low); @@ -44,78 +38,6 @@ void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu) memcpy(uu->node, in.info+10, 6); } -void smb_uuid_generate_random(struct GUID *uu) -{ - UUID_FLAT tmp; - - generate_random_buffer(tmp.info, sizeof(tmp.info)); - smb_uuid_unpack(tmp, uu); - - uu->clock_seq[0] = (uu->clock_seq[0] & 0x3F) | 0x80; - uu->time_hi_and_version = (uu->time_hi_and_version & 0x0FFF) | 0x4000; -} - -const char *smb_uuid_string(TALLOC_CTX *mem_ctx, const struct GUID uu) -{ - char *result; - - result = talloc_asprintf( - mem_ctx, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uu.time_low, uu.time_mid, uu.time_hi_and_version, - uu.clock_seq[0], uu.clock_seq[1], - uu.node[0], uu.node[1], uu.node[2], - uu.node[3], uu.node[4], uu.node[5]); - - SMB_ASSERT(result != NULL); - return result; -} - -bool smb_string_to_uuid(const char *in, struct GUID* uu) -{ - bool ret = False; - const char *ptr = in; - char *end = (char *)in; - int i; - unsigned v1, v2; - - if (!in || !uu) goto out; - - uu->time_low = strtoul(ptr, &end, 16); - if ((end - ptr) != 8 || *end != '-') goto out; - ptr = (end + 1); - - uu->time_mid = strtoul(ptr, &end, 16); - if ((end - ptr) != 4 || *end != '-') goto out; - ptr = (end + 1); - - uu->time_hi_and_version = strtoul(ptr, &end, 16); - if ((end - ptr) != 4 || *end != '-') goto out; - ptr = (end + 1); - - if (sscanf(ptr, "%02x%02x", &v1, &v2) != 2) { - goto out; - } - uu->clock_seq[0] = v1; - uu->clock_seq[1] = v2; - ptr += 4; - - if (*ptr != '-') goto out; - ptr++; - - for (i = 0; i < 6; i++) { - if (sscanf(ptr, "%02x", &v1) != 1) { - goto out; - } - uu->node[i] = v1; - ptr += 2; - } - - ret = True; -out: - return ret; -} - /***************************************************************** Return the binary string representation of a GUID. Caller must free. diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c deleted file mode 100644 index e44a92d34d..0000000000 --- a/source3/lib/xfile.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - Unix SMB/CIFS implementation. - stdio replacement - Copyright (C) Andrew Tridgell 2001 - - 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 . -*/ - -/* - stdio is very convenient, but on some systems the file descriptor - in FILE* is 8 bits, so it fails when more than 255 files are open. - - XFILE replaces stdio. It is less efficient, but at least it works - when you have lots of files open - - The main restriction on XFILE is that it doesn't support seeking, - and doesn't support O_RDWR. That keeps the code simple. -*/ - -#include "includes.h" - -#define XBUFSIZE BUFSIZ - -static XFILE _x_stdin = { 0, NULL, NULL, XBUFSIZE, 0, O_RDONLY, X_IOFBF, 0 }; -static XFILE _x_stdout = { 1, NULL, NULL, XBUFSIZE, 0, O_WRONLY, X_IOLBF, 0 }; -static XFILE _x_stderr = { 2, NULL, NULL, 0, 0, O_WRONLY, X_IONBF, 0 }; - -XFILE *x_stdin = &_x_stdin; -XFILE *x_stdout = &_x_stdout; -XFILE *x_stderr = &_x_stderr; - -#define X_FLAG_EOF 1 -#define X_FLAG_ERROR 2 -#define X_FLAG_EINVAL 3 - -/* simulate setvbuf() */ -int x_setvbuf(XFILE *f, char *buf, int mode, size_t size) -{ - if (x_fflush(f) != 0) return -1; - if (f->bufused) return -1; - - /* on files being read full buffering is the only option */ - if ((f->open_flags & O_ACCMODE) == O_RDONLY) { - mode = X_IOFBF; - } - - /* destroy any earlier buffer */ - SAFE_FREE(f->buf); - f->buf = 0; - f->bufsize = 0; - f->next = NULL; - f->bufused = 0; - f->buftype = mode; - - if (f->buftype == X_IONBF) return 0; - - /* if buffering then we need some size */ - if (size == 0) size = XBUFSIZE; - - f->bufsize = size; - f->bufused = 0; - - return 0; -} - -/* allocate the buffer */ -static int x_allocate_buffer(XFILE *f) -{ - if (f->buf) return 1; - if (f->bufsize == 0) return 0; - f->buf = (char *)SMB_MALLOC(f->bufsize); - if (!f->buf) return 0; - f->next = f->buf; - return 1; -} - - -/* this looks more like open() than fopen(), but that is quite deliberate. - I want programmers to *think* about O_EXCL, O_CREAT etc not just - get them magically added -*/ -XFILE *x_fopen(const char *fname, int flags, mode_t mode) -{ - XFILE *ret; - - ret = SMB_MALLOC_P(XFILE); - if (!ret) { - return NULL; - } - - memset(ret, 0, sizeof(XFILE)); - - if ((flags & O_ACCMODE) == O_RDWR) { - /* we don't support RDWR in XFILE - use file - descriptors instead */ - SAFE_FREE(ret); - errno = EINVAL; - return NULL; - } - - ret->open_flags = flags; - - ret->fd = sys_open(fname, flags, mode); - if (ret->fd == -1) { - SAFE_FREE(ret); - return NULL; - } - - x_setvbuf(ret, NULL, X_IOFBF, XBUFSIZE); - - return ret; -} - -XFILE *x_fdup(const XFILE *f) -{ - XFILE *ret; - int fd; - - fd = dup(x_fileno(f)); - if (fd < 0) { - return NULL; - } - - ret = SMB_CALLOC_ARRAY(XFILE, 1); - if (!ret) { - close(fd); - return NULL; - } - - ret->fd = fd; - ret->open_flags = f->open_flags; - x_setvbuf(ret, NULL, X_IOFBF, XBUFSIZE); - return ret; -} - -/* simulate fclose() */ -int x_fclose(XFILE *f) -{ - int ret; - - /* make sure we flush any buffered data */ - (void)x_fflush(f); - - ret = close(f->fd); - f->fd = -1; - if (f->buf) { - /* make sure data can't leak into a later malloc */ - memset(f->buf, 0, f->bufsize); - SAFE_FREE(f->buf); - } - /* check the file descriptor given to the function is NOT one of the static - * descriptor of this libreary or we will free unallocated memory - * --sss */ - if (f != x_stdin && f != x_stdout && f != x_stderr) { - SAFE_FREE(f); - } - return ret; -} - -/* simulate fwrite() */ -size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f) -{ - ssize_t ret; - size_t total=0; - - /* we might be writing unbuffered */ - if (f->buftype == X_IONBF || - (!f->buf && !x_allocate_buffer(f))) { - ret = write(f->fd, p, size*nmemb); - if (ret == -1) return -1; - return ret/size; - } - - - while (total < size*nmemb) { - size_t n = f->bufsize - f->bufused; - n = MIN(n, (size*nmemb)-total); - - if (n == 0) { - /* it's full, flush it */ - if (x_fflush(f) != 0) { - return -1; - } - continue; - } - - memcpy(f->buf + f->bufused, total+(const char *)p, n); - f->bufused += n; - total += n; - } - - /* when line buffered we need to flush at the last linefeed. This can - flush a bit more than necessary, but that is harmless */ - if (f->buftype == X_IOLBF && f->bufused) { - int i; - for (i=(size*nmemb)-1; i>=0; i--) { - if (*(i+(const char *)p) == '\n') { - if (x_fflush(f) != 0) { - return -1; - } - break; - } - } - } - - return total/size; -} - -/* thank goodness for asprintf() */ - int x_vfprintf(XFILE *f, const char *format, va_list ap) -{ - char *p; - int len, ret; - va_list ap2; - - VA_COPY(ap2, ap); - - len = vasprintf(&p, format, ap2); - if (len <= 0) { - va_end(ap2); - return len; - } - ret = x_fwrite(p, 1, len, f); - SAFE_FREE(p); - - va_end(ap2); - - return ret; -} - - int x_fprintf(XFILE *f, const char *format, ...) -{ - va_list ap; - int ret; - - va_start(ap, format); - ret = x_vfprintf(f, format, ap); - va_end(ap); - return ret; -} - -/* at least fileno() is simple! */ -int x_fileno(const XFILE *f) -{ - return f->fd; -} - -/* simulate fflush() */ -int x_fflush(XFILE *f) -{ - int ret; - - if (f->flags & X_FLAG_ERROR) return -1; - - if (f->bufused == 0 || !f->buf) return 0; - - if ((f->open_flags & O_ACCMODE) != O_WRONLY) { - errno = EINVAL; - return -1; - } - - ret = write(f->fd, f->buf, f->bufused); - if (ret == -1) return -1; - - f->bufused -= ret; - if (f->bufused > 0) { - f->flags |= X_FLAG_ERROR; - memmove(f->buf, ret + (char *)f->buf, f->bufused); - return -1; - } - - return 0; -} - -/* simulate setbuffer() */ -void x_setbuffer(XFILE *f, char *buf, size_t size) -{ - x_setvbuf(f, buf, buf?X_IOFBF:X_IONBF, size); -} - -/* simulate setbuf() */ -void x_setbuf(XFILE *f, char *buf) -{ - x_setvbuf(f, buf, buf?X_IOFBF:X_IONBF, XBUFSIZE); -} - -/* simulate setlinebuf() */ -void x_setlinebuf(XFILE *f) -{ - x_setvbuf(f, NULL, X_IOLBF, 0); -} - - -/* simulate feof() */ -int x_feof(XFILE *f) -{ - if (f->flags & X_FLAG_EOF) return 1; - return 0; -} - -/* simulate ferror() */ -int x_ferror(XFILE *f) -{ - if (f->flags & X_FLAG_ERROR) return 1; - return 0; -} - -/* fill the read buffer */ -static void x_fillbuf(XFILE *f) -{ - int n; - - if (f->bufused) return; - - if (!f->buf && !x_allocate_buffer(f)) return; - - n = read(f->fd, f->buf, f->bufsize); - if (n <= 0) return; - f->bufused = n; - f->next = f->buf; -} - -/* simulate fgetc() */ -int x_fgetc(XFILE *f) -{ - int ret; - - if (f->flags & (X_FLAG_EOF | X_FLAG_ERROR)) return EOF; - - if (f->bufused == 0) x_fillbuf(f); - - if (f->bufused == 0) { - f->flags |= X_FLAG_EOF; - return EOF; - } - - ret = *(unsigned char *)(f->next); - f->next++; - f->bufused--; - return ret; -} - -/* simulate fread */ -size_t x_fread(void *p, size_t size, size_t nmemb, XFILE *f) -{ - size_t total = 0; - while (total < size*nmemb) { - int c = x_fgetc(f); - if (c == EOF) break; - (total+(char *)p)[0] = (char)c; - total++; - } - return total/size; -} - -/* simulate fgets() */ -char *x_fgets(char *s, int size, XFILE *stream) -{ - char *s0 = s; - int l = size; - while (l>1) { - int c = x_fgetc(stream); - if (c == EOF) break; - *s++ = (char)c; - l--; - if (c == '\n') break; - } - if (l==size || x_ferror(stream)) { - return 0; - } - *s = 0; - return s0; -} - -/* trivial seek, works only for SEEK_SET and SEEK_END if SEEK_CUR is - * set then an error is returned */ -off_t x_tseek(XFILE *f, off_t offset, int whence) -{ - if (f->flags & X_FLAG_ERROR) - return -1; - - /* only SEEK_SET and SEEK_END are supported */ - /* SEEK_CUR needs internal offset counter */ - if (whence != SEEK_SET && whence != SEEK_END) { - f->flags |= X_FLAG_EINVAL; - errno = EINVAL; - return -1; - } - - /* empty the buffer */ - switch (f->open_flags & O_ACCMODE) { - case O_RDONLY: - f->bufused = 0; - break; - case O_WRONLY: - if (x_fflush(f) != 0) - return -1; - break; - default: - errno = EINVAL; - return -1; - } - - f->flags &= ~X_FLAG_EOF; - return (off_t)sys_lseek(f->fd, offset, whence); -} diff --git a/source3/libaddns/dns.h b/source3/libaddns/dns.h index 2eaeaf7608..3f95c739d5 100644 --- a/source3/libaddns/dns.h +++ b/source3/libaddns/dns.h @@ -25,7 +25,7 @@ #ifndef _DNS_H #define _DNS_H -#include "lib/replace/replace.h" +#include "../replace/replace.h" #include "system/network.h" /* make sure we have included the correct config.h */ diff --git a/source3/libaddns/dnsmarshall.c b/source3/libaddns/dnsmarshall.c index 8c3389eb9b..5530290c57 100644 --- a/source3/libaddns/dnsmarshall.c +++ b/source3/libaddns/dnsmarshall.c @@ -252,6 +252,7 @@ void dns_unmarshall_domain_name(TALLOC_CTX *mem_ctx, if (!(name = talloc(mem_ctx, struct dns_domain_name))) { buf->error = ERROR_DNS_NO_MEMORY; + return; } dns_unmarshall_label(name, 0, buf, &name->pLabelList); diff --git a/source3/libaddns/dnsrecord.c b/source3/libaddns/dnsrecord.c index 500cbd6681..559c2644d4 100644 --- a/source3/libaddns/dnsrecord.c +++ b/source3/libaddns/dnsrecord.c @@ -378,10 +378,10 @@ DNS_ERROR dns_create_update_request(TALLOC_CTX *mem_ctx, if (!ERR_DNS_IS_OK(err)) return err; /* - * The zone must be used at all + * Use the same prereq as WinXP -- No CNAME records for this host. */ - err = dns_create_rrec(req, domainname, QTYPE_ANY, DNS_CLASS_ANY, + err = dns_create_rrec(req, hostname, QTYPE_CNAME, DNS_CLASS_NONE, 0, 0, NULL, &rec); if (!ERR_DNS_IS_OK(err)) goto error; diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index 0bde3e6984..9f0f68ed7b 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -23,6 +23,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" #ifdef HAVE_KRB5 @@ -108,7 +109,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data, - pac_data, + NULL, pac_data, (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -124,7 +125,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } ndr_err = ndr_pull_struct_blob(pac_data_blob, pac_data_raw, - pac_data_raw, + NULL, pac_data_raw, (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA_RAW); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -205,7 +206,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, /* We find the data blobs above, now we parse them to get at the exact portion we should zero */ ndr_err = ndr_pull_struct_blob(kdc_sig_blob, kdc_sig_wipe, - kdc_sig_wipe, + NULL, kdc_sig_wipe, (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -215,7 +216,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, } ndr_err = ndr_pull_struct_blob(srv_sig_blob, srv_sig_wipe, - srv_sig_wipe, + NULL, srv_sig_wipe, (ndr_pull_flags_fn_t)ndr_pull_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -230,7 +231,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, /* and reencode, back into the same place it came from */ ndr_err = ndr_push_struct_blob(kdc_sig_blob, pac_data_raw, - kdc_sig_wipe, + NULL, kdc_sig_wipe, (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -239,7 +240,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, return status; } ndr_err = ndr_push_struct_blob(srv_sig_blob, pac_data_raw, - srv_sig_wipe, + NULL, srv_sig_wipe, (ndr_push_flags_fn_t)ndr_push_PAC_SIGNATURE_DATA); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -250,7 +251,7 @@ static krb5_error_code check_pac_checksum(TALLOC_CTX *mem_ctx, /* push out the whole structure, but now with zero'ed signatures */ ndr_err = ndr_push_struct_blob(&modified_pac_blob, pac_data_raw, - pac_data_raw, + NULL, pac_data_raw, (ndr_push_flags_fn_t)ndr_push_PAC_DATA_RAW); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -403,12 +404,12 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx, DEBUG(10,("got TGT for %s in %s\n", auth_princ, cc)); if (expire_time) { DEBUGADD(10,("\tvalid until: %s (%d)\n", - http_timestring(*expire_time), + http_timestring(talloc_tos(), *expire_time), (int)*expire_time)); } if (renew_till_time) { DEBUGADD(10,("\trenewable till: %s (%d)\n", - http_timestring(*renew_till_time), + http_timestring(talloc_tos(), *renew_till_time), (int)*renew_till_time)); } diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c index 11565065af..c37220c903 100644 --- a/source3/libads/cldap.c +++ b/source3/libads/cldap.c @@ -119,8 +119,8 @@ static void gotalarm_sig(void) */ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, int sock, - uint32_t *nt_version, - union nbt_cldap_netlogon **reply) + uint32_t nt_version, + struct netlogon_samlogon_response **reply) { int ret; ASN1_DATA data; @@ -131,7 +131,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, int i1; /* half the time of a regular ldap timeout, not less than 3 seconds. */ unsigned int al_secs = MAX(3,lp_ldap_timeout()/2); - union nbt_cldap_netlogon *r = NULL; + struct netlogon_samlogon_response *r = NULL; + NTSTATUS status; blob = data_blob(NULL, 8192); if (blob.data == NULL) { @@ -185,7 +186,7 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, return -1; } - r = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon); + r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response); if (!r) { errno = ENOMEM; data_blob_free(&os1); @@ -195,7 +196,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, return -1; } - if (!pull_mailslot_cldap_reply(mem_ctx, &os3, r, nt_version)) { + status = pull_netlogon_samlogon_response(&os3, mem_ctx, NULL, r); + if (!NT_STATUS_IS_OK(status)) { data_blob_free(&os1); data_blob_free(&os2); data_blob_free(&os3); @@ -204,6 +206,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, return -1; } + map_netlogon_samlogon_response(r); + data_blob_free(&os1); data_blob_free(&os2); data_blob_free(&os3); @@ -227,8 +231,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx, bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *server, const char *realm, - uint32_t *nt_version, - union nbt_cldap_netlogon **reply) + uint32_t nt_version, + struct netlogon_samlogon_response **reply) { int sock; int ret; @@ -240,7 +244,7 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, return False; } - ret = send_cldap_netlogon(sock, realm, global_myname(), *nt_version); + ret = send_cldap_netlogon(sock, realm, global_myname(), nt_version); if (ret != 0) { close(sock); return False; @@ -262,107 +266,24 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx, bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx, const char *server, const char *realm, - struct nbt_cldap_netlogon_5 *reply5) + struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5) { - uint32_t nt_version = NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX; - union nbt_cldap_netlogon *reply = NULL; + uint32_t nt_version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; + struct netlogon_samlogon_response *reply = NULL; bool ret; - ret = ads_cldap_netlogon(mem_ctx, server, realm, &nt_version, &reply); + ret = ads_cldap_netlogon(mem_ctx, server, realm, nt_version, &reply); if (!ret) { return false; } - if (nt_version != (NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX)) { + if (reply->ntver != NETLOGON_NT_VERSION_5EX) { + DEBUG(0,("ads_cldap_netlogon_5: nt_version mismatch: 0x%08x\n", + reply->ntver)); return false; } - *reply5 = reply->logon5; - - return true; -} - -/**************************************************************** -****************************************************************/ - -bool pull_mailslot_cldap_reply(TALLOC_CTX *mem_ctx, - const DATA_BLOB *blob, - union nbt_cldap_netlogon *r, - uint32_t *nt_version) -{ - enum ndr_err_code ndr_err; - uint32_t nt_version_query = ((*nt_version) & 0x0000001f); - uint16_t command = 0; - - ndr_err = ndr_pull_struct_blob(blob, mem_ctx, &command, - (ndr_pull_flags_fn_t)ndr_pull_uint16); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return false; - } - - switch (command) { - case 0x13: /* 19 */ - case 0x15: /* 21 */ - case 0x17: /* 23 */ - case 0x19: /* 25 */ - break; - default: - DEBUG(1,("got unexpected command: %d (0x%08x)\n", - command, command)); - return false; - } - - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - - /* when the caller requested just those nt_version bits that the server - * was able to reply to, we are fine and all done. otherwise we need to - * assume downgraded replies which are painfully parsed here - gd */ - - if (nt_version_query & NETLOGON_VERSION_WITH_CLOSEST_SITE) { - nt_version_query &= ~NETLOGON_VERSION_WITH_CLOSEST_SITE; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - if (nt_version_query & NETLOGON_VERSION_5EX_WITH_IP) { - nt_version_query &= ~NETLOGON_VERSION_5EX_WITH_IP; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - if (nt_version_query & NETLOGON_VERSION_5EX) { - nt_version_query &= ~NETLOGON_VERSION_5EX; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - if (nt_version_query & NETLOGON_VERSION_5) { - nt_version_query &= ~NETLOGON_VERSION_5; - } - ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - goto done; - } - - return false; - - done: - if (DEBUGLEVEL >= 10) { - NDR_PRINT_UNION_DEBUG(nbt_cldap_netlogon, nt_version_query, r); - } - - *nt_version = nt_version_query; + *reply5 = reply->data.nt5_ex; return true; } diff --git a/source3/libads/disp_sec.c b/source3/libads/disp_sec.c index f4c68638df..a5e04a4a6c 100644 --- a/source3/libads/disp_sec.c +++ b/source3/libads/disp_sec.c @@ -114,15 +114,15 @@ static void ads_disp_sec_ace_object(ADS_STRUCT *ads, { if (object->flags & SEC_ACE_OBJECT_PRESENT) { printf("Object type: SEC_ACE_OBJECT_PRESENT\n"); - printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, - object->type.type), + printf("Object GUID: %s (%s)\n", GUID_string(mem_ctx, + &object->type.type), ads_interprete_guid_from_object(ads, mem_ctx, &object->type.type)); } if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) { printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n"); - printf("Object GUID: %s (%s)\n", smb_uuid_string(mem_ctx, - object->inherited_type.inherited_type), + printf("Object GUID: %s (%s)\n", GUID_string(mem_ctx, + &object->inherited_type.inherited_type), ads_interprete_guid_from_object(ads, mem_ctx, &object->inherited_type.inherited_type)); } diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c index 719f3bd3ec..0ff9f2ba32 100644 --- a/source3/libads/krb5_setpw.c +++ b/source3/libads/krb5_setpw.c @@ -285,7 +285,7 @@ static krb5_error_code parse_setpw_reply(krb5_context context, return KRB5KRB_AP_ERR_MODIFIED; } - p = packet->data; + p = (char *)packet->data; /* ** see if it is an error */ @@ -368,7 +368,7 @@ static krb5_error_code parse_setpw_reply(krb5_context context, return KRB5KRB_AP_ERR_MODIFIED; } - p = clearresult.data; + p = (char *)clearresult.data; res_code = RSVAL(p, 0); @@ -687,10 +687,10 @@ kerb_prompter(krb5_context ctx, void *data, memset(prompts[0].reply->data, 0, prompts[0].reply->length); if (prompts[0].reply->length > 0) { if (data) { - strncpy(prompts[0].reply->data, + strncpy((char *)prompts[0].reply->data, (const char *)data, prompts[0].reply->length-1); - prompts[0].reply->length = strlen(prompts[0].reply->data); + prompts[0].reply->length = strlen((const char *)prompts[0].reply->data); } else { prompts[0].reply->length = 0; } diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index eb45e3a0dd..2dcd1fd6ae 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -176,7 +176,7 @@ bool ads_closest_dc(ADS_STRUCT *ads) static bool ads_try_connect(ADS_STRUCT *ads, const char *server, bool gc) { char *srv; - struct nbt_cldap_netlogon_5 cldap_reply; + struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply; TALLOC_CTX *mem_ctx = NULL; bool ret = false; @@ -801,7 +801,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads, int *count, struct berval **cookie) { int rc, i, version; - char *utf8_expr, *utf8_path, **search_attrs; + char *utf8_expr, *utf8_path, **search_attrs = NULL; size_t converted_size; LDAPControl PagedResults, NoReferrals, ExternalCtrl, *controls[4], **rcontrols; BerElement *cookie_be = NULL; @@ -832,7 +832,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads, else { /* This would be the utf8-encoded version...*/ /* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */ - if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) { + if (!(search_attrs = str_list_copy(talloc_tos(), attrs))) { rc = LDAP_NO_MEMORY; goto done; } @@ -1144,7 +1144,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, else { /* This would be the utf8-encoded version...*/ /* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */ - if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) + if (!(search_attrs = str_list_copy(talloc_tos(), attrs))) { DEBUG(1,("ads_do_search: str_list_copy() failed!")); rc = LDAP_NO_MEMORY; @@ -2062,7 +2062,7 @@ static void dump_guid(ADS_STRUCT *ads, const char *field, struct berval **values memcpy(guid.info, values[i]->bv_val, sizeof(guid.info)); smb_uuid_unpack(guid, &tmp); - printf("%s: %s\n", field, smb_uuid_string(talloc_tos(), tmp)); + printf("%s: %s\n", field, GUID_string(talloc_tos(), &tmp)); } } @@ -2828,6 +2828,7 @@ ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32 *val) if ( (ads_s = ads_init( ads->server.realm, ads->server.workgroup, ads->server.ldap_server )) == NULL ) { + status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY); goto done; } ads_s->auth.flags = ADS_AUTH_ANON_BIND; @@ -3747,7 +3748,7 @@ const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads, } expr = talloc_asprintf(mem_ctx, "(rightsGuid=%s)", - smb_uuid_string(mem_ctx, *rights_guid)); + GUID_string(mem_ctx, rights_guid)); if (!expr) { goto done; } diff --git a/source3/libads/ldap_schema.c b/source3/libads/ldap_schema.c index ff41ccc861..b5d2d35889 100644 --- a/source3/libads/ldap_schema.c +++ b/source3/libads/ldap_schema.c @@ -246,19 +246,22 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx, ADS_ATTR_SFU_GIDNUMBER_OID, ADS_ATTR_SFU_HOMEDIR_OID, ADS_ATTR_SFU_SHELL_OID, - ADS_ATTR_SFU_GECOS_OID}; + ADS_ATTR_SFU_GECOS_OID, + ADS_ATTR_SFU_UID_OID }; const char *oids_sfu20[] = { ADS_ATTR_SFU20_UIDNUMBER_OID, ADS_ATTR_SFU20_GIDNUMBER_OID, ADS_ATTR_SFU20_HOMEDIR_OID, ADS_ATTR_SFU20_SHELL_OID, - ADS_ATTR_SFU20_GECOS_OID}; + ADS_ATTR_SFU20_GECOS_OID, + ADS_ATTR_SFU20_UID_OID }; const char *oids_rfc2307[] = { ADS_ATTR_RFC2307_UIDNUMBER_OID, ADS_ATTR_RFC2307_GIDNUMBER_OID, ADS_ATTR_RFC2307_HOMEDIR_OID, ADS_ATTR_RFC2307_SHELL_OID, - ADS_ATTR_RFC2307_GECOS_OID }; + ADS_ATTR_RFC2307_GECOS_OID, + ADS_ATTR_RFC2307_UID_OID }; DEBUG(10,("ads_check_posix_schema_mapping for schema mode: %d\n", map_type)); @@ -359,6 +362,12 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx, strequal(ADS_ATTR_SFU20_GECOS_OID, oids_out[i])) { schema->posix_gecos_attr = talloc_strdup(schema, names_out[i]); } + + if (strequal(ADS_ATTR_RFC2307_UID_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_UID_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_UID_OID, oids_out[i])) { + schema->posix_uid_attr = talloc_strdup(schema, names_out[i]); + } } if (!schema->posix_uidnumber_attr || diff --git a/source3/libads/util.c b/source3/libads/util.c index 72f5dee80c..9866a15285 100644 --- a/source3/libads/util.c +++ b/source3/libads/util.c @@ -33,7 +33,7 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip return ADS_ERROR_SYSTEM(ENOENT); } - new_password = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); + new_password = generate_random_str(talloc_tos(), DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); ret = kerberos_set_password(ads->auth.kdc_server, host_principal, password, host_principal, new_password, ads->auth.time_offset); @@ -86,6 +86,8 @@ ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads, server_realm = SMB_STRDUP(ads->config.realm); if (!server || !server_realm) { + SAFE_FREE(server); + SAFE_FREE(server_realm); return ADS_ERROR(LDAP_NO_MEMORY); } diff --git a/source3/libcli/nbt/nbtname.c b/source3/libcli/nbt/nbtname.c deleted file mode 100644 index fbb9550655..0000000000 --- a/source3/libcli/nbt/nbtname.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - manipulate nbt name structures - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -/* - see rfc1002 for the detailed format of compressed names -*/ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_nbt.h" -#include "librpc/gen_ndr/ndr_misc.h" - -/* don't allow an unlimited number of name components */ -#define MAX_COMPONENTS 10 - -/** - print a nbt string -*/ -_PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s) -{ - ndr_print_string(ndr, name, s); -} - -/* - pull one component of a nbt_string -*/ -static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr, - uint8_t **component, - uint32_t *offset, - uint32_t *max_offset) -{ - uint8_t len; - uint_t loops = 0; - while (loops < 5) { - if (*offset >= ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "BAD NBT NAME component"); - } - len = ndr->data[*offset]; - if (len == 0) { - *offset += 1; - *max_offset = MAX(*max_offset, *offset); - *component = NULL; - return NDR_ERR_SUCCESS; - } - if ((len & 0xC0) == 0xC0) { - /* its a label pointer */ - if (1 + *offset >= ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "BAD NBT NAME component"); - } - *max_offset = MAX(*max_offset, *offset + 2); - *offset = ((len&0x3F)<<8) | ndr->data[1 + *offset]; - *max_offset = MAX(*max_offset, *offset); - loops++; - continue; - } - if ((len & 0xC0) != 0) { - /* its a reserved length field */ - return ndr_pull_error(ndr, NDR_ERR_STRING, - "BAD NBT NAME component"); - } - if (*offset + len + 2 > ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "BAD NBT NAME component"); - } - *component = (uint8_t*)talloc_strndup(ndr, (const char *)&ndr->data[1 + *offset], len); - NDR_ERR_HAVE_NO_MEMORY(*component); - *offset += len + 1; - *max_offset = MAX(*max_offset, *offset); - return NDR_ERR_SUCCESS; - } - - /* too many pointers */ - return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD NBT NAME component"); -} - -/** - pull a nbt_string from the wire -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s) -{ - uint32_t offset = ndr->offset; - uint32_t max_offset = offset; - unsigned num_components; - char *name; - - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - - name = NULL; - - /* break up name into a list of components */ - for (num_components=0;num_componentsoffset = max_offset; - - return NDR_ERR_SUCCESS; -} - -/** - push a nbt string to the wire -*/ -_PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s) -{ - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - - while (s && *s) { - enum ndr_err_code ndr_err; - char *compname; - size_t complen; - uint32_t offset; - - /* see if we have pushed the remaing string allready, - * if so we use a label pointer to this string - */ - ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false); - if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - uint8_t b[2]; - - if (offset > 0x3FFF) { - return ndr_push_error(ndr, NDR_ERR_STRING, - "offset for nbt string label pointer %u[%08X] > 0x00003FFF", - offset, offset); - } - - b[0] = 0xC0 | (offset>>8); - b[1] = (offset & 0xFF); - - return ndr_push_bytes(ndr, b, 2); - } - - complen = strcspn(s, "."); - - /* we need to make sure the length fits into 6 bytes */ - if (complen >= 0x3F) { - return ndr_push_error(ndr, NDR_ERR_STRING, - "component length %u[%08X] > 0x00003F", - (unsigned)complen, (unsigned)complen); - } - - compname = talloc_asprintf(ndr, "%c%*.*s", - (unsigned char)complen, - (unsigned char)complen, - (unsigned char)complen, s); - NDR_ERR_HAVE_NO_MEMORY(compname); - - /* remember the current componemt + the rest of the string - * so it can be reused later - */ - NDR_CHECK(ndr_token_store(ndr, &ndr->nbt_string_list, s, ndr->offset)); - - /* push just this component into the blob */ - NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, complen+1)); - talloc_free(compname); - - s += complen; - if (*s == '.') s++; - } - - /* if we reach the end of the string and have pushed the last component - * without using a label pointer, we need to terminate the string - */ - return ndr_push_bytes(ndr, (const uint8_t *)"", 1); -} - - -/* - decompress a 'compressed' name component - */ -static bool decompress_name(char *name, enum nbt_name_type *type) -{ - int i; - for (i=0;name[2*i];i++) { - uint8_t c1 = name[2*i]; - uint8_t c2 = name[1+(2*i)]; - if (c1 < 'A' || c1 > 'P' || - c2 < 'A' || c2 > 'P') { - return false; - } - name[i] = ((c1-'A')<<4) | (c2-'A'); - } - name[i] = 0; - if (i == 16) { - *type = (enum nbt_name_type)(name[15]); - name[15] = 0; - i--; - } else { - *type = NBT_NAME_CLIENT; - } - - /* trim trailing spaces */ - for (;i>0 && name[i-1]==' ';i--) { - name[i-1] = 0; - } - - return true; -} - - -/* - compress a name component - */ -static uint8_t *compress_name(TALLOC_CTX *mem_ctx, - const uint8_t *name, enum nbt_name_type type) -{ - uint8_t *cname; - int i; - uint8_t pad_char; - - if (strlen((const char *)name) > 15) { - return NULL; - } - - cname = talloc_array(mem_ctx, uint8_t, 33); - if (cname == NULL) return NULL; - - for (i=0;name[i];i++) { - cname[2*i] = 'A' + (name[i]>>4); - cname[1+2*i] = 'A' + (name[i]&0xF); - } - if (strcmp((const char *)name, "*") == 0) { - pad_char = 0; - } else { - pad_char = ' '; - } - for (;i<15;i++) { - cname[2*i] = 'A' + (pad_char>>4); - cname[1+2*i] = 'A' + (pad_char&0xF); - } - - pad_char = type; - cname[2*i] = 'A' + (pad_char>>4); - cname[1+2*i] = 'A' + (pad_char&0xF); - - cname[32] = 0; - return cname; -} - - -/** - pull a nbt name from the wire -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r) -{ - uint8_t *scope; - char *cname; - const char *s; - bool ok; - - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - - NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &s)); - - scope = (uint8_t *)strchr(s, '.'); - if (scope) { - *scope = 0; - r->scope = talloc_strdup(ndr->current_mem_ctx, (const char *)&scope[1]); - NDR_ERR_HAVE_NO_MEMORY(r->scope); - } else { - r->scope = NULL; - } - - cname = discard_const_p(char, s); - - /* the first component is limited to 16 bytes in the DOS charset, - which is 32 in the 'compressed' form */ - if (strlen(cname) > 32) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "NBT NAME cname > 32"); - } - - /* decompress the first component */ - ok = decompress_name(cname, &r->type); - if (!ok) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "NBT NAME failed to decompress"); - } - - r->name = talloc_strdup(ndr->current_mem_ctx, cname); - NDR_ERR_HAVE_NO_MEMORY(r->name); - - talloc_free(cname); - - return NDR_ERR_SUCCESS; -} - -/** - push a nbt name to the wire -*/ -_PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r) -{ - uint8_t *cname, *fullname; - enum ndr_err_code ndr_err; - - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - - if (strlen(r->name) > 15) { - return ndr_push_error(ndr, NDR_ERR_STRING, - "nbt_name longer as 15 chars: %s", - r->name); - } - - cname = compress_name(ndr, (const uint8_t *)r->name, r->type); - NDR_ERR_HAVE_NO_MEMORY(cname); - - if (r->scope) { - fullname = (uint8_t *)talloc_asprintf(ndr, "%s.%s", cname, r->scope); - NDR_ERR_HAVE_NO_MEMORY(fullname); - talloc_free(cname); - } else { - fullname = cname; - } - - ndr_err = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname); - - return ndr_err; -} - - -/** - copy a nbt name structure -*/ -_PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname) -{ - *newname = *name; - newname->name = talloc_strdup(mem_ctx, newname->name); - NT_STATUS_HAVE_NO_MEMORY(newname->name); - newname->scope = talloc_strdup(mem_ctx, newname->scope); - if (name->scope) { - NT_STATUS_HAVE_NO_MEMORY(newname->scope); - } - return NT_STATUS_OK; -} - -/** - push a nbt name into a blob -*/ -_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name) -{ - enum ndr_err_code ndr_err; - - ndr_err = ndr_push_struct_blob(blob, mem_ctx, name, (ndr_push_flags_fn_t)ndr_push_nbt_name); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return ndr_map_error2ntstatus(ndr_err); - } - - return NT_STATUS_OK; -} - -/** - pull a nbt name from a blob -*/ -_PUBLIC_ NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name) -{ - enum ndr_err_code ndr_err; - - ndr_err = ndr_pull_struct_blob(blob, mem_ctx, name, - (ndr_pull_flags_fn_t)ndr_pull_nbt_name); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return ndr_map_error2ntstatus(ndr_err); - } - - return NT_STATUS_OK; -} - - -/** - choose a name to use when calling a server in a NBT session request. - we use heuristics to see if the name we have been given is a IP - address, or a too-long name. If it is then use *SMBSERVER, or a - truncated name -*/ -_PUBLIC_ void nbt_choose_called_name(TALLOC_CTX *mem_ctx, - struct nbt_name *n, const char *name, int type) -{ - n->scope = NULL; - n->type = type; - - if ((name == NULL) || is_ipaddress(name)) { - n->name = "*SMBSERVER"; - return; - } - if (strlen(name) > 15) { - const char *p = strchr(name, '.'); - char *s; - if (p - name > 15) { - n->name = "*SMBSERVER"; - return; - } - s = talloc_strndup(mem_ctx, name, PTR_DIFF(p, name)); - n->name = talloc_strdup_upper(mem_ctx, s); - return; - } - - n->name = talloc_strdup_upper(mem_ctx, name); -} - - -/* - escape a string into a form containing only a small set of characters, - the rest is hex encoded. This is similar to URL encoding -*/ -static const char *nbt_hex_encode(TALLOC_CTX *mem_ctx, const char *s) -{ - int i, len; - char *ret; - const char *valid_chars = "_-.$@ "; -#define NBT_CHAR_ALLOW(c) (isalnum((unsigned char)c) || strchr(valid_chars, c)) - - for (len=i=0;s[i];i++,len++) { - if (!NBT_CHAR_ALLOW(s[i])) { - len += 2; - } - } - - ret = talloc_array(mem_ctx, char, len+1); - if (ret == NULL) return NULL; - - for (len=i=0;s[i];i++) { - if (NBT_CHAR_ALLOW(s[i])) { - ret[len++] = s[i]; - } else { - snprintf(&ret[len], 4, "%%%02x", (unsigned char)s[i]); - len += 3; - } - } - ret[len] = 0; - - return ret; -} - - -/** - form a string for a NBT name -*/ -_PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name) -{ - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - char *ret; - if (name->scope) { - ret = talloc_asprintf(mem_ctx, "%s<%02x>-%s", - nbt_hex_encode(tmp_ctx, name->name), - name->type, - nbt_hex_encode(tmp_ctx, name->scope)); - } else { - ret = talloc_asprintf(mem_ctx, "%s<%02x>", - nbt_hex_encode(tmp_ctx, name->name), - name->type); - } - talloc_free(tmp_ctx); - return ret; -} - -/** - pull a nbt name, WINS Replication uses another on wire format for nbt name -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r) -{ - struct nbt_name *r; - uint8_t *namebuf; - uint32_t namebuf_len; - - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &namebuf_len)); - if (namebuf_len < 1 || namebuf_len > 255) { - return ndr_pull_error(ndr, NDR_ERR_ALLOC, "value out of range"); - } - NDR_PULL_ALLOC_N(ndr, namebuf, namebuf_len); - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len)); - - NDR_PULL_ALLOC(ndr, r); - - /* oh wow, what a nasty bug in windows ... */ - if (namebuf[0] == 0x1b && namebuf_len >= 16) { - namebuf[0] = namebuf[15]; - namebuf[15] = 0x1b; - } - - if (namebuf_len < 17) { - r->type = 0x00; - - r->name = talloc_strndup(r, (char *)namebuf, namebuf_len); - if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory"); - - r->scope= NULL; - - talloc_free(namebuf); - *_r = r; - return NDR_ERR_SUCCESS; - } - - r->type = namebuf[15]; - - namebuf[15] = '\0'; - trim_string((char *)namebuf, NULL, " "); - r->name = talloc_strdup(r, (char *)namebuf); - if (!r->name) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory"); - - if (namebuf_len > 18) { - r->scope = talloc_strndup(r, (char *)(namebuf+17), namebuf_len-17); - if (!r->scope) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "out of memory"); - } else { - r->scope = NULL; - } - - talloc_free(namebuf); - *_r = r; - return NDR_ERR_SUCCESS; -} - -/** - push a nbt name, WINS Replication uses another on wire format for nbt name -*/ -_PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r) -{ - uint8_t *namebuf; - uint32_t namebuf_len; - uint32_t _name_len; - uint32_t scope_len = 0; - - if (r == NULL) { - return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, - "wrepl_nbt_name NULL pointer"); - } - - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - - _name_len = strlen(r->name); - if (_name_len > 15) { - return ndr_push_error(ndr, NDR_ERR_STRING, - "wrepl_nbt_name longer as 15 chars: %s", - r->name); - } - - if (r->scope) { - scope_len = strlen(r->scope); - } - if (scope_len > 238) { - return ndr_push_error(ndr, NDR_ERR_STRING, - "wrepl_nbt_name scope longer as 238 chars: %s", - r->scope); - } - - namebuf = (uint8_t *)talloc_asprintf(ndr, "%-15s%c%s", - r->name, 'X', - (r->scope?r->scope:"")); - if (!namebuf) return ndr_push_error(ndr, NDR_ERR_ALLOC, "out of memory"); - - namebuf_len = strlen((char *)namebuf) + 1; - - /* - * we need to set the type here, and use a place-holder in the talloc_asprintf() - * as the type can be 0x00, and then the namebuf_len = strlen(namebuf); would give wrong results - */ - namebuf[15] = r->type; - - /* oh wow, what a nasty bug in windows ... */ - if (r->type == 0x1b) { - namebuf[15] = namebuf[0]; - namebuf[0] = 0x1b; - } - - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, namebuf_len)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len)); - - talloc_free(namebuf); - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r) -{ - char *s = nbt_name_string(ndr, r); - ndr_print_string(ndr, name, s); - talloc_free(s); -} diff --git a/source3/libgpo/gpext/registry.c b/source3/libgpo/gpext/registry.c index 188a48ab49..f501498407 100644 --- a/source3/libgpo/gpext/registry.c +++ b/source3/libgpo/gpext/registry.c @@ -410,7 +410,7 @@ static NTSTATUS reg_parse_registry(TALLOC_CTX *mem_ctx, return status; } - buf = (uint16 *)file_load(real_filename, &n, 0); + buf = (uint16 *)file_load(real_filename, &n, 0, NULL); if (!buf) { TALLOC_FREE(reg_file); return NT_STATUS_CANNOT_LOAD_REGISTRY_FILE; @@ -455,7 +455,7 @@ static NTSTATUS reg_parse_registry(TALLOC_CTX *mem_ctx, status = NT_STATUS_OK; out: - SAFE_FREE(buf); + TALLOC_FREE(buf); prs_mem_free(&ps); return status; diff --git a/source3/libgpo/gpext/scripts.c b/source3/libgpo/gpext/scripts.c index c07407c3f0..02c3abaa1e 100644 --- a/source3/libgpo/gpext/scripts.c +++ b/source3/libgpo/gpext/scripts.c @@ -93,7 +93,7 @@ static NTSTATUS generate_gp_registry_entry(TALLOC_CTX *mem_ctx, data->type = data_type; switch (data->type) { case REG_QWORD: - data->v.qword = (uint64_t)data_p; + data->v.qword = *(uint64_t *)data_p; break; case REG_SZ: data->v.sz.str = talloc_strdup(mem_ctx, (char *)data_p); diff --git a/source3/libgpo/gpext/security.c b/source3/libgpo/gpext/security.c new file mode 100644 index 0000000000..6aeb354c41 --- /dev/null +++ b/source3/libgpo/gpext/security.c @@ -0,0 +1,267 @@ +/* + * Unix SMB/CIFS implementation. + * Group Policy Support + * Copyright (C) Guenther Deschner 2005-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 . + */ + +#include "includes.h" +#include "libgpo/gpo_ini.h" + +#define GP_EXT_NAME "security" + +#define GPTTMPL_UNIX_PATH "Microsoft/Windows NT/SecEdit/GptTmpl.inf" + +#define GPTTMPL_SECTION_UNICODE "Unicode" +#define GPTTMPL_SECTION_VERSION "Version" + +#define GPTTMPL_SECTION_REGISTRY_VALUES "Registry Values" +#define GPTTMPL_SECTION_SYSTEM_ACCESS "System Access" +#define GPTTMPL_SECTION_KERBEROS_POLICY "Kerberos Policy" +#define GPTTMPL_SECTION_EVENT_AUDIT "Event Audit" +#define GPTTMPL_SECTION_PRIVILEGE_RIGHTS "Privilege Rights" +#define GPTTMPL_SECTION_APPLICATION_LOG "Application Log" +#define GPTTMPL_SECTION_SECURITY_LOG "Security Log" +#define GPTTMPL_SECTION_SYSTEM_LOG "System Log" +#define GPTTMPL_SECTION_GROUP_MEMBERSHIP "Group Membership" +#define GPTTMPL_SECTION_FILE_SECURITY "File Security" +#define GPTTMPL_SECTION_SERVICE_GENERAL_SETTING "Service General Setting" + +static TALLOC_CTX *ctx = NULL; + +struct gpttmpl_table { + const char *section; + const char *parameter; + enum winreg_Type type; +}; + +/**************************************************************** + parse the Version section from gpttmpl file +****************************************************************/ + +#define GPTTMPL_PARAMETER_REVISION "Revision" +#define GPTTMPL_PARAMETER_SIGNATURE "signature" +#define GPTTMPL_VALUE_CHICAGO "$CHICAGO$" /* whatever this is good for... */ +#define GPTTMPL_PARAMETER_UNICODE "Unicode" + +static NTSTATUS gpttmpl_parse_header(dictionary *dict, + uint32_t *version_out) +{ + const char *signature = NULL; + uint32_t version; + + if (!dict) { + return NT_STATUS_INVALID_PARAMETER; + } + + if ((signature = iniparser_getstring(dict, GPTTMPL_SECTION_VERSION + ":"GPTTMPL_PARAMETER_SIGNATURE, NULL)) == NULL) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + if (!strequal(signature, GPTTMPL_VALUE_CHICAGO)) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + if ((version = iniparser_getint(dict, GPTTMPL_SECTION_VERSION + ":"GPTTMPL_PARAMETER_REVISION, Undefined)) == Undefined) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + if (version_out) { + *version_out = version; + } + + /* treat that as boolean */ + if ((!iniparser_getboolean(dict, GPTTMPL_SECTION_UNICODE + ":"GPTTMPL_PARAMETER_UNICODE, Undefined)) == Undefined) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS gpttmpl_init_context(TALLOC_CTX *mem_ctx, + uint32_t flags, + const char *unix_path, + struct gp_inifile_context **ini_ctx) +{ + NTSTATUS status; + uint32_t version; + struct gp_inifile_context *tmp_ctx = NULL; + + status = gp_inifile_init_context(mem_ctx, flags, unix_path, + GPTTMPL_UNIX_PATH, &tmp_ctx); + NT_STATUS_NOT_OK_RETURN(status); + + status = gpttmpl_parse_header(tmp_ctx->dict, &version); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1,("gpttmpl_init_context: failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(tmp_ctx); + return status; + } + + *ini_ctx = tmp_ctx; + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS gpttmpl_process(struct gp_inifile_context *ini_ctx, + struct registry_key *root_key, + uint32_t flags) +{ + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS security_process_group_policy(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + uint32_t flags, + struct registry_key *root_key, + const struct nt_user_token *token, + struct GROUP_POLICY_OBJECT *gpo, + const char *extension_guid, + const char *snapin_guid) +{ + NTSTATUS status; + char *unix_path = NULL; + struct gp_inifile_context *ini_ctx = NULL; + + debug_gpext_header(0, "security_process_group_policy", flags, gpo, + extension_guid, snapin_guid); + + /* this handler processes the gpttmpl files and merge output to the + * registry */ + + status = gpo_get_unix_path(mem_ctx, gpo, &unix_path); + if (!NT_STATUS_IS_OK(status)) { + goto out; + } + + status = gpttmpl_init_context(mem_ctx, flags, unix_path, &ini_ctx); + if (!NT_STATUS_IS_OK(status)) { + goto out; + } + + status = gpttmpl_process(ini_ctx, root_key, flags); + if (!NT_STATUS_IS_OK(status)) { + goto out; + } + + out: + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("security_process_group_policy: %s\n", + nt_errstr(status))); + } + TALLOC_FREE(ini_ctx); + + return status; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS security_get_reg_config(TALLOC_CTX *mem_ctx, + struct gp_extension_reg_info **reg_info) +{ + NTSTATUS status; + struct gp_extension_reg_info *info = NULL; + + struct gp_extension_reg_table table[] = { + /* FIXME: how can we store the "(Default)" value ??? */ + /* { "", REG_SZ, "Security" }, */ + { "ProcessGroupPolicy", REG_SZ, "security_process_group_policy" }, + { "NoUserPolicy", REG_DWORD, "1" }, + { "ExtensionDebugLevel", REG_DWORD, "1" }, + { NULL, REG_NONE, NULL } + }; + + info = TALLOC_ZERO_P(mem_ctx, struct gp_extension_reg_info); + NT_STATUS_HAVE_NO_MEMORY(info); + + status = gp_ext_info_add_entry(mem_ctx, GP_EXT_NAME, + GP_EXT_GUID_SECURITY, + table, info); + NT_STATUS_NOT_OK_RETURN(status); + + *reg_info = info; + + return NT_STATUS_OK; +} + + +/**************************************************************** +****************************************************************/ + +static NTSTATUS security_initialize(TALLOC_CTX *mem_ctx) +{ + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static NTSTATUS security_shutdown(void) +{ + NTSTATUS status; + + status = unregister_gp_extension(GP_EXT_NAME); + if (NT_STATUS_IS_OK(status)) { + return status; + } + + TALLOC_FREE(ctx); + + return NT_STATUS_OK; +} + +/**************************************************************** +****************************************************************/ + +static struct gp_extension_methods security_methods = { + .initialize = security_initialize, + .process_group_policy = security_process_group_policy, + .get_reg_config = security_get_reg_config, + .shutdown = security_shutdown +}; + +/**************************************************************** +****************************************************************/ + +NTSTATUS gpext_security_init(void) +{ + NTSTATUS status; + + ctx = talloc_init("gpext_security_init"); + NT_STATUS_HAVE_NO_MEMORY(ctx); + + status = register_gp_extension(ctx, SMB_GPEXT_INTERFACE_VERSION, + GP_EXT_NAME, GP_EXT_GUID_SECURITY, + &security_methods); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(ctx); + } + + return status; +} diff --git a/source3/libgpo/gpo_ini.c b/source3/libgpo/gpo_ini.c index 54aaffa477..aa8f7c7770 100644 --- a/source3/libgpo/gpo_ini.c +++ b/source3/libgpo/gpo_ini.c @@ -63,7 +63,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - data_in = (uint8 *)file_load(filename_in, &n, 0); + data_in = (uint8 *)file_load(filename_in, &n, 0, NULL); if (!data_in) { status = NT_STATUS_NO_SUCH_FILE; goto out; @@ -116,7 +116,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx, close(tmp_fd); } - SAFE_FREE(data_in); + TALLOC_FREE(data_in); return status; } diff --git a/source3/libgpo/gpo_reg.c b/source3/libgpo/gpo_reg.c index 920deeb189..d49315021e 100644 --- a/source3/libgpo/gpo_reg.c +++ b/source3/libgpo/gpo_reg.c @@ -689,25 +689,25 @@ static WERROR gp_reg_generate_sd(TALLOC_CTX *mem_ctx, size_t *sd_size) { SEC_ACE ace[6]; - SEC_ACCESS mask; + uint32_t mask; SEC_ACL *acl = NULL; uint8_t inherit_flags; - init_sec_access(&mask, REG_KEY_ALL); + mask = REG_KEY_ALL; init_sec_ace(&ace[0], &global_sid_System, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_access(&mask, REG_KEY_ALL); + mask = REG_KEY_ALL; init_sec_ace(&ace[1], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_access(&mask, REG_KEY_READ); + mask = REG_KEY_READ; init_sec_ace(&ace[2], sid ? sid : &global_sid_Authenticated_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, @@ -717,19 +717,19 @@ static WERROR gp_reg_generate_sd(TALLOC_CTX *mem_ctx, SEC_ACE_FLAG_CONTAINER_INHERIT | SEC_ACE_FLAG_INHERIT_ONLY; - init_sec_access(&mask, REG_KEY_ALL); + mask = REG_KEY_ALL; init_sec_ace(&ace[3], &global_sid_System, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, inherit_flags); - init_sec_access(&mask, REG_KEY_ALL); + mask = REG_KEY_ALL; init_sec_ace(&ace[4], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, inherit_flags); - init_sec_access(&mask, REG_KEY_READ); + mask = REG_KEY_READ; init_sec_ace(&ace[5], sid ? sid : &global_sid_Authenticated_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, diff --git a/source3/libnet/libnet_dssync.c b/source3/libnet/libnet_dssync.c index bae03effed..81866c85ba 100644 --- a/source3/libnet/libnet_dssync.c +++ b/source3/libnet/libnet_dssync.c @@ -297,7 +297,7 @@ static NTSTATUS libnet_dssync_lookup_nc(TALLOC_CTX *mem_ctx, req.req1.count = 1; req.req1.names = names; req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; - req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_UKNOWN; + req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_UNKNOWN; req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; status = rpccli_drsuapi_DsCrackNames(ctx->cli, mem_ctx, @@ -539,17 +539,24 @@ static NTSTATUS libnet_dssync_getncchanges(TALLOC_CTX *mem_ctx, if (level_out == 1) { out_level = 1; ctr1 = &ctr.ctr1; - } else if (level_out == 2) { + } else if (level_out == 2 && ctr.ctr2.mszip1.ts) { out_level = 1; - ctr1 = ctr.ctr2.ctr.mszip1.ctr1; + ctr1 = &ctr.ctr2.mszip1.ts->ctr1; } else if (level_out == 6) { out_level = 6; ctr6 = &ctr.ctr6; } else if (level_out == 7 && ctr.ctr7.level == 6 - && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) { + && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP + && ctr.ctr7.ctr.mszip6.ts) { out_level = 6; - ctr6 = ctr.ctr7.ctr.mszip6.ctr6; + ctr6 = &ctr.ctr7.ctr.mszip6.ts->ctr6; + } else if (level_out == 7 + && ctr.ctr7.level == 6 + && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS + && ctr.ctr7.ctr.xpress6.ts) { + out_level = 6; + ctr6 = &ctr.ctr7.ctr.xpress6.ts->ctr6; } if (out_level == 1) { diff --git a/source3/libnet/libnet_dssync_keytab.c b/source3/libnet/libnet_dssync_keytab.c index 6ba2c3aa41..6a3139d6ad 100644 --- a/source3/libnet/libnet_dssync_keytab.c +++ b/source3/libnet/libnet_dssync_keytab.c @@ -86,7 +86,7 @@ static NTSTATUS keytab_startup(struct dssync_context *ctx, TALLOC_CTX *mem_ctx, old_utdv = talloc(mem_ctx, struct replUpToDateVectorBlob); ndr_err = ndr_pull_struct_blob(&entry->password, old_utdv, - old_utdv, + NULL, old_utdv, (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); @@ -124,7 +124,7 @@ static NTSTATUS keytab_finish(struct dssync_context *ctx, TALLOC_CTX *mem_ctx, NDR_PRINT_DEBUG(replUpToDateVectorBlob, new_utdv); } - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, new_utdv, + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, new_utdv, (ndr_push_flags_fn_t)ndr_push_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -179,7 +179,7 @@ static NTSTATUS parse_supplemental_credentials(TALLOC_CTX *mem_ctx, bool newer_keys = false; uint32_t j; - ndr_err = ndr_pull_struct_blob_all(blob, mem_ctx, &scb, + ndr_err = ndr_pull_struct_blob_all(blob, mem_ctx, NULL, &scb, (ndr_pull_flags_fn_t)ndr_pull_supplementalCredentialsBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -236,7 +236,7 @@ static NTSTATUS parse_supplemental_credentials(TALLOC_CTX *mem_ctx, status = NT_STATUS_NO_MEMORY; goto done; } - ndr_err = ndr_pull_struct_blob(&scpk_blob, mem_ctx, pkb, + ndr_err = ndr_pull_struct_blob(&scpk_blob, mem_ctx, NULL, pkb, (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index a39dee676f..6935e000dc 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -357,10 +357,15 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, strupper_m(spn); spn_array[0] = spn; - if (name_to_fqdn(my_fqdn, r->in.machine_name) && - !strequal(my_fqdn, r->in.machine_name)) { + if (!name_to_fqdn(my_fqdn, r->in.machine_name) + || (strchr(my_fqdn, '.') == NULL)) { + fstr_sprintf(my_fqdn, "%s.%s", r->in.machine_name, + r->out.dns_domain_name); + } + + strlower_m(my_fqdn); - strlower_m(my_fqdn); + if (!strequal(my_fqdn, r->in.machine_name)) { spn = talloc_asprintf(mem_ctx, "HOST/%s", my_fqdn); if (!spn) { return ADS_ERROR_LDAP(LDAP_NO_MEMORY); @@ -770,7 +775,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, ZERO_STRUCT(user_pol); if (!r->in.machine_password) { - r->in.machine_password = talloc_strdup(mem_ctx, generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH)); + r->in.machine_password = generate_random_str(mem_ctx, DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); NT_STATUS_HAVE_NO_MEMORY(r->in.machine_password); } diff --git a/source3/libnet/libnet_proto.h b/source3/libnet/libnet_proto.h index 43046a44c0..69a16c1c7d 100644 --- a/source3/libnet/libnet_proto.h +++ b/source3/libnet/libnet_proto.h @@ -53,7 +53,7 @@ krb5_error_code libnet_keytab_add(struct libnet_keytab_context *ctx); struct libnet_keytab_entry *libnet_keytab_search(struct libnet_keytab_context *ctx, const char *principal, int kvno, - const const krb5_enctype enctype, + const krb5_enctype enctype, TALLOC_CTX *mem_ctx); #endif diff --git a/source3/libnet/libnet_samsync.c b/source3/libnet/libnet_samsync.c index daf27ffb51..64dcf6de51 100644 --- a/source3/libnet/libnet_samsync.c +++ b/source3/libnet/libnet_samsync.c @@ -65,7 +65,7 @@ static NTSTATUS fix_user(TALLOC_CTX *mem_ctx, user->user_private_info.SensitiveData = data.data; user->user_private_info.DataLength = data.length; - ndr_err = ndr_pull_struct_blob(&data, mem_ctx, &keys, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, NULL, &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { dump_data(10, data.data, data.length); @@ -397,7 +397,7 @@ NTSTATUS pull_netr_AcctLockStr(TALLOC_CTX *mem_ctx, blob = data_blob_const(r->array, r->length); - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, str, + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, str, (ndr_pull_flags_fn_t)ndr_pull_netr_AcctLockStr); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { diff --git a/source3/libnet/libnet_samsync_keytab.c b/source3/libnet/libnet_samsync_keytab.c index f284f08ad9..9e666ced32 100644 --- a/source3/libnet/libnet_samsync_keytab.c +++ b/source3/libnet/libnet_samsync_keytab.c @@ -93,6 +93,7 @@ static NTSTATUS fetch_sam_entry_keytab(TALLOC_CTX *mem_ctx, ctx->dns_domain_name); entry.password = data_blob_talloc(mem_ctx, nt_passwd, 16); entry.kvno = ads_get_kvno(ctx->ads, entry.name); + entry.enctype = ENCTYPE_NULL; NT_STATUS_HAVE_NO_MEMORY(entry.name); NT_STATUS_HAVE_NO_MEMORY(entry.principal); diff --git a/source3/librpc/gen_ndr/cli_initshutdown.c b/source3/librpc/gen_ndr/cli_initshutdown.c index ab48623ee1..bc8ca5b5f1 100644 --- a/source3/librpc/gen_ndr/cli_initshutdown.c +++ b/source3/librpc/gen_ndr/cli_initshutdown.c @@ -9,7 +9,7 @@ NTSTATUS rpccli_initshutdown_Init(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, @@ -103,7 +103,7 @@ NTSTATUS rpccli_initshutdown_Abort(struct rpc_pipe_client *cli, NTSTATUS rpccli_initshutdown_InitEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, diff --git a/source3/librpc/gen_ndr/cli_initshutdown.h b/source3/librpc/gen_ndr/cli_initshutdown.h index c7d2cad664..e2eb9daabe 100644 --- a/source3/librpc/gen_ndr/cli_initshutdown.h +++ b/source3/librpc/gen_ndr/cli_initshutdown.h @@ -4,7 +4,7 @@ NTSTATUS rpccli_initshutdown_Init(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, @@ -16,7 +16,7 @@ NTSTATUS rpccli_initshutdown_Abort(struct rpc_pipe_client *cli, NTSTATUS rpccli_initshutdown_InitEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 4ab27ed04b..e7775b1bfe 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -503,7 +503,7 @@ NTSTATUS rpccli_lsa_EnumAccounts(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_CreateTrustedDomain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - struct policy_handle *handle /* [in] [ref] */, + struct policy_handle *policy_handle /* [in] [ref] */, struct lsa_DomainInfo *info /* [in] [ref] */, uint32_t access_mask /* [in] */, struct policy_handle *trustdom_handle /* [out] [ref] */) @@ -512,7 +512,7 @@ NTSTATUS rpccli_lsa_CreateTrustedDomain(struct rpc_pipe_client *cli, NTSTATUS status; /* In parameters */ - r.in.handle = handle; + r.in.policy_handle = policy_handle; r.in.info = info; r.in.access_mask = access_mask; @@ -1141,12 +1141,18 @@ NTSTATUS rpccli_lsa_QueryTrustedDomainInfo(struct rpc_pipe_client *cli, } NTSTATUS rpccli_lsa_SetInformationTrustedDomain(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + struct policy_handle *trustdom_handle /* [in] [ref] */, + enum lsa_TrustDomInfoEnum level /* [in] */, + union lsa_TrustedDomainInfo *info /* [in] [ref,switch_is(level)] */) { struct lsa_SetInformationTrustedDomain r; NTSTATUS status; /* In parameters */ + r.in.trustdom_handle = trustdom_handle; + r.in.level = level; + r.in.info = info; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_SetInformationTrustedDomain, &r); @@ -1706,12 +1712,20 @@ NTSTATUS rpccli_lsa_QueryTrustedDomainInfoBySid(struct rpc_pipe_client *cli, } NTSTATUS rpccli_lsa_SetTrustedDomainInfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + struct dom_sid2 *dom_sid /* [in] [ref] */, + enum lsa_TrustDomInfoEnum level /* [in] */, + union lsa_TrustedDomainInfo *info /* [in] [ref,switch_is(level)] */) { struct lsa_SetTrustedDomainInfo r; NTSTATUS status; /* In parameters */ + r.in.handle = handle; + r.in.dom_sid = dom_sid; + r.in.level = level; + r.in.info = info; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_SetTrustedDomainInfo, &r); @@ -2161,12 +2175,21 @@ NTSTATUS rpccli_lsa_EnumTrustedDomainsEx(struct rpc_pipe_client *cli, } NTSTATUS rpccli_lsa_CreateTrustedDomainEx(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + struct policy_handle *policy_handle /* [in] [ref] */, + struct lsa_TrustDomainInfoInfoEx *info /* [in] [ref] */, + struct lsa_TrustDomainInfoAuthInfoInternal *auth_info /* [in] [ref] */, + uint32_t access_mask /* [in] */, + struct policy_handle *trustdom_handle /* [out] [ref] */) { struct lsa_CreateTrustedDomainEx r; NTSTATUS status; /* In parameters */ + r.in.policy_handle = policy_handle; + r.in.info = info; + r.in.auth_info = auth_info; + r.in.access_mask = access_mask; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_CreateTrustedDomainEx, &r); @@ -2191,6 +2214,7 @@ NTSTATUS rpccli_lsa_CreateTrustedDomainEx(struct rpc_pipe_client *cli, } /* Return variables */ + *trustdom_handle = *r.out.trustdom_handle; /* Return result */ return r.out.result; @@ -2462,8 +2486,8 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, struct lsa_TransSidArray2 *sids /* [in,out] [ref] */, enum lsa_LookupNamesLevel level /* [in] */, uint32_t *count /* [in,out] [ref] */, - uint32_t unknown1 /* [in] */, - uint32_t unknown2 /* [in] */) + uint32_t lookup_options /* [in] */, + uint32_t client_revision /* [in] */) { struct lsa_LookupNames2 r; NTSTATUS status; @@ -2475,8 +2499,8 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, r.in.sids = sids; r.in.level = level; r.in.count = count; - r.in.unknown1 = unknown1; - r.in.unknown2 = unknown2; + r.in.lookup_options = lookup_options; + r.in.client_revision = client_revision; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_LookupNames2, &r); @@ -2510,12 +2534,21 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, } NTSTATUS rpccli_lsa_CreateTrustedDomainEx2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + struct policy_handle *policy_handle /* [in] [ref] */, + struct lsa_TrustDomainInfoInfoEx *info /* [in] [ref] */, + struct lsa_TrustDomainInfoAuthInfoInternal *auth_info /* [in] [ref] */, + uint32_t access_mask /* [in] */, + struct policy_handle *trustdom_handle /* [out] [ref] */) { struct lsa_CreateTrustedDomainEx2 r; NTSTATUS status; /* In parameters */ + r.in.policy_handle = policy_handle; + r.in.info = info; + r.in.auth_info = auth_info; + r.in.access_mask = access_mask; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_CreateTrustedDomainEx2, &r); @@ -2540,6 +2573,7 @@ NTSTATUS rpccli_lsa_CreateTrustedDomainEx2(struct rpc_pipe_client *cli, } /* Return variables */ + *trustdom_handle = *r.out.trustdom_handle; /* Return result */ return r.out.result; @@ -2842,8 +2876,8 @@ NTSTATUS rpccli_lsa_LookupNames3(struct rpc_pipe_client *cli, struct lsa_TransSidArray3 *sids /* [in,out] [ref] */, enum lsa_LookupNamesLevel level /* [in] */, uint32_t *count /* [in,out] [ref] */, - uint32_t unknown1 /* [in] */, - uint32_t unknown2 /* [in] */) + uint32_t lookup_options /* [in] */, + uint32_t client_revision /* [in] */) { struct lsa_LookupNames3 r; NTSTATUS status; @@ -2855,8 +2889,8 @@ NTSTATUS rpccli_lsa_LookupNames3(struct rpc_pipe_client *cli, r.in.sids = sids; r.in.level = level; r.in.count = count; - r.in.unknown1 = unknown1; - r.in.unknown2 = unknown2; + r.in.lookup_options = lookup_options; + r.in.client_revision = client_revision; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_LookupNames3, &r); @@ -3209,8 +3243,8 @@ NTSTATUS rpccli_lsa_LookupNames4(struct rpc_pipe_client *cli, struct lsa_TransSidArray3 *sids /* [in,out] [ref] */, enum lsa_LookupNamesLevel level /* [in] */, uint32_t *count /* [in,out] [ref] */, - uint32_t unknown1 /* [in] */, - uint32_t unknown2 /* [in] */) + uint32_t lookup_options /* [in] */, + uint32_t client_revision /* [in] */) { struct lsa_LookupNames4 r; NTSTATUS status; @@ -3221,8 +3255,8 @@ NTSTATUS rpccli_lsa_LookupNames4(struct rpc_pipe_client *cli, r.in.sids = sids; r.in.level = level; r.in.count = count; - r.in.unknown1 = unknown1; - r.in.unknown2 = unknown2; + r.in.lookup_options = lookup_options; + r.in.client_revision = client_revision; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_LookupNames4, &r); diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index f3333a091b..554182c6db 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -57,7 +57,7 @@ NTSTATUS rpccli_lsa_EnumAccounts(struct rpc_pipe_client *cli, uint32_t num_entries /* [in] [range(0,8192)] */); NTSTATUS rpccli_lsa_CreateTrustedDomain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - struct policy_handle *handle /* [in] [ref] */, + struct policy_handle *policy_handle /* [in] [ref] */, struct lsa_DomainInfo *info /* [in] [ref] */, uint32_t access_mask /* [in] */, struct policy_handle *trustdom_handle /* [out] [ref] */); @@ -133,7 +133,10 @@ NTSTATUS rpccli_lsa_QueryTrustedDomainInfo(struct rpc_pipe_client *cli, enum lsa_TrustDomInfoEnum level /* [in] */, union lsa_TrustedDomainInfo **info /* [out] [ref,switch_is(level)] */); NTSTATUS rpccli_lsa_SetInformationTrustedDomain(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + struct policy_handle *trustdom_handle /* [in] [ref] */, + enum lsa_TrustDomInfoEnum level /* [in] */, + union lsa_TrustedDomainInfo *info /* [in] [ref,switch_is(level)] */); NTSTATUS rpccli_lsa_OpenSecret(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, @@ -201,7 +204,11 @@ NTSTATUS rpccli_lsa_QueryTrustedDomainInfoBySid(struct rpc_pipe_client *cli, enum lsa_TrustDomInfoEnum level /* [in] */, union lsa_TrustedDomainInfo **info /* [out] [ref,switch_is(level)] */); NTSTATUS rpccli_lsa_SetTrustedDomainInfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + struct dom_sid2 *dom_sid /* [in] [ref] */, + enum lsa_TrustDomInfoEnum level /* [in] */, + union lsa_TrustedDomainInfo *info /* [in] [ref,switch_is(level)] */); NTSTATUS rpccli_lsa_DeleteTrustedDomain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, @@ -250,7 +257,12 @@ NTSTATUS rpccli_lsa_EnumTrustedDomainsEx(struct rpc_pipe_client *cli, struct lsa_DomainListEx *domains /* [out] [ref] */, uint32_t max_size /* [in] */); NTSTATUS rpccli_lsa_CreateTrustedDomainEx(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + struct policy_handle *policy_handle /* [in] [ref] */, + struct lsa_TrustDomainInfoInfoEx *info /* [in] [ref] */, + struct lsa_TrustDomainInfoAuthInfoInternal *auth_info /* [in] [ref] */, + uint32_t access_mask /* [in] */, + struct policy_handle *trustdom_handle /* [out] [ref] */); NTSTATUS rpccli_lsa_CloseTrustedDomainEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in,out] [ref] */); @@ -291,10 +303,15 @@ NTSTATUS rpccli_lsa_LookupNames2(struct rpc_pipe_client *cli, struct lsa_TransSidArray2 *sids /* [in,out] [ref] */, enum lsa_LookupNamesLevel level /* [in] */, uint32_t *count /* [in,out] [ref] */, - uint32_t unknown1 /* [in] */, - uint32_t unknown2 /* [in] */); + uint32_t lookup_options /* [in] */, + uint32_t client_revision /* [in] */); NTSTATUS rpccli_lsa_CreateTrustedDomainEx2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + struct policy_handle *policy_handle /* [in] [ref] */, + struct lsa_TrustDomainInfoInfoEx *info /* [in] [ref] */, + struct lsa_TrustDomainInfoAuthInfoInternal *auth_info /* [in] [ref] */, + uint32_t access_mask /* [in] */, + struct policy_handle *trustdom_handle /* [out] [ref] */); NTSTATUS rpccli_lsa_CREDRWRITE(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_lsa_CREDRREAD(struct rpc_pipe_client *cli, @@ -320,8 +337,8 @@ NTSTATUS rpccli_lsa_LookupNames3(struct rpc_pipe_client *cli, struct lsa_TransSidArray3 *sids /* [in,out] [ref] */, enum lsa_LookupNamesLevel level /* [in] */, uint32_t *count /* [in,out] [ref] */, - uint32_t unknown1 /* [in] */, - uint32_t unknown2 /* [in] */); + uint32_t lookup_options /* [in] */, + uint32_t client_revision /* [in] */); NTSTATUS rpccli_lsa_CREDRGETSESSIONTYPES(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_lsa_LSARREGISTERAUDITEVENT(struct rpc_pipe_client *cli, @@ -357,8 +374,8 @@ NTSTATUS rpccli_lsa_LookupNames4(struct rpc_pipe_client *cli, struct lsa_TransSidArray3 *sids /* [in,out] [ref] */, enum lsa_LookupNamesLevel level /* [in] */, uint32_t *count /* [in,out] [ref] */, - uint32_t unknown1 /* [in] */, - uint32_t unknown2 /* [in] */); + uint32_t lookup_options /* [in] */, + uint32_t client_revision /* [in] */); NTSTATUS rpccli_lsa_LSAROPENPOLICYSCE(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(struct rpc_pipe_client *cli, diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index d6ac8b9ede..941273bddc 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -110,8 +110,8 @@ NTSTATUS rpccli_netr_LogonSamLogon(struct rpc_pipe_client *cli, const char *computer_name /* [in] [unique,charset(UTF16)] */, struct netr_Authenticator *credential /* [in] [unique] */, struct netr_Authenticator *return_authenticator /* [in,out] [unique] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo *logon /* [in] [ref,switch_is(logon_level)] */, + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel *logon /* [in] [ref,switch_is(logon_level)] */, uint16_t validation_level /* [in] */, union netr_Validation *validation /* [out] [ref,switch_is(validation_level)] */, uint8_t *authoritative /* [out] [ref] */) @@ -167,8 +167,8 @@ NTSTATUS rpccli_netr_LogonSamLogoff(struct rpc_pipe_client *cli, const char *computer_name /* [in] [unique,charset(UTF16)] */, struct netr_Authenticator *credential /* [in] [unique] */, struct netr_Authenticator *return_authenticator /* [in,out] [unique] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo logon /* [in] [switch_is(logon_level)] */) + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel logon /* [in] [switch_is(logon_level)] */) { struct netr_LogonSamLogoff r; NTSTATUS status; @@ -1934,8 +1934,8 @@ NTSTATUS rpccli_netr_LogonSamLogonEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name /* [in] [unique,charset(UTF16)] */, const char *computer_name /* [in] [unique,charset(UTF16)] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo *logon /* [in] [ref,switch_is(logon_level)] */, + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel *logon /* [in] [ref,switch_is(logon_level)] */, uint16_t validation_level /* [in] */, union netr_Validation *validation /* [out] [ref,switch_is(validation_level)] */, uint8_t *authoritative /* [out] [ref] */, @@ -2241,8 +2241,8 @@ NTSTATUS rpccli_netr_LogonSamLogonWithFlags(struct rpc_pipe_client *cli, const char *computer_name /* [in] [unique,charset(UTF16)] */, struct netr_Authenticator *credential /* [in] [unique] */, struct netr_Authenticator *return_authenticator /* [in,out] [unique] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo logon /* [in] [switch_is(logon_level)] */, + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel logon /* [in] [switch_is(logon_level)] */, uint16_t validation_level /* [in] */, union netr_Validation *validation /* [out] [ref,switch_is(validation_level)] */, uint8_t *authoritative /* [out] [ref] */, diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index 2033315a5d..0a0cfdf6e4 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -21,8 +21,8 @@ NTSTATUS rpccli_netr_LogonSamLogon(struct rpc_pipe_client *cli, const char *computer_name /* [in] [unique,charset(UTF16)] */, struct netr_Authenticator *credential /* [in] [unique] */, struct netr_Authenticator *return_authenticator /* [in,out] [unique] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo *logon /* [in] [ref,switch_is(logon_level)] */, + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel *logon /* [in] [ref,switch_is(logon_level)] */, uint16_t validation_level /* [in] */, union netr_Validation *validation /* [out] [ref,switch_is(validation_level)] */, uint8_t *authoritative /* [out] [ref] */); @@ -32,8 +32,8 @@ NTSTATUS rpccli_netr_LogonSamLogoff(struct rpc_pipe_client *cli, const char *computer_name /* [in] [unique,charset(UTF16)] */, struct netr_Authenticator *credential /* [in] [unique] */, struct netr_Authenticator *return_authenticator /* [in,out] [unique] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo logon /* [in] [switch_is(logon_level)] */); + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel logon /* [in] [switch_is(logon_level)] */); NTSTATUS rpccli_netr_ServerReqChallenge(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name /* [in] [unique,charset(UTF16)] */, @@ -297,8 +297,8 @@ NTSTATUS rpccli_netr_LogonSamLogonEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *server_name /* [in] [unique,charset(UTF16)] */, const char *computer_name /* [in] [unique,charset(UTF16)] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo *logon /* [in] [ref,switch_is(logon_level)] */, + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel *logon /* [in] [ref,switch_is(logon_level)] */, uint16_t validation_level /* [in] */, union netr_Validation *validation /* [out] [ref,switch_is(validation_level)] */, uint8_t *authoritative /* [out] [ref] */, @@ -349,8 +349,8 @@ NTSTATUS rpccli_netr_LogonSamLogonWithFlags(struct rpc_pipe_client *cli, const char *computer_name /* [in] [unique,charset(UTF16)] */, struct netr_Authenticator *credential /* [in] [unique] */, struct netr_Authenticator *return_authenticator /* [in,out] [unique] */, - enum netr_LogonLevel logon_level /* [in] */, - union netr_LogonInfo logon /* [in] [switch_is(logon_level)] */, + enum netr_LogonInfoClass logon_level /* [in] */, + union netr_LogonLevel logon /* [in] [switch_is(logon_level)] */, uint16_t validation_level /* [in] */, union netr_Validation *validation /* [out] [ref,switch_is(validation_level)] */, uint8_t *authoritative /* [out] [ref] */, diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.c b/source3/librpc/gen_ndr/cli_ntsvcs.c index bc5dba4d91..f8ef7a99ad 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.c +++ b/source3/librpc/gen_ndr/cli_ntsvcs.c @@ -424,12 +424,19 @@ NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *filter /* [in] [unique,charset(UTF16)] */, + uint16_t *buffer /* [out] [ref,length_is(*length),size_is(*length)] */, + uint32_t *length /* [in,out] [ref] */, + uint32_t flags /* [in] */, WERROR *werror) { struct PNP_GetDeviceList r; NTSTATUS status; /* In parameters */ + r.in.filter = filter; + r.in.length = length; + r.in.flags = flags; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(PNP_GetDeviceList, &r); @@ -454,6 +461,8 @@ NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, } /* Return variables */ + memcpy(buffer, r.out.buffer, *r.in.length * sizeof(*buffer)); + *length = *r.out.length; /* Return result */ if (werror) { @@ -555,11 +564,11 @@ NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *devicepath /* [in] [ref,charset(UTF16)] */, uint32_t property /* [in] */, - uint32_t *unknown1 /* [in,out] [ref] */, + uint32_t *reg_data_type /* [in,out] [ref] */, uint8_t *buffer /* [out] [ref,length_is(*buffer_size),size_is(*buffer_size)] */, uint32_t *buffer_size /* [in,out] [ref] */, uint32_t *needed /* [in,out] [ref] */, - uint32_t unknown3 /* [in] */, + uint32_t flags /* [in] */, WERROR *werror) { struct PNP_GetDeviceRegProp r; @@ -568,10 +577,10 @@ NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, /* In parameters */ r.in.devicepath = devicepath; r.in.property = property; - r.in.unknown1 = unknown1; + r.in.reg_data_type = reg_data_type; r.in.buffer_size = buffer_size; r.in.needed = needed; - r.in.unknown3 = unknown3; + r.in.flags = flags; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(PNP_GetDeviceRegProp, &r); @@ -596,7 +605,7 @@ NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, } /* Return variables */ - *unknown1 = *r.out.unknown1; + *reg_data_type = *r.out.reg_data_type; memcpy(buffer, r.out.buffer, *r.in.buffer_size * sizeof(*buffer)); *buffer_size = *r.out.buffer_size; *needed = *r.out.needed; diff --git a/source3/librpc/gen_ndr/cli_ntsvcs.h b/source3/librpc/gen_ndr/cli_ntsvcs.h index a52a79ecc5..4ed8a401ec 100644 --- a/source3/librpc/gen_ndr/cli_ntsvcs.h +++ b/source3/librpc/gen_ndr/cli_ntsvcs.h @@ -36,6 +36,10 @@ NTSTATUS rpccli_PNP_EnumerateSubKeys(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceList(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *filter /* [in] [unique,charset(UTF16)] */, + uint16_t *buffer /* [out] [ref,length_is(*length),size_is(*length)] */, + uint32_t *length /* [in,out] [ref] */, + uint32_t flags /* [in] */, WERROR *werror); NTSTATUS rpccli_PNP_GetDeviceListSize(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -50,11 +54,11 @@ NTSTATUS rpccli_PNP_GetDeviceRegProp(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *devicepath /* [in] [ref,charset(UTF16)] */, uint32_t property /* [in] */, - uint32_t *unknown1 /* [in,out] [ref] */, + uint32_t *reg_data_type /* [in,out] [ref] */, uint8_t *buffer /* [out] [ref,length_is(*buffer_size),size_is(*buffer_size)] */, uint32_t *buffer_size /* [in,out] [ref] */, uint32_t *needed /* [in,out] [ref] */, - uint32_t unknown3 /* [in] */, + uint32_t flags /* [in] */, WERROR *werror); NTSTATUS rpccli_PNP_SetDeviceRegProp(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/cli_svcctl.c b/source3/librpc/gen_ndr/cli_svcctl.c index c996c761d5..e5fd4dac87 100644 --- a/source3/librpc/gen_ndr/cli_svcctl.c +++ b/source3/librpc/gen_ndr/cli_svcctl.c @@ -858,9 +858,9 @@ NTSTATUS rpccli_svcctl_OpenServiceW(struct rpc_pipe_client *cli, NTSTATUS rpccli_svcctl_QueryServiceConfigW(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, - uint8_t *query /* [out] */, - uint32_t buf_size /* [in] */, - uint32_t *bytes_needed /* [out] [ref] */, + struct QUERY_SERVICE_CONFIG *query /* [out] [ref] */, + uint32_t buf_size /* [in] [range(0,8192)] */, + uint32_t *bytes_needed /* [out] [ref,range(0,8192)] */, WERROR *werror) { struct svcctl_QueryServiceConfigW r; @@ -893,7 +893,7 @@ NTSTATUS rpccli_svcctl_QueryServiceConfigW(struct rpc_pipe_client *cli, } /* Return variables */ - memcpy(query, r.out.query, r.in.buf_size * sizeof(*query)); + *query = *r.out.query; *bytes_needed = *r.out.bytes_needed; /* Return result */ diff --git a/source3/librpc/gen_ndr/cli_svcctl.h b/source3/librpc/gen_ndr/cli_svcctl.h index 56f0a2b0e7..02abbadf1e 100644 --- a/source3/librpc/gen_ndr/cli_svcctl.h +++ b/source3/librpc/gen_ndr/cli_svcctl.h @@ -127,9 +127,9 @@ NTSTATUS rpccli_svcctl_OpenServiceW(struct rpc_pipe_client *cli, NTSTATUS rpccli_svcctl_QueryServiceConfigW(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, - uint8_t *query /* [out] */, - uint32_t buf_size /* [in] */, - uint32_t *bytes_needed /* [out] [ref] */, + struct QUERY_SERVICE_CONFIG *query /* [out] [ref] */, + uint32_t buf_size /* [in] [range(0,8192)] */, + uint32_t *bytes_needed /* [out] [ref,range(0,8192)] */, WERROR *werror); NTSTATUS rpccli_svcctl_QueryServiceLockStatusW(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/cli_winreg.c b/source3/librpc/gen_ndr/cli_winreg.c index 29f7e50c45..17b7281c72 100644 --- a/source3/librpc/gen_ndr/cli_winreg.c +++ b/source3/librpc/gen_ndr/cli_winreg.c @@ -497,7 +497,7 @@ NTSTATUS rpccli_winreg_EnumValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, uint32_t enum_index /* [in] */, - struct winreg_ValNameBuf *name /* [in,out] [ref] */, + struct winreg_StringBuf *name /* [in,out] [ref] */, enum winreg_Type *type /* [in,out] [unique] */, uint8_t *value /* [in,out] [unique,length_is(*length),size_is(*size)] */, uint32_t *size /* [in,out] [unique] */, @@ -872,9 +872,9 @@ NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, struct policy_handle *handle /* [in] [ref] */, struct winreg_String *value_name /* [in] [ref] */, enum winreg_Type *type /* [in,out] [unique] */, - uint8_t *data /* [in,out] [unique,length_is(*value_length),size_is(*data_size)] */, + uint8_t *data /* [in,out] [unique,length_is(*data_length),size_is(*data_size)] */, uint32_t *data_size /* [in,out] [unique] */, - uint32_t *value_length /* [in,out] [unique] */, + uint32_t *data_length /* [in,out] [unique] */, WERROR *werror) { struct winreg_QueryValue r; @@ -886,7 +886,7 @@ NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, r.in.type = type; r.in.data = data; r.in.data_size = data_size; - r.in.value_length = value_length; + r.in.data_length = data_length; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(winreg_QueryValue, &r); @@ -920,8 +920,8 @@ NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, if (data_size && r.out.data_size) { *data_size = *r.out.data_size; } - if (value_length && r.out.value_length) { - *value_length = *r.out.value_length; + if (data_length && r.out.data_length) { + *data_length = *r.out.data_length; } /* Return result */ @@ -1070,7 +1070,7 @@ NTSTATUS rpccli_winreg_SaveKey(struct rpc_pipe_client *cli, NTSTATUS rpccli_winreg_SetKeySecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, - uint32_t access_mask /* [in] */, + uint32_t sec_info /* [in] */, struct KeySecurityData *sd /* [in] [ref] */, WERROR *werror) { @@ -1079,7 +1079,7 @@ NTSTATUS rpccli_winreg_SetKeySecurity(struct rpc_pipe_client *cli, /* In parameters */ r.in.handle = handle; - r.in.access_mask = access_mask; + r.in.sec_info = sec_info; r.in.sd = sd; if (DEBUGLEVEL >= 10) { @@ -1209,7 +1209,7 @@ NTSTATUS rpccli_winreg_UnLoadKey(struct rpc_pipe_client *cli, NTSTATUS rpccli_winreg_InitiateSystemShutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, @@ -1498,7 +1498,7 @@ NTSTATUS rpccli_winreg_QueryMultipleValues(struct rpc_pipe_client *cli, NTSTATUS rpccli_winreg_InitiateSystemShutdownEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, diff --git a/source3/librpc/gen_ndr/cli_winreg.h b/source3/librpc/gen_ndr/cli_winreg.h index 793a4ffc5b..fb27bce9d2 100644 --- a/source3/librpc/gen_ndr/cli_winreg.h +++ b/source3/librpc/gen_ndr/cli_winreg.h @@ -68,7 +68,7 @@ NTSTATUS rpccli_winreg_EnumValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, uint32_t enum_index /* [in] */, - struct winreg_ValNameBuf *name /* [in,out] [ref] */, + struct winreg_StringBuf *name /* [in,out] [ref] */, enum winreg_Type *type /* [in,out] [unique] */, uint8_t *value /* [in,out] [unique,length_is(*length),size_is(*size)] */, uint32_t *size /* [in,out] [unique] */, @@ -126,9 +126,9 @@ NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, struct policy_handle *handle /* [in] [ref] */, struct winreg_String *value_name /* [in] [ref] */, enum winreg_Type *type /* [in,out] [unique] */, - uint8_t *data /* [in,out] [unique,length_is(*value_length),size_is(*data_size)] */, + uint8_t *data /* [in,out] [unique,length_is(*data_length),size_is(*data_size)] */, uint32_t *data_size /* [in,out] [unique] */, - uint32_t *value_length /* [in,out] [unique] */, + uint32_t *data_length /* [in,out] [unique] */, WERROR *werror); NTSTATUS rpccli_winreg_ReplaceKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -148,7 +148,7 @@ NTSTATUS rpccli_winreg_SaveKey(struct rpc_pipe_client *cli, NTSTATUS rpccli_winreg_SetKeySecurity(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle /* [in] [ref] */, - uint32_t access_mask /* [in] */, + uint32_t sec_info /* [in] */, struct KeySecurityData *sd /* [in] [ref] */, WERROR *werror); NTSTATUS rpccli_winreg_SetValue(struct rpc_pipe_client *cli, @@ -165,7 +165,7 @@ NTSTATUS rpccli_winreg_UnLoadKey(struct rpc_pipe_client *cli, NTSTATUS rpccli_winreg_InitiateSystemShutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, @@ -202,7 +202,7 @@ NTSTATUS rpccli_winreg_QueryMultipleValues(struct rpc_pipe_client *cli, NTSTATUS rpccli_winreg_InitiateSystemShutdownEx(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint16_t *hostname /* [in] [unique] */, - struct initshutdown_String *message /* [in] [unique] */, + struct lsa_StringLarge *message /* [in] [unique] */, uint32_t timeout /* [in] */, uint8_t force_apps /* [in] */, uint8_t do_reboot /* [in] */, diff --git a/source3/librpc/gen_ndr/dfs.h b/source3/librpc/gen_ndr/dfs.h index 8957eaef56..07548c3742 100644 --- a/source3/librpc/gen_ndr/dfs.h +++ b/source3/librpc/gen_ndr/dfs.h @@ -2,6 +2,7 @@ #include +#include "librpc/gen_ndr/misc.h" #ifndef _HEADER_netdfs #define _HEADER_netdfs diff --git a/source3/librpc/gen_ndr/drsblobs.h b/source3/librpc/gen_ndr/drsblobs.h index b0ab9aea2a..692746468e 100644 --- a/source3/librpc/gen_ndr/drsblobs.h +++ b/source3/librpc/gen_ndr/drsblobs.h @@ -4,12 +4,16 @@ #include "librpc/gen_ndr/drsuapi.h" #include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/samr.h" +#include "librpc/gen_ndr/lsa.h" #ifndef _HEADER_drsblobs #define _HEADER_drsblobs #define SUPPLEMENTAL_CREDENTIALS_PREFIX ( " " ) enum drsuapi_DsAttributeId; +enum lsa_TrustAuthType; + struct replPropertyMetaData1 { enum drsuapi_DsAttributeId attid; uint32_t version; @@ -247,7 +251,7 @@ struct package_PrimaryKerberosBlob { }/* [public] */; struct package_PrimaryCLEARTEXTBlob { - const char * cleartext;/* [flag(LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING)] */ + DATA_BLOB cleartext;/* [flag(LIBNDR_FLAG_REMAINING)] */ }/* [public] */; struct package_PrimaryWDigestHash { @@ -263,63 +267,158 @@ struct package_PrimaryWDigestBlob { struct package_PrimaryWDigestHash *hashes; }/* [public] */; -struct trustAuthInOutSecret1 { - NTTIME time1; - uint32_t unknown1; - DATA_BLOB value; - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */ +struct AuthInfoNone { + uint32_t size;/* [value(0)] */ }; -struct trustAuthInOutCtr1 { - struct trustAuthInOutSecret1 *value1;/* [relative] */ - struct trustAuthInOutSecret1 *value2;/* [relative] */ +struct AuthInfoNT4Owf { + uint32_t size;/* [value(16)] */ + struct samr_Password password; }; -struct trustAuthInOutSecret2V1 { - NTTIME time1; - uint32_t unknown1; - DATA_BLOB value; - NTTIME time2; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */ +struct AuthInfoClear { + uint32_t size; + uint8_t *password; }; -struct trustAuthInOutSecret2V2 { - NTTIME time1; - uint32_t unknown1; - DATA_BLOB value; - NTTIME time2; - uint32_t unknown2; - uint32_t unknown3; - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */ -}; - -struct trustAuthInOutCtr2 { - struct trustAuthInOutSecret2V1 *value1;/* [relative] */ - struct trustAuthInOutSecret2V2 *value2;/* [relative] */ +struct AuthInfoVersion { + uint32_t size;/* [value(4)] */ + uint32_t version; }; -union trustAuthInOutCtr { - struct trustAuthInOutCtr1 ctr1;/* [case] */ - struct trustAuthInOutCtr2 ctr2;/* [case(2)] */ +union AuthInfo { + struct AuthInfoNone none;/* [case(TRUST_AUTH_TYPE_NONE)] */ + struct AuthInfoNT4Owf nt4owf;/* [case(TRUST_AUTH_TYPE_NT4OWF)] */ + struct AuthInfoClear clear;/* [case(TRUST_AUTH_TYPE_CLEAR)] */ + struct AuthInfoVersion version;/* [case(TRUST_AUTH_TYPE_VERSION)] */ }/* [nodiscriminant] */; -struct trustAuthInOutBlob { - uint32_t version; - union trustAuthInOutCtr ctr;/* [switch_is(version)] */ +struct AuthenticationInformation { + NTTIME LastUpdateTime; + enum lsa_TrustAuthType AuthType; + union AuthInfo AuthInfo;/* [switch_is(AuthType)] */ + DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */ }/* [public] */; +struct AuthenticationInformationArray { + struct AuthenticationInformation *array;/* [size_is] */ +}/* [noprint,nopush,nopull] */; + +struct trustAuthInOutBlob { + uint32_t count; + struct AuthenticationInformationArray *current;/* [relative] */ + struct AuthenticationInformationArray *previous;/* [relative] */ +}/* [noprint,gensize,nopull,public,nopush] */; + +struct trustCurrentPasswords { + uint32_t count; + struct AuthenticationInformation **current;/* [relative] */ +}/* [gensize,public] */; + +struct trustDomainPasswords { + uint8_t confounder[512]; + struct trustCurrentPasswords outgoing;/* [subcontext_size(outgoing_size),subcontext(0)] */ + struct trustCurrentPasswords incoming;/* [subcontext_size(incoming_size),subcontext(0)] */ + uint32_t outgoing_size;/* [value(ndr_size_trustCurrentPasswords(&outgoing,ndr->flags))] */ + uint32_t incoming_size;/* [value(ndr_size_trustCurrentPasswords(&incoming,ndr->flags))] */ +}/* [public,nopull] */; + struct DsCompressedChunk { uint32_t marker; DATA_BLOB data; }/* [public] */; -struct DsCompressedBlob { - struct DsCompressedChunk chunks[5]; +struct ExtendedErrorAString { + uint16_t __size; + const char *string;/* [unique,charset(DOS),size_is(__size)] */ +}; + +struct ExtendedErrorUString { + uint16_t __size; + const char *string;/* [unique,charset(UTF16),size_is(__size)] */ +}; + +struct ExtendedErrorBlob { + uint16_t length; + uint8_t *data;/* [unique,size_is(length)] */ +}; + +enum ExtendedErrorComputerNamePresent +#ifndef USE_UINT_ENUMS + { + EXTENDED_ERROR_COMPUTER_NAME_PRESENT=1, + EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT=2 +} +#else + { __donnot_use_enum_ExtendedErrorComputerNamePresent=0x7FFFFFFF} +#define EXTENDED_ERROR_COMPUTER_NAME_PRESENT ( 1 ) +#define EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT ( 2 ) +#endif +; + +union ExtendedErrorComputerNameU { + struct ExtendedErrorUString name;/* [case(EXTENDED_ERROR_COMPUTER_NAME_PRESENT)] */ +}/* [switch_type(ExtendedErrorComputerNamePresent)] */; + +struct ExtendedErrorComputerName { + enum ExtendedErrorComputerNamePresent present; + union ExtendedErrorComputerNameU n;/* [switch_is(present)] */ +}; + +enum ExtendedErrorParamType +#ifndef USE_UINT_ENUMS + { + EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING=1, + EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING=2, + EXTENDED_ERROR_PARAM_TYPE_UINT32=3, + EXTENDED_ERROR_PARAM_TYPE_UINT16=4, + EXTENDED_ERROR_PARAM_TYPE_UINT64=5, + EXTENDED_ERROR_PARAM_TYPE_NONE=6, + EXTENDED_ERROR_PARAM_TYPE_BLOB=7 +} +#else + { __donnot_use_enum_ExtendedErrorParamType=0x7FFFFFFF} +#define EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING ( 1 ) +#define EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING ( 2 ) +#define EXTENDED_ERROR_PARAM_TYPE_UINT32 ( 3 ) +#define EXTENDED_ERROR_PARAM_TYPE_UINT16 ( 4 ) +#define EXTENDED_ERROR_PARAM_TYPE_UINT64 ( 5 ) +#define EXTENDED_ERROR_PARAM_TYPE_NONE ( 6 ) +#define EXTENDED_ERROR_PARAM_TYPE_BLOB ( 7 ) +#endif +; + +union ExtendedErrorParamU { + struct ExtendedErrorAString a_string;/* [case(EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING)] */ + struct ExtendedErrorUString u_string;/* [case(EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING)] */ + uint32_t uint32;/* [case(EXTENDED_ERROR_PARAM_TYPE_UINT32)] */ + uint16_t uint16;/* [case(EXTENDED_ERROR_PARAM_TYPE_UINT16)] */ + uint64_t uint64;/* [case(EXTENDED_ERROR_PARAM_TYPE_UINT64)] */ + struct ExtendedErrorBlob blob;/* [case(EXTENDED_ERROR_PARAM_TYPE_BLOB)] */ +}/* [switch_type(ExtendedErrorParamType)] */; + +struct ExtendedErrorParam { + enum ExtendedErrorParamType type; + union ExtendedErrorParamU p;/* [switch_is(type)] */ +}; + +struct ExtendedErrorInfo { + struct ExtendedErrorInfo *next;/* [unique] */ + struct ExtendedErrorComputerName computer_name; + uint64_t pid; + NTTIME time; + uint32_t generating_component; + WERROR status; + uint16_t detection_location; + uint16_t flags; + uint16_t num_params; + struct ExtendedErrorParam *params;/* [size_is(num_params)] */ }/* [public] */; +struct ExtendedErrorInfoPtr { + struct ExtendedErrorInfo *info;/* [unique] */ +}; + struct decode_replPropertyMetaData { struct { @@ -417,9 +516,17 @@ struct decode_trustAuthInOut { }; -struct decode_DsCompressed { +struct decode_trustDomainPasswords { + struct { + struct trustDomainPasswords blob; + } in; + +}; + + +struct decode_ExtendedErrorInfo { struct { - struct DsCompressedBlob blob; + struct ExtendedErrorInfoPtr ptr;/* [subcontext(0xFFFFFC01)] */ } in; }; diff --git a/source3/librpc/gen_ndr/drsuapi.h b/source3/librpc/gen_ndr/drsuapi.h index 049c2bf4b1..ba01e8f226 100644 --- a/source3/librpc/gen_ndr/drsuapi.h +++ b/source3/librpc/gen_ndr/drsuapi.h @@ -575,29 +575,37 @@ struct drsuapi_DsGetNCChangesCtr6 { WERROR drs_error; }/* [gensize,public] */; +struct drsuapi_DsGetNCChangesCtr1TS { + struct drsuapi_DsGetNCChangesCtr1 ctr1;/* [subcontext(0xFFFFFC01)] */ +}/* [public] */; + +struct drsuapi_DsGetNCChangesCtr6TS { + struct drsuapi_DsGetNCChangesCtr6 ctr6;/* [subcontext(0xFFFFFC01)] */ +}/* [public] */; + struct drsuapi_DsGetNCChangesMSZIPCtr1 { uint32_t decompressed_length; uint32_t compressed_length; - struct drsuapi_DsGetNCChangesCtr1 *ctr1;/* [unique,compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ -}; + struct drsuapi_DsGetNCChangesCtr1TS *ts;/* [unique,compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ +}/* [nopush] */; struct drsuapi_DsGetNCChangesMSZIPCtr6 { uint32_t decompressed_length; uint32_t compressed_length; - struct drsuapi_DsGetNCChangesCtr6 *ctr6;/* [unique,compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ -}; + struct drsuapi_DsGetNCChangesCtr6TS *ts;/* [unique,compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ +}/* [nopush] */; struct drsuapi_DsGetNCChangesXPRESSCtr1 { uint32_t decompressed_length; uint32_t compressed_length; - struct drsuapi_DsGetNCChangesCtr1 *ctr1;/* [unique,compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ -}; + struct drsuapi_DsGetNCChangesCtr1TS *ts;/* [unique,compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ +}/* [nopush] */; struct drsuapi_DsGetNCChangesXPRESSCtr6 { uint32_t decompressed_length; uint32_t compressed_length; - struct drsuapi_DsGetNCChangesCtr6 *ctr6;/* [unique,compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ -}; + struct drsuapi_DsGetNCChangesCtr6TS *ts;/* [unique,compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length),subcontext_size(compressed_length),subcontext(4)] */ +}/* [nopush] */; enum drsuapi_DsGetNCChangesCompressionType #ifndef USE_UINT_ENUMS @@ -620,7 +628,7 @@ union drsuapi_DsGetNCChangesCompressedCtr { }/* [nodiscriminant,flag(LIBNDR_PRINT_ARRAY_HEX)] */; struct drsuapi_DsGetNCChangesCtr2 { - union drsuapi_DsGetNCChangesCompressedCtr ctr;/* [switch_is(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] */ + struct drsuapi_DsGetNCChangesMSZIPCtr1 mszip1; }; struct drsuapi_DsGetNCChangesCtr7 { @@ -790,7 +798,7 @@ enum drsuapi_DsNameFlags enum drsuapi_DsNameFormat #ifndef USE_UINT_ENUMS { - DRSUAPI_DS_NAME_FORMAT_UKNOWN=0, + DRSUAPI_DS_NAME_FORMAT_UNKNOWN=0, DRSUAPI_DS_NAME_FORMAT_FQDN_1779=1, DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT=2, DRSUAPI_DS_NAME_FORMAT_DISPLAY=3, @@ -804,7 +812,7 @@ enum drsuapi_DsNameFormat } #else { __donnot_use_enum_drsuapi_DsNameFormat=0x7FFFFFFF} -#define DRSUAPI_DS_NAME_FORMAT_UKNOWN ( 0 ) +#define DRSUAPI_DS_NAME_FORMAT_UNKNOWN ( 0 ) #define DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ( 1 ) #define DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT ( 2 ) #define DRSUAPI_DS_NAME_FORMAT_DISPLAY ( 3 ) @@ -889,7 +897,7 @@ union drsuapi_DsWriteAccountSpnResult { struct drsuapi_DsRemoveDSServerRequest1 { const char *server_dn;/* [unique,charset(UTF16)] */ const char *domain_dn;/* [unique,charset(UTF16)] */ - uint32_t unknown; + uint32_t commit; }; union drsuapi_DsRemoveDSServerRequest { @@ -897,7 +905,7 @@ union drsuapi_DsRemoveDSServerRequest { }/* [switch_type(int32)] */; struct drsuapi_DsRemoveDSServerResult1 { - WERROR status; + uint32_t last_dc_in_domain; }; union drsuapi_DsRemoveDSServerResult { diff --git a/source3/librpc/gen_ndr/echo.h b/source3/librpc/gen_ndr/echo.h index c8b5b86422..79d4220714 100644 --- a/source3/librpc/gen_ndr/echo.h +++ b/source3/librpc/gen_ndr/echo.h @@ -7,7 +7,7 @@ struct echo_info1 { uint8_t v; -}; +}/* [public] */; struct echo_info2 { uint16_t v; diff --git a/source3/librpc/gen_ndr/epmapper.h b/source3/librpc/gen_ndr/epmapper.h index d39269b32b..4b75261a02 100644 --- a/source3/librpc/gen_ndr/epmapper.h +++ b/source3/librpc/gen_ndr/epmapper.h @@ -2,6 +2,7 @@ #include +#include "librpc/gen_ndr/misc.h" #ifndef _HEADER_epmapper #define _HEADER_epmapper @@ -226,7 +227,9 @@ struct epm_twr_t { struct epm_entry_t { struct GUID object; struct epm_twr_t *tower;/* [ptr] */ - const char * annotation;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4)] */ + uint32_t __annotation_offset;/* [value(0)] */ + uint32_t __annotation_length;/* [value(strlen(annotation)+1)] */ + const char *annotation;/* [charset(DOS)] */ }; struct rpc_if_id_t { diff --git a/source3/librpc/gen_ndr/initshutdown.h b/source3/librpc/gen_ndr/initshutdown.h index 366f017c97..014e2fe689 100644 --- a/source3/librpc/gen_ndr/initshutdown.h +++ b/source3/librpc/gen_ndr/initshutdown.h @@ -2,25 +2,15 @@ #include +#include "librpc/gen_ndr/lsa.h" #ifndef _HEADER_initshutdown #define _HEADER_initshutdown -struct initshutdown_String_sub { - uint32_t name_size;/* [value(strlen_m_term(name))] */ - const char * name;/* [flag(LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM)] */ -}; - -struct initshutdown_String { - uint16_t name_len;/* [value(strlen_m(name->name)*2)] */ - uint16_t name_size;/* [value(strlen_m_term(name->name)*2)] */ - struct initshutdown_String_sub *name;/* [unique] */ -}/* [public] */; - struct initshutdown_Init { struct { uint16_t *hostname;/* [unique] */ - struct initshutdown_String *message;/* [unique] */ + struct lsa_StringLarge *message;/* [unique] */ uint32_t timeout; uint8_t force_apps; uint8_t do_reboot; @@ -48,7 +38,7 @@ struct initshutdown_Abort { struct initshutdown_InitEx { struct { uint16_t *hostname;/* [unique] */ - struct initshutdown_String *message;/* [unique] */ + struct lsa_StringLarge *message;/* [unique] */ uint32_t timeout; uint8_t force_apps; uint8_t do_reboot; diff --git a/source3/librpc/gen_ndr/krb5pac.h b/source3/librpc/gen_ndr/krb5pac.h index b3b29e5b2f..7ec3e95d70 100644 --- a/source3/librpc/gen_ndr/krb5pac.h +++ b/source3/librpc/gen_ndr/krb5pac.h @@ -8,6 +8,7 @@ #ifndef _HEADER_krb5pac #define _HEADER_krb5pac +#define NETLOGON_GENERIC_KRB5_PAC_VALIDATE ( 3 ) struct PAC_LOGON_NAME { NTTIME logon_time; uint16_t size;/* [value(2*strlen_m(account_name))] */ @@ -39,10 +40,6 @@ struct PAC_UNKNOWN_12 { }; struct PAC_LOGON_INFO_CTR { - uint32_t unknown1;/* [value(0x00081001)] */ - uint32_t unknown2;/* [value(0xCCCCCCCC)] */ - uint32_t _ndr_size;/* [value(NDR_ROUND(ndr_size_PAC_LOGON_INFO(info,ndr->flags)+4,8))] */ - uint32_t unknown3;/* [value(0x00000000)] */ struct PAC_LOGON_INFO *info;/* [unique] */ }/* [public] */; @@ -72,7 +69,7 @@ struct DATA_BLOB_REM { }; union PAC_INFO { - struct PAC_LOGON_INFO_CTR logon_info;/* [case(PAC_TYPE_LOGON_INFO)] */ + struct PAC_LOGON_INFO_CTR logon_info;/* [subcontext(0xFFFFFC01),case(PAC_TYPE_LOGON_INFO)] */ struct PAC_SIGNATURE_DATA srv_cksum;/* [case(PAC_TYPE_SRV_CHECKSUM)] */ struct PAC_SIGNATURE_DATA kdc_cksum;/* [case(PAC_TYPE_KDC_CHECKSUM)] */ struct PAC_LOGON_NAME logon_name;/* [case(PAC_TYPE_LOGON_NAME)] */ @@ -105,6 +102,14 @@ struct PAC_DATA_RAW { struct PAC_BUFFER_RAW *buffers; }/* [public] */; +struct PAC_Validate { + uint32_t MessageType;/* [value(NETLOGON_GENERIC_KRB5_PAC_VALIDATE)] */ + uint32_t ChecksumLength; + int32_t SignatureType; + uint32_t SignatureLength; + DATA_BLOB ChecksumAndSignature;/* [flag(LIBNDR_FLAG_REMAINING)] */ +}/* [public] */; + struct netsamlogoncache_entry { time_t timestamp; struct netr_SamInfo3 info3; @@ -134,4 +139,12 @@ struct decode_login_info { }; + +struct decode_pac_validate { + struct { + struct PAC_Validate pac_validate; + } in; + +}; + #endif /* _HEADER_krb5pac */ diff --git a/source3/librpc/gen_ndr/libnetapi.h b/source3/librpc/gen_ndr/libnetapi.h index 98da9e12ea..ae7acbf572 100644 --- a/source3/librpc/gen_ndr/libnetapi.h +++ b/source3/librpc/gen_ndr/libnetapi.h @@ -413,7 +413,9 @@ struct USER_INFO_X { uint32_t usriX_code_page; const char * usriX_profile; const char * usriX_home_dir_drive; + uint32_t usriX_user_id; uint32_t usriX_primary_group_id; + uint32_t usriX_password_expired; }; struct GROUP_USERS_INFO_0 { diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 1e3d3162b2..d91cf4b66d 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -2,6 +2,7 @@ #include +#include "librpc/gen_ndr/misc.h" #include "librpc/gen_ndr/security.h" #ifndef _HEADER_lsarpc #define _HEADER_lsarpc @@ -11,6 +12,9 @@ #define MAX_REF_DOMAINS ( LSA_REF_DOMAIN_LIST_MULTIPLIER ) #define MAX_LOOKUP_SIDS ( 0x5000 ) #define LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER ( 82 ) +#define LSA_CLIENT_REVISION_NO_DNS ( 0x00000001 ) +#define LSA_CLIENT_REVISION_DNS ( 0x00000002 ) +#define LSA_LOOKUP_OPTIONS_NO_ISOLATED ( 0x80000000 ) struct lsa_String { uint16_t length;/* [value(2*strlen_m(string))] */ uint16_t size;/* [value(2*strlen_m(string))] */ @@ -93,12 +97,11 @@ struct lsa_ObjectAttribute { struct lsa_AuditLogInfo { uint32_t percent_full; - uint32_t log_size; - NTTIME retention_time; + uint32_t maximum_log_size; + uint64_t retention_time; uint8_t shutdown_in_progress; - NTTIME time_to_shutdown; + uint64_t time_to_shutdown; uint32_t next_audit_record; - uint32_t unknown; }; enum lsa_PolicyAuditPolicy @@ -162,9 +165,21 @@ struct lsa_PDAccountInfo { struct lsa_String name; }; +enum lsa_Role +#ifndef USE_UINT_ENUMS + { + LSA_ROLE_BACKUP=2, + LSA_ROLE_PRIMARY=3 +} +#else + { __donnot_use_enum_lsa_Role=0x7FFFFFFF} +#define LSA_ROLE_BACKUP ( 2 ) +#define LSA_ROLE_PRIMARY ( 3 ) +#endif +; + struct lsa_ServerRole { - uint16_t unknown; - uint16_t role; + enum lsa_Role role; }; struct lsa_ReplicaSourceInfo { @@ -191,7 +206,6 @@ struct lsa_AuditFullSetInfo { }; struct lsa_AuditFullQueryInfo { - uint16_t unknown; uint8_t shutdown_on_full; uint8_t log_is_full; }; @@ -215,10 +229,12 @@ enum lsa_PolicyInfo LSA_POLICY_INFO_ROLE=6, LSA_POLICY_INFO_REPLICA=7, LSA_POLICY_INFO_QUOTA=8, - LSA_POLICY_INFO_DB=9, + LSA_POLICY_INFO_MOD=9, LSA_POLICY_INFO_AUDIT_FULL_SET=10, LSA_POLICY_INFO_AUDIT_FULL_QUERY=11, - LSA_POLICY_INFO_DNS=12 + LSA_POLICY_INFO_DNS=12, + LSA_POLICY_INFO_DNS_INT=13, + LSA_POLICY_INFO_L_ACCOUNT_DOMAIN=14 } #else { __donnot_use_enum_lsa_PolicyInfo=0x7FFFFFFF} @@ -230,10 +246,12 @@ enum lsa_PolicyInfo #define LSA_POLICY_INFO_ROLE ( 6 ) #define LSA_POLICY_INFO_REPLICA ( 7 ) #define LSA_POLICY_INFO_QUOTA ( 8 ) -#define LSA_POLICY_INFO_DB ( 9 ) +#define LSA_POLICY_INFO_MOD ( 9 ) #define LSA_POLICY_INFO_AUDIT_FULL_SET ( 10 ) #define LSA_POLICY_INFO_AUDIT_FULL_QUERY ( 11 ) #define LSA_POLICY_INFO_DNS ( 12 ) +#define LSA_POLICY_INFO_DNS_INT ( 13 ) +#define LSA_POLICY_INFO_L_ACCOUNT_DOMAIN ( 14 ) #endif ; @@ -246,10 +264,11 @@ union lsa_PolicyInformation { struct lsa_ServerRole role;/* [case(LSA_POLICY_INFO_ROLE)] */ struct lsa_ReplicaSourceInfo replica;/* [case(LSA_POLICY_INFO_REPLICA)] */ struct lsa_DefaultQuotaInfo quota;/* [case(LSA_POLICY_INFO_QUOTA)] */ - struct lsa_ModificationInfo db;/* [case(LSA_POLICY_INFO_DB)] */ + struct lsa_ModificationInfo mod;/* [case(LSA_POLICY_INFO_MOD)] */ struct lsa_AuditFullSetInfo auditfullset;/* [case(LSA_POLICY_INFO_AUDIT_FULL_SET)] */ struct lsa_AuditFullQueryInfo auditfullquery;/* [case(LSA_POLICY_INFO_AUDIT_FULL_QUERY)] */ struct lsa_DnsDomainInfo dns;/* [case(LSA_POLICY_INFO_DNS)] */ + struct lsa_DomainInfo l_account_domain;/* [case(LSA_POLICY_INFO_L_ACCOUNT_DOMAIN)] */ }/* [switch_type(uint16)] */; struct lsa_SidPtr { @@ -320,7 +339,8 @@ enum lsa_LookupNamesLevel LSA_LOOKUP_NAMES_PRIMARY_DOMAIN_ONLY=3, LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY=4, LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY=5, - LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2=6 + LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2=6, + LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC=7 } #else { __donnot_use_enum_lsa_LookupNamesLevel=0x7FFFFFFF} @@ -330,6 +350,7 @@ enum lsa_LookupNamesLevel #define LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY ( 4 ) #define LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY ( 5 ) #define LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 ( 6 ) +#define LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC ( 7 ) #endif ; @@ -355,6 +376,21 @@ struct lsa_PrivilegeSet { struct lsa_LUIDAttribute *set;/* [size_is(count)] */ }; +/* bitmap lsa_SystemAccessModeFlags */ +#define LSA_POLICY_MODE_INTERACTIVE ( 0x00000001 ) +#define LSA_POLICY_MODE_NETWORK ( 0x00000002 ) +#define LSA_POLICY_MODE_BATCH ( 0x00000004 ) +#define LSA_POLICY_MODE_SERVICE ( 0x00000010 ) +#define LSA_POLICY_MODE_PROXY ( 0x00000020 ) +#define LSA_POLICY_MODE_DENY_INTERACTIVE ( 0x00000040 ) +#define LSA_POLICY_MODE_DENY_NETWORK ( 0x00000080 ) +#define LSA_POLICY_MODE_DENY_BATCH ( 0x00000100 ) +#define LSA_POLICY_MODE_DENY_SERVICE ( 0x00000200 ) +#define LSA_POLICY_MODE_REMOTE_INTERACTIVE ( 0x00000400 ) +#define LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE ( 0x00000800 ) +#define LSA_POLICY_MODE_ALL ( 0x00000FF7 ) +#define LSA_POLICY_MODE_ALL_NT4 ( 0x00000037 ) + struct lsa_DATA_BUF { uint32_t length; uint32_t size; @@ -370,35 +406,75 @@ enum lsa_TrustDomInfoEnum #ifndef USE_UINT_ENUMS { LSA_TRUSTED_DOMAIN_INFO_NAME=1, - LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO=2, + LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS=2, LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET=3, LSA_TRUSTED_DOMAIN_INFO_PASSWORD=4, LSA_TRUSTED_DOMAIN_INFO_BASIC=5, LSA_TRUSTED_DOMAIN_INFO_INFO_EX=6, LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO=7, LSA_TRUSTED_DOMAIN_INFO_FULL_INFO=8, - LSA_TRUSTED_DOMAIN_INFO_11=11, - LSA_TRUSTED_DOMAIN_INFO_INFO_ALL=12 + LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL=9, + LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL=10, + LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL=11, + LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL=12, + LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES=13 } #else { __donnot_use_enum_lsa_TrustDomInfoEnum=0x7FFFFFFF} #define LSA_TRUSTED_DOMAIN_INFO_NAME ( 1 ) -#define LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO ( 2 ) +#define LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS ( 2 ) #define LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET ( 3 ) #define LSA_TRUSTED_DOMAIN_INFO_PASSWORD ( 4 ) #define LSA_TRUSTED_DOMAIN_INFO_BASIC ( 5 ) #define LSA_TRUSTED_DOMAIN_INFO_INFO_EX ( 6 ) #define LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO ( 7 ) #define LSA_TRUSTED_DOMAIN_INFO_FULL_INFO ( 8 ) -#define LSA_TRUSTED_DOMAIN_INFO_11 ( 11 ) -#define LSA_TRUSTED_DOMAIN_INFO_INFO_ALL ( 12 ) +#define LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL ( 9 ) +#define LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL ( 10 ) +#define LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL ( 11 ) +#define LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL ( 12 ) +#define LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES ( 13 ) +#endif +; + +/* bitmap lsa_TrustDirection */ +#define LSA_TRUST_DIRECTION_INBOUND ( 0x00000001 ) +#define LSA_TRUST_DIRECTION_OUTBOUND ( 0x00000002 ) + +enum lsa_TrustType +#ifndef USE_UINT_ENUMS + { + LSA_TRUST_TYPE_DOWNLEVEL=0x00000001, + LSA_TRUST_TYPE_UPLEVEL=0x00000002, + LSA_TRUST_TYPE_MIT=0x00000003 +} +#else + { __donnot_use_enum_lsa_TrustType=0x7FFFFFFF} +#define LSA_TRUST_TYPE_DOWNLEVEL ( 0x00000001 ) +#define LSA_TRUST_TYPE_UPLEVEL ( 0x00000002 ) +#define LSA_TRUST_TYPE_MIT ( 0x00000003 ) #endif ; +/* bitmap lsa_TrustAttributes */ +#define LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE ( 0x00000001 ) +#define LSA_TRUST_ATTRIBUTE_UPLEVEL_ONLY ( 0x00000002 ) +#define LSA_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN ( 0x00000004 ) +#define LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE ( 0x00000008 ) +#define LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION ( 0x00000010 ) +#define LSA_TRUST_ATTRIBUTE_WITHIN_FOREST ( 0x00000020 ) +#define LSA_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL ( 0x00000040 ) +#define LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION ( 0x00000080 ) + struct lsa_TrustDomainInfoName { struct lsa_StringLarge netbios_name; }; +struct lsa_TrustDomainInfoControllers { + uint32_t entries; + struct lsa_StringLarge *netbios_names;/* [unique,size_is(entries)] */ +}; + struct lsa_TrustDomainInfoPosixOffset { uint32_t posix_offset; }; @@ -418,13 +494,30 @@ struct lsa_TrustDomainInfoInfoEx { struct lsa_StringLarge netbios_name; struct dom_sid2 *sid;/* [unique] */ uint32_t trust_direction; - uint32_t trust_type; + enum lsa_TrustType trust_type; uint32_t trust_attributes; }; +enum lsa_TrustAuthType +#ifndef USE_UINT_ENUMS + { + TRUST_AUTH_TYPE_NONE=0, + TRUST_AUTH_TYPE_NT4OWF=1, + TRUST_AUTH_TYPE_CLEAR=2, + TRUST_AUTH_TYPE_VERSION=3 +} +#else + { __donnot_use_enum_lsa_TrustAuthType=0x7FFFFFFF} +#define TRUST_AUTH_TYPE_NONE ( 0 ) +#define TRUST_AUTH_TYPE_NT4OWF ( 1 ) +#define TRUST_AUTH_TYPE_CLEAR ( 2 ) +#define TRUST_AUTH_TYPE_VERSION ( 3 ) +#endif +; + struct lsa_TrustDomainInfoBuffer { NTTIME last_update_time; - uint32_t secret_type; + enum lsa_TrustAuthType AuthType; struct lsa_DATA_BUF2 data; }; @@ -443,28 +536,46 @@ struct lsa_TrustDomainInfoFullInfo { struct lsa_TrustDomainInfoAuthInfo auth_info; }; -struct lsa_TrustDomainInfo11 { +struct lsa_TrustDomainInfoAuthInfoInternal { + struct lsa_DATA_BUF2 auth_blob; +}; + +struct lsa_TrustDomainInfoFullInfoInternal { struct lsa_TrustDomainInfoInfoEx info_ex; - struct lsa_DATA_BUF2 data1; + struct lsa_TrustDomainInfoPosixOffset posix_offset; + struct lsa_TrustDomainInfoAuthInfoInternal auth_info; }; -struct lsa_TrustDomainInfoInfoAll { +struct lsa_TrustDomainInfoInfoEx2Internal { struct lsa_TrustDomainInfoInfoEx info_ex; - struct lsa_DATA_BUF2 data1; + uint32_t forest_trust_length; + uint8_t *forest_trust_data;/* [unique,size_is(forest_trust_length)] */ +}; + +struct lsa_TrustDomainInfoFullInfo2Internal { + struct lsa_TrustDomainInfoInfoEx2Internal info; struct lsa_TrustDomainInfoPosixOffset posix_offset; struct lsa_TrustDomainInfoAuthInfo auth_info; }; +struct lsa_TrustDomainInfoSupportedEncTypes { + uint32_t enc_types; +}; + union lsa_TrustedDomainInfo { struct lsa_TrustDomainInfoName name;/* [case(LSA_TRUSTED_DOMAIN_INFO_NAME)] */ + struct lsa_TrustDomainInfoControllers controllers;/* [case(LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS)] */ struct lsa_TrustDomainInfoPosixOffset posix_offset;/* [case(LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET)] */ struct lsa_TrustDomainInfoPassword password;/* [case(LSA_TRUSTED_DOMAIN_INFO_PASSWORD)] */ struct lsa_TrustDomainInfoBasic info_basic;/* [case(LSA_TRUSTED_DOMAIN_INFO_BASIC)] */ struct lsa_TrustDomainInfoInfoEx info_ex;/* [case(LSA_TRUSTED_DOMAIN_INFO_INFO_EX)] */ struct lsa_TrustDomainInfoAuthInfo auth_info;/* [case(LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO)] */ struct lsa_TrustDomainInfoFullInfo full_info;/* [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)] */ - struct lsa_TrustDomainInfo11 info11;/* [case(LSA_TRUSTED_DOMAIN_INFO_11)] */ - struct lsa_TrustDomainInfoInfoAll info_all;/* [case(LSA_TRUSTED_DOMAIN_INFO_INFO_ALL)] */ + struct lsa_TrustDomainInfoAuthInfoInternal auth_info_internal;/* [case(LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL)] */ + struct lsa_TrustDomainInfoFullInfoInternal full_info_internal;/* [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL)] */ + struct lsa_TrustDomainInfoInfoEx2Internal info_ex2_internal;/* [case(LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL)] */ + struct lsa_TrustDomainInfoFullInfo2Internal full_info2_internal;/* [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL)] */ + struct lsa_TrustDomainInfoSupportedEncTypes enc_types;/* [case(LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES)] */ }/* [switch_type(lsa_TrustDomInfoEnum)] */; struct lsa_DATA_BUF_PTR { @@ -545,7 +656,7 @@ struct lsa_TranslatedSid3 { enum lsa_SidType sid_type; struct dom_sid2 *sid;/* [unique] */ uint32_t sid_index; - uint32_t unknown; + uint32_t flags; }; struct lsa_TransSidArray3 { @@ -762,7 +873,7 @@ struct lsa_EnumAccounts { struct lsa_CreateTrustedDomain { struct { - struct policy_handle *handle;/* [ref] */ + struct policy_handle *policy_handle;/* [ref] */ struct lsa_DomainInfo *info;/* [ref] */ uint32_t access_mask; } in; @@ -972,6 +1083,12 @@ struct lsa_QueryTrustedDomainInfo { struct lsa_SetInformationTrustedDomain { + struct { + struct policy_handle *trustdom_handle;/* [ref] */ + enum lsa_TrustDomInfoEnum level; + union lsa_TrustedDomainInfo *info;/* [ref,switch_is(level)] */ + } in; + struct { NTSTATUS result; } out; @@ -1159,6 +1276,13 @@ struct lsa_QueryTrustedDomainInfoBySid { struct lsa_SetTrustedDomainInfo { + struct { + struct policy_handle *handle;/* [ref] */ + struct dom_sid2 *dom_sid;/* [ref] */ + enum lsa_TrustDomInfoEnum level; + union lsa_TrustedDomainInfo *info;/* [ref,switch_is(level)] */ + } in; + struct { NTSTATUS result; } out; @@ -1302,6 +1426,14 @@ struct lsa_EnumTrustedDomainsEx { struct lsa_CreateTrustedDomainEx { struct { + struct policy_handle *policy_handle;/* [ref] */ + struct lsa_TrustDomainInfoInfoEx *info;/* [ref] */ + struct lsa_TrustDomainInfoAuthInfoInternal *auth_info;/* [ref] */ + uint32_t access_mask; + } in; + + struct { + struct policy_handle *trustdom_handle;/* [ref] */ NTSTATUS result; } out; @@ -1399,8 +1531,8 @@ struct lsa_LookupNames2 { uint32_t num_names;/* [range(0,1000)] */ struct lsa_String *names;/* [size_is(num_names)] */ enum lsa_LookupNamesLevel level; - uint32_t unknown1; - uint32_t unknown2; + uint32_t lookup_options; + uint32_t client_revision; struct lsa_TransSidArray2 *sids;/* [ref] */ uint32_t *count;/* [ref] */ } in; @@ -1417,6 +1549,14 @@ struct lsa_LookupNames2 { struct lsa_CreateTrustedDomainEx2 { struct { + struct policy_handle *policy_handle;/* [ref] */ + struct lsa_TrustDomainInfoInfoEx *info;/* [ref] */ + struct lsa_TrustDomainInfoAuthInfoInternal *auth_info;/* [ref] */ + uint32_t access_mask; + } in; + + struct { + struct policy_handle *trustdom_handle;/* [ref] */ NTSTATUS result; } out; @@ -1493,8 +1633,8 @@ struct lsa_LookupNames3 { uint32_t num_names;/* [range(0,1000)] */ struct lsa_String *names;/* [size_is(num_names)] */ enum lsa_LookupNamesLevel level; - uint32_t unknown1; - uint32_t unknown2; + uint32_t lookup_options; + uint32_t client_revision; struct lsa_TransSidArray3 *sids;/* [ref] */ uint32_t *count;/* [ref] */ } in; @@ -1597,8 +1737,8 @@ struct lsa_LookupNames4 { uint32_t num_names;/* [range(0,1000)] */ struct lsa_String *names;/* [size_is(num_names)] */ enum lsa_LookupNamesLevel level; - uint32_t unknown1; - uint32_t unknown2; + uint32_t lookup_options; + uint32_t client_revision; struct lsa_TransSidArray3 *sids;/* [ref] */ uint32_t *count;/* [ref] */ } in; diff --git a/source3/librpc/gen_ndr/misc.h b/source3/librpc/gen_ndr/misc.h index 4fa7415db7..b3740faf34 100644 --- a/source3/librpc/gen_ndr/misc.h +++ b/source3/librpc/gen_ndr/misc.h @@ -26,13 +26,17 @@ struct policy_handle { enum netr_SchannelType #ifndef USE_UINT_ENUMS { + SEC_CHAN_NULL=0, SEC_CHAN_WKSTA=2, + SEC_CHAN_DNS_DOMAIN=3, SEC_CHAN_DOMAIN=4, SEC_CHAN_BDC=6 } #else { __donnot_use_enum_netr_SchannelType=0x7FFFFFFF} +#define SEC_CHAN_NULL ( 0 ) #define SEC_CHAN_WKSTA ( 2 ) +#define SEC_CHAN_DNS_DOMAIN ( 3 ) #define SEC_CHAN_DOMAIN ( 4 ) #define SEC_CHAN_BDC ( 6 ) #endif diff --git a/source3/librpc/gen_ndr/nbt.h b/source3/librpc/gen_ndr/nbt.h index 62ad524a91..4b872d7936 100644 --- a/source3/librpc/gen_ndr/nbt.h +++ b/source3/librpc/gen_ndr/nbt.h @@ -221,15 +221,15 @@ union nbt_rdata { struct nbt_rdata_netbios netbios;/* [case(NBT_QTYPE_NETBIOS)] */ struct nbt_rdata_status status;/* [case(NBT_QTYPE_STATUS)] */ struct nbt_rdata_data data;/* [default] */ -}/* [nodiscriminant] */; +}/* [nodiscriminant,public] */; struct nbt_res_rec { struct nbt_name name; enum nbt_qtype rr_type; enum nbt_qclass rr_class; uint32_t ttl; - union nbt_rdata rdata;/* [switch_is(((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,"struct ndr_push")&&((rdata).data.length==2))?0:rr_type))] */ -}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */; + union nbt_rdata rdata;/* [switch_is(rr_type)] */ +}/* [nopush,flag(LIBNDR_PRINT_ARRAY_HEX)] */; struct nbt_name_packet { uint16_t name_trn_id; @@ -390,69 +390,11 @@ struct nbt_dgram_packet { union dgram_data data;/* [switch_is(msg_type)] */ }/* [public,flag(LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_BIGENDIAN|LIBNDR_PRINT_ARRAY_HEX)] */; -enum nbt_netlogon_command -#ifndef USE_UINT_ENUMS - { - NETLOGON_QUERY_FOR_PDC=0x7, - NETLOGON_ANNOUNCE_UAS=0xa, - NETLOGON_RESPONSE_FROM_PDC=0xc, - NETLOGON_QUERY_FOR_PDC2=0x12, - NETLOGON_RESPONSE_FROM_PDC2=0x17, - NETLOGON_RESPONSE_FROM_PDC_USER=0x19 -} -#else - { __donnot_use_enum_nbt_netlogon_command=0x7FFFFFFF} -#define NETLOGON_QUERY_FOR_PDC ( 0x7 ) -#define NETLOGON_ANNOUNCE_UAS ( 0xa ) -#define NETLOGON_RESPONSE_FROM_PDC ( 0xc ) -#define NETLOGON_QUERY_FOR_PDC2 ( 0x12 ) -#define NETLOGON_RESPONSE_FROM_PDC2 ( 0x17 ) -#define NETLOGON_RESPONSE_FROM_PDC_USER ( 0x19 ) -#endif -; - -/* bitmap nbt_netlogon_version */ -#define NETLOGON_VERSION_1 ( 0x00000001 ) -#define NETLOGON_VERSION_5 ( 0x00000002 ) -#define NETLOGON_VERSION_5EX ( 0x00000004 ) -#define NETLOGON_VERSION_5EX_WITH_IP ( 0x00000008 ) -#define NETLOGON_VERSION_WITH_CLOSEST_SITE ( 0x00000010 ) -#define NETLOGON_VERSION_AVOID_NT4_EMUL ( 0x01000000 ) -#define NETLOGON_VERSION_PDC ( 0x10000000 ) -#define NETLOGON_VERSION_IP ( 0x20000000 ) -#define NETLOGON_VERSION_LOCAL ( 0x40000000 ) -#define NETLOGON_VERSION_GC ( 0x80000000 ) - -struct nbt_netlogon_query_for_pdc { - const char * computer_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */ - const char * unicode_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - uint32_t nt_version; - uint16_t lmnt_token; - uint16_t lm20_token; -}; - -struct nbt_netlogon_query_for_pdc2 { - uint16_t request_count; - const char * computer_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - uint32_t unknown[2]; - uint32_t nt_version; - uint16_t lmnt_token; - uint16_t lm20_token; -}; - -struct nbt_netlogon_response_from_pdc { - const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */ - const char * unicode_pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - uint32_t nt_version; - uint16_t lmnt_token; - uint16_t lm20_token; -}; +struct nbt_sockaddr { + uint32_t sockaddr_family; + const char * pdc_ip;/* [flag(LIBNDR_FLAG_BIGENDIAN)] */ + DATA_BLOB remaining;/* [flag(LIBNDR_FLAG_REMAINING)] */ +}/* [gensize,public] */; /* bitmap nbt_server_type */ #define NBT_SERVER_PDC ( 0x00000001 ) @@ -468,157 +410,90 @@ struct nbt_netlogon_response_from_pdc { #define NBT_SERVER_SELECT_SECRET_DOMAIN_6 ( 0x00000800 ) #define NBT_SERVER_FULL_SECRET_DOMAIN_6 ( 0x00001000 ) -struct nbt_dc_sock_addr { - uint32_t family; - const char * pdc_ip;/* [flag(LIBNDR_FLAG_BIGENDIAN)] */ - DATA_BLOB remaining;/* [flag(LIBNDR_FLAG_REMAINING)] */ -}; - -struct nbt_netlogon_response_from_pdc2 { - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */ - uint32_t server_type; - struct GUID domain_uuid; - const char * forest; - const char * dns_domain; - const char * pdc_dns_name; - const char * domain; - const char * pdc_name; - const char * user_name; - const char * server_site; - const char * client_site; - uint8_t dc_sock_addr_size; - struct nbt_dc_sock_addr dc_sock_addr;/* [subcontext_size(dc_sock_addr_size),subcontext(0)] */ - uint32_t nt_version; - uint16_t lmnt_token; - uint16_t lm20_token; -}; - -enum netr_SamDatabaseID; - -struct nbt_db_change { - enum netr_SamDatabaseID db_index; - uint64_t serial; - NTTIME timestamp; -}; +/* bitmap netlogon_nt_version_flags */ +#define NETLOGON_NT_VERSION_1 ( 0x00000001 ) +#define NETLOGON_NT_VERSION_5 ( 0x00000002 ) +#define NETLOGON_NT_VERSION_5EX ( 0x00000004 ) +#define NETLOGON_NT_VERSION_5EX_WITH_IP ( 0x00000008 ) +#define NETLOGON_NT_VERSION_WITH_CLOSEST_SITE ( 0x00000010 ) +#define NETLOGON_NT_VERSION_AVIOD_NT4EMUL ( 0x01000000 ) +#define NETLOGON_NT_VERSION_PDC ( 0x10000000 ) +#define NETLOGON_NT_VERSION_IP ( 0x20000000 ) +#define NETLOGON_NT_VERSION_LOCAL ( 0x40000000 ) +#define NETLOGON_NT_VERSION_GC ( 0x80000000 ) + +enum netlogon_command +#ifndef USE_UINT_ENUMS + { + LOGON_PRIMARY_QUERY=7, + NETLOGON_ANNOUNCE_UAS=10, + NETLOGON_RESPONSE_FROM_PDC=12, + LOGON_SAM_LOGON_REQUEST=18, + LOGON_SAM_LOGON_RESPONSE=19, + LOGON_SAM_LOGON_PAUSE_RESPONSE=20, + LOGON_SAM_LOGON_USER_UNKNOWN=21, + LOGON_SAM_LOGON_RESPONSE_EX=23, + LOGON_SAM_LOGON_PAUSE_RESPONSE_EX=24, + LOGON_SAM_LOGON_USER_UNKNOWN_EX=25 +} +#else + { __donnot_use_enum_netlogon_command=0x7FFFFFFF} +#define LOGON_PRIMARY_QUERY ( 7 ) +#define NETLOGON_ANNOUNCE_UAS ( 10 ) +#define NETLOGON_RESPONSE_FROM_PDC ( 12 ) +#define LOGON_SAM_LOGON_REQUEST ( 18 ) +#define LOGON_SAM_LOGON_RESPONSE ( 19 ) +#define LOGON_SAM_LOGON_PAUSE_RESPONSE ( 20 ) +#define LOGON_SAM_LOGON_USER_UNKNOWN ( 21 ) +#define LOGON_SAM_LOGON_RESPONSE_EX ( 23 ) +#define LOGON_SAM_LOGON_PAUSE_RESPONSE_EX ( 24 ) +#define LOGON_SAM_LOGON_USER_UNKNOWN_EX ( 25 ) +#endif +; -struct nbt_netlogon_announce_uas { - uint32_t serial_lo; - time_t timestamp; - uint32_t pulse; - uint32_t random; - const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - const char * domain;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */ - const char * unicode_pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * unicode_domain;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - uint32_t db_count; - struct nbt_db_change *dbchange; +struct NETLOGON_SAM_LOGON_REQUEST { + uint16_t request_count; + const char * computer_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t acct_control; uint32_t sid_size;/* [value(ndr_size_dom_sid0(&sid,ndr->flags))] */ + DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN4)] */ struct dom_sid0 sid;/* [subcontext_size(sid_size),subcontext(0)] */ uint32_t nt_version; uint16_t lmnt_token; uint16_t lm20_token; -}; +}/* [nopull,nopush] */; -union nbt_netlogon_request { - struct nbt_netlogon_query_for_pdc pdc;/* [case(NETLOGON_QUERY_FOR_PDC)] */ - struct nbt_netlogon_query_for_pdc2 pdc2;/* [case(NETLOGON_QUERY_FOR_PDC2)] */ - struct nbt_netlogon_announce_uas uas;/* [case(NETLOGON_ANNOUNCE_UAS)] */ - struct nbt_netlogon_response_from_pdc response;/* [case(NETLOGON_RESPONSE_FROM_PDC)] */ - struct nbt_netlogon_response_from_pdc2 response2;/* [case(NETLOGON_RESPONSE_FROM_PDC2)] */ -}/* [nodiscriminant] */; - -struct nbt_netlogon_packet { - enum nbt_netlogon_command command; - union nbt_netlogon_request req;/* [switch_is(command)] */ -}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; - -struct nbt_cldap_netlogon_1 { - enum nbt_netlogon_command type; - const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ +struct NETLOGON_SAM_LOGON_RESPONSE_NT40 { + enum netlogon_command command; + const char * server;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - uint32_t nt_version;/* [value] */ + const char * domain;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t nt_version; uint16_t lmnt_token; uint16_t lm20_token; -}; +}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; -struct nbt_cldap_netlogon_3 { - enum nbt_netlogon_command type; +struct NETLOGON_SAM_LOGON_RESPONSE { + enum netlogon_command command; const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ struct GUID domain_uuid; - struct GUID unknown_uuid; + struct GUID zero_uuid; const char * forest; const char * dns_domain; const char * pdc_dns_name; const char * pdc_ip; uint32_t server_type; - uint32_t nt_version;/* [value(3)] */ - uint16_t lmnt_token; - uint16_t lm20_token; -}; - -struct nbt_cldap_netlogon_5 { - enum nbt_netlogon_command type; - uint16_t sbz; - uint32_t server_type; - struct GUID domain_uuid; - const char * forest; - const char * dns_domain; - const char * pdc_dns_name; - const char * domain; - const char * pdc_name; - const char * user_name; - const char * server_site; - const char * client_site; - uint32_t nt_version;/* [value(5)] */ - uint16_t lmnt_token; - uint16_t lm20_token; -}/* [public] */; - -struct nbt_cldap_netlogon_13 { - enum nbt_netlogon_command type; - uint16_t sbz; - uint32_t server_type; - struct GUID domain_uuid; - const char * forest; - const char * dns_domain; - const char * pdc_dns_name; - const char * domain; - const char * pdc_name; - const char * user_name; - const char * server_site; - const char * client_site; - uint8_t dc_sock_addr_size; - struct nbt_dc_sock_addr dc_sock_addr;/* [subcontext_size(dc_sock_addr_size),subcontext(0)] */ - uint32_t nt_version;/* [value(13)] */ - uint16_t lmnt_token; - uint16_t lm20_token; -}; - -struct nbt_cldap_netlogon_15 { - enum nbt_netlogon_command type; - uint16_t sbz; - uint32_t server_type; - struct GUID domain_uuid; - const char * forest; - const char * dns_domain; - const char * pdc_dns_name; - const char * domain; - const char * pdc_name; - const char * user_name; - const char * server_site; - const char * client_site; - const char * next_closest_site; - uint32_t nt_version;/* [value(15)] */ + uint32_t nt_version; uint16_t lmnt_token; uint16_t lm20_token; -}/* [public] */; +}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; -struct nbt_cldap_netlogon_29 { - enum nbt_netlogon_command type; +struct NETLOGON_SAM_LOGON_RESPONSE_EX { + enum netlogon_command command; uint16_t sbz; uint32_t server_type; struct GUID domain_uuid; @@ -630,71 +505,70 @@ struct nbt_cldap_netlogon_29 { const char * user_name; const char * server_site; const char * client_site; - uint8_t dc_sock_addr_size; - struct nbt_dc_sock_addr dc_sock_addr;/* [subcontext_size(dc_sock_addr_size),subcontext(0)] */ + uint8_t sockaddr_size;/* [value(ndr_size_nbt_sockaddr(&sockaddr,ndr->flags))] */ + struct nbt_sockaddr sockaddr;/* [subcontext_size(sockaddr_size),subcontext(0)] */ const char * next_closest_site; - uint32_t nt_version;/* [value(29)] */ + uint32_t nt_version; uint16_t lmnt_token; uint16_t lm20_token; -}/* [public] */; - -union nbt_cldap_netlogon { - struct nbt_cldap_netlogon_1 logon1;/* [case(0)] */ - struct nbt_cldap_netlogon_3 logon3;/* [case(2)] */ - struct nbt_cldap_netlogon_5 logon5;/* [case(4)] */ - struct nbt_cldap_netlogon_13 logon13;/* [case(8)] */ - struct nbt_cldap_netlogon_15 logon15;/* [case(20)] */ - struct nbt_cldap_netlogon_29 logon29;/* [case(29)] */ -}/* [public,nodiscriminant,flag(LIBNDR_FLAG_NOALIGN)] */; - -enum nbt_ntlogon_command -#ifndef USE_UINT_ENUMS - { - NTLOGON_SAM_LOGON=0x12, - NTLOGON_SAM_LOGON_REPLY=0x13, - NTLOGON_SAM_LOGON_REPLY15=0x15, - NTLOGON_RESPONSE_FROM_PDC2=0x17 -} -#else - { __donnot_use_enum_nbt_ntlogon_command=0x7FFFFFFF} -#define NTLOGON_SAM_LOGON ( 0x12 ) -#define NTLOGON_SAM_LOGON_REPLY ( 0x13 ) -#define NTLOGON_SAM_LOGON_REPLY15 ( 0x15 ) -#define NTLOGON_RESPONSE_FROM_PDC2 ( 0x17 ) -#endif -; +}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; -struct nbt_ntlogon_sam_logon { - uint16_t request_count; - const char * computer_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ +struct nbt_netlogon_query_for_pdc { + const char * computer_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ const char * mailslot_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ - uint32_t acct_control; - uint32_t sid_size;/* [value(ndr_size_dom_sid0(&sid,ndr->flags))] */ - struct dom_sid0 sid;/* [subcontext_size(sid_size),subcontext(0)] */ + DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */ + const char * unicode_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ uint32_t nt_version; uint16_t lmnt_token; uint16_t lm20_token; }; -struct nbt_ntlogon_sam_logon_reply { - const char * server;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * user_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ - const char * domain;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ +struct nbt_netlogon_response_from_pdc { + enum netlogon_command command; + const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ + DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */ + const char * unicode_pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + const char * domain_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ uint32_t nt_version; uint16_t lmnt_token; uint16_t lm20_token; +}/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; + +enum netr_SamDatabaseID; + +struct nbt_db_change_info { + enum netr_SamDatabaseID db_index; + uint64_t serial; + NTTIME timestamp; +}; + +struct NETLOGON_DB_CHANGE { + uint32_t serial_lo; + time_t timestamp; + uint32_t pulse; + uint32_t random; + const char * pdc_name;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ + const char * domain;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ + DATA_BLOB _pad;/* [flag(LIBNDR_FLAG_ALIGN2)] */ + const char * unicode_pdc_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + const char * unicode_domain;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t db_count; + struct nbt_db_change_info *dbchange; + uint32_t sid_size;/* [value(ndr_size_dom_sid0(&sid,ndr->flags))] */ + struct dom_sid0 sid;/* [subcontext_size(sid_size),subcontext(0)] */ + uint32_t message_format_version; + uint32_t message_token; }; -union nbt_ntlogon_request { - struct nbt_ntlogon_sam_logon logon;/* [case(NTLOGON_SAM_LOGON)] */ - struct nbt_ntlogon_sam_logon_reply reply;/* [case(NTLOGON_SAM_LOGON_REPLY)] */ - struct nbt_netlogon_response_from_pdc2 reply2;/* [case(NTLOGON_RESPONSE_FROM_PDC2)] */ +union nbt_netlogon_request { + struct NETLOGON_SAM_LOGON_REQUEST logon;/* [case(LOGON_SAM_LOGON_REQUEST)] */ + struct nbt_netlogon_query_for_pdc pdc;/* [case(LOGON_PRIMARY_QUERY)] */ + struct NETLOGON_DB_CHANGE uas;/* [case(NETLOGON_ANNOUNCE_UAS)] */ }/* [nodiscriminant] */; -struct nbt_ntlogon_packet { - enum nbt_ntlogon_command command; - union nbt_ntlogon_request req;/* [switch_is(command)] */ +struct nbt_netlogon_packet { + enum netlogon_command command; + union nbt_netlogon_request req;/* [switch_is(command)] */ }/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; enum nbt_browse_opcode diff --git a/source3/librpc/gen_ndr/ndr_dfs.c b/source3/librpc/gen_ndr/ndr_dfs.c index de3ac48c00..75a0d4b755 100644 --- a/source3/librpc/gen_ndr/ndr_dfs.c +++ b/source3/librpc/gen_ndr/ndr_dfs.c @@ -3,6 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_dfs.h" +#include "librpc/gen_ndr/ndr_misc.h" static enum ndr_err_code ndr_push_dfs_ManagerVersion(struct ndr_push *ndr, int ndr_flags, enum dfs_ManagerVersion r) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); @@ -544,7 +545,6 @@ static enum ndr_err_code ndr_push_dfs_Info4(struct ndr_push *ndr, int ndr_flags, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->comment, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->comment, ndr_charset_length(r->comment, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->guid)); if (r->stores) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_stores)); for (cntr_stores_1 = 0; cntr_stores_1 < r->num_stores; cntr_stores_1++) { @@ -618,7 +618,6 @@ static enum ndr_err_code ndr_pull_dfs_Info4(struct ndr_pull *ndr, int ndr_flags, NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->comment, ndr_get_array_length(ndr, &r->comment), sizeof(uint16_t), CH_UTF16)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_comment_0, 0); } - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->guid)); if (r->stores) { _mem_save_stores_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->stores, 0); @@ -733,7 +732,6 @@ static enum ndr_err_code ndr_push_dfs_Info5(struct ndr_push *ndr, int ndr_flags, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->comment, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->comment, ndr_charset_length(r->comment, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->guid)); } return NDR_ERR_SUCCESS; } @@ -790,7 +788,6 @@ static enum ndr_err_code ndr_pull_dfs_Info5(struct ndr_pull *ndr, int ndr_flags, NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->comment, ndr_get_array_length(ndr, &r->comment), sizeof(uint16_t), CH_UTF16)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_comment_0, 0); } - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->guid)); } return NDR_ERR_SUCCESS; } @@ -948,7 +945,6 @@ static enum ndr_err_code ndr_push_dfs_Info6(struct ndr_push *ndr, int ndr_flags, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->comment, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->comment, ndr_charset_length(r->comment, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->guid)); if (r->stores) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_stores)); for (cntr_stores_1 = 0; cntr_stores_1 < r->num_stores; cntr_stores_1++) { @@ -1024,7 +1020,6 @@ static enum ndr_err_code ndr_pull_dfs_Info6(struct ndr_pull *ndr, int ndr_flags, NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->comment, ndr_get_array_length(ndr, &r->comment), sizeof(uint16_t), CH_UTF16)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_comment_0, 0); } - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->guid)); if (r->stores) { _mem_save_stores_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->stores, 0); @@ -1096,7 +1091,6 @@ static enum ndr_err_code ndr_push_dfs_Info7(struct ndr_push *ndr, int ndr_flags, NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->generation_guid)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->generation_guid)); } return NDR_ERR_SUCCESS; } @@ -1108,7 +1102,6 @@ static enum ndr_err_code ndr_pull_dfs_Info7(struct ndr_pull *ndr, int ndr_flags, NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->generation_guid)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->generation_guid)); } return NDR_ERR_SUCCESS; } @@ -1671,7 +1664,7 @@ static enum ndr_err_code ndr_push_dfs_Info(struct ndr_push *ndr, int ndr_flags, case 7: if (r->info7) { - NDR_CHECK(ndr_push_dfs_Info7(ndr, NDR_SCALARS|NDR_BUFFERS, r->info7)); + NDR_CHECK(ndr_push_dfs_Info7(ndr, NDR_SCALARS, r->info7)); } break; @@ -1973,7 +1966,7 @@ static enum ndr_err_code ndr_pull_dfs_Info(struct ndr_pull *ndr, int ndr_flags, if (r->info7) { _mem_save_info7_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->info7, 0); - NDR_CHECK(ndr_pull_dfs_Info7(ndr, NDR_SCALARS|NDR_BUFFERS, r->info7)); + NDR_CHECK(ndr_pull_dfs_Info7(ndr, NDR_SCALARS, r->info7)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info7_0, 0); } break; diff --git a/source3/librpc/gen_ndr/ndr_drsblobs.c b/source3/librpc/gen_ndr/ndr_drsblobs.c index 41a448cbe3..dd8d77ea15 100644 --- a/source3/librpc/gen_ndr/ndr_drsblobs.c +++ b/source3/librpc/gen_ndr/ndr_drsblobs.c @@ -5,6 +5,8 @@ #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/gen_ndr/ndr_samr.h" +#include "librpc/gen_ndr/ndr_lsa.h" static enum ndr_err_code ndr_push_replPropertyMetaData1(struct ndr_push *ndr, int ndr_flags, const struct replPropertyMetaData1 *r) { if (ndr_flags & NDR_SCALARS) { @@ -2165,10 +2167,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_package_PrimaryCLEARTEXTBlob(struct ndr_push if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->cleartext)); - ndr->flags = _flags_save_string; + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->cleartext)); + ndr->flags = _flags_save_DATA_BLOB; } } if (ndr_flags & NDR_BUFFERS) { @@ -2181,10 +2183,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_package_PrimaryCLEARTEXTBlob(struct ndr_pull if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->cleartext)); - ndr->flags = _flags_save_string; + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->cleartext)); + ndr->flags = _flags_save_DATA_BLOB; } } if (ndr_flags & NDR_BUFFERS) { @@ -2196,7 +2198,7 @@ _PUBLIC_ void ndr_print_package_PrimaryCLEARTEXTBlob(struct ndr_print *ndr, cons { ndr_print_struct(ndr, name, "package_PrimaryCLEARTEXTBlob"); ndr->depth++; - ndr_print_string(ndr, "cleartext", r->cleartext); + ndr_print_DATA_BLOB(ndr, "cleartext", r->cleartext); ndr->depth--; } @@ -2311,13 +2313,269 @@ _PUBLIC_ void ndr_print_package_PrimaryWDigestBlob(struct ndr_print *ndr, const ndr->depth--; } -static enum ndr_err_code ndr_push_trustAuthInOutSecret1(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutSecret1 *r) +static enum ndr_err_code ndr_push_AuthInfoNone(struct ndr_push *ndr, int ndr_flags, const struct AuthInfoNone *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_AuthInfoNone(struct ndr_pull *ndr, int ndr_flags, struct AuthInfoNone *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_AuthInfoNone(struct ndr_print *ndr, const char *name, const struct AuthInfoNone *r) +{ + ndr_print_struct(ndr, name, "AuthInfoNone"); + ndr->depth++; + ndr_print_uint32(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0:r->size); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_AuthInfoNT4Owf(struct ndr_push *ndr, int ndr_flags, const struct AuthInfoNT4Owf *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 16)); + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS, &r->password)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_BUFFERS, &r->password)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_AuthInfoNT4Owf(struct ndr_pull *ndr, int ndr_flags, struct AuthInfoNT4Owf *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS, &r->password)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_BUFFERS, &r->password)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_AuthInfoNT4Owf(struct ndr_print *ndr, const char *name, const struct AuthInfoNT4Owf *r) +{ + ndr_print_struct(ndr, name, "AuthInfoNT4Owf"); + ndr->depth++; + ndr_print_uint32(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?16:r->size); + ndr_print_samr_Password(ndr, "password", &r->password); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_AuthInfoClear(struct ndr_push *ndr, int ndr_flags, const struct AuthInfoClear *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->password, r->size)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_AuthInfoClear(struct ndr_pull *ndr, int ndr_flags, struct AuthInfoClear *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_PULL_ALLOC_N(ndr, r->password, r->size); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->password, r->size)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_AuthInfoClear(struct ndr_print *ndr, const char *name, const struct AuthInfoClear *r) +{ + ndr_print_struct(ndr, name, "AuthInfoClear"); + ndr->depth++; + ndr_print_uint32(ndr, "size", r->size); + ndr_print_array_uint8(ndr, "password", r->password, r->size); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_AuthInfoVersion(struct ndr_push *ndr, int ndr_flags, const struct AuthInfoVersion *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_AuthInfoVersion(struct ndr_pull *ndr, int ndr_flags, struct AuthInfoVersion *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_AuthInfoVersion(struct ndr_print *ndr, const char *name, const struct AuthInfoVersion *r) +{ + ndr_print_struct(ndr, name, "AuthInfoVersion"); + ndr->depth++; + ndr_print_uint32(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?4:r->size); + ndr_print_uint32(ndr, "version", r->version); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_AuthInfo(struct ndr_push *ndr, int ndr_flags, const union AuthInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case TRUST_AUTH_TYPE_NONE: { + NDR_CHECK(ndr_push_AuthInfoNone(ndr, NDR_SCALARS, &r->none)); + break; } + + case TRUST_AUTH_TYPE_NT4OWF: { + NDR_CHECK(ndr_push_AuthInfoNT4Owf(ndr, NDR_SCALARS, &r->nt4owf)); + break; } + + case TRUST_AUTH_TYPE_CLEAR: { + NDR_CHECK(ndr_push_AuthInfoClear(ndr, NDR_SCALARS, &r->clear)); + break; } + + case TRUST_AUTH_TYPE_VERSION: { + NDR_CHECK(ndr_push_AuthInfoVersion(ndr, NDR_SCALARS, &r->version)); + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case TRUST_AUTH_TYPE_NONE: + break; + + case TRUST_AUTH_TYPE_NT4OWF: + NDR_CHECK(ndr_push_AuthInfoNT4Owf(ndr, NDR_BUFFERS, &r->nt4owf)); + break; + + case TRUST_AUTH_TYPE_CLEAR: + break; + + case TRUST_AUTH_TYPE_VERSION: + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_AuthInfo(struct ndr_pull *ndr, int ndr_flags, union AuthInfo *r) +{ + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case TRUST_AUTH_TYPE_NONE: { + NDR_CHECK(ndr_pull_AuthInfoNone(ndr, NDR_SCALARS, &r->none)); + break; } + + case TRUST_AUTH_TYPE_NT4OWF: { + NDR_CHECK(ndr_pull_AuthInfoNT4Owf(ndr, NDR_SCALARS, &r->nt4owf)); + break; } + + case TRUST_AUTH_TYPE_CLEAR: { + NDR_CHECK(ndr_pull_AuthInfoClear(ndr, NDR_SCALARS, &r->clear)); + break; } + + case TRUST_AUTH_TYPE_VERSION: { + NDR_CHECK(ndr_pull_AuthInfoVersion(ndr, NDR_SCALARS, &r->version)); + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case TRUST_AUTH_TYPE_NONE: + break; + + case TRUST_AUTH_TYPE_NT4OWF: + NDR_CHECK(ndr_pull_AuthInfoNT4Owf(ndr, NDR_BUFFERS, &r->nt4owf)); + break; + + case TRUST_AUTH_TYPE_CLEAR: + break; + + case TRUST_AUTH_TYPE_VERSION: + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_AuthInfo(struct ndr_print *ndr, const char *name, const union AuthInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "AuthInfo"); + switch (level) { + case TRUST_AUTH_TYPE_NONE: + ndr_print_AuthInfoNone(ndr, "none", &r->none); + break; + + case TRUST_AUTH_TYPE_NT4OWF: + ndr_print_AuthInfoNT4Owf(ndr, "nt4owf", &r->nt4owf); + break; + + case TRUST_AUTH_TYPE_CLEAR: + ndr_print_AuthInfoClear(ndr, "clear", &r->clear); + break; + + case TRUST_AUTH_TYPE_VERSION: + ndr_print_AuthInfoVersion(ndr, "version", &r->version); + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + +_PUBLIC_ enum ndr_err_code ndr_push_AuthenticationInformation(struct ndr_push *ndr, int ndr_flags, const struct AuthenticationInformation *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time1)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown1)); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->value)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->LastUpdateTime)); + NDR_CHECK(ndr_push_lsa_TrustAuthType(ndr, NDR_SCALARS, r->AuthType)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->AuthInfo, r->AuthType)); + NDR_CHECK(ndr_push_AuthInfo(ndr, NDR_SCALARS, &r->AuthInfo)); { uint32_t _flags_save_DATA_BLOB = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); @@ -2326,17 +2584,19 @@ static enum ndr_err_code ndr_push_trustAuthInOutSecret1(struct ndr_push *ndr, in } } if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_AuthInfo(ndr, NDR_BUFFERS, &r->AuthInfo)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_trustAuthInOutSecret1(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutSecret1 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_AuthenticationInformation(struct ndr_pull *ndr, int ndr_flags, struct AuthenticationInformation *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->value)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->LastUpdateTime)); + NDR_CHECK(ndr_pull_lsa_TrustAuthType(ndr, NDR_SCALARS, &r->AuthType)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->AuthInfo, r->AuthType)); + NDR_CHECK(ndr_pull_AuthInfo(ndr, NDR_SCALARS, &r->AuthInfo)); { uint32_t _flags_save_DATA_BLOB = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); @@ -2345,325 +2605,583 @@ static enum ndr_err_code ndr_pull_trustAuthInOutSecret1(struct ndr_pull *ndr, in } } if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_AuthInfo(ndr, NDR_BUFFERS, &r->AuthInfo)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutSecret1(struct ndr_print *ndr, const char *name, const struct trustAuthInOutSecret1 *r) +_PUBLIC_ void ndr_print_AuthenticationInformation(struct ndr_print *ndr, const char *name, const struct AuthenticationInformation *r) { - ndr_print_struct(ndr, name, "trustAuthInOutSecret1"); + ndr_print_struct(ndr, name, "AuthenticationInformation"); ndr->depth++; - ndr_print_NTTIME(ndr, "time1", r->time1); - ndr_print_uint32(ndr, "unknown1", r->unknown1); - ndr_print_DATA_BLOB(ndr, "value", r->value); + ndr_print_NTTIME(ndr, "LastUpdateTime", r->LastUpdateTime); + ndr_print_lsa_TrustAuthType(ndr, "AuthType", r->AuthType); + ndr_print_set_switch_value(ndr, &r->AuthInfo, r->AuthType); + ndr_print_AuthInfo(ndr, "AuthInfo", &r->AuthInfo); ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); ndr->depth--; } -static enum ndr_err_code ndr_push_trustAuthInOutCtr1(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutCtr1 *r) +_PUBLIC_ size_t ndr_size_trustAuthInOutBlob(const struct trustAuthInOutBlob *r, int flags) { + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_trustAuthInOutBlob); +} + +_PUBLIC_ enum ndr_err_code ndr_push_trustCurrentPasswords(struct ndr_push *ndr, int ndr_flags, const struct trustCurrentPasswords *r) +{ + uint32_t cntr_current_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->value1)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->value2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + for (cntr_current_0 = 0; cntr_current_0 < r->count; cntr_current_0++) { + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->current[cntr_current_0])); + } } if (ndr_flags & NDR_BUFFERS) { - if (r->value1) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->value1)); - NDR_CHECK(ndr_push_trustAuthInOutSecret1(ndr, NDR_SCALARS, r->value1)); + for (cntr_current_0 = 0; cntr_current_0 < r->count; cntr_current_0++) { + if (r->current[cntr_current_0]) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->current[cntr_current_0])); + NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS|NDR_BUFFERS, r->current[cntr_current_0])); + } } - if (r->value2) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->value2)); - NDR_CHECK(ndr_push_trustAuthInOutSecret1(ndr, NDR_SCALARS, r->value2)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_trustCurrentPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustCurrentPasswords *r) +{ + uint32_t _ptr_current; + uint32_t cntr_current_0; + TALLOC_CTX *_mem_save_current_0; + TALLOC_CTX *_mem_save_current_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count)); + NDR_PULL_ALLOC_N(ndr, r->current, r->count); + _mem_save_current_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->current, 0); + for (cntr_current_0 = 0; cntr_current_0 < r->count; cntr_current_0++) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_current)); + if (_ptr_current) { + NDR_PULL_ALLOC(ndr, r->current[cntr_current_0]); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->current[cntr_current_0], _ptr_current)); + } else { + r->current[cntr_current_0] = NULL; + } + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_0, 0); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_current_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->current, 0); + for (cntr_current_0 = 0; cntr_current_0 < r->count; cntr_current_0++) { + if (r->current[cntr_current_0]) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->current[cntr_current_0])); + _mem_save_current_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->current[cntr_current_0], 0); + NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS|NDR_BUFFERS, r->current[cntr_current_0])); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_1, 0); + ndr->offset = _relative_save_offset; + } } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_0, 0); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_trustAuthInOutCtr1(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutCtr1 *r) +_PUBLIC_ void ndr_print_trustCurrentPasswords(struct ndr_print *ndr, const char *name, const struct trustCurrentPasswords *r) +{ + uint32_t cntr_current_0; + ndr_print_struct(ndr, name, "trustCurrentPasswords"); + ndr->depth++; + ndr_print_uint32(ndr, "count", r->count); + ndr->print(ndr, "%s: ARRAY(%d)", "current", (int)r->count); + ndr->depth++; + for (cntr_current_0=0;cntr_current_0count;cntr_current_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_current_0) != -1) { + ndr_print_ptr(ndr, "current", r->current[cntr_current_0]); + ndr->depth++; + if (r->current[cntr_current_0]) { + ndr_print_AuthenticationInformation(ndr, "current", r->current[cntr_current_0]); + } + ndr->depth--; + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_trustCurrentPasswords(const struct trustCurrentPasswords *r, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_trustCurrentPasswords); +} + +_PUBLIC_ enum ndr_err_code ndr_push_trustDomainPasswords(struct ndr_push *ndr, int ndr_flags, const struct trustDomainPasswords *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->confounder, 512)); + { + struct ndr_push *_ndr_outgoing; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_outgoing, 0, ndr_size_trustCurrentPasswords(&r->outgoing, ndr->flags))); + NDR_CHECK(ndr_push_trustCurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_outgoing, 0, ndr_size_trustCurrentPasswords(&r->outgoing, ndr->flags))); + } + { + struct ndr_push *_ndr_incoming; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_incoming, 0, ndr_size_trustCurrentPasswords(&r->incoming, ndr->flags))); + NDR_CHECK(ndr_push_trustCurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_incoming, 0, ndr_size_trustCurrentPasswords(&r->incoming, ndr->flags))); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_trustCurrentPasswords(&r->outgoing, ndr->flags))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_trustCurrentPasswords(&r->incoming, ndr->flags))); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_trustDomainPasswords(struct ndr_print *ndr, const char *name, const struct trustDomainPasswords *r) +{ + ndr_print_struct(ndr, name, "trustDomainPasswords"); + ndr->depth++; + ndr_print_array_uint8(ndr, "confounder", r->confounder, 512); + ndr_print_trustCurrentPasswords(ndr, "outgoing", &r->outgoing); + ndr_print_trustCurrentPasswords(ndr, "incoming", &r->incoming); + ndr_print_uint32(ndr, "outgoing_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_trustCurrentPasswords(&r->outgoing, ndr->flags):r->outgoing_size); + ndr_print_uint32(ndr, "incoming_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_trustCurrentPasswords(&r->incoming, ndr->flags):r->incoming_size); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_DsCompressedChunk(struct ndr_push *ndr, int ndr_flags, const struct DsCompressedChunk *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->marker)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_DsCompressedChunk(struct ndr_pull *ndr, int ndr_flags, struct DsCompressedChunk *r) { - uint32_t _ptr_value1; - TALLOC_CTX *_mem_save_value1_0; - uint32_t _ptr_value2; - TALLOC_CTX *_mem_save_value2_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value1)); - if (_ptr_value1) { - NDR_PULL_ALLOC(ndr, r->value1); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->value1, _ptr_value1)); - } else { - r->value1 = NULL; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->marker)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_DsCompressedChunk(struct ndr_print *ndr, const char *name, const struct DsCompressedChunk *r) +{ + ndr_print_struct(ndr, name, "DsCompressedChunk"); + ndr->depth++; + ndr_print_uint32(ndr, "marker", r->marker); + ndr_print_DATA_BLOB(ndr, "data", r->data); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_ExtendedErrorAString(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorAString *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->__size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->__size)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, r->__size, sizeof(uint8_t), CH_DOS)); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value2)); - if (_ptr_value2) { - NDR_PULL_ALLOC(ndr, r->value2); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->value2, _ptr_value2)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_ExtendedErrorAString(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorAString *r) +{ + uint32_t _ptr_string; + TALLOC_CTX *_mem_save_string_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->__size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); + if (_ptr_string) { + NDR_PULL_ALLOC(ndr, r->string); } else { - r->value2 = NULL; + r->string = NULL; } } if (ndr_flags & NDR_BUFFERS) { - if (r->value1) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->value1)); - _mem_save_value1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->value1, 0); - NDR_CHECK(ndr_pull_trustAuthInOutSecret1(ndr, NDR_SCALARS, r->value1)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value1_0, 0); - ndr->offset = _relative_save_offset; + if (r->string) { + _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->string)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->string, ndr_get_array_size(ndr, &r->string), sizeof(uint8_t), CH_DOS)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); } - if (r->value2) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->value2)); - _mem_save_value2_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->value2, 0); - NDR_CHECK(ndr_pull_trustAuthInOutSecret1(ndr, NDR_SCALARS, r->value2)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value2_0, 0); - ndr->offset = _relative_save_offset; + if (r->string) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->string, r->__size)); } } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutCtr1(struct ndr_print *ndr, const char *name, const struct trustAuthInOutCtr1 *r) +_PUBLIC_ void ndr_print_ExtendedErrorAString(struct ndr_print *ndr, const char *name, const struct ExtendedErrorAString *r) { - ndr_print_struct(ndr, name, "trustAuthInOutCtr1"); + ndr_print_struct(ndr, name, "ExtendedErrorAString"); ndr->depth++; - ndr_print_ptr(ndr, "value1", r->value1); + ndr_print_uint16(ndr, "__size", r->__size); + ndr_print_ptr(ndr, "string", r->string); ndr->depth++; - if (r->value1) { - ndr_print_trustAuthInOutSecret1(ndr, "value1", r->value1); + if (r->string) { + ndr_print_string(ndr, "string", r->string); } ndr->depth--; - ndr_print_ptr(ndr, "value2", r->value2); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_ExtendedErrorUString(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorUString *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->__size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->__size)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, r->__size, sizeof(uint16_t), CH_UTF16)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_ExtendedErrorUString(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorUString *r) +{ + uint32_t _ptr_string; + TALLOC_CTX *_mem_save_string_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->__size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); + if (_ptr_string) { + NDR_PULL_ALLOC(ndr, r->string); + } else { + r->string = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->string)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->string, ndr_get_array_size(ndr, &r->string), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); + } + if (r->string) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->string, r->__size)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_ExtendedErrorUString(struct ndr_print *ndr, const char *name, const struct ExtendedErrorUString *r) +{ + ndr_print_struct(ndr, name, "ExtendedErrorUString"); + ndr->depth++; + ndr_print_uint16(ndr, "__size", r->__size); + ndr_print_ptr(ndr, "string", r->string); ndr->depth++; - if (r->value2) { - ndr_print_trustAuthInOutSecret1(ndr, "value2", r->value2); + if (r->string) { + ndr_print_string(ndr, "string", r->string); } ndr->depth--; ndr->depth--; } -static enum ndr_err_code ndr_push_trustAuthInOutSecret2V1(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutSecret2V1 *r) +static enum ndr_err_code ndr_push_ExtendedErrorBlob(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorBlob *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time1)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown1)); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->value)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time2)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown3)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown4)); - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->data) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->data, r->length)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_ExtendedErrorBlob(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorBlob *r) +{ + uint32_t _ptr_data; + TALLOC_CTX *_mem_save_data_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->data); + } else { + r->data = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->data) { + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->data)); + NDR_PULL_ALLOC_N(ndr, r->data, ndr_get_array_size(ndr, &r->data)); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->data, ndr_get_array_size(ndr, &r->data))); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); + } + if (r->data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->data, r->length)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_ExtendedErrorBlob(struct ndr_print *ndr, const char *name, const struct ExtendedErrorBlob *r) +{ + ndr_print_struct(ndr, name, "ExtendedErrorBlob"); + ndr->depth++; + ndr_print_uint16(ndr, "length", r->length); + ndr_print_ptr(ndr, "data", r->data); + ndr->depth++; + if (r->data) { + ndr_print_array_uint8(ndr, "data", r->data, r->length); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_ExtendedErrorComputerNamePresent(struct ndr_push *ndr, int ndr_flags, enum ExtendedErrorComputerNamePresent r) +{ + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_ExtendedErrorComputerNamePresent(struct ndr_pull *ndr, int ndr_flags, enum ExtendedErrorComputerNamePresent *r) +{ + uint16_t v; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_ExtendedErrorComputerNamePresent(struct ndr_print *ndr, const char *name, enum ExtendedErrorComputerNamePresent r) +{ + const char *val = NULL; + + switch (r) { + case EXTENDED_ERROR_COMPUTER_NAME_PRESENT: val = "EXTENDED_ERROR_COMPUTER_NAME_PRESENT"; break; + case EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT: val = "EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_ExtendedErrorComputerNameU(struct ndr_push *ndr, int ndr_flags, const union ExtendedErrorComputerNameU *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_ExtendedErrorComputerNamePresent(ndr, NDR_SCALARS, level)); + switch (level) { + case EXTENDED_ERROR_COMPUTER_NAME_PRESENT: { + NDR_CHECK(ndr_push_ExtendedErrorUString(ndr, NDR_SCALARS, &r->name)); + break; } + + case EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT: { + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } } if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case EXTENDED_ERROR_COMPUTER_NAME_PRESENT: + NDR_CHECK(ndr_push_ExtendedErrorUString(ndr, NDR_BUFFERS, &r->name)); + break; + + case EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT: + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_trustAuthInOutSecret2V1(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutSecret2V1 *r) +static enum ndr_err_code ndr_pull_ExtendedErrorComputerNameU(struct ndr_pull *ndr, int ndr_flags, union ExtendedErrorComputerNameU *r) { + int level; + uint16_t _level; + level = ndr_pull_get_switch_value(ndr, r); if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->value)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time2)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown4)); - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case EXTENDED_ERROR_COMPUTER_NAME_PRESENT: { + NDR_CHECK(ndr_pull_ExtendedErrorUString(ndr, NDR_SCALARS, &r->name)); + break; } + + case EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT: { + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } } if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case EXTENDED_ERROR_COMPUTER_NAME_PRESENT: + NDR_CHECK(ndr_pull_ExtendedErrorUString(ndr, NDR_BUFFERS, &r->name)); + break; + + case EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT: + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutSecret2V1(struct ndr_print *ndr, const char *name, const struct trustAuthInOutSecret2V1 *r) +_PUBLIC_ void ndr_print_ExtendedErrorComputerNameU(struct ndr_print *ndr, const char *name, const union ExtendedErrorComputerNameU *r) { - ndr_print_struct(ndr, name, "trustAuthInOutSecret2V1"); - ndr->depth++; - ndr_print_NTTIME(ndr, "time1", r->time1); - ndr_print_uint32(ndr, "unknown1", r->unknown1); - ndr_print_DATA_BLOB(ndr, "value", r->value); - ndr_print_NTTIME(ndr, "time2", r->time2); - ndr_print_uint32(ndr, "unknown2", r->unknown2); - ndr_print_uint32(ndr, "unknown3", r->unknown3); - ndr_print_uint32(ndr, "unknown4", r->unknown4); - ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); - ndr->depth--; + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "ExtendedErrorComputerNameU"); + switch (level) { + case EXTENDED_ERROR_COMPUTER_NAME_PRESENT: + ndr_print_ExtendedErrorUString(ndr, "name", &r->name); + break; + + case EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT: + break; + + default: + ndr_print_bad_level(ndr, name, level); + } } -static enum ndr_err_code ndr_push_trustAuthInOutSecret2V2(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutSecret2V2 *r) +static enum ndr_err_code ndr_push_ExtendedErrorComputerName(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorComputerName *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time1)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown1)); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->value)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time2)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown3)); - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } + NDR_CHECK(ndr_push_ExtendedErrorComputerNamePresent(ndr, NDR_SCALARS, r->present)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->n, r->present)); + NDR_CHECK(ndr_push_ExtendedErrorComputerNameU(ndr, NDR_SCALARS, &r->n)); } if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_ExtendedErrorComputerNameU(ndr, NDR_BUFFERS, &r->n)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_trustAuthInOutSecret2V2(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutSecret2V2 *r) +static enum ndr_err_code ndr_pull_ExtendedErrorComputerName(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorComputerName *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->value)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time2)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3)); - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } + NDR_CHECK(ndr_pull_ExtendedErrorComputerNamePresent(ndr, NDR_SCALARS, &r->present)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->n, r->present)); + NDR_CHECK(ndr_pull_ExtendedErrorComputerNameU(ndr, NDR_SCALARS, &r->n)); } if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_ExtendedErrorComputerNameU(ndr, NDR_BUFFERS, &r->n)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutSecret2V2(struct ndr_print *ndr, const char *name, const struct trustAuthInOutSecret2V2 *r) +_PUBLIC_ void ndr_print_ExtendedErrorComputerName(struct ndr_print *ndr, const char *name, const struct ExtendedErrorComputerName *r) { - ndr_print_struct(ndr, name, "trustAuthInOutSecret2V2"); + ndr_print_struct(ndr, name, "ExtendedErrorComputerName"); ndr->depth++; - ndr_print_NTTIME(ndr, "time1", r->time1); - ndr_print_uint32(ndr, "unknown1", r->unknown1); - ndr_print_DATA_BLOB(ndr, "value", r->value); - ndr_print_NTTIME(ndr, "time2", r->time2); - ndr_print_uint32(ndr, "unknown2", r->unknown2); - ndr_print_uint32(ndr, "unknown3", r->unknown3); - ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); + ndr_print_ExtendedErrorComputerNamePresent(ndr, "present", r->present); + ndr_print_set_switch_value(ndr, &r->n, r->present); + ndr_print_ExtendedErrorComputerNameU(ndr, "n", &r->n); ndr->depth--; } -static enum ndr_err_code ndr_push_trustAuthInOutCtr2(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutCtr2 *r) +static enum ndr_err_code ndr_push_ExtendedErrorParamType(struct ndr_push *ndr, int ndr_flags, enum ExtendedErrorParamType r) { - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->value1)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->value2)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->value1) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->value1)); - NDR_CHECK(ndr_push_trustAuthInOutSecret2V1(ndr, NDR_SCALARS, r->value1)); - } - if (r->value2) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->value2)); - NDR_CHECK(ndr_push_trustAuthInOutSecret2V2(ndr, NDR_SCALARS, r->value2)); - } - } + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_trustAuthInOutCtr2(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutCtr2 *r) +static enum ndr_err_code ndr_pull_ExtendedErrorParamType(struct ndr_pull *ndr, int ndr_flags, enum ExtendedErrorParamType *r) { - uint32_t _ptr_value1; - TALLOC_CTX *_mem_save_value1_0; - uint32_t _ptr_value2; - TALLOC_CTX *_mem_save_value2_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value1)); - if (_ptr_value1) { - NDR_PULL_ALLOC(ndr, r->value1); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->value1, _ptr_value1)); - } else { - r->value1 = NULL; - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value2)); - if (_ptr_value2) { - NDR_PULL_ALLOC(ndr, r->value2); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->value2, _ptr_value2)); - } else { - r->value2 = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->value1) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->value1)); - _mem_save_value1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->value1, 0); - NDR_CHECK(ndr_pull_trustAuthInOutSecret2V1(ndr, NDR_SCALARS, r->value1)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value1_0, 0); - ndr->offset = _relative_save_offset; - } - if (r->value2) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->value2)); - _mem_save_value2_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->value2, 0); - NDR_CHECK(ndr_pull_trustAuthInOutSecret2V2(ndr, NDR_SCALARS, r->value2)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value2_0, 0); - ndr->offset = _relative_save_offset; - } - } + uint16_t v; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); + *r = v; return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutCtr2(struct ndr_print *ndr, const char *name, const struct trustAuthInOutCtr2 *r) +_PUBLIC_ void ndr_print_ExtendedErrorParamType(struct ndr_print *ndr, const char *name, enum ExtendedErrorParamType r) { - ndr_print_struct(ndr, name, "trustAuthInOutCtr2"); - ndr->depth++; - ndr_print_ptr(ndr, "value1", r->value1); - ndr->depth++; - if (r->value1) { - ndr_print_trustAuthInOutSecret2V1(ndr, "value1", r->value1); - } - ndr->depth--; - ndr_print_ptr(ndr, "value2", r->value2); - ndr->depth++; - if (r->value2) { - ndr_print_trustAuthInOutSecret2V2(ndr, "value2", r->value2); + const char *val = NULL; + + switch (r) { + case EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING: val = "EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING"; break; + case EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING: val = "EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING"; break; + case EXTENDED_ERROR_PARAM_TYPE_UINT32: val = "EXTENDED_ERROR_PARAM_TYPE_UINT32"; break; + case EXTENDED_ERROR_PARAM_TYPE_UINT16: val = "EXTENDED_ERROR_PARAM_TYPE_UINT16"; break; + case EXTENDED_ERROR_PARAM_TYPE_UINT64: val = "EXTENDED_ERROR_PARAM_TYPE_UINT64"; break; + case EXTENDED_ERROR_PARAM_TYPE_NONE: val = "EXTENDED_ERROR_PARAM_TYPE_NONE"; break; + case EXTENDED_ERROR_PARAM_TYPE_BLOB: val = "EXTENDED_ERROR_PARAM_TYPE_BLOB"; break; } - ndr->depth--; - ndr->depth--; + ndr_print_enum(ndr, name, "ENUM", val, r); } -static enum ndr_err_code ndr_push_trustAuthInOutCtr(struct ndr_push *ndr, int ndr_flags, const union trustAuthInOutCtr *r) +static enum ndr_err_code ndr_push_ExtendedErrorParamU(struct ndr_push *ndr, int ndr_flags, const union ExtendedErrorParamU *r) { if (ndr_flags & NDR_SCALARS) { int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_ExtendedErrorParamType(ndr, NDR_SCALARS, level)); switch (level) { - case 1: { - NDR_CHECK(ndr_push_trustAuthInOutCtr1(ndr, NDR_SCALARS, &r->ctr1)); + case EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING: { + NDR_CHECK(ndr_push_ExtendedErrorAString(ndr, NDR_SCALARS, &r->a_string)); break; } - case 2: { - NDR_CHECK(ndr_push_trustAuthInOutCtr2(ndr, NDR_SCALARS, &r->ctr2)); + case EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING: { + NDR_CHECK(ndr_push_ExtendedErrorUString(ndr, NDR_SCALARS, &r->u_string)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_UINT32: { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->uint32)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_UINT16: { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->uint16)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_UINT64: { + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->uint64)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_NONE: { + break; } + + case EXTENDED_ERROR_PARAM_TYPE_BLOB: { + NDR_CHECK(ndr_push_ExtendedErrorBlob(ndr, NDR_SCALARS, &r->blob)); break; } default: @@ -2673,12 +3191,28 @@ static enum ndr_err_code ndr_push_trustAuthInOutCtr(struct ndr_push *ndr, int nd if (ndr_flags & NDR_BUFFERS) { int level = ndr_push_get_switch_value(ndr, r); switch (level) { - case 1: - NDR_CHECK(ndr_push_trustAuthInOutCtr1(ndr, NDR_BUFFERS, &r->ctr1)); + case EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING: + NDR_CHECK(ndr_push_ExtendedErrorAString(ndr, NDR_BUFFERS, &r->a_string)); break; - case 2: - NDR_CHECK(ndr_push_trustAuthInOutCtr2(ndr, NDR_BUFFERS, &r->ctr2)); + case EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING: + NDR_CHECK(ndr_push_ExtendedErrorUString(ndr, NDR_BUFFERS, &r->u_string)); + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT32: + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT16: + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT64: + break; + + case EXTENDED_ERROR_PARAM_TYPE_NONE: + break; + + case EXTENDED_ERROR_PARAM_TYPE_BLOB: + NDR_CHECK(ndr_push_ExtendedErrorBlob(ndr, NDR_BUFFERS, &r->blob)); break; default: @@ -2688,18 +3222,42 @@ static enum ndr_err_code ndr_push_trustAuthInOutCtr(struct ndr_push *ndr, int nd return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_trustAuthInOutCtr(struct ndr_pull *ndr, int ndr_flags, union trustAuthInOutCtr *r) +static enum ndr_err_code ndr_pull_ExtendedErrorParamU(struct ndr_pull *ndr, int ndr_flags, union ExtendedErrorParamU *r) { int level; + uint16_t _level; level = ndr_pull_get_switch_value(ndr, r); if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } switch (level) { - case 1: { - NDR_CHECK(ndr_pull_trustAuthInOutCtr1(ndr, NDR_SCALARS, &r->ctr1)); + case EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING: { + NDR_CHECK(ndr_pull_ExtendedErrorAString(ndr, NDR_SCALARS, &r->a_string)); break; } - case 2: { - NDR_CHECK(ndr_pull_trustAuthInOutCtr2(ndr, NDR_SCALARS, &r->ctr2)); + case EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING: { + NDR_CHECK(ndr_pull_ExtendedErrorUString(ndr, NDR_SCALARS, &r->u_string)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_UINT32: { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->uint32)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_UINT16: { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->uint16)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_UINT64: { + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->uint64)); + break; } + + case EXTENDED_ERROR_PARAM_TYPE_NONE: { + break; } + + case EXTENDED_ERROR_PARAM_TYPE_BLOB: { + NDR_CHECK(ndr_pull_ExtendedErrorBlob(ndr, NDR_SCALARS, &r->blob)); break; } default: @@ -2708,12 +3266,28 @@ static enum ndr_err_code ndr_pull_trustAuthInOutCtr(struct ndr_pull *ndr, int nd } if (ndr_flags & NDR_BUFFERS) { switch (level) { - case 1: - NDR_CHECK(ndr_pull_trustAuthInOutCtr1(ndr, NDR_BUFFERS, &r->ctr1)); + case EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING: + NDR_CHECK(ndr_pull_ExtendedErrorAString(ndr, NDR_BUFFERS, &r->a_string)); break; - case 2: - NDR_CHECK(ndr_pull_trustAuthInOutCtr2(ndr, NDR_BUFFERS, &r->ctr2)); + case EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING: + NDR_CHECK(ndr_pull_ExtendedErrorUString(ndr, NDR_BUFFERS, &r->u_string)); + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT32: + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT16: + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT64: + break; + + case EXTENDED_ERROR_PARAM_TYPE_NONE: + break; + + case EXTENDED_ERROR_PARAM_TYPE_BLOB: + NDR_CHECK(ndr_pull_ExtendedErrorBlob(ndr, NDR_BUFFERS, &r->blob)); break; default: @@ -2723,18 +3297,37 @@ static enum ndr_err_code ndr_pull_trustAuthInOutCtr(struct ndr_pull *ndr, int nd return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutCtr(struct ndr_print *ndr, const char *name, const union trustAuthInOutCtr *r) +_PUBLIC_ void ndr_print_ExtendedErrorParamU(struct ndr_print *ndr, const char *name, const union ExtendedErrorParamU *r) { int level; level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "trustAuthInOutCtr"); + ndr_print_union(ndr, name, level, "ExtendedErrorParamU"); switch (level) { - case 1: - ndr_print_trustAuthInOutCtr1(ndr, "ctr1", &r->ctr1); + case EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING: + ndr_print_ExtendedErrorAString(ndr, "a_string", &r->a_string); break; - case 2: - ndr_print_trustAuthInOutCtr2(ndr, "ctr2", &r->ctr2); + case EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING: + ndr_print_ExtendedErrorUString(ndr, "u_string", &r->u_string); + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT32: + ndr_print_uint32(ndr, "uint32", r->uint32); + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT16: + ndr_print_uint16(ndr, "uint16", r->uint16); + break; + + case EXTENDED_ERROR_PARAM_TYPE_UINT64: + ndr_print_hyper(ndr, "uint64", r->uint64); + break; + + case EXTENDED_ERROR_PARAM_TYPE_NONE: + break; + + case EXTENDED_ERROR_PARAM_TYPE_BLOB: + ndr_print_ExtendedErrorBlob(ndr, "blob", &r->blob); break; default: @@ -2742,118 +3335,205 @@ _PUBLIC_ void ndr_print_trustAuthInOutCtr(struct ndr_print *ndr, const char *nam } } -_PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r) +static enum ndr_err_code ndr_push_ExtendedErrorParam(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorParam *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->ctr, r->version)); - NDR_CHECK(ndr_push_trustAuthInOutCtr(ndr, NDR_SCALARS, &r->ctr)); + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_ExtendedErrorParamType(ndr, NDR_SCALARS, r->type)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->p, r->type)); + NDR_CHECK(ndr_push_ExtendedErrorParamU(ndr, NDR_SCALARS, &r->p)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_trustAuthInOutCtr(ndr, NDR_BUFFERS, &r->ctr)); + NDR_CHECK(ndr_push_ExtendedErrorParamU(ndr, NDR_BUFFERS, &r->p)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r) +static enum ndr_err_code ndr_pull_ExtendedErrorParam(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorParam *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->ctr, r->version)); - NDR_CHECK(ndr_pull_trustAuthInOutCtr(ndr, NDR_SCALARS, &r->ctr)); + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_ExtendedErrorParamType(ndr, NDR_SCALARS, &r->type)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->p, r->type)); + NDR_CHECK(ndr_pull_ExtendedErrorParamU(ndr, NDR_SCALARS, &r->p)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_trustAuthInOutCtr(ndr, NDR_BUFFERS, &r->ctr)); + NDR_CHECK(ndr_pull_ExtendedErrorParamU(ndr, NDR_BUFFERS, &r->p)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r) +_PUBLIC_ void ndr_print_ExtendedErrorParam(struct ndr_print *ndr, const char *name, const struct ExtendedErrorParam *r) { - ndr_print_struct(ndr, name, "trustAuthInOutBlob"); + ndr_print_struct(ndr, name, "ExtendedErrorParam"); ndr->depth++; - ndr_print_uint32(ndr, "version", r->version); - ndr_print_set_switch_value(ndr, &r->ctr, r->version); - ndr_print_trustAuthInOutCtr(ndr, "ctr", &r->ctr); + ndr_print_ExtendedErrorParamType(ndr, "type", r->type); + ndr_print_set_switch_value(ndr, &r->p, r->type); + ndr_print_ExtendedErrorParamU(ndr, "p", &r->p); ndr->depth--; } -_PUBLIC_ enum ndr_err_code ndr_push_DsCompressedChunk(struct ndr_push *ndr, int ndr_flags, const struct DsCompressedChunk *r) +_PUBLIC_ enum ndr_err_code ndr_push_ExtendedErrorInfo(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorInfo *r) { + uint32_t cntr_params_0; if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->marker)); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_params)); + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->next)); + NDR_CHECK(ndr_push_ExtendedErrorComputerName(ndr, NDR_SCALARS, &r->computer_name)); + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->pid)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->generating_component)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->status)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->detection_location)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_params)); + for (cntr_params_0 = 0; cntr_params_0 < r->num_params; cntr_params_0++) { + NDR_CHECK(ndr_push_ExtendedErrorParam(ndr, NDR_SCALARS, &r->params[cntr_params_0])); + } } if (ndr_flags & NDR_BUFFERS) { + if (r->next) { + NDR_CHECK(ndr_push_ExtendedErrorInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->next)); + } + NDR_CHECK(ndr_push_ExtendedErrorComputerName(ndr, NDR_BUFFERS, &r->computer_name)); + for (cntr_params_0 = 0; cntr_params_0 < r->num_params; cntr_params_0++) { + NDR_CHECK(ndr_push_ExtendedErrorParam(ndr, NDR_BUFFERS, &r->params[cntr_params_0])); + } } return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull_DsCompressedChunk(struct ndr_pull *ndr, int ndr_flags, struct DsCompressedChunk *r) +_PUBLIC_ enum ndr_err_code ndr_pull_ExtendedErrorInfo(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorInfo *r) { + uint32_t _ptr_next; + TALLOC_CTX *_mem_save_next_0; + uint32_t cntr_params_0; + TALLOC_CTX *_mem_save_params_0; if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->marker)); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->data)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->params)); + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_next)); + if (_ptr_next) { + NDR_PULL_ALLOC(ndr, r->next); + } else { + r->next = NULL; + } + NDR_CHECK(ndr_pull_ExtendedErrorComputerName(ndr, NDR_SCALARS, &r->computer_name)); + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->pid)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->generating_component)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->status)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->detection_location)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->flags)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_params)); + NDR_PULL_ALLOC_N(ndr, r->params, ndr_get_array_size(ndr, &r->params)); + _mem_save_params_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->params, 0); + for (cntr_params_0 = 0; cntr_params_0 < r->num_params; cntr_params_0++) { + NDR_CHECK(ndr_pull_ExtendedErrorParam(ndr, NDR_SCALARS, &r->params[cntr_params_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_params_0, 0); + if (r->params) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->params, r->num_params)); + } } if (ndr_flags & NDR_BUFFERS) { + if (r->next) { + _mem_save_next_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->next, 0); + NDR_CHECK(ndr_pull_ExtendedErrorInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->next)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_next_0, 0); + } + NDR_CHECK(ndr_pull_ExtendedErrorComputerName(ndr, NDR_BUFFERS, &r->computer_name)); + _mem_save_params_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->params, 0); + for (cntr_params_0 = 0; cntr_params_0 < r->num_params; cntr_params_0++) { + NDR_CHECK(ndr_pull_ExtendedErrorParam(ndr, NDR_BUFFERS, &r->params[cntr_params_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_params_0, 0); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_DsCompressedChunk(struct ndr_print *ndr, const char *name, const struct DsCompressedChunk *r) +_PUBLIC_ void ndr_print_ExtendedErrorInfo(struct ndr_print *ndr, const char *name, const struct ExtendedErrorInfo *r) { - ndr_print_struct(ndr, name, "DsCompressedChunk"); + uint32_t cntr_params_0; + ndr_print_struct(ndr, name, "ExtendedErrorInfo"); ndr->depth++; - ndr_print_uint32(ndr, "marker", r->marker); - ndr_print_DATA_BLOB(ndr, "data", r->data); + ndr_print_ptr(ndr, "next", r->next); + ndr->depth++; + if (r->next) { + ndr_print_ExtendedErrorInfo(ndr, "next", r->next); + } + ndr->depth--; + ndr_print_ExtendedErrorComputerName(ndr, "computer_name", &r->computer_name); + ndr_print_hyper(ndr, "pid", r->pid); + ndr_print_NTTIME(ndr, "time", r->time); + ndr_print_uint32(ndr, "generating_component", r->generating_component); + ndr_print_WERROR(ndr, "status", r->status); + ndr_print_uint16(ndr, "detection_location", r->detection_location); + ndr_print_uint16(ndr, "flags", r->flags); + ndr_print_uint16(ndr, "num_params", r->num_params); + ndr->print(ndr, "%s: ARRAY(%d)", "params", (int)r->num_params); + ndr->depth++; + for (cntr_params_0=0;cntr_params_0num_params;cntr_params_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_params_0) != -1) { + ndr_print_ExtendedErrorParam(ndr, "params", &r->params[cntr_params_0]); + free(idx_0); + } + } + ndr->depth--; ndr->depth--; } -_PUBLIC_ enum ndr_err_code ndr_push_DsCompressedBlob(struct ndr_push *ndr, int ndr_flags, const struct DsCompressedBlob *r) +static enum ndr_err_code ndr_push_ExtendedErrorInfoPtr(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorInfoPtr *r) { - uint32_t cntr_chunks_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - for (cntr_chunks_0 = 0; cntr_chunks_0 < 5; cntr_chunks_0++) { - NDR_CHECK(ndr_push_DsCompressedChunk(ndr, NDR_SCALARS, &r->chunks[cntr_chunks_0])); - } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info)); } if (ndr_flags & NDR_BUFFERS) { + if (r->info) { + NDR_CHECK(ndr_push_ExtendedErrorInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->info)); + } } return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull_DsCompressedBlob(struct ndr_pull *ndr, int ndr_flags, struct DsCompressedBlob *r) +static enum ndr_err_code ndr_pull_ExtendedErrorInfoPtr(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorInfoPtr *r) { - uint32_t cntr_chunks_0; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_info_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - for (cntr_chunks_0 = 0; cntr_chunks_0 < 5; cntr_chunks_0++) { - NDR_CHECK(ndr_pull_DsCompressedChunk(ndr, NDR_SCALARS, &r->chunks[cntr_chunks_0])); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->info); + } else { + r->info = NULL; } } if (ndr_flags & NDR_BUFFERS) { + if (r->info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info, 0); + NDR_CHECK(ndr_pull_ExtendedErrorInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_DsCompressedBlob(struct ndr_print *ndr, const char *name, const struct DsCompressedBlob *r) +_PUBLIC_ void ndr_print_ExtendedErrorInfoPtr(struct ndr_print *ndr, const char *name, const struct ExtendedErrorInfoPtr *r) { - uint32_t cntr_chunks_0; - ndr_print_struct(ndr, name, "DsCompressedBlob"); + ndr_print_struct(ndr, name, "ExtendedErrorInfoPtr"); ndr->depth++; - ndr->print(ndr, "%s: ARRAY(%d)", "chunks", (int)5); + ndr_print_ptr(ndr, "info", r->info); ndr->depth++; - for (cntr_chunks_0=0;cntr_chunks_0<5;cntr_chunks_0++) { - char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_chunks_0) != -1) { - ndr_print_DsCompressedChunk(ndr, "chunks", &r->chunks[cntr_chunks_0]); - free(idx_0); - } + if (r->info) { + ndr_print_ExtendedErrorInfo(ndr, "info", r->info); } ndr->depth--; ndr->depth--; @@ -3351,41 +4031,92 @@ _PUBLIC_ void ndr_print_decode_trustAuthInOut(struct ndr_print *ndr, const char ndr->depth--; } -static enum ndr_err_code ndr_push_decode_DsCompressed(struct ndr_push *ndr, int flags, const struct decode_DsCompressed *r) +static enum ndr_err_code ndr_push_decode_trustDomainPasswords(struct ndr_push *ndr, int flags, const struct decode_trustDomainPasswords *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_trustDomainPasswords(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.blob)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_decode_trustDomainPasswords(struct ndr_pull *ndr, int flags, struct decode_trustDomainPasswords *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_trustDomainPasswords(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.blob)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_decode_trustDomainPasswords(struct ndr_print *ndr, const char *name, int flags, const struct decode_trustDomainPasswords *r) +{ + ndr_print_struct(ndr, name, "decode_trustDomainPasswords"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "decode_trustDomainPasswords"); + ndr->depth++; + ndr_print_trustDomainPasswords(ndr, "blob", &r->in.blob); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "decode_trustDomainPasswords"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_decode_ExtendedErrorInfo(struct ndr_push *ndr, int flags, const struct decode_ExtendedErrorInfo *r) { if (flags & NDR_IN) { - NDR_CHECK(ndr_push_DsCompressedBlob(ndr, NDR_SCALARS, &r->in.blob)); + { + struct ndr_push *_ndr_ptr; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ptr, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_push_ExtendedErrorInfoPtr(_ndr_ptr, NDR_SCALARS|NDR_BUFFERS, &r->in.ptr)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ptr, 0xFFFFFC01, -1)); + } } if (flags & NDR_OUT) { } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_decode_DsCompressed(struct ndr_pull *ndr, int flags, struct decode_DsCompressed *r) +static enum ndr_err_code ndr_pull_decode_ExtendedErrorInfo(struct ndr_pull *ndr, int flags, struct decode_ExtendedErrorInfo *r) { if (flags & NDR_IN) { - NDR_CHECK(ndr_pull_DsCompressedBlob(ndr, NDR_SCALARS, &r->in.blob)); + { + struct ndr_pull *_ndr_ptr; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ptr, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_pull_ExtendedErrorInfoPtr(_ndr_ptr, NDR_SCALARS|NDR_BUFFERS, &r->in.ptr)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ptr, 0xFFFFFC01, -1)); + } } if (flags & NDR_OUT) { } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_decode_DsCompressed(struct ndr_print *ndr, const char *name, int flags, const struct decode_DsCompressed *r) +_PUBLIC_ void ndr_print_decode_ExtendedErrorInfo(struct ndr_print *ndr, const char *name, int flags, const struct decode_ExtendedErrorInfo *r) { - ndr_print_struct(ndr, name, "decode_DsCompressed"); + ndr_print_struct(ndr, name, "decode_ExtendedErrorInfo"); ndr->depth++; if (flags & NDR_SET_VALUES) { ndr->flags |= LIBNDR_PRINT_SET_VALUES; } if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "decode_DsCompressed"); + ndr_print_struct(ndr, "in", "decode_ExtendedErrorInfo"); ndr->depth++; - ndr_print_DsCompressedBlob(ndr, "blob", &r->in.blob); + ndr_print_ExtendedErrorInfoPtr(ndr, "ptr", &r->in.ptr); ndr->depth--; } if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "decode_DsCompressed"); + ndr_print_struct(ndr, "out", "decode_ExtendedErrorInfo"); ndr->depth++; ndr->depth--; } @@ -3490,11 +4221,19 @@ static const struct ndr_interface_call drsblobs_calls[] = { false, }, { - "decode_DsCompressed", - sizeof(struct decode_DsCompressed), - (ndr_push_flags_fn_t) ndr_push_decode_DsCompressed, - (ndr_pull_flags_fn_t) ndr_pull_decode_DsCompressed, - (ndr_print_function_t) ndr_print_decode_DsCompressed, + "decode_trustDomainPasswords", + sizeof(struct decode_trustDomainPasswords), + (ndr_push_flags_fn_t) ndr_push_decode_trustDomainPasswords, + (ndr_pull_flags_fn_t) ndr_pull_decode_trustDomainPasswords, + (ndr_print_function_t) ndr_print_decode_trustDomainPasswords, + false, + }, + { + "decode_ExtendedErrorInfo", + sizeof(struct decode_ExtendedErrorInfo), + (ndr_push_flags_fn_t) ndr_push_decode_ExtendedErrorInfo, + (ndr_pull_flags_fn_t) ndr_pull_decode_ExtendedErrorInfo, + (ndr_print_function_t) ndr_print_decode_ExtendedErrorInfo, false, }, { NULL, 0, NULL, NULL, NULL, false } @@ -3526,7 +4265,7 @@ const struct ndr_interface_table ndr_table_drsblobs = { NDR_DRSBLOBS_VERSION }, .helpstring = NDR_DRSBLOBS_HELPSTRING, - .num_calls = 13, + .num_calls = 14, .calls = drsblobs_calls, .endpoints = &drsblobs_endpoints, .authservices = &drsblobs_authservices diff --git a/source3/librpc/gen_ndr/ndr_drsblobs.h b/source3/librpc/gen_ndr/ndr_drsblobs.h index 171e7e25a1..8a5298874a 100644 --- a/source3/librpc/gen_ndr/ndr_drsblobs.h +++ b/source3/librpc/gen_ndr/ndr_drsblobs.h @@ -35,9 +35,11 @@ extern const struct ndr_interface_table ndr_table_drsblobs; #define NDR_DECODE_TRUSTAUTHINOUT (0x0b) -#define NDR_DECODE_DSCOMPRESSED (0x0c) +#define NDR_DECODE_TRUSTDOMAINPASSWORDS (0x0c) -#define NDR_DRSBLOBS_CALL_COUNT (13) +#define NDR_DECODE_EXTENDEDERRORINFO (0x0d) + +#define NDR_DRSBLOBS_CALL_COUNT (14) void ndr_print_replPropertyMetaData1(struct ndr_print *ndr, const char *name, const struct replPropertyMetaData1 *r); void ndr_print_replPropertyMetaDataCtr1(struct ndr_print *ndr, const char *name, const struct replPropertyMetaDataCtr1 *r); void ndr_print_replPropertyMetaDataCtr(struct ndr_print *ndr, const char *name, const union replPropertyMetaDataCtr *r); @@ -102,21 +104,44 @@ void ndr_print_package_PrimaryWDigestHash(struct ndr_print *ndr, const char *nam enum ndr_err_code ndr_push_package_PrimaryWDigestBlob(struct ndr_push *ndr, int ndr_flags, const struct package_PrimaryWDigestBlob *r); enum ndr_err_code ndr_pull_package_PrimaryWDigestBlob(struct ndr_pull *ndr, int ndr_flags, struct package_PrimaryWDigestBlob *r); void ndr_print_package_PrimaryWDigestBlob(struct ndr_print *ndr, const char *name, const struct package_PrimaryWDigestBlob *r); -void ndr_print_trustAuthInOutSecret1(struct ndr_print *ndr, const char *name, const struct trustAuthInOutSecret1 *r); -void ndr_print_trustAuthInOutCtr1(struct ndr_print *ndr, const char *name, const struct trustAuthInOutCtr1 *r); -void ndr_print_trustAuthInOutSecret2V1(struct ndr_print *ndr, const char *name, const struct trustAuthInOutSecret2V1 *r); -void ndr_print_trustAuthInOutSecret2V2(struct ndr_print *ndr, const char *name, const struct trustAuthInOutSecret2V2 *r); -void ndr_print_trustAuthInOutCtr2(struct ndr_print *ndr, const char *name, const struct trustAuthInOutCtr2 *r); -void ndr_print_trustAuthInOutCtr(struct ndr_print *ndr, const char *name, const union trustAuthInOutCtr *r); +void ndr_print_AuthInfoNone(struct ndr_print *ndr, const char *name, const struct AuthInfoNone *r); +void ndr_print_AuthInfoNT4Owf(struct ndr_print *ndr, const char *name, const struct AuthInfoNT4Owf *r); +void ndr_print_AuthInfoClear(struct ndr_print *ndr, const char *name, const struct AuthInfoClear *r); +void ndr_print_AuthInfoVersion(struct ndr_print *ndr, const char *name, const struct AuthInfoVersion *r); +void ndr_print_AuthInfo(struct ndr_print *ndr, const char *name, const union AuthInfo *r); +enum ndr_err_code ndr_push_AuthenticationInformation(struct ndr_push *ndr, int ndr_flags, const struct AuthenticationInformation *r); +enum ndr_err_code ndr_pull_AuthenticationInformation(struct ndr_pull *ndr, int ndr_flags, struct AuthenticationInformation *r); +void ndr_print_AuthenticationInformation(struct ndr_print *ndr, const char *name, const struct AuthenticationInformation *r); +enum ndr_err_code ndr_push_AuthenticationInformationArray(struct ndr_push *ndr, int ndr_flags, const struct AuthenticationInformationArray *r); +enum ndr_err_code ndr_pull_AuthenticationInformationArray(struct ndr_pull *ndr, int ndr_flags, struct AuthenticationInformationArray *r); +void ndr_print_AuthenticationInformationArray(struct ndr_print *ndr, const char *name, const struct AuthenticationInformationArray *r); enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r); enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r); void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r); +size_t ndr_size_trustAuthInOutBlob(const struct trustAuthInOutBlob *r, int flags); +enum ndr_err_code ndr_push_trustCurrentPasswords(struct ndr_push *ndr, int ndr_flags, const struct trustCurrentPasswords *r); +enum ndr_err_code ndr_pull_trustCurrentPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustCurrentPasswords *r); +void ndr_print_trustCurrentPasswords(struct ndr_print *ndr, const char *name, const struct trustCurrentPasswords *r); +size_t ndr_size_trustCurrentPasswords(const struct trustCurrentPasswords *r, int flags); +enum ndr_err_code ndr_push_trustDomainPasswords(struct ndr_push *ndr, int ndr_flags, const struct trustDomainPasswords *r); +enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r); +void ndr_print_trustDomainPasswords(struct ndr_print *ndr, const char *name, const struct trustDomainPasswords *r); enum ndr_err_code ndr_push_DsCompressedChunk(struct ndr_push *ndr, int ndr_flags, const struct DsCompressedChunk *r); enum ndr_err_code ndr_pull_DsCompressedChunk(struct ndr_pull *ndr, int ndr_flags, struct DsCompressedChunk *r); void ndr_print_DsCompressedChunk(struct ndr_print *ndr, const char *name, const struct DsCompressedChunk *r); -enum ndr_err_code ndr_push_DsCompressedBlob(struct ndr_push *ndr, int ndr_flags, const struct DsCompressedBlob *r); -enum ndr_err_code ndr_pull_DsCompressedBlob(struct ndr_pull *ndr, int ndr_flags, struct DsCompressedBlob *r); -void ndr_print_DsCompressedBlob(struct ndr_print *ndr, const char *name, const struct DsCompressedBlob *r); +void ndr_print_ExtendedErrorAString(struct ndr_print *ndr, const char *name, const struct ExtendedErrorAString *r); +void ndr_print_ExtendedErrorUString(struct ndr_print *ndr, const char *name, const struct ExtendedErrorUString *r); +void ndr_print_ExtendedErrorBlob(struct ndr_print *ndr, const char *name, const struct ExtendedErrorBlob *r); +void ndr_print_ExtendedErrorComputerNamePresent(struct ndr_print *ndr, const char *name, enum ExtendedErrorComputerNamePresent r); +void ndr_print_ExtendedErrorComputerNameU(struct ndr_print *ndr, const char *name, const union ExtendedErrorComputerNameU *r); +void ndr_print_ExtendedErrorComputerName(struct ndr_print *ndr, const char *name, const struct ExtendedErrorComputerName *r); +void ndr_print_ExtendedErrorParamType(struct ndr_print *ndr, const char *name, enum ExtendedErrorParamType r); +void ndr_print_ExtendedErrorParamU(struct ndr_print *ndr, const char *name, const union ExtendedErrorParamU *r); +void ndr_print_ExtendedErrorParam(struct ndr_print *ndr, const char *name, const struct ExtendedErrorParam *r); +enum ndr_err_code ndr_push_ExtendedErrorInfo(struct ndr_push *ndr, int ndr_flags, const struct ExtendedErrorInfo *r); +enum ndr_err_code ndr_pull_ExtendedErrorInfo(struct ndr_pull *ndr, int ndr_flags, struct ExtendedErrorInfo *r); +void ndr_print_ExtendedErrorInfo(struct ndr_print *ndr, const char *name, const struct ExtendedErrorInfo *r); +void ndr_print_ExtendedErrorInfoPtr(struct ndr_print *ndr, const char *name, const struct ExtendedErrorInfoPtr *r); void ndr_print_decode_replPropertyMetaData(struct ndr_print *ndr, const char *name, int flags, const struct decode_replPropertyMetaData *r); void ndr_print_decode_replUpToDateVector(struct ndr_print *ndr, const char *name, int flags, const struct decode_replUpToDateVector *r); void ndr_print_decode_repsFromTo(struct ndr_print *ndr, const char *name, int flags, const struct decode_repsFromTo *r); @@ -129,5 +154,6 @@ void ndr_print_decode_PrimaryKerberos(struct ndr_print *ndr, const char *name, i void ndr_print_decode_PrimaryCLEARTEXT(struct ndr_print *ndr, const char *name, int flags, const struct decode_PrimaryCLEARTEXT *r); void ndr_print_decode_PrimaryWDigest(struct ndr_print *ndr, const char *name, int flags, const struct decode_PrimaryWDigest *r); void ndr_print_decode_trustAuthInOut(struct ndr_print *ndr, const char *name, int flags, const struct decode_trustAuthInOut *r); -void ndr_print_decode_DsCompressed(struct ndr_print *ndr, const char *name, int flags, const struct decode_DsCompressed *r); +void ndr_print_decode_trustDomainPasswords(struct ndr_print *ndr, const char *name, int flags, const struct decode_trustDomainPasswords *r); +void ndr_print_decode_ExtendedErrorInfo(struct ndr_print *ndr, const char *name, int flags, const struct decode_ExtendedErrorInfo *r); #endif /* _HEADER_NDR_drsblobs */ diff --git a/source3/librpc/gen_ndr/ndr_drsuapi.c b/source3/librpc/gen_ndr/ndr_drsuapi.c index 38b88f643c..c2a4aee180 100644 --- a/source3/librpc/gen_ndr/ndr_drsuapi.c +++ b/source3/librpc/gen_ndr/ndr_drsuapi.c @@ -2823,217 +2823,219 @@ _PUBLIC_ size_t ndr_size_drsuapi_DsGetNCChangesCtr6(const struct drsuapi_DsGetNC return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsGetNCChangesCtr6); } -static enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r) +_PUBLIC_ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesCtr1TS(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesCtr1TS *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ctr1)); + NDR_CHECK(ndr_push_align(ndr, 1)); + { + struct ndr_push *_ndr_ctr1; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ctr1, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1(_ndr_ctr1, NDR_SCALARS|NDR_BUFFERS, &r->ctr1)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ctr1, 0xFFFFFC01, -1)); + } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr1) { - { - struct ndr_push *_ndr_ctr1; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ctr1, 4, r->compressed_length)); - { - struct ndr_push *_ndr_ctr1_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ctr1, &_ndr_ctr1_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1(_ndr_ctr1_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr1)); - NDR_CHECK(ndr_push_compression_end(_ndr_ctr1, _ndr_ctr1_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ctr1, 4, r->compressed_length)); - } - } } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesMSZIPCtr1 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesCtr1TS(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesCtr1TS *r) { - uint32_t _ptr_ctr1; - TALLOC_CTX *_mem_save_ctr1_0; if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->decompressed_length)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->compressed_length)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ctr1)); - if (_ptr_ctr1) { - NDR_PULL_ALLOC(ndr, r->ctr1); - } else { - r->ctr1 = NULL; + NDR_CHECK(ndr_pull_align(ndr, 1)); + { + struct ndr_pull *_ndr_ctr1; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ctr1, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr1(_ndr_ctr1, NDR_SCALARS|NDR_BUFFERS, &r->ctr1)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ctr1, 0xFFFFFC01, -1)); } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr1) { - _mem_save_ctr1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->ctr1, 0); - { - struct ndr_pull *_ndr_ctr1; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ctr1, 4, r->compressed_length)); - { - struct ndr_pull *_ndr_ctr1_compressed; - NDR_CHECK(ndr_pull_compression_start(_ndr_ctr1, &_ndr_ctr1_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr1(_ndr_ctr1_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr1)); - NDR_CHECK(ndr_pull_compression_end(_ndr_ctr1, _ndr_ctr1_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - } - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ctr1, 4, r->compressed_length)); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ctr1_0, 0); - } } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r) +_PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesCtr1TS(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesCtr1TS *r) { - ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesMSZIPCtr1"); - ndr->depth++; - ndr_print_uint32(ndr, "decompressed_length", r->decompressed_length); - ndr_print_uint32(ndr, "compressed_length", r->compressed_length); - ndr_print_ptr(ndr, "ctr1", r->ctr1); + ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesCtr1TS"); ndr->depth++; - if (r->ctr1) { - ndr_print_drsuapi_DsGetNCChangesCtr1(ndr, "ctr1", r->ctr1); - } - ndr->depth--; + ndr_print_drsuapi_DsGetNCChangesCtr1(ndr, "ctr1", &r->ctr1); ndr->depth--; } -static enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r) +_PUBLIC_ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesCtr6TS(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesCtr6TS *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ctr6)); + NDR_CHECK(ndr_push_align(ndr, 1)); + { + struct ndr_push *_ndr_ctr6; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ctr6, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6(_ndr_ctr6, NDR_SCALARS|NDR_BUFFERS, &r->ctr6)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ctr6, 0xFFFFFC01, -1)); + } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr6) { - { - struct ndr_push *_ndr_ctr6; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ctr6, 4, r->compressed_length)); - { - struct ndr_push *_ndr_ctr6_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ctr6, &_ndr_ctr6_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6(_ndr_ctr6_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr6)); - NDR_CHECK(ndr_push_compression_end(_ndr_ctr6, _ndr_ctr6_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ctr6, 4, r->compressed_length)); - } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesCtr6TS(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesCtr6TS *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 1)); + { + struct ndr_pull *_ndr_ctr6; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ctr6, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr6(_ndr_ctr6, NDR_SCALARS|NDR_BUFFERS, &r->ctr6)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ctr6, 0xFFFFFC01, -1)); } } + if (ndr_flags & NDR_BUFFERS) { + } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesMSZIPCtr6 *r) +_PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesCtr6TS(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesCtr6TS *r) +{ + ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesCtr6TS"); + ndr->depth++; + ndr_print_drsuapi_DsGetNCChangesCtr6(ndr, "ctr6", &r->ctr6); + ndr->depth--; +} + +static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesMSZIPCtr1 *r) { - uint32_t _ptr_ctr6; - TALLOC_CTX *_mem_save_ctr6_0; + uint32_t _ptr_ts; + TALLOC_CTX *_mem_save_ts_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->decompressed_length)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->compressed_length)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ctr6)); - if (_ptr_ctr6) { - NDR_PULL_ALLOC(ndr, r->ctr6); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ts)); + if (_ptr_ts) { + NDR_PULL_ALLOC(ndr, r->ts); } else { - r->ctr6 = NULL; + r->ts = NULL; } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr6) { - _mem_save_ctr6_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->ctr6, 0); + if (r->ts) { + _mem_save_ts_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->ts, 0); { - struct ndr_pull *_ndr_ctr6; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ctr6, 4, r->compressed_length)); + struct ndr_pull *_ndr_ts; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ts, 4, r->compressed_length)); { - struct ndr_pull *_ndr_ctr6_compressed; - NDR_CHECK(ndr_pull_compression_start(_ndr_ctr6, &_ndr_ctr6_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); - NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr6(_ndr_ctr6_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr6)); - NDR_CHECK(ndr_pull_compression_end(_ndr_ctr6, _ndr_ctr6_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); + struct ndr_pull *_ndr_ts_compressed; + NDR_CHECK(ndr_pull_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); + NDR_CHECK(ndr_pull_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); } - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ctr6, 4, r->compressed_length)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ts, 4, r->compressed_length)); } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ctr6_0, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ts_0, 0); } } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r) +_PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r) { - ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesMSZIPCtr6"); + ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesMSZIPCtr1"); ndr->depth++; ndr_print_uint32(ndr, "decompressed_length", r->decompressed_length); ndr_print_uint32(ndr, "compressed_length", r->compressed_length); - ndr_print_ptr(ndr, "ctr6", r->ctr6); + ndr_print_ptr(ndr, "ts", r->ts); ndr->depth++; - if (r->ctr6) { - ndr_print_drsuapi_DsGetNCChangesCtr6(ndr, "ctr6", r->ctr6); + if (r->ts) { + ndr_print_drsuapi_DsGetNCChangesCtr1TS(ndr, "ts", r->ts); } ndr->depth--; ndr->depth--; } -static enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r) +static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesMSZIPCtr6 *r) { + uint32_t _ptr_ts; + TALLOC_CTX *_mem_save_ts_0; if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ctr1)); + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->decompressed_length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->compressed_length)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ts)); + if (_ptr_ts) { + NDR_PULL_ALLOC(ndr, r->ts); + } else { + r->ts = NULL; + } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr1) { + if (r->ts) { + _mem_save_ts_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->ts, 0); { - struct ndr_push *_ndr_ctr1; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ctr1, 4, r->compressed_length)); + struct ndr_pull *_ndr_ts; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ts, 4, r->compressed_length)); { - struct ndr_push *_ndr_ctr1_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ctr1, &_ndr_ctr1_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1(_ndr_ctr1_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr1)); - NDR_CHECK(ndr_push_compression_end(_ndr_ctr1, _ndr_ctr1_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); + struct ndr_pull *_ndr_ts_compressed; + NDR_CHECK(ndr_pull_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); + NDR_CHECK(ndr_pull_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, r->decompressed_length)); } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ctr1, 4, r->compressed_length)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ts, 4, r->compressed_length)); } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ts_0, 0); } } return NDR_ERR_SUCCESS; } +_PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r) +{ + ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesMSZIPCtr6"); + ndr->depth++; + ndr_print_uint32(ndr, "decompressed_length", r->decompressed_length); + ndr_print_uint32(ndr, "compressed_length", r->compressed_length); + ndr_print_ptr(ndr, "ts", r->ts); + ndr->depth++; + if (r->ts) { + ndr_print_drsuapi_DsGetNCChangesCtr6TS(ndr, "ts", r->ts); + } + ndr->depth--; + ndr->depth--; +} + static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesXPRESSCtr1 *r) { - uint32_t _ptr_ctr1; - TALLOC_CTX *_mem_save_ctr1_0; + uint32_t _ptr_ts; + TALLOC_CTX *_mem_save_ts_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->decompressed_length)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->compressed_length)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ctr1)); - if (_ptr_ctr1) { - NDR_PULL_ALLOC(ndr, r->ctr1); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ts)); + if (_ptr_ts) { + NDR_PULL_ALLOC(ndr, r->ts); } else { - r->ctr1 = NULL; + r->ts = NULL; } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr1) { - _mem_save_ctr1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->ctr1, 0); + if (r->ts) { + _mem_save_ts_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->ts, 0); { - struct ndr_pull *_ndr_ctr1; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ctr1, 4, r->compressed_length)); + struct ndr_pull *_ndr_ts; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ts, 4, r->compressed_length)); { - struct ndr_pull *_ndr_ctr1_compressed; - NDR_CHECK(ndr_pull_compression_start(_ndr_ctr1, &_ndr_ctr1_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); - NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr1(_ndr_ctr1_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr1)); - NDR_CHECK(ndr_pull_compression_end(_ndr_ctr1, _ndr_ctr1_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); + struct ndr_pull *_ndr_ts_compressed; + NDR_CHECK(ndr_pull_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); + NDR_CHECK(ndr_pull_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); } - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ctr1, 4, r->compressed_length)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ts, 4, r->compressed_length)); } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ctr1_0, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ts_0, 0); } } return NDR_ERR_SUCCESS; @@ -3045,72 +3047,46 @@ _PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_print *ndr, ndr->depth++; ndr_print_uint32(ndr, "decompressed_length", r->decompressed_length); ndr_print_uint32(ndr, "compressed_length", r->compressed_length); - ndr_print_ptr(ndr, "ctr1", r->ctr1); + ndr_print_ptr(ndr, "ts", r->ts); ndr->depth++; - if (r->ctr1) { - ndr_print_drsuapi_DsGetNCChangesCtr1(ndr, "ctr1", r->ctr1); + if (r->ts) { + ndr_print_drsuapi_DsGetNCChangesCtr1TS(ndr, "ts", r->ts); } ndr->depth--; ndr->depth--; } -static enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ctr6)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->ctr6) { - { - struct ndr_push *_ndr_ctr6; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ctr6, 4, r->compressed_length)); - { - struct ndr_push *_ndr_ctr6_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ctr6, &_ndr_ctr6_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6(_ndr_ctr6_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr6)); - NDR_CHECK(ndr_push_compression_end(_ndr_ctr6, _ndr_ctr6_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ctr6, 4, r->compressed_length)); - } - } - } - return NDR_ERR_SUCCESS; -} - static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesXPRESSCtr6 *r) { - uint32_t _ptr_ctr6; - TALLOC_CTX *_mem_save_ctr6_0; + uint32_t _ptr_ts; + TALLOC_CTX *_mem_save_ts_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->decompressed_length)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->compressed_length)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ctr6)); - if (_ptr_ctr6) { - NDR_PULL_ALLOC(ndr, r->ctr6); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ts)); + if (_ptr_ts) { + NDR_PULL_ALLOC(ndr, r->ts); } else { - r->ctr6 = NULL; + r->ts = NULL; } } if (ndr_flags & NDR_BUFFERS) { - if (r->ctr6) { - _mem_save_ctr6_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->ctr6, 0); + if (r->ts) { + _mem_save_ts_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->ts, 0); { - struct ndr_pull *_ndr_ctr6; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ctr6, 4, r->compressed_length)); + struct ndr_pull *_ndr_ts; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_ts, 4, r->compressed_length)); { - struct ndr_pull *_ndr_ctr6_compressed; - NDR_CHECK(ndr_pull_compression_start(_ndr_ctr6, &_ndr_ctr6_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); - NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr6(_ndr_ctr6_compressed, NDR_SCALARS|NDR_BUFFERS, r->ctr6)); - NDR_CHECK(ndr_pull_compression_end(_ndr_ctr6, _ndr_ctr6_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); + struct ndr_pull *_ndr_ts_compressed; + NDR_CHECK(ndr_pull_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); + NDR_CHECK(ndr_pull_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, r->decompressed_length)); } - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ctr6, 4, r->compressed_length)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_ts, 4, r->compressed_length)); } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ctr6_0, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ts_0, 0); } } return NDR_ERR_SUCCESS; @@ -3122,10 +3098,10 @@ _PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_print *ndr, ndr->depth++; ndr_print_uint32(ndr, "decompressed_length", r->decompressed_length); ndr_print_uint32(ndr, "compressed_length", r->compressed_length); - ndr_print_ptr(ndr, "ctr6", r->ctr6); + ndr_print_ptr(ndr, "ts", r->ts); ndr->depth++; - if (r->ctr6) { - ndr_print_drsuapi_DsGetNCChangesCtr6(ndr, "ctr6", r->ctr6); + if (r->ts) { + ndr_print_drsuapi_DsGetNCChangesCtr6TS(ndr, "ts", r->ts); } ndr->depth--; ndr->depth--; @@ -3304,11 +3280,10 @@ static enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesCtr2(struct ndr_push *nd { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->ctr, 1 | (DRSUAPI_COMPRESSION_TYPE_MSZIP << 16))); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCompressedCtr(ndr, NDR_SCALARS, &r->ctr)); + NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(ndr, NDR_SCALARS, &r->mszip1)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCompressedCtr(ndr, NDR_BUFFERS, &r->ctr)); + NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(ndr, NDR_BUFFERS, &r->mszip1)); } return NDR_ERR_SUCCESS; } @@ -3317,11 +3292,10 @@ static enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesCtr2(struct ndr_pull *nd { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->ctr, 1 | (DRSUAPI_COMPRESSION_TYPE_MSZIP << 16))); - NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCompressedCtr(ndr, NDR_SCALARS, &r->ctr)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesMSZIPCtr1(ndr, NDR_SCALARS, &r->mszip1)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesCompressedCtr(ndr, NDR_BUFFERS, &r->ctr)); + NDR_CHECK(ndr_pull_drsuapi_DsGetNCChangesMSZIPCtr1(ndr, NDR_BUFFERS, &r->mszip1)); } return NDR_ERR_SUCCESS; } @@ -3330,8 +3304,7 @@ _PUBLIC_ void ndr_print_drsuapi_DsGetNCChangesCtr2(struct ndr_print *ndr, const { ndr_print_struct(ndr, name, "drsuapi_DsGetNCChangesCtr2"); ndr->depth++; - ndr_print_set_switch_value(ndr, &r->ctr, 1 | (DRSUAPI_COMPRESSION_TYPE_MSZIP << 16)); - ndr_print_drsuapi_DsGetNCChangesCompressedCtr(ndr, "ctr", &r->ctr); + ndr_print_drsuapi_DsGetNCChangesMSZIPCtr1(ndr, "mszip1", &r->mszip1); ndr->depth--; } @@ -4741,7 +4714,7 @@ _PUBLIC_ void ndr_print_drsuapi_DsNameFormat(struct ndr_print *ndr, const char * const char *val = NULL; switch (r) { - case DRSUAPI_DS_NAME_FORMAT_UKNOWN: val = "DRSUAPI_DS_NAME_FORMAT_UKNOWN"; break; + case DRSUAPI_DS_NAME_FORMAT_UNKNOWN: val = "DRSUAPI_DS_NAME_FORMAT_UNKNOWN"; break; case DRSUAPI_DS_NAME_FORMAT_FQDN_1779: val = "DRSUAPI_DS_NAME_FORMAT_FQDN_1779"; break; case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT: val = "DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT"; break; case DRSUAPI_DS_NAME_FORMAT_DISPLAY: val = "DRSUAPI_DS_NAME_FORMAT_DISPLAY"; break; @@ -5609,7 +5582,7 @@ static enum ndr_err_code ndr_push_drsuapi_DsRemoveDSServerRequest1(struct ndr_pu NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->server_dn)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->domain_dn)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->commit)); } if (ndr_flags & NDR_BUFFERS) { if (r->server_dn) { @@ -5648,7 +5621,7 @@ static enum ndr_err_code ndr_pull_drsuapi_DsRemoveDSServerRequest1(struct ndr_pu } else { r->domain_dn = NULL; } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->commit)); } if (ndr_flags & NDR_BUFFERS) { if (r->server_dn) { @@ -5695,7 +5668,7 @@ _PUBLIC_ void ndr_print_drsuapi_DsRemoveDSServerRequest1(struct ndr_print *ndr, ndr_print_string(ndr, "domain_dn", r->domain_dn); } ndr->depth--; - ndr_print_uint32(ndr, "unknown", r->unknown); + ndr_print_uint32(ndr, "commit", r->commit); ndr->depth--; } @@ -5778,7 +5751,7 @@ static enum ndr_err_code ndr_push_drsuapi_DsRemoveDSServerResult1(struct ndr_pus { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->status)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->last_dc_in_domain)); } if (ndr_flags & NDR_BUFFERS) { } @@ -5789,7 +5762,7 @@ static enum ndr_err_code ndr_pull_drsuapi_DsRemoveDSServerResult1(struct ndr_pul { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->status)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->last_dc_in_domain)); } if (ndr_flags & NDR_BUFFERS) { } @@ -5800,7 +5773,7 @@ _PUBLIC_ void ndr_print_drsuapi_DsRemoveDSServerResult1(struct ndr_print *ndr, c { ndr_print_struct(ndr, name, "drsuapi_DsRemoveDSServerResult1"); ndr->depth++; - ndr_print_WERROR(ndr, "status", r->status); + ndr_print_uint32(ndr, "last_dc_in_domain", r->last_dc_in_domain); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/ndr_drsuapi.h b/source3/librpc/gen_ndr/ndr_drsuapi.h index 6b6a0b5670..4b5ead467f 100644 --- a/source3/librpc/gen_ndr/ndr_drsuapi.h +++ b/source3/librpc/gen_ndr/ndr_drsuapi.h @@ -6,7 +6,7 @@ #ifndef _HEADER_NDR_drsuapi #define _HEADER_NDR_drsuapi -#include "librpc/ndr/ndr_drsuapi.h" +#include "../librpc/ndr/ndr_drsuapi.h" #define NDR_DRSUAPI_UUID "e3514235-4b06-11d1-ab04-00c04fc2dcd2" #define NDR_DRSUAPI_VERSION 4.0 #define NDR_DRSUAPI_NAME "drsuapi" @@ -151,9 +151,19 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesCtr6(struct ndr_push *ndr, int enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesCtr6(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesCtr6 *r); void ndr_print_drsuapi_DsGetNCChangesCtr6(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesCtr6 *r); size_t ndr_size_drsuapi_DsGetNCChangesCtr6(const struct drsuapi_DsGetNCChangesCtr6 *r, int flags); +enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesCtr1TS(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesCtr1TS *r); +enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesCtr1TS(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesCtr1TS *r); +void ndr_print_drsuapi_DsGetNCChangesCtr1TS(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesCtr1TS *r); +enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesCtr6TS(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesCtr6TS *r); +enum ndr_err_code ndr_pull_drsuapi_DsGetNCChangesCtr6TS(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsGetNCChangesCtr6TS *r); +void ndr_print_drsuapi_DsGetNCChangesCtr6TS(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesCtr6TS *r); +enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r); void ndr_print_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r); +enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r); void ndr_print_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r); +enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r); void ndr_print_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r); +enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r); void ndr_print_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_print *ndr, const char *name, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r); void ndr_print_drsuapi_DsGetNCChangesCompressionType(struct ndr_print *ndr, const char *name, enum drsuapi_DsGetNCChangesCompressionType r); void ndr_print_drsuapi_DsGetNCChangesCompressedCtr(struct ndr_print *ndr, const char *name, const union drsuapi_DsGetNCChangesCompressedCtr *r); diff --git a/source3/librpc/gen_ndr/ndr_echo.c b/source3/librpc/gen_ndr/ndr_echo.c index 93a8464c7b..99556e1bff 100644 --- a/source3/librpc/gen_ndr/ndr_echo.c +++ b/source3/librpc/gen_ndr/ndr_echo.c @@ -3,7 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_echo.h" -static enum ndr_err_code ndr_push_echo_info1(struct ndr_push *ndr, int ndr_flags, const struct echo_info1 *r) +_PUBLIC_ enum ndr_err_code ndr_push_echo_info1(struct ndr_push *ndr, int ndr_flags, const struct echo_info1 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 1)); @@ -14,7 +14,7 @@ static enum ndr_err_code ndr_push_echo_info1(struct ndr_push *ndr, int ndr_flags return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_echo_info1(struct ndr_pull *ndr, int ndr_flags, struct echo_info1 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_echo_info1(struct ndr_pull *ndr, int ndr_flags, struct echo_info1 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 1)); diff --git a/source3/librpc/gen_ndr/ndr_echo.h b/source3/librpc/gen_ndr/ndr_echo.h index 7af1c7446b..c1c7716573 100644 --- a/source3/librpc/gen_ndr/ndr_echo.h +++ b/source3/librpc/gen_ndr/ndr_echo.h @@ -32,6 +32,8 @@ extern const struct ndr_interface_table ndr_table_rpcecho; #define NDR_ECHO_TESTDOUBLEPOINTER (0x09) #define NDR_RPCECHO_CALL_COUNT (10) +enum ndr_err_code ndr_push_echo_info1(struct ndr_push *ndr, int ndr_flags, const struct echo_info1 *r); +enum ndr_err_code ndr_pull_echo_info1(struct ndr_pull *ndr, int ndr_flags, struct echo_info1 *r); void ndr_print_echo_info1(struct ndr_print *ndr, const char *name, const struct echo_info1 *r); void ndr_print_echo_info2(struct ndr_print *ndr, const char *name, const struct echo_info2 *r); void ndr_print_echo_info3(struct ndr_print *ndr, const char *name, const struct echo_info3 *r); diff --git a/source3/librpc/gen_ndr/ndr_epmapper.c b/source3/librpc/gen_ndr/ndr_epmapper.c index ab84d289cf..0f1005dda7 100644 --- a/source3/librpc/gen_ndr/ndr_epmapper.c +++ b/source3/librpc/gen_ndr/ndr_epmapper.c @@ -3,6 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_epmapper.h" +#include "librpc/gen_ndr/ndr_misc.h" static enum ndr_err_code ndr_push_epm_protocol(struct ndr_push *ndr, int ndr_flags, enum epm_protocol r) { NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r)); @@ -1632,15 +1633,11 @@ static enum ndr_err_code ndr_push_epm_entry_t(struct ndr_push *ndr, int ndr_flag NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->object)); NDR_CHECK(ndr_push_full_ptr(ndr, r->tower)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->annotation)); - ndr->flags = _flags_save_string; - } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen(r->annotation) + 1)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->annotation, strlen(r->annotation) + 1, sizeof(uint8_t), CH_DOS)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->object)); if (r->tower) { NDR_CHECK(ndr_push_epm_twr_t(ndr, NDR_SCALARS, r->tower)); } @@ -1661,15 +1658,11 @@ static enum ndr_err_code ndr_pull_epm_entry_t(struct ndr_pull *ndr, int ndr_flag } else { r->tower = NULL; } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->annotation)); - ndr->flags = _flags_save_string; - } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__annotation_offset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__annotation_length)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->annotation, r->__annotation_length, sizeof(uint8_t), CH_DOS)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->object)); if (r->tower) { _mem_save_tower_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->tower, 0); @@ -1691,6 +1684,8 @@ _PUBLIC_ void ndr_print_epm_entry_t(struct ndr_print *ndr, const char *name, con ndr_print_epm_twr_t(ndr, "tower", r->tower); } ndr->depth--; + ndr_print_uint32(ndr, "__annotation_offset", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0:r->__annotation_offset); + ndr_print_uint32(ndr, "__annotation_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen(r->annotation) + 1:r->__annotation_length); ndr_print_string(ndr, "annotation", r->annotation); ndr->depth--; } @@ -1704,7 +1699,6 @@ static enum ndr_err_code ndr_push_rpc_if_id_t(struct ndr_push *ndr, int ndr_flag NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->vers_minor)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->uuid)); } return NDR_ERR_SUCCESS; } @@ -1718,7 +1712,6 @@ static enum ndr_err_code ndr_pull_rpc_if_id_t(struct ndr_pull *ndr, int ndr_flag NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->vers_minor)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->uuid)); } return NDR_ERR_SUCCESS; } @@ -1952,24 +1945,24 @@ static enum ndr_err_code ndr_push_epm_Lookup(struct ndr_push *ndr, int flags, co NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.inquiry_type)); NDR_CHECK(ndr_push_full_ptr(ndr, r->in.object)); if (r->in.object) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.object)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.object)); } NDR_CHECK(ndr_push_full_ptr(ndr, r->in.interface_id)); if (r->in.interface_id) { - NDR_CHECK(ndr_push_rpc_if_id_t(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.interface_id)); + NDR_CHECK(ndr_push_rpc_if_id_t(ndr, NDR_SCALARS, r->in.interface_id)); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.vers_option)); if (r->in.entry_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.entry_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.entry_handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.max_ents)); } if (flags & NDR_OUT) { if (r->out.entry_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.entry_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.entry_handle)); if (r->out.num_ents == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2011,7 +2004,7 @@ static enum ndr_err_code ndr_pull_epm_Lookup(struct ndr_pull *ndr, int flags, st if (r->in.object) { _mem_save_object_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.object, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.object)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.object)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_object_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_interface_id)); @@ -2023,7 +2016,7 @@ static enum ndr_err_code ndr_pull_epm_Lookup(struct ndr_pull *ndr, int flags, st if (r->in.interface_id) { _mem_save_interface_id_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.interface_id, 0); - NDR_CHECK(ndr_pull_rpc_if_id_t(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.interface_id)); + NDR_CHECK(ndr_pull_rpc_if_id_t(ndr, NDR_SCALARS, r->in.interface_id)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_interface_id_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.vers_option)); @@ -2032,7 +2025,7 @@ static enum ndr_err_code ndr_pull_epm_Lookup(struct ndr_pull *ndr, int flags, st } _mem_save_entry_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.entry_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.entry_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.entry_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entry_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.max_ents)); NDR_PULL_ALLOC(ndr, r->out.entry_handle); @@ -2046,7 +2039,7 @@ static enum ndr_err_code ndr_pull_epm_Lookup(struct ndr_pull *ndr, int flags, st } _mem_save_entry_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.entry_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.entry_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.entry_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entry_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.num_ents); @@ -2146,7 +2139,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_epm_Map(struct ndr_push *ndr, int flags, con if (flags & NDR_IN) { NDR_CHECK(ndr_push_full_ptr(ndr, r->in.object)); if (r->in.object) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.object)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.object)); } NDR_CHECK(ndr_push_full_ptr(ndr, r->in.map_tower)); if (r->in.map_tower) { @@ -2155,14 +2148,14 @@ _PUBLIC_ enum ndr_err_code ndr_push_epm_Map(struct ndr_push *ndr, int flags, con if (r->in.entry_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.entry_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.entry_handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.max_towers)); } if (flags & NDR_OUT) { if (r->out.entry_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.entry_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.entry_handle)); if (r->out.num_towers == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2203,7 +2196,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_epm_Map(struct ndr_pull *ndr, int flags, str if (r->in.object) { _mem_save_object_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.object, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.object)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.object)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_object_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_map_tower)); @@ -2223,7 +2216,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_epm_Map(struct ndr_pull *ndr, int flags, str } _mem_save_entry_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.entry_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.entry_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.entry_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entry_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.max_towers)); NDR_PULL_ALLOC(ndr, r->out.entry_handle); @@ -2237,7 +2230,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_epm_Map(struct ndr_pull *ndr, int flags, str } _mem_save_entry_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.entry_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.entry_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.entry_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entry_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.num_towers); @@ -2335,13 +2328,13 @@ static enum ndr_err_code ndr_push_epm_LookupHandleFree(struct ndr_push *ndr, int if (r->in.entry_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.entry_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.entry_handle)); } if (flags & NDR_OUT) { if (r->out.entry_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.entry_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.entry_handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -2358,7 +2351,7 @@ static enum ndr_err_code ndr_pull_epm_LookupHandleFree(struct ndr_pull *ndr, int } _mem_save_entry_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.entry_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.entry_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.entry_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entry_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.entry_handle); *r->out.entry_handle = *r->in.entry_handle; @@ -2369,7 +2362,7 @@ static enum ndr_err_code ndr_pull_epm_LookupHandleFree(struct ndr_pull *ndr, int } _mem_save_entry_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.entry_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.entry_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.entry_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entry_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.result)); } @@ -2411,7 +2404,7 @@ static enum ndr_err_code ndr_push_epm_InqObject(struct ndr_push *ndr, int flags, if (r->in.epm_object == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.epm_object)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.epm_object)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.result)); @@ -2428,7 +2421,7 @@ static enum ndr_err_code ndr_pull_epm_InqObject(struct ndr_pull *ndr, int flags, } _mem_save_epm_object_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.epm_object, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.epm_object)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.epm_object)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_epm_object_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { @@ -2468,7 +2461,7 @@ static enum ndr_err_code ndr_push_epm_MgmtDelete(struct ndr_push *ndr, int flags NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.object_speced)); NDR_CHECK(ndr_push_full_ptr(ndr, r->in.object)); if (r->in.object) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.object)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.object)); } NDR_CHECK(ndr_push_full_ptr(ndr, r->in.tower)); if (r->in.tower) { @@ -2498,7 +2491,7 @@ static enum ndr_err_code ndr_pull_epm_MgmtDelete(struct ndr_pull *ndr, int flags if (r->in.object) { _mem_save_object_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.object, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.object)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.object)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_object_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_tower)); diff --git a/source3/librpc/gen_ndr/ndr_eventlog.c b/source3/librpc/gen_ndr/ndr_eventlog.c index 2eb26c4bc4..f0c7ee4d61 100644 --- a/source3/librpc/gen_ndr/ndr_eventlog.c +++ b/source3/librpc/gen_ndr/ndr_eventlog.c @@ -192,7 +192,7 @@ static enum ndr_err_code ndr_push_eventlog_ClearEventLogW(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.backupfile)); if (r->in.backupfile) { NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.backupfile)); @@ -215,7 +215,7 @@ static enum ndr_err_code ndr_pull_eventlog_ClearEventLogW(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_backupfile)); if (_ptr_backupfile) { @@ -314,13 +314,13 @@ static enum ndr_err_code ndr_push_eventlog_CloseEventLog(struct ndr_push *ndr, i if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -337,7 +337,7 @@ static enum ndr_err_code ndr_pull_eventlog_CloseEventLog(struct ndr_pull *ndr, i } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.handle); *r->out.handle = *r->in.handle; @@ -348,7 +348,7 @@ static enum ndr_err_code ndr_pull_eventlog_CloseEventLog(struct ndr_pull *ndr, i } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -431,7 +431,7 @@ static enum ndr_err_code ndr_push_eventlog_GetNumRecords(struct ndr_push *ndr, i if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.number == NULL) { @@ -455,7 +455,7 @@ static enum ndr_err_code ndr_pull_eventlog_GetNumRecords(struct ndr_pull *ndr, i } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.number); ZERO_STRUCTP(r->out.number); @@ -508,7 +508,7 @@ static enum ndr_err_code ndr_push_eventlog_GetOldestRecord(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.oldest_entry == NULL) { @@ -532,7 +532,7 @@ static enum ndr_err_code ndr_pull_eventlog_GetOldestRecord(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.oldest_entry); ZERO_STRUCTP(r->out.oldest_entry); @@ -642,7 +642,7 @@ static enum ndr_err_code ndr_push_eventlog_OpenEventLogW(struct ndr_push *ndr, i if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -695,7 +695,7 @@ static enum ndr_err_code ndr_pull_eventlog_OpenEventLogW(struct ndr_pull *ndr, i } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -831,7 +831,7 @@ static enum ndr_err_code ndr_push_eventlog_ReadEventLogW(struct ndr_push *ndr, i if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offset)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.number_of_bytes)); @@ -868,7 +868,7 @@ static enum ndr_err_code ndr_pull_eventlog_ReadEventLogW(struct ndr_pull *ndr, i } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offset)); @@ -1449,7 +1449,7 @@ static enum ndr_err_code ndr_push_eventlog_FlushEventLog(struct ndr_push *ndr, i if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); @@ -1466,7 +1466,7 @@ static enum ndr_err_code ndr_pull_eventlog_FlushEventLog(struct ndr_pull *ndr, i } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/ndr_initshutdown.c b/source3/librpc/gen_ndr/ndr_initshutdown.c index 5d6c0c3c08..62a19af3a2 100644 --- a/source3/librpc/gen_ndr/ndr_initshutdown.c +++ b/source3/librpc/gen_ndr/ndr_initshutdown.c @@ -3,106 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_initshutdown.h" -static enum ndr_err_code ndr_push_initshutdown_String_sub(struct ndr_push *ndr, int ndr_flags, const struct initshutdown_String_sub *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term(r->name))); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name)); - ndr->flags = _flags_save_string; - } - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_initshutdown_String_sub(struct ndr_pull *ndr, int ndr_flags, struct initshutdown_String_sub *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->name_size)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name)); - ndr->flags = _flags_save_string; - } - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_initshutdown_String_sub(struct ndr_print *ndr, const char *name, const struct initshutdown_String_sub *r) -{ - ndr_print_struct(ndr, name, "initshutdown_String_sub"); - ndr->depth++; - ndr_print_uint32(ndr, "name_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term(r->name):r->name_size); - ndr_print_string(ndr, "name", r->name); - ndr->depth--; -} - -_PUBLIC_ enum ndr_err_code ndr_push_initshutdown_String(struct ndr_push *ndr, int ndr_flags, const struct initshutdown_String *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m(r->name->name) * 2)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term(r->name->name) * 2)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->name)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->name) { - NDR_CHECK(ndr_push_initshutdown_String_sub(ndr, NDR_SCALARS, r->name)); - } - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_initshutdown_String(struct ndr_pull *ndr, int ndr_flags, struct initshutdown_String *r) -{ - uint32_t _ptr_name; - TALLOC_CTX *_mem_save_name_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->name_len)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->name_size)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name)); - if (_ptr_name) { - NDR_PULL_ALLOC(ndr, r->name); - } else { - r->name = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->name) { - _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->name, 0); - NDR_CHECK(ndr_pull_initshutdown_String_sub(ndr, NDR_SCALARS, r->name)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0); - } - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_initshutdown_String(struct ndr_print *ndr, const char *name, const struct initshutdown_String *r) -{ - ndr_print_struct(ndr, name, "initshutdown_String"); - ndr->depth++; - ndr_print_uint16(ndr, "name_len", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m(r->name->name) * 2:r->name_len); - ndr_print_uint16(ndr, "name_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term(r->name->name) * 2:r->name_size); - ndr_print_ptr(ndr, "name", r->name); - ndr->depth++; - if (r->name) { - ndr_print_initshutdown_String_sub(ndr, "name", r->name); - } - ndr->depth--; - ndr->depth--; -} - +#include "librpc/gen_ndr/ndr_lsa.h" static enum ndr_err_code ndr_push_initshutdown_Init(struct ndr_push *ndr, int flags, const struct initshutdown_Init *r) { if (flags & NDR_IN) { @@ -112,7 +13,7 @@ static enum ndr_err_code ndr_push_initshutdown_Init(struct ndr_push *ndr, int fl } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.message)); if (r->in.message) { - NDR_CHECK(ndr_push_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.timeout)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.force_apps)); @@ -152,7 +53,7 @@ static enum ndr_err_code ndr_pull_initshutdown_Init(struct ndr_pull *ndr, int fl if (r->in.message) { _mem_save_message_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.message, 0); - NDR_CHECK(ndr_pull_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_message_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.timeout)); @@ -184,7 +85,7 @@ _PUBLIC_ void ndr_print_initshutdown_Init(struct ndr_print *ndr, const char *nam ndr_print_ptr(ndr, "message", r->in.message); ndr->depth++; if (r->in.message) { - ndr_print_initshutdown_String(ndr, "message", r->in.message); + ndr_print_lsa_StringLarge(ndr, "message", r->in.message); } ndr->depth--; ndr_print_uint32(ndr, "timeout", r->in.timeout); @@ -275,7 +176,7 @@ static enum ndr_err_code ndr_push_initshutdown_InitEx(struct ndr_push *ndr, int } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.message)); if (r->in.message) { - NDR_CHECK(ndr_push_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.timeout)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.force_apps)); @@ -316,7 +217,7 @@ static enum ndr_err_code ndr_pull_initshutdown_InitEx(struct ndr_pull *ndr, int if (r->in.message) { _mem_save_message_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.message, 0); - NDR_CHECK(ndr_pull_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_message_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.timeout)); @@ -349,7 +250,7 @@ _PUBLIC_ void ndr_print_initshutdown_InitEx(struct ndr_print *ndr, const char *n ndr_print_ptr(ndr, "message", r->in.message); ndr->depth++; if (r->in.message) { - ndr_print_initshutdown_String(ndr, "message", r->in.message); + ndr_print_lsa_StringLarge(ndr, "message", r->in.message); } ndr->depth--; ndr_print_uint32(ndr, "timeout", r->in.timeout); diff --git a/source3/librpc/gen_ndr/ndr_initshutdown.h b/source3/librpc/gen_ndr/ndr_initshutdown.h index 9a19432678..2cb5a530b0 100644 --- a/source3/librpc/gen_ndr/ndr_initshutdown.h +++ b/source3/librpc/gen_ndr/ndr_initshutdown.h @@ -18,10 +18,6 @@ extern const struct ndr_interface_table ndr_table_initshutdown; #define NDR_INITSHUTDOWN_INITEX (0x02) #define NDR_INITSHUTDOWN_CALL_COUNT (3) -void ndr_print_initshutdown_String_sub(struct ndr_print *ndr, const char *name, const struct initshutdown_String_sub *r); -enum ndr_err_code ndr_push_initshutdown_String(struct ndr_push *ndr, int ndr_flags, const struct initshutdown_String *r); -enum ndr_err_code ndr_pull_initshutdown_String(struct ndr_pull *ndr, int ndr_flags, struct initshutdown_String *r); -void ndr_print_initshutdown_String(struct ndr_print *ndr, const char *name, const struct initshutdown_String *r); void ndr_print_initshutdown_Init(struct ndr_print *ndr, const char *name, int flags, const struct initshutdown_Init *r); void ndr_print_initshutdown_Abort(struct ndr_print *ndr, const char *name, int flags, const struct initshutdown_Abort *r); void ndr_print_initshutdown_InitEx(struct ndr_print *ndr, const char *name, int flags, const struct initshutdown_InitEx *r); diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.c b/source3/librpc/gen_ndr/ndr_krb5pac.c index 6e06f90a68..f9e93e5210 100644 --- a/source3/librpc/gen_ndr/ndr_krb5pac.c +++ b/source3/librpc/gen_ndr/ndr_krb5pac.c @@ -170,10 +170,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x00081001)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0xCCCCCCCC)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, NDR_ROUND(ndr_size_PAC_LOGON_INFO(r->info, ndr->flags) + 4, 8))); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x00000000)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->info)); } if (ndr_flags & NDR_BUFFERS) { @@ -190,10 +186,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_PAC_LOGON_INFO_CTR(struct ndr_pull *ndr, int TALLOC_CTX *_mem_save_info_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); if (_ptr_info) { NDR_PULL_ALLOC(ndr, r->info); @@ -216,10 +208,6 @@ _PUBLIC_ void ndr_print_PAC_LOGON_INFO_CTR(struct ndr_print *ndr, const char *na { ndr_print_struct(ndr, name, "PAC_LOGON_INFO_CTR"); ndr->depth++; - ndr_print_uint32(ndr, "unknown1", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x00081001:r->unknown1); - ndr_print_uint32(ndr, "unknown2", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0xCCCCCCCC:r->unknown2); - ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?NDR_ROUND(ndr_size_PAC_LOGON_INFO(r->info, ndr->flags) + 4, 8):r->_ndr_size); - ndr_print_uint32(ndr, "unknown3", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x00000000:r->unknown3); ndr_print_ptr(ndr, "info", r->info); ndr->depth++; if (r->info) { @@ -304,7 +292,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags int level = ndr_push_get_switch_value(ndr, r); switch (level) { case PAC_TYPE_LOGON_INFO: { - NDR_CHECK(ndr_push_PAC_LOGON_INFO_CTR(ndr, NDR_SCALARS, &r->logon_info)); + { + struct ndr_push *_ndr_logon_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_logon_info, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_push_PAC_LOGON_INFO_CTR(_ndr_logon_info, NDR_SCALARS|NDR_BUFFERS, &r->logon_info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_logon_info, 0xFFFFFC01, -1)); + } break; } case PAC_TYPE_SRV_CHECKSUM: { @@ -334,7 +327,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_PAC_INFO(struct ndr_push *ndr, int ndr_flags int level = ndr_push_get_switch_value(ndr, r); switch (level) { case PAC_TYPE_LOGON_INFO: - NDR_CHECK(ndr_push_PAC_LOGON_INFO_CTR(ndr, NDR_BUFFERS, &r->logon_info)); break; case PAC_TYPE_SRV_CHECKSUM: @@ -361,7 +353,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags if (ndr_flags & NDR_SCALARS) { switch (level) { case PAC_TYPE_LOGON_INFO: { - NDR_CHECK(ndr_pull_PAC_LOGON_INFO_CTR(ndr, NDR_SCALARS, &r->logon_info)); + { + struct ndr_pull *_ndr_logon_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_logon_info, 0xFFFFFC01, -1)); + NDR_CHECK(ndr_pull_PAC_LOGON_INFO_CTR(_ndr_logon_info, NDR_SCALARS|NDR_BUFFERS, &r->logon_info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_logon_info, 0xFFFFFC01, -1)); + } break; } case PAC_TYPE_SRV_CHECKSUM: { @@ -390,7 +387,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_PAC_INFO(struct ndr_pull *ndr, int ndr_flags if (ndr_flags & NDR_BUFFERS) { switch (level) { case PAC_TYPE_LOGON_INFO: - NDR_CHECK(ndr_pull_PAC_LOGON_INFO_CTR(ndr, NDR_BUFFERS, &r->logon_info)); break; case PAC_TYPE_SRV_CHECKSUM: @@ -672,6 +668,58 @@ _PUBLIC_ void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, co ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_PAC_Validate(struct ndr_push *ndr, int ndr_flags, const struct PAC_Validate *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, NETLOGON_GENERIC_KRB5_PAC_VALIDATE)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ChecksumLength)); + NDR_CHECK(ndr_push_int32(ndr, NDR_SCALARS, r->SignatureType)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->SignatureLength)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->ChecksumAndSignature)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_PAC_Validate(struct ndr_pull *ndr, int ndr_flags, struct PAC_Validate *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->MessageType)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ChecksumLength)); + NDR_CHECK(ndr_pull_int32(ndr, NDR_SCALARS, &r->SignatureType)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->SignatureLength)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->ChecksumAndSignature)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_PAC_Validate(struct ndr_print *ndr, const char *name, const struct PAC_Validate *r) +{ + ndr_print_struct(ndr, name, "PAC_Validate"); + ndr->depth++; + ndr_print_uint32(ndr, "MessageType", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?NETLOGON_GENERIC_KRB5_PAC_VALIDATE:r->MessageType); + ndr_print_uint32(ndr, "ChecksumLength", r->ChecksumLength); + ndr_print_int32(ndr, "SignatureType", r->SignatureType); + ndr_print_uint32(ndr, "SignatureLength", r->SignatureLength); + ndr_print_DATA_BLOB(ndr, "ChecksumAndSignature", r->ChecksumAndSignature); + ndr->depth--; +} + _PUBLIC_ enum ndr_err_code ndr_push_netsamlogoncache_entry(struct ndr_push *ndr, int ndr_flags, const struct netsamlogoncache_entry *r) { if (ndr_flags & NDR_SCALARS) { @@ -830,6 +878,47 @@ _PUBLIC_ void ndr_print_decode_login_info(struct ndr_print *ndr, const char *nam ndr->depth--; } +static enum ndr_err_code ndr_push_decode_pac_validate(struct ndr_push *ndr, int flags, const struct decode_pac_validate *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_PAC_Validate(ndr, NDR_SCALARS, &r->in.pac_validate)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_decode_pac_validate(struct ndr_pull *ndr, int flags, struct decode_pac_validate *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_PAC_Validate(ndr, NDR_SCALARS, &r->in.pac_validate)); + } + if (flags & NDR_OUT) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_decode_pac_validate(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac_validate *r) +{ + ndr_print_struct(ndr, name, "decode_pac_validate"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "decode_pac_validate"); + ndr->depth++; + ndr_print_PAC_Validate(ndr, "pac_validate", &r->in.pac_validate); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "decode_pac_validate"); + ndr->depth++; + ndr->depth--; + } + ndr->depth--; +} + static const struct ndr_interface_call krb5pac_calls[] = { { "decode_pac", @@ -855,6 +944,14 @@ static const struct ndr_interface_call krb5pac_calls[] = { (ndr_print_function_t) ndr_print_decode_login_info, false, }, + { + "decode_pac_validate", + sizeof(struct decode_pac_validate), + (ndr_push_flags_fn_t) ndr_push_decode_pac_validate, + (ndr_pull_flags_fn_t) ndr_pull_decode_pac_validate, + (ndr_print_function_t) ndr_print_decode_pac_validate, + false, + }, { NULL, 0, NULL, NULL, NULL, false } }; @@ -884,7 +981,7 @@ const struct ndr_interface_table ndr_table_krb5pac = { NDR_KRB5PAC_VERSION }, .helpstring = NDR_KRB5PAC_HELPSTRING, - .num_calls = 3, + .num_calls = 4, .calls = krb5pac_calls, .endpoints = &krb5pac_endpoints, .authservices = &krb5pac_authservices diff --git a/source3/librpc/gen_ndr/ndr_krb5pac.h b/source3/librpc/gen_ndr/ndr_krb5pac.h index 7f03106879..bf09e3fad5 100644 --- a/source3/librpc/gen_ndr/ndr_krb5pac.h +++ b/source3/librpc/gen_ndr/ndr_krb5pac.h @@ -17,7 +17,9 @@ extern const struct ndr_interface_table ndr_table_krb5pac; #define NDR_DECODE_LOGIN_INFO (0x02) -#define NDR_KRB5PAC_CALL_COUNT (3) +#define NDR_DECODE_PAC_VALIDATE (0x03) + +#define NDR_KRB5PAC_CALL_COUNT (4) void ndr_print_PAC_LOGON_NAME(struct ndr_print *ndr, const char *name, const struct PAC_LOGON_NAME *r); enum ndr_err_code ndr_push_PAC_SIGNATURE_DATA(struct ndr_push *ndr, int ndr_flags, const struct PAC_SIGNATURE_DATA *r); enum ndr_err_code ndr_pull_PAC_SIGNATURE_DATA(struct ndr_pull *ndr, int ndr_flags, struct PAC_SIGNATURE_DATA *r); @@ -46,10 +48,14 @@ void ndr_print_PAC_BUFFER_RAW(struct ndr_print *ndr, const char *name, const str enum ndr_err_code ndr_push_PAC_DATA_RAW(struct ndr_push *ndr, int ndr_flags, const struct PAC_DATA_RAW *r); enum ndr_err_code ndr_pull_PAC_DATA_RAW(struct ndr_pull *ndr, int ndr_flags, struct PAC_DATA_RAW *r); void ndr_print_PAC_DATA_RAW(struct ndr_print *ndr, const char *name, const struct PAC_DATA_RAW *r); +enum ndr_err_code ndr_push_PAC_Validate(struct ndr_push *ndr, int ndr_flags, const struct PAC_Validate *r); +enum ndr_err_code ndr_pull_PAC_Validate(struct ndr_pull *ndr, int ndr_flags, struct PAC_Validate *r); +void ndr_print_PAC_Validate(struct ndr_print *ndr, const char *name, const struct PAC_Validate *r); enum ndr_err_code ndr_push_netsamlogoncache_entry(struct ndr_push *ndr, int ndr_flags, const struct netsamlogoncache_entry *r); enum ndr_err_code ndr_pull_netsamlogoncache_entry(struct ndr_pull *ndr, int ndr_flags, struct netsamlogoncache_entry *r); void ndr_print_netsamlogoncache_entry(struct ndr_print *ndr, const char *name, const struct netsamlogoncache_entry *r); void ndr_print_decode_pac(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac *r); void ndr_print_decode_pac_raw(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac_raw *r); void ndr_print_decode_login_info(struct ndr_print *ndr, const char *name, int flags, const struct decode_login_info *r); +void ndr_print_decode_pac_validate(struct ndr_print *ndr, const char *name, int flags, const struct decode_pac_validate *r); #endif /* _HEADER_NDR_krb5pac */ diff --git a/source3/librpc/gen_ndr/ndr_libnetapi.c b/source3/librpc/gen_ndr/ndr_libnetapi.c index a5266827b6..d7bf63e62f 100644 --- a/source3/librpc/gen_ndr/ndr_libnetapi.c +++ b/source3/librpc/gen_ndr/ndr_libnetapi.c @@ -1895,7 +1895,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_USER_INFO_X(struct ndr_push *ndr, int ndr_fl NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_code_page)); NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->usriX_profile)); NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->usriX_home_dir_drive)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_user_id)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_primary_group_id)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->usriX_password_expired)); } if (ndr_flags & NDR_BUFFERS) { if (r->usriX_logon_hours) { @@ -1942,7 +1944,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_USER_INFO_X(struct ndr_pull *ndr, int ndr_fl NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_code_page)); NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->usriX_profile)); NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->usriX_home_dir_drive)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_user_id)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_primary_group_id)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->usriX_password_expired)); } if (ndr_flags & NDR_BUFFERS) { if (r->usriX_logon_hours) { @@ -1990,7 +1994,9 @@ _PUBLIC_ void ndr_print_USER_INFO_X(struct ndr_print *ndr, const char *name, con ndr_print_uint32(ndr, "usriX_code_page", r->usriX_code_page); ndr_print_string(ndr, "usriX_profile", r->usriX_profile); ndr_print_string(ndr, "usriX_home_dir_drive", r->usriX_home_dir_drive); + ndr_print_uint32(ndr, "usriX_user_id", r->usriX_user_id); ndr_print_uint32(ndr, "usriX_primary_group_id", r->usriX_primary_group_id); + ndr_print_uint32(ndr, "usriX_password_expired", r->usriX_password_expired); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index f25410ad27..926903865e 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -3,6 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_security.h" _PUBLIC_ enum ndr_err_code ndr_push_lsa_String(struct ndr_push *ndr, int ndr_flags, const struct lsa_String *r) { @@ -833,14 +834,13 @@ _PUBLIC_ void ndr_print_lsa_PolicyAccessMask(struct ndr_print *ndr, const char * static enum ndr_err_code ndr_push_lsa_AuditLogInfo(struct ndr_push *ndr, int ndr_flags, const struct lsa_AuditLogInfo *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_align(ndr, 8)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->percent_full)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->log_size)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->retention_time)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->maximum_log_size)); + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->retention_time)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->shutdown_in_progress)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->time_to_shutdown)); + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->time_to_shutdown)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->next_audit_record)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown)); } if (ndr_flags & NDR_BUFFERS) { } @@ -850,14 +850,13 @@ static enum ndr_err_code ndr_push_lsa_AuditLogInfo(struct ndr_push *ndr, int ndr static enum ndr_err_code ndr_pull_lsa_AuditLogInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditLogInfo *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->percent_full)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->log_size)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->retention_time)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->maximum_log_size)); + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->retention_time)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->shutdown_in_progress)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->time_to_shutdown)); + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->time_to_shutdown)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->next_audit_record)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown)); } if (ndr_flags & NDR_BUFFERS) { } @@ -869,12 +868,11 @@ _PUBLIC_ void ndr_print_lsa_AuditLogInfo(struct ndr_print *ndr, const char *name ndr_print_struct(ndr, name, "lsa_AuditLogInfo"); ndr->depth++; ndr_print_uint32(ndr, "percent_full", r->percent_full); - ndr_print_uint32(ndr, "log_size", r->log_size); - ndr_print_NTTIME(ndr, "retention_time", r->retention_time); + ndr_print_uint32(ndr, "maximum_log_size", r->maximum_log_size); + ndr_print_hyper(ndr, "retention_time", r->retention_time); ndr_print_uint8(ndr, "shutdown_in_progress", r->shutdown_in_progress); - ndr_print_NTTIME(ndr, "time_to_shutdown", r->time_to_shutdown); + ndr_print_hyper(ndr, "time_to_shutdown", r->time_to_shutdown); ndr_print_uint32(ndr, "next_audit_record", r->next_audit_record); - ndr_print_uint32(ndr, "unknown", r->unknown); ndr->depth--; } @@ -1077,12 +1075,36 @@ _PUBLIC_ void ndr_print_lsa_PDAccountInfo(struct ndr_print *ndr, const char *nam ndr->depth--; } +static enum ndr_err_code ndr_push_lsa_Role(struct ndr_push *ndr, int ndr_flags, enum lsa_Role r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_lsa_Role(struct ndr_pull *ndr, int ndr_flags, enum lsa_Role *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_Role(struct ndr_print *ndr, const char *name, enum lsa_Role r) +{ + const char *val = NULL; + + switch (r) { + case LSA_ROLE_BACKUP: val = "LSA_ROLE_BACKUP"; break; + case LSA_ROLE_PRIMARY: val = "LSA_ROLE_PRIMARY"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + static enum ndr_err_code ndr_push_lsa_ServerRole(struct ndr_push *ndr, int ndr_flags, const struct lsa_ServerRole *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 2)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->role)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_lsa_Role(ndr, NDR_SCALARS, r->role)); } if (ndr_flags & NDR_BUFFERS) { } @@ -1092,9 +1114,8 @@ static enum ndr_err_code ndr_push_lsa_ServerRole(struct ndr_push *ndr, int ndr_f static enum ndr_err_code ndr_pull_lsa_ServerRole(struct ndr_pull *ndr, int ndr_flags, struct lsa_ServerRole *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 2)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->role)); + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_lsa_Role(ndr, NDR_SCALARS, &r->role)); } if (ndr_flags & NDR_BUFFERS) { } @@ -1105,8 +1126,7 @@ _PUBLIC_ void ndr_print_lsa_ServerRole(struct ndr_print *ndr, const char *name, { ndr_print_struct(ndr, name, "lsa_ServerRole"); ndr->depth++; - ndr_print_uint16(ndr, "unknown", r->unknown); - ndr_print_uint16(ndr, "role", r->role); + ndr_print_lsa_Role(ndr, "role", r->role); ndr->depth--; } @@ -1197,7 +1217,7 @@ static enum ndr_err_code ndr_push_lsa_ModificationInfo(struct ndr_push *ndr, int if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 8)); NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->modified_id)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->db_create_time)); + NDR_CHECK(ndr_push_NTTIME_hyper(ndr, NDR_SCALARS, r->db_create_time)); } if (ndr_flags & NDR_BUFFERS) { } @@ -1209,7 +1229,7 @@ static enum ndr_err_code ndr_pull_lsa_ModificationInfo(struct ndr_pull *ndr, int if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->modified_id)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->db_create_time)); + NDR_CHECK(ndr_pull_NTTIME_hyper(ndr, NDR_SCALARS, &r->db_create_time)); } if (ndr_flags & NDR_BUFFERS) { } @@ -1221,7 +1241,7 @@ _PUBLIC_ void ndr_print_lsa_ModificationInfo(struct ndr_print *ndr, const char * ndr_print_struct(ndr, name, "lsa_ModificationInfo"); ndr->depth++; ndr_print_hyper(ndr, "modified_id", r->modified_id); - ndr_print_NTTIME(ndr, "db_create_time", r->db_create_time); + ndr_print_NTTIME_hyper(ndr, "db_create_time", r->db_create_time); ndr->depth--; } @@ -1258,8 +1278,7 @@ _PUBLIC_ void ndr_print_lsa_AuditFullSetInfo(struct ndr_print *ndr, const char * static enum ndr_err_code ndr_push_lsa_AuditFullQueryInfo(struct ndr_push *ndr, int ndr_flags, const struct lsa_AuditFullQueryInfo *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 2)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown)); + NDR_CHECK(ndr_push_align(ndr, 1)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->shutdown_on_full)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->log_is_full)); } @@ -1271,8 +1290,7 @@ static enum ndr_err_code ndr_push_lsa_AuditFullQueryInfo(struct ndr_push *ndr, i static enum ndr_err_code ndr_pull_lsa_AuditFullQueryInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditFullQueryInfo *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 2)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown)); + NDR_CHECK(ndr_pull_align(ndr, 1)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->shutdown_on_full)); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->log_is_full)); } @@ -1285,7 +1303,6 @@ _PUBLIC_ void ndr_print_lsa_AuditFullQueryInfo(struct ndr_print *ndr, const char { ndr_print_struct(ndr, name, "lsa_AuditFullQueryInfo"); ndr->depth++; - ndr_print_uint16(ndr, "unknown", r->unknown); ndr_print_uint8(ndr, "shutdown_on_full", r->shutdown_on_full); ndr_print_uint8(ndr, "log_is_full", r->log_is_full); ndr->depth--; @@ -1305,7 +1322,6 @@ static enum ndr_err_code ndr_push_lsa_DnsDomainInfo(struct ndr_push *ndr, int nd NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_BUFFERS, &r->name)); NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_BUFFERS, &r->dns_domain)); NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_BUFFERS, &r->dns_forest)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_guid)); if (r->sid) { NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->sid)); } @@ -1334,7 +1350,6 @@ static enum ndr_err_code ndr_pull_lsa_DnsDomainInfo(struct ndr_pull *ndr, int nd NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_BUFFERS, &r->name)); NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_BUFFERS, &r->dns_domain)); NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_BUFFERS, &r->dns_forest)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_guid)); if (r->sid) { _mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->sid, 0); @@ -1389,10 +1404,12 @@ _PUBLIC_ void ndr_print_lsa_PolicyInfo(struct ndr_print *ndr, const char *name, case LSA_POLICY_INFO_ROLE: val = "LSA_POLICY_INFO_ROLE"; break; case LSA_POLICY_INFO_REPLICA: val = "LSA_POLICY_INFO_REPLICA"; break; case LSA_POLICY_INFO_QUOTA: val = "LSA_POLICY_INFO_QUOTA"; break; - case LSA_POLICY_INFO_DB: val = "LSA_POLICY_INFO_DB"; break; + case LSA_POLICY_INFO_MOD: val = "LSA_POLICY_INFO_MOD"; break; case LSA_POLICY_INFO_AUDIT_FULL_SET: val = "LSA_POLICY_INFO_AUDIT_FULL_SET"; break; case LSA_POLICY_INFO_AUDIT_FULL_QUERY: val = "LSA_POLICY_INFO_AUDIT_FULL_QUERY"; break; case LSA_POLICY_INFO_DNS: val = "LSA_POLICY_INFO_DNS"; break; + case LSA_POLICY_INFO_DNS_INT: val = "LSA_POLICY_INFO_DNS_INT"; break; + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: val = "LSA_POLICY_INFO_L_ACCOUNT_DOMAIN"; break; } ndr_print_enum(ndr, name, "ENUM", val, r); } @@ -1435,8 +1452,8 @@ static enum ndr_err_code ndr_push_lsa_PolicyInformation(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_DefaultQuotaInfo(ndr, NDR_SCALARS, &r->quota)); break; } - case LSA_POLICY_INFO_DB: { - NDR_CHECK(ndr_push_lsa_ModificationInfo(ndr, NDR_SCALARS, &r->db)); + case LSA_POLICY_INFO_MOD: { + NDR_CHECK(ndr_push_lsa_ModificationInfo(ndr, NDR_SCALARS, &r->mod)); break; } case LSA_POLICY_INFO_AUDIT_FULL_SET: { @@ -1451,6 +1468,14 @@ static enum ndr_err_code ndr_push_lsa_PolicyInformation(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_DnsDomainInfo(ndr, NDR_SCALARS, &r->dns)); break; } + case LSA_POLICY_INFO_DNS_INT: { + NDR_CHECK(ndr_push_lsa_DnsDomainInfo(ndr, NDR_SCALARS, &r->dns)); + break; } + + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: { + NDR_CHECK(ndr_push_lsa_DomainInfo(ndr, NDR_SCALARS, &r->l_account_domain)); + break; } + default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -1487,7 +1512,7 @@ static enum ndr_err_code ndr_push_lsa_PolicyInformation(struct ndr_push *ndr, in case LSA_POLICY_INFO_QUOTA: break; - case LSA_POLICY_INFO_DB: + case LSA_POLICY_INFO_MOD: break; case LSA_POLICY_INFO_AUDIT_FULL_SET: @@ -1500,6 +1525,14 @@ static enum ndr_err_code ndr_push_lsa_PolicyInformation(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_DnsDomainInfo(ndr, NDR_BUFFERS, &r->dns)); break; + case LSA_POLICY_INFO_DNS_INT: + NDR_CHECK(ndr_push_lsa_DnsDomainInfo(ndr, NDR_BUFFERS, &r->dns)); + break; + + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: + NDR_CHECK(ndr_push_lsa_DomainInfo(ndr, NDR_BUFFERS, &r->l_account_domain)); + break; + default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -1550,8 +1583,8 @@ static enum ndr_err_code ndr_pull_lsa_PolicyInformation(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_DefaultQuotaInfo(ndr, NDR_SCALARS, &r->quota)); break; } - case LSA_POLICY_INFO_DB: { - NDR_CHECK(ndr_pull_lsa_ModificationInfo(ndr, NDR_SCALARS, &r->db)); + case LSA_POLICY_INFO_MOD: { + NDR_CHECK(ndr_pull_lsa_ModificationInfo(ndr, NDR_SCALARS, &r->mod)); break; } case LSA_POLICY_INFO_AUDIT_FULL_SET: { @@ -1566,6 +1599,14 @@ static enum ndr_err_code ndr_pull_lsa_PolicyInformation(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_DnsDomainInfo(ndr, NDR_SCALARS, &r->dns)); break; } + case LSA_POLICY_INFO_DNS_INT: { + NDR_CHECK(ndr_pull_lsa_DnsDomainInfo(ndr, NDR_SCALARS, &r->dns)); + break; } + + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: { + NDR_CHECK(ndr_pull_lsa_DomainInfo(ndr, NDR_SCALARS, &r->l_account_domain)); + break; } + default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -1601,7 +1642,7 @@ static enum ndr_err_code ndr_pull_lsa_PolicyInformation(struct ndr_pull *ndr, in case LSA_POLICY_INFO_QUOTA: break; - case LSA_POLICY_INFO_DB: + case LSA_POLICY_INFO_MOD: break; case LSA_POLICY_INFO_AUDIT_FULL_SET: @@ -1614,6 +1655,14 @@ static enum ndr_err_code ndr_pull_lsa_PolicyInformation(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_DnsDomainInfo(ndr, NDR_BUFFERS, &r->dns)); break; + case LSA_POLICY_INFO_DNS_INT: + NDR_CHECK(ndr_pull_lsa_DnsDomainInfo(ndr, NDR_BUFFERS, &r->dns)); + break; + + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: + NDR_CHECK(ndr_pull_lsa_DomainInfo(ndr, NDR_BUFFERS, &r->l_account_domain)); + break; + default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -1659,8 +1708,8 @@ _PUBLIC_ void ndr_print_lsa_PolicyInformation(struct ndr_print *ndr, const char ndr_print_lsa_DefaultQuotaInfo(ndr, "quota", &r->quota); break; - case LSA_POLICY_INFO_DB: - ndr_print_lsa_ModificationInfo(ndr, "db", &r->db); + case LSA_POLICY_INFO_MOD: + ndr_print_lsa_ModificationInfo(ndr, "mod", &r->mod); break; case LSA_POLICY_INFO_AUDIT_FULL_SET: @@ -1675,6 +1724,14 @@ _PUBLIC_ void ndr_print_lsa_PolicyInformation(struct ndr_print *ndr, const char ndr_print_lsa_DnsDomainInfo(ndr, "dns", &r->dns); break; + case LSA_POLICY_INFO_DNS_INT: + ndr_print_lsa_DnsDomainInfo(ndr, "dns", &r->dns); + break; + + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: + ndr_print_lsa_DomainInfo(ndr, "l_account_domain", &r->l_account_domain); + break; + default: ndr_print_bad_level(ndr, name, level); } @@ -1906,13 +1963,13 @@ _PUBLIC_ void ndr_print_lsa_DomainList(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_lsa_SidType(struct ndr_push *ndr, int ndr_flags, enum lsa_SidType r) +_PUBLIC_ enum ndr_err_code ndr_push_lsa_SidType(struct ndr_push *ndr, int ndr_flags, enum lsa_SidType r) { NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_lsa_SidType(struct ndr_pull *ndr, int ndr_flags, enum lsa_SidType *r) +_PUBLIC_ enum ndr_err_code ndr_pull_lsa_SidType(struct ndr_pull *ndr, int ndr_flags, enum lsa_SidType *r) { uint16_t v; NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); @@ -2175,6 +2232,7 @@ _PUBLIC_ void ndr_print_lsa_LookupNamesLevel(struct ndr_print *ndr, const char * case LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY: val = "LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY"; break; case LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY: val = "LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY"; break; case LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2: val = "LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2"; break; + case LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC: val = "LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC"; break; } ndr_print_enum(ndr, name, "ENUM", val, r); } @@ -2589,19 +2647,100 @@ _PUBLIC_ void ndr_print_lsa_TrustDomInfoEnum(struct ndr_print *ndr, const char * switch (r) { case LSA_TRUSTED_DOMAIN_INFO_NAME: val = "LSA_TRUSTED_DOMAIN_INFO_NAME"; break; - case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO: val = "LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO"; break; + case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS: val = "LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS"; break; case LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET: val = "LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET"; break; case LSA_TRUSTED_DOMAIN_INFO_PASSWORD: val = "LSA_TRUSTED_DOMAIN_INFO_PASSWORD"; break; case LSA_TRUSTED_DOMAIN_INFO_BASIC: val = "LSA_TRUSTED_DOMAIN_INFO_BASIC"; break; case LSA_TRUSTED_DOMAIN_INFO_INFO_EX: val = "LSA_TRUSTED_DOMAIN_INFO_INFO_EX"; break; case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO: val = "LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO"; break; case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO: val = "LSA_TRUSTED_DOMAIN_INFO_FULL_INFO"; break; - case LSA_TRUSTED_DOMAIN_INFO_11: val = "LSA_TRUSTED_DOMAIN_INFO_11"; break; - case LSA_TRUSTED_DOMAIN_INFO_INFO_ALL: val = "LSA_TRUSTED_DOMAIN_INFO_INFO_ALL"; break; + case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL: val = "LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL"; break; + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL: val = "LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL"; break; + case LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL: val = "LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL"; break; + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL: val = "LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL"; break; + case LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES: val = "LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES"; break; } ndr_print_enum(ndr, name, "ENUM", val, r); } +_PUBLIC_ enum ndr_err_code ndr_push_lsa_TrustDirection(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_lsa_TrustDirection(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustDirection(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_DIRECTION_INBOUND", LSA_TRUST_DIRECTION_INBOUND, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_DIRECTION_OUTBOUND", LSA_TRUST_DIRECTION_OUTBOUND, r); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_lsa_TrustType(struct ndr_push *ndr, int ndr_flags, enum lsa_TrustType r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_lsa_TrustType(struct ndr_pull *ndr, int ndr_flags, enum lsa_TrustType *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustType(struct ndr_print *ndr, const char *name, enum lsa_TrustType r) +{ + const char *val = NULL; + + switch (r) { + case LSA_TRUST_TYPE_DOWNLEVEL: val = "LSA_TRUST_TYPE_DOWNLEVEL"; break; + case LSA_TRUST_TYPE_UPLEVEL: val = "LSA_TRUST_TYPE_UPLEVEL"; break; + case LSA_TRUST_TYPE_MIT: val = "LSA_TRUST_TYPE_MIT"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +_PUBLIC_ enum ndr_err_code ndr_push_lsa_TrustAttributes(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_lsa_TrustAttributes(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustAttributes(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE", LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_UPLEVEL_ONLY", LSA_TRUST_ATTRIBUTE_UPLEVEL_ONLY, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN", LSA_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE", LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION", LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_WITHIN_FOREST", LSA_TRUST_ATTRIBUTE_WITHIN_FOREST, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL", LSA_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION", LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION, r); + ndr->depth--; +} + static enum ndr_err_code ndr_push_lsa_TrustDomainInfoName(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoName *r) { if (ndr_flags & NDR_SCALARS) { @@ -2634,6 +2773,92 @@ _PUBLIC_ void ndr_print_lsa_TrustDomainInfoName(struct ndr_print *ndr, const cha ndr->depth--; } +static enum ndr_err_code ndr_push_lsa_TrustDomainInfoControllers(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoControllers *r) +{ + uint32_t cntr_netbios_names_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->entries)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->netbios_names)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->netbios_names) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->entries)); + for (cntr_netbios_names_1 = 0; cntr_netbios_names_1 < r->entries; cntr_netbios_names_1++) { + NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS, &r->netbios_names[cntr_netbios_names_1])); + } + for (cntr_netbios_names_1 = 0; cntr_netbios_names_1 < r->entries; cntr_netbios_names_1++) { + NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_BUFFERS, &r->netbios_names[cntr_netbios_names_1])); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoControllers(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoControllers *r) +{ + uint32_t _ptr_netbios_names; + uint32_t cntr_netbios_names_1; + TALLOC_CTX *_mem_save_netbios_names_0; + TALLOC_CTX *_mem_save_netbios_names_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->entries)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_netbios_names)); + if (_ptr_netbios_names) { + NDR_PULL_ALLOC(ndr, r->netbios_names); + } else { + r->netbios_names = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->netbios_names) { + _mem_save_netbios_names_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->netbios_names, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->netbios_names)); + NDR_PULL_ALLOC_N(ndr, r->netbios_names, ndr_get_array_size(ndr, &r->netbios_names)); + _mem_save_netbios_names_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->netbios_names, 0); + for (cntr_netbios_names_1 = 0; cntr_netbios_names_1 < r->entries; cntr_netbios_names_1++) { + NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_SCALARS, &r->netbios_names[cntr_netbios_names_1])); + } + for (cntr_netbios_names_1 = 0; cntr_netbios_names_1 < r->entries; cntr_netbios_names_1++) { + NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_BUFFERS, &r->netbios_names[cntr_netbios_names_1])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_netbios_names_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_netbios_names_0, 0); + } + if (r->netbios_names) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->netbios_names, r->entries)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustDomainInfoControllers(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoControllers *r) +{ + uint32_t cntr_netbios_names_1; + ndr_print_struct(ndr, name, "lsa_TrustDomainInfoControllers"); + ndr->depth++; + ndr_print_uint32(ndr, "entries", r->entries); + ndr_print_ptr(ndr, "netbios_names", r->netbios_names); + ndr->depth++; + if (r->netbios_names) { + ndr->print(ndr, "%s: ARRAY(%d)", "netbios_names", (int)r->entries); + ndr->depth++; + for (cntr_netbios_names_1=0;cntr_netbios_names_1entries;cntr_netbios_names_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_netbios_names_1) != -1) { + ndr_print_lsa_StringLarge(ndr, "netbios_names", &r->netbios_names[cntr_netbios_names_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr->depth--; +} + static enum ndr_err_code ndr_push_lsa_TrustDomainInfoPosixOffset(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoPosixOffset *r) { if (ndr_flags & NDR_SCALARS) { @@ -2802,9 +3027,9 @@ static enum ndr_err_code ndr_push_lsa_TrustDomainInfoInfoEx(struct ndr_push *ndr NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS, &r->domain_name)); NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS, &r->netbios_name)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->sid)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->trust_direction)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->trust_type)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->trust_attributes)); + NDR_CHECK(ndr_push_lsa_TrustDirection(ndr, NDR_SCALARS, r->trust_direction)); + NDR_CHECK(ndr_push_lsa_TrustType(ndr, NDR_SCALARS, r->trust_type)); + NDR_CHECK(ndr_push_lsa_TrustAttributes(ndr, NDR_SCALARS, r->trust_attributes)); } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_BUFFERS, &r->domain_name)); @@ -2830,9 +3055,9 @@ static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoInfoEx(struct ndr_pull *ndr } else { r->sid = NULL; } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->trust_direction)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->trust_type)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->trust_attributes)); + NDR_CHECK(ndr_pull_lsa_TrustDirection(ndr, NDR_SCALARS, &r->trust_direction)); + NDR_CHECK(ndr_pull_lsa_TrustType(ndr, NDR_SCALARS, &r->trust_type)); + NDR_CHECK(ndr_pull_lsa_TrustAttributes(ndr, NDR_SCALARS, &r->trust_attributes)); } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_BUFFERS, &r->domain_name)); @@ -2859,18 +3084,45 @@ _PUBLIC_ void ndr_print_lsa_TrustDomainInfoInfoEx(struct ndr_print *ndr, const c ndr_print_dom_sid2(ndr, "sid", r->sid); } ndr->depth--; - ndr_print_uint32(ndr, "trust_direction", r->trust_direction); - ndr_print_uint32(ndr, "trust_type", r->trust_type); - ndr_print_uint32(ndr, "trust_attributes", r->trust_attributes); + ndr_print_lsa_TrustDirection(ndr, "trust_direction", r->trust_direction); + ndr_print_lsa_TrustType(ndr, "trust_type", r->trust_type); + ndr_print_lsa_TrustAttributes(ndr, "trust_attributes", r->trust_attributes); ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_lsa_TrustAuthType(struct ndr_push *ndr, int ndr_flags, enum lsa_TrustAuthType r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_lsa_TrustAuthType(struct ndr_pull *ndr, int ndr_flags, enum lsa_TrustAuthType *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustAuthType(struct ndr_print *ndr, const char *name, enum lsa_TrustAuthType r) +{ + const char *val = NULL; + + switch (r) { + case TRUST_AUTH_TYPE_NONE: val = "TRUST_AUTH_TYPE_NONE"; break; + case TRUST_AUTH_TYPE_NT4OWF: val = "TRUST_AUTH_TYPE_NT4OWF"; break; + case TRUST_AUTH_TYPE_CLEAR: val = "TRUST_AUTH_TYPE_CLEAR"; break; + case TRUST_AUTH_TYPE_VERSION: val = "TRUST_AUTH_TYPE_VERSION"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + static enum ndr_err_code ndr_push_lsa_TrustDomainInfoBuffer(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoBuffer *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 8)); NDR_CHECK(ndr_push_NTTIME_hyper(ndr, NDR_SCALARS, r->last_update_time)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->secret_type)); + NDR_CHECK(ndr_push_lsa_TrustAuthType(ndr, NDR_SCALARS, r->AuthType)); NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->data)); } if (ndr_flags & NDR_BUFFERS) { @@ -2884,7 +3136,7 @@ static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoBuffer(struct ndr_pull *ndr if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_NTTIME_hyper(ndr, NDR_SCALARS, &r->last_update_time)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->secret_type)); + NDR_CHECK(ndr_pull_lsa_TrustAuthType(ndr, NDR_SCALARS, &r->AuthType)); NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->data)); } if (ndr_flags & NDR_BUFFERS) { @@ -2898,7 +3150,7 @@ _PUBLIC_ void ndr_print_lsa_TrustDomainInfoBuffer(struct ndr_print *ndr, const c ndr_print_struct(ndr, name, "lsa_TrustDomainInfoBuffer"); ndr->depth++; ndr_print_NTTIME_hyper(ndr, "last_update_time", r->last_update_time); - ndr_print_uint32(ndr, "secret_type", r->secret_type); + ndr_print_lsa_TrustAuthType(ndr, "AuthType", r->AuthType); ndr_print_lsa_DATA_BUF2(ndr, "data", &r->data); ndr->depth--; } @@ -3072,88 +3324,213 @@ _PUBLIC_ void ndr_print_lsa_TrustDomainInfoFullInfo(struct ndr_print *ndr, const ndr->depth--; } -static enum ndr_err_code ndr_push_lsa_TrustDomainInfo11(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfo11 *r) +static enum ndr_err_code ndr_push_lsa_TrustDomainInfoAuthInfoInternal(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoAuthInfoInternal *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->auth_blob)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_BUFFERS, &r->auth_blob)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoAuthInfoInternal *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->auth_blob)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_BUFFERS, &r->auth_blob)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustDomainInfoAuthInfoInternal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoAuthInfoInternal *r) +{ + ndr_print_struct(ndr, name, "lsa_TrustDomainInfoAuthInfoInternal"); + ndr->depth++; + ndr_print_lsa_DATA_BUF2(ndr, "auth_blob", &r->auth_blob); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_lsa_TrustDomainInfoFullInfoInternal(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoFullInfoInternal *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS, &r->info_ex)); - NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->data1)); + NDR_CHECK(ndr_push_lsa_TrustDomainInfoPosixOffset(ndr, NDR_SCALARS, &r->posix_offset)); + NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS, &r->auth_info)); } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_BUFFERS, &r->info_ex)); - NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_BUFFERS, &r->data1)); + NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_BUFFERS, &r->auth_info)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_lsa_TrustDomainInfo11(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfo11 *r) +static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoFullInfoInternal(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoFullInfoInternal *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS, &r->info_ex)); - NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->data1)); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoPosixOffset(ndr, NDR_SCALARS, &r->posix_offset)); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS, &r->auth_info)); } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_BUFFERS, &r->info_ex)); - NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_BUFFERS, &r->data1)); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_BUFFERS, &r->auth_info)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_lsa_TrustDomainInfo11(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfo11 *r) +_PUBLIC_ void ndr_print_lsa_TrustDomainInfoFullInfoInternal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoFullInfoInternal *r) { - ndr_print_struct(ndr, name, "lsa_TrustDomainInfo11"); + ndr_print_struct(ndr, name, "lsa_TrustDomainInfoFullInfoInternal"); ndr->depth++; ndr_print_lsa_TrustDomainInfoInfoEx(ndr, "info_ex", &r->info_ex); - ndr_print_lsa_DATA_BUF2(ndr, "data1", &r->data1); + ndr_print_lsa_TrustDomainInfoPosixOffset(ndr, "posix_offset", &r->posix_offset); + ndr_print_lsa_TrustDomainInfoAuthInfoInternal(ndr, "auth_info", &r->auth_info); ndr->depth--; } -static enum ndr_err_code ndr_push_lsa_TrustDomainInfoInfoAll(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoInfoAll *r) +static enum ndr_err_code ndr_push_lsa_TrustDomainInfoInfoEx2Internal(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoInfoEx2Internal *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS, &r->info_ex)); - NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->data1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->forest_trust_length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->forest_trust_data)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_BUFFERS, &r->info_ex)); + if (r->forest_trust_data) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->forest_trust_length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->forest_trust_data, r->forest_trust_length)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoInfoEx2Internal(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoInfoEx2Internal *r) +{ + uint32_t _ptr_forest_trust_data; + TALLOC_CTX *_mem_save_forest_trust_data_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS, &r->info_ex)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->forest_trust_length)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_forest_trust_data)); + if (_ptr_forest_trust_data) { + NDR_PULL_ALLOC(ndr, r->forest_trust_data); + } else { + r->forest_trust_data = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_BUFFERS, &r->info_ex)); + if (r->forest_trust_data) { + _mem_save_forest_trust_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->forest_trust_data, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->forest_trust_data)); + NDR_PULL_ALLOC_N(ndr, r->forest_trust_data, ndr_get_array_size(ndr, &r->forest_trust_data)); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->forest_trust_data, ndr_get_array_size(ndr, &r->forest_trust_data))); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_forest_trust_data_0, 0); + } + if (r->forest_trust_data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->forest_trust_data, r->forest_trust_length)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustDomainInfoInfoEx2Internal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoEx2Internal *r) +{ + ndr_print_struct(ndr, name, "lsa_TrustDomainInfoInfoEx2Internal"); + ndr->depth++; + ndr_print_lsa_TrustDomainInfoInfoEx(ndr, "info_ex", &r->info_ex); + ndr_print_uint32(ndr, "forest_trust_length", r->forest_trust_length); + ndr_print_ptr(ndr, "forest_trust_data", r->forest_trust_data); + ndr->depth++; + if (r->forest_trust_data) { + ndr_print_array_uint8(ndr, "forest_trust_data", r->forest_trust_data, r->forest_trust_length); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_lsa_TrustDomainInfoFullInfo2Internal(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoFullInfo2Internal *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_SCALARS, &r->info)); NDR_CHECK(ndr_push_lsa_TrustDomainInfoPosixOffset(ndr, NDR_SCALARS, &r->posix_offset)); NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfo(ndr, NDR_SCALARS, &r->auth_info)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_BUFFERS, &r->info_ex)); - NDR_CHECK(ndr_push_lsa_DATA_BUF2(ndr, NDR_BUFFERS, &r->data1)); + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_BUFFERS, &r->info)); NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfo(ndr, NDR_BUFFERS, &r->auth_info)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoInfoAll(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoInfoAll *r) +static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoFullInfo2Internal(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoFullInfo2Internal *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS, &r->info_ex)); - NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_SCALARS, &r->data1)); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_SCALARS, &r->info)); NDR_CHECK(ndr_pull_lsa_TrustDomainInfoPosixOffset(ndr, NDR_SCALARS, &r->posix_offset)); NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfo(ndr, NDR_SCALARS, &r->auth_info)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_BUFFERS, &r->info_ex)); - NDR_CHECK(ndr_pull_lsa_DATA_BUF2(ndr, NDR_BUFFERS, &r->data1)); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_BUFFERS, &r->info)); NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfo(ndr, NDR_BUFFERS, &r->auth_info)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_lsa_TrustDomainInfoInfoAll(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoAll *r) +_PUBLIC_ void ndr_print_lsa_TrustDomainInfoFullInfo2Internal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoFullInfo2Internal *r) { - ndr_print_struct(ndr, name, "lsa_TrustDomainInfoInfoAll"); + ndr_print_struct(ndr, name, "lsa_TrustDomainInfoFullInfo2Internal"); ndr->depth++; - ndr_print_lsa_TrustDomainInfoInfoEx(ndr, "info_ex", &r->info_ex); - ndr_print_lsa_DATA_BUF2(ndr, "data1", &r->data1); + ndr_print_lsa_TrustDomainInfoInfoEx2Internal(ndr, "info", &r->info); ndr_print_lsa_TrustDomainInfoPosixOffset(ndr, "posix_offset", &r->posix_offset); ndr_print_lsa_TrustDomainInfoAuthInfo(ndr, "auth_info", &r->auth_info); ndr->depth--; } +static enum ndr_err_code ndr_push_lsa_TrustDomainInfoSupportedEncTypes(struct ndr_push *ndr, int ndr_flags, const struct lsa_TrustDomainInfoSupportedEncTypes *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_kerb_EncTypes(ndr, NDR_SCALARS, r->enc_types)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_lsa_TrustDomainInfoSupportedEncTypes(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustDomainInfoSupportedEncTypes *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_kerb_EncTypes(ndr, NDR_SCALARS, &r->enc_types)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_lsa_TrustDomainInfoSupportedEncTypes(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoSupportedEncTypes *r) +{ + ndr_print_struct(ndr, name, "lsa_TrustDomainInfoSupportedEncTypes"); + ndr->depth++; + ndr_print_kerb_EncTypes(ndr, "enc_types", r->enc_types); + ndr->depth--; +} + static enum ndr_err_code ndr_push_lsa_TrustedDomainInfo(struct ndr_push *ndr, int ndr_flags, const union lsa_TrustedDomainInfo *r) { if (ndr_flags & NDR_SCALARS) { @@ -3164,6 +3541,10 @@ static enum ndr_err_code ndr_push_lsa_TrustedDomainInfo(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_TrustDomainInfoName(ndr, NDR_SCALARS, &r->name)); break; } + case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS: { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoControllers(ndr, NDR_SCALARS, &r->controllers)); + break; } + case LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET: { NDR_CHECK(ndr_push_lsa_TrustDomainInfoPosixOffset(ndr, NDR_SCALARS, &r->posix_offset)); break; } @@ -3188,12 +3569,24 @@ static enum ndr_err_code ndr_push_lsa_TrustedDomainInfo(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_TrustDomainInfoFullInfo(ndr, NDR_SCALARS, &r->full_info)); break; } - case LSA_TRUSTED_DOMAIN_INFO_11: { - NDR_CHECK(ndr_push_lsa_TrustDomainInfo11(ndr, NDR_SCALARS, &r->info11)); + case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL: { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS, &r->auth_info_internal)); + break; } + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL: { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoFullInfoInternal(ndr, NDR_SCALARS, &r->full_info_internal)); + break; } + + case LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL: { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_SCALARS, &r->info_ex2_internal)); + break; } + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL: { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoFullInfo2Internal(ndr, NDR_SCALARS, &r->full_info2_internal)); break; } - case LSA_TRUSTED_DOMAIN_INFO_INFO_ALL: { - NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoAll(ndr, NDR_SCALARS, &r->info_all)); + case LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES: { + NDR_CHECK(ndr_push_lsa_TrustDomainInfoSupportedEncTypes(ndr, NDR_SCALARS, &r->enc_types)); break; } default: @@ -3207,6 +3600,10 @@ static enum ndr_err_code ndr_push_lsa_TrustedDomainInfo(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_TrustDomainInfoName(ndr, NDR_BUFFERS, &r->name)); break; + case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS: + NDR_CHECK(ndr_push_lsa_TrustDomainInfoControllers(ndr, NDR_BUFFERS, &r->controllers)); + break; + case LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET: break; @@ -3230,12 +3627,23 @@ static enum ndr_err_code ndr_push_lsa_TrustedDomainInfo(struct ndr_push *ndr, in NDR_CHECK(ndr_push_lsa_TrustDomainInfoFullInfo(ndr, NDR_BUFFERS, &r->full_info)); break; - case LSA_TRUSTED_DOMAIN_INFO_11: - NDR_CHECK(ndr_push_lsa_TrustDomainInfo11(ndr, NDR_BUFFERS, &r->info11)); + case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL: + NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_BUFFERS, &r->auth_info_internal)); + break; + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL: + NDR_CHECK(ndr_push_lsa_TrustDomainInfoFullInfoInternal(ndr, NDR_BUFFERS, &r->full_info_internal)); + break; + + case LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL: + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_BUFFERS, &r->info_ex2_internal)); + break; + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL: + NDR_CHECK(ndr_push_lsa_TrustDomainInfoFullInfo2Internal(ndr, NDR_BUFFERS, &r->full_info2_internal)); break; - case LSA_TRUSTED_DOMAIN_INFO_INFO_ALL: - NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoAll(ndr, NDR_BUFFERS, &r->info_all)); + case LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES: break; default: @@ -3260,6 +3668,10 @@ static enum ndr_err_code ndr_pull_lsa_TrustedDomainInfo(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_TrustDomainInfoName(ndr, NDR_SCALARS, &r->name)); break; } + case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS: { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoControllers(ndr, NDR_SCALARS, &r->controllers)); + break; } + case LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET: { NDR_CHECK(ndr_pull_lsa_TrustDomainInfoPosixOffset(ndr, NDR_SCALARS, &r->posix_offset)); break; } @@ -3284,12 +3696,24 @@ static enum ndr_err_code ndr_pull_lsa_TrustedDomainInfo(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_TrustDomainInfoFullInfo(ndr, NDR_SCALARS, &r->full_info)); break; } - case LSA_TRUSTED_DOMAIN_INFO_11: { - NDR_CHECK(ndr_pull_lsa_TrustDomainInfo11(ndr, NDR_SCALARS, &r->info11)); + case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL: { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS, &r->auth_info_internal)); + break; } + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL: { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoFullInfoInternal(ndr, NDR_SCALARS, &r->full_info_internal)); + break; } + + case LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL: { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_SCALARS, &r->info_ex2_internal)); + break; } + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL: { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoFullInfo2Internal(ndr, NDR_SCALARS, &r->full_info2_internal)); break; } - case LSA_TRUSTED_DOMAIN_INFO_INFO_ALL: { - NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoAll(ndr, NDR_SCALARS, &r->info_all)); + case LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES: { + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoSupportedEncTypes(ndr, NDR_SCALARS, &r->enc_types)); break; } default: @@ -3302,6 +3726,10 @@ static enum ndr_err_code ndr_pull_lsa_TrustedDomainInfo(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_TrustDomainInfoName(ndr, NDR_BUFFERS, &r->name)); break; + case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS: + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoControllers(ndr, NDR_BUFFERS, &r->controllers)); + break; + case LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET: break; @@ -3325,12 +3753,23 @@ static enum ndr_err_code ndr_pull_lsa_TrustedDomainInfo(struct ndr_pull *ndr, in NDR_CHECK(ndr_pull_lsa_TrustDomainInfoFullInfo(ndr, NDR_BUFFERS, &r->full_info)); break; - case LSA_TRUSTED_DOMAIN_INFO_11: - NDR_CHECK(ndr_pull_lsa_TrustDomainInfo11(ndr, NDR_BUFFERS, &r->info11)); + case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL: + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_BUFFERS, &r->auth_info_internal)); + break; + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL: + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoFullInfoInternal(ndr, NDR_BUFFERS, &r->full_info_internal)); + break; + + case LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL: + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx2Internal(ndr, NDR_BUFFERS, &r->info_ex2_internal)); + break; + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL: + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoFullInfo2Internal(ndr, NDR_BUFFERS, &r->full_info2_internal)); break; - case LSA_TRUSTED_DOMAIN_INFO_INFO_ALL: - NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoAll(ndr, NDR_BUFFERS, &r->info_all)); + case LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES: break; default: @@ -3350,6 +3789,10 @@ _PUBLIC_ void ndr_print_lsa_TrustedDomainInfo(struct ndr_print *ndr, const char ndr_print_lsa_TrustDomainInfoName(ndr, "name", &r->name); break; + case LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS: + ndr_print_lsa_TrustDomainInfoControllers(ndr, "controllers", &r->controllers); + break; + case LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET: ndr_print_lsa_TrustDomainInfoPosixOffset(ndr, "posix_offset", &r->posix_offset); break; @@ -3374,12 +3817,24 @@ _PUBLIC_ void ndr_print_lsa_TrustedDomainInfo(struct ndr_print *ndr, const char ndr_print_lsa_TrustDomainInfoFullInfo(ndr, "full_info", &r->full_info); break; - case LSA_TRUSTED_DOMAIN_INFO_11: - ndr_print_lsa_TrustDomainInfo11(ndr, "info11", &r->info11); + case LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL: + ndr_print_lsa_TrustDomainInfoAuthInfoInternal(ndr, "auth_info_internal", &r->auth_info_internal); + break; + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL: + ndr_print_lsa_TrustDomainInfoFullInfoInternal(ndr, "full_info_internal", &r->full_info_internal); + break; + + case LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL: + ndr_print_lsa_TrustDomainInfoInfoEx2Internal(ndr, "info_ex2_internal", &r->info_ex2_internal); + break; + + case LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL: + ndr_print_lsa_TrustDomainInfoFullInfo2Internal(ndr, "full_info2_internal", &r->full_info2_internal); break; - case LSA_TRUSTED_DOMAIN_INFO_INFO_ALL: - ndr_print_lsa_TrustDomainInfoInfoAll(ndr, "info_all", &r->info_all); + case LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES: + ndr_print_lsa_TrustDomainInfoSupportedEncTypes(ndr, "enc_types", &r->enc_types); break; default: @@ -4070,7 +4525,7 @@ static enum ndr_err_code ndr_push_lsa_TranslatedSid3(struct ndr_push *ndr, int n NDR_CHECK(ndr_push_lsa_SidType(ndr, NDR_SCALARS, r->sid_type)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->sid)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sid_index)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags)); } if (ndr_flags & NDR_BUFFERS) { if (r->sid) { @@ -4094,7 +4549,7 @@ static enum ndr_err_code ndr_pull_lsa_TranslatedSid3(struct ndr_pull *ndr, int n r->sid = NULL; } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_index)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags)); } if (ndr_flags & NDR_BUFFERS) { if (r->sid) { @@ -4119,7 +4574,7 @@ _PUBLIC_ void ndr_print_lsa_TranslatedSid3(struct ndr_print *ndr, const char *na } ndr->depth--; ndr_print_uint32(ndr, "sid_index", r->sid_index); - ndr_print_uint32(ndr, "unknown", r->unknown); + ndr_print_uint32(ndr, "flags", r->flags); ndr->depth--; } @@ -4645,13 +5100,13 @@ static enum ndr_err_code ndr_push_lsa_Close(struct ndr_push *ndr, int flags, con if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -4668,7 +5123,7 @@ static enum ndr_err_code ndr_pull_lsa_Close(struct ndr_pull *ndr, int flags, str } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.handle); *r->out.handle = *r->in.handle; @@ -4679,7 +5134,7 @@ static enum ndr_err_code ndr_pull_lsa_Close(struct ndr_pull *ndr, int flags, str } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -4721,7 +5176,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_Delete(struct ndr_push *ndr, int flags, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); @@ -4738,7 +5193,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_Delete(struct ndr_pull *ndr, int flags, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { @@ -4778,7 +5233,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_EnumPrivs(struct ndr_push *ndr, int flag if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.resume_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -4812,7 +5267,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_EnumPrivs(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.resume_handle); @@ -4891,7 +5346,7 @@ static enum ndr_err_code ndr_push_lsa_QuerySecurity(struct ndr_push *ndr, int fl if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_security_secinfo(ndr, NDR_SCALARS, r->in.sec_info)); } if (flags & NDR_OUT) { @@ -4921,7 +5376,7 @@ static enum ndr_err_code ndr_pull_lsa_QuerySecurity(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_security_secinfo(ndr, NDR_SCALARS, &r->in.sec_info)); NDR_PULL_ALLOC(ndr, r->out.sdbuf); @@ -4992,7 +5447,7 @@ static enum ndr_err_code ndr_push_lsa_SetSecObj(struct ndr_push *ndr, int flags, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_security_secinfo(ndr, NDR_SCALARS, r->in.sec_info)); if (r->in.sdbuf == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -5015,7 +5470,7 @@ static enum ndr_err_code ndr_pull_lsa_SetSecObj(struct ndr_pull *ndr, int flags, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_security_secinfo(ndr, NDR_SCALARS, &r->in.sec_info)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -5120,7 +5575,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenPolicy(struct ndr_push *ndr, int fla if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -5164,7 +5619,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenPolicy(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -5213,7 +5668,7 @@ static enum ndr_err_code ndr_push_lsa_QueryInfoPolicy(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_PolicyInfo(ndr, NDR_SCALARS, r->in.level)); } if (flags & NDR_OUT) { @@ -5244,7 +5699,7 @@ static enum ndr_err_code ndr_pull_lsa_QueryInfoPolicy(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_PolicyInfo(ndr, NDR_SCALARS, &r->in.level)); NDR_PULL_ALLOC(ndr, r->out.info); @@ -5317,7 +5772,7 @@ static enum ndr_err_code ndr_push_lsa_SetInfoPolicy(struct ndr_push *ndr, int fl if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_PolicyInfo(ndr, NDR_SCALARS, r->in.level)); if (r->in.info == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -5341,7 +5796,7 @@ static enum ndr_err_code ndr_pull_lsa_SetInfoPolicy(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_PolicyInfo(ndr, NDR_SCALARS, &r->in.level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -5437,7 +5892,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateAccount(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -5448,7 +5903,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateAccount(struct ndr_push *ndr, int if (r->out.acct_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.acct_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.acct_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -5467,7 +5922,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateAccount(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sid); @@ -5486,7 +5941,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateAccount(struct ndr_pull *ndr, int } _mem_save_acct_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.acct_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.acct_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.acct_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_acct_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -5533,7 +5988,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_EnumAccounts(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.resume_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -5567,7 +6022,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_EnumAccounts(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.resume_handle); @@ -5646,10 +6101,10 @@ _PUBLIC_ void ndr_print_lsa_EnumAccounts(struct ndr_print *ndr, const char *name _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateTrustedDomain(struct ndr_push *ndr, int flags, const struct lsa_CreateTrustedDomain *r) { if (flags & NDR_IN) { - if (r->in.handle == NULL) { + if (r->in.policy_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.policy_handle)); if (r->in.info == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -5660,7 +6115,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateTrustedDomain(struct ndr_push *ndr if (r->out.trustdom_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.trustdom_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -5668,19 +6123,19 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateTrustedDomain(struct ndr_push *ndr _PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateTrustedDomain(struct ndr_pull *ndr, int flags, struct lsa_CreateTrustedDomain *r) { - TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_policy_handle_0; TALLOC_CTX *_mem_save_info_0; TALLOC_CTX *_mem_save_trustdom_handle_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->in.handle); + NDR_PULL_ALLOC(ndr, r->in.policy_handle); } - _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + _mem_save_policy_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.policy_handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.policy_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_policy_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.info); } @@ -5698,7 +6153,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateTrustedDomain(struct ndr_pull *ndr } _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.trustdom_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -5715,9 +6170,9 @@ _PUBLIC_ void ndr_print_lsa_CreateTrustedDomain(struct ndr_print *ndr, const cha if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_CreateTrustedDomain"); ndr->depth++; - ndr_print_ptr(ndr, "handle", r->in.handle); + ndr_print_ptr(ndr, "policy_handle", r->in.policy_handle); ndr->depth++; - ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr_print_policy_handle(ndr, "policy_handle", r->in.policy_handle); ndr->depth--; ndr_print_ptr(ndr, "info", r->in.info); ndr->depth++; @@ -5745,7 +6200,7 @@ static enum ndr_err_code ndr_push_lsa_EnumTrustDom(struct ndr_push *ndr, int fla if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.resume_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -5779,7 +6234,7 @@ static enum ndr_err_code ndr_pull_lsa_EnumTrustDom(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.resume_handle); @@ -5859,7 +6314,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames(struct ndr_push *ndr, int fl if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.num_names)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.num_names)); for (cntr_names_0 = 0; cntr_names_0 < r->in.num_names; cntr_names_0++) { @@ -5917,7 +6372,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.num_names)); if (r->in.num_names < 0 || r->in.num_names > 1000) { @@ -6066,7 +6521,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids(struct ndr_push *ndr, int fla if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -6119,7 +6574,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sids); @@ -6249,7 +6704,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateSecret(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } @@ -6257,7 +6712,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_CreateSecret(struct ndr_push *ndr, int f if (r->out.sec_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sec_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.sec_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -6275,7 +6730,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateSecret(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); @@ -6288,7 +6743,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_CreateSecret(struct ndr_pull *ndr, int f } _mem_save_sec_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.sec_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sec_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.sec_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sec_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -6332,7 +6787,7 @@ static enum ndr_err_code ndr_push_lsa_OpenAccount(struct ndr_push *ndr, int flag if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -6343,7 +6798,7 @@ static enum ndr_err_code ndr_push_lsa_OpenAccount(struct ndr_push *ndr, int flag if (r->out.acct_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.acct_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.acct_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -6362,7 +6817,7 @@ static enum ndr_err_code ndr_pull_lsa_OpenAccount(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sid); @@ -6381,7 +6836,7 @@ static enum ndr_err_code ndr_pull_lsa_OpenAccount(struct ndr_pull *ndr, int flag } _mem_save_acct_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.acct_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.acct_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.acct_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_acct_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -6428,7 +6883,7 @@ static enum ndr_err_code ndr_push_lsa_EnumPrivsAccount(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.privs == NULL) { @@ -6457,7 +6912,7 @@ static enum ndr_err_code ndr_pull_lsa_EnumPrivsAccount(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.privs); ZERO_STRUCTP(r->out.privs); @@ -6526,7 +6981,7 @@ static enum ndr_err_code ndr_push_lsa_AddPrivilegesToAccount(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.privs == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -6548,7 +7003,7 @@ static enum ndr_err_code ndr_pull_lsa_AddPrivilegesToAccount(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.privs); @@ -6599,7 +7054,7 @@ static enum ndr_err_code ndr_push_lsa_RemovePrivilegesFromAccount(struct ndr_pus if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.remove_all)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.privs)); if (r->in.privs) { @@ -6623,7 +7078,7 @@ static enum ndr_err_code ndr_pull_lsa_RemovePrivilegesFromAccount(struct ndr_pul } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->in.remove_all)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_privs)); @@ -6765,7 +7220,7 @@ static enum ndr_err_code ndr_push_lsa_GetSystemAccessAccount(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.access_mask == NULL) { @@ -6789,7 +7244,7 @@ static enum ndr_err_code ndr_pull_lsa_GetSystemAccessAccount(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.access_mask); ZERO_STRUCTP(r->out.access_mask); @@ -6842,7 +7297,7 @@ static enum ndr_err_code ndr_push_lsa_SetSystemAccessAccount(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } if (flags & NDR_OUT) { @@ -6860,7 +7315,7 @@ static enum ndr_err_code ndr_pull_lsa_SetSystemAccessAccount(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); } @@ -6902,7 +7357,7 @@ static enum ndr_err_code ndr_push_lsa_OpenTrustedDomain(struct ndr_push *ndr, in if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -6913,7 +7368,7 @@ static enum ndr_err_code ndr_push_lsa_OpenTrustedDomain(struct ndr_push *ndr, in if (r->out.trustdom_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.trustdom_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -6932,7 +7387,7 @@ static enum ndr_err_code ndr_pull_lsa_OpenTrustedDomain(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sid); @@ -6951,7 +7406,7 @@ static enum ndr_err_code ndr_pull_lsa_OpenTrustedDomain(struct ndr_pull *ndr, in } _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.trustdom_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -6998,7 +7453,7 @@ static enum ndr_err_code ndr_push_lsa_QueryTrustedDomainInfo(struct ndr_push *nd if (r->in.trustdom_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.trustdom_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.trustdom_handle)); NDR_CHECK(ndr_push_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, r->in.level)); } if (flags & NDR_OUT) { @@ -7029,7 +7484,7 @@ static enum ndr_err_code ndr_pull_lsa_QueryTrustedDomainInfo(struct ndr_pull *nd } _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.trustdom_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.trustdom_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, &r->in.level)); NDR_PULL_ALLOC(ndr, r->out.info); @@ -7099,6 +7554,16 @@ _PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfo(struct ndr_print *ndr, const static enum ndr_err_code ndr_push_lsa_SetInformationTrustedDomain(struct ndr_push *ndr, int flags, const struct lsa_SetInformationTrustedDomain *r) { if (flags & NDR_IN) { + if (r->in.trustdom_handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.trustdom_handle)); + NDR_CHECK(ndr_push_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, r->in.level)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_push_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); @@ -7108,7 +7573,25 @@ static enum ndr_err_code ndr_push_lsa_SetInformationTrustedDomain(struct ndr_pus static enum ndr_err_code ndr_pull_lsa_SetInformationTrustedDomain(struct ndr_pull *ndr, int flags, struct lsa_SetInformationTrustedDomain *r) { + TALLOC_CTX *_mem_save_trustdom_handle_0; + TALLOC_CTX *_mem_save_info_0; if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.trustdom_handle); + } + _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.trustdom_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, &r->in.level)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); @@ -7126,6 +7609,16 @@ _PUBLIC_ void ndr_print_lsa_SetInformationTrustedDomain(struct ndr_print *ndr, c if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_SetInformationTrustedDomain"); ndr->depth++; + ndr_print_ptr(ndr, "trustdom_handle", r->in.trustdom_handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "trustdom_handle", r->in.trustdom_handle); + ndr->depth--; + ndr_print_lsa_TrustDomInfoEnum(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.info, r->in.level); + ndr_print_lsa_TrustedDomainInfo(ndr, "info", r->in.info); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { @@ -7143,7 +7636,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenSecret(struct ndr_push *ndr, int fla if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } @@ -7151,7 +7644,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenSecret(struct ndr_push *ndr, int fla if (r->out.sec_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sec_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.sec_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -7169,7 +7662,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenSecret(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); @@ -7182,7 +7675,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenSecret(struct ndr_pull *ndr, int fla } _mem_save_sec_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.sec_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sec_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.sec_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sec_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -7226,7 +7719,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_SetSecret(struct ndr_push *ndr, int flag if (r->in.sec_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sec_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.sec_handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.new_val)); if (r->in.new_val) { NDR_CHECK(ndr_push_lsa_DATA_BUF(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.new_val)); @@ -7255,7 +7748,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_SetSecret(struct ndr_pull *ndr, int flag } _mem_save_sec_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.sec_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sec_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.sec_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sec_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_new_val)); if (_ptr_new_val) { @@ -7331,7 +7824,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_QuerySecret(struct ndr_push *ndr, int fl if (r->in.sec_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sec_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.sec_handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.new_val)); if (r->in.new_val) { NDR_CHECK(ndr_push_lsa_DATA_BUF_PTR(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.new_val)); @@ -7390,7 +7883,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_QuerySecret(struct ndr_pull *ndr, int fl } _mem_save_sec_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.sec_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sec_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.sec_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sec_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_new_val)); if (_ptr_new_val) { @@ -7574,7 +8067,7 @@ static enum ndr_err_code ndr_push_lsa_LookupPrivValue(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -7603,7 +8096,7 @@ static enum ndr_err_code ndr_pull_lsa_LookupPrivValue(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.name); @@ -7667,7 +8160,7 @@ static enum ndr_err_code ndr_push_lsa_LookupPrivName(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.luid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -7701,7 +8194,7 @@ static enum ndr_err_code ndr_pull_lsa_LookupPrivName(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.luid); @@ -7781,7 +8274,7 @@ static enum ndr_err_code ndr_push_lsa_LookupPrivDisplayName(struct ndr_push *ndr if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -7822,7 +8315,7 @@ static enum ndr_err_code ndr_pull_lsa_LookupPrivDisplayName(struct ndr_pull *ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.name); @@ -7919,13 +8412,13 @@ static enum ndr_err_code ndr_push_lsa_DeleteObject(struct ndr_push *ndr, int fla if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -7942,7 +8435,7 @@ static enum ndr_err_code ndr_pull_lsa_DeleteObject(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.handle); *r->out.handle = *r->in.handle; @@ -7953,7 +8446,7 @@ static enum ndr_err_code ndr_pull_lsa_DeleteObject(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -7995,7 +8488,7 @@ static enum ndr_err_code ndr_push_lsa_EnumAccountsWithUserRight(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.name)); if (r->in.name) { NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name)); @@ -8025,7 +8518,7 @@ static enum ndr_err_code ndr_pull_lsa_EnumAccountsWithUserRight(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name)); if (_ptr_name) { @@ -8096,7 +8589,7 @@ static enum ndr_err_code ndr_push_lsa_EnumAccountRights(struct ndr_push *ndr, in if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -8125,7 +8618,7 @@ static enum ndr_err_code ndr_pull_lsa_EnumAccountRights(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sid); @@ -8189,7 +8682,7 @@ static enum ndr_err_code ndr_push_lsa_AddAccountRights(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -8216,7 +8709,7 @@ static enum ndr_err_code ndr_pull_lsa_AddAccountRights(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sid); @@ -8278,7 +8771,7 @@ static enum ndr_err_code ndr_push_lsa_RemoveAccountRights(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -8306,7 +8799,7 @@ static enum ndr_err_code ndr_pull_lsa_RemoveAccountRights(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sid); @@ -8370,7 +8863,7 @@ static enum ndr_err_code ndr_push_lsa_QueryTrustedDomainInfoBySid(struct ndr_pus if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.dom_sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -8406,7 +8899,7 @@ static enum ndr_err_code ndr_pull_lsa_QueryTrustedDomainInfoBySid(struct ndr_pul } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.dom_sid); @@ -8487,6 +8980,20 @@ _PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfoBySid(struct ndr_print *ndr, c static enum ndr_err_code ndr_push_lsa_SetTrustedDomainInfo(struct ndr_push *ndr, int flags, const struct lsa_SetTrustedDomainInfo *r) { if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + if (r->in.dom_sid == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.dom_sid)); + NDR_CHECK(ndr_push_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, r->in.level)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_push_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); @@ -8496,7 +9003,33 @@ static enum ndr_err_code ndr_push_lsa_SetTrustedDomainInfo(struct ndr_push *ndr, static enum ndr_err_code ndr_pull_lsa_SetTrustedDomainInfo(struct ndr_pull *ndr, int flags, struct lsa_SetTrustedDomainInfo *r) { + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_dom_sid_0; + TALLOC_CTX *_mem_save_info_0; if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.dom_sid); + } + _mem_save_dom_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.dom_sid, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.dom_sid)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dom_sid_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, &r->in.level)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); @@ -8514,6 +9047,20 @@ _PUBLIC_ void ndr_print_lsa_SetTrustedDomainInfo(struct ndr_print *ndr, const ch if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_SetTrustedDomainInfo"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_ptr(ndr, "dom_sid", r->in.dom_sid); + ndr->depth++; + ndr_print_dom_sid2(ndr, "dom_sid", r->in.dom_sid); + ndr->depth--; + ndr_print_lsa_TrustDomInfoEnum(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_set_switch_value(ndr, r->in.info, r->in.level); + ndr_print_lsa_TrustedDomainInfo(ndr, "info", r->in.info); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { @@ -8531,7 +9078,7 @@ static enum ndr_err_code ndr_push_lsa_DeleteTrustedDomain(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.dom_sid == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -8553,7 +9100,7 @@ static enum ndr_err_code ndr_pull_lsa_DeleteTrustedDomain(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.dom_sid); @@ -8700,7 +9247,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_OpenPolicy2(struct ndr_push *ndr, int fl if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -8750,7 +9297,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_OpenPolicy2(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -9033,7 +9580,7 @@ static enum ndr_err_code ndr_push_lsa_QueryInfoPolicy2(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_PolicyInfo(ndr, NDR_SCALARS, r->in.level)); } if (flags & NDR_OUT) { @@ -9064,7 +9611,7 @@ static enum ndr_err_code ndr_pull_lsa_QueryInfoPolicy2(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_PolicyInfo(ndr, NDR_SCALARS, &r->in.level)); NDR_PULL_ALLOC(ndr, r->out.info); @@ -9137,7 +9684,7 @@ static enum ndr_err_code ndr_push_lsa_SetInfoPolicy2(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_PolicyInfo(ndr, NDR_SCALARS, r->in.level)); if (r->in.info == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -9161,7 +9708,7 @@ static enum ndr_err_code ndr_pull_lsa_SetInfoPolicy2(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_PolicyInfo(ndr, NDR_SCALARS, &r->in.level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -9216,7 +9763,7 @@ static enum ndr_err_code ndr_push_lsa_QueryTrustedDomainInfoByName(struct ndr_pu if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.trusted_domain == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -9252,7 +9799,7 @@ static enum ndr_err_code ndr_pull_lsa_QueryTrustedDomainInfoByName(struct ndr_pu } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.trusted_domain); @@ -9336,7 +9883,7 @@ static enum ndr_err_code ndr_push_lsa_SetTrustedDomainInfoByName(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.trusted_domain)); NDR_CHECK(ndr_push_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, r->in.level)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.info)); @@ -9362,7 +9909,7 @@ static enum ndr_err_code ndr_pull_lsa_SetTrustedDomainInfoByName(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.trusted_domain)); NDR_CHECK(ndr_pull_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, &r->in.level)); @@ -9426,7 +9973,7 @@ static enum ndr_err_code ndr_push_lsa_EnumTrustedDomainsEx(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.resume_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -9460,7 +10007,7 @@ static enum ndr_err_code ndr_pull_lsa_EnumTrustedDomainsEx(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.resume_handle); @@ -9536,8 +10083,25 @@ _PUBLIC_ void ndr_print_lsa_EnumTrustedDomainsEx(struct ndr_print *ndr, const ch static enum ndr_err_code ndr_push_lsa_CreateTrustedDomainEx(struct ndr_push *ndr, int flags, const struct lsa_CreateTrustedDomainEx *r) { if (flags & NDR_IN) { + if (r->in.policy_handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.policy_handle)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + if (r->in.auth_info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.auth_info)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } if (flags & NDR_OUT) { + if (r->out.trustdom_handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -9545,9 +10109,46 @@ static enum ndr_err_code ndr_push_lsa_CreateTrustedDomainEx(struct ndr_push *ndr static enum ndr_err_code ndr_pull_lsa_CreateTrustedDomainEx(struct ndr_pull *ndr, int flags, struct lsa_CreateTrustedDomainEx *r) { + TALLOC_CTX *_mem_save_policy_handle_0; + TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_auth_info_0; + TALLOC_CTX *_mem_save_trustdom_handle_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.policy_handle); + } + _mem_save_policy_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.policy_handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.policy_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_policy_handle_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.auth_info); + } + _mem_save_auth_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.auth_info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.auth_info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_auth_info_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_PULL_ALLOC(ndr, r->out.trustdom_handle); + ZERO_STRUCTP(r->out.trustdom_handle); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.trustdom_handle); + } + _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -9563,11 +10164,28 @@ _PUBLIC_ void ndr_print_lsa_CreateTrustedDomainEx(struct ndr_print *ndr, const c if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_CreateTrustedDomainEx"); ndr->depth++; + ndr_print_ptr(ndr, "policy_handle", r->in.policy_handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "policy_handle", r->in.policy_handle); + ndr->depth--; + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_lsa_TrustDomainInfoInfoEx(ndr, "info", r->in.info); + ndr->depth--; + ndr_print_ptr(ndr, "auth_info", r->in.auth_info); + ndr->depth++; + ndr_print_lsa_TrustDomainInfoAuthInfoInternal(ndr, "auth_info", r->in.auth_info); + ndr->depth--; + ndr_print_uint32(ndr, "access_mask", r->in.access_mask); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "lsa_CreateTrustedDomainEx"); ndr->depth++; + ndr_print_ptr(ndr, "trustdom_handle", r->out.trustdom_handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "trustdom_handle", r->out.trustdom_handle); + ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; } @@ -9580,13 +10198,13 @@ static enum ndr_err_code ndr_push_lsa_CloseTrustedDomainEx(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -9603,7 +10221,7 @@ static enum ndr_err_code ndr_pull_lsa_CloseTrustedDomainEx(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.handle); *r->out.handle = *r->in.handle; @@ -9614,7 +10232,7 @@ static enum ndr_err_code ndr_pull_lsa_CloseTrustedDomainEx(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -9656,7 +10274,7 @@ static enum ndr_err_code ndr_push_lsa_QueryDomainInformationPolicy(struct ndr_pu if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.level)); } if (flags & NDR_OUT) { @@ -9687,7 +10305,7 @@ static enum ndr_err_code ndr_pull_lsa_QueryDomainInformationPolicy(struct ndr_pu } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.level)); NDR_PULL_ALLOC(ndr, r->out.info); @@ -9760,7 +10378,7 @@ static enum ndr_err_code ndr_push_lsa_SetDomainInformationPolicy(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.level)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.info)); if (r->in.info) { @@ -9785,7 +10403,7 @@ static enum ndr_err_code ndr_pull_lsa_SetDomainInformationPolicy(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.level)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); @@ -9847,7 +10465,7 @@ static enum ndr_err_code ndr_push_lsa_OpenTrustedDomainByName(struct ndr_push *n if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } @@ -9855,7 +10473,7 @@ static enum ndr_err_code ndr_push_lsa_OpenTrustedDomainByName(struct ndr_push *n if (r->out.trustdom_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.trustdom_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -9873,7 +10491,7 @@ static enum ndr_err_code ndr_pull_lsa_OpenTrustedDomainByName(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); @@ -9886,7 +10504,7 @@ static enum ndr_err_code ndr_pull_lsa_OpenTrustedDomainByName(struct ndr_pull *n } _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.trustdom_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -9971,7 +10589,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupSids2(struct ndr_push *ndr, int fl if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.sids == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -10026,7 +10644,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupSids2(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sids); @@ -10161,7 +10779,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames2(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.num_names)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.num_names)); for (cntr_names_0 = 0; cntr_names_0 < r->in.num_names; cntr_names_0++) { @@ -10179,8 +10797,8 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames2(struct ndr_push *ndr, int f return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.lookup_options)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.client_revision)); } if (flags & NDR_OUT) { if (r->out.domains == NULL) { @@ -10221,7 +10839,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames2(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.num_names)); if (r->in.num_names < 0 || r->in.num_names > 1000) { @@ -10253,8 +10871,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames2(struct ndr_pull *ndr, int f NDR_PULL_SET_MEM_CTX(ndr, r->in.count, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.count)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.lookup_options)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.client_revision)); NDR_PULL_ALLOC(ndr, r->out.domains); ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); @@ -10338,8 +10956,8 @@ _PUBLIC_ void ndr_print_lsa_LookupNames2(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_uint32(ndr, "count", *r->in.count); ndr->depth--; - ndr_print_uint32(ndr, "unknown1", r->in.unknown1); - ndr_print_uint32(ndr, "unknown2", r->in.unknown2); + ndr_print_uint32(ndr, "lookup_options", r->in.lookup_options); + ndr_print_uint32(ndr, "client_revision", r->in.client_revision); ndr->depth--; } if (flags & NDR_OUT) { @@ -10371,8 +10989,25 @@ _PUBLIC_ void ndr_print_lsa_LookupNames2(struct ndr_print *ndr, const char *name static enum ndr_err_code ndr_push_lsa_CreateTrustedDomainEx2(struct ndr_push *ndr, int flags, const struct lsa_CreateTrustedDomainEx2 *r) { if (flags & NDR_IN) { + if (r->in.policy_handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.policy_handle)); + if (r->in.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + if (r->in.auth_info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.auth_info)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } if (flags & NDR_OUT) { + if (r->out.trustdom_handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -10380,9 +11015,46 @@ static enum ndr_err_code ndr_push_lsa_CreateTrustedDomainEx2(struct ndr_push *nd static enum ndr_err_code ndr_pull_lsa_CreateTrustedDomainEx2(struct ndr_pull *ndr, int flags, struct lsa_CreateTrustedDomainEx2 *r) { + TALLOC_CTX *_mem_save_policy_handle_0; + TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_auth_info_0; + TALLOC_CTX *_mem_save_trustdom_handle_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.policy_handle); + } + _mem_save_policy_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.policy_handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.policy_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_policy_handle_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoInfoEx(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.auth_info); + } + _mem_save_auth_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.auth_info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_TrustDomainInfoAuthInfoInternal(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.auth_info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_auth_info_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_PULL_ALLOC(ndr, r->out.trustdom_handle); + ZERO_STRUCTP(r->out.trustdom_handle); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.trustdom_handle); + } + _mem_save_trustdom_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.trustdom_handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.trustdom_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trustdom_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -10398,11 +11070,28 @@ _PUBLIC_ void ndr_print_lsa_CreateTrustedDomainEx2(struct ndr_print *ndr, const if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_CreateTrustedDomainEx2"); ndr->depth++; + ndr_print_ptr(ndr, "policy_handle", r->in.policy_handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "policy_handle", r->in.policy_handle); + ndr->depth--; + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + ndr_print_lsa_TrustDomainInfoInfoEx(ndr, "info", r->in.info); + ndr->depth--; + ndr_print_ptr(ndr, "auth_info", r->in.auth_info); + ndr->depth++; + ndr_print_lsa_TrustDomainInfoAuthInfoInternal(ndr, "auth_info", r->in.auth_info); + ndr->depth--; + ndr_print_uint32(ndr, "access_mask", r->in.access_mask); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "lsa_CreateTrustedDomainEx2"); ndr->depth++; + ndr_print_ptr(ndr, "trustdom_handle", r->out.trustdom_handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "trustdom_handle", r->out.trustdom_handle); + ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; } @@ -10744,7 +11433,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.num_names)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.num_names)); for (cntr_names_0 = 0; cntr_names_0 < r->in.num_names; cntr_names_0++) { @@ -10762,8 +11451,8 @@ _PUBLIC_ enum ndr_err_code ndr_push_lsa_LookupNames3(struct ndr_push *ndr, int f return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.lookup_options)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.client_revision)); } if (flags & NDR_OUT) { if (r->out.domains == NULL) { @@ -10804,7 +11493,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.num_names)); if (r->in.num_names < 0 || r->in.num_names > 1000) { @@ -10836,8 +11525,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_lsa_LookupNames3(struct ndr_pull *ndr, int f NDR_PULL_SET_MEM_CTX(ndr, r->in.count, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.count)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.lookup_options)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.client_revision)); NDR_PULL_ALLOC(ndr, r->out.domains); ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); @@ -10921,8 +11610,8 @@ _PUBLIC_ void ndr_print_lsa_LookupNames3(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_uint32(ndr, "count", *r->in.count); ndr->depth--; - ndr_print_uint32(ndr, "unknown1", r->in.unknown1); - ndr_print_uint32(ndr, "unknown2", r->in.unknown2); + ndr_print_uint32(ndr, "lookup_options", r->in.lookup_options); + ndr_print_uint32(ndr, "client_revision", r->in.client_revision); ndr->depth--; } if (flags & NDR_OUT) { @@ -11121,7 +11810,7 @@ static enum ndr_err_code ndr_push_lsa_lsaRQueryForestTrustInformation(struct ndr if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.trusted_domain_name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -11156,7 +11845,7 @@ static enum ndr_err_code ndr_pull_lsa_lsaRQueryForestTrustInformation(struct ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.trusted_domain_name); @@ -11508,8 +12197,8 @@ static enum ndr_err_code ndr_push_lsa_LookupNames4(struct ndr_push *ndr, int fla return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.count)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.lookup_options)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.client_revision)); } if (flags & NDR_OUT) { if (r->out.domains == NULL) { @@ -11574,8 +12263,8 @@ static enum ndr_err_code ndr_pull_lsa_LookupNames4(struct ndr_pull *ndr, int fla NDR_PULL_SET_MEM_CTX(ndr, r->in.count, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.count)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.lookup_options)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.client_revision)); NDR_PULL_ALLOC(ndr, r->out.domains); ZERO_STRUCTP(r->out.domains); NDR_PULL_ALLOC(ndr, r->out.sids); @@ -11655,8 +12344,8 @@ _PUBLIC_ void ndr_print_lsa_LookupNames4(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_uint32(ndr, "count", *r->in.count); ndr->depth--; - ndr_print_uint32(ndr, "unknown1", r->in.unknown1); - ndr_print_uint32(ndr, "unknown2", r->in.unknown2); + ndr_print_uint32(ndr, "lookup_options", r->in.lookup_options); + ndr_print_uint32(ndr, "client_revision", r->in.client_revision); ndr->depth--; } if (flags & NDR_OUT) { diff --git a/source3/librpc/gen_ndr/ndr_lsa.h b/source3/librpc/gen_ndr/ndr_lsa.h index a489b5423e..2f623c2ba9 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.h +++ b/source3/librpc/gen_ndr/ndr_lsa.h @@ -207,6 +207,7 @@ void ndr_print_lsa_PolicyAuditPolicy(struct ndr_print *ndr, const char *name, en void ndr_print_lsa_AuditEventsInfo(struct ndr_print *ndr, const char *name, const struct lsa_AuditEventsInfo *r); void ndr_print_lsa_DomainInfo(struct ndr_print *ndr, const char *name, const struct lsa_DomainInfo *r); void ndr_print_lsa_PDAccountInfo(struct ndr_print *ndr, const char *name, const struct lsa_PDAccountInfo *r); +void ndr_print_lsa_Role(struct ndr_print *ndr, const char *name, enum lsa_Role r); void ndr_print_lsa_ServerRole(struct ndr_print *ndr, const char *name, const struct lsa_ServerRole *r); void ndr_print_lsa_ReplicaSourceInfo(struct ndr_print *ndr, const char *name, const struct lsa_ReplicaSourceInfo *r); void ndr_print_lsa_DefaultQuotaInfo(struct ndr_print *ndr, const char *name, const struct lsa_DefaultQuotaInfo *r); @@ -221,6 +222,8 @@ enum ndr_err_code ndr_push_lsa_SidArray(struct ndr_push *ndr, int ndr_flags, con enum ndr_err_code ndr_pull_lsa_SidArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_SidArray *r); void ndr_print_lsa_SidArray(struct ndr_print *ndr, const char *name, const struct lsa_SidArray *r); void ndr_print_lsa_DomainList(struct ndr_print *ndr, const char *name, const struct lsa_DomainList *r); +enum ndr_err_code ndr_push_lsa_SidType(struct ndr_push *ndr, int ndr_flags, enum lsa_SidType r); +enum ndr_err_code ndr_pull_lsa_SidType(struct ndr_pull *ndr, int ndr_flags, enum lsa_SidType *r); void ndr_print_lsa_SidType(struct ndr_print *ndr, const char *name, enum lsa_SidType r); void ndr_print_lsa_TranslatedSid(struct ndr_print *ndr, const char *name, const struct lsa_TranslatedSid *r); void ndr_print_lsa_TransSidArray(struct ndr_print *ndr, const char *name, const struct lsa_TransSidArray *r); @@ -233,16 +236,30 @@ void ndr_print_lsa_PrivilegeSet(struct ndr_print *ndr, const char *name, const s void ndr_print_lsa_DATA_BUF(struct ndr_print *ndr, const char *name, const struct lsa_DATA_BUF *r); void ndr_print_lsa_DATA_BUF2(struct ndr_print *ndr, const char *name, const struct lsa_DATA_BUF2 *r); void ndr_print_lsa_TrustDomInfoEnum(struct ndr_print *ndr, const char *name, enum lsa_TrustDomInfoEnum r); +enum ndr_err_code ndr_push_lsa_TrustDirection(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_lsa_TrustDirection(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_lsa_TrustDirection(struct ndr_print *ndr, const char *name, uint32_t r); +void ndr_print_lsa_TrustType(struct ndr_print *ndr, const char *name, enum lsa_TrustType r); +enum ndr_err_code ndr_push_lsa_TrustAttributes(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_lsa_TrustAttributes(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_lsa_TrustAttributes(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_lsa_TrustDomainInfoName(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoName *r); +void ndr_print_lsa_TrustDomainInfoControllers(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoControllers *r); void ndr_print_lsa_TrustDomainInfoPosixOffset(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoPosixOffset *r); void ndr_print_lsa_TrustDomainInfoPassword(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoPassword *r); void ndr_print_lsa_TrustDomainInfoBasic(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoBasic *r); void ndr_print_lsa_TrustDomainInfoInfoEx(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoEx *r); +enum ndr_err_code ndr_push_lsa_TrustAuthType(struct ndr_push *ndr, int ndr_flags, enum lsa_TrustAuthType r); +enum ndr_err_code ndr_pull_lsa_TrustAuthType(struct ndr_pull *ndr, int ndr_flags, enum lsa_TrustAuthType *r); +void ndr_print_lsa_TrustAuthType(struct ndr_print *ndr, const char *name, enum lsa_TrustAuthType r); void ndr_print_lsa_TrustDomainInfoBuffer(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoBuffer *r); void ndr_print_lsa_TrustDomainInfoAuthInfo(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoAuthInfo *r); void ndr_print_lsa_TrustDomainInfoFullInfo(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoFullInfo *r); -void ndr_print_lsa_TrustDomainInfo11(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfo11 *r); -void ndr_print_lsa_TrustDomainInfoInfoAll(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoAll *r); +void ndr_print_lsa_TrustDomainInfoAuthInfoInternal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoAuthInfoInternal *r); +void ndr_print_lsa_TrustDomainInfoFullInfoInternal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoFullInfoInternal *r); +void ndr_print_lsa_TrustDomainInfoInfoEx2Internal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoInfoEx2Internal *r); +void ndr_print_lsa_TrustDomainInfoFullInfo2Internal(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoFullInfo2Internal *r); +void ndr_print_lsa_TrustDomainInfoSupportedEncTypes(struct ndr_print *ndr, const char *name, const struct lsa_TrustDomainInfoSupportedEncTypes *r); void ndr_print_lsa_TrustedDomainInfo(struct ndr_print *ndr, const char *name, const union lsa_TrustedDomainInfo *r); void ndr_print_lsa_DATA_BUF_PTR(struct ndr_print *ndr, const char *name, const struct lsa_DATA_BUF_PTR *r); void ndr_print_lsa_RightSet(struct ndr_print *ndr, const char *name, const struct lsa_RightSet *r); diff --git a/source3/librpc/gen_ndr/ndr_misc.c b/source3/librpc/gen_ndr/ndr_misc.c index 56105d499f..22c416a0d7 100644 --- a/source3/librpc/gen_ndr/ndr_misc.c +++ b/source3/librpc/gen_ndr/ndr_misc.c @@ -123,7 +123,9 @@ _PUBLIC_ void ndr_print_netr_SchannelType(struct ndr_print *ndr, const char *nam const char *val = NULL; switch (r) { + case SEC_CHAN_NULL: val = "SEC_CHAN_NULL"; break; case SEC_CHAN_WKSTA: val = "SEC_CHAN_WKSTA"; break; + case SEC_CHAN_DNS_DOMAIN: val = "SEC_CHAN_DNS_DOMAIN"; break; case SEC_CHAN_DOMAIN: val = "SEC_CHAN_DOMAIN"; break; case SEC_CHAN_BDC: val = "SEC_CHAN_BDC"; break; } diff --git a/source3/librpc/gen_ndr/ndr_nbt.c b/source3/librpc/gen_ndr/ndr_nbt.c index 75667183a8..c02b539da5 100644 --- a/source3/librpc/gen_ndr/ndr_nbt.c +++ b/source3/librpc/gen_ndr/ndr_nbt.c @@ -77,13 +77,13 @@ _PUBLIC_ void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const ndr->depth--; } -static enum ndr_err_code ndr_push_nbt_qclass(struct ndr_push *ndr, int ndr_flags, enum nbt_qclass r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_qclass(struct ndr_push *ndr, int ndr_flags, enum nbt_qclass r) { NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_qclass(struct ndr_pull *ndr, int ndr_flags, enum nbt_qclass *r) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_qclass(struct ndr_pull *ndr, int ndr_flags, enum nbt_qclass *r) { uint16_t v; NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); @@ -101,13 +101,13 @@ _PUBLIC_ void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum ndr_print_enum(ndr, name, "ENUM", val, r); } -static enum ndr_err_code ndr_push_nbt_qtype(struct ndr_push *ndr, int ndr_flags, enum nbt_qtype r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_qtype(struct ndr_push *ndr, int ndr_flags, enum nbt_qtype r) { NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_qtype(struct ndr_pull *ndr, int ndr_flags, enum nbt_qtype *r) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_qtype(struct ndr_pull *ndr, int ndr_flags, enum nbt_qtype *r) { uint16_t v; NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); @@ -496,7 +496,7 @@ _PUBLIC_ void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, const union nbt_rdata *r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, const union nbt_rdata *r) { if (ndr_flags & NDR_SCALARS) { int level = ndr_push_get_switch_value(ndr, r); @@ -532,7 +532,7 @@ static enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_rdata(struct ndr_pull *ndr, int ndr_flags, union nbt_rdata *r) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_rdata(struct ndr_pull *ndr, int ndr_flags, union nbt_rdata *r) { int level; level = ndr_pull_get_switch_value(ndr, r); @@ -589,27 +589,6 @@ _PUBLIC_ void ndr_print_nbt_rdata(struct ndr_print *ndr, const char *name, const } } -static enum ndr_err_code ndr_push_nbt_res_rec(struct ndr_push *ndr, int ndr_flags, const struct nbt_res_rec *r) -{ - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_name(ndr, NDR_SCALARS, &r->name)); - NDR_CHECK(ndr_push_nbt_qtype(ndr, NDR_SCALARS, r->rr_type)); - NDR_CHECK(ndr_push_nbt_qclass(ndr, NDR_SCALARS, r->rr_class)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ttl)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, "struct ndr_push") && ((r->rdata).data.length == 2))?0:r->rr_type))); - NDR_CHECK(ndr_push_nbt_rdata(ndr, NDR_SCALARS, &r->rdata)); - } - if (ndr_flags & NDR_BUFFERS) { - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} - static enum ndr_err_code ndr_pull_nbt_res_rec(struct ndr_pull *ndr, int ndr_flags, struct nbt_res_rec *r) { { @@ -621,7 +600,7 @@ static enum ndr_err_code ndr_pull_nbt_res_rec(struct ndr_pull *ndr, int ndr_flag NDR_CHECK(ndr_pull_nbt_qtype(ndr, NDR_SCALARS, &r->rr_type)); NDR_CHECK(ndr_pull_nbt_qclass(ndr, NDR_SCALARS, &r->rr_class)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ttl)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, "struct ndr_push") && ((r->rdata).data.length == 2))?0:r->rr_type))); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->rdata, r->rr_type)); NDR_CHECK(ndr_pull_nbt_rdata(ndr, NDR_SCALARS, &r->rdata)); } if (ndr_flags & NDR_BUFFERS) { @@ -642,7 +621,7 @@ _PUBLIC_ void ndr_print_nbt_res_rec(struct ndr_print *ndr, const char *name, con ndr_print_nbt_qtype(ndr, "rr_type", r->rr_type); ndr_print_nbt_qclass(ndr, "rr_class", r->rr_class); ndr_print_uint32(ndr, "ttl", r->ttl); - ndr_print_set_switch_value(ndr, &r->rdata, ((((r->rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, "struct ndr_push") && ((r->rdata).data.length == 2))?0:r->rr_type)); + ndr_print_set_switch_value(ndr, &r->rdata, r->rr_type); ndr_print_nbt_rdata(ndr, "rdata", &r->rdata); ndr->depth--; ndr->flags = _flags_save_STRUCT; @@ -1548,13 +1527,138 @@ _PUBLIC_ void ndr_print_nbt_dgram_packet(struct ndr_print *ndr, const char *name } } -static enum ndr_err_code ndr_push_nbt_netlogon_command(struct ndr_push *ndr, int ndr_flags, enum nbt_netlogon_command r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_sockaddr(struct ndr_push *ndr, int ndr_flags, const struct nbt_sockaddr *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sockaddr_family)); + { + uint32_t _flags_save_ipv4address = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); + NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip)); + ndr->flags = _flags_save_ipv4address; + } + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->remaining)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_sockaddr(struct ndr_pull *ndr, int ndr_flags, struct nbt_sockaddr *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sockaddr_family)); + { + uint32_t _flags_save_ipv4address = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); + NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip)); + ndr->flags = _flags_save_ipv4address; + } + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->remaining)); + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_nbt_sockaddr(struct ndr_print *ndr, const char *name, const struct nbt_sockaddr *r) +{ + ndr_print_struct(ndr, name, "nbt_sockaddr"); + ndr->depth++; + ndr_print_uint32(ndr, "sockaddr_family", r->sockaddr_family); + ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip); + ndr_print_DATA_BLOB(ndr, "remaining", r->remaining); + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_nbt_sockaddr(const struct nbt_sockaddr *r, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_nbt_sockaddr); +} + +_PUBLIC_ enum ndr_err_code ndr_push_nbt_server_type(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_server_type(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_PDC", NBT_SERVER_PDC, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_GC", NBT_SERVER_GC, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_LDAP", NBT_SERVER_LDAP, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_DS", NBT_SERVER_DS, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_KDC", NBT_SERVER_KDC, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_TIMESERV", NBT_SERVER_TIMESERV, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_CLOSEST", NBT_SERVER_CLOSEST, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_WRITABLE", NBT_SERVER_WRITABLE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_GOOD_TIMESERV", NBT_SERVER_GOOD_TIMESERV, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_NDNC", NBT_SERVER_NDNC, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_SELECT_SECRET_DOMAIN_6", NBT_SERVER_SELECT_SECRET_DOMAIN_6, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_FULL_SECRET_DOMAIN_6", NBT_SERVER_FULL_SECRET_DOMAIN_6, r); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_netlogon_nt_version_flags(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_netlogon_nt_version_flags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netlogon_nt_version_flags(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_1", NETLOGON_NT_VERSION_1, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_5", NETLOGON_NT_VERSION_5, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_5EX", NETLOGON_NT_VERSION_5EX, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_5EX_WITH_IP", NETLOGON_NT_VERSION_5EX_WITH_IP, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_WITH_CLOSEST_SITE", NETLOGON_NT_VERSION_WITH_CLOSEST_SITE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_AVIOD_NT4EMUL", NETLOGON_NT_VERSION_AVIOD_NT4EMUL, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_PDC", NETLOGON_NT_VERSION_PDC, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_IP", NETLOGON_NT_VERSION_IP, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_LOCAL", NETLOGON_NT_VERSION_LOCAL, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_NT_VERSION_GC", NETLOGON_NT_VERSION_GC, r); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_netlogon_command(struct ndr_push *ndr, int ndr_flags, enum netlogon_command r) { NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_netlogon_command(struct ndr_pull *ndr, int ndr_flags, enum nbt_netlogon_command *r) +_PUBLIC_ enum ndr_err_code ndr_pull_netlogon_command(struct ndr_pull *ndr, int ndr_flags, enum netlogon_command *r) { uint16_t v; NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); @@ -1562,64 +1666,353 @@ static enum ndr_err_code ndr_pull_nbt_netlogon_command(struct ndr_pull *ndr, int return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_netlogon_command(struct ndr_print *ndr, const char *name, enum nbt_netlogon_command r) +_PUBLIC_ void ndr_print_netlogon_command(struct ndr_print *ndr, const char *name, enum netlogon_command r) { const char *val = NULL; switch (r) { - case NETLOGON_QUERY_FOR_PDC: val = "NETLOGON_QUERY_FOR_PDC"; break; + case LOGON_PRIMARY_QUERY: val = "LOGON_PRIMARY_QUERY"; break; case NETLOGON_ANNOUNCE_UAS: val = "NETLOGON_ANNOUNCE_UAS"; break; case NETLOGON_RESPONSE_FROM_PDC: val = "NETLOGON_RESPONSE_FROM_PDC"; break; - case NETLOGON_QUERY_FOR_PDC2: val = "NETLOGON_QUERY_FOR_PDC2"; break; - case NETLOGON_RESPONSE_FROM_PDC2: val = "NETLOGON_RESPONSE_FROM_PDC2"; break; - case NETLOGON_RESPONSE_FROM_PDC_USER: val = "NETLOGON_RESPONSE_FROM_PDC_USER"; break; + case LOGON_SAM_LOGON_REQUEST: val = "LOGON_SAM_LOGON_REQUEST"; break; + case LOGON_SAM_LOGON_RESPONSE: val = "LOGON_SAM_LOGON_RESPONSE"; break; + case LOGON_SAM_LOGON_PAUSE_RESPONSE: val = "LOGON_SAM_LOGON_PAUSE_RESPONSE"; break; + case LOGON_SAM_LOGON_USER_UNKNOWN: val = "LOGON_SAM_LOGON_USER_UNKNOWN"; break; + case LOGON_SAM_LOGON_RESPONSE_EX: val = "LOGON_SAM_LOGON_RESPONSE_EX"; break; + case LOGON_SAM_LOGON_PAUSE_RESPONSE_EX: val = "LOGON_SAM_LOGON_PAUSE_RESPONSE_EX"; break; + case LOGON_SAM_LOGON_USER_UNKNOWN_EX: val = "LOGON_SAM_LOGON_USER_UNKNOWN_EX"; break; } ndr_print_enum(ndr, name, "ENUM", val, r); } -static enum ndr_err_code ndr_push_nbt_netlogon_version(struct ndr_push *ndr, int ndr_flags, uint32_t r) +_PUBLIC_ void ndr_print_NETLOGON_SAM_LOGON_REQUEST(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_REQUEST *r) +{ + ndr_print_struct(ndr, name, "NETLOGON_SAM_LOGON_REQUEST"); + ndr->depth++; + ndr_print_uint16(ndr, "request_count", r->request_count); + ndr_print_string(ndr, "computer_name", r->computer_name); + ndr_print_string(ndr, "user_name", r->user_name); + ndr_print_string(ndr, "mailslot_name", r->mailslot_name); + ndr_print_samr_AcctFlags(ndr, "acct_control", r->acct_control); + ndr_print_uint32(ndr, "sid_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->sid, ndr->flags):r->sid_size); + ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); + ndr_print_dom_sid0(ndr, "sid", &r->sid); + ndr_print_netlogon_nt_version_flags(ndr, "nt_version", r->nt_version); + ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); + ndr_print_uint16(ndr, "lm20_token", r->lm20_token); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_NT40(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_NT40 *r) { { - uint32_t _flags_save_BITMAP = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); - ndr->flags = _flags_save_BITMAP; + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->server)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_netlogon_version(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +_PUBLIC_ enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_NT40(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_NT40 *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->server)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_NETLOGON_SAM_LOGON_RESPONSE_NT40(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_RESPONSE_NT40 *r) +{ + ndr_print_struct(ndr, name, "NETLOGON_SAM_LOGON_RESPONSE_NT40"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + ndr->depth++; + ndr_print_netlogon_command(ndr, "command", r->command); + ndr_print_string(ndr, "server", r->server); + ndr_print_string(ndr, "user_name", r->user_name); + ndr_print_string(ndr, "domain", r->domain); + ndr_print_netlogon_nt_version_flags(ndr, "nt_version", r->nt_version); + ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); + ndr_print_uint16(ndr, "lm20_token", r->lm20_token); + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + +_PUBLIC_ enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->zero_uuid)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); + NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip)); + NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->zero_uuid)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); + NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip)); + NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_NETLOGON_SAM_LOGON_RESPONSE(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_RESPONSE *r) +{ + ndr_print_struct(ndr, name, "NETLOGON_SAM_LOGON_RESPONSE"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + ndr->depth++; + ndr_print_netlogon_command(ndr, "command", r->command); + ndr_print_string(ndr, "pdc_name", r->pdc_name); + ndr_print_string(ndr, "user_name", r->user_name); + ndr_print_string(ndr, "domain_name", r->domain_name); + ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); + ndr_print_GUID(ndr, "zero_uuid", &r->zero_uuid); + ndr_print_nbt_string(ndr, "forest", r->forest); + ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); + ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); + ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip); + ndr_print_nbt_server_type(ndr, "server_type", r->server_type); + ndr_print_netlogon_nt_version_flags(ndr, "nt_version", r->nt_version); + ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); + ndr_print_uint16(ndr, "lm20_token", r->lm20_token); + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + +_PUBLIC_ enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz)); + NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags))); + { + struct ndr_push *_ndr_sockaddr; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags))); + NDR_CHECK(ndr_push_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS, &r->sockaddr)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags))); + } + NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site)); + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r) { - uint32_t v; { - uint32_t _flags_save_BITMAP = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); - *r = v; - ndr->flags = _flags_save_BITMAP; + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); + NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sockaddr_size)); + { + struct ndr_pull *_ndr_sockaddr; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sockaddr, 0, r->sockaddr_size)); + NDR_CHECK(ndr_pull_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS, &r->sockaddr)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sockaddr, 0, r->sockaddr_size)); + } + NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site)); + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_netlogon_version(struct ndr_print *ndr, const char *name, uint32_t r) +_PUBLIC_ void ndr_print_NETLOGON_SAM_LOGON_RESPONSE_EX(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r) { + ndr_print_struct(ndr, name, "NETLOGON_SAM_LOGON_RESPONSE_EX"); { - uint32_t _flags_save_BITMAP = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN); - ndr_print_uint32(ndr, name, r); + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); ndr->depth++; - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_1", NETLOGON_VERSION_1, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_5", NETLOGON_VERSION_5, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_5EX", NETLOGON_VERSION_5EX, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_5EX_WITH_IP", NETLOGON_VERSION_5EX_WITH_IP, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_WITH_CLOSEST_SITE", NETLOGON_VERSION_WITH_CLOSEST_SITE, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_AVOID_NT4_EMUL", NETLOGON_VERSION_AVOID_NT4_EMUL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_PDC", NETLOGON_VERSION_PDC, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_IP", NETLOGON_VERSION_IP, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_LOCAL", NETLOGON_VERSION_LOCAL, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETLOGON_VERSION_GC", NETLOGON_VERSION_GC, r); + ndr_print_netlogon_command(ndr, "command", r->command); + ndr_print_uint16(ndr, "sbz", r->sbz); + ndr_print_nbt_server_type(ndr, "server_type", r->server_type); + ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); + ndr_print_nbt_string(ndr, "forest", r->forest); + ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); + ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); + ndr_print_nbt_string(ndr, "domain", r->domain); + ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name); + ndr_print_nbt_string(ndr, "user_name", r->user_name); + ndr_print_nbt_string(ndr, "server_site", r->server_site); + ndr_print_nbt_string(ndr, "client_site", r->client_site); + ndr_print_uint8(ndr, "sockaddr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags):r->sockaddr_size); + ndr_print_nbt_sockaddr(ndr, "sockaddr", &r->sockaddr); + ndr_print_nbt_string(ndr, "next_closest_site", r->next_closest_site); + ndr_print_netlogon_nt_version_flags(ndr, "nt_version", r->nt_version); + ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); + ndr_print_uint16(ndr, "lm20_token", r->lm20_token); ndr->depth--; - ndr->flags = _flags_save_BITMAP; + ndr->flags = _flags_save_STRUCT; } } @@ -1651,7 +2044,7 @@ static enum ndr_err_code ndr_push_nbt_netlogon_query_for_pdc(struct ndr_push *nd NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_name)); ndr->flags = _flags_save_string; } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); } @@ -1688,7 +2081,7 @@ static enum ndr_err_code ndr_pull_nbt_netlogon_query_for_pdc(struct ndr_pull *nd NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_name)); ndr->flags = _flags_save_string; } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); } @@ -1705,2146 +2098,322 @@ _PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc(struct ndr_print *ndr, const ndr_print_string(ndr, "mailslot_name", r->mailslot_name); ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); ndr_print_string(ndr, "unicode_name", r->unicode_name); - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); + ndr_print_netlogon_nt_version_flags(ndr, "nt_version", r->nt_version); ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); ndr_print_uint16(ndr, "lm20_token", r->lm20_token); ndr->depth--; } -static enum ndr_err_code ndr_push_nbt_netlogon_query_for_pdc2(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_query_for_pdc2 *r) -{ - uint32_t cntr_unknown_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name)); - ndr->flags = _flags_save_string; - } - for (cntr_unknown_0 = 0; cntr_unknown_0 < 2; cntr_unknown_0++) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown[cntr_unknown_0])); - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_netlogon_query_for_pdc2(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_query_for_pdc2 *r) -{ - uint32_t cntr_unknown_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name)); - ndr->flags = _flags_save_string; - } - for (cntr_unknown_0 = 0; cntr_unknown_0 < 2; cntr_unknown_0++) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown[cntr_unknown_0])); - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc2 *r) -{ - uint32_t cntr_unknown_0; - ndr_print_struct(ndr, name, "nbt_netlogon_query_for_pdc2"); - ndr->depth++; - ndr_print_uint16(ndr, "request_count", r->request_count); - ndr_print_string(ndr, "computer_name", r->computer_name); - ndr_print_string(ndr, "user_name", r->user_name); - ndr_print_string(ndr, "mailslot_name", r->mailslot_name); - ndr->print(ndr, "%s: ARRAY(%d)", "unknown", (int)2); - ndr->depth++; - for (cntr_unknown_0=0;cntr_unknown_0<2;cntr_unknown_0++) { - char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) { - ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]); - free(idx_0); - } - } - ndr->depth--; - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_netlogon_response_from_pdc(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_response_from_pdc *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_netlogon_response_from_pdc(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_response_from_pdc *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r) -{ - ndr_print_struct(ndr, name, "nbt_netlogon_response_from_pdc"); - ndr->depth++; - ndr_print_string(ndr, "pdc_name", r->pdc_name); - ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); - ndr_print_string(ndr, "unicode_pdc_name", r->unicode_pdc_name); - ndr_print_string(ndr, "domain_name", r->domain_name); - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_server_type(struct ndr_push *ndr, int ndr_flags, uint32_t r) -{ - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_server_type(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) -{ - uint32_t v; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); - *r = v; - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r) -{ - ndr_print_uint32(ndr, name, r); - ndr->depth++; - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_PDC", NBT_SERVER_PDC, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_GC", NBT_SERVER_GC, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_LDAP", NBT_SERVER_LDAP, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_DS", NBT_SERVER_DS, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_KDC", NBT_SERVER_KDC, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_TIMESERV", NBT_SERVER_TIMESERV, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_CLOSEST", NBT_SERVER_CLOSEST, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_WRITABLE", NBT_SERVER_WRITABLE, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_GOOD_TIMESERV", NBT_SERVER_GOOD_TIMESERV, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_NDNC", NBT_SERVER_NDNC, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_SELECT_SECRET_DOMAIN_6", NBT_SERVER_SELECT_SECRET_DOMAIN_6, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NBT_SERVER_FULL_SECRET_DOMAIN_6", NBT_SERVER_FULL_SECRET_DOMAIN_6, r); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_dc_sock_addr(struct ndr_push *ndr, int ndr_flags, const struct nbt_dc_sock_addr *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->family)); - { - uint32_t _flags_save_ipv4address = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); - NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip)); - ndr->flags = _flags_save_ipv4address; - } - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->remaining)); - ndr->flags = _flags_save_DATA_BLOB; - } - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_dc_sock_addr(struct ndr_pull *ndr, int ndr_flags, struct nbt_dc_sock_addr *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->family)); - { - uint32_t _flags_save_ipv4address = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_BIGENDIAN); - NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip)); - ndr->flags = _flags_save_ipv4address; - } - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->remaining)); - ndr->flags = _flags_save_DATA_BLOB; - } - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_dc_sock_addr(struct ndr_print *ndr, const char *name, const struct nbt_dc_sock_addr *r) -{ - ndr_print_struct(ndr, name, "nbt_dc_sock_addr"); - ndr->depth++; - ndr_print_uint32(ndr, "family", r->family); - ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip); - ndr_print_DATA_BLOB(ndr, "remaining", r->remaining); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_netlogon_response_from_pdc2(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_response_from_pdc2 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } - NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->dc_sock_addr_size)); - { - struct ndr_push *_ndr_dc_sock_addr; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - NDR_CHECK(ndr_push_nbt_dc_sock_addr(_ndr_dc_sock_addr, NDR_SCALARS, &r->dc_sock_addr)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_netlogon_response_from_pdc2(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_response_from_pdc2 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } - NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->dc_sock_addr_size)); - { - struct ndr_pull *_ndr_dc_sock_addr; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - NDR_CHECK(ndr_pull_nbt_dc_sock_addr(_ndr_dc_sock_addr, NDR_SCALARS, &r->dc_sock_addr)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc2 *r) -{ - ndr_print_struct(ndr, name, "nbt_netlogon_response_from_pdc2"); - ndr->depth++; - ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); - ndr_print_nbt_server_type(ndr, "server_type", r->server_type); - ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); - ndr_print_nbt_string(ndr, "forest", r->forest); - ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); - ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); - ndr_print_nbt_string(ndr, "domain", r->domain); - ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name); - ndr_print_nbt_string(ndr, "user_name", r->user_name); - ndr_print_nbt_string(ndr, "server_site", r->server_site); - ndr_print_nbt_string(ndr, "client_site", r->client_site); - ndr_print_uint8(ndr, "dc_sock_addr_size", r->dc_sock_addr_size); - ndr_print_nbt_dc_sock_addr(ndr, "dc_sock_addr", &r->dc_sock_addr); - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_db_change(struct ndr_push *ndr, int ndr_flags, const struct nbt_db_change *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 8)); - NDR_CHECK(ndr_push_netr_SamDatabaseID(ndr, NDR_SCALARS, r->db_index)); - NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->serial)); - NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->timestamp)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_db_change(struct ndr_pull *ndr, int ndr_flags, struct nbt_db_change *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 8)); - NDR_CHECK(ndr_pull_netr_SamDatabaseID(ndr, NDR_SCALARS, &r->db_index)); - NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->serial)); - NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->timestamp)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_db_change(struct ndr_print *ndr, const char *name, const struct nbt_db_change *r) -{ - ndr_print_struct(ndr, name, "nbt_db_change"); - ndr->depth++; - ndr_print_netr_SamDatabaseID(ndr, "db_index", r->db_index); - ndr_print_hyper(ndr, "serial", r->serial); - ndr_print_NTTIME(ndr, "timestamp", r->timestamp); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_netlogon_announce_uas(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_announce_uas *r) -{ - uint32_t cntr_dbchange_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 8)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->serial_lo)); - NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->timestamp)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pulse)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->random)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); - NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_domain)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->db_count)); - for (cntr_dbchange_0 = 0; cntr_dbchange_0 < r->db_count; cntr_dbchange_0++) { - NDR_CHECK(ndr_push_nbt_db_change(ndr, NDR_SCALARS, &r->dbchange[cntr_dbchange_0])); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags))); - { - struct ndr_push *_ndr_sid; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); - NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_netlogon_announce_uas(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_announce_uas *r) -{ - uint32_t cntr_dbchange_0; - TALLOC_CTX *_mem_save_dbchange_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 8)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->serial_lo)); - NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->timestamp)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pulse)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->random)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_DATA_BLOB = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); - ndr->flags = _flags_save_DATA_BLOB; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_domain)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->db_count)); - NDR_PULL_ALLOC_N(ndr, r->dbchange, r->db_count); - _mem_save_dbchange_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->dbchange, 0); - for (cntr_dbchange_0 = 0; cntr_dbchange_0 < r->db_count; cntr_dbchange_0++) { - NDR_CHECK(ndr_pull_nbt_db_change(ndr, NDR_SCALARS, &r->dbchange[cntr_dbchange_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dbchange_0, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size)); - { - struct ndr_pull *_ndr_sid; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size)); - NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size)); - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_netlogon_announce_uas(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_announce_uas *r) -{ - uint32_t cntr_dbchange_0; - ndr_print_struct(ndr, name, "nbt_netlogon_announce_uas"); - ndr->depth++; - ndr_print_uint32(ndr, "serial_lo", r->serial_lo); - ndr_print_time_t(ndr, "timestamp", r->timestamp); - ndr_print_uint32(ndr, "pulse", r->pulse); - ndr_print_uint32(ndr, "random", r->random); - ndr_print_string(ndr, "pdc_name", r->pdc_name); - ndr_print_string(ndr, "domain", r->domain); - ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); - ndr_print_string(ndr, "unicode_pdc_name", r->unicode_pdc_name); - ndr_print_string(ndr, "unicode_domain", r->unicode_domain); - ndr_print_uint32(ndr, "db_count", r->db_count); - ndr->print(ndr, "%s: ARRAY(%d)", "dbchange", (int)r->db_count); - ndr->depth++; - for (cntr_dbchange_0=0;cntr_dbchange_0db_count;cntr_dbchange_0++) { - char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_dbchange_0) != -1) { - ndr_print_nbt_db_change(ndr, "dbchange", &r->dbchange[cntr_dbchange_0]); - free(idx_0); - } - } - ndr->depth--; - ndr_print_uint32(ndr, "sid_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->sid, ndr->flags):r->sid_size); - ndr_print_dom_sid0(ndr, "sid", &r->sid); - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_netlogon_request(struct ndr_push *ndr, int ndr_flags, const union nbt_netlogon_request *r) -{ - if (ndr_flags & NDR_SCALARS) { - int level = ndr_push_get_switch_value(ndr, r); - switch (level) { - case NETLOGON_QUERY_FOR_PDC: { - NDR_CHECK(ndr_push_nbt_netlogon_query_for_pdc(ndr, NDR_SCALARS, &r->pdc)); - break; } - - case NETLOGON_QUERY_FOR_PDC2: { - NDR_CHECK(ndr_push_nbt_netlogon_query_for_pdc2(ndr, NDR_SCALARS, &r->pdc2)); - break; } - - case NETLOGON_ANNOUNCE_UAS: { - NDR_CHECK(ndr_push_nbt_netlogon_announce_uas(ndr, NDR_SCALARS, &r->uas)); - break; } - - case NETLOGON_RESPONSE_FROM_PDC: { - NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc(ndr, NDR_SCALARS, &r->response)); - break; } - - case NETLOGON_RESPONSE_FROM_PDC2: { - NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2)); - break; } - - case NETLOGON_RESPONSE_FROM_PDC_USER: { - NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2)); - break; } - - default: - return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); - } - } - if (ndr_flags & NDR_BUFFERS) { - int level = ndr_push_get_switch_value(ndr, r); - switch (level) { - case NETLOGON_QUERY_FOR_PDC: - break; - - case NETLOGON_QUERY_FOR_PDC2: - break; - - case NETLOGON_ANNOUNCE_UAS: - NDR_CHECK(ndr_push_nbt_netlogon_announce_uas(ndr, NDR_BUFFERS, &r->uas)); - break; - - case NETLOGON_RESPONSE_FROM_PDC: - break; - - case NETLOGON_RESPONSE_FROM_PDC2: - break; - - case NETLOGON_RESPONSE_FROM_PDC_USER: - break; - - default: - return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); - } - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_netlogon_request(struct ndr_pull *ndr, int ndr_flags, union nbt_netlogon_request *r) -{ - int level; - level = ndr_pull_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case NETLOGON_QUERY_FOR_PDC: { - NDR_CHECK(ndr_pull_nbt_netlogon_query_for_pdc(ndr, NDR_SCALARS, &r->pdc)); - break; } - - case NETLOGON_QUERY_FOR_PDC2: { - NDR_CHECK(ndr_pull_nbt_netlogon_query_for_pdc2(ndr, NDR_SCALARS, &r->pdc2)); - break; } - - case NETLOGON_ANNOUNCE_UAS: { - NDR_CHECK(ndr_pull_nbt_netlogon_announce_uas(ndr, NDR_SCALARS, &r->uas)); - break; } - - case NETLOGON_RESPONSE_FROM_PDC: { - NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc(ndr, NDR_SCALARS, &r->response)); - break; } - - case NETLOGON_RESPONSE_FROM_PDC2: { - NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2)); - break; } - - case NETLOGON_RESPONSE_FROM_PDC_USER: { - NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->response2)); - break; } - - default: - return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); - } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case NETLOGON_QUERY_FOR_PDC: - break; - - case NETLOGON_QUERY_FOR_PDC2: - break; - - case NETLOGON_ANNOUNCE_UAS: - NDR_CHECK(ndr_pull_nbt_netlogon_announce_uas(ndr, NDR_BUFFERS, &r->uas)); - break; - - case NETLOGON_RESPONSE_FROM_PDC: - break; - - case NETLOGON_RESPONSE_FROM_PDC2: - break; - - case NETLOGON_RESPONSE_FROM_PDC_USER: - break; - - default: - return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); - } - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r) -{ - int level; - level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "nbt_netlogon_request"); - switch (level) { - case NETLOGON_QUERY_FOR_PDC: - ndr_print_nbt_netlogon_query_for_pdc(ndr, "pdc", &r->pdc); - break; - - case NETLOGON_QUERY_FOR_PDC2: - ndr_print_nbt_netlogon_query_for_pdc2(ndr, "pdc2", &r->pdc2); - break; - - case NETLOGON_ANNOUNCE_UAS: - ndr_print_nbt_netlogon_announce_uas(ndr, "uas", &r->uas); - break; - - case NETLOGON_RESPONSE_FROM_PDC: - ndr_print_nbt_netlogon_response_from_pdc(ndr, "response", &r->response); - break; - - case NETLOGON_RESPONSE_FROM_PDC2: - ndr_print_nbt_netlogon_response_from_pdc2(ndr, "response2", &r->response2); - break; - - case NETLOGON_RESPONSE_FROM_PDC_USER: - ndr_print_nbt_netlogon_response_from_pdc2(ndr, "response2", &r->response2); - break; - - default: - ndr_print_bad_level(ndr, name, level); - } -} - -_PUBLIC_ enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r) -{ - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 8)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->command)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->req, r->command)); - NDR_CHECK(ndr_push_nbt_netlogon_request(ndr, NDR_SCALARS, &r->req)); - } - if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_nbt_netlogon_request(ndr, NDR_BUFFERS, &r->req)); - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r) -{ - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 8)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->command)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->req, r->command)); - NDR_CHECK(ndr_pull_nbt_netlogon_request(ndr, NDR_SCALARS, &r->req)); - } - if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_nbt_netlogon_request(ndr, NDR_BUFFERS, &r->req)); - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r) -{ - ndr_print_struct(ndr, name, "nbt_netlogon_packet"); - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "command", r->command); - ndr_print_set_switch_value(ndr, &r->req, r->command); - ndr_print_nbt_netlogon_request(ndr, "req", &r->req); - ndr->depth--; - ndr->flags = _flags_save_STRUCT; - } -} - -static enum ndr_err_code ndr_push_nbt_cldap_netlogon_1(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_1 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, 1)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_1(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_1 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->type)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_1(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_1 *r) -{ - ndr_print_struct(ndr, name, "nbt_cldap_netlogon_1"); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "type", r->type); - ndr_print_string(ndr, "pdc_name", r->pdc_name); - ndr_print_string(ndr, "user_name", r->user_name); - ndr_print_string(ndr, "domain_name", r->domain_name); - ndr_print_nbt_netlogon_version(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?1:r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_cldap_netlogon_3(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_3 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->unknown_uuid)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); - NDR_CHECK(ndr_push_ipv4address(ndr, NDR_SCALARS, r->pdc_ip)); - NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, 3)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_3(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_3 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->type)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->unknown_uuid)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); - NDR_CHECK(ndr_pull_ipv4address(ndr, NDR_SCALARS, &r->pdc_ip)); - NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_3(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_3 *r) -{ - ndr_print_struct(ndr, name, "nbt_cldap_netlogon_3"); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "type", r->type); - ndr_print_string(ndr, "pdc_name", r->pdc_name); - ndr_print_string(ndr, "user_name", r->user_name); - ndr_print_string(ndr, "domain_name", r->domain_name); - ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); - ndr_print_GUID(ndr, "unknown_uuid", &r->unknown_uuid); - ndr_print_nbt_string(ndr, "forest", r->forest); - ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); - ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); - ndr_print_ipv4address(ndr, "pdc_ip", r->pdc_ip); - ndr_print_nbt_server_type(ndr, "server_type", r->server_type); - ndr_print_nbt_netlogon_version(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?3:r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_5(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_5 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz)); - NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, 5)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_5(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_5 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); - NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_5(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_5 *r) -{ - ndr_print_struct(ndr, name, "nbt_cldap_netlogon_5"); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "type", r->type); - ndr_print_uint16(ndr, "sbz", r->sbz); - ndr_print_nbt_server_type(ndr, "server_type", r->server_type); - ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); - ndr_print_nbt_string(ndr, "forest", r->forest); - ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); - ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); - ndr_print_nbt_string(ndr, "domain", r->domain); - ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name); - ndr_print_nbt_string(ndr, "user_name", r->user_name); - ndr_print_nbt_string(ndr, "server_site", r->server_site); - ndr_print_nbt_string(ndr, "client_site", r->client_site); - ndr_print_nbt_netlogon_version(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?5:r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -static enum ndr_err_code ndr_push_nbt_cldap_netlogon_13(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_13 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz)); - NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->dc_sock_addr_size)); - { - struct ndr_push *_ndr_dc_sock_addr; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - NDR_CHECK(ndr_push_nbt_dc_sock_addr(_ndr_dc_sock_addr, NDR_SCALARS, &r->dc_sock_addr)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, 13)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_nbt_cldap_netlogon_13(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_13 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); - NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->dc_sock_addr_size)); - { - struct ndr_pull *_ndr_dc_sock_addr; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - NDR_CHECK(ndr_pull_nbt_dc_sock_addr(_ndr_dc_sock_addr, NDR_SCALARS, &r->dc_sock_addr)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_13 *r) -{ - ndr_print_struct(ndr, name, "nbt_cldap_netlogon_13"); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "type", r->type); - ndr_print_uint16(ndr, "sbz", r->sbz); - ndr_print_nbt_server_type(ndr, "server_type", r->server_type); - ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); - ndr_print_nbt_string(ndr, "forest", r->forest); - ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); - ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); - ndr_print_nbt_string(ndr, "domain", r->domain); - ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name); - ndr_print_nbt_string(ndr, "user_name", r->user_name); - ndr_print_nbt_string(ndr, "server_site", r->server_site); - ndr_print_nbt_string(ndr, "client_site", r->client_site); - ndr_print_uint8(ndr, "dc_sock_addr_size", r->dc_sock_addr_size); - ndr_print_nbt_dc_sock_addr(ndr, "dc_sock_addr", &r->dc_sock_addr); - ndr_print_nbt_netlogon_version(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?13:r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_15(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_15 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz)); - NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site)); - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, 15)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_15(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_15 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); - NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site)); - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_15(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_15 *r) -{ - ndr_print_struct(ndr, name, "nbt_cldap_netlogon_15"); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "type", r->type); - ndr_print_uint16(ndr, "sbz", r->sbz); - ndr_print_nbt_server_type(ndr, "server_type", r->server_type); - ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); - ndr_print_nbt_string(ndr, "forest", r->forest); - ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); - ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); - ndr_print_nbt_string(ndr, "domain", r->domain); - ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name); - ndr_print_nbt_string(ndr, "user_name", r->user_name); - ndr_print_nbt_string(ndr, "server_site", r->server_site); - ndr_print_nbt_string(ndr, "client_site", r->client_site); - ndr_print_nbt_string(ndr, "next_closest_site", r->next_closest_site); - ndr_print_nbt_netlogon_version(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?15:r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_29(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_29 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz)); - NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site)); - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site)); - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->dc_sock_addr_size)); - { - struct ndr_push *_ndr_dc_sock_addr; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - NDR_CHECK(ndr_push_nbt_dc_sock_addr(_ndr_dc_sock_addr, NDR_SCALARS, &r->dc_sock_addr)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - } - NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site)); - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, 29)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_29(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_29 *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_netlogon_command(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz)); - NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site)); - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site)); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->dc_sock_addr_size)); - { - struct ndr_pull *_ndr_dc_sock_addr; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - NDR_CHECK(ndr_pull_nbt_dc_sock_addr(_ndr_dc_sock_addr, NDR_SCALARS, &r->dc_sock_addr)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_dc_sock_addr, 0, r->dc_sock_addr_size)); - } - NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site)); - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon_29(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_29 *r) -{ - ndr_print_struct(ndr, name, "nbt_cldap_netlogon_29"); - ndr->depth++; - ndr_print_nbt_netlogon_command(ndr, "type", r->type); - ndr_print_uint16(ndr, "sbz", r->sbz); - ndr_print_nbt_server_type(ndr, "server_type", r->server_type); - ndr_print_GUID(ndr, "domain_uuid", &r->domain_uuid); - ndr_print_nbt_string(ndr, "forest", r->forest); - ndr_print_nbt_string(ndr, "dns_domain", r->dns_domain); - ndr_print_nbt_string(ndr, "pdc_dns_name", r->pdc_dns_name); - ndr_print_nbt_string(ndr, "domain", r->domain); - ndr_print_nbt_string(ndr, "pdc_name", r->pdc_name); - ndr_print_nbt_string(ndr, "user_name", r->user_name); - ndr_print_nbt_string(ndr, "server_site", r->server_site); - ndr_print_nbt_string(ndr, "client_site", r->client_site); - ndr_print_uint8(ndr, "dc_sock_addr_size", r->dc_sock_addr_size); - ndr_print_nbt_dc_sock_addr(ndr, "dc_sock_addr", &r->dc_sock_addr); - ndr_print_nbt_string(ndr, "next_closest_site", r->next_closest_site); - ndr_print_nbt_netlogon_version(ndr, "nt_version", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?29:r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); - ndr->depth--; -} - -_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon(struct ndr_push *ndr, int ndr_flags, const union nbt_cldap_netlogon *r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_netlogon_response_from_pdc(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_response_from_pdc *r) { { - uint32_t _flags_save_UNION = ndr->flags; + uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); if (ndr_flags & NDR_SCALARS) { - int level = ndr_push_get_switch_value(ndr, r); - switch (level) { - case 0: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 1: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 2: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 3: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 4: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 5: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 6: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 7: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 8: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 9: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 10: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 11: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 12: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 13: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 14: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 15: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 16: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 17: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 18: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 19: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 20: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 21: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 22: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 23: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 24: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 25: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 26: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 27: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 28: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 29: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_29(ndr, NDR_SCALARS, &r->logon29)); - break; } - - case 30: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_29(ndr, NDR_SCALARS, &r->logon29)); - break; } - - case 31: { - NDR_CHECK(ndr_push_nbt_cldap_netlogon_29(ndr, NDR_SCALARS, &r->logon29)); - break; } - - default: - return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); - } - } - if (ndr_flags & NDR_BUFFERS) { - int level = ndr_push_get_switch_value(ndr, r); - switch (level) { - case 0: - break; - - case 1: - break; - - case 2: - break; - - case 3: - break; - - case 4: - break; - - case 5: - break; - - case 6: - break; - - case 7: - break; - - case 8: - break; - - case 9: - break; - - case 10: - break; - - case 11: - break; - - case 12: - break; - - case 13: - break; - - case 14: - break; - - case 15: - break; - - case 16: - break; - - case 17: - break; - - case 18: - break; - - case 19: - break; - - case 20: - break; - - case 21: - break; - - case 22: - break; - - case 23: - break; - - case 24: - break; - - case 25: - break; - - case 26: - break; - - case 27: - break; - - case 28: - break; - - case 29: - break; - - case 30: - break; - - case 31: - break; - - default: - return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); + ndr->flags = _flags_save_string; } - } - ndr->flags = _flags_save_UNION; - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon(struct ndr_pull *ndr, int ndr_flags, union nbt_cldap_netlogon *r) -{ - int level; - { - uint32_t _flags_save_UNION = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - level = ndr_pull_get_switch_value(ndr, r); - if (ndr_flags & NDR_SCALARS) { - switch (level) { - case 0: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 1: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 2: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 3: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 4: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 5: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 6: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 7: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_5(ndr, NDR_SCALARS, &r->logon5)); - break; } - - case 8: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 9: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 10: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 11: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 12: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 13: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 14: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 15: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_13(ndr, NDR_SCALARS, &r->logon13)); - break; } - - case 16: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 17: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_1(ndr, NDR_SCALARS, &r->logon1)); - break; } - - case 18: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 19: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_3(ndr, NDR_SCALARS, &r->logon3)); - break; } - - case 20: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 21: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 22: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 23: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 24: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 25: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 26: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 27: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 28: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_15(ndr, NDR_SCALARS, &r->logon15)); - break; } - - case 29: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_29(ndr, NDR_SCALARS, &r->logon29)); - break; } - - case 30: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_29(ndr, NDR_SCALARS, &r->logon29)); - break; } - - case 31: { - NDR_CHECK(ndr_pull_nbt_cldap_netlogon_29(ndr, NDR_SCALARS, &r->logon29)); - break; } - - default: - return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); + ndr->flags = _flags_save_DATA_BLOB; } - } - if (ndr_flags & NDR_BUFFERS) { - switch (level) { - case 0: - break; - - case 1: - break; - - case 2: - break; - - case 3: - break; - - case 4: - break; - - case 5: - break; - - case 6: - break; - - case 7: - break; - - case 8: - break; - - case 9: - break; - - case 10: - break; - - case 11: - break; - - case 12: - break; - - case 13: - break; - - case 14: - break; - - case 15: - break; - - case 16: - break; - - case 17: - break; - - case 18: - break; - - case 19: - break; - - case 20: - break; - - case 21: - break; - - case 22: - break; - - case 23: - break; - - case 24: - break; - - case 25: - break; - - case 26: - break; - - case 27: - break; - - case 28: - break; - - case 29: - break; - - case 30: - break; - - case 31: - break; - - default: - return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_pdc_name)); + ndr->flags = _flags_save_string; } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { } - ndr->flags = _flags_save_UNION; - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_nbt_cldap_netlogon(struct ndr_print *ndr, const char *name, const union nbt_cldap_netlogon *r) -{ - int level; - { - uint32_t _flags_save_UNION = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "nbt_cldap_netlogon"); - switch (level) { - case 0: - ndr_print_nbt_cldap_netlogon_1(ndr, "logon1", &r->logon1); - break; - - case 1: - ndr_print_nbt_cldap_netlogon_1(ndr, "logon1", &r->logon1); - break; - - case 2: - ndr_print_nbt_cldap_netlogon_3(ndr, "logon3", &r->logon3); - break; - - case 3: - ndr_print_nbt_cldap_netlogon_3(ndr, "logon3", &r->logon3); - break; - - case 4: - ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5); - break; - - case 5: - ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5); - break; - - case 6: - ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5); - break; - - case 7: - ndr_print_nbt_cldap_netlogon_5(ndr, "logon5", &r->logon5); - break; - - case 8: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 9: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 10: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 11: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 12: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 13: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 14: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 15: - ndr_print_nbt_cldap_netlogon_13(ndr, "logon13", &r->logon13); - break; - - case 16: - ndr_print_nbt_cldap_netlogon_1(ndr, "logon1", &r->logon1); - break; - - case 17: - ndr_print_nbt_cldap_netlogon_1(ndr, "logon1", &r->logon1); - break; - - case 18: - ndr_print_nbt_cldap_netlogon_3(ndr, "logon3", &r->logon3); - break; - - case 19: - ndr_print_nbt_cldap_netlogon_3(ndr, "logon3", &r->logon3); - break; - - case 20: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 21: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 22: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 23: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 24: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 25: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 26: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 27: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 28: - ndr_print_nbt_cldap_netlogon_15(ndr, "logon15", &r->logon15); - break; - - case 29: - ndr_print_nbt_cldap_netlogon_29(ndr, "logon29", &r->logon29); - break; - - case 30: - ndr_print_nbt_cldap_netlogon_29(ndr, "logon29", &r->logon29); - break; - - case 31: - ndr_print_nbt_cldap_netlogon_29(ndr, "logon29", &r->logon29); - break; - - default: - ndr_print_bad_level(ndr, name, level); - } - ndr->flags = _flags_save_UNION; + ndr->flags = _flags_save_STRUCT; } -} - -static enum ndr_err_code ndr_push_nbt_ntlogon_command(struct ndr_push *ndr, int ndr_flags, enum nbt_ntlogon_command r) -{ - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_ntlogon_command(struct ndr_pull *ndr, int ndr_flags, enum nbt_ntlogon_command *r) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_netlogon_response_from_pdc(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_response_from_pdc *r) { - uint16_t v; - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); - *r = v; + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); + ndr->flags = _flags_save_DATA_BLOB; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_pdc_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_ntlogon_command(struct ndr_print *ndr, const char *name, enum nbt_ntlogon_command r) +_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r) { - const char *val = NULL; - - switch (r) { - case NTLOGON_SAM_LOGON: val = "NTLOGON_SAM_LOGON"; break; - case NTLOGON_SAM_LOGON_REPLY: val = "NTLOGON_SAM_LOGON_REPLY"; break; - case NTLOGON_SAM_LOGON_REPLY15: val = "NTLOGON_SAM_LOGON_REPLY15"; break; - case NTLOGON_RESPONSE_FROM_PDC2: val = "NTLOGON_RESPONSE_FROM_PDC2"; break; + ndr_print_struct(ndr, name, "nbt_netlogon_response_from_pdc"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + ndr->depth++; + ndr_print_netlogon_command(ndr, "command", r->command); + ndr_print_string(ndr, "pdc_name", r->pdc_name); + ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); + ndr_print_string(ndr, "unicode_pdc_name", r->unicode_pdc_name); + ndr_print_string(ndr, "domain_name", r->domain_name); + ndr_print_netlogon_nt_version_flags(ndr, "nt_version", r->nt_version); + ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); + ndr_print_uint16(ndr, "lm20_token", r->lm20_token); + ndr->depth--; + ndr->flags = _flags_save_STRUCT; } - ndr_print_enum(ndr, name, "ENUM", val, r); } -static enum ndr_err_code ndr_push_nbt_ntlogon_sam_logon(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_sam_logon *r) +static enum ndr_err_code ndr_push_nbt_db_change_info(struct ndr_push *ndr, int ndr_flags, const struct nbt_db_change_info *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_push_samr_AcctFlags(ndr, NDR_SCALARS, r->acct_control)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags))); - { - struct ndr_push *_ndr_sid; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); - NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); - } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_netr_SamDatabaseID(ndr, NDR_SCALARS, r->db_index)); + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->serial)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->timestamp)); } if (ndr_flags & NDR_BUFFERS) { } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_ntlogon_sam_logon(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_sam_logon *r) +static enum ndr_err_code ndr_pull_nbt_db_change_info(struct ndr_pull *ndr, int ndr_flags, struct nbt_db_change_info *r) { if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count)); - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); - ndr->flags = _flags_save_string; - } - { - uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name)); - ndr->flags = _flags_save_string; - } - NDR_CHECK(ndr_pull_samr_AcctFlags(ndr, NDR_SCALARS, &r->acct_control)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size)); - { - struct ndr_pull *_ndr_sid; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size)); - NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size)); - } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_netr_SamDatabaseID(ndr, NDR_SCALARS, &r->db_index)); + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->serial)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->timestamp)); } if (ndr_flags & NDR_BUFFERS) { } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon *r) +_PUBLIC_ void ndr_print_nbt_db_change_info(struct ndr_print *ndr, const char *name, const struct nbt_db_change_info *r) { - ndr_print_struct(ndr, name, "nbt_ntlogon_sam_logon"); + ndr_print_struct(ndr, name, "nbt_db_change_info"); ndr->depth++; - ndr_print_uint16(ndr, "request_count", r->request_count); - ndr_print_string(ndr, "computer_name", r->computer_name); - ndr_print_string(ndr, "user_name", r->user_name); - ndr_print_string(ndr, "mailslot_name", r->mailslot_name); - ndr_print_samr_AcctFlags(ndr, "acct_control", r->acct_control); - ndr_print_uint32(ndr, "sid_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->sid, ndr->flags):r->sid_size); - ndr_print_dom_sid0(ndr, "sid", &r->sid); - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); + ndr_print_netr_SamDatabaseID(ndr, "db_index", r->db_index); + ndr_print_hyper(ndr, "serial", r->serial); + ndr_print_NTTIME(ndr, "timestamp", r->timestamp); ndr->depth--; } -static enum ndr_err_code ndr_push_nbt_ntlogon_sam_logon_reply(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_sam_logon_reply *r) +static enum ndr_err_code ndr_push_NETLOGON_DB_CHANGE(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_DB_CHANGE *r) { + uint32_t cntr_dbchange_0; if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->serial_lo)); + NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->timestamp)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pulse)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->random)); { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->server)); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->pdc_name)); ndr->flags = _flags_save_string; } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad)); + ndr->flags = _flags_save_DATA_BLOB; + } { uint32_t _flags_save_string = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_pdc_name)); ndr->flags = _flags_save_string; } { uint32_t _flags_save_string = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->unicode_domain)); ndr->flags = _flags_save_string; } - NDR_CHECK(ndr_push_nbt_netlogon_version(ndr, NDR_SCALARS, r->nt_version)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->db_count)); + for (cntr_dbchange_0 = 0; cntr_dbchange_0 < r->db_count; cntr_dbchange_0++) { + NDR_CHECK(ndr_push_nbt_db_change_info(ndr, NDR_SCALARS, &r->dbchange[cntr_dbchange_0])); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags))); + { + struct ndr_push *_ndr_sid; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); + NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags))); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->message_format_version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->message_token)); } if (ndr_flags & NDR_BUFFERS) { } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_ntlogon_sam_logon_reply(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_sam_logon_reply *r) +static enum ndr_err_code ndr_pull_NETLOGON_DB_CHANGE(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_DB_CHANGE *r) { + uint32_t cntr_dbchange_0; + TALLOC_CTX *_mem_save_dbchange_0; if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->serial_lo)); + NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->timestamp)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pulse)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->random)); { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->server)); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->pdc_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain)); ndr->flags = _flags_save_string; } + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN2); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); + ndr->flags = _flags_save_DATA_BLOB; + } { uint32_t _flags_save_string = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_pdc_name)); ndr->flags = _flags_save_string; } { uint32_t _flags_save_string = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); - NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain)); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->unicode_domain)); ndr->flags = _flags_save_string; } - NDR_CHECK(ndr_pull_nbt_netlogon_version(ndr, NDR_SCALARS, &r->nt_version)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->db_count)); + NDR_PULL_ALLOC_N(ndr, r->dbchange, r->db_count); + _mem_save_dbchange_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->dbchange, 0); + for (cntr_dbchange_0 = 0; cntr_dbchange_0 < r->db_count; cntr_dbchange_0++) { + NDR_CHECK(ndr_pull_nbt_db_change_info(ndr, NDR_SCALARS, &r->dbchange[cntr_dbchange_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dbchange_0, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size)); + { + struct ndr_pull *_ndr_sid; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size)); + NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size)); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->message_format_version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->message_token)); } if (ndr_flags & NDR_BUFFERS) { } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon_reply(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon_reply *r) +_PUBLIC_ void ndr_print_NETLOGON_DB_CHANGE(struct ndr_print *ndr, const char *name, const struct NETLOGON_DB_CHANGE *r) { - ndr_print_struct(ndr, name, "nbt_ntlogon_sam_logon_reply"); + uint32_t cntr_dbchange_0; + ndr_print_struct(ndr, name, "NETLOGON_DB_CHANGE"); ndr->depth++; - ndr_print_string(ndr, "server", r->server); - ndr_print_string(ndr, "user_name", r->user_name); + ndr_print_uint32(ndr, "serial_lo", r->serial_lo); + ndr_print_time_t(ndr, "timestamp", r->timestamp); + ndr_print_uint32(ndr, "pulse", r->pulse); + ndr_print_uint32(ndr, "random", r->random); + ndr_print_string(ndr, "pdc_name", r->pdc_name); ndr_print_string(ndr, "domain", r->domain); - ndr_print_nbt_netlogon_version(ndr, "nt_version", r->nt_version); - ndr_print_uint16(ndr, "lmnt_token", r->lmnt_token); - ndr_print_uint16(ndr, "lm20_token", r->lm20_token); + ndr_print_DATA_BLOB(ndr, "_pad", r->_pad); + ndr_print_string(ndr, "unicode_pdc_name", r->unicode_pdc_name); + ndr_print_string(ndr, "unicode_domain", r->unicode_domain); + ndr_print_uint32(ndr, "db_count", r->db_count); + ndr->print(ndr, "%s: ARRAY(%d)", "dbchange", (int)r->db_count); + ndr->depth++; + for (cntr_dbchange_0=0;cntr_dbchange_0db_count;cntr_dbchange_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_dbchange_0) != -1) { + ndr_print_nbt_db_change_info(ndr, "dbchange", &r->dbchange[cntr_dbchange_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_uint32(ndr, "sid_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->sid, ndr->flags):r->sid_size); + ndr_print_dom_sid0(ndr, "sid", &r->sid); + ndr_print_uint32(ndr, "message_format_version", r->message_format_version); + ndr_print_uint32(ndr, "message_token", r->message_token); ndr->depth--; } -static enum ndr_err_code ndr_push_nbt_ntlogon_request(struct ndr_push *ndr, int ndr_flags, const union nbt_ntlogon_request *r) +static enum ndr_err_code ndr_push_nbt_netlogon_request(struct ndr_push *ndr, int ndr_flags, const union nbt_netlogon_request *r) { if (ndr_flags & NDR_SCALARS) { int level = ndr_push_get_switch_value(ndr, r); switch (level) { - case NTLOGON_SAM_LOGON: { - NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon(ndr, NDR_SCALARS, &r->logon)); - break; } - - case NTLOGON_SAM_LOGON_REPLY: { - NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply)); + case LOGON_SAM_LOGON_REQUEST: { + NDR_CHECK(ndr_push_NETLOGON_SAM_LOGON_REQUEST(ndr, NDR_SCALARS, &r->logon)); break; } - case NTLOGON_SAM_LOGON_REPLY15: { - NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply)); + case LOGON_PRIMARY_QUERY: { + NDR_CHECK(ndr_push_nbt_netlogon_query_for_pdc(ndr, NDR_SCALARS, &r->pdc)); break; } - case NTLOGON_RESPONSE_FROM_PDC2: { - NDR_CHECK(ndr_push_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->reply2)); + case NETLOGON_ANNOUNCE_UAS: { + NDR_CHECK(ndr_push_NETLOGON_DB_CHANGE(ndr, NDR_SCALARS, &r->uas)); break; } default: @@ -3854,17 +2423,15 @@ static enum ndr_err_code ndr_push_nbt_ntlogon_request(struct ndr_push *ndr, int if (ndr_flags & NDR_BUFFERS) { int level = ndr_push_get_switch_value(ndr, r); switch (level) { - case NTLOGON_SAM_LOGON: - NDR_CHECK(ndr_push_nbt_ntlogon_sam_logon(ndr, NDR_BUFFERS, &r->logon)); - break; - - case NTLOGON_SAM_LOGON_REPLY: + case LOGON_SAM_LOGON_REQUEST: + NDR_CHECK(ndr_push_NETLOGON_SAM_LOGON_REQUEST(ndr, NDR_BUFFERS, &r->logon)); break; - case NTLOGON_SAM_LOGON_REPLY15: + case LOGON_PRIMARY_QUERY: break; - case NTLOGON_RESPONSE_FROM_PDC2: + case NETLOGON_ANNOUNCE_UAS: + NDR_CHECK(ndr_push_NETLOGON_DB_CHANGE(ndr, NDR_BUFFERS, &r->uas)); break; default: @@ -3874,26 +2441,22 @@ static enum ndr_err_code ndr_push_nbt_ntlogon_request(struct ndr_push *ndr, int return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_nbt_ntlogon_request(struct ndr_pull *ndr, int ndr_flags, union nbt_ntlogon_request *r) +static enum ndr_err_code ndr_pull_nbt_netlogon_request(struct ndr_pull *ndr, int ndr_flags, union nbt_netlogon_request *r) { int level; level = ndr_pull_get_switch_value(ndr, r); if (ndr_flags & NDR_SCALARS) { switch (level) { - case NTLOGON_SAM_LOGON: { - NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon(ndr, NDR_SCALARS, &r->logon)); - break; } - - case NTLOGON_SAM_LOGON_REPLY: { - NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply)); + case LOGON_SAM_LOGON_REQUEST: { + NDR_CHECK(ndr_pull_NETLOGON_SAM_LOGON_REQUEST(ndr, NDR_SCALARS, &r->logon)); break; } - case NTLOGON_SAM_LOGON_REPLY15: { - NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon_reply(ndr, NDR_SCALARS, &r->reply)); + case LOGON_PRIMARY_QUERY: { + NDR_CHECK(ndr_pull_nbt_netlogon_query_for_pdc(ndr, NDR_SCALARS, &r->pdc)); break; } - case NTLOGON_RESPONSE_FROM_PDC2: { - NDR_CHECK(ndr_pull_nbt_netlogon_response_from_pdc2(ndr, NDR_SCALARS, &r->reply2)); + case NETLOGON_ANNOUNCE_UAS: { + NDR_CHECK(ndr_pull_NETLOGON_DB_CHANGE(ndr, NDR_SCALARS, &r->uas)); break; } default: @@ -3902,17 +2465,15 @@ static enum ndr_err_code ndr_pull_nbt_ntlogon_request(struct ndr_pull *ndr, int } if (ndr_flags & NDR_BUFFERS) { switch (level) { - case NTLOGON_SAM_LOGON: - NDR_CHECK(ndr_pull_nbt_ntlogon_sam_logon(ndr, NDR_BUFFERS, &r->logon)); - break; - - case NTLOGON_SAM_LOGON_REPLY: + case LOGON_SAM_LOGON_REQUEST: + NDR_CHECK(ndr_pull_NETLOGON_SAM_LOGON_REQUEST(ndr, NDR_BUFFERS, &r->logon)); break; - case NTLOGON_SAM_LOGON_REPLY15: + case LOGON_PRIMARY_QUERY: break; - case NTLOGON_RESPONSE_FROM_PDC2: + case NETLOGON_ANNOUNCE_UAS: + NDR_CHECK(ndr_pull_NETLOGON_DB_CHANGE(ndr, NDR_BUFFERS, &r->uas)); break; default: @@ -3922,26 +2483,22 @@ static enum ndr_err_code ndr_pull_nbt_ntlogon_request(struct ndr_pull *ndr, int return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *name, const union nbt_ntlogon_request *r) +_PUBLIC_ void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r) { int level; level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "nbt_ntlogon_request"); + ndr_print_union(ndr, name, level, "nbt_netlogon_request"); switch (level) { - case NTLOGON_SAM_LOGON: - ndr_print_nbt_ntlogon_sam_logon(ndr, "logon", &r->logon); - break; - - case NTLOGON_SAM_LOGON_REPLY: - ndr_print_nbt_ntlogon_sam_logon_reply(ndr, "reply", &r->reply); + case LOGON_SAM_LOGON_REQUEST: + ndr_print_NETLOGON_SAM_LOGON_REQUEST(ndr, "logon", &r->logon); break; - case NTLOGON_SAM_LOGON_REPLY15: - ndr_print_nbt_ntlogon_sam_logon_reply(ndr, "reply", &r->reply); + case LOGON_PRIMARY_QUERY: + ndr_print_nbt_netlogon_query_for_pdc(ndr, "pdc", &r->pdc); break; - case NTLOGON_RESPONSE_FROM_PDC2: - ndr_print_nbt_netlogon_response_from_pdc2(ndr, "reply2", &r->reply2); + case NETLOGON_ANNOUNCE_UAS: + ndr_print_NETLOGON_DB_CHANGE(ndr, "uas", &r->uas); break; default: @@ -3949,54 +2506,54 @@ _PUBLIC_ void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *n } } -_PUBLIC_ enum ndr_err_code ndr_push_nbt_ntlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_packet *r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r) { { uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_nbt_ntlogon_command(ndr, NDR_SCALARS, r->command)); + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command)); NDR_CHECK(ndr_push_set_switch_value(ndr, &r->req, r->command)); - NDR_CHECK(ndr_push_nbt_ntlogon_request(ndr, NDR_SCALARS, &r->req)); + NDR_CHECK(ndr_push_nbt_netlogon_request(ndr, NDR_SCALARS, &r->req)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_nbt_ntlogon_request(ndr, NDR_BUFFERS, &r->req)); + NDR_CHECK(ndr_push_nbt_netlogon_request(ndr, NDR_BUFFERS, &r->req)); } ndr->flags = _flags_save_STRUCT; } return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull_nbt_ntlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_packet *r) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r) { { uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_nbt_ntlogon_command(ndr, NDR_SCALARS, &r->command)); + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command)); NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->req, r->command)); - NDR_CHECK(ndr_pull_nbt_ntlogon_request(ndr, NDR_SCALARS, &r->req)); + NDR_CHECK(ndr_pull_nbt_netlogon_request(ndr, NDR_SCALARS, &r->req)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_nbt_ntlogon_request(ndr, NDR_BUFFERS, &r->req)); + NDR_CHECK(ndr_pull_nbt_netlogon_request(ndr, NDR_BUFFERS, &r->req)); } ndr->flags = _flags_save_STRUCT; } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_nbt_ntlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_packet *r) +_PUBLIC_ void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r) { - ndr_print_struct(ndr, name, "nbt_ntlogon_packet"); + ndr_print_struct(ndr, name, "nbt_netlogon_packet"); { uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); ndr->depth++; - ndr_print_nbt_ntlogon_command(ndr, "command", r->command); + ndr_print_netlogon_command(ndr, "command", r->command); ndr_print_set_switch_value(ndr, &r->req, r->command); - ndr_print_nbt_ntlogon_request(ndr, "req", &r->req); + ndr_print_nbt_netlogon_request(ndr, "req", &r->req); ndr->depth--; ndr->flags = _flags_save_STRUCT; } diff --git a/source3/librpc/gen_ndr/ndr_nbt.h b/source3/librpc/gen_ndr/ndr_nbt.h index 6e9702d5d5..1a0ca0c302 100644 --- a/source3/librpc/gen_ndr/ndr_nbt.h +++ b/source3/librpc/gen_ndr/ndr_nbt.h @@ -6,14 +6,19 @@ #ifndef _HEADER_NDR_nbt #define _HEADER_NDR_nbt -#include "libcli/nbt/libnbt.h" +#include "../libcli/netlogon.h" +#include "../libcli/nbt/libnbt.h" #define NDR_NBT_CALL_COUNT (0) void ndr_print_nbt_operation(struct ndr_print *ndr, const char *name, uint16_t r); void ndr_print_nbt_name_type(struct ndr_print *ndr, const char *name, enum nbt_name_type r); enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r); enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r); void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r); +enum ndr_err_code ndr_push_nbt_qclass(struct ndr_push *ndr, int ndr_flags, enum nbt_qclass r); +enum ndr_err_code ndr_pull_nbt_qclass(struct ndr_pull *ndr, int ndr_flags, enum nbt_qclass *r); void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum nbt_qclass r); +enum ndr_err_code ndr_push_nbt_qtype(struct ndr_push *ndr, int ndr_flags, enum nbt_qtype r); +enum ndr_err_code ndr_pull_nbt_qtype(struct ndr_pull *ndr, int ndr_flags, enum nbt_qtype *r); void ndr_print_nbt_qtype(struct ndr_print *ndr, const char *name, enum nbt_qtype r); void ndr_print_nbt_name_question(struct ndr_print *ndr, const char *name, const struct nbt_name_question *r); void ndr_print_nb_flags(struct ndr_print *ndr, const char *name, uint16_t r); @@ -23,7 +28,10 @@ void ndr_print_nbt_statistics(struct ndr_print *ndr, const char *name, const str void ndr_print_nbt_status_name(struct ndr_print *ndr, const char *name, const struct nbt_status_name *r); void ndr_print_nbt_rdata_status(struct ndr_print *ndr, const char *name, const struct nbt_rdata_status *r); void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name, const struct nbt_rdata_data *r); +enum ndr_err_code ndr_push_nbt_rdata(struct ndr_push *ndr, int ndr_flags, const union nbt_rdata *r); +enum ndr_err_code ndr_pull_nbt_rdata(struct ndr_pull *ndr, int ndr_flags, union nbt_rdata *r); void ndr_print_nbt_rdata(struct ndr_print *ndr, const char *name, const union nbt_rdata *r); +enum ndr_err_code ndr_push_nbt_res_rec(struct ndr_push *ndr, int ndr_flags, const struct nbt_res_rec *r); void ndr_print_nbt_res_rec(struct ndr_print *ndr, const char *name, const struct nbt_res_rec *r); enum ndr_err_code ndr_push_nbt_name_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_name_packet *r); enum ndr_err_code ndr_pull_nbt_name_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_name_packet *r); @@ -43,42 +51,41 @@ void ndr_print_dgram_data(struct ndr_print *ndr, const char *name, const union d enum ndr_err_code ndr_push_nbt_dgram_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_dgram_packet *r); enum ndr_err_code ndr_pull_nbt_dgram_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_dgram_packet *r); void ndr_print_nbt_dgram_packet(struct ndr_print *ndr, const char *name, const struct nbt_dgram_packet *r); -void ndr_print_nbt_netlogon_command(struct ndr_print *ndr, const char *name, enum nbt_netlogon_command r); -void ndr_print_nbt_netlogon_version(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_nbt_sockaddr(struct ndr_push *ndr, int ndr_flags, const struct nbt_sockaddr *r); +enum ndr_err_code ndr_pull_nbt_sockaddr(struct ndr_pull *ndr, int ndr_flags, struct nbt_sockaddr *r); +void ndr_print_nbt_sockaddr(struct ndr_print *ndr, const char *name, const struct nbt_sockaddr *r); +size_t ndr_size_nbt_sockaddr(const struct nbt_sockaddr *r, int flags); +enum ndr_err_code ndr_push_nbt_server_type(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_nbt_server_type(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_netlogon_nt_version_flags(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_netlogon_nt_version_flags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_netlogon_nt_version_flags(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_netlogon_command(struct ndr_push *ndr, int ndr_flags, enum netlogon_command r); +enum ndr_err_code ndr_pull_netlogon_command(struct ndr_pull *ndr, int ndr_flags, enum netlogon_command *r); +void ndr_print_netlogon_command(struct ndr_print *ndr, const char *name, enum netlogon_command r); +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_REQUEST(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_REQUEST *r); +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_REQUEST(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_REQUEST *r); +void ndr_print_NETLOGON_SAM_LOGON_REQUEST(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_REQUEST *r); +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_NT40(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_NT40 *r); +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_NT40(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_NT40 *r); +void ndr_print_NETLOGON_SAM_LOGON_RESPONSE_NT40(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_RESPONSE_NT40 *r); +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE *r); +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE *r); +void ndr_print_NETLOGON_SAM_LOGON_RESPONSE(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_RESPONSE *r); +enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r); +enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r); +void ndr_print_NETLOGON_SAM_LOGON_RESPONSE_EX(struct ndr_print *ndr, const char *name, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r); void ndr_print_nbt_netlogon_query_for_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc *r); -void ndr_print_nbt_netlogon_query_for_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc2 *r); +enum ndr_err_code ndr_push_nbt_netlogon_response_from_pdc(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_response_from_pdc *r); +enum ndr_err_code ndr_pull_nbt_netlogon_response_from_pdc(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_response_from_pdc *r); void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r); -void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r); -void ndr_print_nbt_dc_sock_addr(struct ndr_print *ndr, const char *name, const struct nbt_dc_sock_addr *r); -void ndr_print_nbt_netlogon_response_from_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc2 *r); -void ndr_print_nbt_db_change(struct ndr_print *ndr, const char *name, const struct nbt_db_change *r); -void ndr_print_nbt_netlogon_announce_uas(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_announce_uas *r); +void ndr_print_nbt_db_change_info(struct ndr_print *ndr, const char *name, const struct nbt_db_change_info *r); +void ndr_print_NETLOGON_DB_CHANGE(struct ndr_print *ndr, const char *name, const struct NETLOGON_DB_CHANGE *r); void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r); enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r); enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r); void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r); -void ndr_print_nbt_cldap_netlogon_1(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_1 *r); -void ndr_print_nbt_cldap_netlogon_3(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_3 *r); -enum ndr_err_code ndr_push_nbt_cldap_netlogon_5(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_5 *r); -enum ndr_err_code ndr_pull_nbt_cldap_netlogon_5(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_5 *r); -void ndr_print_nbt_cldap_netlogon_5(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_5 *r); -void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_13 *r); -enum ndr_err_code ndr_push_nbt_cldap_netlogon_15(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_15 *r); -enum ndr_err_code ndr_pull_nbt_cldap_netlogon_15(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_15 *r); -void ndr_print_nbt_cldap_netlogon_15(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_15 *r); -enum ndr_err_code ndr_push_nbt_cldap_netlogon_29(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_29 *r); -enum ndr_err_code ndr_pull_nbt_cldap_netlogon_29(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_29 *r); -void ndr_print_nbt_cldap_netlogon_29(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_29 *r); -enum ndr_err_code ndr_push_nbt_cldap_netlogon(struct ndr_push *ndr, int ndr_flags, const union nbt_cldap_netlogon *r); -enum ndr_err_code ndr_pull_nbt_cldap_netlogon(struct ndr_pull *ndr, int ndr_flags, union nbt_cldap_netlogon *r); -void ndr_print_nbt_cldap_netlogon(struct ndr_print *ndr, const char *name, const union nbt_cldap_netlogon *r); -void ndr_print_nbt_ntlogon_command(struct ndr_print *ndr, const char *name, enum nbt_ntlogon_command r); -void ndr_print_nbt_ntlogon_sam_logon(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon *r); -void ndr_print_nbt_ntlogon_sam_logon_reply(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon_reply *r); -void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *name, const union nbt_ntlogon_request *r); -enum ndr_err_code ndr_push_nbt_ntlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_packet *r); -enum ndr_err_code ndr_pull_nbt_ntlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_packet *r); -void ndr_print_nbt_ntlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_packet *r); void ndr_print_nbt_browse_opcode(struct ndr_print *ndr, const char *name, enum nbt_browse_opcode r); void ndr_print_nbt_browse_host_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_host_announcement *r); void ndr_print_nbt_browse_announcement_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_announcement_request *r); diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index b43a157997..169d35e326 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -3,6 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_netlogon.h" +#include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_samr.h" #include "librpc/gen_ndr/ndr_security.h" @@ -362,8 +363,6 @@ static enum ndr_err_code ndr_push_netr_PasswordInfo(struct ndr_push *ndr, int nd } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_netr_IdentityInfo(ndr, NDR_BUFFERS, &r->identity_info)); - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_BUFFERS, &r->lmpassword)); - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_BUFFERS, &r->ntpassword)); } return NDR_ERR_SUCCESS; } @@ -378,8 +377,6 @@ static enum ndr_err_code ndr_pull_netr_PasswordInfo(struct ndr_pull *ndr, int nd } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_netr_IdentityInfo(ndr, NDR_BUFFERS, &r->identity_info)); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_BUFFERS, &r->lmpassword)); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_BUFFERS, &r->ntpassword)); } return NDR_ERR_SUCCESS; } @@ -541,32 +538,155 @@ _PUBLIC_ void ndr_print_netr_NetworkInfo(struct ndr_print *ndr, const char *name } } -_PUBLIC_ enum ndr_err_code ndr_push_netr_LogonInfo(struct ndr_push *ndr, int ndr_flags, const union netr_LogonInfo *r) +static enum ndr_err_code ndr_push_netr_GenericInfo(struct ndr_push *ndr, int ndr_flags, const struct netr_GenericInfo *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_netr_IdentityInfo(ndr, NDR_SCALARS, &r->identity_info)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->package_name)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_netr_IdentityInfo(ndr, NDR_BUFFERS, &r->identity_info)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->package_name)); + if (r->data) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->data, r->length)); + } + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_GenericInfo(struct ndr_pull *ndr, int ndr_flags, struct netr_GenericInfo *r) +{ + uint32_t _ptr_data; + TALLOC_CTX *_mem_save_data_0; + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_netr_IdentityInfo(ndr, NDR_SCALARS, &r->identity_info)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->package_name)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->length)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->data); + } else { + r->data = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_netr_IdentityInfo(ndr, NDR_BUFFERS, &r->identity_info)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->package_name)); + if (r->data) { + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->data)); + NDR_PULL_ALLOC_N(ndr, r->data, ndr_get_array_size(ndr, &r->data)); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->data, ndr_get_array_size(ndr, &r->data))); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); + } + if (r->data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->data, r->length)); + } + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_GenericInfo(struct ndr_print *ndr, const char *name, const struct netr_GenericInfo *r) +{ + ndr_print_struct(ndr, name, "netr_GenericInfo"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + ndr->depth++; + ndr_print_netr_IdentityInfo(ndr, "identity_info", &r->identity_info); + ndr_print_lsa_String(ndr, "package_name", &r->package_name); + ndr_print_uint32(ndr, "length", r->length); + ndr_print_ptr(ndr, "data", r->data); + ndr->depth++; + if (r->data) { + ndr_print_array_uint8(ndr, "data", r->data, r->length); + } + ndr->depth--; + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + +static enum ndr_err_code ndr_push_netr_LogonInfoClass(struct ndr_push *ndr, int ndr_flags, enum netr_LogonInfoClass r) +{ + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_LogonInfoClass(struct ndr_pull *ndr, int ndr_flags, enum netr_LogonInfoClass *r) +{ + uint16_t v; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_LogonInfoClass(struct ndr_print *ndr, const char *name, enum netr_LogonInfoClass r) +{ + const char *val = NULL; + + switch (r) { + case NetlogonInteractiveInformation: val = "NetlogonInteractiveInformation"; break; + case NetlogonNetworkInformation: val = "NetlogonNetworkInformation"; break; + case NetlogonServiceInformation: val = "NetlogonServiceInformation"; break; + case NetlogonGenericInformation: val = "NetlogonGenericInformation"; break; + case NetlogonInteractiveTransitiveInformation: val = "NetlogonInteractiveTransitiveInformation"; break; + case NetlogonNetworkTransitiveInformation: val = "NetlogonNetworkTransitiveInformation"; break; + case NetlogonServiceTransitiveInformation: val = "NetlogonServiceTransitiveInformation"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +_PUBLIC_ enum ndr_err_code ndr_push_netr_LogonLevel(struct ndr_push *ndr, int ndr_flags, const union netr_LogonLevel *r) { if (ndr_flags & NDR_SCALARS) { int level = ndr_push_get_switch_value(ndr, r); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, level)); + NDR_CHECK(ndr_push_netr_LogonInfoClass(ndr, NDR_SCALARS, level)); switch (level) { - case 1: { + case NetlogonInteractiveInformation: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->password)); break; } - case 2: { + case NetlogonNetworkInformation: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->network)); break; } - case 3: { + case NetlogonServiceInformation: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->password)); break; } - case 5: { + case NetlogonGenericInformation: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->generic)); + break; } + + case NetlogonInteractiveTransitiveInformation: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->password)); break; } - case 6: { + case NetlogonNetworkTransitiveInformation: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->network)); break; } + case NetlogonServiceTransitiveInformation: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->password)); + break; } + default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -574,36 +694,48 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_LogonInfo(struct ndr_push *ndr, int ndr if (ndr_flags & NDR_BUFFERS) { int level = ndr_push_get_switch_value(ndr, r); switch (level) { - case 1: + case NetlogonInteractiveInformation: if (r->password) { NDR_CHECK(ndr_push_netr_PasswordInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->password)); } break; - case 2: + case NetlogonNetworkInformation: if (r->network) { NDR_CHECK(ndr_push_netr_NetworkInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->network)); } break; - case 3: + case NetlogonServiceInformation: if (r->password) { NDR_CHECK(ndr_push_netr_PasswordInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->password)); } break; - case 5: + case NetlogonGenericInformation: + if (r->generic) { + NDR_CHECK(ndr_push_netr_GenericInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->generic)); + } + break; + + case NetlogonInteractiveTransitiveInformation: if (r->password) { NDR_CHECK(ndr_push_netr_PasswordInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->password)); } break; - case 6: + case NetlogonNetworkTransitiveInformation: if (r->network) { NDR_CHECK(ndr_push_netr_NetworkInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->network)); } break; + case NetlogonServiceTransitiveInformation: + if (r->password) { + NDR_CHECK(ndr_push_netr_PasswordInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->password)); + } + break; + default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -611,12 +743,13 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_LogonInfo(struct ndr_push *ndr, int ndr return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr_flags, union netr_LogonInfo *r) +_PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonLevel(struct ndr_pull *ndr, int ndr_flags, union netr_LogonLevel *r) { int level; uint16_t _level; TALLOC_CTX *_mem_save_password_0; TALLOC_CTX *_mem_save_network_0; + TALLOC_CTX *_mem_save_generic_0; level = ndr_pull_get_switch_value(ndr, r); if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &_level)); @@ -624,7 +757,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); } switch (level) { - case 1: { + case NetlogonInteractiveInformation: { uint32_t _ptr_password; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_password)); if (_ptr_password) { @@ -634,7 +767,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; } - case 2: { + case NetlogonNetworkInformation: { uint32_t _ptr_network; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_network)); if (_ptr_network) { @@ -644,7 +777,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; } - case 3: { + case NetlogonServiceInformation: { uint32_t _ptr_password; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_password)); if (_ptr_password) { @@ -654,7 +787,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; } - case 5: { + case NetlogonGenericInformation: { + uint32_t _ptr_generic; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_generic)); + if (_ptr_generic) { + NDR_PULL_ALLOC(ndr, r->generic); + } else { + r->generic = NULL; + } + break; } + + case NetlogonInteractiveTransitiveInformation: { uint32_t _ptr_password; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_password)); if (_ptr_password) { @@ -664,7 +807,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; } - case 6: { + case NetlogonNetworkTransitiveInformation: { uint32_t _ptr_network; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_network)); if (_ptr_network) { @@ -674,13 +817,23 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; } + case NetlogonServiceTransitiveInformation: { + uint32_t _ptr_password; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_password)); + if (_ptr_password) { + NDR_PULL_ALLOC(ndr, r->password); + } else { + r->password = NULL; + } + break; } + default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } } if (ndr_flags & NDR_BUFFERS) { switch (level) { - case 1: + case NetlogonInteractiveInformation: if (r->password) { _mem_save_password_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->password, 0); @@ -689,7 +842,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; - case 2: + case NetlogonNetworkInformation: if (r->network) { _mem_save_network_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->network, 0); @@ -698,7 +851,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; - case 3: + case NetlogonServiceInformation: if (r->password) { _mem_save_password_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->password, 0); @@ -707,7 +860,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; - case 5: + case NetlogonGenericInformation: + if (r->generic) { + _mem_save_generic_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->generic, 0); + NDR_CHECK(ndr_pull_netr_GenericInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->generic)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_generic_0, 0); + } + break; + + case NetlogonInteractiveTransitiveInformation: if (r->password) { _mem_save_password_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->password, 0); @@ -716,7 +878,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; - case 6: + case NetlogonNetworkTransitiveInformation: if (r->network) { _mem_save_network_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->network, 0); @@ -725,6 +887,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr } break; + case NetlogonServiceTransitiveInformation: + if (r->password) { + _mem_save_password_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->password, 0); + NDR_CHECK(ndr_pull_netr_PasswordInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->password)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_password_0, 0); + } + break; + default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } @@ -732,13 +903,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, const union netr_LogonInfo *r) +_PUBLIC_ void ndr_print_netr_LogonLevel(struct ndr_print *ndr, const char *name, const union netr_LogonLevel *r) { int level; level = ndr_print_get_switch_value(ndr, r); - ndr_print_union(ndr, name, level, "netr_LogonInfo"); + ndr_print_union(ndr, name, level, "netr_LogonLevel"); switch (level) { - case 1: + case NetlogonInteractiveInformation: ndr_print_ptr(ndr, "password", r->password); ndr->depth++; if (r->password) { @@ -747,7 +918,7 @@ _PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, ndr->depth--; break; - case 2: + case NetlogonNetworkInformation: ndr_print_ptr(ndr, "network", r->network); ndr->depth++; if (r->network) { @@ -756,7 +927,7 @@ _PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, ndr->depth--; break; - case 3: + case NetlogonServiceInformation: ndr_print_ptr(ndr, "password", r->password); ndr->depth++; if (r->password) { @@ -765,7 +936,16 @@ _PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, ndr->depth--; break; - case 5: + case NetlogonGenericInformation: + ndr_print_ptr(ndr, "generic", r->generic); + ndr->depth++; + if (r->generic) { + ndr_print_netr_GenericInfo(ndr, "generic", r->generic); + } + ndr->depth--; + break; + + case NetlogonInteractiveTransitiveInformation: ndr_print_ptr(ndr, "password", r->password); ndr->depth++; if (r->password) { @@ -774,7 +954,7 @@ _PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, ndr->depth--; break; - case 6: + case NetlogonNetworkTransitiveInformation: ndr_print_ptr(ndr, "network", r->network); ndr->depth++; if (r->network) { @@ -783,6 +963,15 @@ _PUBLIC_ void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, ndr->depth--; break; + case NetlogonServiceTransitiveInformation: + ndr_print_ptr(ndr, "password", r->password); + ndr->depth++; + if (r->password) { + ndr_print_netr_PasswordInfo(ndr, "password", r->password); + } + ndr->depth--; + break; + default: ndr_print_bad_level(ndr, name, level); } @@ -1514,17 +1703,92 @@ _PUBLIC_ void ndr_print_netr_PacInfo(struct ndr_print *ndr, const char *name, co ndr->depth--; } +static enum ndr_err_code ndr_push_netr_GenericInfo2(struct ndr_push *ndr, int ndr_flags, const struct netr_GenericInfo2 *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->data) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->data, r->length)); + } + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_GenericInfo2(struct ndr_pull *ndr, int ndr_flags, struct netr_GenericInfo2 *r) +{ + uint32_t _ptr_data; + TALLOC_CTX *_mem_save_data_0; + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->length)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->data); + } else { + r->data = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->data) { + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->data)); + NDR_PULL_ALLOC_N(ndr, r->data, ndr_get_array_size(ndr, &r->data)); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->data, ndr_get_array_size(ndr, &r->data))); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); + } + if (r->data) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->data, r->length)); + } + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_GenericInfo2(struct ndr_print *ndr, const char *name, const struct netr_GenericInfo2 *r) +{ + ndr_print_struct(ndr, name, "netr_GenericInfo2"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + ndr->depth++; + ndr_print_uint32(ndr, "length", r->length); + ndr_print_ptr(ndr, "data", r->data); + ndr->depth++; + if (r->data) { + ndr_print_array_uint8(ndr, "data", r->data, r->length); + } + ndr->depth--; + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + _PUBLIC_ enum ndr_err_code ndr_push_netr_Validation(struct ndr_push *ndr, int ndr_flags, const union netr_Validation *r) { if (ndr_flags & NDR_SCALARS) { int level = ndr_push_get_switch_value(ndr, r); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, level)); switch (level) { - case 2: { + case NetlogonValidationSamInfo: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->sam2)); break; } - case 3: { + case NetlogonValidationSamInfo2: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->sam3)); break; } @@ -1532,11 +1796,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_Validation(struct ndr_push *ndr, int nd NDR_CHECK(ndr_push_unique_ptr(ndr, r->pac)); break; } - case 5: { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->pac)); + case NetlogonValidationGenericInfo2: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->generic)); break; } - case 6: { + case NetlogonValidationSamInfo4: { NDR_CHECK(ndr_push_unique_ptr(ndr, r->sam6)); break; } @@ -1547,13 +1811,13 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_Validation(struct ndr_push *ndr, int nd if (ndr_flags & NDR_BUFFERS) { int level = ndr_push_get_switch_value(ndr, r); switch (level) { - case 2: + case NetlogonValidationSamInfo: if (r->sam2) { NDR_CHECK(ndr_push_netr_SamInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->sam2)); } break; - case 3: + case NetlogonValidationSamInfo2: if (r->sam3) { NDR_CHECK(ndr_push_netr_SamInfo3(ndr, NDR_SCALARS|NDR_BUFFERS, r->sam3)); } @@ -1565,13 +1829,13 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_Validation(struct ndr_push *ndr, int nd } break; - case 5: - if (r->pac) { - NDR_CHECK(ndr_push_netr_PacInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->pac)); + case NetlogonValidationGenericInfo2: + if (r->generic) { + NDR_CHECK(ndr_push_netr_GenericInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->generic)); } break; - case 6: + case NetlogonValidationSamInfo4: if (r->sam6) { NDR_CHECK(ndr_push_netr_SamInfo6(ndr, NDR_SCALARS|NDR_BUFFERS, r->sam6)); } @@ -1591,6 +1855,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd TALLOC_CTX *_mem_save_sam2_0; TALLOC_CTX *_mem_save_sam3_0; TALLOC_CTX *_mem_save_pac_0; + TALLOC_CTX *_mem_save_generic_0; TALLOC_CTX *_mem_save_sam6_0; level = ndr_pull_get_switch_value(ndr, r); if (ndr_flags & NDR_SCALARS) { @@ -1599,7 +1864,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); } switch (level) { - case 2: { + case NetlogonValidationSamInfo: { uint32_t _ptr_sam2; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sam2)); if (_ptr_sam2) { @@ -1609,7 +1874,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd } break; } - case 3: { + case NetlogonValidationSamInfo2: { uint32_t _ptr_sam3; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sam3)); if (_ptr_sam3) { @@ -1629,17 +1894,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd } break; } - case 5: { - uint32_t _ptr_pac; - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_pac)); - if (_ptr_pac) { - NDR_PULL_ALLOC(ndr, r->pac); + case NetlogonValidationGenericInfo2: { + uint32_t _ptr_generic; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_generic)); + if (_ptr_generic) { + NDR_PULL_ALLOC(ndr, r->generic); } else { - r->pac = NULL; + r->generic = NULL; } break; } - case 6: { + case NetlogonValidationSamInfo4: { uint32_t _ptr_sam6; NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sam6)); if (_ptr_sam6) { @@ -1655,7 +1920,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd } if (ndr_flags & NDR_BUFFERS) { switch (level) { - case 2: + case NetlogonValidationSamInfo: if (r->sam2) { _mem_save_sam2_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->sam2, 0); @@ -1664,7 +1929,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd } break; - case 3: + case NetlogonValidationSamInfo2: if (r->sam3) { _mem_save_sam3_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->sam3, 0); @@ -1682,16 +1947,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int nd } break; - case 5: - if (r->pac) { - _mem_save_pac_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->pac, 0); - NDR_CHECK(ndr_pull_netr_PacInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->pac)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_pac_0, 0); + case NetlogonValidationGenericInfo2: + if (r->generic) { + _mem_save_generic_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->generic, 0); + NDR_CHECK(ndr_pull_netr_GenericInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->generic)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_generic_0, 0); } break; - case 6: + case NetlogonValidationSamInfo4: if (r->sam6) { _mem_save_sam6_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->sam6, 0); @@ -1713,7 +1978,7 @@ _PUBLIC_ void ndr_print_netr_Validation(struct ndr_print *ndr, const char *name, level = ndr_print_get_switch_value(ndr, r); ndr_print_union(ndr, name, level, "netr_Validation"); switch (level) { - case 2: + case NetlogonValidationSamInfo: ndr_print_ptr(ndr, "sam2", r->sam2); ndr->depth++; if (r->sam2) { @@ -1722,7 +1987,7 @@ _PUBLIC_ void ndr_print_netr_Validation(struct ndr_print *ndr, const char *name, ndr->depth--; break; - case 3: + case NetlogonValidationSamInfo2: ndr_print_ptr(ndr, "sam3", r->sam3); ndr->depth++; if (r->sam3) { @@ -1740,16 +2005,16 @@ _PUBLIC_ void ndr_print_netr_Validation(struct ndr_print *ndr, const char *name, ndr->depth--; break; - case 5: - ndr_print_ptr(ndr, "pac", r->pac); + case NetlogonValidationGenericInfo2: + ndr_print_ptr(ndr, "generic", r->generic); ndr->depth++; - if (r->pac) { - ndr_print_netr_PacInfo(ndr, "pac", r->pac); + if (r->generic) { + ndr_print_netr_GenericInfo2(ndr, "generic", r->generic); } ndr->depth--; break; - case 6: + case NetlogonValidationSamInfo4: ndr_print_ptr(ndr, "sam6", r->sam6); ndr->depth++; if (r->sam6) { @@ -1841,31 +2106,6 @@ _PUBLIC_ void ndr_print_netr_Authenticator(struct ndr_print *ndr, const char *na ndr->depth--; } -static enum ndr_err_code ndr_push_netr_LogonLevel(struct ndr_push *ndr, int ndr_flags, enum netr_LogonLevel r) -{ - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_netr_LogonLevel(struct ndr_pull *ndr, int ndr_flags, enum netr_LogonLevel *r) -{ - uint16_t v; - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); - *r = v; - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_netr_LogonLevel(struct ndr_print *ndr, const char *name, enum netr_LogonLevel r) -{ - const char *val = NULL; - - switch (r) { - case INTERACTIVE_LOGON_TYPE: val = "INTERACTIVE_LOGON_TYPE"; break; - case NET_LOGON_TYPE: val = "NET_LOGON_TYPE"; break; - } - ndr_print_enum(ndr, name, "ENUM", val, r); -} - static enum ndr_err_code ndr_push_netr_DELTA_DELETE_USER(struct ndr_push *ndr, int ndr_flags, const struct netr_DELTA_DELETE_USER *r) { if (ndr_flags & NDR_SCALARS) { @@ -1968,7 +2208,6 @@ static enum ndr_err_code ndr_push_netr_USER_KEY16(struct ndr_push *ndr, int ndr_ NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS, &r->pwd)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_BUFFERS, &r->pwd)); } return NDR_ERR_SUCCESS; } @@ -1983,7 +2222,6 @@ static enum ndr_err_code ndr_pull_netr_USER_KEY16(struct ndr_pull *ndr, int ndr_ NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS, &r->pwd)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_BUFFERS, &r->pwd)); } return NDR_ERR_SUCCESS; } @@ -2061,8 +2299,6 @@ static enum ndr_err_code ndr_push_netr_USER_KEYS2(struct ndr_push *ndr, int ndr_ NDR_CHECK(ndr_push_netr_PasswordHistory(ndr, NDR_SCALARS, &r->history)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_netr_USER_KEY16(ndr, NDR_BUFFERS, &r->lmpassword)); - NDR_CHECK(ndr_push_netr_USER_KEY16(ndr, NDR_BUFFERS, &r->ntpassword)); } return NDR_ERR_SUCCESS; } @@ -2076,8 +2312,6 @@ static enum ndr_err_code ndr_pull_netr_USER_KEYS2(struct ndr_pull *ndr, int ndr_ NDR_CHECK(ndr_pull_netr_PasswordHistory(ndr, NDR_SCALARS, &r->history)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_netr_USER_KEY16(ndr, NDR_BUFFERS, &r->lmpassword)); - NDR_CHECK(ndr_pull_netr_USER_KEY16(ndr, NDR_BUFFERS, &r->ntpassword)); } return NDR_ERR_SUCCESS; } @@ -2099,7 +2333,6 @@ static enum ndr_err_code ndr_push_netr_USER_KEY_UNION(struct ndr_push *ndr, int NDR_CHECK(ndr_push_netr_USER_KEYS2(ndr, NDR_SCALARS, &r->keys2)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_netr_USER_KEYS2(ndr, NDR_BUFFERS, &r->keys2)); } return NDR_ERR_SUCCESS; } @@ -2111,7 +2344,6 @@ static enum ndr_err_code ndr_pull_netr_USER_KEY_UNION(struct ndr_pull *ndr, int NDR_CHECK(ndr_pull_netr_USER_KEYS2(ndr, NDR_SCALARS, &r->keys2)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_netr_USER_KEYS2(ndr, NDR_BUFFERS, &r->keys2)); } return NDR_ERR_SUCCESS; } @@ -2132,7 +2364,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_USER_KEYS(struct ndr_push *ndr, int ndr NDR_CHECK(ndr_push_netr_USER_KEY_UNION(ndr, NDR_SCALARS, &r->keys)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_netr_USER_KEY_UNION(ndr, NDR_BUFFERS, &r->keys)); } return NDR_ERR_SUCCESS; } @@ -2145,7 +2376,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_USER_KEYS(struct ndr_pull *ndr, int ndr NDR_CHECK(ndr_pull_netr_USER_KEY_UNION(ndr, NDR_SCALARS, &r->keys)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_netr_USER_KEY_UNION(ndr, NDR_BUFFERS, &r->keys)); } return NDR_ERR_SUCCESS; } @@ -2293,8 +2523,6 @@ static enum ndr_err_code ndr_push_netr_DELTA_USER(struct ndr_push *ndr, int ndr_ NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->description)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->workstations)); NDR_CHECK(ndr_push_samr_LogonHours(ndr, NDR_BUFFERS, &r->logon_hours)); - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_BUFFERS, &r->lmpassword)); - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_BUFFERS, &r->ntpassword)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->comment)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->parameters)); NDR_CHECK(ndr_push_netr_USER_PRIVATE_INFO(ndr, NDR_BUFFERS, &r->user_private_info)); @@ -2358,8 +2586,6 @@ static enum ndr_err_code ndr_pull_netr_DELTA_USER(struct ndr_pull *ndr, int ndr_ NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->description)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->workstations)); NDR_CHECK(ndr_pull_samr_LogonHours(ndr, NDR_BUFFERS, &r->logon_hours)); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_BUFFERS, &r->lmpassword)); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_BUFFERS, &r->ntpassword)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->comment)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->parameters)); NDR_CHECK(ndr_pull_netr_USER_PRIVATE_INFO(ndr, NDR_BUFFERS, &r->user_private_info)); @@ -2421,7 +2647,7 @@ static enum ndr_err_code ndr_push_netr_DELTA_DOMAIN(struct ndr_push *ndr, int nd if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->domain_name)); - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->comment)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->oem_information)); NDR_CHECK(ndr_push_dlong(ndr, NDR_SCALARS, r->force_logoff_time)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->min_password_length)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->password_history_length)); @@ -2442,7 +2668,7 @@ static enum ndr_err_code ndr_push_netr_DELTA_DOMAIN(struct ndr_push *ndr, int nd } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->domain_name)); - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->oem_information)); NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_BUFFERS, &r->sdbuf)); NDR_CHECK(ndr_push_lsa_BinaryString(ndr, NDR_BUFFERS, &r->account_lockout)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->unknown2)); @@ -2457,7 +2683,7 @@ static enum ndr_err_code ndr_pull_netr_DELTA_DOMAIN(struct ndr_pull *ndr, int nd if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->domain_name)); - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->comment)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->oem_information)); NDR_CHECK(ndr_pull_dlong(ndr, NDR_SCALARS, &r->force_logoff_time)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->min_password_length)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->password_history_length)); @@ -2478,7 +2704,7 @@ static enum ndr_err_code ndr_pull_netr_DELTA_DOMAIN(struct ndr_pull *ndr, int nd } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->domain_name)); - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->oem_information)); NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_BUFFERS, &r->sdbuf)); NDR_CHECK(ndr_pull_lsa_BinaryString(ndr, NDR_BUFFERS, &r->account_lockout)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->unknown2)); @@ -2493,7 +2719,7 @@ _PUBLIC_ void ndr_print_netr_DELTA_DOMAIN(struct ndr_print *ndr, const char *nam ndr_print_struct(ndr, name, "netr_DELTA_DOMAIN"); ndr->depth++; ndr_print_lsa_String(ndr, "domain_name", &r->domain_name); - ndr_print_lsa_String(ndr, "comment", &r->comment); + ndr_print_lsa_String(ndr, "oem_information", &r->oem_information); ndr_print_dlong(ndr, "force_logoff_time", r->force_logoff_time); ndr_print_uint16(ndr, "min_password_length", r->min_password_length); ndr_print_uint16(ndr, "password_history_length", r->password_history_length); @@ -6176,7 +6402,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_netr_DsRGetDCNameInfo(struct ndr_push *ndr, NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->dc_address, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->dc_address, ndr_charset_length(r->dc_address, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_guid)); if (r->domain_name) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->domain_name, CH_UTF16))); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); @@ -6286,7 +6511,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_netr_DsRGetDCNameInfo(struct ndr_pull *ndr, NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->dc_address, ndr_get_array_length(ndr, &r->dc_address), sizeof(uint16_t), CH_UTF16)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dc_address_0, 0); } - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_guid)); if (r->domain_name) { _mem_save_domain_name_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->domain_name, 0); @@ -6385,6 +6609,35 @@ _PUBLIC_ void ndr_print_netr_DsRGetDCNameInfo(struct ndr_print *ndr, const char ndr->depth--; } +static enum ndr_err_code ndr_push_netr_TrustFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_TrustFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_TrustFlags(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_IN_FOREST", NETR_TRUST_FLAG_IN_FOREST, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_OUTBOUND", NETR_TRUST_FLAG_OUTBOUND, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_TREEROOT", NETR_TRUST_FLAG_TREEROOT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_PRIMARY", NETR_TRUST_FLAG_PRIMARY, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_NATIVE", NETR_TRUST_FLAG_NATIVE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_INBOUND", NETR_TRUST_FLAG_INBOUND, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_MIT_KRB5", NETR_TRUST_FLAG_MIT_KRB5, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_AES", NETR_TRUST_FLAG_AES, r); + ndr->depth--; +} + static enum ndr_err_code ndr_push_netr_BinaryString(struct ndr_push *ndr, int ndr_flags, const struct netr_BinaryString *r) { uint32_t cntr_data_1; @@ -6893,10 +7146,115 @@ _PUBLIC_ void ndr_print_netr_DomainQuery(struct ndr_print *ndr, const char *name } } +static enum ndr_err_code ndr_push_netr_trust_extension(struct ndr_push *ndr, int ndr_flags, const struct netr_trust_extension *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 8)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 8)); + NDR_CHECK(ndr_push_netr_TrustFlags(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->parent_index)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->trust_type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->trust_attributes)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_trust_extension(struct ndr_pull *ndr, int ndr_flags, struct netr_trust_extension *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dummy)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_netr_TrustFlags(ndr, NDR_SCALARS, &r->flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->parent_index)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->trust_type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->trust_attributes)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_trust_extension(struct ndr_print *ndr, const char *name, const struct netr_trust_extension *r) +{ + ndr_print_struct(ndr, name, "netr_trust_extension"); + ndr->depth++; + ndr_print_uint32(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?8:r->length); + ndr_print_uint32(ndr, "dummy", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0:r->dummy); + ndr_print_uint32(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?8:r->size); + ndr_print_netr_TrustFlags(ndr, "flags", r->flags); + ndr_print_uint32(ndr, "parent_index", r->parent_index); + ndr_print_uint32(ndr, "trust_type", r->trust_type); + ndr_print_uint32(ndr, "trust_attributes", r->trust_attributes); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_netr_trust_extension_container(struct ndr_push *ndr, int ndr_flags, const struct netr_trust_extension_container *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->info) { + NDR_CHECK(ndr_push_netr_trust_extension(ndr, NDR_SCALARS, r->info)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_trust_extension_container(struct ndr_pull *ndr, int ndr_flags, struct netr_trust_extension_container *r) +{ + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_info_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->info); + } else { + r->info = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info, 0); + NDR_CHECK(ndr_pull_netr_trust_extension(ndr, NDR_SCALARS, r->info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_trust_extension_container(struct ndr_print *ndr, const char *name, const struct netr_trust_extension_container *r) +{ + ndr_print_struct(ndr, name, "netr_trust_extension_container"); + ndr->depth++; + ndr_print_uint16(ndr, "length", r->length); + ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->length:r->size); + ndr_print_ptr(ndr, "info", r->info); + ndr->depth++; + if (r->info) { + ndr_print_netr_trust_extension(ndr, "info", r->info); + } + ndr->depth--; + ndr->depth--; +} + static enum ndr_err_code ndr_push_netr_DomainTrustInfo(struct ndr_push *ndr, int ndr_flags, const struct netr_DomainTrustInfo *r) { - uint32_t cntr_unknown1_0; - uint32_t cntr_unknown_0; + uint32_t cntr_dummystring_0; + uint32_t cntr_dummy_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->domainname)); @@ -6904,23 +7262,24 @@ static enum ndr_err_code ndr_push_netr_DomainTrustInfo(struct ndr_push *ndr, int NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->forest)); NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->guid)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->sid)); - for (cntr_unknown1_0 = 0; cntr_unknown1_0 < 4; cntr_unknown1_0++) { - NDR_CHECK(ndr_push_netr_BinaryString(ndr, NDR_SCALARS, &r->unknown1[cntr_unknown1_0])); + NDR_CHECK(ndr_push_netr_trust_extension_container(ndr, NDR_SCALARS, &r->trust_extension)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->dummystring[cntr_dummystring_0])); } - for (cntr_unknown_0 = 0; cntr_unknown_0 < 4; cntr_unknown_0++) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown[cntr_unknown_0])); + for (cntr_dummy_0 = 0; cntr_dummy_0 < 4; cntr_dummy_0++) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dummy[cntr_dummy_0])); } } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->domainname)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->fulldomainname)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->forest)); - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->guid)); if (r->sid) { NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->sid)); } - for (cntr_unknown1_0 = 0; cntr_unknown1_0 < 4; cntr_unknown1_0++) { - NDR_CHECK(ndr_push_netr_BinaryString(ndr, NDR_BUFFERS, &r->unknown1[cntr_unknown1_0])); + NDR_CHECK(ndr_push_netr_trust_extension_container(ndr, NDR_BUFFERS, &r->trust_extension)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->dummystring[cntr_dummystring_0])); } } return NDR_ERR_SUCCESS; @@ -6930,8 +7289,8 @@ static enum ndr_err_code ndr_pull_netr_DomainTrustInfo(struct ndr_pull *ndr, int { uint32_t _ptr_sid; TALLOC_CTX *_mem_save_sid_0; - uint32_t cntr_unknown1_0; - uint32_t cntr_unknown_0; + uint32_t cntr_dummystring_0; + uint32_t cntr_dummy_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->domainname)); @@ -6944,26 +7303,27 @@ static enum ndr_err_code ndr_pull_netr_DomainTrustInfo(struct ndr_pull *ndr, int } else { r->sid = NULL; } - for (cntr_unknown1_0 = 0; cntr_unknown1_0 < 4; cntr_unknown1_0++) { - NDR_CHECK(ndr_pull_netr_BinaryString(ndr, NDR_SCALARS, &r->unknown1[cntr_unknown1_0])); + NDR_CHECK(ndr_pull_netr_trust_extension_container(ndr, NDR_SCALARS, &r->trust_extension)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->dummystring[cntr_dummystring_0])); } - for (cntr_unknown_0 = 0; cntr_unknown_0 < 4; cntr_unknown_0++) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown[cntr_unknown_0])); + for (cntr_dummy_0 = 0; cntr_dummy_0 < 4; cntr_dummy_0++) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dummy[cntr_dummy_0])); } } if (ndr_flags & NDR_BUFFERS) { NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->domainname)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->fulldomainname)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->forest)); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->guid)); if (r->sid) { _mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->sid, 0); NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->sid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, 0); } - for (cntr_unknown1_0 = 0; cntr_unknown1_0 < 4; cntr_unknown1_0++) { - NDR_CHECK(ndr_pull_netr_BinaryString(ndr, NDR_BUFFERS, &r->unknown1[cntr_unknown1_0])); + NDR_CHECK(ndr_pull_netr_trust_extension_container(ndr, NDR_BUFFERS, &r->trust_extension)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->dummystring[cntr_dummystring_0])); } } return NDR_ERR_SUCCESS; @@ -6971,8 +7331,8 @@ static enum ndr_err_code ndr_pull_netr_DomainTrustInfo(struct ndr_pull *ndr, int _PUBLIC_ void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char *name, const struct netr_DomainTrustInfo *r) { - uint32_t cntr_unknown1_0; - uint32_t cntr_unknown_0; + uint32_t cntr_dummystring_0; + uint32_t cntr_dummy_0; ndr_print_struct(ndr, name, "netr_DomainTrustInfo"); ndr->depth++; ndr_print_lsa_String(ndr, "domainname", &r->domainname); @@ -6985,22 +7345,23 @@ _PUBLIC_ void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char * ndr_print_dom_sid2(ndr, "sid", r->sid); } ndr->depth--; - ndr->print(ndr, "%s: ARRAY(%d)", "unknown1", (int)4); + ndr_print_netr_trust_extension_container(ndr, "trust_extension", &r->trust_extension); + ndr->print(ndr, "%s: ARRAY(%d)", "dummystring", (int)3); ndr->depth++; - for (cntr_unknown1_0=0;cntr_unknown1_0<4;cntr_unknown1_0++) { + for (cntr_dummystring_0=0;cntr_dummystring_0<3;cntr_dummystring_0++) { char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_unknown1_0) != -1) { - ndr_print_netr_BinaryString(ndr, "unknown1", &r->unknown1[cntr_unknown1_0]); + if (asprintf(&idx_0, "[%d]", cntr_dummystring_0) != -1) { + ndr_print_lsa_String(ndr, "dummystring", &r->dummystring[cntr_dummystring_0]); free(idx_0); } } ndr->depth--; - ndr->print(ndr, "%s: ARRAY(%d)", "unknown", (int)4); + ndr->print(ndr, "%s: ARRAY(%d)", "dummy", (int)4); ndr->depth++; - for (cntr_unknown_0=0;cntr_unknown_0<4;cntr_unknown_0++) { + for (cntr_dummy_0=0;cntr_dummy_0<4;cntr_dummy_0++) { char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) { - ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]); + if (asprintf(&idx_0, "[%d]", cntr_dummy_0) != -1) { + ndr_print_uint32(ndr, "dummy", r->dummy[cntr_dummy_0]); free(idx_0); } } @@ -7008,17 +7369,108 @@ _PUBLIC_ void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char * ndr->depth--; } +static enum ndr_err_code ndr_push_netr_LsaPolicyInfo(struct ndr_push *ndr, int ndr_flags, const struct netr_LsaPolicyInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->policy_size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->policy)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->policy) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->policy_size)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->policy, r->policy_size)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_netr_LsaPolicyInfo(struct ndr_pull *ndr, int ndr_flags, struct netr_LsaPolicyInfo *r) +{ + uint32_t _ptr_policy; + TALLOC_CTX *_mem_save_policy_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->policy_size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_policy)); + if (_ptr_policy) { + NDR_PULL_ALLOC(ndr, r->policy); + } else { + r->policy = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->policy) { + _mem_save_policy_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->policy, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->policy)); + NDR_PULL_ALLOC_N(ndr, r->policy, ndr_get_array_size(ndr, &r->policy)); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->policy, ndr_get_array_size(ndr, &r->policy))); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_policy_0, 0); + } + if (r->policy) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->policy, r->policy_size)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_LsaPolicyInfo(struct ndr_print *ndr, const char *name, const struct netr_LsaPolicyInfo *r) +{ + ndr_print_struct(ndr, name, "netr_LsaPolicyInfo"); + ndr->depth++; + ndr_print_uint32(ndr, "policy_size", r->policy_size); + ndr_print_ptr(ndr, "policy", r->policy); + ndr->depth++; + if (r->policy) { + ndr_print_array_uint8(ndr, "policy", r->policy, r->policy_size); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_netr_WorkstationFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_netr_WorkstationFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_netr_WorkstationFlags(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS", NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_WS_FLAG_HANDLES_SPN_UPDATE", NETR_WS_FLAG_HANDLES_SPN_UPDATE, r); + ndr->depth--; +} + static enum ndr_err_code ndr_push_netr_DomainInfo1(struct ndr_push *ndr, int ndr_flags, const struct netr_DomainInfo1 *r) { uint32_t cntr_trusts_1; - uint32_t cntr_unknown_0; + uint32_t cntr_dummystring_0; + uint32_t cntr_dummy_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_netr_DomainTrustInfo(ndr, NDR_SCALARS, &r->domaininfo)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_trusts)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->trusts)); - for (cntr_unknown_0 = 0; cntr_unknown_0 < 14; cntr_unknown_0++) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown[cntr_unknown_0])); + NDR_CHECK(ndr_push_netr_LsaPolicyInfo(ndr, NDR_SCALARS, &r->lsa_policy)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->dns_hostname)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->dummystring[cntr_dummystring_0])); + } + NDR_CHECK(ndr_push_netr_WorkstationFlags(ndr, NDR_SCALARS, r->workstation_flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->supported_enc_types)); + for (cntr_dummy_0 = 0; cntr_dummy_0 < 2; cntr_dummy_0++) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dummy[cntr_dummy_0])); } } if (ndr_flags & NDR_BUFFERS) { @@ -7032,6 +7484,11 @@ static enum ndr_err_code ndr_push_netr_DomainInfo1(struct ndr_push *ndr, int ndr NDR_CHECK(ndr_push_netr_DomainTrustInfo(ndr, NDR_BUFFERS, &r->trusts[cntr_trusts_1])); } } + NDR_CHECK(ndr_push_netr_LsaPolicyInfo(ndr, NDR_BUFFERS, &r->lsa_policy)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->dns_hostname)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->dummystring[cntr_dummystring_0])); + } } return NDR_ERR_SUCCESS; } @@ -7042,7 +7499,8 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo1(struct ndr_pull *ndr, int ndr uint32_t cntr_trusts_1; TALLOC_CTX *_mem_save_trusts_0; TALLOC_CTX *_mem_save_trusts_1; - uint32_t cntr_unknown_0; + uint32_t cntr_dummystring_0; + uint32_t cntr_dummy_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_netr_DomainTrustInfo(ndr, NDR_SCALARS, &r->domaininfo)); @@ -7053,8 +7511,15 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo1(struct ndr_pull *ndr, int ndr } else { r->trusts = NULL; } - for (cntr_unknown_0 = 0; cntr_unknown_0 < 14; cntr_unknown_0++) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown[cntr_unknown_0])); + NDR_CHECK(ndr_pull_netr_LsaPolicyInfo(ndr, NDR_SCALARS, &r->lsa_policy)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->dns_hostname)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->dummystring[cntr_dummystring_0])); + } + NDR_CHECK(ndr_pull_netr_WorkstationFlags(ndr, NDR_SCALARS, &r->workstation_flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->supported_enc_types)); + for (cntr_dummy_0 = 0; cntr_dummy_0 < 2; cntr_dummy_0++) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dummy[cntr_dummy_0])); } } if (ndr_flags & NDR_BUFFERS) { @@ -7075,6 +7540,11 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo1(struct ndr_pull *ndr, int ndr NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trusts_1, 0); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trusts_0, 0); } + NDR_CHECK(ndr_pull_netr_LsaPolicyInfo(ndr, NDR_BUFFERS, &r->lsa_policy)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->dns_hostname)); + for (cntr_dummystring_0 = 0; cntr_dummystring_0 < 3; cntr_dummystring_0++) { + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->dummystring[cntr_dummystring_0])); + } if (r->trusts) { NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->trusts, r->num_trusts)); } @@ -7085,7 +7555,8 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo1(struct ndr_pull *ndr, int ndr _PUBLIC_ void ndr_print_netr_DomainInfo1(struct ndr_print *ndr, const char *name, const struct netr_DomainInfo1 *r) { uint32_t cntr_trusts_1; - uint32_t cntr_unknown_0; + uint32_t cntr_dummystring_0; + uint32_t cntr_dummy_0; ndr_print_struct(ndr, name, "netr_DomainInfo1"); ndr->depth++; ndr_print_netr_DomainTrustInfo(ndr, "domaininfo", &r->domaininfo); @@ -7105,12 +7576,26 @@ _PUBLIC_ void ndr_print_netr_DomainInfo1(struct ndr_print *ndr, const char *name ndr->depth--; } ndr->depth--; - ndr->print(ndr, "%s: ARRAY(%d)", "unknown", (int)14); + ndr_print_netr_LsaPolicyInfo(ndr, "lsa_policy", &r->lsa_policy); + ndr_print_lsa_String(ndr, "dns_hostname", &r->dns_hostname); + ndr->print(ndr, "%s: ARRAY(%d)", "dummystring", (int)3); ndr->depth++; - for (cntr_unknown_0=0;cntr_unknown_0<14;cntr_unknown_0++) { + for (cntr_dummystring_0=0;cntr_dummystring_0<3;cntr_dummystring_0++) { char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_unknown_0) != -1) { - ndr_print_uint32(ndr, "unknown", r->unknown[cntr_unknown_0]); + if (asprintf(&idx_0, "[%d]", cntr_dummystring_0) != -1) { + ndr_print_lsa_String(ndr, "dummystring", &r->dummystring[cntr_dummystring_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_netr_WorkstationFlags(ndr, "workstation_flags", r->workstation_flags); + ndr_print_uint32(ndr, "supported_enc_types", r->supported_enc_types); + ndr->print(ndr, "%s: ARRAY(%d)", "dummy", (int)2); + ndr->depth++; + for (cntr_dummy_0=0;cntr_dummy_0<2;cntr_dummy_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_dummy_0) != -1) { + ndr_print_uint32(ndr, "dummy", r->dummy[cntr_dummy_0]); free(idx_0); } } @@ -7129,7 +7614,7 @@ static enum ndr_err_code ndr_push_netr_DomainInfo(struct ndr_push *ndr, int ndr_ break; } case 2: { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->info1)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info2)); break; } default: @@ -7146,8 +7631,8 @@ static enum ndr_err_code ndr_push_netr_DomainInfo(struct ndr_push *ndr, int ndr_ break; case 2: - if (r->info1) { - NDR_CHECK(ndr_push_netr_DomainInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + if (r->info2) { + NDR_CHECK(ndr_push_netr_DomainInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2)); } break; @@ -7163,6 +7648,7 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo(struct ndr_pull *ndr, int ndr_ int level; uint32_t _level; TALLOC_CTX *_mem_save_info1_0; + TALLOC_CTX *_mem_save_info2_0; level = ndr_pull_get_switch_value(ndr, r); if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level)); @@ -7181,12 +7667,12 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; } case 2: { - uint32_t _ptr_info1; - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info1)); - if (_ptr_info1) { - NDR_PULL_ALLOC(ndr, r->info1); + uint32_t _ptr_info2; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info2)); + if (_ptr_info2) { + NDR_PULL_ALLOC(ndr, r->info2); } else { - r->info1 = NULL; + r->info2 = NULL; } break; } @@ -7206,11 +7692,11 @@ static enum ndr_err_code ndr_pull_netr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; case 2: - if (r->info1) { - _mem_save_info1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->info1, 0); - NDR_CHECK(ndr_pull_netr_DomainInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info1_0, 0); + if (r->info2) { + _mem_save_info2_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info2, 0); + NDR_CHECK(ndr_pull_netr_DomainInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info2_0, 0); } break; @@ -7237,10 +7723,10 @@ _PUBLIC_ void ndr_print_netr_DomainInfo(struct ndr_print *ndr, const char *name, break; case 2: - ndr_print_ptr(ndr, "info1", r->info1); + ndr_print_ptr(ndr, "info2", r->info2); ndr->depth++; - if (r->info1) { - ndr_print_netr_DomainInfo1(ndr, "info1", r->info1); + if (r->info2) { + ndr_print_netr_DomainInfo1(ndr, "info2", r->info2); } ndr->depth--; break; @@ -7444,33 +7930,6 @@ _PUBLIC_ void ndr_print_netr_DsRAddress(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_netr_TrustFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r) -{ - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_netr_TrustFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) -{ - uint32_t v; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); - *r = v; - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_netr_TrustFlags(struct ndr_print *ndr, const char *name, uint32_t r) -{ - ndr_print_uint32(ndr, name, r); - ndr->depth++; - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_IN_FOREST", NETR_TRUST_FLAG_IN_FOREST, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_OUTBOUND", NETR_TRUST_FLAG_OUTBOUND, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_TREEROOT", NETR_TRUST_FLAG_TREEROOT, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_PRIMARY", NETR_TRUST_FLAG_PRIMARY, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_NATIVE", NETR_TRUST_FLAG_NATIVE, r); - ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "NETR_TRUST_FLAG_INBOUND", NETR_TRUST_FLAG_INBOUND, r); - ndr->depth--; -} - static enum ndr_err_code ndr_push_netr_TrustType(struct ndr_push *ndr, int ndr_flags, enum netr_TrustType r) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); @@ -7555,7 +8014,6 @@ static enum ndr_err_code ndr_push_netr_DomainTrust(struct ndr_push *ndr, int ndr if (r->sid) { NDR_CHECK(ndr_push_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->sid)); } - NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->guid)); } return NDR_ERR_SUCCESS; } @@ -7625,7 +8083,6 @@ static enum ndr_err_code ndr_pull_netr_DomainTrust(struct ndr_pull *ndr, int ndr NDR_CHECK(ndr_pull_dom_sid2(ndr, NDR_SCALARS|NDR_BUFFERS, r->sid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, 0); } - NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->guid)); } return NDR_ERR_SUCCESS; } @@ -8235,12 +8692,12 @@ static enum ndr_err_code ndr_push_netr_LogonSamLogon(struct ndr_push *ndr, int f if (r->in.return_authenticator) { NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); } - NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS, r->in.logon_level)); + NDR_CHECK(ndr_push_netr_LogonInfoClass(ndr, NDR_SCALARS, r->in.logon_level)); if (r->in.logon == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_push_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); + NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.validation_level)); } if (flags & NDR_OUT) { @@ -8338,14 +8795,14 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogon(struct ndr_pull *ndr, int f NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_authenticator_0, 0); } - NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS, &r->in.logon_level)); + NDR_CHECK(ndr_pull_netr_LogonInfoClass(ndr, NDR_SCALARS, &r->in.logon_level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.logon); } _mem_save_logon_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.logon, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_pull_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); + NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_logon_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.validation_level)); NDR_PULL_ALLOC(ndr, r->out.validation); @@ -8420,11 +8877,11 @@ _PUBLIC_ void ndr_print_netr_LogonSamLogon(struct ndr_print *ndr, const char *na ndr_print_netr_Authenticator(ndr, "return_authenticator", r->in.return_authenticator); } ndr->depth--; - ndr_print_netr_LogonLevel(ndr, "logon_level", r->in.logon_level); + ndr_print_netr_LogonInfoClass(ndr, "logon_level", r->in.logon_level); ndr_print_ptr(ndr, "logon", r->in.logon); ndr->depth++; ndr_print_set_switch_value(ndr, r->in.logon, r->in.logon_level); - ndr_print_netr_LogonInfo(ndr, "logon", r->in.logon); + ndr_print_netr_LogonLevel(ndr, "logon", r->in.logon); ndr->depth--; ndr_print_uint16(ndr, "validation_level", r->in.validation_level); ndr->depth--; @@ -8478,9 +8935,9 @@ static enum ndr_err_code ndr_push_netr_LogonSamLogoff(struct ndr_push *ndr, int if (r->in.return_authenticator) { NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); } - NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS, r->in.logon_level)); + NDR_CHECK(ndr_push_netr_LogonInfoClass(ndr, NDR_SCALARS, r->in.logon_level)); NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_push_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.return_authenticator)); @@ -8565,9 +9022,9 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogoff(struct ndr_pull *ndr, int NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_authenticator_0, 0); } - NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS, &r->in.logon_level)); + NDR_CHECK(ndr_pull_netr_LogonInfoClass(ndr, NDR_SCALARS, &r->in.logon_level)); NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_pull_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_return_authenticator)); @@ -8621,9 +9078,9 @@ _PUBLIC_ void ndr_print_netr_LogonSamLogoff(struct ndr_print *ndr, const char *n ndr_print_netr_Authenticator(ndr, "return_authenticator", r->in.return_authenticator); } ndr->depth--; - ndr_print_netr_LogonLevel(ndr, "logon_level", r->in.logon_level); + ndr_print_netr_LogonInfoClass(ndr, "logon_level", r->in.logon_level); ndr_print_set_switch_value(ndr, &r->in.logon, r->in.logon_level); - ndr_print_netr_LogonInfo(ndr, "logon", &r->in.logon); + ndr_print_netr_LogonLevel(ndr, "logon", &r->in.logon); ndr->depth--; } if (flags & NDR_OUT) { @@ -8926,7 +9383,7 @@ static enum ndr_err_code ndr_push_netr_ServerPasswordSet(struct ndr_push *ndr, i if (r->in.new_password == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.new_password)); + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS, r->in.new_password)); } if (flags & NDR_OUT) { if (r->out.return_authenticator == NULL) { @@ -8993,7 +9450,7 @@ static enum ndr_err_code ndr_pull_netr_ServerPasswordSet(struct ndr_pull *ndr, i } _mem_save_new_password_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.new_password, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.new_password)); + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS, r->in.new_password)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_new_password_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.return_authenticator); ZERO_STRUCTP(r->out.return_authenticator); @@ -11134,11 +11591,11 @@ static enum ndr_err_code ndr_push_netr_DsRGetDCName(struct ndr_push *ndr, int fl } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.domain_guid)); if (r->in.domain_guid) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.site_guid)); if (r->in.site_guid) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.site_guid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.site_guid)); } NDR_CHECK(ndr_push_netr_DsRGetDCName_flags(ndr, NDR_SCALARS, r->in.flags)); } @@ -11216,7 +11673,7 @@ static enum ndr_err_code ndr_pull_netr_DsRGetDCName(struct ndr_pull *ndr, int fl if (r->in.domain_guid) { _mem_save_domain_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.domain_guid, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_guid_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_site_guid)); @@ -11228,7 +11685,7 @@ static enum ndr_err_code ndr_pull_netr_DsRGetDCName(struct ndr_pull *ndr, int fl if (r->in.site_guid) { _mem_save_site_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.site_guid, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.site_guid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.site_guid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_site_guid_0, 0); } NDR_CHECK(ndr_pull_netr_DsRGetDCName_flags(ndr, NDR_SCALARS, &r->in.flags)); @@ -11811,7 +12268,7 @@ static enum ndr_err_code ndr_push_netr_DsRGetDCNameEx(struct ndr_push *ndr, int } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.domain_guid)); if (r->in.domain_guid) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.site_name)); if (r->in.site_name) { @@ -11896,7 +12353,7 @@ static enum ndr_err_code ndr_pull_netr_DsRGetDCNameEx(struct ndr_pull *ndr, int if (r->in.domain_guid) { _mem_save_domain_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.domain_guid, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_guid_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_site_name)); @@ -12476,7 +12933,7 @@ static enum ndr_err_code ndr_push_netr_ServerPasswordGet(struct ndr_push *ndr, i if (r->out.password == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.password)); + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS, r->out.password)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -12550,7 +13007,7 @@ static enum ndr_err_code ndr_pull_netr_ServerPasswordGet(struct ndr_pull *ndr, i } _mem_save_password_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.password, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.password)); + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS, r->out.password)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_password_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -12831,7 +13288,7 @@ static enum ndr_err_code ndr_push_netr_DsRGetDCNameEx2(struct ndr_push *ndr, int } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.domain_guid)); if (r->in.domain_guid) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.site_name)); if (r->in.site_name) { @@ -12937,7 +13394,7 @@ static enum ndr_err_code ndr_pull_netr_DsRGetDCNameEx2(struct ndr_pull *ndr, int if (r->in.domain_guid) { _mem_save_domain_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.domain_guid, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_guid_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_site_name)); @@ -13458,12 +13915,12 @@ static enum ndr_err_code ndr_push_netr_LogonSamLogonEx(struct ndr_push *ndr, int NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.computer_name, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.computer_name, ndr_charset_length(r->in.computer_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); } - NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS, r->in.logon_level)); + NDR_CHECK(ndr_push_netr_LogonInfoClass(ndr, NDR_SCALARS, r->in.logon_level)); if (r->in.logon == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_push_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); + NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.validation_level)); if (r->in.flags == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -13538,14 +13995,14 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogonEx(struct ndr_pull *ndr, int NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.computer_name, ndr_get_array_length(ndr, &r->in.computer_name), sizeof(uint16_t), CH_UTF16)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_computer_name_0, 0); } - NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS, &r->in.logon_level)); + NDR_CHECK(ndr_pull_netr_LogonInfoClass(ndr, NDR_SCALARS, &r->in.logon_level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.logon); } _mem_save_logon_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.logon, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_pull_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); + NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.logon)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_logon_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.validation_level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -13612,11 +14069,11 @@ _PUBLIC_ void ndr_print_netr_LogonSamLogonEx(struct ndr_print *ndr, const char * ndr_print_string(ndr, "computer_name", r->in.computer_name); } ndr->depth--; - ndr_print_netr_LogonLevel(ndr, "logon_level", r->in.logon_level); + ndr_print_netr_LogonInfoClass(ndr, "logon_level", r->in.logon_level); ndr_print_ptr(ndr, "logon", r->in.logon); ndr->depth++; ndr_print_set_switch_value(ndr, r->in.logon, r->in.logon_level); - ndr_print_netr_LogonInfo(ndr, "logon", r->in.logon); + ndr_print_netr_LogonLevel(ndr, "logon", r->in.logon); ndr->depth--; ndr_print_uint16(ndr, "validation_level", r->in.validation_level); ndr_print_ptr(ndr, "flags", r->in.flags); @@ -13763,11 +14220,11 @@ static enum ndr_err_code ndr_push_netr_DsrDeregisterDNSHostRecords(struct ndr_pu } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.domain_guid)); if (r->in.domain_guid) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.dsa_guid)); if (r->in.dsa_guid) { - NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.dsa_guid)); + NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.dsa_guid)); } if (r->in.dns_host == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -13839,7 +14296,7 @@ static enum ndr_err_code ndr_pull_netr_DsrDeregisterDNSHostRecords(struct ndr_pu if (r->in.domain_guid) { _mem_save_domain_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.domain_guid, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.domain_guid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.domain_guid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_guid_0, 0); } NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dsa_guid)); @@ -13851,7 +14308,7 @@ static enum ndr_err_code ndr_pull_netr_DsrDeregisterDNSHostRecords(struct ndr_pu if (r->in.dsa_guid) { _mem_save_dsa_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.dsa_guid, 0); - NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.dsa_guid)); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.dsa_guid)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dsa_guid_0, 0); } NDR_CHECK(ndr_pull_array_size(ndr, &r->in.dns_host)); @@ -13949,11 +14406,11 @@ static enum ndr_err_code ndr_push_netr_ServerTrustPasswordsGet(struct ndr_push * if (r->out.password == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.password)); + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS, r->out.password)); if (r->out.password2 == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.password2)); + NDR_CHECK(ndr_push_samr_Password(ndr, NDR_SCALARS, r->out.password2)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -14030,14 +14487,14 @@ static enum ndr_err_code ndr_pull_netr_ServerTrustPasswordsGet(struct ndr_pull * } _mem_save_password_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.password, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.password)); + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS, r->out.password)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_password_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.password2); } _mem_save_password2_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.password2, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.password2)); + NDR_CHECK(ndr_pull_samr_Password(ndr, NDR_SCALARS, r->out.password2)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_password2_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -14436,9 +14893,9 @@ static enum ndr_err_code ndr_push_netr_LogonSamLogonWithFlags(struct ndr_push *n if (r->in.return_authenticator) { NDR_CHECK(ndr_push_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); } - NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS, r->in.logon_level)); + NDR_CHECK(ndr_push_netr_LogonInfoClass(ndr, NDR_SCALARS, r->in.logon_level)); NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_push_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + NDR_CHECK(ndr_push_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->in.validation_level)); if (r->in.flags == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -14544,9 +15001,9 @@ static enum ndr_err_code ndr_pull_netr_LogonSamLogonWithFlags(struct ndr_pull *n NDR_CHECK(ndr_pull_netr_Authenticator(ndr, NDR_SCALARS, r->in.return_authenticator)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_return_authenticator_0, 0); } - NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS, &r->in.logon_level)); + NDR_CHECK(ndr_pull_netr_LogonInfoClass(ndr, NDR_SCALARS, &r->in.logon_level)); NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.logon, r->in.logon_level)); - NDR_CHECK(ndr_pull_netr_LogonInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); + NDR_CHECK(ndr_pull_netr_LogonLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.logon)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->in.validation_level)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.flags); @@ -14636,9 +15093,9 @@ _PUBLIC_ void ndr_print_netr_LogonSamLogonWithFlags(struct ndr_print *ndr, const ndr_print_netr_Authenticator(ndr, "return_authenticator", r->in.return_authenticator); } ndr->depth--; - ndr_print_netr_LogonLevel(ndr, "logon_level", r->in.logon_level); + ndr_print_netr_LogonInfoClass(ndr, "logon_level", r->in.logon_level); ndr_print_set_switch_value(ndr, &r->in.logon, r->in.logon_level); - ndr_print_netr_LogonInfo(ndr, "logon", &r->in.logon); + ndr_print_netr_LogonLevel(ndr, "logon", &r->in.logon); ndr_print_uint16(ndr, "validation_level", r->in.validation_level); ndr_print_ptr(ndr, "flags", r->in.flags); ndr->depth++; diff --git a/source3/librpc/gen_ndr/ndr_netlogon.h b/source3/librpc/gen_ndr/ndr_netlogon.h index a9d36aeacb..2a3c0fbf84 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.h +++ b/source3/librpc/gen_ndr/ndr_netlogon.h @@ -118,9 +118,11 @@ void ndr_print_netr_IdentityInfo(struct ndr_print *ndr, const char *name, const void ndr_print_netr_PasswordInfo(struct ndr_print *ndr, const char *name, const struct netr_PasswordInfo *r); void ndr_print_netr_ChallengeResponse(struct ndr_print *ndr, const char *name, const struct netr_ChallengeResponse *r); void ndr_print_netr_NetworkInfo(struct ndr_print *ndr, const char *name, const struct netr_NetworkInfo *r); -enum ndr_err_code ndr_push_netr_LogonInfo(struct ndr_push *ndr, int ndr_flags, const union netr_LogonInfo *r); -enum ndr_err_code ndr_pull_netr_LogonInfo(struct ndr_pull *ndr, int ndr_flags, union netr_LogonInfo *r); -void ndr_print_netr_LogonInfo(struct ndr_print *ndr, const char *name, const union netr_LogonInfo *r); +void ndr_print_netr_GenericInfo(struct ndr_print *ndr, const char *name, const struct netr_GenericInfo *r); +void ndr_print_netr_LogonInfoClass(struct ndr_print *ndr, const char *name, enum netr_LogonInfoClass r); +enum ndr_err_code ndr_push_netr_LogonLevel(struct ndr_push *ndr, int ndr_flags, const union netr_LogonLevel *r); +enum ndr_err_code ndr_pull_netr_LogonLevel(struct ndr_pull *ndr, int ndr_flags, union netr_LogonLevel *r); +void ndr_print_netr_LogonLevel(struct ndr_print *ndr, const char *name, const union netr_LogonLevel *r); enum ndr_err_code ndr_push_netr_UserSessionKey(struct ndr_push *ndr, int ndr_flags, const struct netr_UserSessionKey *r); enum ndr_err_code ndr_pull_netr_UserSessionKey(struct ndr_pull *ndr, int ndr_flags, struct netr_UserSessionKey *r); void ndr_print_netr_UserSessionKey(struct ndr_print *ndr, const char *name, const struct netr_UserSessionKey *r); @@ -138,6 +140,7 @@ enum ndr_err_code ndr_pull_netr_SamInfo3(struct ndr_pull *ndr, int ndr_flags, st void ndr_print_netr_SamInfo3(struct ndr_print *ndr, const char *name, const struct netr_SamInfo3 *r); void ndr_print_netr_SamInfo6(struct ndr_print *ndr, const char *name, const struct netr_SamInfo6 *r); void ndr_print_netr_PacInfo(struct ndr_print *ndr, const char *name, const struct netr_PacInfo *r); +void ndr_print_netr_GenericInfo2(struct ndr_print *ndr, const char *name, const struct netr_GenericInfo2 *r); enum ndr_err_code ndr_push_netr_Validation(struct ndr_push *ndr, int ndr_flags, const union netr_Validation *r); enum ndr_err_code ndr_pull_netr_Validation(struct ndr_pull *ndr, int ndr_flags, union netr_Validation *r); void ndr_print_netr_Validation(struct ndr_print *ndr, const char *name, const union netr_Validation *r); @@ -147,7 +150,6 @@ void ndr_print_netr_Credential(struct ndr_print *ndr, const char *name, const st enum ndr_err_code ndr_push_netr_Authenticator(struct ndr_push *ndr, int ndr_flags, const struct netr_Authenticator *r); enum ndr_err_code ndr_pull_netr_Authenticator(struct ndr_pull *ndr, int ndr_flags, struct netr_Authenticator *r); void ndr_print_netr_Authenticator(struct ndr_print *ndr, const char *name, const struct netr_Authenticator *r); -void ndr_print_netr_LogonLevel(struct ndr_print *ndr, const char *name, enum netr_LogonLevel r); void ndr_print_netr_DELTA_DELETE_USER(struct ndr_print *ndr, const char *name, const struct netr_DELTA_DELETE_USER *r); void ndr_print_netr_USER_KEY16(struct ndr_print *ndr, const char *name, const struct netr_USER_KEY16 *r); void ndr_print_netr_PasswordHistory(struct ndr_print *ndr, const char *name, const struct netr_PasswordHistory *r); @@ -195,16 +197,22 @@ void ndr_print_netr_DsR_DcFlags(struct ndr_print *ndr, const char *name, uint32_ enum ndr_err_code ndr_push_netr_DsRGetDCNameInfo(struct ndr_push *ndr, int ndr_flags, const struct netr_DsRGetDCNameInfo *r); enum ndr_err_code ndr_pull_netr_DsRGetDCNameInfo(struct ndr_pull *ndr, int ndr_flags, struct netr_DsRGetDCNameInfo *r); void ndr_print_netr_DsRGetDCNameInfo(struct ndr_print *ndr, const char *name, const struct netr_DsRGetDCNameInfo *r); +void ndr_print_netr_TrustFlags(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_netr_BinaryString(struct ndr_print *ndr, const char *name, const struct netr_BinaryString *r); void ndr_print_netr_DomainQuery1(struct ndr_print *ndr, const char *name, const struct netr_DomainQuery1 *r); void ndr_print_netr_DomainQuery(struct ndr_print *ndr, const char *name, const union netr_DomainQuery *r); +void ndr_print_netr_trust_extension(struct ndr_print *ndr, const char *name, const struct netr_trust_extension *r); +void ndr_print_netr_trust_extension_container(struct ndr_print *ndr, const char *name, const struct netr_trust_extension_container *r); void ndr_print_netr_DomainTrustInfo(struct ndr_print *ndr, const char *name, const struct netr_DomainTrustInfo *r); +void ndr_print_netr_LsaPolicyInfo(struct ndr_print *ndr, const char *name, const struct netr_LsaPolicyInfo *r); +enum ndr_err_code ndr_push_netr_WorkstationFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_netr_WorkstationFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_netr_WorkstationFlags(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_netr_DomainInfo1(struct ndr_print *ndr, const char *name, const struct netr_DomainInfo1 *r); void ndr_print_netr_DomainInfo(struct ndr_print *ndr, const char *name, const union netr_DomainInfo *r); void ndr_print_netr_CryptPassword(struct ndr_print *ndr, const char *name, const struct netr_CryptPassword *r); void ndr_print_netr_DsRAddressToSitenamesWCtr(struct ndr_print *ndr, const char *name, const struct netr_DsRAddressToSitenamesWCtr *r); void ndr_print_netr_DsRAddress(struct ndr_print *ndr, const char *name, const struct netr_DsRAddress *r); -void ndr_print_netr_TrustFlags(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_netr_TrustType(struct ndr_print *ndr, const char *name, enum netr_TrustType r); void ndr_print_netr_TrustAttributes(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_netr_DomainTrust(struct ndr_print *ndr, const char *name, const struct netr_DomainTrust *r); diff --git a/source3/librpc/gen_ndr/ndr_notify.c b/source3/librpc/gen_ndr/ndr_notify.c index 00ba8bc293..dfa72d8004 100644 --- a/source3/librpc/gen_ndr/ndr_notify.c +++ b/source3/librpc/gen_ndr/ndr_notify.c @@ -3,6 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_notify.h" +#include "librpc/gen_ndr/ndr_security.h" _PUBLIC_ enum ndr_err_code ndr_push_notify_entry(struct ndr_push *ndr, int ndr_flags, const struct notify_entry *r) { if (ndr_flags & NDR_SCALARS) { diff --git a/source3/librpc/gen_ndr/ndr_ntsvcs.c b/source3/librpc/gen_ndr/ndr_ntsvcs.c index 62acf474ae..35d02a0dcb 100644 --- a/source3/librpc/gen_ndr/ndr_ntsvcs.c +++ b/source3/librpc/gen_ndr/ndr_ntsvcs.c @@ -508,9 +508,35 @@ _PUBLIC_ void ndr_print_PNP_EnumerateSubKeys(struct ndr_print *ndr, const char * static enum ndr_err_code ndr_push_PNP_GetDeviceList(struct ndr_push *ndr, int flags, const struct PNP_GetDeviceList *r) { + uint32_t cntr_buffer_1; if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.filter)); + if (r->in.filter) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.filter, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.filter, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.filter, ndr_charset_length(r->in.filter, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->in.length == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags)); } if (flags & NDR_OUT) { + if (r->out.buffer == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); + for (cntr_buffer_1 = 0; cntr_buffer_1 < *r->out.length; cntr_buffer_1++) { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->out.buffer[cntr_buffer_1])); + } + if (r->out.length == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -518,16 +544,81 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceList(struct ndr_push *ndr, int fl static enum ndr_err_code ndr_pull_PNP_GetDeviceList(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceList *r) { + uint32_t _ptr_filter; + uint32_t cntr_buffer_1; + TALLOC_CTX *_mem_save_filter_0; + TALLOC_CTX *_mem_save_buffer_1; + TALLOC_CTX *_mem_save_length_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_filter)); + if (_ptr_filter) { + NDR_PULL_ALLOC(ndr, r->in.filter); + } else { + r->in.filter = NULL; + } + if (r->in.filter) { + _mem_save_filter_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.filter, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.filter)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.filter)); + if (ndr_get_array_length(ndr, &r->in.filter) > ndr_get_array_size(ndr, &r->in.filter)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.filter), ndr_get_array_length(ndr, &r->in.filter)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.filter), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.filter, ndr_get_array_length(ndr, &r->in.filter), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_filter_0, 0); + } + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.length); + } + _mem_save_length_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.length, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.length)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags)); + NDR_PULL_ALLOC_N(ndr, r->out.buffer, *r->in.length); + memset(r->out.buffer, 0, (*r->in.length) * sizeof(*r->out.buffer)); + NDR_PULL_ALLOC(ndr, r->out.length); + *r->out.length = *r->in.length; } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_array_size(ndr, &r->out.buffer)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->out.buffer)); + if (ndr_get_array_length(ndr, &r->out.buffer) > ndr_get_array_size(ndr, &r->out.buffer)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->out.buffer), ndr_get_array_length(ndr, &r->out.buffer)); + } + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC_N(ndr, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer)); + } + _mem_save_buffer_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.buffer, 0); + for (cntr_buffer_1 = 0; cntr_buffer_1 < *r->out.length; cntr_buffer_1++) { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->out.buffer[cntr_buffer_1])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_1, 0); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.length); + } + _mem_save_length_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.length, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.length)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + if (r->out.buffer) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.buffer, *r->out.length)); + } + if (r->out.buffer) { + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->out.buffer, *r->out.length)); + } } return NDR_ERR_SUCCESS; } _PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *name, int flags, const struct PNP_GetDeviceList *r) { + uint32_t cntr_buffer_1; ndr_print_struct(ndr, name, "PNP_GetDeviceList"); ndr->depth++; if (flags & NDR_SET_VALUES) { @@ -536,11 +627,39 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceList(struct ndr_print *ndr, const char *nam if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "PNP_GetDeviceList"); ndr->depth++; + ndr_print_ptr(ndr, "filter", r->in.filter); + ndr->depth++; + if (r->in.filter) { + ndr_print_string(ndr, "filter", r->in.filter); + } + ndr->depth--; + ndr_print_ptr(ndr, "length", r->in.length); + ndr->depth++; + ndr_print_uint32(ndr, "length", *r->in.length); + ndr->depth--; + ndr_print_uint32(ndr, "flags", r->in.flags); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceList"); ndr->depth++; + ndr_print_ptr(ndr, "buffer", r->out.buffer); + ndr->depth++; + ndr->print(ndr, "%s: ARRAY(%d)", "buffer", (int)*r->out.length); + ndr->depth++; + for (cntr_buffer_1=0;cntr_buffer_1<*r->out.length;cntr_buffer_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_buffer_1) != -1) { + ndr_print_uint16(ndr, "buffer", r->out.buffer[cntr_buffer_1]); + free(idx_1); + } + } + ndr->depth--; + ndr->depth--; + ndr_print_ptr(ndr, "length", r->out.length); + ndr->depth++; + ndr_print_uint32(ndr, "length", *r->out.length); + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } @@ -696,10 +815,10 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceRegProp(struct ndr_push *ndr, int NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.devicepath, CH_UTF16))); NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.devicepath, ndr_charset_length(r->in.devicepath, CH_UTF16), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.property)); - if (r->in.unknown1 == NULL) { + if (r->in.reg_data_type == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.unknown1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.reg_data_type)); if (r->in.buffer_size == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -708,13 +827,13 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceRegProp(struct ndr_push *ndr, int return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.needed)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown3)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags)); } if (flags & NDR_OUT) { - if (r->out.unknown1 == NULL) { + if (r->out.reg_data_type == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.unknown1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.reg_data_type)); if (r->out.buffer == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -737,7 +856,7 @@ static enum ndr_err_code ndr_push_PNP_GetDeviceRegProp(struct ndr_push *ndr, int static enum ndr_err_code ndr_pull_PNP_GetDeviceRegProp(struct ndr_pull *ndr, int flags, struct PNP_GetDeviceRegProp *r) { - TALLOC_CTX *_mem_save_unknown1_0; + TALLOC_CTX *_mem_save_reg_data_type_0; TALLOC_CTX *_mem_save_buffer_size_0; TALLOC_CTX *_mem_save_needed_0; if (flags & NDR_IN) { @@ -752,12 +871,12 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceRegProp(struct ndr_pull *ndr, int NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.devicepath, ndr_get_array_length(ndr, &r->in.devicepath), sizeof(uint16_t), CH_UTF16)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.property)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->in.unknown1); + NDR_PULL_ALLOC(ndr, r->in.reg_data_type); } - _mem_save_unknown1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.unknown1, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.unknown1)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown1_0, LIBNDR_FLAG_REF_ALLOC); + _mem_save_reg_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.reg_data_type, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.reg_data_type)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_reg_data_type_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.buffer_size); } @@ -772,9 +891,9 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceRegProp(struct ndr_pull *ndr, int NDR_PULL_SET_MEM_CTX(ndr, r->in.needed, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.needed)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown3)); - NDR_PULL_ALLOC(ndr, r->out.unknown1); - *r->out.unknown1 = *r->in.unknown1; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags)); + NDR_PULL_ALLOC(ndr, r->out.reg_data_type); + *r->out.reg_data_type = *r->in.reg_data_type; NDR_PULL_ALLOC_N(ndr, r->out.buffer, *r->in.buffer_size); memset(r->out.buffer, 0, (*r->in.buffer_size) * sizeof(*r->out.buffer)); NDR_PULL_ALLOC(ndr, r->out.buffer_size); @@ -784,12 +903,12 @@ static enum ndr_err_code ndr_pull_PNP_GetDeviceRegProp(struct ndr_pull *ndr, int } if (flags & NDR_OUT) { if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.unknown1); + NDR_PULL_ALLOC(ndr, r->out.reg_data_type); } - _mem_save_unknown1_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.unknown1, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.unknown1)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_unknown1_0, LIBNDR_FLAG_REF_ALLOC); + _mem_save_reg_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.reg_data_type, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.reg_data_type)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_reg_data_type_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_array_size(ndr, &r->out.buffer)); NDR_CHECK(ndr_pull_array_length(ndr, &r->out.buffer)); if (ndr_get_array_length(ndr, &r->out.buffer) > ndr_get_array_size(ndr, &r->out.buffer)) { @@ -839,9 +958,9 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceRegProp(struct ndr_print *ndr, const char * ndr_print_string(ndr, "devicepath", r->in.devicepath); ndr->depth--; ndr_print_uint32(ndr, "property", r->in.property); - ndr_print_ptr(ndr, "unknown1", r->in.unknown1); + ndr_print_ptr(ndr, "reg_data_type", r->in.reg_data_type); ndr->depth++; - ndr_print_uint32(ndr, "unknown1", *r->in.unknown1); + ndr_print_uint32(ndr, "reg_data_type", *r->in.reg_data_type); ndr->depth--; ndr_print_ptr(ndr, "buffer_size", r->in.buffer_size); ndr->depth++; @@ -851,15 +970,15 @@ _PUBLIC_ void ndr_print_PNP_GetDeviceRegProp(struct ndr_print *ndr, const char * ndr->depth++; ndr_print_uint32(ndr, "needed", *r->in.needed); ndr->depth--; - ndr_print_uint32(ndr, "unknown3", r->in.unknown3); + ndr_print_uint32(ndr, "flags", r->in.flags); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "PNP_GetDeviceRegProp"); ndr->depth++; - ndr_print_ptr(ndr, "unknown1", r->out.unknown1); + ndr_print_ptr(ndr, "reg_data_type", r->out.reg_data_type); ndr->depth++; - ndr_print_uint32(ndr, "unknown1", *r->out.unknown1); + ndr_print_uint32(ndr, "reg_data_type", *r->out.reg_data_type); ndr->depth--; ndr_print_ptr(ndr, "buffer", r->out.buffer); ndr->depth++; diff --git a/source3/librpc/gen_ndr/ndr_samr.c b/source3/librpc/gen_ndr/ndr_samr.c index 9c5a886325..10055aef37 100644 --- a/source3/librpc/gen_ndr/ndr_samr.c +++ b/source3/librpc/gen_ndr/ndr_samr.c @@ -406,12 +406,12 @@ _PUBLIC_ void ndr_print_samr_DomInfo1(struct ndr_print *ndr, const char *name, c ndr->depth--; } -static enum ndr_err_code ndr_push_samr_DomInfo2(struct ndr_push *ndr, int ndr_flags, const struct samr_DomInfo2 *r) +static enum ndr_err_code ndr_push_samr_DomGeneralInformation(struct ndr_push *ndr, int ndr_flags, const struct samr_DomGeneralInformation *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->force_logoff_time)); - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->comment)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->oem_information)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->domain_name)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->primary)); NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->sequence_num)); @@ -423,19 +423,19 @@ static enum ndr_err_code ndr_push_samr_DomInfo2(struct ndr_push *ndr, int ndr_fl NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_aliases)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->oem_information)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->domain_name)); NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->primary)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_samr_DomInfo2(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo2 *r) +static enum ndr_err_code ndr_pull_samr_DomGeneralInformation(struct ndr_pull *ndr, int ndr_flags, struct samr_DomGeneralInformation *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->force_logoff_time)); - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->comment)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->oem_information)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->domain_name)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->primary)); NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->sequence_num)); @@ -447,19 +447,19 @@ static enum ndr_err_code ndr_pull_samr_DomInfo2(struct ndr_pull *ndr, int ndr_fl NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_aliases)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->oem_information)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->domain_name)); NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->primary)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_samr_DomInfo2(struct ndr_print *ndr, const char *name, const struct samr_DomInfo2 *r) +_PUBLIC_ void ndr_print_samr_DomGeneralInformation(struct ndr_print *ndr, const char *name, const struct samr_DomGeneralInformation *r) { - ndr_print_struct(ndr, name, "samr_DomInfo2"); + ndr_print_struct(ndr, name, "samr_DomGeneralInformation"); ndr->depth++; ndr_print_NTTIME(ndr, "force_logoff_time", r->force_logoff_time); - ndr_print_lsa_String(ndr, "comment", &r->comment); + ndr_print_lsa_String(ndr, "oem_information", &r->oem_information); ndr_print_lsa_String(ndr, "domain_name", &r->domain_name); ndr_print_lsa_String(ndr, "primary", &r->primary); ndr_print_udlong(ndr, "sequence_num", r->sequence_num); @@ -502,35 +502,35 @@ _PUBLIC_ void ndr_print_samr_DomInfo3(struct ndr_print *ndr, const char *name, c ndr->depth--; } -static enum ndr_err_code ndr_push_samr_DomInfo4(struct ndr_push *ndr, int ndr_flags, const struct samr_DomInfo4 *r) +static enum ndr_err_code ndr_push_samr_DomOEMInformation(struct ndr_push *ndr, int ndr_flags, const struct samr_DomOEMInformation *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->comment)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, &r->oem_information)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_BUFFERS, &r->oem_information)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_samr_DomInfo4(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo4 *r) +static enum ndr_err_code ndr_pull_samr_DomOEMInformation(struct ndr_pull *ndr, int ndr_flags, struct samr_DomOEMInformation *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->comment)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, &r->oem_information)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_BUFFERS, &r->oem_information)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_samr_DomInfo4(struct ndr_print *ndr, const char *name, const struct samr_DomInfo4 *r) +_PUBLIC_ void ndr_print_samr_DomOEMInformation(struct ndr_print *ndr, const char *name, const struct samr_DomOEMInformation *r) { - ndr_print_struct(ndr, name, "samr_DomInfo4"); + ndr_print_struct(ndr, name, "samr_DomOEMInformation"); ndr->depth++; - ndr_print_lsa_String(ndr, "comment", &r->comment); + ndr_print_lsa_String(ndr, "oem_information", &r->oem_information); ndr->depth--; } @@ -691,41 +691,41 @@ _PUBLIC_ void ndr_print_samr_DomInfo9(struct ndr_print *ndr, const char *name, c ndr->depth--; } -static enum ndr_err_code ndr_push_samr_DomInfo11(struct ndr_push *ndr, int ndr_flags, const struct samr_DomInfo11 *r) +static enum ndr_err_code ndr_push_samr_DomGeneralInformation2(struct ndr_push *ndr, int ndr_flags, const struct samr_DomGeneralInformation2 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 8)); - NDR_CHECK(ndr_push_samr_DomInfo2(ndr, NDR_SCALARS, &r->info2)); + NDR_CHECK(ndr_push_samr_DomGeneralInformation(ndr, NDR_SCALARS, &r->general)); NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->lockout_duration)); NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->lockout_window)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lockout_threshold)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_push_samr_DomInfo2(ndr, NDR_BUFFERS, &r->info2)); + NDR_CHECK(ndr_push_samr_DomGeneralInformation(ndr, NDR_BUFFERS, &r->general)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_samr_DomInfo11(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo11 *r) +static enum ndr_err_code ndr_pull_samr_DomGeneralInformation2(struct ndr_pull *ndr, int ndr_flags, struct samr_DomGeneralInformation2 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 8)); - NDR_CHECK(ndr_pull_samr_DomInfo2(ndr, NDR_SCALARS, &r->info2)); + NDR_CHECK(ndr_pull_samr_DomGeneralInformation(ndr, NDR_SCALARS, &r->general)); NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->lockout_duration)); NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->lockout_window)); NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lockout_threshold)); } if (ndr_flags & NDR_BUFFERS) { - NDR_CHECK(ndr_pull_samr_DomInfo2(ndr, NDR_BUFFERS, &r->info2)); + NDR_CHECK(ndr_pull_samr_DomGeneralInformation(ndr, NDR_BUFFERS, &r->general)); } return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_samr_DomInfo11(struct ndr_print *ndr, const char *name, const struct samr_DomInfo11 *r) +_PUBLIC_ void ndr_print_samr_DomGeneralInformation2(struct ndr_print *ndr, const char *name, const struct samr_DomGeneralInformation2 *r) { - ndr_print_struct(ndr, name, "samr_DomInfo11"); + ndr_print_struct(ndr, name, "samr_DomGeneralInformation2"); ndr->depth++; - ndr_print_samr_DomInfo2(ndr, "info2", &r->info2); + ndr_print_samr_DomGeneralInformation(ndr, "general", &r->general); ndr_print_hyper(ndr, "lockout_duration", r->lockout_duration); ndr_print_hyper(ndr, "lockout_window", r->lockout_window); ndr_print_uint16(ndr, "lockout_threshold", r->lockout_threshold); @@ -818,7 +818,7 @@ static enum ndr_err_code ndr_push_samr_DomainInfo(struct ndr_push *ndr, int ndr_ break; } case 2: { - NDR_CHECK(ndr_push_samr_DomInfo2(ndr, NDR_SCALARS, &r->info2)); + NDR_CHECK(ndr_push_samr_DomGeneralInformation(ndr, NDR_SCALARS, &r->general)); break; } case 3: { @@ -826,7 +826,7 @@ static enum ndr_err_code ndr_push_samr_DomainInfo(struct ndr_push *ndr, int ndr_ break; } case 4: { - NDR_CHECK(ndr_push_samr_DomInfo4(ndr, NDR_SCALARS, &r->info4)); + NDR_CHECK(ndr_push_samr_DomOEMInformation(ndr, NDR_SCALARS, &r->oem)); break; } case 5: { @@ -850,7 +850,7 @@ static enum ndr_err_code ndr_push_samr_DomainInfo(struct ndr_push *ndr, int ndr_ break; } case 11: { - NDR_CHECK(ndr_push_samr_DomInfo11(ndr, NDR_SCALARS, &r->info11)); + NDR_CHECK(ndr_push_samr_DomGeneralInformation2(ndr, NDR_SCALARS, &r->general2)); break; } case 12: { @@ -872,14 +872,14 @@ static enum ndr_err_code ndr_push_samr_DomainInfo(struct ndr_push *ndr, int ndr_ break; case 2: - NDR_CHECK(ndr_push_samr_DomInfo2(ndr, NDR_BUFFERS, &r->info2)); + NDR_CHECK(ndr_push_samr_DomGeneralInformation(ndr, NDR_BUFFERS, &r->general)); break; case 3: break; case 4: - NDR_CHECK(ndr_push_samr_DomInfo4(ndr, NDR_BUFFERS, &r->info4)); + NDR_CHECK(ndr_push_samr_DomOEMInformation(ndr, NDR_BUFFERS, &r->oem)); break; case 5: @@ -900,7 +900,7 @@ static enum ndr_err_code ndr_push_samr_DomainInfo(struct ndr_push *ndr, int ndr_ break; case 11: - NDR_CHECK(ndr_push_samr_DomInfo11(ndr, NDR_BUFFERS, &r->info11)); + NDR_CHECK(ndr_push_samr_DomGeneralInformation2(ndr, NDR_BUFFERS, &r->general2)); break; case 12: @@ -932,7 +932,7 @@ static enum ndr_err_code ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; } case 2: { - NDR_CHECK(ndr_pull_samr_DomInfo2(ndr, NDR_SCALARS, &r->info2)); + NDR_CHECK(ndr_pull_samr_DomGeneralInformation(ndr, NDR_SCALARS, &r->general)); break; } case 3: { @@ -940,7 +940,7 @@ static enum ndr_err_code ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; } case 4: { - NDR_CHECK(ndr_pull_samr_DomInfo4(ndr, NDR_SCALARS, &r->info4)); + NDR_CHECK(ndr_pull_samr_DomOEMInformation(ndr, NDR_SCALARS, &r->oem)); break; } case 5: { @@ -964,7 +964,7 @@ static enum ndr_err_code ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; } case 11: { - NDR_CHECK(ndr_pull_samr_DomInfo11(ndr, NDR_SCALARS, &r->info11)); + NDR_CHECK(ndr_pull_samr_DomGeneralInformation2(ndr, NDR_SCALARS, &r->general2)); break; } case 12: { @@ -985,14 +985,14 @@ static enum ndr_err_code ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; case 2: - NDR_CHECK(ndr_pull_samr_DomInfo2(ndr, NDR_BUFFERS, &r->info2)); + NDR_CHECK(ndr_pull_samr_DomGeneralInformation(ndr, NDR_BUFFERS, &r->general)); break; case 3: break; case 4: - NDR_CHECK(ndr_pull_samr_DomInfo4(ndr, NDR_BUFFERS, &r->info4)); + NDR_CHECK(ndr_pull_samr_DomOEMInformation(ndr, NDR_BUFFERS, &r->oem)); break; case 5: @@ -1013,7 +1013,7 @@ static enum ndr_err_code ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_ break; case 11: - NDR_CHECK(ndr_pull_samr_DomInfo11(ndr, NDR_BUFFERS, &r->info11)); + NDR_CHECK(ndr_pull_samr_DomGeneralInformation2(ndr, NDR_BUFFERS, &r->general2)); break; case 12: @@ -1040,7 +1040,7 @@ _PUBLIC_ void ndr_print_samr_DomainInfo(struct ndr_print *ndr, const char *name, break; case 2: - ndr_print_samr_DomInfo2(ndr, "info2", &r->info2); + ndr_print_samr_DomGeneralInformation(ndr, "general", &r->general); break; case 3: @@ -1048,7 +1048,7 @@ _PUBLIC_ void ndr_print_samr_DomainInfo(struct ndr_print *ndr, const char *name, break; case 4: - ndr_print_samr_DomInfo4(ndr, "info4", &r->info4); + ndr_print_samr_DomOEMInformation(ndr, "oem", &r->oem); break; case 5: @@ -1072,7 +1072,7 @@ _PUBLIC_ void ndr_print_samr_DomainInfo(struct ndr_print *ndr, const char *name, break; case 11: - ndr_print_samr_DomInfo11(ndr, "info11", &r->info11); + ndr_print_samr_DomGeneralInformation2(ndr, "general2", &r->general2); break; case 12: diff --git a/source3/librpc/gen_ndr/ndr_samr.h b/source3/librpc/gen_ndr/ndr_samr.h index c21b5455fb..1f582061f9 100644 --- a/source3/librpc/gen_ndr/ndr_samr.h +++ b/source3/librpc/gen_ndr/ndr_samr.h @@ -163,15 +163,15 @@ enum ndr_err_code ndr_push_samr_PasswordProperties(struct ndr_push *ndr, int ndr enum ndr_err_code ndr_pull_samr_PasswordProperties(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); void ndr_print_samr_PasswordProperties(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_samr_DomInfo1(struct ndr_print *ndr, const char *name, const struct samr_DomInfo1 *r); -void ndr_print_samr_DomInfo2(struct ndr_print *ndr, const char *name, const struct samr_DomInfo2 *r); +void ndr_print_samr_DomGeneralInformation(struct ndr_print *ndr, const char *name, const struct samr_DomGeneralInformation *r); void ndr_print_samr_DomInfo3(struct ndr_print *ndr, const char *name, const struct samr_DomInfo3 *r); -void ndr_print_samr_DomInfo4(struct ndr_print *ndr, const char *name, const struct samr_DomInfo4 *r); +void ndr_print_samr_DomOEMInformation(struct ndr_print *ndr, const char *name, const struct samr_DomOEMInformation *r); void ndr_print_samr_DomInfo5(struct ndr_print *ndr, const char *name, const struct samr_DomInfo5 *r); void ndr_print_samr_DomInfo6(struct ndr_print *ndr, const char *name, const struct samr_DomInfo6 *r); void ndr_print_samr_DomInfo7(struct ndr_print *ndr, const char *name, const struct samr_DomInfo7 *r); void ndr_print_samr_DomInfo8(struct ndr_print *ndr, const char *name, const struct samr_DomInfo8 *r); void ndr_print_samr_DomInfo9(struct ndr_print *ndr, const char *name, const struct samr_DomInfo9 *r); -void ndr_print_samr_DomInfo11(struct ndr_print *ndr, const char *name, const struct samr_DomInfo11 *r); +void ndr_print_samr_DomGeneralInformation2(struct ndr_print *ndr, const char *name, const struct samr_DomGeneralInformation2 *r); void ndr_print_samr_DomInfo12(struct ndr_print *ndr, const char *name, const struct samr_DomInfo12 *r); void ndr_print_samr_DomInfo13(struct ndr_print *ndr, const char *name, const struct samr_DomInfo13 *r); void ndr_print_samr_DomainInfo(struct ndr_print *ndr, const char *name, const union samr_DomainInfo *r); diff --git a/source3/librpc/gen_ndr/ndr_security.c b/source3/librpc/gen_ndr/ndr_security.c index d54fdb2395..de899241ab 100644 --- a/source3/librpc/gen_ndr/ndr_security.c +++ b/source3/librpc/gen_ndr/ndr_security.c @@ -1024,3 +1024,29 @@ _PUBLIC_ void ndr_print_security_secinfo(struct ndr_print *ndr, const char *name ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_kerb_EncTypes(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_kerb_EncTypes(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_kerb_EncTypes(struct ndr_print *ndr, const char *name, uint32_t r) +{ + ndr_print_uint32(ndr, name, r); + ndr->depth++; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_DES_CBC_CRC", KERB_ENCTYPE_DES_CBC_CRC, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_DES_CBC_MD5", KERB_ENCTYPE_DES_CBC_MD5, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_RC4_HMAC_MD5", KERB_ENCTYPE_RC4_HMAC_MD5, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96", KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96", KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96, r); + ndr->depth--; +} + diff --git a/source3/librpc/gen_ndr/ndr_security.h b/source3/librpc/gen_ndr/ndr_security.h index 79bfd78f51..7a2ff74309 100644 --- a/source3/librpc/gen_ndr/ndr_security.h +++ b/source3/librpc/gen_ndr/ndr_security.h @@ -38,4 +38,7 @@ void ndr_print_security_token(struct ndr_print *ndr, const char *name, const str enum ndr_err_code ndr_push_security_secinfo(struct ndr_push *ndr, int ndr_flags, uint32_t r); enum ndr_err_code ndr_pull_security_secinfo(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); void ndr_print_security_secinfo(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_kerb_EncTypes(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_kerb_EncTypes(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_kerb_EncTypes(struct ndr_print *ndr, const char *name, uint32_t r); #endif /* _HEADER_NDR_security */ diff --git a/source3/librpc/gen_ndr/ndr_srvsvc.c b/source3/librpc/gen_ndr/ndr_srvsvc.c index d97ee0171c..36c3dbe256 100644 --- a/source3/librpc/gen_ndr/ndr_srvsvc.c +++ b/source3/librpc/gen_ndr/ndr_srvsvc.c @@ -18013,7 +18013,7 @@ static enum ndr_err_code ndr_push_srvsvc_NetShareDelStart(struct ndr_push *ndr, if (flags & NDR_OUT) { NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.hnd)); if (r->out.hnd) { - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.hnd)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.hnd)); } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } @@ -18066,7 +18066,7 @@ static enum ndr_err_code ndr_pull_srvsvc_NetShareDelStart(struct ndr_pull *ndr, if (r->out.hnd) { _mem_save_hnd_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.hnd, 0); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.hnd)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.hnd)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hnd_0, 0); } NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); @@ -18114,13 +18114,13 @@ static enum ndr_err_code ndr_push_srvsvc_NetShareDelCommit(struct ndr_push *ndr, if (flags & NDR_IN) { NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.hnd)); if (r->in.hnd) { - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.hnd)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.hnd)); } } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.hnd)); if (r->out.hnd) { - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.hnd)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.hnd)); } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } @@ -18143,7 +18143,7 @@ static enum ndr_err_code ndr_pull_srvsvc_NetShareDelCommit(struct ndr_pull *ndr, if (r->in.hnd) { _mem_save_hnd_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.hnd, 0); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.hnd)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.hnd)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hnd_0, 0); } } @@ -18157,7 +18157,7 @@ static enum ndr_err_code ndr_pull_srvsvc_NetShareDelCommit(struct ndr_pull *ndr, if (r->out.hnd) { _mem_save_hnd_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.hnd, 0); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.hnd)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.hnd)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hnd_0, 0); } NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); diff --git a/source3/librpc/gen_ndr/ndr_svcctl.c b/source3/librpc/gen_ndr/ndr_svcctl.c index eb3929696e..e897ef334b 100644 --- a/source3/librpc/gen_ndr/ndr_svcctl.c +++ b/source3/librpc/gen_ndr/ndr_svcctl.c @@ -3,6 +3,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_svcctl.h" +#include "librpc/gen_ndr/ndr_misc.h" static enum ndr_err_code ndr_push_SERVICE_LOCK_STATUS(struct ndr_push *ndr, int ndr_flags, const struct SERVICE_LOCK_STATUS *r) { if (ndr_flags & NDR_SCALARS) { @@ -352,19 +353,228 @@ _PUBLIC_ void ndr_print_svcctl_ServiceAccessMask(struct ndr_print *ndr, const ch ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_QUERY_SERVICE_CONFIG(struct ndr_push *ndr, int ndr_flags, const struct QUERY_SERVICE_CONFIG *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->service_type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->start_type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->error_control)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->executablepath)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->loadordergroup)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->tag_id)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->dependencies)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->startname)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->displayname)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->executablepath) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->executablepath, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->executablepath, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->executablepath, ndr_charset_length(r->executablepath, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->loadordergroup) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->loadordergroup, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->loadordergroup, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->loadordergroup, ndr_charset_length(r->loadordergroup, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->dependencies) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->dependencies, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->dependencies, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->dependencies, ndr_charset_length(r->dependencies, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->startname) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->startname, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->startname, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->startname, ndr_charset_length(r->startname, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->displayname) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->displayname, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->displayname, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->displayname, ndr_charset_length(r->displayname, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_QUERY_SERVICE_CONFIG(struct ndr_pull *ndr, int ndr_flags, struct QUERY_SERVICE_CONFIG *r) +{ + uint32_t _ptr_executablepath; + TALLOC_CTX *_mem_save_executablepath_0; + uint32_t _ptr_loadordergroup; + TALLOC_CTX *_mem_save_loadordergroup_0; + uint32_t _ptr_dependencies; + TALLOC_CTX *_mem_save_dependencies_0; + uint32_t _ptr_startname; + TALLOC_CTX *_mem_save_startname_0; + uint32_t _ptr_displayname; + TALLOC_CTX *_mem_save_displayname_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->service_type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->start_type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->error_control)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_executablepath)); + if (_ptr_executablepath) { + NDR_PULL_ALLOC(ndr, r->executablepath); + } else { + r->executablepath = NULL; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_loadordergroup)); + if (_ptr_loadordergroup) { + NDR_PULL_ALLOC(ndr, r->loadordergroup); + } else { + r->loadordergroup = NULL; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->tag_id)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dependencies)); + if (_ptr_dependencies) { + NDR_PULL_ALLOC(ndr, r->dependencies); + } else { + r->dependencies = NULL; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_startname)); + if (_ptr_startname) { + NDR_PULL_ALLOC(ndr, r->startname); + } else { + r->startname = NULL; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_displayname)); + if (_ptr_displayname) { + NDR_PULL_ALLOC(ndr, r->displayname); + } else { + r->displayname = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->executablepath) { + _mem_save_executablepath_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->executablepath, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->executablepath)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->executablepath)); + if (ndr_get_array_length(ndr, &r->executablepath) > ndr_get_array_size(ndr, &r->executablepath)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->executablepath), ndr_get_array_length(ndr, &r->executablepath)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->executablepath), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->executablepath, ndr_get_array_length(ndr, &r->executablepath), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_executablepath_0, 0); + } + if (r->loadordergroup) { + _mem_save_loadordergroup_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->loadordergroup, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->loadordergroup)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->loadordergroup)); + if (ndr_get_array_length(ndr, &r->loadordergroup) > ndr_get_array_size(ndr, &r->loadordergroup)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->loadordergroup), ndr_get_array_length(ndr, &r->loadordergroup)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->loadordergroup), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->loadordergroup, ndr_get_array_length(ndr, &r->loadordergroup), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_loadordergroup_0, 0); + } + if (r->dependencies) { + _mem_save_dependencies_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->dependencies, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->dependencies)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->dependencies)); + if (ndr_get_array_length(ndr, &r->dependencies) > ndr_get_array_size(ndr, &r->dependencies)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->dependencies), ndr_get_array_length(ndr, &r->dependencies)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->dependencies), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->dependencies, ndr_get_array_length(ndr, &r->dependencies), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dependencies_0, 0); + } + if (r->startname) { + _mem_save_startname_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->startname, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->startname)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->startname)); + if (ndr_get_array_length(ndr, &r->startname) > ndr_get_array_size(ndr, &r->startname)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->startname), ndr_get_array_length(ndr, &r->startname)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->startname), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->startname, ndr_get_array_length(ndr, &r->startname), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_startname_0, 0); + } + if (r->displayname) { + _mem_save_displayname_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->displayname, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->displayname)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->displayname)); + if (ndr_get_array_length(ndr, &r->displayname) > ndr_get_array_size(ndr, &r->displayname)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->displayname), ndr_get_array_length(ndr, &r->displayname)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->displayname), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->displayname, ndr_get_array_length(ndr, &r->displayname), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_displayname_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_QUERY_SERVICE_CONFIG(struct ndr_print *ndr, const char *name, const struct QUERY_SERVICE_CONFIG *r) +{ + ndr_print_struct(ndr, name, "QUERY_SERVICE_CONFIG"); + ndr->depth++; + ndr_print_uint32(ndr, "service_type", r->service_type); + ndr_print_uint32(ndr, "start_type", r->start_type); + ndr_print_uint32(ndr, "error_control", r->error_control); + ndr_print_ptr(ndr, "executablepath", r->executablepath); + ndr->depth++; + if (r->executablepath) { + ndr_print_string(ndr, "executablepath", r->executablepath); + } + ndr->depth--; + ndr_print_ptr(ndr, "loadordergroup", r->loadordergroup); + ndr->depth++; + if (r->loadordergroup) { + ndr_print_string(ndr, "loadordergroup", r->loadordergroup); + } + ndr->depth--; + ndr_print_uint32(ndr, "tag_id", r->tag_id); + ndr_print_ptr(ndr, "dependencies", r->dependencies); + ndr->depth++; + if (r->dependencies) { + ndr_print_string(ndr, "dependencies", r->dependencies); + } + ndr->depth--; + ndr_print_ptr(ndr, "startname", r->startname); + ndr->depth++; + if (r->startname) { + ndr_print_string(ndr, "startname", r->startname); + } + ndr->depth--; + ndr_print_ptr(ndr, "displayname", r->displayname); + ndr->depth++; + if (r->displayname) { + ndr_print_string(ndr, "displayname", r->displayname); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_QUERY_SERVICE_CONFIG(const struct QUERY_SERVICE_CONFIG *r, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_QUERY_SERVICE_CONFIG); +} + static enum ndr_err_code ndr_push_svcctl_CloseServiceHandle(struct ndr_push *ndr, int flags, const struct svcctl_CloseServiceHandle *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -381,7 +591,7 @@ static enum ndr_err_code ndr_pull_svcctl_CloseServiceHandle(struct ndr_pull *ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.handle); *r->out.handle = *r->in.handle; @@ -392,7 +602,7 @@ static enum ndr_err_code ndr_pull_svcctl_CloseServiceHandle(struct ndr_pull *ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -434,7 +644,7 @@ static enum ndr_err_code ndr_push_svcctl_ControlService(struct ndr_push *ndr, in if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.control)); } if (flags & NDR_OUT) { @@ -459,7 +669,7 @@ static enum ndr_err_code ndr_pull_svcctl_ControlService(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.control)); NDR_PULL_ALLOC(ndr, r->out.service_status); @@ -514,7 +724,7 @@ static enum ndr_err_code ndr_push_svcctl_DeleteService(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); @@ -531,7 +741,7 @@ static enum ndr_err_code ndr_pull_svcctl_DeleteService(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { @@ -571,13 +781,13 @@ static enum ndr_err_code ndr_push_svcctl_LockServiceDatabase(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.lock == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.lock)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.lock)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -595,7 +805,7 @@ static enum ndr_err_code ndr_pull_svcctl_LockServiceDatabase(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.lock); ZERO_STRUCTP(r->out.lock); @@ -606,7 +816,7 @@ static enum ndr_err_code ndr_pull_svcctl_LockServiceDatabase(struct ndr_pull *nd } _mem_save_lock_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.lock, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.lock)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.lock)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_lock_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -648,7 +858,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceObjectSecurity(struct ndr_p if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.security_flags)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buffer_size)); } @@ -679,7 +889,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceObjectSecurity(struct ndr_p } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.security_flags)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buffer_size)); @@ -756,7 +966,7 @@ static enum ndr_err_code ndr_push_svcctl_SetServiceObjectSecurity(struct ndr_pus if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.security_flags)); if (r->in.buffer == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -780,7 +990,7 @@ static enum ndr_err_code ndr_pull_svcctl_SetServiceObjectSecurity(struct ndr_pul } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.security_flags)); NDR_CHECK(ndr_pull_array_size(ndr, &r->in.buffer)); @@ -836,7 +1046,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceStatus(struct ndr_push *ndr if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.service_status == NULL) { @@ -860,7 +1070,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceStatus(struct ndr_pull *ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.service_status); ZERO_STRUCTP(r->out.service_status); @@ -954,13 +1164,13 @@ static enum ndr_err_code ndr_push_svcctl_UnlockServiceDatabase(struct ndr_push * if (r->in.lock == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.lock)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.lock)); } if (flags & NDR_OUT) { if (r->out.lock == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.lock)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.lock)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -977,7 +1187,7 @@ static enum ndr_err_code ndr_pull_svcctl_UnlockServiceDatabase(struct ndr_pull * } _mem_save_lock_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.lock, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.lock)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.lock)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_lock_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.lock); *r->out.lock = *r->in.lock; @@ -988,7 +1198,7 @@ static enum ndr_err_code ndr_pull_svcctl_UnlockServiceDatabase(struct ndr_pull * } _mem_save_lock_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.lock, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.lock)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.lock)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_lock_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -1071,7 +1281,7 @@ static enum ndr_err_code ndr_push_svcctl_SCSetServiceBitsW(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.bits)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.bitson)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.immediate)); @@ -1091,7 +1301,7 @@ static enum ndr_err_code ndr_pull_svcctl_SCSetServiceBitsW(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.bits)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.bitson)); @@ -1137,7 +1347,7 @@ static enum ndr_err_code ndr_push_svcctl_ChangeServiceConfigW(struct ndr_push *n if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.start)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.error)); @@ -1218,7 +1428,7 @@ static enum ndr_err_code ndr_pull_svcctl_ChangeServiceConfigW(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.start)); @@ -1421,7 +1631,7 @@ static enum ndr_err_code ndr_push_svcctl_CreateServiceW(struct ndr_push *ndr, in if (r->in.scmanager_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.scmanager_handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.ServiceName, CH_UTF16))); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.ServiceName, CH_UTF16))); @@ -1480,7 +1690,7 @@ static enum ndr_err_code ndr_push_svcctl_CreateServiceW(struct ndr_push *ndr, in if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -1510,7 +1720,7 @@ static enum ndr_err_code ndr_pull_svcctl_CreateServiceW(struct ndr_pull *ndr, in } _mem_save_scmanager_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.scmanager_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.scmanager_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_scmanager_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_array_size(ndr, &r->in.ServiceName)); NDR_CHECK(ndr_pull_array_length(ndr, &r->in.ServiceName)); @@ -1653,7 +1863,7 @@ static enum ndr_err_code ndr_pull_svcctl_CreateServiceW(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -1745,7 +1955,7 @@ static enum ndr_err_code ndr_push_svcctl_EnumDependentServicesW(struct ndr_push if (r->in.service == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.service)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.service)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.state)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } @@ -1781,7 +1991,7 @@ static enum ndr_err_code ndr_pull_svcctl_EnumDependentServicesW(struct ndr_pull } _mem_save_service_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.service, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.service)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.service)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_service_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.state)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); @@ -1874,7 +2084,7 @@ static enum ndr_err_code ndr_push_svcctl_EnumServicesStatusW(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.state)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); @@ -1918,7 +2128,7 @@ static enum ndr_err_code ndr_pull_svcctl_EnumServicesStatusW(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.state)); @@ -2050,7 +2260,7 @@ static enum ndr_err_code ndr_push_svcctl_OpenSCManagerW(struct ndr_push *ndr, in if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -2112,7 +2322,7 @@ static enum ndr_err_code ndr_pull_svcctl_OpenSCManagerW(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -2163,7 +2373,7 @@ static enum ndr_err_code ndr_push_svcctl_OpenServiceW(struct ndr_push *ndr, int if (r->in.scmanager_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.scmanager_handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.ServiceName, CH_UTF16))); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.ServiceName, CH_UTF16))); @@ -2174,7 +2384,7 @@ static enum ndr_err_code ndr_push_svcctl_OpenServiceW(struct ndr_push *ndr, int if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -2192,7 +2402,7 @@ static enum ndr_err_code ndr_pull_svcctl_OpenServiceW(struct ndr_pull *ndr, int } _mem_save_scmanager_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.scmanager_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.scmanager_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_scmanager_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_array_size(ndr, &r->in.ServiceName)); NDR_CHECK(ndr_pull_array_length(ndr, &r->in.ServiceName)); @@ -2211,7 +2421,7 @@ static enum ndr_err_code ndr_pull_svcctl_OpenServiceW(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -2255,11 +2465,14 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceConfigW(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.query, r->in.buf_size)); + if (r->out.query == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_QUERY_SERVICE_CONFIG(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.query)); if (r->out.bytes_needed == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2272,6 +2485,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceConfigW(struct ndr_push *nd static enum ndr_err_code ndr_pull_svcctl_QueryServiceConfigW(struct ndr_pull *ndr, int flags, struct svcctl_QueryServiceConfigW *r) { TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_query_0; TALLOC_CTX *_mem_save_bytes_needed_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -2281,21 +2495,34 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceConfigW(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); + if (r->in.buf_size < 0 || r->in.buf_size > 8192) { + return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); + } + NDR_PULL_ALLOC(ndr, r->out.query); + ZERO_STRUCTP(r->out.query); NDR_PULL_ALLOC(ndr, r->out.bytes_needed); ZERO_STRUCTP(r->out.bytes_needed); } if (flags & NDR_OUT) { - NDR_PULL_ALLOC_N(ndr, r->out.query, r->in.buf_size); - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.query, r->in.buf_size)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.query); + } + _mem_save_query_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.query, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_QUERY_SERVICE_CONFIG(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.query)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_query_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.bytes_needed); } _mem_save_bytes_needed_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.bytes_needed, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.bytes_needed)); + if (*r->out.bytes_needed < 0 || *r->out.bytes_needed > 8192) { + return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_bytes_needed_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -2322,7 +2549,10 @@ _PUBLIC_ void ndr_print_svcctl_QueryServiceConfigW(struct ndr_print *ndr, const if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "svcctl_QueryServiceConfigW"); ndr->depth++; - ndr_print_array_uint8(ndr, "query", r->out.query, r->in.buf_size); + ndr_print_ptr(ndr, "query", r->out.query); + ndr->depth++; + ndr_print_QUERY_SERVICE_CONFIG(ndr, "query", r->out.query); + ndr->depth--; ndr_print_ptr(ndr, "bytes_needed", r->out.bytes_needed); ndr->depth++; ndr_print_uint32(ndr, "bytes_needed", *r->out.bytes_needed); @@ -2339,7 +2569,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceLockStatusW(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } if (flags & NDR_OUT) { @@ -2369,7 +2599,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceLockStatusW(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); NDR_PULL_ALLOC(ndr, r->out.lock_status); @@ -2437,7 +2667,7 @@ static enum ndr_err_code ndr_push_svcctl_StartServiceW(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.NumArgs)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.Arguments)); if (r->in.Arguments) { @@ -2464,7 +2694,7 @@ static enum ndr_err_code ndr_pull_svcctl_StartServiceW(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.NumArgs)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_Arguments)); @@ -2530,7 +2760,7 @@ static enum ndr_err_code ndr_push_svcctl_GetServiceDisplayNameW(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.service_name)); if (r->in.service_name) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.service_name, CH_UTF16))); @@ -2581,7 +2811,7 @@ static enum ndr_err_code ndr_pull_svcctl_GetServiceDisplayNameW(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_service_name)); if (_ptr_service_name) { @@ -2716,7 +2946,7 @@ static enum ndr_err_code ndr_push_svcctl_GetServiceKeyNameW(struct ndr_push *ndr if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.service_name)); if (r->in.service_name) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.service_name, CH_UTF16))); @@ -2767,7 +2997,7 @@ static enum ndr_err_code ndr_pull_svcctl_GetServiceKeyNameW(struct ndr_pull *ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_service_name)); if (_ptr_service_name) { @@ -2902,7 +3132,7 @@ static enum ndr_err_code ndr_push_svcctl_SCSetServiceBitsA(struct ndr_push *ndr, if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.bits)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.bitson)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.immediate)); @@ -2922,7 +3152,7 @@ static enum ndr_err_code ndr_pull_svcctl_SCSetServiceBitsA(struct ndr_pull *ndr, } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.bits)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.bitson)); @@ -2968,7 +3198,7 @@ static enum ndr_err_code ndr_push_svcctl_ChangeServiceConfigA(struct ndr_push *n if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.start)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.error)); @@ -3049,7 +3279,7 @@ static enum ndr_err_code ndr_pull_svcctl_ChangeServiceConfigA(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.start)); @@ -3252,7 +3482,7 @@ static enum ndr_err_code ndr_push_svcctl_CreateServiceA(struct ndr_push *ndr, in if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.ServiceName)); if (r->in.ServiceName) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.ServiceName, CH_UTF16))); @@ -3344,7 +3574,7 @@ static enum ndr_err_code ndr_pull_svcctl_CreateServiceA(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ServiceName)); if (_ptr_ServiceName) { @@ -3578,7 +3808,7 @@ static enum ndr_err_code ndr_push_svcctl_EnumDependentServicesA(struct ndr_push if (r->in.service == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.service)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.service)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.state)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } @@ -3615,7 +3845,7 @@ static enum ndr_err_code ndr_pull_svcctl_EnumDependentServicesA(struct ndr_pull } _mem_save_service_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.service, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.service)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.service)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_service_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.state)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); @@ -3703,7 +3933,7 @@ static enum ndr_err_code ndr_push_svcctl_EnumServicesStatusA(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.state)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); @@ -3747,7 +3977,7 @@ static enum ndr_err_code ndr_pull_svcctl_EnumServicesStatusA(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.state)); @@ -3879,7 +4109,7 @@ static enum ndr_err_code ndr_push_svcctl_OpenSCManagerA(struct ndr_push *ndr, in if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -3941,7 +4171,7 @@ static enum ndr_err_code ndr_pull_svcctl_OpenSCManagerA(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -3992,7 +4222,7 @@ static enum ndr_err_code ndr_push_svcctl_OpenServiceA(struct ndr_push *ndr, int if (r->in.scmanager_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.scmanager_handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.ServiceName)); if (r->in.ServiceName) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.ServiceName, CH_UTF16))); @@ -4019,7 +4249,7 @@ static enum ndr_err_code ndr_pull_svcctl_OpenServiceA(struct ndr_pull *ndr, int } _mem_save_scmanager_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.scmanager_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.scmanager_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_scmanager_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ServiceName)); if (_ptr_ServiceName) { @@ -4085,7 +4315,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceConfigA(struct ndr_push *nd if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } if (flags & NDR_OUT) { @@ -4111,7 +4341,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceConfigA(struct ndr_pull *nd } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); NDR_PULL_ALLOC(ndr, r->out.bytes_needed); @@ -4169,7 +4399,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceLockStatusA(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } if (flags & NDR_OUT) { @@ -4199,7 +4429,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceLockStatusA(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); NDR_PULL_ALLOC(ndr, r->out.lock_status); @@ -4267,7 +4497,7 @@ static enum ndr_err_code ndr_push_svcctl_StartServiceA(struct ndr_push *ndr, int if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.NumArgs)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.Arguments)); if (r->in.Arguments) { @@ -4294,7 +4524,7 @@ static enum ndr_err_code ndr_pull_svcctl_StartServiceA(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.NumArgs)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_Arguments)); @@ -4360,7 +4590,7 @@ static enum ndr_err_code ndr_push_svcctl_GetServiceDisplayNameA(struct ndr_push if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.service_name)); if (r->in.service_name) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.service_name, CH_UTF16))); @@ -4411,7 +4641,7 @@ static enum ndr_err_code ndr_pull_svcctl_GetServiceDisplayNameA(struct ndr_pull } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_service_name)); if (_ptr_service_name) { @@ -4546,7 +4776,7 @@ static enum ndr_err_code ndr_push_svcctl_GetServiceKeyNameA(struct ndr_push *ndr if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.service_name)); if (r->in.service_name) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.service_name, CH_UTF16))); @@ -4597,7 +4827,7 @@ static enum ndr_err_code ndr_pull_svcctl_GetServiceKeyNameA(struct ndr_pull *ndr } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_service_name)); if (_ptr_service_name) { @@ -4814,7 +5044,7 @@ static enum ndr_err_code ndr_push_svcctl_ChangeServiceConfig2A(struct ndr_push * if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.info)); if (r->in.info) { @@ -4838,7 +5068,7 @@ static enum ndr_err_code ndr_pull_svcctl_ChangeServiceConfig2A(struct ndr_pull * } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); @@ -4898,7 +5128,7 @@ static enum ndr_err_code ndr_push_svcctl_ChangeServiceConfig2W(struct ndr_push * if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.info)); if (r->in.info) { @@ -4922,7 +5152,7 @@ static enum ndr_err_code ndr_pull_svcctl_ChangeServiceConfig2W(struct ndr_pull * } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); @@ -4982,7 +5212,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceConfig2A(struct ndr_push *n if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } @@ -5009,7 +5239,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceConfig2A(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); @@ -5069,7 +5299,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceConfig2W(struct ndr_push *n if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } @@ -5096,7 +5326,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceConfig2W(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); @@ -5156,7 +5386,7 @@ static enum ndr_err_code ndr_push_svcctl_QueryServiceStatusEx(struct ndr_push *n if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.buf_size)); } @@ -5183,7 +5413,7 @@ static enum ndr_err_code ndr_pull_svcctl_QueryServiceStatusEx(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.buf_size)); @@ -5243,7 +5473,7 @@ static enum ndr_err_code ndr_push_EnumServicesStatusExA(struct ndr_push *ndr, in if (r->in.scmanager == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.scmanager)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.state)); @@ -5300,7 +5530,7 @@ static enum ndr_err_code ndr_pull_EnumServicesStatusExA(struct ndr_pull *ndr, in } _mem_save_scmanager_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.scmanager, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.scmanager)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_scmanager_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); @@ -5448,7 +5678,7 @@ static enum ndr_err_code ndr_push_EnumServicesStatusExW(struct ndr_push *ndr, in if (r->in.scmanager == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.scmanager)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.info_level)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.state)); @@ -5505,7 +5735,7 @@ static enum ndr_err_code ndr_pull_EnumServicesStatusExW(struct ndr_pull *ndr, in } _mem_save_scmanager_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.scmanager, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.scmanager)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.scmanager)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_scmanager_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.info_level)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); diff --git a/source3/librpc/gen_ndr/ndr_svcctl.h b/source3/librpc/gen_ndr/ndr_svcctl.h index 4475b08792..0bebd3401a 100644 --- a/source3/librpc/gen_ndr/ndr_svcctl.h +++ b/source3/librpc/gen_ndr/ndr_svcctl.h @@ -108,6 +108,10 @@ enum ndr_err_code ndr_pull_svcctl_ServerType(struct ndr_pull *ndr, int ndr_flags void ndr_print_svcctl_ServerType(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_svcctl_MgrAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_svcctl_ServiceAccessMask(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_QUERY_SERVICE_CONFIG(struct ndr_push *ndr, int ndr_flags, const struct QUERY_SERVICE_CONFIG *r); +enum ndr_err_code ndr_pull_QUERY_SERVICE_CONFIG(struct ndr_pull *ndr, int ndr_flags, struct QUERY_SERVICE_CONFIG *r); +void ndr_print_QUERY_SERVICE_CONFIG(struct ndr_print *ndr, const char *name, const struct QUERY_SERVICE_CONFIG *r); +size_t ndr_size_QUERY_SERVICE_CONFIG(const struct QUERY_SERVICE_CONFIG *r, int flags); void ndr_print_svcctl_CloseServiceHandle(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_CloseServiceHandle *r); void ndr_print_svcctl_ControlService(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_ControlService *r); void ndr_print_svcctl_DeleteService(struct ndr_print *ndr, const char *name, int flags, const struct svcctl_DeleteService *r); diff --git a/source3/librpc/gen_ndr/ndr_winreg.c b/source3/librpc/gen_ndr/ndr_winreg.c index 053e155616..791d11103d 100644 --- a/source3/librpc/gen_ndr/ndr_winreg.c +++ b/source3/librpc/gen_ndr/ndr_winreg.c @@ -4,7 +4,6 @@ #include "librpc/gen_ndr/ndr_winreg.h" #include "librpc/gen_ndr/ndr_lsa.h" -#include "librpc/gen_ndr/ndr_initshutdown.h" #include "librpc/gen_ndr/ndr_security.h" static enum ndr_err_code ndr_push_winreg_AccessMask(struct ndr_push *ndr, int ndr_flags, uint32_t r) { @@ -35,13 +34,13 @@ _PUBLIC_ void ndr_print_winreg_AccessMask(struct ndr_print *ndr, const char *nam ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_Type(struct ndr_push *ndr, int ndr_flags, enum winreg_Type r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_Type(struct ndr_push *ndr, int ndr_flags, enum winreg_Type r) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_Type(struct ndr_pull *ndr, int ndr_flags, enum winreg_Type *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_Type(struct ndr_pull *ndr, int ndr_flags, enum winreg_Type *r) { uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); @@ -276,7 +275,7 @@ static enum ndr_err_code ndr_push_winreg_StringBuf(struct ndr_push *ndr, int ndr { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term_null(r->name) * 2)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2)); NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->size)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->name)); } @@ -284,8 +283,8 @@ static enum ndr_err_code ndr_push_winreg_StringBuf(struct ndr_push *ndr, int ndr if (r->name) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size / 2)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term_null(r->name) * 2 / 2)); - NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, strlen_m_term_null(r->name) * 2 / 2, sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2 / 2)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, strlen_m_term(r->name) * 2 / 2, sizeof(uint16_t), CH_UTF16)); } } return NDR_ERR_SUCCESS; @@ -332,7 +331,7 @@ _PUBLIC_ void ndr_print_winreg_StringBuf(struct ndr_print *ndr, const char *name { ndr_print_struct(ndr, name, "winreg_StringBuf"); ndr->depth++; - ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term_null(r->name) * 2:r->length); + ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term(r->name) * 2:r->length); ndr_print_uint16(ndr, "size", r->size); ndr_print_ptr(ndr, "name", r->name); ndr->depth++; @@ -343,74 +342,28 @@ _PUBLIC_ void ndr_print_winreg_StringBuf(struct ndr_print *ndr, const char *name ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_ValNameBuf(struct ndr_push *ndr, int ndr_flags, const struct winreg_ValNameBuf *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_NotifyChangeType(struct ndr_push *ndr, int ndr_flags, uint32_t r) { - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2)); - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->size)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->name)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->name) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size / 2)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, strlen_m_term(r->name) * 2 / 2)); - NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, strlen_m_term(r->name) * 2 / 2, sizeof(uint16_t), CH_UTF16)); - } - } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_ValNameBuf(struct ndr_pull *ndr, int ndr_flags, struct winreg_ValNameBuf *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_NotifyChangeType(struct ndr_pull *ndr, int ndr_flags, uint32_t *r) { - uint32_t _ptr_name; - TALLOC_CTX *_mem_save_name_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->length)); - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name)); - if (_ptr_name) { - NDR_PULL_ALLOC(ndr, r->name); - } else { - r->name = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->name) { - _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->name, 0); - NDR_CHECK(ndr_pull_array_size(ndr, &r->name)); - NDR_CHECK(ndr_pull_array_length(ndr, &r->name)); - if (ndr_get_array_length(ndr, &r->name) > ndr_get_array_size(ndr, &r->name)) { - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->name), ndr_get_array_length(ndr, &r->name)); - } - NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->name, ndr_get_array_length(ndr, &r->name), sizeof(uint16_t), CH_UTF16)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0); - } - if (r->name) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->name, r->size / 2)); - } - if (r->name) { - NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->name, r->length / 2)); - } - } + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_winreg_ValNameBuf(struct ndr_print *ndr, const char *name, const struct winreg_ValNameBuf *r) +_PUBLIC_ void ndr_print_winreg_NotifyChangeType(struct ndr_print *ndr, const char *name, uint32_t r) { - ndr_print_struct(ndr, name, "winreg_ValNameBuf"); - ndr->depth++; - ndr_print_uint16(ndr, "length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?strlen_m_term(r->name) * 2:r->length); - ndr_print_uint16(ndr, "size", r->size); - ndr_print_ptr(ndr, "name", r->name); + ndr_print_uint32(ndr, name, r); ndr->depth++; - if (r->name) { - ndr_print_string(ndr, "name", r->name); - } - ndr->depth--; + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "REG_NOTIFY_CHANGE_NAME", REG_NOTIFY_CHANGE_NAME, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "REG_NOTIFY_CHANGE_ATTRIBUTES", REG_NOTIFY_CHANGE_ATTRIBUTES, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "REG_NOTIFY_CHANGE_LAST_SET", REG_NOTIFY_CHANGE_LAST_SET, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "REG_NOTIFY_CHANGE_SECURITY", REG_NOTIFY_CHANGE_SECURITY, r); ndr->depth--; } @@ -525,7 +478,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKCR(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -561,7 +514,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKCR(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -613,7 +566,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKCU(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -649,7 +602,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKCU(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -688,7 +641,7 @@ _PUBLIC_ void ndr_print_winreg_OpenHKCU(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_OpenHKLM(struct ndr_push *ndr, int flags, const struct winreg_OpenHKLM *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_OpenHKLM(struct ndr_push *ndr, int flags, const struct winreg_OpenHKLM *r) { if (flags & NDR_IN) { NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.system_name)); @@ -701,13 +654,13 @@ static enum ndr_err_code ndr_push_winreg_OpenHKLM(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_OpenHKLM(struct ndr_pull *ndr, int flags, struct winreg_OpenHKLM *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_OpenHKLM(struct ndr_pull *ndr, int flags, struct winreg_OpenHKLM *r) { uint32_t _ptr_system_name; TALLOC_CTX *_mem_save_system_name_0; @@ -737,7 +690,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKLM(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -789,7 +742,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKPD(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -825,7 +778,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKPD(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -877,7 +830,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKU(struct ndr_push *ndr, int flags if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -913,7 +866,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKU(struct ndr_pull *ndr, int flags } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -952,25 +905,25 @@ _PUBLIC_ void ndr_print_winreg_OpenHKU(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_CloseKey(struct ndr_push *ndr, int flags, const struct winreg_CloseKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_CloseKey(struct ndr_push *ndr, int flags, const struct winreg_CloseKey *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_CloseKey(struct ndr_pull *ndr, int flags, struct winreg_CloseKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_CloseKey(struct ndr_pull *ndr, int flags, struct winreg_CloseKey *r) { TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { @@ -981,7 +934,7 @@ static enum ndr_err_code ndr_pull_winreg_CloseKey(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.handle); *r->out.handle = *r->in.handle; @@ -992,7 +945,7 @@ static enum ndr_err_code ndr_pull_winreg_CloseKey(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -1028,13 +981,13 @@ _PUBLIC_ void ndr_print_winreg_CloseKey(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_CreateKey(struct ndr_push *ndr, int flags, const struct winreg_CreateKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_CreateKey(struct ndr_push *ndr, int flags, const struct winreg_CreateKey *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.keyclass)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.options)); @@ -1052,7 +1005,7 @@ static enum ndr_err_code ndr_push_winreg_CreateKey(struct ndr_push *ndr, int fla if (r->out.new_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.new_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.new_handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.action_taken)); if (r->out.action_taken) { NDR_CHECK(ndr_push_winreg_CreateAction(ndr, NDR_SCALARS, *r->out.action_taken)); @@ -1062,7 +1015,7 @@ static enum ndr_err_code ndr_push_winreg_CreateKey(struct ndr_push *ndr, int fla return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_CreateKey(struct ndr_pull *ndr, int flags, struct winreg_CreateKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_CreateKey(struct ndr_pull *ndr, int flags, struct winreg_CreateKey *r) { uint32_t _ptr_secdesc; uint32_t _ptr_action_taken; @@ -1078,7 +1031,7 @@ static enum ndr_err_code ndr_pull_winreg_CreateKey(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.keyclass)); @@ -1117,7 +1070,7 @@ static enum ndr_err_code ndr_pull_winreg_CreateKey(struct ndr_pull *ndr, int fla } _mem_save_new_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.new_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.new_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.new_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_new_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_action_taken)); if (_ptr_action_taken) { @@ -1187,13 +1140,13 @@ _PUBLIC_ void ndr_print_winreg_CreateKey(struct ndr_print *ndr, const char *name ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_DeleteKey(struct ndr_push *ndr, int flags, const struct winreg_DeleteKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_DeleteKey(struct ndr_push *ndr, int flags, const struct winreg_DeleteKey *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.key)); } if (flags & NDR_OUT) { @@ -1202,7 +1155,7 @@ static enum ndr_err_code ndr_push_winreg_DeleteKey(struct ndr_push *ndr, int fla return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_DeleteKey(struct ndr_pull *ndr, int flags, struct winreg_DeleteKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_DeleteKey(struct ndr_pull *ndr, int flags, struct winreg_DeleteKey *r) { TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { @@ -1211,7 +1164,7 @@ static enum ndr_err_code ndr_pull_winreg_DeleteKey(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.key)); } @@ -1253,7 +1206,7 @@ static enum ndr_err_code ndr_push_winreg_DeleteValue(struct ndr_push *ndr, int f if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.value)); } if (flags & NDR_OUT) { @@ -1271,7 +1224,7 @@ static enum ndr_err_code ndr_pull_winreg_DeleteValue(struct ndr_pull *ndr, int f } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.value)); } @@ -1307,13 +1260,13 @@ _PUBLIC_ void ndr_print_winreg_DeleteValue(struct ndr_print *ndr, const char *na ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_EnumKey(struct ndr_push *ndr, int flags, const struct winreg_EnumKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_EnumKey(struct ndr_push *ndr, int flags, const struct winreg_EnumKey *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.enum_index)); if (r->in.name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -1346,7 +1299,7 @@ static enum ndr_err_code ndr_push_winreg_EnumKey(struct ndr_push *ndr, int flags return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_EnumKey(struct ndr_pull *ndr, int flags, struct winreg_EnumKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_EnumKey(struct ndr_pull *ndr, int flags, struct winreg_EnumKey *r) { uint32_t _ptr_keyclass; uint32_t _ptr_last_changed_time; @@ -1362,7 +1315,7 @@ static enum ndr_err_code ndr_pull_winreg_EnumKey(struct ndr_pull *ndr, int flags } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.enum_index)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -1494,18 +1447,18 @@ _PUBLIC_ void ndr_print_winreg_EnumKey(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int flags, const struct winreg_EnumValue *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int flags, const struct winreg_EnumValue *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.enum_index)); if (r->in.name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name)); + NDR_CHECK(ndr_push_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.type)); if (r->in.type) { NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->in.type)); @@ -1530,7 +1483,7 @@ static enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int fla if (r->out.name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name)); + NDR_CHECK(ndr_push_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.type)); if (r->out.type) { NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->out.type)); @@ -1555,7 +1508,7 @@ static enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int fla return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int flags, struct winreg_EnumValue *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int flags, struct winreg_EnumValue *r) { uint32_t _ptr_type; uint32_t _ptr_value; @@ -1575,7 +1528,7 @@ static enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int fla } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.enum_index)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -1583,7 +1536,7 @@ static enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int fla } _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.name, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name)); + NDR_CHECK(ndr_pull_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.name)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_type)); if (_ptr_type) { @@ -1656,7 +1609,7 @@ static enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int fla } _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.name, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_winreg_ValNameBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name)); + NDR_CHECK(ndr_pull_winreg_StringBuf(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.name)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_type)); if (_ptr_type) { @@ -1742,7 +1695,7 @@ _PUBLIC_ void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name ndr_print_uint32(ndr, "enum_index", r->in.enum_index); ndr_print_ptr(ndr, "name", r->in.name); ndr->depth++; - ndr_print_winreg_ValNameBuf(ndr, "name", r->in.name); + ndr_print_winreg_StringBuf(ndr, "name", r->in.name); ndr->depth--; ndr_print_ptr(ndr, "type", r->in.type); ndr->depth++; @@ -1776,7 +1729,7 @@ _PUBLIC_ void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name ndr->depth++; ndr_print_ptr(ndr, "name", r->out.name); ndr->depth++; - ndr_print_winreg_ValNameBuf(ndr, "name", r->out.name); + ndr_print_winreg_StringBuf(ndr, "name", r->out.name); ndr->depth--; ndr_print_ptr(ndr, "type", r->out.type); ndr->depth++; @@ -1809,13 +1762,13 @@ _PUBLIC_ void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_FlushKey(struct ndr_push *ndr, int flags, const struct winreg_FlushKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_FlushKey(struct ndr_push *ndr, int flags, const struct winreg_FlushKey *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); @@ -1823,7 +1776,7 @@ static enum ndr_err_code ndr_push_winreg_FlushKey(struct ndr_push *ndr, int flag return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_FlushKey(struct ndr_pull *ndr, int flags, struct winreg_FlushKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_FlushKey(struct ndr_pull *ndr, int flags, struct winreg_FlushKey *r) { TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { @@ -1832,7 +1785,7 @@ static enum ndr_err_code ndr_pull_winreg_FlushKey(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); } if (flags & NDR_OUT) { @@ -1866,13 +1819,13 @@ _PUBLIC_ void ndr_print_winreg_FlushKey(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_GetKeySecurity(struct ndr_push *ndr, int flags, const struct winreg_GetKeySecurity *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_GetKeySecurity(struct ndr_push *ndr, int flags, const struct winreg_GetKeySecurity *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_security_secinfo(ndr, NDR_SCALARS, r->in.sec_info)); if (r->in.sd == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); @@ -1889,7 +1842,7 @@ static enum ndr_err_code ndr_push_winreg_GetKeySecurity(struct ndr_push *ndr, in return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_GetKeySecurity(struct ndr_pull *ndr, int flags, struct winreg_GetKeySecurity *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_GetKeySecurity(struct ndr_pull *ndr, int flags, struct winreg_GetKeySecurity *r) { TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_sd_0; @@ -1901,7 +1854,7 @@ static enum ndr_err_code ndr_pull_winreg_GetKeySecurity(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_security_secinfo(ndr, NDR_SCALARS, &r->in.sec_info)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { @@ -1967,7 +1920,7 @@ static enum ndr_err_code ndr_push_winreg_LoadKey(struct ndr_push *ndr, int flags if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.keyname)); if (r->in.keyname) { NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.keyname)); @@ -1996,7 +1949,7 @@ static enum ndr_err_code ndr_pull_winreg_LoadKey(struct ndr_pull *ndr, int flags } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_keyname)); if (_ptr_keyname) { @@ -2066,15 +2019,15 @@ _PUBLIC_ void ndr_print_winreg_LoadKey(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_NotifyChangeKeyValue(struct ndr_push *ndr, int flags, const struct winreg_NotifyChangeKeyValue *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_NotifyChangeKeyValue(struct ndr_push *ndr, int flags, const struct winreg_NotifyChangeKeyValue *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.watch_subtree)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.notify_filter)); + NDR_CHECK(ndr_push_winreg_NotifyChangeType(ndr, NDR_SCALARS, r->in.notify_filter)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.string1)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.string2)); @@ -2086,7 +2039,7 @@ static enum ndr_err_code ndr_push_winreg_NotifyChangeKeyValue(struct ndr_push *n return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_NotifyChangeKeyValue(struct ndr_pull *ndr, int flags, struct winreg_NotifyChangeKeyValue *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_NotifyChangeKeyValue(struct ndr_pull *ndr, int flags, struct winreg_NotifyChangeKeyValue *r) { TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { @@ -2095,10 +2048,10 @@ static enum ndr_err_code ndr_pull_winreg_NotifyChangeKeyValue(struct ndr_pull *n } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->in.watch_subtree)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.notify_filter)); + NDR_CHECK(ndr_pull_winreg_NotifyChangeType(ndr, NDR_SCALARS, &r->in.notify_filter)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown)); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.string1)); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.string2)); @@ -2125,7 +2078,7 @@ _PUBLIC_ void ndr_print_winreg_NotifyChangeKeyValue(struct ndr_print *ndr, const ndr_print_policy_handle(ndr, "handle", r->in.handle); ndr->depth--; ndr_print_uint8(ndr, "watch_subtree", r->in.watch_subtree); - ndr_print_uint32(ndr, "notify_filter", r->in.notify_filter); + ndr_print_winreg_NotifyChangeType(ndr, "notify_filter", r->in.notify_filter); ndr_print_uint32(ndr, "unknown", r->in.unknown); ndr_print_winreg_String(ndr, "string1", &r->in.string1); ndr_print_winreg_String(ndr, "string2", &r->in.string2); @@ -2141,13 +2094,13 @@ _PUBLIC_ void ndr_print_winreg_NotifyChangeKeyValue(struct ndr_print *ndr, const ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_OpenKey(struct ndr_push *ndr, int flags, const struct winreg_OpenKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_OpenKey(struct ndr_push *ndr, int flags, const struct winreg_OpenKey *r) { if (flags & NDR_IN) { if (r->in.parent_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.parent_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.parent_handle)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.keyname)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown)); NDR_CHECK(ndr_push_winreg_AccessMask(ndr, NDR_SCALARS, r->in.access_mask)); @@ -2156,13 +2109,13 @@ static enum ndr_err_code ndr_push_winreg_OpenKey(struct ndr_push *ndr, int flags if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_OpenKey(struct ndr_pull *ndr, int flags, struct winreg_OpenKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_OpenKey(struct ndr_pull *ndr, int flags, struct winreg_OpenKey *r) { TALLOC_CTX *_mem_save_parent_handle_0; TALLOC_CTX *_mem_save_handle_0; @@ -2174,7 +2127,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenKey(struct ndr_pull *ndr, int flags } _mem_save_parent_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.parent_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.parent_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.parent_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_parent_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.keyname)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown)); @@ -2188,7 +2141,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenKey(struct ndr_pull *ndr, int flags } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -2227,13 +2180,13 @@ _PUBLIC_ void ndr_print_winreg_OpenKey(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_QueryInfoKey(struct ndr_push *ndr, int flags, const struct winreg_QueryInfoKey *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_QueryInfoKey(struct ndr_push *ndr, int flags, const struct winreg_QueryInfoKey *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.classname == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2281,7 +2234,7 @@ static enum ndr_err_code ndr_push_winreg_QueryInfoKey(struct ndr_push *ndr, int return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_QueryInfoKey(struct ndr_pull *ndr, int flags, struct winreg_QueryInfoKey *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_QueryInfoKey(struct ndr_pull *ndr, int flags, struct winreg_QueryInfoKey *r) { TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_classname_0; @@ -2301,7 +2254,7 @@ static enum ndr_err_code ndr_pull_winreg_QueryInfoKey(struct ndr_pull *ndr, int } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.classname); @@ -2463,13 +2416,13 @@ _PUBLIC_ void ndr_print_winreg_QueryInfoKey(struct ndr_print *ndr, const char *n ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struct winreg_QueryValue *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struct winreg_QueryValue *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.value_name == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2482,16 +2435,16 @@ static enum ndr_err_code ndr_push_winreg_QueryValue(struct ndr_push *ndr, int fl if (r->in.data) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.data_size)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.value_length)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.data, *r->in.value_length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.data_length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.data, *r->in.data_length)); } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.data_size)); if (r->in.data_size) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.data_size)); } - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.value_length)); - if (r->in.value_length) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.value_length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.data_length)); + if (r->in.data_length) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.data_length)); } } if (flags & NDR_OUT) { @@ -2503,34 +2456,34 @@ static enum ndr_err_code ndr_push_winreg_QueryValue(struct ndr_push *ndr, int fl if (r->out.data) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_size)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.value_length)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.data, *r->out.value_length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.data, *r->out.data_length)); } NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.data_size)); if (r->out.data_size) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_size)); } - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.value_length)); - if (r->out.value_length) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.value_length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.data_length)); + if (r->out.data_length) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_length)); } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winreg_QueryValue *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winreg_QueryValue *r) { uint32_t _ptr_type; uint32_t _ptr_data; uint32_t _ptr_data_size; - uint32_t _ptr_value_length; + uint32_t _ptr_data_length; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_value_name_0; TALLOC_CTX *_mem_save_type_0; TALLOC_CTX *_mem_save_data_0; TALLOC_CTX *_mem_save_data_size_0; - TALLOC_CTX *_mem_save_value_length_0; + TALLOC_CTX *_mem_save_data_length_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -2539,7 +2492,7 @@ static enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.value_name); @@ -2590,25 +2543,25 @@ static enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int fl NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.data_size)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_size_0, 0); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value_length)); - if (_ptr_value_length) { - NDR_PULL_ALLOC(ndr, r->in.value_length); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_length)); + if (_ptr_data_length) { + NDR_PULL_ALLOC(ndr, r->in.data_length); } else { - r->in.value_length = NULL; + r->in.data_length = NULL; } - if (r->in.value_length) { - _mem_save_value_length_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.value_length, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.value_length)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value_length_0, 0); + if (r->in.data_length) { + _mem_save_data_length_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.data_length, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.data_length)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_length_0, 0); } if (r->in.data) { if (r->in.data_size == NULL) return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, "NULL Pointer for size_is()"); NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.data, *r->in.data_size)); } if (r->in.data) { - if (r->in.value_length == NULL) return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, "NULL Pointer for length_is()"); - NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->in.data, *r->in.value_length)); + if (r->in.data_length == NULL) return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, "NULL Pointer for length_is()"); + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->in.data, *r->in.data_length)); } } if (flags & NDR_OUT) { @@ -2654,17 +2607,17 @@ static enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int fl NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.data_size)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_size_0, 0); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value_length)); - if (_ptr_value_length) { - NDR_PULL_ALLOC(ndr, r->out.value_length); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_length)); + if (_ptr_data_length) { + NDR_PULL_ALLOC(ndr, r->out.data_length); } else { - r->out.value_length = NULL; + r->out.data_length = NULL; } - if (r->out.value_length) { - _mem_save_value_length_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.value_length, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.value_length)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value_length_0, 0); + if (r->out.data_length) { + _mem_save_data_length_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.data_length, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.data_length)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_length_0, 0); } NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); if (r->out.data) { @@ -2672,8 +2625,8 @@ static enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int fl NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.data, *r->out.data_size)); } if (r->out.data) { - if (r->out.value_length == NULL) return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, "NULL Pointer for length_is()"); - NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->out.data, *r->out.value_length)); + if (r->out.data_length == NULL) return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, "NULL Pointer for length_is()"); + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->out.data, *r->out.data_length)); } } return NDR_ERR_SUCCESS; @@ -2706,8 +2659,8 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr_print_ptr(ndr, "data", r->in.data); ndr->depth++; if (r->in.data) { - if (r->in.value_length == NULL) return; - ndr_print_array_uint8(ndr, "data", r->in.data, *r->in.value_length); + if (r->in.data_length == NULL) return; + ndr_print_array_uint8(ndr, "data", r->in.data, *r->in.data_length); } ndr->depth--; ndr_print_ptr(ndr, "data_size", r->in.data_size); @@ -2716,10 +2669,10 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr_print_uint32(ndr, "data_size", *r->in.data_size); } ndr->depth--; - ndr_print_ptr(ndr, "value_length", r->in.value_length); + ndr_print_ptr(ndr, "data_length", r->in.data_length); ndr->depth++; - if (r->in.value_length) { - ndr_print_uint32(ndr, "value_length", *r->in.value_length); + if (r->in.data_length) { + ndr_print_uint32(ndr, "data_length", *r->in.data_length); } ndr->depth--; ndr->depth--; @@ -2736,8 +2689,8 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr_print_ptr(ndr, "data", r->out.data); ndr->depth++; if (r->out.data) { - if (r->out.value_length == NULL) return; - ndr_print_array_uint8(ndr, "data", r->out.data, *r->out.value_length); + if (r->out.data_length == NULL) return; + ndr_print_array_uint8(ndr, "data", r->out.data, *r->out.data_length); } ndr->depth--; ndr_print_ptr(ndr, "data_size", r->out.data_size); @@ -2746,10 +2699,10 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr_print_uint32(ndr, "data_size", *r->out.data_size); } ndr->depth--; - ndr_print_ptr(ndr, "value_length", r->out.value_length); + ndr_print_ptr(ndr, "data_length", r->out.data_length); ndr->depth++; - if (r->out.value_length) { - ndr_print_uint32(ndr, "value_length", *r->out.value_length); + if (r->out.data_length) { + ndr_print_uint32(ndr, "data_length", *r->out.data_length); } ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); @@ -2805,7 +2758,7 @@ static enum ndr_err_code ndr_push_winreg_RestoreKey(struct ndr_push *ndr, int fl if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.filename == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2828,7 +2781,7 @@ static enum ndr_err_code ndr_pull_winreg_RestoreKey(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.filename); @@ -2881,7 +2834,7 @@ static enum ndr_err_code ndr_push_winreg_SaveKey(struct ndr_push *ndr, int flags if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); if (r->in.filename == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2909,7 +2862,7 @@ static enum ndr_err_code ndr_pull_winreg_SaveKey(struct ndr_pull *ndr, int flags } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.filename); @@ -2978,8 +2931,8 @@ static enum ndr_err_code ndr_push_winreg_SetKeySecurity(struct ndr_push *ndr, in if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_CHECK(ndr_push_winreg_AccessMask(ndr, NDR_SCALARS, r->in.access_mask)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_security_secinfo(ndr, NDR_SCALARS, r->in.sec_info)); if (r->in.sd == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -3001,9 +2954,9 @@ static enum ndr_err_code ndr_pull_winreg_SetKeySecurity(struct ndr_pull *ndr, in } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_winreg_AccessMask(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_CHECK(ndr_pull_security_secinfo(ndr, NDR_SCALARS, &r->in.sec_info)); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->in.sd); } @@ -3032,7 +2985,7 @@ _PUBLIC_ void ndr_print_winreg_SetKeySecurity(struct ndr_print *ndr, const char ndr->depth++; ndr_print_policy_handle(ndr, "handle", r->in.handle); ndr->depth--; - ndr_print_winreg_AccessMask(ndr, "access_mask", r->in.access_mask); + ndr_print_security_secinfo(ndr, "sec_info", r->in.sec_info); ndr_print_ptr(ndr, "sd", r->in.sd); ndr->depth++; ndr_print_KeySecurityData(ndr, "sd", r->in.sd); @@ -3054,7 +3007,7 @@ static enum ndr_err_code ndr_push_winreg_SetValue(struct ndr_push *ndr, int flag if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_CHECK(ndr_push_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type)); if (r->in.data == NULL) { @@ -3079,7 +3032,7 @@ static enum ndr_err_code ndr_pull_winreg_SetValue(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_winreg_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.name)); NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type)); @@ -3181,7 +3134,7 @@ static enum ndr_err_code ndr_push_winreg_InitiateSystemShutdown(struct ndr_push } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.message)); if (r->in.message) { - NDR_CHECK(ndr_push_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.timeout)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.force_apps)); @@ -3221,7 +3174,7 @@ static enum ndr_err_code ndr_pull_winreg_InitiateSystemShutdown(struct ndr_pull if (r->in.message) { _mem_save_message_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.message, 0); - NDR_CHECK(ndr_pull_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_message_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.timeout)); @@ -3253,7 +3206,7 @@ _PUBLIC_ void ndr_print_winreg_InitiateSystemShutdown(struct ndr_print *ndr, con ndr_print_ptr(ndr, "message", r->in.message); ndr->depth++; if (r->in.message) { - ndr_print_initshutdown_String(ndr, "message", r->in.message); + ndr_print_lsa_StringLarge(ndr, "message", r->in.message); } ndr->depth--; ndr_print_uint32(ndr, "timeout", r->in.timeout); @@ -3335,13 +3288,13 @@ _PUBLIC_ void ndr_print_winreg_AbortSystemShutdown(struct ndr_print *ndr, const ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_GetVersion(struct ndr_push *ndr, int flags, const struct winreg_GetVersion *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_GetVersion(struct ndr_push *ndr, int flags, const struct winreg_GetVersion *r) { if (flags & NDR_IN) { if (r->in.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); } if (flags & NDR_OUT) { if (r->out.version == NULL) { @@ -3353,7 +3306,7 @@ static enum ndr_err_code ndr_push_winreg_GetVersion(struct ndr_push *ndr, int fl return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_GetVersion(struct ndr_pull *ndr, int flags, struct winreg_GetVersion *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_GetVersion(struct ndr_pull *ndr, int flags, struct winreg_GetVersion *r) { TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_version_0; @@ -3365,7 +3318,7 @@ static enum ndr_err_code ndr_pull_winreg_GetVersion(struct ndr_pull *ndr, int fl } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_PULL_ALLOC(ndr, r->out.version); ZERO_STRUCTP(r->out.version); @@ -3425,7 +3378,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKCC(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -3461,7 +3414,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKCC(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -3513,7 +3466,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKDD(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -3549,7 +3502,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKDD(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -3588,14 +3541,14 @@ _PUBLIC_ void ndr_print_winreg_OpenHKDD(struct ndr_print *ndr, const char *name, ndr->depth--; } -static enum ndr_err_code ndr_push_winreg_QueryMultipleValues(struct ndr_push *ndr, int flags, const struct winreg_QueryMultipleValues *r) +_PUBLIC_ enum ndr_err_code ndr_push_winreg_QueryMultipleValues(struct ndr_push *ndr, int flags, const struct winreg_QueryMultipleValues *r) { uint32_t cntr_values_1; if (flags & NDR_IN) { if (r->in.key_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.key_handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.key_handle)); if (r->in.values == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -3650,7 +3603,7 @@ static enum ndr_err_code ndr_push_winreg_QueryMultipleValues(struct ndr_push *nd return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_winreg_QueryMultipleValues(struct ndr_pull *ndr, int flags, struct winreg_QueryMultipleValues *r) +_PUBLIC_ enum ndr_err_code ndr_pull_winreg_QueryMultipleValues(struct ndr_pull *ndr, int flags, struct winreg_QueryMultipleValues *r) { uint32_t cntr_values_1; uint32_t _ptr_buffer; @@ -3666,7 +3619,7 @@ static enum ndr_err_code ndr_pull_winreg_QueryMultipleValues(struct ndr_pull *nd } _mem_save_key_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.key_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.key_handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.key_handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_key_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_array_size(ndr, &r->in.values)); NDR_CHECK(ndr_pull_array_length(ndr, &r->in.values)); @@ -3872,7 +3825,7 @@ static enum ndr_err_code ndr_push_winreg_InitiateSystemShutdownEx(struct ndr_pus } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.message)); if (r->in.message) { - NDR_CHECK(ndr_push_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_push_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.timeout)); NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->in.force_apps)); @@ -3913,7 +3866,7 @@ static enum ndr_err_code ndr_pull_winreg_InitiateSystemShutdownEx(struct ndr_pul if (r->in.message) { _mem_save_message_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->in.message, 0); - NDR_CHECK(ndr_pull_initshutdown_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); + NDR_CHECK(ndr_pull_lsa_StringLarge(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.message)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_message_0, 0); } NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.timeout)); @@ -3946,7 +3899,7 @@ _PUBLIC_ void ndr_print_winreg_InitiateSystemShutdownEx(struct ndr_print *ndr, c ndr_print_ptr(ndr, "message", r->in.message); ndr->depth++; if (r->in.message) { - ndr_print_initshutdown_String(ndr, "message", r->in.message); + ndr_print_lsa_StringLarge(ndr, "message", r->in.message); } ndr->depth--; ndr_print_uint32(ndr, "timeout", r->in.timeout); @@ -4018,7 +3971,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKPT(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -4054,7 +4007,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKPT(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -4106,7 +4059,7 @@ static enum ndr_err_code ndr_push_winreg_OpenHKPN(struct ndr_push *ndr, int flag if (r->out.handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -4142,7 +4095,7 @@ static enum ndr_err_code ndr_pull_winreg_OpenHKPN(struct ndr_pull *ndr, int flag } _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.handle)); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } diff --git a/source3/librpc/gen_ndr/ndr_winreg.h b/source3/librpc/gen_ndr/ndr_winreg.h index c093b0d1e0..8dea3ae273 100644 --- a/source3/librpc/gen_ndr/ndr_winreg.h +++ b/source3/librpc/gen_ndr/ndr_winreg.h @@ -83,6 +83,8 @@ extern const struct ndr_interface_table ndr_table_winreg; #define NDR_WINREG_CALL_COUNT (35) void ndr_print_winreg_AccessMask(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_winreg_Type(struct ndr_push *ndr, int ndr_flags, enum winreg_Type r); +enum ndr_err_code ndr_pull_winreg_Type(struct ndr_pull *ndr, int ndr_flags, enum winreg_Type *r); void ndr_print_winreg_Type(struct ndr_print *ndr, const char *name, enum winreg_Type r); enum ndr_err_code ndr_push_winreg_String(struct ndr_push *ndr, int ndr_flags, const struct winreg_String *r); enum ndr_err_code ndr_pull_winreg_String(struct ndr_pull *ndr, int ndr_flags, struct winreg_String *r); @@ -91,26 +93,52 @@ void ndr_print_KeySecurityData(struct ndr_print *ndr, const char *name, const st void ndr_print_winreg_SecBuf(struct ndr_print *ndr, const char *name, const struct winreg_SecBuf *r); void ndr_print_winreg_CreateAction(struct ndr_print *ndr, const char *name, enum winreg_CreateAction r); void ndr_print_winreg_StringBuf(struct ndr_print *ndr, const char *name, const struct winreg_StringBuf *r); -void ndr_print_winreg_ValNameBuf(struct ndr_print *ndr, const char *name, const struct winreg_ValNameBuf *r); +enum ndr_err_code ndr_push_winreg_NotifyChangeType(struct ndr_push *ndr, int ndr_flags, uint32_t r); +enum ndr_err_code ndr_pull_winreg_NotifyChangeType(struct ndr_pull *ndr, int ndr_flags, uint32_t *r); +void ndr_print_winreg_NotifyChangeType(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_KeySecurityAttribute(struct ndr_print *ndr, const char *name, const struct KeySecurityAttribute *r); void ndr_print_QueryMultipleValue(struct ndr_print *ndr, const char *name, const struct QueryMultipleValue *r); void ndr_print_winreg_OpenHKCR(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKCR *r); void ndr_print_winreg_OpenHKCU(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKCU *r); +enum ndr_err_code ndr_push_winreg_OpenHKLM(struct ndr_push *ndr, int flags, const struct winreg_OpenHKLM *r); +enum ndr_err_code ndr_pull_winreg_OpenHKLM(struct ndr_pull *ndr, int flags, struct winreg_OpenHKLM *r); void ndr_print_winreg_OpenHKLM(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKLM *r); void ndr_print_winreg_OpenHKPD(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKPD *r); void ndr_print_winreg_OpenHKU(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKU *r); +enum ndr_err_code ndr_push_winreg_CloseKey(struct ndr_push *ndr, int flags, const struct winreg_CloseKey *r); +enum ndr_err_code ndr_pull_winreg_CloseKey(struct ndr_pull *ndr, int flags, struct winreg_CloseKey *r); void ndr_print_winreg_CloseKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_CloseKey *r); +enum ndr_err_code ndr_push_winreg_CreateKey(struct ndr_push *ndr, int flags, const struct winreg_CreateKey *r); +enum ndr_err_code ndr_pull_winreg_CreateKey(struct ndr_pull *ndr, int flags, struct winreg_CreateKey *r); void ndr_print_winreg_CreateKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_CreateKey *r); +enum ndr_err_code ndr_push_winreg_DeleteKey(struct ndr_push *ndr, int flags, const struct winreg_DeleteKey *r); +enum ndr_err_code ndr_pull_winreg_DeleteKey(struct ndr_pull *ndr, int flags, struct winreg_DeleteKey *r); void ndr_print_winreg_DeleteKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_DeleteKey *r); void ndr_print_winreg_DeleteValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_DeleteValue *r); +enum ndr_err_code ndr_push_winreg_EnumKey(struct ndr_push *ndr, int flags, const struct winreg_EnumKey *r); +enum ndr_err_code ndr_pull_winreg_EnumKey(struct ndr_pull *ndr, int flags, struct winreg_EnumKey *r); void ndr_print_winreg_EnumKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_EnumKey *r); +enum ndr_err_code ndr_push_winreg_EnumValue(struct ndr_push *ndr, int flags, const struct winreg_EnumValue *r); +enum ndr_err_code ndr_pull_winreg_EnumValue(struct ndr_pull *ndr, int flags, struct winreg_EnumValue *r); void ndr_print_winreg_EnumValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_EnumValue *r); +enum ndr_err_code ndr_push_winreg_FlushKey(struct ndr_push *ndr, int flags, const struct winreg_FlushKey *r); +enum ndr_err_code ndr_pull_winreg_FlushKey(struct ndr_pull *ndr, int flags, struct winreg_FlushKey *r); void ndr_print_winreg_FlushKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_FlushKey *r); +enum ndr_err_code ndr_push_winreg_GetKeySecurity(struct ndr_push *ndr, int flags, const struct winreg_GetKeySecurity *r); +enum ndr_err_code ndr_pull_winreg_GetKeySecurity(struct ndr_pull *ndr, int flags, struct winreg_GetKeySecurity *r); void ndr_print_winreg_GetKeySecurity(struct ndr_print *ndr, const char *name, int flags, const struct winreg_GetKeySecurity *r); void ndr_print_winreg_LoadKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_LoadKey *r); +enum ndr_err_code ndr_push_winreg_NotifyChangeKeyValue(struct ndr_push *ndr, int flags, const struct winreg_NotifyChangeKeyValue *r); +enum ndr_err_code ndr_pull_winreg_NotifyChangeKeyValue(struct ndr_pull *ndr, int flags, struct winreg_NotifyChangeKeyValue *r); void ndr_print_winreg_NotifyChangeKeyValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_NotifyChangeKeyValue *r); +enum ndr_err_code ndr_push_winreg_OpenKey(struct ndr_push *ndr, int flags, const struct winreg_OpenKey *r); +enum ndr_err_code ndr_pull_winreg_OpenKey(struct ndr_pull *ndr, int flags, struct winreg_OpenKey *r); void ndr_print_winreg_OpenKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenKey *r); +enum ndr_err_code ndr_push_winreg_QueryInfoKey(struct ndr_push *ndr, int flags, const struct winreg_QueryInfoKey *r); +enum ndr_err_code ndr_pull_winreg_QueryInfoKey(struct ndr_pull *ndr, int flags, struct winreg_QueryInfoKey *r); void ndr_print_winreg_QueryInfoKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryInfoKey *r); +enum ndr_err_code ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struct winreg_QueryValue *r); +enum ndr_err_code ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winreg_QueryValue *r); void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryValue *r); void ndr_print_winreg_ReplaceKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_ReplaceKey *r); void ndr_print_winreg_RestoreKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_RestoreKey *r); @@ -120,9 +148,13 @@ void ndr_print_winreg_SetValue(struct ndr_print *ndr, const char *name, int flag void ndr_print_winreg_UnLoadKey(struct ndr_print *ndr, const char *name, int flags, const struct winreg_UnLoadKey *r); void ndr_print_winreg_InitiateSystemShutdown(struct ndr_print *ndr, const char *name, int flags, const struct winreg_InitiateSystemShutdown *r); void ndr_print_winreg_AbortSystemShutdown(struct ndr_print *ndr, const char *name, int flags, const struct winreg_AbortSystemShutdown *r); +enum ndr_err_code ndr_push_winreg_GetVersion(struct ndr_push *ndr, int flags, const struct winreg_GetVersion *r); +enum ndr_err_code ndr_pull_winreg_GetVersion(struct ndr_pull *ndr, int flags, struct winreg_GetVersion *r); void ndr_print_winreg_GetVersion(struct ndr_print *ndr, const char *name, int flags, const struct winreg_GetVersion *r); void ndr_print_winreg_OpenHKCC(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKCC *r); void ndr_print_winreg_OpenHKDD(struct ndr_print *ndr, const char *name, int flags, const struct winreg_OpenHKDD *r); +enum ndr_err_code ndr_push_winreg_QueryMultipleValues(struct ndr_push *ndr, int flags, const struct winreg_QueryMultipleValues *r); +enum ndr_err_code ndr_pull_winreg_QueryMultipleValues(struct ndr_pull *ndr, int flags, struct winreg_QueryMultipleValues *r); void ndr_print_winreg_QueryMultipleValues(struct ndr_print *ndr, const char *name, int flags, const struct winreg_QueryMultipleValues *r); void ndr_print_winreg_InitiateSystemShutdownEx(struct ndr_print *ndr, const char *name, int flags, const struct winreg_InitiateSystemShutdownEx *r); void ndr_print_winreg_SaveKeyEx(struct ndr_print *ndr, const char *name, int flags, const struct winreg_SaveKeyEx *r); diff --git a/source3/librpc/gen_ndr/ndr_xattr.c b/source3/librpc/gen_ndr/ndr_xattr.c index 92369835cf..0e9dda9f47 100644 --- a/source3/librpc/gen_ndr/ndr_xattr.c +++ b/source3/librpc/gen_ndr/ndr_xattr.c @@ -3,7 +3,244 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_xattr.h" -_PUBLIC_ enum ndr_err_code ndr_push_tdb_xattr(struct ndr_push *ndr, int ndr_flags, const struct tdb_xattr *r) +#include "librpc/gen_ndr/ndr_security.h" +static enum ndr_err_code ndr_push_xattr_DosInfo1(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->attrib)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ea_size)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->alloc_size)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->create_time)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->change_time)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_xattr_DosInfo1(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->attrib)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ea_size)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->alloc_size)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->create_time)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->change_time)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosInfo1(struct ndr_print *ndr, const char *name, const struct xattr_DosInfo1 *r) +{ + ndr_print_struct(ndr, name, "xattr_DosInfo1"); + ndr->depth++; + ndr_print_uint32(ndr, "attrib", r->attrib); + ndr_print_uint32(ndr, "ea_size", r->ea_size); + ndr_print_udlong(ndr, "size", r->size); + ndr_print_udlong(ndr, "alloc_size", r->alloc_size); + ndr_print_NTTIME(ndr, "create_time", r->create_time); + ndr_print_NTTIME(ndr, "change_time", r->change_time); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_xattr_DosInfo2Old(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosInfo2Old *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->attrib)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ea_size)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->alloc_size)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->create_time)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->change_time)); + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->write_time)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_xattr_DosInfo2Old(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosInfo2Old *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->attrib)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ea_size)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->alloc_size)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->create_time)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->change_time)); + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->write_time)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosInfo2Old(struct ndr_print *ndr, const char *name, const struct xattr_DosInfo2Old *r) +{ + ndr_print_struct(ndr, name, "xattr_DosInfo2Old"); + ndr->depth++; + ndr_print_uint32(ndr, "flags", r->flags); + ndr_print_uint32(ndr, "attrib", r->attrib); + ndr_print_uint32(ndr, "ea_size", r->ea_size); + ndr_print_udlong(ndr, "size", r->size); + ndr_print_udlong(ndr, "alloc_size", r->alloc_size); + ndr_print_NTTIME(ndr, "create_time", r->create_time); + ndr_print_NTTIME(ndr, "change_time", r->change_time); + ndr_print_NTTIME(ndr, "write_time", r->write_time); + ndr_print_string(ndr, "name", r->name); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_xattr_DosInfo(struct ndr_push *ndr, int ndr_flags, const union xattr_DosInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, level)); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_xattr_DosInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + case 2: { + NDR_CHECK(ndr_push_xattr_DosInfo2Old(ndr, NDR_SCALARS, &r->oldinfo2)); + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: + break; + + case 2: + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_xattr_DosInfo(struct ndr_pull *ndr, int ndr_flags, union xattr_DosInfo *r) +{ + int level; + uint16_t _level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_xattr_DosInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + case 2: { + NDR_CHECK(ndr_pull_xattr_DosInfo2Old(ndr, NDR_SCALARS, &r->oldinfo2)); + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case 1: + break; + + case 2: + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosInfo(struct ndr_print *ndr, const char *name, const union xattr_DosInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "xattr_DosInfo"); + switch (level) { + case 1: + ndr_print_xattr_DosInfo1(ndr, "info1", &r->info1); + break; + + case 2: + ndr_print_xattr_DosInfo2Old(ndr, "oldinfo2", &r->oldinfo2); + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + +_PUBLIC_ enum ndr_err_code ndr_push_xattr_DosAttrib(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosAttrib *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->version)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->info, r->version)); + NDR_CHECK(ndr_push_xattr_DosInfo(ndr, NDR_SCALARS, &r->info)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_xattr_DosAttrib(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosAttrib *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->version)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->info, r->version)); + NDR_CHECK(ndr_pull_xattr_DosInfo(ndr, NDR_SCALARS, &r->info)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosAttrib(struct ndr_print *ndr, const char *name, const struct xattr_DosAttrib *r) +{ + ndr_print_struct(ndr, name, "xattr_DosAttrib"); + ndr->depth++; + ndr_print_uint16(ndr, "version", r->version); + ndr_print_set_switch_value(ndr, &r->info, r->version); + ndr_print_xattr_DosInfo(ndr, "info", &r->info); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_xattr_EA(struct ndr_push *ndr, int ndr_flags, const struct xattr_EA *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -20,7 +257,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_tdb_xattr(struct ndr_push *ndr, int ndr_flag return NDR_ERR_SUCCESS; } -_PUBLIC_ enum ndr_err_code ndr_pull_tdb_xattr(struct ndr_pull *ndr, int ndr_flags, struct tdb_xattr *r) +static enum ndr_err_code ndr_pull_xattr_EA(struct ndr_pull *ndr, int ndr_flags, struct xattr_EA *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); @@ -37,23 +274,103 @@ _PUBLIC_ enum ndr_err_code ndr_pull_tdb_xattr(struct ndr_pull *ndr, int ndr_flag return NDR_ERR_SUCCESS; } -_PUBLIC_ void ndr_print_tdb_xattr(struct ndr_print *ndr, const char *name, const struct tdb_xattr *r) +_PUBLIC_ void ndr_print_xattr_EA(struct ndr_print *ndr, const char *name, const struct xattr_EA *r) { - ndr_print_struct(ndr, name, "tdb_xattr"); + ndr_print_struct(ndr, name, "xattr_EA"); ndr->depth++; ndr_print_string(ndr, "name", r->name); ndr_print_DATA_BLOB(ndr, "value", r->value); ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_xattr_DosEAs(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosEAs *r) +{ + uint32_t cntr_eas_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_eas)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->eas)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->eas) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_eas)); + for (cntr_eas_1 = 0; cntr_eas_1 < r->num_eas; cntr_eas_1++) { + NDR_CHECK(ndr_push_xattr_EA(ndr, NDR_SCALARS, &r->eas[cntr_eas_1])); + } + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_xattr_DosEAs(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosEAs *r) +{ + uint32_t _ptr_eas; + uint32_t cntr_eas_1; + TALLOC_CTX *_mem_save_eas_0; + TALLOC_CTX *_mem_save_eas_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_eas)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_eas)); + if (_ptr_eas) { + NDR_PULL_ALLOC(ndr, r->eas); + } else { + r->eas = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->eas) { + _mem_save_eas_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->eas, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->eas)); + NDR_PULL_ALLOC_N(ndr, r->eas, ndr_get_array_size(ndr, &r->eas)); + _mem_save_eas_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->eas, 0); + for (cntr_eas_1 = 0; cntr_eas_1 < r->num_eas; cntr_eas_1++) { + NDR_CHECK(ndr_pull_xattr_EA(ndr, NDR_SCALARS, &r->eas[cntr_eas_1])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_eas_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_eas_0, 0); + } + if (r->eas) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->eas, r->num_eas)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosEAs(struct ndr_print *ndr, const char *name, const struct xattr_DosEAs *r) +{ + uint32_t cntr_eas_1; + ndr_print_struct(ndr, name, "xattr_DosEAs"); + ndr->depth++; + ndr_print_uint16(ndr, "num_eas", r->num_eas); + ndr_print_ptr(ndr, "eas", r->eas); + ndr->depth++; + if (r->eas) { + ndr->print(ndr, "%s: ARRAY(%d)", "eas", (int)r->num_eas); + ndr->depth++; + for (cntr_eas_1=0;cntr_eas_1num_eas;cntr_eas_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_eas_1) != -1) { + ndr_print_xattr_EA(ndr, "eas", &r->eas[cntr_eas_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr->depth--; +} + _PUBLIC_ enum ndr_err_code ndr_push_tdb_xattrs(struct ndr_push *ndr, int ndr_flags, const struct tdb_xattrs *r) { - uint32_t cntr_xattrs_0; + uint32_t cntr_eas_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_xattrs)); - for (cntr_xattrs_0 = 0; cntr_xattrs_0 < r->num_xattrs; cntr_xattrs_0++) { - NDR_CHECK(ndr_push_tdb_xattr(ndr, NDR_SCALARS, &r->xattrs[cntr_xattrs_0])); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_eas)); + for (cntr_eas_0 = 0; cntr_eas_0 < r->num_eas; cntr_eas_0++) { + NDR_CHECK(ndr_push_xattr_EA(ndr, NDR_SCALARS, &r->eas[cntr_eas_0])); } } if (ndr_flags & NDR_BUFFERS) { @@ -63,18 +380,18 @@ _PUBLIC_ enum ndr_err_code ndr_push_tdb_xattrs(struct ndr_push *ndr, int ndr_fla _PUBLIC_ enum ndr_err_code ndr_pull_tdb_xattrs(struct ndr_pull *ndr, int ndr_flags, struct tdb_xattrs *r) { - uint32_t cntr_xattrs_0; - TALLOC_CTX *_mem_save_xattrs_0; + uint32_t cntr_eas_0; + TALLOC_CTX *_mem_save_eas_0; if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_xattrs)); - NDR_PULL_ALLOC_N(ndr, r->xattrs, r->num_xattrs); - _mem_save_xattrs_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->xattrs, 0); - for (cntr_xattrs_0 = 0; cntr_xattrs_0 < r->num_xattrs; cntr_xattrs_0++) { - NDR_CHECK(ndr_pull_tdb_xattr(ndr, NDR_SCALARS, &r->xattrs[cntr_xattrs_0])); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_eas)); + NDR_PULL_ALLOC_N(ndr, r->eas, r->num_eas); + _mem_save_eas_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->eas, 0); + for (cntr_eas_0 = 0; cntr_eas_0 < r->num_eas; cntr_eas_0++) { + NDR_CHECK(ndr_pull_xattr_EA(ndr, NDR_SCALARS, &r->eas[cntr_eas_0])); } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_xattrs_0, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_eas_0, 0); } if (ndr_flags & NDR_BUFFERS) { } @@ -83,16 +400,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_tdb_xattrs(struct ndr_pull *ndr, int ndr_fla _PUBLIC_ void ndr_print_tdb_xattrs(struct ndr_print *ndr, const char *name, const struct tdb_xattrs *r) { - uint32_t cntr_xattrs_0; + uint32_t cntr_eas_0; ndr_print_struct(ndr, name, "tdb_xattrs"); ndr->depth++; - ndr_print_uint32(ndr, "num_xattrs", r->num_xattrs); - ndr->print(ndr, "%s: ARRAY(%d)", "xattrs", (int)r->num_xattrs); + ndr_print_uint32(ndr, "num_eas", r->num_eas); + ndr->print(ndr, "%s: ARRAY(%d)", "eas", (int)r->num_eas); ndr->depth++; - for (cntr_xattrs_0=0;cntr_xattrs_0num_xattrs;cntr_xattrs_0++) { + for (cntr_eas_0=0;cntr_eas_0num_eas;cntr_eas_0++) { char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_xattrs_0) != -1) { - ndr_print_tdb_xattr(ndr, "xattrs", &r->xattrs[cntr_xattrs_0]); + if (asprintf(&idx_0, "[%d]", cntr_eas_0) != -1) { + ndr_print_xattr_EA(ndr, "eas", &r->eas[cntr_eas_0]); free(idx_0); } } @@ -100,6 +417,135 @@ _PUBLIC_ void ndr_print_tdb_xattrs(struct ndr_print *ndr, const char *name, cons ndr->depth--; } +static enum ndr_err_code ndr_push_xattr_DosStream(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosStream *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->alloc_size)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_xattr_DosStream(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosStream *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->alloc_size)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosStream(struct ndr_print *ndr, const char *name, const struct xattr_DosStream *r) +{ + ndr_print_struct(ndr, name, "xattr_DosStream"); + ndr->depth++; + ndr_print_uint32(ndr, "flags", r->flags); + ndr_print_udlong(ndr, "size", r->size); + ndr_print_udlong(ndr, "alloc_size", r->alloc_size); + ndr_print_string(ndr, "name", r->name); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_xattr_DosStreams(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosStreams *r) +{ + uint32_t cntr_streams_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_streams)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->streams)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->streams) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_streams)); + for (cntr_streams_1 = 0; cntr_streams_1 < r->num_streams; cntr_streams_1++) { + NDR_CHECK(ndr_push_xattr_DosStream(ndr, NDR_SCALARS, &r->streams[cntr_streams_1])); + } + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_xattr_DosStreams(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosStreams *r) +{ + uint32_t _ptr_streams; + uint32_t cntr_streams_1; + TALLOC_CTX *_mem_save_streams_0; + TALLOC_CTX *_mem_save_streams_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_streams)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_streams)); + if (_ptr_streams) { + NDR_PULL_ALLOC(ndr, r->streams); + } else { + r->streams = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->streams) { + _mem_save_streams_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->streams, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->streams)); + NDR_PULL_ALLOC_N(ndr, r->streams, ndr_get_array_size(ndr, &r->streams)); + _mem_save_streams_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->streams, 0); + for (cntr_streams_1 = 0; cntr_streams_1 < r->num_streams; cntr_streams_1++) { + NDR_CHECK(ndr_pull_xattr_DosStream(ndr, NDR_SCALARS, &r->streams[cntr_streams_1])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_streams_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_streams_0, 0); + } + if (r->streams) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->streams, r->num_streams)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_xattr_DosStreams(struct ndr_print *ndr, const char *name, const struct xattr_DosStreams *r) +{ + uint32_t cntr_streams_1; + ndr_print_struct(ndr, name, "xattr_DosStreams"); + ndr->depth++; + ndr_print_uint32(ndr, "num_streams", r->num_streams); + ndr_print_ptr(ndr, "streams", r->streams); + ndr->depth++; + if (r->streams) { + ndr->print(ndr, "%s: ARRAY(%d)", "streams", (int)r->num_streams); + ndr->depth++; + for (cntr_streams_1=0;cntr_streams_1num_streams;cntr_streams_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_streams_1) != -1) { + ndr_print_xattr_DosStream(ndr, "streams", &r->streams[cntr_streams_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr->depth--; +} + _PUBLIC_ enum ndr_err_code ndr_push_security_descriptor_timestamp(struct ndr_push *ndr, int ndr_flags, const struct security_descriptor_timestamp *r) { if (ndr_flags & NDR_SCALARS) { diff --git a/source3/librpc/gen_ndr/ndr_xattr.h b/source3/librpc/gen_ndr/ndr_xattr.h index 21c5ae03b5..38701b1aca 100644 --- a/source3/librpc/gen_ndr/ndr_xattr.h +++ b/source3/librpc/gen_ndr/ndr_xattr.h @@ -7,12 +7,23 @@ #define _HEADER_NDR_xattr #define NDR_XATTR_CALL_COUNT (0) -enum ndr_err_code ndr_push_tdb_xattr(struct ndr_push *ndr, int ndr_flags, const struct tdb_xattr *r); -enum ndr_err_code ndr_pull_tdb_xattr(struct ndr_pull *ndr, int ndr_flags, struct tdb_xattr *r); -void ndr_print_tdb_xattr(struct ndr_print *ndr, const char *name, const struct tdb_xattr *r); +void ndr_print_xattr_DosInfo1(struct ndr_print *ndr, const char *name, const struct xattr_DosInfo1 *r); +void ndr_print_xattr_DosInfo2Old(struct ndr_print *ndr, const char *name, const struct xattr_DosInfo2Old *r); +void ndr_print_xattr_DosInfo(struct ndr_print *ndr, const char *name, const union xattr_DosInfo *r); +enum ndr_err_code ndr_push_xattr_DosAttrib(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosAttrib *r); +enum ndr_err_code ndr_pull_xattr_DosAttrib(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosAttrib *r); +void ndr_print_xattr_DosAttrib(struct ndr_print *ndr, const char *name, const struct xattr_DosAttrib *r); +void ndr_print_xattr_EA(struct ndr_print *ndr, const char *name, const struct xattr_EA *r); +enum ndr_err_code ndr_push_xattr_DosEAs(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosEAs *r); +enum ndr_err_code ndr_pull_xattr_DosEAs(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosEAs *r); +void ndr_print_xattr_DosEAs(struct ndr_print *ndr, const char *name, const struct xattr_DosEAs *r); enum ndr_err_code ndr_push_tdb_xattrs(struct ndr_push *ndr, int ndr_flags, const struct tdb_xattrs *r); enum ndr_err_code ndr_pull_tdb_xattrs(struct ndr_pull *ndr, int ndr_flags, struct tdb_xattrs *r); void ndr_print_tdb_xattrs(struct ndr_print *ndr, const char *name, const struct tdb_xattrs *r); +void ndr_print_xattr_DosStream(struct ndr_print *ndr, const char *name, const struct xattr_DosStream *r); +enum ndr_err_code ndr_push_xattr_DosStreams(struct ndr_push *ndr, int ndr_flags, const struct xattr_DosStreams *r); +enum ndr_err_code ndr_pull_xattr_DosStreams(struct ndr_pull *ndr, int ndr_flags, struct xattr_DosStreams *r); +void ndr_print_xattr_DosStreams(struct ndr_print *ndr, const char *name, const struct xattr_DosStreams *r); enum ndr_err_code ndr_push_security_descriptor_timestamp(struct ndr_push *ndr, int ndr_flags, const struct security_descriptor_timestamp *r); enum ndr_err_code ndr_pull_security_descriptor_timestamp(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor_timestamp *r); void ndr_print_security_descriptor_timestamp(struct ndr_print *ndr, const char *name, const struct security_descriptor_timestamp *r); diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index 1cea1f0f42..cf3959b199 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -2,6 +2,7 @@ #include +#include "librpc/gen_ndr/misc.h" #include "librpc/gen_ndr/lsa.h" #include "librpc/gen_ndr/samr.h" #include "librpc/gen_ndr/security.h" @@ -78,10 +79,41 @@ struct netr_NetworkInfo { struct netr_ChallengeResponse lm; }/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */; -union netr_LogonInfo { - struct netr_PasswordInfo *password;/* [unique,case] */ - struct netr_NetworkInfo *network;/* [unique,case(2)] */ -}/* [public,switch_type(uint16)] */; +struct netr_GenericInfo { + struct netr_IdentityInfo identity_info; + struct lsa_String package_name; + uint32_t length; + uint8_t *data;/* [unique,size_is(length)] */ +}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */; + +enum netr_LogonInfoClass +#ifndef USE_UINT_ENUMS + { + NetlogonInteractiveInformation=1, + NetlogonNetworkInformation=2, + NetlogonServiceInformation=3, + NetlogonGenericInformation=4, + NetlogonInteractiveTransitiveInformation=5, + NetlogonNetworkTransitiveInformation=6, + NetlogonServiceTransitiveInformation=7 +} +#else + { __donnot_use_enum_netr_LogonInfoClass=0x7FFFFFFF} +#define NetlogonInteractiveInformation ( 1 ) +#define NetlogonNetworkInformation ( 2 ) +#define NetlogonServiceInformation ( 3 ) +#define NetlogonGenericInformation ( 4 ) +#define NetlogonInteractiveTransitiveInformation ( 5 ) +#define NetlogonNetworkTransitiveInformation ( 6 ) +#define NetlogonServiceTransitiveInformation ( 7 ) +#endif +; + +union netr_LogonLevel { + struct netr_PasswordInfo *password;/* [unique,case(NetlogonInteractiveInformation)] */ + struct netr_NetworkInfo *network;/* [unique,case(NetlogonNetworkInformation)] */ + struct netr_GenericInfo *generic;/* [unique,case(NetlogonGenericInformation)] */ +}/* [public,switch_type(netr_LogonInfoClass)] */; struct netr_UserSessionKey { uint8_t key[16]; @@ -172,11 +204,36 @@ struct netr_PacInfo { struct lsa_String unknown4; }; +struct netr_GenericInfo2 { + uint32_t length; + uint8_t *data;/* [unique,size_is(length)] */ +}/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */; + +enum netr_ValidationInfoClass +#ifndef USE_UINT_ENUMS + { + NetlogonValidationUasInfo=1, + NetlogonValidationSamInfo=2, + NetlogonValidationSamInfo2=3, + NetlogonValidationGenericInfo2=5, + NetlogonValidationSamInfo4=6 +} +#else + { __donnot_use_enum_netr_ValidationInfoClass=0x7FFFFFFF} +#define NetlogonValidationUasInfo ( 1 ) +#define NetlogonValidationSamInfo ( 2 ) +#define NetlogonValidationSamInfo2 ( 3 ) +#define NetlogonValidationGenericInfo2 ( 5 ) +#define NetlogonValidationSamInfo4 ( 6 ) +#endif +; + union netr_Validation { - struct netr_SamInfo2 *sam2;/* [unique,case(2)] */ - struct netr_SamInfo3 *sam3;/* [unique,case(3)] */ + struct netr_SamInfo2 *sam2;/* [unique,case(NetlogonValidationSamInfo)] */ + struct netr_SamInfo3 *sam3;/* [unique,case(NetlogonValidationSamInfo2)] */ struct netr_PacInfo *pac;/* [unique,case(4)] */ - struct netr_SamInfo6 *sam6;/* [unique,case(6)] */ + struct netr_GenericInfo2 *generic;/* [unique,case(NetlogonValidationGenericInfo2)] */ + struct netr_SamInfo6 *sam6;/* [unique,case(NetlogonValidationSamInfo4)] */ }/* [public,switch_type(uint16)] */; struct netr_Credential { @@ -188,19 +245,6 @@ struct netr_Authenticator { time_t timestamp; }/* [public] */; -enum netr_LogonLevel -#ifndef USE_UINT_ENUMS - { - INTERACTIVE_LOGON_TYPE=1, - NET_LOGON_TYPE=2 -} -#else - { __donnot_use_enum_netr_LogonLevel=0x7FFFFFFF} -#define INTERACTIVE_LOGON_TYPE ( 1 ) -#define NET_LOGON_TYPE ( 2 ) -#endif -; - enum netr_SchannelType; enum netr_SamDatabaseID; @@ -298,7 +342,7 @@ struct netr_DELTA_USER { struct netr_DELTA_DOMAIN { struct lsa_String domain_name; - struct lsa_String comment; + struct lsa_String oem_information; int64_t force_logoff_time; uint16_t min_password_length; uint16_t password_history_length; @@ -736,6 +780,16 @@ struct netr_DsRGetDCNameInfo { const char *client_site_name;/* [unique,charset(UTF16)] */ }/* [public] */; +/* bitmap netr_TrustFlags */ +#define NETR_TRUST_FLAG_IN_FOREST ( 0x00000001 ) +#define NETR_TRUST_FLAG_OUTBOUND ( 0x00000002 ) +#define NETR_TRUST_FLAG_TREEROOT ( 0x00000004 ) +#define NETR_TRUST_FLAG_PRIMARY ( 0x00000008 ) +#define NETR_TRUST_FLAG_NATIVE ( 0x00000010 ) +#define NETR_TRUST_FLAG_INBOUND ( 0x00000020 ) +#define NETR_TRUST_FLAG_MIT_KRB5 ( 0x00000080 ) +#define NETR_TRUST_FLAG_AES ( 0x00000100 ) + struct netr_BinaryString { uint16_t length; uint16_t size; @@ -761,25 +815,57 @@ union netr_DomainQuery { struct netr_DomainQuery1 *query1;/* [unique,case] */ }; +struct netr_trust_extension { + uint32_t length;/* [value(8)] */ + uint32_t dummy;/* [value(0)] */ + uint32_t size;/* [value(8)] */ + uint32_t flags; + uint32_t parent_index; + uint32_t trust_type; + uint32_t trust_attributes; +}; + +struct netr_trust_extension_container { + uint16_t length; + uint16_t size;/* [value(length)] */ + struct netr_trust_extension *info;/* [unique] */ +}; + struct netr_DomainTrustInfo { struct lsa_String domainname; struct lsa_String fulldomainname; struct lsa_String forest; struct GUID guid; struct dom_sid2 *sid;/* [unique] */ - struct netr_BinaryString unknown1[4]; - uint32_t unknown[4]; + struct netr_trust_extension_container trust_extension; + struct lsa_String dummystring[3]; + uint32_t dummy[4]; }; +struct netr_LsaPolicyInfo { + uint32_t policy_size; + uint8_t *policy;/* [unique,size_is(policy_size)] */ +}; + +/* bitmap netr_WorkstationFlags */ +#define NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS ( 0x00000001 ) +#define NETR_WS_FLAG_HANDLES_SPN_UPDATE ( 0x00000002 ) + struct netr_DomainInfo1 { struct netr_DomainTrustInfo domaininfo; uint32_t num_trusts; struct netr_DomainTrustInfo *trusts;/* [unique,size_is(num_trusts)] */ - uint32_t unknown[14]; + struct netr_LsaPolicyInfo lsa_policy; + struct lsa_String dns_hostname; + struct lsa_String dummystring[3]; + uint32_t workstation_flags; + uint32_t supported_enc_types; + uint32_t dummy[2]; }; union netr_DomainInfo { struct netr_DomainInfo1 *info1;/* [unique,case] */ + struct netr_DomainInfo1 *info2;/* [unique,case(2)] */ }; struct netr_CryptPassword { @@ -797,14 +883,6 @@ struct netr_DsRAddress { uint32_t size; }; -/* bitmap netr_TrustFlags */ -#define NETR_TRUST_FLAG_IN_FOREST ( 0x00000001 ) -#define NETR_TRUST_FLAG_OUTBOUND ( 0x00000002 ) -#define NETR_TRUST_FLAG_TREEROOT ( 0x00000004 ) -#define NETR_TRUST_FLAG_PRIMARY ( 0x00000008 ) -#define NETR_TRUST_FLAG_NATIVE ( 0x00000010 ) -#define NETR_TRUST_FLAG_INBOUND ( 0x00000020 ) - enum netr_TrustType #ifndef USE_UINT_ENUMS { @@ -894,8 +972,8 @@ struct netr_LogonSamLogon { const char *server_name;/* [unique,charset(UTF16)] */ const char *computer_name;/* [unique,charset(UTF16)] */ struct netr_Authenticator *credential;/* [unique] */ - enum netr_LogonLevel logon_level; - union netr_LogonInfo *logon;/* [ref,switch_is(logon_level)] */ + enum netr_LogonInfoClass logon_level; + union netr_LogonLevel *logon;/* [ref,switch_is(logon_level)] */ uint16_t validation_level; struct netr_Authenticator *return_authenticator;/* [unique] */ } in; @@ -915,8 +993,8 @@ struct netr_LogonSamLogoff { const char *server_name;/* [unique,charset(UTF16)] */ const char *computer_name;/* [unique,charset(UTF16)] */ struct netr_Authenticator *credential;/* [unique] */ - enum netr_LogonLevel logon_level; - union netr_LogonInfo logon;/* [switch_is(logon_level)] */ + enum netr_LogonInfoClass logon_level; + union netr_LogonLevel logon;/* [switch_is(logon_level)] */ struct netr_Authenticator *return_authenticator;/* [unique] */ } in; @@ -1480,8 +1558,8 @@ struct netr_LogonSamLogonEx { struct { const char *server_name;/* [unique,charset(UTF16)] */ const char *computer_name;/* [unique,charset(UTF16)] */ - enum netr_LogonLevel logon_level; - union netr_LogonInfo *logon;/* [ref,switch_is(logon_level)] */ + enum netr_LogonInfoClass logon_level; + union netr_LogonLevel *logon;/* [ref,switch_is(logon_level)] */ uint16_t validation_level; uint32_t *flags;/* [ref] */ } in; @@ -1582,8 +1660,8 @@ struct netr_LogonSamLogonWithFlags { const char *server_name;/* [unique,charset(UTF16)] */ const char *computer_name;/* [unique,charset(UTF16)] */ struct netr_Authenticator *credential;/* [unique] */ - enum netr_LogonLevel logon_level; - union netr_LogonInfo logon;/* [switch_is(logon_level)] */ + enum netr_LogonInfoClass logon_level; + union netr_LogonLevel logon;/* [switch_is(logon_level)] */ uint16_t validation_level; struct netr_Authenticator *return_authenticator;/* [unique] */ uint32_t *flags;/* [ref] */ diff --git a/source3/librpc/gen_ndr/notify.h b/source3/librpc/gen_ndr/notify.h index c809702e5d..46a7e24e0d 100644 --- a/source3/librpc/gen_ndr/notify.h +++ b/source3/librpc/gen_ndr/notify.h @@ -2,6 +2,7 @@ #include +#include "librpc/gen_ndr/security.h" #ifndef _HEADER_notify #define _HEADER_notify diff --git a/source3/librpc/gen_ndr/ntsvcs.h b/source3/librpc/gen_ndr/ntsvcs.h index 95484e49f5..b56b552ae2 100644 --- a/source3/librpc/gen_ndr/ntsvcs.h +++ b/source3/librpc/gen_ndr/ntsvcs.h @@ -101,6 +101,14 @@ struct PNP_EnumerateSubKeys { struct PNP_GetDeviceList { struct { + const char *filter;/* [unique,charset(UTF16)] */ + uint32_t flags; + uint32_t *length;/* [ref] */ + } in; + + struct { + uint16_t *buffer;/* [ref,length_is(*length),size_is(*length)] */ + uint32_t *length;/* [ref] */ WERROR result; } out; @@ -133,15 +141,15 @@ struct PNP_GetDeviceRegProp { struct { const char *devicepath;/* [ref,charset(UTF16)] */ uint32_t property; - uint32_t unknown3; - uint32_t *unknown1;/* [ref] */ + uint32_t flags; + uint32_t *reg_data_type;/* [ref] */ uint32_t *buffer_size;/* [ref] */ uint32_t *needed;/* [ref] */ } in; struct { uint8_t *buffer;/* [ref,length_is(*buffer_size),size_is(*buffer_size)] */ - uint32_t *unknown1;/* [ref] */ + uint32_t *reg_data_type;/* [ref] */ uint32_t *buffer_size;/* [ref] */ uint32_t *needed;/* [ref] */ WERROR result; diff --git a/source3/librpc/gen_ndr/samr.h b/source3/librpc/gen_ndr/samr.h index 522c6a9cec..62f6bf8de6 100644 --- a/source3/librpc/gen_ndr/samr.h +++ b/source3/librpc/gen_ndr/samr.h @@ -125,9 +125,9 @@ struct samr_DomInfo1 { int64_t min_password_age; }; -struct samr_DomInfo2 { +struct samr_DomGeneralInformation { NTTIME force_logoff_time; - struct lsa_String comment; + struct lsa_String oem_information; struct lsa_String domain_name; struct lsa_String primary; uint64_t sequence_num; @@ -143,8 +143,8 @@ struct samr_DomInfo3 { NTTIME force_logoff_time; }; -struct samr_DomInfo4 { - struct lsa_String comment; +struct samr_DomOEMInformation { + struct lsa_String oem_information; }; struct samr_DomInfo5 { @@ -168,8 +168,8 @@ struct samr_DomInfo9 { uint32_t unknown; }; -struct samr_DomInfo11 { - struct samr_DomInfo2 info2; +struct samr_DomGeneralInformation2 { + struct samr_DomGeneralInformation general; uint64_t lockout_duration; uint64_t lockout_window; uint16_t lockout_threshold; @@ -190,15 +190,15 @@ struct samr_DomInfo13 { union samr_DomainInfo { struct samr_DomInfo1 info1;/* [case] */ - struct samr_DomInfo2 info2;/* [case(2)] */ + struct samr_DomGeneralInformation general;/* [case(2)] */ struct samr_DomInfo3 info3;/* [case(3)] */ - struct samr_DomInfo4 info4;/* [case(4)] */ + struct samr_DomOEMInformation oem;/* [case(4)] */ struct samr_DomInfo5 info5;/* [case(5)] */ struct samr_DomInfo6 info6;/* [case(6)] */ struct samr_DomInfo7 info7;/* [case(7)] */ struct samr_DomInfo8 info8;/* [case(8)] */ struct samr_DomInfo9 info9;/* [case(9)] */ - struct samr_DomInfo11 info11;/* [case(11)] */ + struct samr_DomGeneralInformation2 general2;/* [case(11)] */ struct samr_DomInfo12 info12;/* [case(12)] */ struct samr_DomInfo13 info13;/* [case(13)] */ }/* [switch_type(uint16)] */; diff --git a/source3/librpc/gen_ndr/security.h b/source3/librpc/gen_ndr/security.h index 04655b178e..5b77d76b50 100644 --- a/source3/librpc/gen_ndr/security.h +++ b/source3/librpc/gen_ndr/security.h @@ -59,6 +59,7 @@ #define SEC_ADS_DELETE_TREE ( 0x00000040 ) #define SEC_ADS_LIST_OBJECT ( 0x00000080 ) #define SEC_ADS_CONTROL_ACCESS ( 0x00000100 ) +#define SEC_MASK_INVALID ( 0x0ce0fe00 ) #define SEC_RIGHTS_FILE_READ ( SEC_STD_READ_CONTROL|SEC_STD_SYNCHRONIZE|SEC_FILE_READ_DATA|SEC_FILE_READ_ATTRIBUTE|SEC_FILE_READ_EA ) #define SEC_RIGHTS_FILE_WRITE ( SEC_STD_READ_CONTROL|SEC_STD_SYNCHRONIZE|SEC_FILE_WRITE_DATA|SEC_FILE_WRITE_ATTRIBUTE|SEC_FILE_WRITE_EA|SEC_FILE_APPEND_DATA ) #define SEC_RIGHTS_FILE_EXECUTE ( SEC_STD_SYNCHRONIZE|SEC_STD_READ_CONTROL|SEC_FILE_READ_ATTRIBUTE|SEC_FILE_EXECUTE ) @@ -74,6 +75,7 @@ #define SID_CREATOR_OWNER_DOMAIN ( "S-1-3" ) #define SID_CREATOR_OWNER ( "S-1-3-0" ) #define SID_CREATOR_GROUP ( "S-1-3-1" ) +#define SID_OWNER_RIGHTS ( "S-1-3-4" ) #define NAME_NT_AUTHORITY ( "NT AUTHORITY" ) #define SID_NT_AUTHORITY ( "S-1-5" ) #define SID_NT_DIALUP ( "S-1-5-1" ) @@ -90,9 +92,14 @@ #define SID_NT_TERMINAL_SERVER_USERS ( "S-1-5-13" ) #define SID_NT_REMOTE_INTERACTIVE ( "S-1-5-14" ) #define SID_NT_THIS_ORGANISATION ( "S-1-5-15" ) +#define SID_NT_IUSR ( "S-1-5-17" ) #define SID_NT_SYSTEM ( "S-1-5-18" ) #define SID_NT_LOCAL_SERVICE ( "S-1-5-19" ) #define SID_NT_NETWORK_SERVICE ( "S-1-5-20" ) +#define SID_NT_DIGEST_AUTHENTICATION ( "S-1-5-64-21" ) +#define SID_NT_NTLM_AUTHENTICATION ( "S-1-5-64-10" ) +#define SID_NT_SCHANNEL_AUTHENTICATION ( "S-1-5-64-14" ) +#define SID_NT_OTHER_ORGANISATION ( "S-1-5-1000" ) #define NAME_BUILTIN ( "BUILTIN" ) #define SID_BUILTIN ( "S-1-5-32" ) #define SID_BUILTIN_ADMINISTRATORS ( "S-1-5-32-544" ) @@ -324,4 +331,11 @@ struct security_token { #define SECINFO_PROTECTED_SACL ( 0x40000000 ) #define SECINFO_PROTECTED_DACL ( 0x80000000 ) +/* bitmap kerb_EncTypes */ +#define KERB_ENCTYPE_DES_CBC_CRC ( 0x00000001 ) +#define KERB_ENCTYPE_DES_CBC_MD5 ( 0x00000002 ) +#define KERB_ENCTYPE_RC4_HMAC_MD5 ( 0x00000004 ) +#define KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96 ( 0x00000008 ) +#define KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96 ( 0x00000010 ) + #endif /* _HEADER_security */ diff --git a/source3/librpc/gen_ndr/srv_dfs.c b/source3/librpc/gen_ndr/srv_dfs.c index 54b2184829..d58272084a 100644 --- a/source3/librpc/gen_ndr/srv_dfs.c +++ b/source3/librpc/gen_ndr/srv_dfs.c @@ -27,7 +27,7 @@ static bool api_dfs_GetManagerVersion(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_dfs_GetManagerVersion(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_GetManagerVersion, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_dfs_Add(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -136,7 +136,7 @@ static bool api_dfs_Add(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Add, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -180,7 +180,7 @@ static bool api_dfs_Remove(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -209,7 +209,7 @@ static bool api_dfs_Remove(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Remove, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -253,7 +253,7 @@ static bool api_dfs_SetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -282,7 +282,7 @@ static bool api_dfs_SetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_SetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -326,7 +326,7 @@ static bool api_dfs_GetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -362,7 +362,7 @@ static bool api_dfs_GetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_GetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -406,7 +406,7 @@ static bool api_dfs_Enum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -438,7 +438,7 @@ static bool api_dfs_Enum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Enum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -482,7 +482,7 @@ static bool api_dfs_Rename(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -511,7 +511,7 @@ static bool api_dfs_Rename(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Rename, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -555,7 +555,7 @@ static bool api_dfs_Move(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -584,7 +584,7 @@ static bool api_dfs_Move(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Move, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -628,7 +628,7 @@ static bool api_dfs_ManagerGetConfigInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -657,7 +657,7 @@ static bool api_dfs_ManagerGetConfigInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_ManagerGetConfigInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -701,7 +701,7 @@ static bool api_dfs_ManagerSendSiteInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -730,7 +730,7 @@ static bool api_dfs_ManagerSendSiteInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_ManagerSendSiteInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -774,7 +774,7 @@ static bool api_dfs_AddFtRoot(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -805,7 +805,7 @@ static bool api_dfs_AddFtRoot(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_AddFtRoot, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -849,7 +849,7 @@ static bool api_dfs_RemoveFtRoot(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -880,7 +880,7 @@ static bool api_dfs_RemoveFtRoot(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_RemoveFtRoot, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -924,7 +924,7 @@ static bool api_dfs_AddStdRoot(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -953,7 +953,7 @@ static bool api_dfs_AddStdRoot(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_AddStdRoot, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -997,7 +997,7 @@ static bool api_dfs_RemoveStdRoot(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1026,7 +1026,7 @@ static bool api_dfs_RemoveStdRoot(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_RemoveStdRoot, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1070,7 +1070,7 @@ static bool api_dfs_ManagerInitialize(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1099,7 +1099,7 @@ static bool api_dfs_ManagerInitialize(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_ManagerInitialize, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1143,7 +1143,7 @@ static bool api_dfs_AddStdRootForced(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1172,7 +1172,7 @@ static bool api_dfs_AddStdRootForced(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_AddStdRootForced, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1216,7 +1216,7 @@ static bool api_dfs_GetDcAddress(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1249,7 +1249,7 @@ static bool api_dfs_GetDcAddress(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_GetDcAddress, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1293,7 +1293,7 @@ static bool api_dfs_SetDcAddress(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1322,7 +1322,7 @@ static bool api_dfs_SetDcAddress(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_SetDcAddress, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1366,7 +1366,7 @@ static bool api_dfs_FlushFtTable(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1395,7 +1395,7 @@ static bool api_dfs_FlushFtTable(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_FlushFtTable, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1439,7 +1439,7 @@ static bool api_dfs_Add2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1468,7 +1468,7 @@ static bool api_dfs_Add2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Add2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1512,7 +1512,7 @@ static bool api_dfs_Remove2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1541,7 +1541,7 @@ static bool api_dfs_Remove2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_Remove2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1585,7 +1585,7 @@ static bool api_dfs_EnumEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1617,7 +1617,7 @@ static bool api_dfs_EnumEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_EnumEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1661,7 +1661,7 @@ static bool api_dfs_SetInfo2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1690,7 +1690,7 @@ static bool api_dfs_SetInfo2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dfs_SetInfo2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_dssetup.c b/source3/librpc/gen_ndr/srv_dssetup.c index 79bde30d06..62123b826c 100644 --- a/source3/librpc/gen_ndr/srv_dssetup.c +++ b/source3/librpc/gen_ndr/srv_dssetup.c @@ -27,7 +27,7 @@ static bool api_dssetup_DsRoleGetPrimaryDomainInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_dssetup_DsRoleGetPrimaryDomainInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleGetPrimaryDomainInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_dssetup_DsRoleDnsNameToFlatName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -136,7 +136,7 @@ static bool api_dssetup_DsRoleDnsNameToFlatName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleDnsNameToFlatName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -180,7 +180,7 @@ static bool api_dssetup_DsRoleDcAsDc(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -209,7 +209,7 @@ static bool api_dssetup_DsRoleDcAsDc(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleDcAsDc, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -253,7 +253,7 @@ static bool api_dssetup_DsRoleDcAsReplica(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -282,7 +282,7 @@ static bool api_dssetup_DsRoleDcAsReplica(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleDcAsReplica, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -326,7 +326,7 @@ static bool api_dssetup_DsRoleDemoteDc(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -355,7 +355,7 @@ static bool api_dssetup_DsRoleDemoteDc(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleDemoteDc, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -399,7 +399,7 @@ static bool api_dssetup_DsRoleGetDcOperationProgress(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -428,7 +428,7 @@ static bool api_dssetup_DsRoleGetDcOperationProgress(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleGetDcOperationProgress, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -472,7 +472,7 @@ static bool api_dssetup_DsRoleGetDcOperationResults(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -501,7 +501,7 @@ static bool api_dssetup_DsRoleGetDcOperationResults(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleGetDcOperationResults, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -545,7 +545,7 @@ static bool api_dssetup_DsRoleCancel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -574,7 +574,7 @@ static bool api_dssetup_DsRoleCancel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleCancel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -618,7 +618,7 @@ static bool api_dssetup_DsRoleServerSaveStateForUpgrade(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -647,7 +647,7 @@ static bool api_dssetup_DsRoleServerSaveStateForUpgrade(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleServerSaveStateForUpgrade, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -691,7 +691,7 @@ static bool api_dssetup_DsRoleUpgradeDownlevelServer(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -720,7 +720,7 @@ static bool api_dssetup_DsRoleUpgradeDownlevelServer(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleUpgradeDownlevelServer, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -764,7 +764,7 @@ static bool api_dssetup_DsRoleAbortDownlevelServerUpgrade(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -793,7 +793,7 @@ static bool api_dssetup_DsRoleAbortDownlevelServerUpgrade(pipes_struct *p) NDR_PRINT_OUT_DEBUG(dssetup_DsRoleAbortDownlevelServerUpgrade, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_echo.c b/source3/librpc/gen_ndr/srv_echo.c index b8b38dad13..970398dc71 100644 --- a/source3/librpc/gen_ndr/srv_echo.c +++ b/source3/librpc/gen_ndr/srv_echo.c @@ -27,7 +27,7 @@ static bool api_echo_AddOne(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_echo_AddOne(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_AddOne, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_echo_EchoData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -143,7 +143,7 @@ static bool api_echo_EchoData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_EchoData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -187,7 +187,7 @@ static bool api_echo_SinkData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -216,7 +216,7 @@ static bool api_echo_SinkData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_SinkData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -260,7 +260,7 @@ static bool api_echo_SourceData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -296,7 +296,7 @@ static bool api_echo_SourceData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_SourceData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -340,7 +340,7 @@ static bool api_echo_TestCall(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -376,7 +376,7 @@ static bool api_echo_TestCall(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_TestCall, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -420,7 +420,7 @@ static bool api_echo_TestCall2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -456,7 +456,7 @@ static bool api_echo_TestCall2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_TestCall2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -500,7 +500,7 @@ static bool api_echo_TestSleep(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -529,7 +529,7 @@ static bool api_echo_TestSleep(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_TestSleep, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -573,7 +573,7 @@ static bool api_echo_TestEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -606,7 +606,7 @@ static bool api_echo_TestEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_TestEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -650,7 +650,7 @@ static bool api_echo_TestSurrounding(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -681,7 +681,7 @@ static bool api_echo_TestSurrounding(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_TestSurrounding, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -725,7 +725,7 @@ static bool api_echo_TestDoublePointer(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -754,7 +754,7 @@ static bool api_echo_TestDoublePointer(pipes_struct *p) NDR_PRINT_OUT_DEBUG(echo_TestDoublePointer, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_epmapper.c b/source3/librpc/gen_ndr/srv_epmapper.c index f42598abd4..a31d89b8e8 100644 --- a/source3/librpc/gen_ndr/srv_epmapper.c +++ b/source3/librpc/gen_ndr/srv_epmapper.c @@ -27,7 +27,7 @@ static bool api_epm_Insert(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -56,7 +56,7 @@ static bool api_epm_Insert(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_Insert, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -100,7 +100,7 @@ static bool api_epm_Delete(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -129,7 +129,7 @@ static bool api_epm_Delete(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_Delete, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -173,7 +173,7 @@ static bool api_epm_Lookup(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -216,7 +216,7 @@ static bool api_epm_Lookup(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_Lookup, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -260,7 +260,7 @@ static bool api_epm_Map(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -303,7 +303,7 @@ static bool api_epm_Map(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_Map, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -347,7 +347,7 @@ static bool api_epm_LookupHandleFree(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -378,7 +378,7 @@ static bool api_epm_LookupHandleFree(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_LookupHandleFree, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -422,7 +422,7 @@ static bool api_epm_InqObject(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -451,7 +451,7 @@ static bool api_epm_InqObject(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_InqObject, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -495,7 +495,7 @@ static bool api_epm_MgmtDelete(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -524,7 +524,7 @@ static bool api_epm_MgmtDelete(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_MgmtDelete, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -568,7 +568,7 @@ static bool api_epm_MapAuth(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -597,7 +597,7 @@ static bool api_epm_MapAuth(pipes_struct *p) NDR_PRINT_OUT_DEBUG(epm_MapAuth, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_eventlog.c b/source3/librpc/gen_ndr/srv_eventlog.c index eb3fb1fe6d..b9a4a2e9ed 100644 --- a/source3/librpc/gen_ndr/srv_eventlog.c +++ b/source3/librpc/gen_ndr/srv_eventlog.c @@ -27,7 +27,7 @@ static bool api_eventlog_ClearEventLogW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -56,7 +56,7 @@ static bool api_eventlog_ClearEventLogW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ClearEventLogW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -100,7 +100,7 @@ static bool api_eventlog_BackupEventLogW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -129,7 +129,7 @@ static bool api_eventlog_BackupEventLogW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_BackupEventLogW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -173,7 +173,7 @@ static bool api_eventlog_CloseEventLog(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -204,7 +204,7 @@ static bool api_eventlog_CloseEventLog(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_CloseEventLog, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -248,7 +248,7 @@ static bool api_eventlog_DeregisterEventSource(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -277,7 +277,7 @@ static bool api_eventlog_DeregisterEventSource(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_DeregisterEventSource, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -321,7 +321,7 @@ static bool api_eventlog_GetNumRecords(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -357,7 +357,7 @@ static bool api_eventlog_GetNumRecords(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_GetNumRecords, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -401,7 +401,7 @@ static bool api_eventlog_GetOldestRecord(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -437,7 +437,7 @@ static bool api_eventlog_GetOldestRecord(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_GetOldestRecord, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -481,7 +481,7 @@ static bool api_eventlog_ChangeNotify(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -510,7 +510,7 @@ static bool api_eventlog_ChangeNotify(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ChangeNotify, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -554,7 +554,7 @@ static bool api_eventlog_OpenEventLogW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -590,7 +590,7 @@ static bool api_eventlog_OpenEventLogW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_OpenEventLogW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -634,7 +634,7 @@ static bool api_eventlog_RegisterEventSourceW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -663,7 +663,7 @@ static bool api_eventlog_RegisterEventSourceW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_RegisterEventSourceW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -707,7 +707,7 @@ static bool api_eventlog_OpenBackupEventLogW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -736,7 +736,7 @@ static bool api_eventlog_OpenBackupEventLogW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_OpenBackupEventLogW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -780,7 +780,7 @@ static bool api_eventlog_ReadEventLogW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -828,7 +828,7 @@ static bool api_eventlog_ReadEventLogW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ReadEventLogW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -872,7 +872,7 @@ static bool api_eventlog_ReportEventW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -901,7 +901,7 @@ static bool api_eventlog_ReportEventW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ReportEventW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -945,7 +945,7 @@ static bool api_eventlog_ClearEventLogA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -974,7 +974,7 @@ static bool api_eventlog_ClearEventLogA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ClearEventLogA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1018,7 +1018,7 @@ static bool api_eventlog_BackupEventLogA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1047,7 +1047,7 @@ static bool api_eventlog_BackupEventLogA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_BackupEventLogA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1091,7 +1091,7 @@ static bool api_eventlog_OpenEventLogA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1120,7 +1120,7 @@ static bool api_eventlog_OpenEventLogA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_OpenEventLogA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1164,7 +1164,7 @@ static bool api_eventlog_RegisterEventSourceA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1193,7 +1193,7 @@ static bool api_eventlog_RegisterEventSourceA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_RegisterEventSourceA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1237,7 +1237,7 @@ static bool api_eventlog_OpenBackupEventLogA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1266,7 +1266,7 @@ static bool api_eventlog_OpenBackupEventLogA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_OpenBackupEventLogA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1310,7 +1310,7 @@ static bool api_eventlog_ReadEventLogA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1339,7 +1339,7 @@ static bool api_eventlog_ReadEventLogA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ReadEventLogA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1383,7 +1383,7 @@ static bool api_eventlog_ReportEventA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1412,7 +1412,7 @@ static bool api_eventlog_ReportEventA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_ReportEventA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1456,7 +1456,7 @@ static bool api_eventlog_RegisterClusterSvc(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1485,7 +1485,7 @@ static bool api_eventlog_RegisterClusterSvc(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_RegisterClusterSvc, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1529,7 +1529,7 @@ static bool api_eventlog_DeregisterClusterSvc(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1558,7 +1558,7 @@ static bool api_eventlog_DeregisterClusterSvc(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_DeregisterClusterSvc, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1602,7 +1602,7 @@ static bool api_eventlog_WriteClusterEvents(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1631,7 +1631,7 @@ static bool api_eventlog_WriteClusterEvents(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_WriteClusterEvents, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1675,7 +1675,7 @@ static bool api_eventlog_GetLogIntormation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1704,7 +1704,7 @@ static bool api_eventlog_GetLogIntormation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_GetLogIntormation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1748,7 +1748,7 @@ static bool api_eventlog_FlushEventLog(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1777,7 +1777,7 @@ static bool api_eventlog_FlushEventLog(pipes_struct *p) NDR_PRINT_OUT_DEBUG(eventlog_FlushEventLog, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_initshutdown.c b/source3/librpc/gen_ndr/srv_initshutdown.c index 00a89661b5..51098074ac 100644 --- a/source3/librpc/gen_ndr/srv_initshutdown.c +++ b/source3/librpc/gen_ndr/srv_initshutdown.c @@ -27,7 +27,7 @@ static bool api_initshutdown_Init(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -56,7 +56,7 @@ static bool api_initshutdown_Init(pipes_struct *p) NDR_PRINT_OUT_DEBUG(initshutdown_Init, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -100,7 +100,7 @@ static bool api_initshutdown_Abort(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -129,7 +129,7 @@ static bool api_initshutdown_Abort(pipes_struct *p) NDR_PRINT_OUT_DEBUG(initshutdown_Abort, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -173,7 +173,7 @@ static bool api_initshutdown_InitEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -202,7 +202,7 @@ static bool api_initshutdown_InitEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(initshutdown_InitEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index 41d1c9716c..b0893623a8 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -27,7 +27,7 @@ static bool api_lsa_Close(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -58,7 +58,7 @@ static bool api_lsa_Close(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_Close, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -102,7 +102,7 @@ static bool api_lsa_Delete(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -131,7 +131,7 @@ static bool api_lsa_Delete(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_Delete, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -175,7 +175,7 @@ static bool api_lsa_EnumPrivs(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -212,7 +212,7 @@ static bool api_lsa_EnumPrivs(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumPrivs, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -256,7 +256,7 @@ static bool api_lsa_QuerySecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -292,7 +292,7 @@ static bool api_lsa_QuerySecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QuerySecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -336,7 +336,7 @@ static bool api_lsa_SetSecObj(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -365,7 +365,7 @@ static bool api_lsa_SetSecObj(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetSecObj, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -409,7 +409,7 @@ static bool api_lsa_ChangePassword(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -438,7 +438,7 @@ static bool api_lsa_ChangePassword(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_ChangePassword, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -482,7 +482,7 @@ static bool api_lsa_OpenPolicy(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -518,7 +518,7 @@ static bool api_lsa_OpenPolicy(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_OpenPolicy, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -562,7 +562,7 @@ static bool api_lsa_QueryInfoPolicy(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -598,7 +598,7 @@ static bool api_lsa_QueryInfoPolicy(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QueryInfoPolicy, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -642,7 +642,7 @@ static bool api_lsa_SetInfoPolicy(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -671,7 +671,7 @@ static bool api_lsa_SetInfoPolicy(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetInfoPolicy, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -715,7 +715,7 @@ static bool api_lsa_ClearAuditLog(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -744,7 +744,7 @@ static bool api_lsa_ClearAuditLog(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_ClearAuditLog, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -788,7 +788,7 @@ static bool api_lsa_CreateAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -824,7 +824,7 @@ static bool api_lsa_CreateAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CreateAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -868,7 +868,7 @@ static bool api_lsa_EnumAccounts(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -905,7 +905,7 @@ static bool api_lsa_EnumAccounts(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumAccounts, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -949,7 +949,7 @@ static bool api_lsa_CreateTrustedDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -985,7 +985,7 @@ static bool api_lsa_CreateTrustedDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CreateTrustedDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1029,7 +1029,7 @@ static bool api_lsa_EnumTrustDom(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1066,7 +1066,7 @@ static bool api_lsa_EnumTrustDom(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumTrustDom, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1110,7 +1110,7 @@ static bool api_lsa_LookupNames(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1148,7 +1148,7 @@ static bool api_lsa_LookupNames(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupNames, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1192,7 +1192,7 @@ static bool api_lsa_LookupSids(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1230,7 +1230,7 @@ static bool api_lsa_LookupSids(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupSids, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1274,7 +1274,7 @@ static bool api_lsa_CreateSecret(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1310,7 +1310,7 @@ static bool api_lsa_CreateSecret(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CreateSecret, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1354,7 +1354,7 @@ static bool api_lsa_OpenAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1390,7 +1390,7 @@ static bool api_lsa_OpenAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_OpenAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1434,7 +1434,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1470,7 +1470,7 @@ static bool api_lsa_EnumPrivsAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumPrivsAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1514,7 +1514,7 @@ static bool api_lsa_AddPrivilegesToAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1543,7 +1543,7 @@ static bool api_lsa_AddPrivilegesToAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_AddPrivilegesToAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1587,7 +1587,7 @@ static bool api_lsa_RemovePrivilegesFromAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1616,7 +1616,7 @@ static bool api_lsa_RemovePrivilegesFromAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_RemovePrivilegesFromAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1660,7 +1660,7 @@ static bool api_lsa_GetQuotasForAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1689,7 +1689,7 @@ static bool api_lsa_GetQuotasForAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_GetQuotasForAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1733,7 +1733,7 @@ static bool api_lsa_SetQuotasForAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1762,7 +1762,7 @@ static bool api_lsa_SetQuotasForAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetQuotasForAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1806,7 +1806,7 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1842,7 +1842,7 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_GetSystemAccessAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1886,7 +1886,7 @@ static bool api_lsa_SetSystemAccessAccount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1915,7 +1915,7 @@ static bool api_lsa_SetSystemAccessAccount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetSystemAccessAccount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1959,7 +1959,7 @@ static bool api_lsa_OpenTrustedDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1995,7 +1995,7 @@ static bool api_lsa_OpenTrustedDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_OpenTrustedDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2039,7 +2039,7 @@ static bool api_lsa_QueryTrustedDomainInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2075,7 +2075,7 @@ static bool api_lsa_QueryTrustedDomainInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QueryTrustedDomainInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2119,7 +2119,7 @@ static bool api_lsa_SetInformationTrustedDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2148,7 +2148,7 @@ static bool api_lsa_SetInformationTrustedDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetInformationTrustedDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2192,7 +2192,7 @@ static bool api_lsa_OpenSecret(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2228,7 +2228,7 @@ static bool api_lsa_OpenSecret(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_OpenSecret, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2272,7 +2272,7 @@ static bool api_lsa_SetSecret(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2301,7 +2301,7 @@ static bool api_lsa_SetSecret(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetSecret, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2345,7 +2345,7 @@ static bool api_lsa_QuerySecret(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2379,7 +2379,7 @@ static bool api_lsa_QuerySecret(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QuerySecret, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2423,7 +2423,7 @@ static bool api_lsa_LookupPrivValue(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2459,7 +2459,7 @@ static bool api_lsa_LookupPrivValue(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupPrivValue, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2503,7 +2503,7 @@ static bool api_lsa_LookupPrivName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2539,7 +2539,7 @@ static bool api_lsa_LookupPrivName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupPrivName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2583,7 +2583,7 @@ static bool api_lsa_LookupPrivDisplayName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2625,7 +2625,7 @@ static bool api_lsa_LookupPrivDisplayName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupPrivDisplayName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2669,7 +2669,7 @@ static bool api_lsa_DeleteObject(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2700,7 +2700,7 @@ static bool api_lsa_DeleteObject(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_DeleteObject, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2744,7 +2744,7 @@ static bool api_lsa_EnumAccountsWithUserRight(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2780,7 +2780,7 @@ static bool api_lsa_EnumAccountsWithUserRight(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumAccountsWithUserRight, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2824,7 +2824,7 @@ static bool api_lsa_EnumAccountRights(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2860,7 +2860,7 @@ static bool api_lsa_EnumAccountRights(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumAccountRights, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2904,7 +2904,7 @@ static bool api_lsa_AddAccountRights(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2933,7 +2933,7 @@ static bool api_lsa_AddAccountRights(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_AddAccountRights, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2977,7 +2977,7 @@ static bool api_lsa_RemoveAccountRights(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3006,7 +3006,7 @@ static bool api_lsa_RemoveAccountRights(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_RemoveAccountRights, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3050,7 +3050,7 @@ static bool api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3086,7 +3086,7 @@ static bool api_lsa_QueryTrustedDomainInfoBySid(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QueryTrustedDomainInfoBySid, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3130,7 +3130,7 @@ static bool api_lsa_SetTrustedDomainInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3159,7 +3159,7 @@ static bool api_lsa_SetTrustedDomainInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetTrustedDomainInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3203,7 +3203,7 @@ static bool api_lsa_DeleteTrustedDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3232,7 +3232,7 @@ static bool api_lsa_DeleteTrustedDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_DeleteTrustedDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3276,7 +3276,7 @@ static bool api_lsa_StorePrivateData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3305,7 +3305,7 @@ static bool api_lsa_StorePrivateData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_StorePrivateData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3349,7 +3349,7 @@ static bool api_lsa_RetrievePrivateData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3378,7 +3378,7 @@ static bool api_lsa_RetrievePrivateData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_RetrievePrivateData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3422,7 +3422,7 @@ static bool api_lsa_OpenPolicy2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3458,7 +3458,7 @@ static bool api_lsa_OpenPolicy2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_OpenPolicy2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3502,7 +3502,7 @@ static bool api_lsa_GetUserName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3534,7 +3534,7 @@ static bool api_lsa_GetUserName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_GetUserName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3578,7 +3578,7 @@ static bool api_lsa_QueryInfoPolicy2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3614,7 +3614,7 @@ static bool api_lsa_QueryInfoPolicy2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QueryInfoPolicy2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3658,7 +3658,7 @@ static bool api_lsa_SetInfoPolicy2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3687,7 +3687,7 @@ static bool api_lsa_SetInfoPolicy2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetInfoPolicy2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3731,7 +3731,7 @@ static bool api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3767,7 +3767,7 @@ static bool api_lsa_QueryTrustedDomainInfoByName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QueryTrustedDomainInfoByName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3811,7 +3811,7 @@ static bool api_lsa_SetTrustedDomainInfoByName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3840,7 +3840,7 @@ static bool api_lsa_SetTrustedDomainInfoByName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetTrustedDomainInfoByName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3884,7 +3884,7 @@ static bool api_lsa_EnumTrustedDomainsEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3921,7 +3921,7 @@ static bool api_lsa_EnumTrustedDomainsEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_EnumTrustedDomainsEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3965,7 +3965,7 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3982,6 +3982,13 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p) NDR_PRINT_IN_DEBUG(lsa_CreateTrustedDomainEx, r); } + ZERO_STRUCT(r->out); + r->out.trustdom_handle = talloc_zero(r, struct policy_handle); + if (r->out.trustdom_handle == NULL) { + talloc_free(r); + return false; + } + r->out.result = _lsa_CreateTrustedDomainEx(p, r); if (p->rng_fault_state) { @@ -3994,7 +4001,7 @@ static bool api_lsa_CreateTrustedDomainEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CreateTrustedDomainEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4038,7 +4045,7 @@ static bool api_lsa_CloseTrustedDomainEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4069,7 +4076,7 @@ static bool api_lsa_CloseTrustedDomainEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CloseTrustedDomainEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4113,7 +4120,7 @@ static bool api_lsa_QueryDomainInformationPolicy(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4149,7 +4156,7 @@ static bool api_lsa_QueryDomainInformationPolicy(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_QueryDomainInformationPolicy, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4193,7 +4200,7 @@ static bool api_lsa_SetDomainInformationPolicy(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4222,7 +4229,7 @@ static bool api_lsa_SetDomainInformationPolicy(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_SetDomainInformationPolicy, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4266,7 +4273,7 @@ static bool api_lsa_OpenTrustedDomainByName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4302,7 +4309,7 @@ static bool api_lsa_OpenTrustedDomainByName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_OpenTrustedDomainByName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4346,7 +4353,7 @@ static bool api_lsa_TestCall(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4375,7 +4382,7 @@ static bool api_lsa_TestCall(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_TestCall, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4419,7 +4426,7 @@ static bool api_lsa_LookupSids2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4457,7 +4464,7 @@ static bool api_lsa_LookupSids2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupSids2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4501,7 +4508,7 @@ static bool api_lsa_LookupNames2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4539,7 +4546,7 @@ static bool api_lsa_LookupNames2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupNames2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4583,7 +4590,7 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4600,6 +4607,13 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p) NDR_PRINT_IN_DEBUG(lsa_CreateTrustedDomainEx2, r); } + ZERO_STRUCT(r->out); + r->out.trustdom_handle = talloc_zero(r, struct policy_handle); + if (r->out.trustdom_handle == NULL) { + talloc_free(r); + return false; + } + r->out.result = _lsa_CreateTrustedDomainEx2(p, r); if (p->rng_fault_state) { @@ -4612,7 +4626,7 @@ static bool api_lsa_CreateTrustedDomainEx2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CreateTrustedDomainEx2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4656,7 +4670,7 @@ static bool api_lsa_CREDRWRITE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4685,7 +4699,7 @@ static bool api_lsa_CREDRWRITE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRWRITE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4729,7 +4743,7 @@ static bool api_lsa_CREDRREAD(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4758,7 +4772,7 @@ static bool api_lsa_CREDRREAD(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRREAD, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4802,7 +4816,7 @@ static bool api_lsa_CREDRENUMERATE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4831,7 +4845,7 @@ static bool api_lsa_CREDRENUMERATE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRENUMERATE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4875,7 +4889,7 @@ static bool api_lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4904,7 +4918,7 @@ static bool api_lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRWRITEDOMAINCREDENTIALS, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4948,7 +4962,7 @@ static bool api_lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4977,7 +4991,7 @@ static bool api_lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRREADDOMAINCREDENTIALS, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5021,7 +5035,7 @@ static bool api_lsa_CREDRDELETE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5050,7 +5064,7 @@ static bool api_lsa_CREDRDELETE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRDELETE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5094,7 +5108,7 @@ static bool api_lsa_CREDRGETTARGETINFO(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5123,7 +5137,7 @@ static bool api_lsa_CREDRGETTARGETINFO(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRGETTARGETINFO, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5167,7 +5181,7 @@ static bool api_lsa_CREDRPROFILELOADED(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5196,7 +5210,7 @@ static bool api_lsa_CREDRPROFILELOADED(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRPROFILELOADED, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5240,7 +5254,7 @@ static bool api_lsa_LookupNames3(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5278,7 +5292,7 @@ static bool api_lsa_LookupNames3(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupNames3, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5322,7 +5336,7 @@ static bool api_lsa_CREDRGETSESSIONTYPES(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5351,7 +5365,7 @@ static bool api_lsa_CREDRGETSESSIONTYPES(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRGETSESSIONTYPES, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5395,7 +5409,7 @@ static bool api_lsa_LSARREGISTERAUDITEVENT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5424,7 +5438,7 @@ static bool api_lsa_LSARREGISTERAUDITEVENT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARREGISTERAUDITEVENT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5468,7 +5482,7 @@ static bool api_lsa_LSARGENAUDITEVENT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5497,7 +5511,7 @@ static bool api_lsa_LSARGENAUDITEVENT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARGENAUDITEVENT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5541,7 +5555,7 @@ static bool api_lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5570,7 +5584,7 @@ static bool api_lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARUNREGISTERAUDITEVENT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5614,7 +5628,7 @@ static bool api_lsa_lsaRQueryForestTrustInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5650,7 +5664,7 @@ static bool api_lsa_lsaRQueryForestTrustInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_lsaRQueryForestTrustInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5694,7 +5708,7 @@ static bool api_lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5723,7 +5737,7 @@ static bool api_lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARSETFORESTTRUSTINFORMATION, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5767,7 +5781,7 @@ static bool api_lsa_CREDRRENAME(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5796,7 +5810,7 @@ static bool api_lsa_CREDRRENAME(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_CREDRRENAME, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5840,7 +5854,7 @@ static bool api_lsa_LookupSids3(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5878,7 +5892,7 @@ static bool api_lsa_LookupSids3(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupSids3, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5922,7 +5936,7 @@ static bool api_lsa_LookupNames4(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5960,7 +5974,7 @@ static bool api_lsa_LookupNames4(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LookupNames4, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -6004,7 +6018,7 @@ static bool api_lsa_LSAROPENPOLICYSCE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -6033,7 +6047,7 @@ static bool api_lsa_LSAROPENPOLICYSCE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSAROPENPOLICYSCE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -6077,7 +6091,7 @@ static bool api_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -6106,7 +6120,7 @@ static bool api_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARADTREGISTERSECURITYEVENTSOURCE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -6150,7 +6164,7 @@ static bool api_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -6179,7 +6193,7 @@ static bool api_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -6223,7 +6237,7 @@ static bool api_lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -6252,7 +6266,7 @@ static bool api_lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(lsa_LSARADTREPORTSECURITYEVENT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_netlogon.c b/source3/librpc/gen_ndr/srv_netlogon.c index 154ef71d40..c14f682c1c 100644 --- a/source3/librpc/gen_ndr/srv_netlogon.c +++ b/source3/librpc/gen_ndr/srv_netlogon.c @@ -27,7 +27,7 @@ static bool api_netr_LogonUasLogon(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_netr_LogonUasLogon(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonUasLogon, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_netr_LogonUasLogoff(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -143,7 +143,7 @@ static bool api_netr_LogonUasLogoff(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonUasLogoff, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -187,7 +187,7 @@ static bool api_netr_LogonSamLogon(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -230,7 +230,7 @@ static bool api_netr_LogonSamLogon(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonSamLogon, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -274,7 +274,7 @@ static bool api_netr_LogonSamLogoff(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -305,7 +305,7 @@ static bool api_netr_LogonSamLogoff(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonSamLogoff, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -349,7 +349,7 @@ static bool api_netr_ServerReqChallenge(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -385,7 +385,7 @@ static bool api_netr_ServerReqChallenge(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerReqChallenge, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -429,7 +429,7 @@ static bool api_netr_ServerAuthenticate(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -465,7 +465,7 @@ static bool api_netr_ServerAuthenticate(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerAuthenticate, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -509,7 +509,7 @@ static bool api_netr_ServerPasswordSet(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -545,7 +545,7 @@ static bool api_netr_ServerPasswordSet(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerPasswordSet, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -589,7 +589,7 @@ static bool api_netr_DatabaseDeltas(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -627,7 +627,7 @@ static bool api_netr_DatabaseDeltas(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DatabaseDeltas, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -671,7 +671,7 @@ static bool api_netr_DatabaseSync(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -709,7 +709,7 @@ static bool api_netr_DatabaseSync(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DatabaseSync, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -753,7 +753,7 @@ static bool api_netr_AccountDeltas(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -808,7 +808,7 @@ static bool api_netr_AccountDeltas(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_AccountDeltas, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -852,7 +852,7 @@ static bool api_netr_AccountSync(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -908,7 +908,7 @@ static bool api_netr_AccountSync(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_AccountSync, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -952,7 +952,7 @@ static bool api_netr_GetDcName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -988,7 +988,7 @@ static bool api_netr_GetDcName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_GetDcName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1032,7 +1032,7 @@ static bool api_netr_LogonControl(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1068,7 +1068,7 @@ static bool api_netr_LogonControl(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonControl, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1112,7 +1112,7 @@ static bool api_netr_GetAnyDCName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1148,7 +1148,7 @@ static bool api_netr_GetAnyDCName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_GetAnyDCName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1192,7 +1192,7 @@ static bool api_netr_LogonControl2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1228,7 +1228,7 @@ static bool api_netr_LogonControl2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonControl2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1272,7 +1272,7 @@ static bool api_netr_ServerAuthenticate2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1309,7 +1309,7 @@ static bool api_netr_ServerAuthenticate2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerAuthenticate2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1353,7 +1353,7 @@ static bool api_netr_DatabaseSync2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1391,7 +1391,7 @@ static bool api_netr_DatabaseSync2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DatabaseSync2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1435,7 +1435,7 @@ static bool api_netr_DatabaseRedo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1472,7 +1472,7 @@ static bool api_netr_DatabaseRedo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DatabaseRedo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1516,7 +1516,7 @@ static bool api_netr_LogonControl2Ex(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1552,7 +1552,7 @@ static bool api_netr_LogonControl2Ex(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonControl2Ex, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1596,7 +1596,7 @@ static bool api_netr_NetrEnumerateTrustedDomains(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1632,7 +1632,7 @@ static bool api_netr_NetrEnumerateTrustedDomains(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NetrEnumerateTrustedDomains, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1676,7 +1676,7 @@ static bool api_netr_DsRGetDCName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1712,7 +1712,7 @@ static bool api_netr_DsRGetDCName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRGetDCName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1756,7 +1756,7 @@ static bool api_netr_NETRLOGONDUMMYROUTINE1(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1785,7 +1785,7 @@ static bool api_netr_NETRLOGONDUMMYROUTINE1(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRLOGONDUMMYROUTINE1, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1829,7 +1829,7 @@ static bool api_netr_NETRLOGONSETSERVICEBITS(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1858,7 +1858,7 @@ static bool api_netr_NETRLOGONSETSERVICEBITS(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRLOGONSETSERVICEBITS, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1902,7 +1902,7 @@ static bool api_netr_LogonGetTrustRid(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1938,7 +1938,7 @@ static bool api_netr_LogonGetTrustRid(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonGetTrustRid, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1982,7 +1982,7 @@ static bool api_netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2011,7 +2011,7 @@ static bool api_netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRLOGONCOMPUTESERVERDIGEST, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2055,7 +2055,7 @@ static bool api_netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2084,7 +2084,7 @@ static bool api_netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRLOGONCOMPUTECLIENTDIGEST, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2128,7 +2128,7 @@ static bool api_netr_ServerAuthenticate3(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2166,7 +2166,7 @@ static bool api_netr_ServerAuthenticate3(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerAuthenticate3, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2210,7 +2210,7 @@ static bool api_netr_DsRGetDCNameEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2246,7 +2246,7 @@ static bool api_netr_DsRGetDCNameEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRGetDCNameEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2290,7 +2290,7 @@ static bool api_netr_DsRGetSiteName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2326,7 +2326,7 @@ static bool api_netr_DsRGetSiteName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRGetSiteName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2370,7 +2370,7 @@ static bool api_netr_LogonGetDomainInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2407,7 +2407,7 @@ static bool api_netr_LogonGetDomainInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonGetDomainInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2451,7 +2451,7 @@ static bool api_netr_ServerPasswordSet2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2487,7 +2487,7 @@ static bool api_netr_ServerPasswordSet2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerPasswordSet2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2531,7 +2531,7 @@ static bool api_netr_ServerPasswordGet(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2573,7 +2573,7 @@ static bool api_netr_ServerPasswordGet(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerPasswordGet, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2617,7 +2617,7 @@ static bool api_netr_NETRLOGONSENDTOSAM(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2646,7 +2646,7 @@ static bool api_netr_NETRLOGONSENDTOSAM(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRLOGONSENDTOSAM, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2690,7 +2690,7 @@ static bool api_netr_DsRAddressToSitenamesW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2726,7 +2726,7 @@ static bool api_netr_DsRAddressToSitenamesW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRAddressToSitenamesW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2770,7 +2770,7 @@ static bool api_netr_DsRGetDCNameEx2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2806,7 +2806,7 @@ static bool api_netr_DsRGetDCNameEx2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRGetDCNameEx2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2850,7 +2850,7 @@ static bool api_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2879,7 +2879,7 @@ static bool api_netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2923,7 +2923,7 @@ static bool api_netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2959,7 +2959,7 @@ static bool api_netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NetrEnumerateTrustedDomainsEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3003,7 +3003,7 @@ static bool api_netr_DsRAddressToSitenamesExW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3039,7 +3039,7 @@ static bool api_netr_DsRAddressToSitenamesExW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRAddressToSitenamesExW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3083,7 +3083,7 @@ static bool api_netr_DsrGetDcSiteCoverageW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3119,7 +3119,7 @@ static bool api_netr_DsrGetDcSiteCoverageW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsrGetDcSiteCoverageW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3163,7 +3163,7 @@ static bool api_netr_LogonSamLogonEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3206,7 +3206,7 @@ static bool api_netr_LogonSamLogonEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonSamLogonEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3250,7 +3250,7 @@ static bool api_netr_DsrEnumerateDomainTrusts(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3286,7 +3286,7 @@ static bool api_netr_DsrEnumerateDomainTrusts(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsrEnumerateDomainTrusts, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3330,7 +3330,7 @@ static bool api_netr_DsrDeregisterDNSHostRecords(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3359,7 +3359,7 @@ static bool api_netr_DsrDeregisterDNSHostRecords(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsrDeregisterDNSHostRecords, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3403,7 +3403,7 @@ static bool api_netr_ServerTrustPasswordsGet(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3451,7 +3451,7 @@ static bool api_netr_ServerTrustPasswordsGet(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_ServerTrustPasswordsGet, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3495,7 +3495,7 @@ static bool api_netr_DsRGetForestTrustInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3531,7 +3531,7 @@ static bool api_netr_DsRGetForestTrustInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_DsRGetForestTrustInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3575,7 +3575,7 @@ static bool api_netr_GetForestTrustInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3617,7 +3617,7 @@ static bool api_netr_GetForestTrustInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_GetForestTrustInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3661,7 +3661,7 @@ static bool api_netr_LogonSamLogonWithFlags(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3705,7 +3705,7 @@ static bool api_netr_LogonSamLogonWithFlags(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_LogonSamLogonWithFlags, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3749,7 +3749,7 @@ static bool api_netr_NETRSERVERGETTRUSTINFO(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3778,7 +3778,7 @@ static bool api_netr_NETRSERVERGETTRUSTINFO(pipes_struct *p) NDR_PRINT_OUT_DEBUG(netr_NETRSERVERGETTRUSTINFO, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_ntsvcs.c b/source3/librpc/gen_ndr/srv_ntsvcs.c index d21e86db6e..87f5d51695 100644 --- a/source3/librpc/gen_ndr/srv_ntsvcs.c +++ b/source3/librpc/gen_ndr/srv_ntsvcs.c @@ -27,7 +27,7 @@ static bool api_PNP_Disconnect(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -56,7 +56,7 @@ static bool api_PNP_Disconnect(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_Disconnect, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -100,7 +100,7 @@ static bool api_PNP_Connect(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -129,7 +129,7 @@ static bool api_PNP_Connect(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_Connect, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -173,7 +173,7 @@ static bool api_PNP_GetVersion(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -209,7 +209,7 @@ static bool api_PNP_GetVersion(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetVersion, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -253,7 +253,7 @@ static bool api_PNP_GetGlobalState(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -282,7 +282,7 @@ static bool api_PNP_GetGlobalState(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetGlobalState, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -326,7 +326,7 @@ static bool api_PNP_InitDetection(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -355,7 +355,7 @@ static bool api_PNP_InitDetection(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_InitDetection, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -399,7 +399,7 @@ static bool api_PNP_ReportLogOn(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -428,7 +428,7 @@ static bool api_PNP_ReportLogOn(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_ReportLogOn, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -472,7 +472,7 @@ static bool api_PNP_ValidateDeviceInstance(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -501,7 +501,7 @@ static bool api_PNP_ValidateDeviceInstance(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_ValidateDeviceInstance, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -545,7 +545,7 @@ static bool api_PNP_GetRootDeviceInstance(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -574,7 +574,7 @@ static bool api_PNP_GetRootDeviceInstance(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetRootDeviceInstance, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -618,7 +618,7 @@ static bool api_PNP_GetRelatedDeviceInstance(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -647,7 +647,7 @@ static bool api_PNP_GetRelatedDeviceInstance(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetRelatedDeviceInstance, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -691,7 +691,7 @@ static bool api_PNP_EnumerateSubKeys(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -720,7 +720,7 @@ static bool api_PNP_EnumerateSubKeys(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_EnumerateSubKeys, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -764,7 +764,7 @@ static bool api_PNP_GetDeviceList(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -781,6 +781,14 @@ static bool api_PNP_GetDeviceList(pipes_struct *p) NDR_PRINT_IN_DEBUG(PNP_GetDeviceList, r); } + ZERO_STRUCT(r->out); + r->out.buffer = talloc_zero_array(r, uint16_t, *r->out.length); + if (r->out.buffer == NULL) { + talloc_free(r); + return false; + } + + r->out.length = r->in.length; r->out.result = _PNP_GetDeviceList(p, r); if (p->rng_fault_state) { @@ -793,7 +801,7 @@ static bool api_PNP_GetDeviceList(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetDeviceList, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -837,7 +845,7 @@ static bool api_PNP_GetDeviceListSize(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -873,7 +881,7 @@ static bool api_PNP_GetDeviceListSize(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetDeviceListSize, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -917,7 +925,7 @@ static bool api_PNP_GetDepth(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -946,7 +954,7 @@ static bool api_PNP_GetDepth(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetDepth, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -990,7 +998,7 @@ static bool api_PNP_GetDeviceRegProp(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1008,7 +1016,7 @@ static bool api_PNP_GetDeviceRegProp(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.unknown1 = r->in.unknown1; + r->out.reg_data_type = r->in.reg_data_type; r->out.buffer = talloc_zero_array(r, uint8_t, *r->out.buffer_size); if (r->out.buffer == NULL) { talloc_free(r); @@ -1029,7 +1037,7 @@ static bool api_PNP_GetDeviceRegProp(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetDeviceRegProp, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1073,7 +1081,7 @@ static bool api_PNP_SetDeviceRegProp(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1102,7 +1110,7 @@ static bool api_PNP_SetDeviceRegProp(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_SetDeviceRegProp, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1146,7 +1154,7 @@ static bool api_PNP_GetClassInstance(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1175,7 +1183,7 @@ static bool api_PNP_GetClassInstance(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetClassInstance, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1219,7 +1227,7 @@ static bool api_PNP_CreateKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1248,7 +1256,7 @@ static bool api_PNP_CreateKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_CreateKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1292,7 +1300,7 @@ static bool api_PNP_DeleteRegistryKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1321,7 +1329,7 @@ static bool api_PNP_DeleteRegistryKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_DeleteRegistryKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1365,7 +1373,7 @@ static bool api_PNP_GetClassCount(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1394,7 +1402,7 @@ static bool api_PNP_GetClassCount(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetClassCount, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1438,7 +1446,7 @@ static bool api_PNP_GetClassName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1467,7 +1475,7 @@ static bool api_PNP_GetClassName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetClassName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1511,7 +1519,7 @@ static bool api_PNP_DeleteClassKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1540,7 +1548,7 @@ static bool api_PNP_DeleteClassKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_DeleteClassKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1584,7 +1592,7 @@ static bool api_PNP_GetInterfaceDeviceAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1613,7 +1621,7 @@ static bool api_PNP_GetInterfaceDeviceAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1657,7 +1665,7 @@ static bool api_PNP_GetInterfaceDeviceList(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1686,7 +1694,7 @@ static bool api_PNP_GetInterfaceDeviceList(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceList, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1730,7 +1738,7 @@ static bool api_PNP_GetInterfaceDeviceListSize(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1759,7 +1767,7 @@ static bool api_PNP_GetInterfaceDeviceListSize(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetInterfaceDeviceListSize, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1803,7 +1811,7 @@ static bool api_PNP_RegisterDeviceClassAssociation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1832,7 +1840,7 @@ static bool api_PNP_RegisterDeviceClassAssociation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_RegisterDeviceClassAssociation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1876,7 +1884,7 @@ static bool api_PNP_UnregisterDeviceClassAssociation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1905,7 +1913,7 @@ static bool api_PNP_UnregisterDeviceClassAssociation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_UnregisterDeviceClassAssociation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1949,7 +1957,7 @@ static bool api_PNP_GetClassRegProp(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1978,7 +1986,7 @@ static bool api_PNP_GetClassRegProp(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetClassRegProp, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2022,7 +2030,7 @@ static bool api_PNP_SetClassRegProp(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2051,7 +2059,7 @@ static bool api_PNP_SetClassRegProp(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_SetClassRegProp, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2095,7 +2103,7 @@ static bool api_PNP_CreateDevInst(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2124,7 +2132,7 @@ static bool api_PNP_CreateDevInst(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_CreateDevInst, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2168,7 +2176,7 @@ static bool api_PNP_DeviceInstanceAction(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2197,7 +2205,7 @@ static bool api_PNP_DeviceInstanceAction(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_DeviceInstanceAction, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2241,7 +2249,7 @@ static bool api_PNP_GetDeviceStatus(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2270,7 +2278,7 @@ static bool api_PNP_GetDeviceStatus(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetDeviceStatus, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2314,7 +2322,7 @@ static bool api_PNP_SetDeviceProblem(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2343,7 +2351,7 @@ static bool api_PNP_SetDeviceProblem(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_SetDeviceProblem, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2387,7 +2395,7 @@ static bool api_PNP_DisableDevInst(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2416,7 +2424,7 @@ static bool api_PNP_DisableDevInst(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_DisableDevInst, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2460,7 +2468,7 @@ static bool api_PNP_UninstallDevInst(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2489,7 +2497,7 @@ static bool api_PNP_UninstallDevInst(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_UninstallDevInst, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2533,7 +2541,7 @@ static bool api_PNP_AddID(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2562,7 +2570,7 @@ static bool api_PNP_AddID(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_AddID, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2606,7 +2614,7 @@ static bool api_PNP_RegisterDriver(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2635,7 +2643,7 @@ static bool api_PNP_RegisterDriver(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_RegisterDriver, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2679,7 +2687,7 @@ static bool api_PNP_QueryRemove(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2708,7 +2716,7 @@ static bool api_PNP_QueryRemove(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_QueryRemove, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2752,7 +2760,7 @@ static bool api_PNP_RequestDeviceEject(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2781,7 +2789,7 @@ static bool api_PNP_RequestDeviceEject(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_RequestDeviceEject, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2825,7 +2833,7 @@ static bool api_PNP_IsDockStationPresent(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2854,7 +2862,7 @@ static bool api_PNP_IsDockStationPresent(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_IsDockStationPresent, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2898,7 +2906,7 @@ static bool api_PNP_RequestEjectPC(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2927,7 +2935,7 @@ static bool api_PNP_RequestEjectPC(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_RequestEjectPC, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2971,7 +2979,7 @@ static bool api_PNP_HwProfFlags(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3009,7 +3017,7 @@ static bool api_PNP_HwProfFlags(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_HwProfFlags, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3053,7 +3061,7 @@ static bool api_PNP_GetHwProfInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3084,7 +3092,7 @@ static bool api_PNP_GetHwProfInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetHwProfInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3128,7 +3136,7 @@ static bool api_PNP_AddEmptyLogConf(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3157,7 +3165,7 @@ static bool api_PNP_AddEmptyLogConf(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_AddEmptyLogConf, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3201,7 +3209,7 @@ static bool api_PNP_FreeLogConf(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3230,7 +3238,7 @@ static bool api_PNP_FreeLogConf(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_FreeLogConf, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3274,7 +3282,7 @@ static bool api_PNP_GetFirstLogConf(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3303,7 +3311,7 @@ static bool api_PNP_GetFirstLogConf(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetFirstLogConf, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3347,7 +3355,7 @@ static bool api_PNP_GetNextLogConf(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3376,7 +3384,7 @@ static bool api_PNP_GetNextLogConf(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetNextLogConf, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3420,7 +3428,7 @@ static bool api_PNP_GetLogConfPriority(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3449,7 +3457,7 @@ static bool api_PNP_GetLogConfPriority(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetLogConfPriority, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3493,7 +3501,7 @@ static bool api_PNP_AddResDes(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3522,7 +3530,7 @@ static bool api_PNP_AddResDes(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_AddResDes, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3566,7 +3574,7 @@ static bool api_PNP_FreeResDes(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3595,7 +3603,7 @@ static bool api_PNP_FreeResDes(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_FreeResDes, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3639,7 +3647,7 @@ static bool api_PNP_GetNextResDes(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3668,7 +3676,7 @@ static bool api_PNP_GetNextResDes(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetNextResDes, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3712,7 +3720,7 @@ static bool api_PNP_GetResDesData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3741,7 +3749,7 @@ static bool api_PNP_GetResDesData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetResDesData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3785,7 +3793,7 @@ static bool api_PNP_GetResDesDataSize(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3814,7 +3822,7 @@ static bool api_PNP_GetResDesDataSize(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetResDesDataSize, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3858,7 +3866,7 @@ static bool api_PNP_ModifyResDes(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3887,7 +3895,7 @@ static bool api_PNP_ModifyResDes(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_ModifyResDes, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3931,7 +3939,7 @@ static bool api_PNP_DetectResourceLimit(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3960,7 +3968,7 @@ static bool api_PNP_DetectResourceLimit(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_DetectResourceLimit, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4004,7 +4012,7 @@ static bool api_PNP_QueryResConfList(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4033,7 +4041,7 @@ static bool api_PNP_QueryResConfList(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_QueryResConfList, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4077,7 +4085,7 @@ static bool api_PNP_SetHwProf(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4106,7 +4114,7 @@ static bool api_PNP_SetHwProf(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_SetHwProf, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4150,7 +4158,7 @@ static bool api_PNP_QueryArbitratorFreeData(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4179,7 +4187,7 @@ static bool api_PNP_QueryArbitratorFreeData(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_QueryArbitratorFreeData, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4223,7 +4231,7 @@ static bool api_PNP_QueryArbitratorFreeSize(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4252,7 +4260,7 @@ static bool api_PNP_QueryArbitratorFreeSize(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_QueryArbitratorFreeSize, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4296,7 +4304,7 @@ static bool api_PNP_RunDetection(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4325,7 +4333,7 @@ static bool api_PNP_RunDetection(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_RunDetection, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4369,7 +4377,7 @@ static bool api_PNP_RegisterNotification(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4398,7 +4406,7 @@ static bool api_PNP_RegisterNotification(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_RegisterNotification, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4442,7 +4450,7 @@ static bool api_PNP_UnregisterNotification(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4471,7 +4479,7 @@ static bool api_PNP_UnregisterNotification(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_UnregisterNotification, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4515,7 +4523,7 @@ static bool api_PNP_GetCustomDevProp(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4544,7 +4552,7 @@ static bool api_PNP_GetCustomDevProp(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetCustomDevProp, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4588,7 +4596,7 @@ static bool api_PNP_GetVersionInternal(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4617,7 +4625,7 @@ static bool api_PNP_GetVersionInternal(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetVersionInternal, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4661,7 +4669,7 @@ static bool api_PNP_GetBlockedDriverInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4690,7 +4698,7 @@ static bool api_PNP_GetBlockedDriverInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetBlockedDriverInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4734,7 +4742,7 @@ static bool api_PNP_GetServerSideDeviceInstallFlags(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4763,7 +4771,7 @@ static bool api_PNP_GetServerSideDeviceInstallFlags(pipes_struct *p) NDR_PRINT_OUT_DEBUG(PNP_GetServerSideDeviceInstallFlags, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_samr.c b/source3/librpc/gen_ndr/srv_samr.c index 1eaa19eaf7..e09c7a3faf 100644 --- a/source3/librpc/gen_ndr/srv_samr.c +++ b/source3/librpc/gen_ndr/srv_samr.c @@ -27,7 +27,7 @@ static bool api_samr_Connect(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_samr_Connect(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Connect, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_samr_Close(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -138,7 +138,7 @@ static bool api_samr_Close(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Close, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -182,7 +182,7 @@ static bool api_samr_SetSecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -211,7 +211,7 @@ static bool api_samr_SetSecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetSecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -255,7 +255,7 @@ static bool api_samr_QuerySecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -291,7 +291,7 @@ static bool api_samr_QuerySecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QuerySecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -335,7 +335,7 @@ static bool api_samr_Shutdown(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -364,7 +364,7 @@ static bool api_samr_Shutdown(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Shutdown, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -408,7 +408,7 @@ static bool api_samr_LookupDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -444,7 +444,7 @@ static bool api_samr_LookupDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_LookupDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -488,7 +488,7 @@ static bool api_samr_EnumDomains(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -531,7 +531,7 @@ static bool api_samr_EnumDomains(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_EnumDomains, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -575,7 +575,7 @@ static bool api_samr_OpenDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -611,7 +611,7 @@ static bool api_samr_OpenDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_OpenDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -655,7 +655,7 @@ static bool api_samr_QueryDomainInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -691,7 +691,7 @@ static bool api_samr_QueryDomainInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryDomainInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -735,7 +735,7 @@ static bool api_samr_SetDomainInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -764,7 +764,7 @@ static bool api_samr_SetDomainInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetDomainInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -808,7 +808,7 @@ static bool api_samr_CreateDomainGroup(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -850,7 +850,7 @@ static bool api_samr_CreateDomainGroup(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_CreateDomainGroup, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -894,7 +894,7 @@ static bool api_samr_EnumDomainGroups(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -937,7 +937,7 @@ static bool api_samr_EnumDomainGroups(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_EnumDomainGroups, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -981,7 +981,7 @@ static bool api_samr_CreateUser(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1023,7 +1023,7 @@ static bool api_samr_CreateUser(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_CreateUser, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1067,7 +1067,7 @@ static bool api_samr_EnumDomainUsers(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1110,7 +1110,7 @@ static bool api_samr_EnumDomainUsers(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_EnumDomainUsers, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1154,7 +1154,7 @@ static bool api_samr_CreateDomAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1196,7 +1196,7 @@ static bool api_samr_CreateDomAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_CreateDomAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1240,7 +1240,7 @@ static bool api_samr_EnumDomainAliases(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1283,7 +1283,7 @@ static bool api_samr_EnumDomainAliases(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_EnumDomainAliases, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1327,7 +1327,7 @@ static bool api_samr_GetAliasMembership(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1363,7 +1363,7 @@ static bool api_samr_GetAliasMembership(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetAliasMembership, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1407,7 +1407,7 @@ static bool api_samr_LookupNames(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1449,7 +1449,7 @@ static bool api_samr_LookupNames(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_LookupNames, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1493,7 +1493,7 @@ static bool api_samr_LookupRids(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1535,7 +1535,7 @@ static bool api_samr_LookupRids(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_LookupRids, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1579,7 +1579,7 @@ static bool api_samr_OpenGroup(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1615,7 +1615,7 @@ static bool api_samr_OpenGroup(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_OpenGroup, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1659,7 +1659,7 @@ static bool api_samr_QueryGroupInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1695,7 +1695,7 @@ static bool api_samr_QueryGroupInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryGroupInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1739,7 +1739,7 @@ static bool api_samr_SetGroupInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1768,7 +1768,7 @@ static bool api_samr_SetGroupInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetGroupInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1812,7 +1812,7 @@ static bool api_samr_AddGroupMember(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1841,7 +1841,7 @@ static bool api_samr_AddGroupMember(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_AddGroupMember, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1885,7 +1885,7 @@ static bool api_samr_DeleteDomainGroup(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1916,7 +1916,7 @@ static bool api_samr_DeleteDomainGroup(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_DeleteDomainGroup, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1960,7 +1960,7 @@ static bool api_samr_DeleteGroupMember(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1989,7 +1989,7 @@ static bool api_samr_DeleteGroupMember(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_DeleteGroupMember, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2033,7 +2033,7 @@ static bool api_samr_QueryGroupMember(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2069,7 +2069,7 @@ static bool api_samr_QueryGroupMember(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryGroupMember, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2113,7 +2113,7 @@ static bool api_samr_SetMemberAttributesOfGroup(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2142,7 +2142,7 @@ static bool api_samr_SetMemberAttributesOfGroup(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetMemberAttributesOfGroup, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2186,7 +2186,7 @@ static bool api_samr_OpenAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2222,7 +2222,7 @@ static bool api_samr_OpenAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_OpenAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2266,7 +2266,7 @@ static bool api_samr_QueryAliasInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2302,7 +2302,7 @@ static bool api_samr_QueryAliasInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryAliasInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2346,7 +2346,7 @@ static bool api_samr_SetAliasInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2375,7 +2375,7 @@ static bool api_samr_SetAliasInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetAliasInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2419,7 +2419,7 @@ static bool api_samr_DeleteDomAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2450,7 +2450,7 @@ static bool api_samr_DeleteDomAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_DeleteDomAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2494,7 +2494,7 @@ static bool api_samr_AddAliasMember(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2523,7 +2523,7 @@ static bool api_samr_AddAliasMember(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_AddAliasMember, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2567,7 +2567,7 @@ static bool api_samr_DeleteAliasMember(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2596,7 +2596,7 @@ static bool api_samr_DeleteAliasMember(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_DeleteAliasMember, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2640,7 +2640,7 @@ static bool api_samr_GetMembersInAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2676,7 +2676,7 @@ static bool api_samr_GetMembersInAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetMembersInAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2720,7 +2720,7 @@ static bool api_samr_OpenUser(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2756,7 +2756,7 @@ static bool api_samr_OpenUser(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_OpenUser, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2800,7 +2800,7 @@ static bool api_samr_DeleteUser(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2831,7 +2831,7 @@ static bool api_samr_DeleteUser(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_DeleteUser, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2875,7 +2875,7 @@ static bool api_samr_QueryUserInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2911,7 +2911,7 @@ static bool api_samr_QueryUserInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryUserInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2955,7 +2955,7 @@ static bool api_samr_SetUserInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2984,7 +2984,7 @@ static bool api_samr_SetUserInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetUserInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3028,7 +3028,7 @@ static bool api_samr_ChangePasswordUser(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3057,7 +3057,7 @@ static bool api_samr_ChangePasswordUser(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_ChangePasswordUser, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3101,7 +3101,7 @@ static bool api_samr_GetGroupsForUser(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3137,7 +3137,7 @@ static bool api_samr_GetGroupsForUser(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetGroupsForUser, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3181,7 +3181,7 @@ static bool api_samr_QueryDisplayInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3229,7 +3229,7 @@ static bool api_samr_QueryDisplayInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryDisplayInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3273,7 +3273,7 @@ static bool api_samr_GetDisplayEnumerationIndex(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3309,7 +3309,7 @@ static bool api_samr_GetDisplayEnumerationIndex(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetDisplayEnumerationIndex, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3353,7 +3353,7 @@ static bool api_samr_TestPrivateFunctionsDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3382,7 +3382,7 @@ static bool api_samr_TestPrivateFunctionsDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_TestPrivateFunctionsDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3426,7 +3426,7 @@ static bool api_samr_TestPrivateFunctionsUser(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3455,7 +3455,7 @@ static bool api_samr_TestPrivateFunctionsUser(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_TestPrivateFunctionsUser, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3499,7 +3499,7 @@ static bool api_samr_GetUserPwInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3535,7 +3535,7 @@ static bool api_samr_GetUserPwInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetUserPwInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3579,7 +3579,7 @@ static bool api_samr_RemoveMemberFromForeignDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3608,7 +3608,7 @@ static bool api_samr_RemoveMemberFromForeignDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_RemoveMemberFromForeignDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3652,7 +3652,7 @@ static bool api_samr_QueryDomainInfo2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3688,7 +3688,7 @@ static bool api_samr_QueryDomainInfo2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryDomainInfo2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3732,7 +3732,7 @@ static bool api_samr_QueryUserInfo2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3768,7 +3768,7 @@ static bool api_samr_QueryUserInfo2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryUserInfo2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3812,7 +3812,7 @@ static bool api_samr_QueryDisplayInfo2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3860,7 +3860,7 @@ static bool api_samr_QueryDisplayInfo2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryDisplayInfo2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3904,7 +3904,7 @@ static bool api_samr_GetDisplayEnumerationIndex2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3940,7 +3940,7 @@ static bool api_samr_GetDisplayEnumerationIndex2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetDisplayEnumerationIndex2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3984,7 +3984,7 @@ static bool api_samr_CreateUser2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4032,7 +4032,7 @@ static bool api_samr_CreateUser2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_CreateUser2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4076,7 +4076,7 @@ static bool api_samr_QueryDisplayInfo3(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4124,7 +4124,7 @@ static bool api_samr_QueryDisplayInfo3(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_QueryDisplayInfo3, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4168,7 +4168,7 @@ static bool api_samr_AddMultipleMembersToAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4197,7 +4197,7 @@ static bool api_samr_AddMultipleMembersToAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_AddMultipleMembersToAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4241,7 +4241,7 @@ static bool api_samr_RemoveMultipleMembersFromAlias(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4270,7 +4270,7 @@ static bool api_samr_RemoveMultipleMembersFromAlias(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_RemoveMultipleMembersFromAlias, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4314,7 +4314,7 @@ static bool api_samr_OemChangePasswordUser2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4343,7 +4343,7 @@ static bool api_samr_OemChangePasswordUser2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_OemChangePasswordUser2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4387,7 +4387,7 @@ static bool api_samr_ChangePasswordUser2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4416,7 +4416,7 @@ static bool api_samr_ChangePasswordUser2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_ChangePasswordUser2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4460,7 +4460,7 @@ static bool api_samr_GetDomPwInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4496,7 +4496,7 @@ static bool api_samr_GetDomPwInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetDomPwInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4540,7 +4540,7 @@ static bool api_samr_Connect2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4576,7 +4576,7 @@ static bool api_samr_Connect2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Connect2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4620,7 +4620,7 @@ static bool api_samr_SetUserInfo2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4649,7 +4649,7 @@ static bool api_samr_SetUserInfo2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetUserInfo2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4693,7 +4693,7 @@ static bool api_samr_SetBootKeyInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4722,7 +4722,7 @@ static bool api_samr_SetBootKeyInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetBootKeyInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4766,7 +4766,7 @@ static bool api_samr_GetBootKeyInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4802,7 +4802,7 @@ static bool api_samr_GetBootKeyInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_GetBootKeyInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4846,7 +4846,7 @@ static bool api_samr_Connect3(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4882,7 +4882,7 @@ static bool api_samr_Connect3(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Connect3, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4926,7 +4926,7 @@ static bool api_samr_Connect4(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4962,7 +4962,7 @@ static bool api_samr_Connect4(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Connect4, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5006,7 +5006,7 @@ static bool api_samr_ChangePasswordUser3(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5048,7 +5048,7 @@ static bool api_samr_ChangePasswordUser3(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_ChangePasswordUser3, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5092,7 +5092,7 @@ static bool api_samr_Connect5(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5140,7 +5140,7 @@ static bool api_samr_Connect5(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_Connect5, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5184,7 +5184,7 @@ static bool api_samr_RidToSid(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5220,7 +5220,7 @@ static bool api_samr_RidToSid(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_RidToSid, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5264,7 +5264,7 @@ static bool api_samr_SetDsrmPassword(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5293,7 +5293,7 @@ static bool api_samr_SetDsrmPassword(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_SetDsrmPassword, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -5337,7 +5337,7 @@ static bool api_samr_ValidatePassword(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -5373,7 +5373,7 @@ static bool api_samr_ValidatePassword(pipes_struct *p) NDR_PRINT_OUT_DEBUG(samr_ValidatePassword, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_srvsvc.c b/source3/librpc/gen_ndr/srv_srvsvc.c index 66faaaaf7e..57d5239971 100644 --- a/source3/librpc/gen_ndr/srv_srvsvc.c +++ b/source3/librpc/gen_ndr/srv_srvsvc.c @@ -27,7 +27,7 @@ static bool api_srvsvc_NetCharDevEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -66,7 +66,7 @@ static bool api_srvsvc_NetCharDevEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -110,7 +110,7 @@ static bool api_srvsvc_NetCharDevGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -146,7 +146,7 @@ static bool api_srvsvc_NetCharDevGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -190,7 +190,7 @@ static bool api_srvsvc_NetCharDevControl(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -219,7 +219,7 @@ static bool api_srvsvc_NetCharDevControl(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevControl, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -263,7 +263,7 @@ static bool api_srvsvc_NetCharDevQEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -302,7 +302,7 @@ static bool api_srvsvc_NetCharDevQEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevQEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -346,7 +346,7 @@ static bool api_srvsvc_NetCharDevQGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -382,7 +382,7 @@ static bool api_srvsvc_NetCharDevQGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevQGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -426,7 +426,7 @@ static bool api_srvsvc_NetCharDevQSetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -457,7 +457,7 @@ static bool api_srvsvc_NetCharDevQSetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevQSetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -501,7 +501,7 @@ static bool api_srvsvc_NetCharDevQPurge(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -530,7 +530,7 @@ static bool api_srvsvc_NetCharDevQPurge(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevQPurge, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -574,7 +574,7 @@ static bool api_srvsvc_NetCharDevQPurgeSelf(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -603,7 +603,7 @@ static bool api_srvsvc_NetCharDevQPurgeSelf(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetCharDevQPurgeSelf, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -647,7 +647,7 @@ static bool api_srvsvc_NetConnEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -685,7 +685,7 @@ static bool api_srvsvc_NetConnEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetConnEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -729,7 +729,7 @@ static bool api_srvsvc_NetFileEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -767,7 +767,7 @@ static bool api_srvsvc_NetFileEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetFileEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -811,7 +811,7 @@ static bool api_srvsvc_NetFileGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -847,7 +847,7 @@ static bool api_srvsvc_NetFileGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetFileGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -891,7 +891,7 @@ static bool api_srvsvc_NetFileClose(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -920,7 +920,7 @@ static bool api_srvsvc_NetFileClose(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetFileClose, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -964,7 +964,7 @@ static bool api_srvsvc_NetSessEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1002,7 +1002,7 @@ static bool api_srvsvc_NetSessEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetSessEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1046,7 +1046,7 @@ static bool api_srvsvc_NetSessDel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1075,7 +1075,7 @@ static bool api_srvsvc_NetSessDel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetSessDel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1119,7 +1119,7 @@ static bool api_srvsvc_NetShareAdd(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1150,7 +1150,7 @@ static bool api_srvsvc_NetShareAdd(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareAdd, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1194,7 +1194,7 @@ static bool api_srvsvc_NetShareEnumAll(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1232,7 +1232,7 @@ static bool api_srvsvc_NetShareEnumAll(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareEnumAll, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1276,7 +1276,7 @@ static bool api_srvsvc_NetShareGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1312,7 +1312,7 @@ static bool api_srvsvc_NetShareGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1356,7 +1356,7 @@ static bool api_srvsvc_NetShareSetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1387,7 +1387,7 @@ static bool api_srvsvc_NetShareSetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareSetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1431,7 +1431,7 @@ static bool api_srvsvc_NetShareDel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1460,7 +1460,7 @@ static bool api_srvsvc_NetShareDel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareDel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1504,7 +1504,7 @@ static bool api_srvsvc_NetShareDelSticky(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1533,7 +1533,7 @@ static bool api_srvsvc_NetShareDelSticky(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareDelSticky, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1577,7 +1577,7 @@ static bool api_srvsvc_NetShareCheck(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1613,7 +1613,7 @@ static bool api_srvsvc_NetShareCheck(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareCheck, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1657,7 +1657,7 @@ static bool api_srvsvc_NetSrvGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1693,7 +1693,7 @@ static bool api_srvsvc_NetSrvGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetSrvGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1737,7 +1737,7 @@ static bool api_srvsvc_NetSrvSetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1768,7 +1768,7 @@ static bool api_srvsvc_NetSrvSetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetSrvSetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1812,7 +1812,7 @@ static bool api_srvsvc_NetDiskEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1850,7 +1850,7 @@ static bool api_srvsvc_NetDiskEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1894,7 +1894,7 @@ static bool api_srvsvc_NetServerStatisticsGet(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1930,7 +1930,7 @@ static bool api_srvsvc_NetServerStatisticsGet(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetServerStatisticsGet, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1974,7 +1974,7 @@ static bool api_srvsvc_NetTransportAdd(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2003,7 +2003,7 @@ static bool api_srvsvc_NetTransportAdd(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetTransportAdd, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2047,7 +2047,7 @@ static bool api_srvsvc_NetTransportEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2086,7 +2086,7 @@ static bool api_srvsvc_NetTransportEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetTransportEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2130,7 +2130,7 @@ static bool api_srvsvc_NetTransportDel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2159,7 +2159,7 @@ static bool api_srvsvc_NetTransportDel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetTransportDel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2203,7 +2203,7 @@ static bool api_srvsvc_NetRemoteTOD(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2239,7 +2239,7 @@ static bool api_srvsvc_NetRemoteTOD(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetRemoteTOD, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2283,7 +2283,7 @@ static bool api_srvsvc_NetSetServiceBits(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2312,7 +2312,7 @@ static bool api_srvsvc_NetSetServiceBits(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetSetServiceBits, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2356,7 +2356,7 @@ static bool api_srvsvc_NetPathType(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2392,7 +2392,7 @@ static bool api_srvsvc_NetPathType(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetPathType, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2436,7 +2436,7 @@ static bool api_srvsvc_NetPathCanonicalize(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2473,7 +2473,7 @@ static bool api_srvsvc_NetPathCanonicalize(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetPathCanonicalize, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2517,7 +2517,7 @@ static bool api_srvsvc_NetPathCompare(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2546,7 +2546,7 @@ static bool api_srvsvc_NetPathCompare(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetPathCompare, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2590,7 +2590,7 @@ static bool api_srvsvc_NetNameValidate(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2619,7 +2619,7 @@ static bool api_srvsvc_NetNameValidate(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetNameValidate, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2663,7 +2663,7 @@ static bool api_srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2692,7 +2692,7 @@ static bool api_srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRPRNAMECANONICALIZE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2736,7 +2736,7 @@ static bool api_srvsvc_NetPRNameCompare(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2765,7 +2765,7 @@ static bool api_srvsvc_NetPRNameCompare(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetPRNameCompare, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2809,7 +2809,7 @@ static bool api_srvsvc_NetShareEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2847,7 +2847,7 @@ static bool api_srvsvc_NetShareEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2891,7 +2891,7 @@ static bool api_srvsvc_NetShareDelStart(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2927,7 +2927,7 @@ static bool api_srvsvc_NetShareDelStart(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareDelStart, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2971,7 +2971,7 @@ static bool api_srvsvc_NetShareDelCommit(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3002,7 +3002,7 @@ static bool api_srvsvc_NetShareDelCommit(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetShareDelCommit, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3046,7 +3046,7 @@ static bool api_srvsvc_NetGetFileSecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3082,7 +3082,7 @@ static bool api_srvsvc_NetGetFileSecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetGetFileSecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3126,7 +3126,7 @@ static bool api_srvsvc_NetSetFileSecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3155,7 +3155,7 @@ static bool api_srvsvc_NetSetFileSecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetSetFileSecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3199,7 +3199,7 @@ static bool api_srvsvc_NetServerTransportAddEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3228,7 +3228,7 @@ static bool api_srvsvc_NetServerTransportAddEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetServerTransportAddEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3272,7 +3272,7 @@ static bool api_srvsvc_NetServerSetServiceBitsEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3301,7 +3301,7 @@ static bool api_srvsvc_NetServerSetServiceBitsEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NetServerSetServiceBitsEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3345,7 +3345,7 @@ static bool api_srvsvc_NETRDFSGETVERSION(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3374,7 +3374,7 @@ static bool api_srvsvc_NETRDFSGETVERSION(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSGETVERSION, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3418,7 +3418,7 @@ static bool api_srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3447,7 +3447,7 @@ static bool api_srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSCREATELOCALPARTITION, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3491,7 +3491,7 @@ static bool api_srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3520,7 +3520,7 @@ static bool api_srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSDELETELOCALPARTITION, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3564,7 +3564,7 @@ static bool api_srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3593,7 +3593,7 @@ static bool api_srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSSETLOCALVOLUMESTATE, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3637,7 +3637,7 @@ static bool api_srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3666,7 +3666,7 @@ static bool api_srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSSETSERVERINFO, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3710,7 +3710,7 @@ static bool api_srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3739,7 +3739,7 @@ static bool api_srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSCREATEEXITPOINT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3783,7 +3783,7 @@ static bool api_srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3812,7 +3812,7 @@ static bool api_srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSDELETEEXITPOINT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3856,7 +3856,7 @@ static bool api_srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3885,7 +3885,7 @@ static bool api_srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSMODIFYPREFIX, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3929,7 +3929,7 @@ static bool api_srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3958,7 +3958,7 @@ static bool api_srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSFIXLOCALVOLUME, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4002,7 +4002,7 @@ static bool api_srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4031,7 +4031,7 @@ static bool api_srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRDFSMANAGERREPORTSITEINFO, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -4075,7 +4075,7 @@ static bool api_srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -4104,7 +4104,7 @@ static bool api_srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p) NDR_PRINT_OUT_DEBUG(srvsvc_NETRSERVERTRANSPORTDELEX, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_svcctl.c b/source3/librpc/gen_ndr/srv_svcctl.c index 32317ad8fe..2349b4fd93 100644 --- a/source3/librpc/gen_ndr/srv_svcctl.c +++ b/source3/librpc/gen_ndr/srv_svcctl.c @@ -27,7 +27,7 @@ static bool api_svcctl_CloseServiceHandle(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -58,7 +58,7 @@ static bool api_svcctl_CloseServiceHandle(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_CloseServiceHandle, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -102,7 +102,7 @@ static bool api_svcctl_ControlService(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -138,7 +138,7 @@ static bool api_svcctl_ControlService(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_ControlService, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -182,7 +182,7 @@ static bool api_svcctl_DeleteService(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -211,7 +211,7 @@ static bool api_svcctl_DeleteService(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_DeleteService, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -255,7 +255,7 @@ static bool api_svcctl_LockServiceDatabase(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -291,7 +291,7 @@ static bool api_svcctl_LockServiceDatabase(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_LockServiceDatabase, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -335,7 +335,7 @@ static bool api_svcctl_QueryServiceObjectSecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -377,7 +377,7 @@ static bool api_svcctl_QueryServiceObjectSecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceObjectSecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -421,7 +421,7 @@ static bool api_svcctl_SetServiceObjectSecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -450,7 +450,7 @@ static bool api_svcctl_SetServiceObjectSecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_SetServiceObjectSecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -494,7 +494,7 @@ static bool api_svcctl_QueryServiceStatus(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -530,7 +530,7 @@ static bool api_svcctl_QueryServiceStatus(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceStatus, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -574,7 +574,7 @@ static bool api_svcctl_SetServiceStatus(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -603,7 +603,7 @@ static bool api_svcctl_SetServiceStatus(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_SetServiceStatus, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -647,7 +647,7 @@ static bool api_svcctl_UnlockServiceDatabase(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -678,7 +678,7 @@ static bool api_svcctl_UnlockServiceDatabase(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_UnlockServiceDatabase, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -722,7 +722,7 @@ static bool api_svcctl_NotifyBootConfigStatus(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -751,7 +751,7 @@ static bool api_svcctl_NotifyBootConfigStatus(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_NotifyBootConfigStatus, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -795,7 +795,7 @@ static bool api_svcctl_SCSetServiceBitsW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -824,7 +824,7 @@ static bool api_svcctl_SCSetServiceBitsW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_SCSetServiceBitsW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -868,7 +868,7 @@ static bool api_svcctl_ChangeServiceConfigW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -904,7 +904,7 @@ static bool api_svcctl_ChangeServiceConfigW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_ChangeServiceConfigW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -948,7 +948,7 @@ static bool api_svcctl_CreateServiceW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -985,7 +985,7 @@ static bool api_svcctl_CreateServiceW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_CreateServiceW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1029,7 +1029,7 @@ static bool api_svcctl_EnumDependentServicesW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1077,7 +1077,7 @@ static bool api_svcctl_EnumDependentServicesW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_EnumDependentServicesW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1121,7 +1121,7 @@ static bool api_svcctl_EnumServicesStatusW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1170,7 +1170,7 @@ static bool api_svcctl_EnumServicesStatusW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_EnumServicesStatusW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1214,7 +1214,7 @@ static bool api_svcctl_OpenSCManagerW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1250,7 +1250,7 @@ static bool api_svcctl_OpenSCManagerW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_OpenSCManagerW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1294,7 +1294,7 @@ static bool api_svcctl_OpenServiceW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1330,7 +1330,7 @@ static bool api_svcctl_OpenServiceW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_OpenServiceW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1374,7 +1374,7 @@ static bool api_svcctl_QueryServiceConfigW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1392,7 +1392,7 @@ static bool api_svcctl_QueryServiceConfigW(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.query = talloc_zero_array(r, uint8_t, r->in.buf_size); + r->out.query = talloc_zero(r, struct QUERY_SERVICE_CONFIG); if (r->out.query == NULL) { talloc_free(r); return false; @@ -1416,7 +1416,7 @@ static bool api_svcctl_QueryServiceConfigW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceConfigW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1460,7 +1460,7 @@ static bool api_svcctl_QueryServiceLockStatusW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1502,7 +1502,7 @@ static bool api_svcctl_QueryServiceLockStatusW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceLockStatusW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1546,7 +1546,7 @@ static bool api_svcctl_StartServiceW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1575,7 +1575,7 @@ static bool api_svcctl_StartServiceW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_StartServiceW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1619,7 +1619,7 @@ static bool api_svcctl_GetServiceDisplayNameW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1656,7 +1656,7 @@ static bool api_svcctl_GetServiceDisplayNameW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_GetServiceDisplayNameW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1700,7 +1700,7 @@ static bool api_svcctl_GetServiceKeyNameW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1737,7 +1737,7 @@ static bool api_svcctl_GetServiceKeyNameW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_GetServiceKeyNameW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1781,7 +1781,7 @@ static bool api_svcctl_SCSetServiceBitsA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1810,7 +1810,7 @@ static bool api_svcctl_SCSetServiceBitsA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_SCSetServiceBitsA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1854,7 +1854,7 @@ static bool api_svcctl_ChangeServiceConfigA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1890,7 +1890,7 @@ static bool api_svcctl_ChangeServiceConfigA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_ChangeServiceConfigA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1934,7 +1934,7 @@ static bool api_svcctl_CreateServiceA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1970,7 +1970,7 @@ static bool api_svcctl_CreateServiceA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_CreateServiceA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2014,7 +2014,7 @@ static bool api_svcctl_EnumDependentServicesA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2062,7 +2062,7 @@ static bool api_svcctl_EnumDependentServicesA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_EnumDependentServicesA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2106,7 +2106,7 @@ static bool api_svcctl_EnumServicesStatusA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2155,7 +2155,7 @@ static bool api_svcctl_EnumServicesStatusA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_EnumServicesStatusA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2199,7 +2199,7 @@ static bool api_svcctl_OpenSCManagerA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2235,7 +2235,7 @@ static bool api_svcctl_OpenSCManagerA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_OpenSCManagerA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2279,7 +2279,7 @@ static bool api_svcctl_OpenServiceA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2308,7 +2308,7 @@ static bool api_svcctl_OpenServiceA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_OpenServiceA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2352,7 +2352,7 @@ static bool api_svcctl_QueryServiceConfigA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2394,7 +2394,7 @@ static bool api_svcctl_QueryServiceConfigA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceConfigA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2438,7 +2438,7 @@ static bool api_svcctl_QueryServiceLockStatusA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2480,7 +2480,7 @@ static bool api_svcctl_QueryServiceLockStatusA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceLockStatusA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2524,7 +2524,7 @@ static bool api_svcctl_StartServiceA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2553,7 +2553,7 @@ static bool api_svcctl_StartServiceA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_StartServiceA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2597,7 +2597,7 @@ static bool api_svcctl_GetServiceDisplayNameA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2634,7 +2634,7 @@ static bool api_svcctl_GetServiceDisplayNameA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_GetServiceDisplayNameA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2678,7 +2678,7 @@ static bool api_svcctl_GetServiceKeyNameA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2715,7 +2715,7 @@ static bool api_svcctl_GetServiceKeyNameA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_GetServiceKeyNameA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2759,7 +2759,7 @@ static bool api_svcctl_GetCurrentGroupeStateW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2788,7 +2788,7 @@ static bool api_svcctl_GetCurrentGroupeStateW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_GetCurrentGroupeStateW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2832,7 +2832,7 @@ static bool api_svcctl_EnumServiceGroupW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2861,7 +2861,7 @@ static bool api_svcctl_EnumServiceGroupW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_EnumServiceGroupW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2905,7 +2905,7 @@ static bool api_svcctl_ChangeServiceConfig2A(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2934,7 +2934,7 @@ static bool api_svcctl_ChangeServiceConfig2A(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_ChangeServiceConfig2A, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2978,7 +2978,7 @@ static bool api_svcctl_ChangeServiceConfig2W(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3007,7 +3007,7 @@ static bool api_svcctl_ChangeServiceConfig2W(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_ChangeServiceConfig2W, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3051,7 +3051,7 @@ static bool api_svcctl_QueryServiceConfig2A(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3093,7 +3093,7 @@ static bool api_svcctl_QueryServiceConfig2A(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceConfig2A, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3137,7 +3137,7 @@ static bool api_svcctl_QueryServiceConfig2W(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3179,7 +3179,7 @@ static bool api_svcctl_QueryServiceConfig2W(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceConfig2W, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3223,7 +3223,7 @@ static bool api_svcctl_QueryServiceStatusEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3265,7 +3265,7 @@ static bool api_svcctl_QueryServiceStatusEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_QueryServiceStatusEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3309,7 +3309,7 @@ static bool api_EnumServicesStatusExA(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3364,7 +3364,7 @@ static bool api_EnumServicesStatusExA(pipes_struct *p) NDR_PRINT_OUT_DEBUG(EnumServicesStatusExA, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3408,7 +3408,7 @@ static bool api_EnumServicesStatusExW(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3463,7 +3463,7 @@ static bool api_EnumServicesStatusExW(pipes_struct *p) NDR_PRINT_OUT_DEBUG(EnumServicesStatusExW, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -3507,7 +3507,7 @@ static bool api_svcctl_SCSendTSMessage(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -3536,7 +3536,7 @@ static bool api_svcctl_SCSendTSMessage(pipes_struct *p) NDR_PRINT_OUT_DEBUG(svcctl_SCSendTSMessage, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_winreg.c b/source3/librpc/gen_ndr/srv_winreg.c index c697f44d2a..77b0a1c5d2 100644 --- a/source3/librpc/gen_ndr/srv_winreg.c +++ b/source3/librpc/gen_ndr/srv_winreg.c @@ -27,7 +27,7 @@ static bool api_winreg_OpenHKCR(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_winreg_OpenHKCR(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKCR, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_winreg_OpenHKCU(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -143,7 +143,7 @@ static bool api_winreg_OpenHKCU(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKCU, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -187,7 +187,7 @@ static bool api_winreg_OpenHKLM(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -223,7 +223,7 @@ static bool api_winreg_OpenHKLM(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKLM, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -267,7 +267,7 @@ static bool api_winreg_OpenHKPD(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -303,7 +303,7 @@ static bool api_winreg_OpenHKPD(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKPD, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -347,7 +347,7 @@ static bool api_winreg_OpenHKU(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -383,7 +383,7 @@ static bool api_winreg_OpenHKU(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKU, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -427,7 +427,7 @@ static bool api_winreg_CloseKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -458,7 +458,7 @@ static bool api_winreg_CloseKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_CloseKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -502,7 +502,7 @@ static bool api_winreg_CreateKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -539,7 +539,7 @@ static bool api_winreg_CreateKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_CreateKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -583,7 +583,7 @@ static bool api_winreg_DeleteKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -612,7 +612,7 @@ static bool api_winreg_DeleteKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_DeleteKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -656,7 +656,7 @@ static bool api_winreg_DeleteValue(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -685,7 +685,7 @@ static bool api_winreg_DeleteValue(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_DeleteValue, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -729,7 +729,7 @@ static bool api_winreg_EnumKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -762,7 +762,7 @@ static bool api_winreg_EnumKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_EnumKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -806,7 +806,7 @@ static bool api_winreg_EnumValue(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -841,7 +841,7 @@ static bool api_winreg_EnumValue(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_EnumValue, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -885,7 +885,7 @@ static bool api_winreg_FlushKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -914,7 +914,7 @@ static bool api_winreg_FlushKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_FlushKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -958,7 +958,7 @@ static bool api_winreg_GetKeySecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -989,7 +989,7 @@ static bool api_winreg_GetKeySecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_GetKeySecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1033,7 +1033,7 @@ static bool api_winreg_LoadKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1062,7 +1062,7 @@ static bool api_winreg_LoadKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_LoadKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1106,7 +1106,7 @@ static bool api_winreg_NotifyChangeKeyValue(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1135,7 +1135,7 @@ static bool api_winreg_NotifyChangeKeyValue(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_NotifyChangeKeyValue, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1179,7 +1179,7 @@ static bool api_winreg_OpenKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1215,7 +1215,7 @@ static bool api_winreg_OpenKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1259,7 +1259,7 @@ static bool api_winreg_QueryInfoKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1338,7 +1338,7 @@ static bool api_winreg_QueryInfoKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_QueryInfoKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1382,7 +1382,7 @@ static bool api_winreg_QueryValue(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1403,7 +1403,7 @@ static bool api_winreg_QueryValue(pipes_struct *p) r->out.type = r->in.type; r->out.data = r->in.data; r->out.data_size = r->in.data_size; - r->out.value_length = r->in.value_length; + r->out.data_length = r->in.data_length; r->out.result = _winreg_QueryValue(p, r); if (p->rng_fault_state) { @@ -1416,7 +1416,7 @@ static bool api_winreg_QueryValue(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_QueryValue, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1460,7 +1460,7 @@ static bool api_winreg_ReplaceKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1489,7 +1489,7 @@ static bool api_winreg_ReplaceKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_ReplaceKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1533,7 +1533,7 @@ static bool api_winreg_RestoreKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1562,7 +1562,7 @@ static bool api_winreg_RestoreKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_RestoreKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1606,7 +1606,7 @@ static bool api_winreg_SaveKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1635,7 +1635,7 @@ static bool api_winreg_SaveKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_SaveKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1679,7 +1679,7 @@ static bool api_winreg_SetKeySecurity(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1708,7 +1708,7 @@ static bool api_winreg_SetKeySecurity(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_SetKeySecurity, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1752,7 +1752,7 @@ static bool api_winreg_SetValue(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1781,7 +1781,7 @@ static bool api_winreg_SetValue(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_SetValue, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1825,7 +1825,7 @@ static bool api_winreg_UnLoadKey(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1854,7 +1854,7 @@ static bool api_winreg_UnLoadKey(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_UnLoadKey, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1898,7 +1898,7 @@ static bool api_winreg_InitiateSystemShutdown(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1927,7 +1927,7 @@ static bool api_winreg_InitiateSystemShutdown(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_InitiateSystemShutdown, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1971,7 +1971,7 @@ static bool api_winreg_AbortSystemShutdown(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2000,7 +2000,7 @@ static bool api_winreg_AbortSystemShutdown(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_AbortSystemShutdown, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2044,7 +2044,7 @@ static bool api_winreg_GetVersion(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2080,7 +2080,7 @@ static bool api_winreg_GetVersion(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_GetVersion, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2124,7 +2124,7 @@ static bool api_winreg_OpenHKCC(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2160,7 +2160,7 @@ static bool api_winreg_OpenHKCC(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKCC, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2204,7 +2204,7 @@ static bool api_winreg_OpenHKDD(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2240,7 +2240,7 @@ static bool api_winreg_OpenHKDD(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKDD, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2284,7 +2284,7 @@ static bool api_winreg_QueryMultipleValues(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2317,7 +2317,7 @@ static bool api_winreg_QueryMultipleValues(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_QueryMultipleValues, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2361,7 +2361,7 @@ static bool api_winreg_InitiateSystemShutdownEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2390,7 +2390,7 @@ static bool api_winreg_InitiateSystemShutdownEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_InitiateSystemShutdownEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2434,7 +2434,7 @@ static bool api_winreg_SaveKeyEx(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2463,7 +2463,7 @@ static bool api_winreg_SaveKeyEx(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_SaveKeyEx, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2507,7 +2507,7 @@ static bool api_winreg_OpenHKPT(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2543,7 +2543,7 @@ static bool api_winreg_OpenHKPT(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKPT, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2587,7 +2587,7 @@ static bool api_winreg_OpenHKPN(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2623,7 +2623,7 @@ static bool api_winreg_OpenHKPN(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_OpenHKPN, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2667,7 +2667,7 @@ static bool api_winreg_QueryMultipleValues2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2696,7 +2696,7 @@ static bool api_winreg_QueryMultipleValues2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(winreg_QueryMultipleValues2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/srv_wkssvc.c b/source3/librpc/gen_ndr/srv_wkssvc.c index 227e4c1a48..9c07fa86ea 100644 --- a/source3/librpc/gen_ndr/srv_wkssvc.c +++ b/source3/librpc/gen_ndr/srv_wkssvc.c @@ -27,7 +27,7 @@ static bool api_wkssvc_NetWkstaGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -63,7 +63,7 @@ static bool api_wkssvc_NetWkstaGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetWkstaGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -107,7 +107,7 @@ static bool api_wkssvc_NetWkstaSetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -138,7 +138,7 @@ static bool api_wkssvc_NetWkstaSetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetWkstaSetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -182,7 +182,7 @@ static bool api_wkssvc_NetWkstaEnumUsers(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -220,7 +220,7 @@ static bool api_wkssvc_NetWkstaEnumUsers(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetWkstaEnumUsers, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -264,7 +264,7 @@ static bool api_wkssvc_NetrWkstaUserGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -300,7 +300,7 @@ static bool api_wkssvc_NetrWkstaUserGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrWkstaUserGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -344,7 +344,7 @@ static bool api_wkssvc_NetrWkstaUserSetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -375,7 +375,7 @@ static bool api_wkssvc_NetrWkstaUserSetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrWkstaUserSetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -419,7 +419,7 @@ static bool api_wkssvc_NetWkstaTransportEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -457,7 +457,7 @@ static bool api_wkssvc_NetWkstaTransportEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetWkstaTransportEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -501,7 +501,7 @@ static bool api_wkssvc_NetrWkstaTransportAdd(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -532,7 +532,7 @@ static bool api_wkssvc_NetrWkstaTransportAdd(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrWkstaTransportAdd, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -576,7 +576,7 @@ static bool api_wkssvc_NetrWkstaTransportDel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -605,7 +605,7 @@ static bool api_wkssvc_NetrWkstaTransportDel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrWkstaTransportDel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -649,7 +649,7 @@ static bool api_wkssvc_NetrUseAdd(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -680,7 +680,7 @@ static bool api_wkssvc_NetrUseAdd(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrUseAdd, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -724,7 +724,7 @@ static bool api_wkssvc_NetrUseGetInfo(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -760,7 +760,7 @@ static bool api_wkssvc_NetrUseGetInfo(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrUseGetInfo, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -804,7 +804,7 @@ static bool api_wkssvc_NetrUseDel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -833,7 +833,7 @@ static bool api_wkssvc_NetrUseDel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrUseDel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -877,7 +877,7 @@ static bool api_wkssvc_NetrUseEnum(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -915,7 +915,7 @@ static bool api_wkssvc_NetrUseEnum(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrUseEnum, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -959,7 +959,7 @@ static bool api_wkssvc_NetrMessageBufferSend(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -988,7 +988,7 @@ static bool api_wkssvc_NetrMessageBufferSend(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrMessageBufferSend, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1032,7 +1032,7 @@ static bool api_wkssvc_NetrWorkstationStatisticsGet(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1068,7 +1068,7 @@ static bool api_wkssvc_NetrWorkstationStatisticsGet(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrWorkstationStatisticsGet, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1112,7 +1112,7 @@ static bool api_wkssvc_NetrLogonDomainNameAdd(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1141,7 +1141,7 @@ static bool api_wkssvc_NetrLogonDomainNameAdd(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrLogonDomainNameAdd, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1185,7 +1185,7 @@ static bool api_wkssvc_NetrLogonDomainNameDel(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1214,7 +1214,7 @@ static bool api_wkssvc_NetrLogonDomainNameDel(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrLogonDomainNameDel, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1258,7 +1258,7 @@ static bool api_wkssvc_NetrJoinDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1287,7 +1287,7 @@ static bool api_wkssvc_NetrJoinDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrJoinDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1331,7 +1331,7 @@ static bool api_wkssvc_NetrUnjoinDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1360,7 +1360,7 @@ static bool api_wkssvc_NetrUnjoinDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrUnjoinDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1404,7 +1404,7 @@ static bool api_wkssvc_NetrRenameMachineInDomain(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1433,7 +1433,7 @@ static bool api_wkssvc_NetrRenameMachineInDomain(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrRenameMachineInDomain, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1477,7 +1477,7 @@ static bool api_wkssvc_NetrValidateName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1506,7 +1506,7 @@ static bool api_wkssvc_NetrValidateName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrValidateName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1550,7 +1550,7 @@ static bool api_wkssvc_NetrGetJoinInformation(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1587,7 +1587,7 @@ static bool api_wkssvc_NetrGetJoinInformation(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrGetJoinInformation, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1631,7 +1631,7 @@ static bool api_wkssvc_NetrGetJoinableOus(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1668,7 +1668,7 @@ static bool api_wkssvc_NetrGetJoinableOus(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrGetJoinableOus, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1712,7 +1712,7 @@ static bool api_wkssvc_NetrJoinDomain2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1741,7 +1741,7 @@ static bool api_wkssvc_NetrJoinDomain2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrJoinDomain2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1785,7 +1785,7 @@ static bool api_wkssvc_NetrUnjoinDomain2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1814,7 +1814,7 @@ static bool api_wkssvc_NetrUnjoinDomain2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrUnjoinDomain2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1858,7 +1858,7 @@ static bool api_wkssvc_NetrRenameMachineInDomain2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1887,7 +1887,7 @@ static bool api_wkssvc_NetrRenameMachineInDomain2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrRenameMachineInDomain2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -1931,7 +1931,7 @@ static bool api_wkssvc_NetrValidateName2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -1960,7 +1960,7 @@ static bool api_wkssvc_NetrValidateName2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrValidateName2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2004,7 +2004,7 @@ static bool api_wkssvc_NetrGetJoinableOus2(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2041,7 +2041,7 @@ static bool api_wkssvc_NetrGetJoinableOus2(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrGetJoinableOus2, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2085,7 +2085,7 @@ static bool api_wkssvc_NetrAddAlternateComputerName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2114,7 +2114,7 @@ static bool api_wkssvc_NetrAddAlternateComputerName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrAddAlternateComputerName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2158,7 +2158,7 @@ static bool api_wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2187,7 +2187,7 @@ static bool api_wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrRemoveAlternateComputerName, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2231,7 +2231,7 @@ static bool api_wkssvc_NetrSetPrimaryComputername(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2260,7 +2260,7 @@ static bool api_wkssvc_NetrSetPrimaryComputername(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrSetPrimaryComputername, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; @@ -2304,7 +2304,7 @@ static bool api_wkssvc_NetrEnumerateComputerNames(pipes_struct *p) return false; } - pull = ndr_pull_init_blob(&blob, r); + pull = ndr_pull_init_blob(&blob, r, NULL); if (pull == NULL) { talloc_free(r); return false; @@ -2340,7 +2340,7 @@ static bool api_wkssvc_NetrEnumerateComputerNames(pipes_struct *p) NDR_PRINT_OUT_DEBUG(wkssvc_NetrEnumerateComputerNames, r); } - push = ndr_push_init_ctx(r); + push = ndr_push_init_ctx(r, NULL); if (push == NULL) { talloc_free(r); return false; diff --git a/source3/librpc/gen_ndr/svcctl.h b/source3/librpc/gen_ndr/svcctl.h index d4135d2ddb..42ed039784 100644 --- a/source3/librpc/gen_ndr/svcctl.h +++ b/source3/librpc/gen_ndr/svcctl.h @@ -2,6 +2,7 @@ #include +#include "librpc/gen_ndr/misc.h" #ifndef _HEADER_svcctl #define _HEADER_svcctl @@ -98,6 +99,18 @@ enum SERVICE_CONTROL #define SC_RIGHT_SVC_INTERROGATE ( 0x0080 ) #define SC_RIGHT_SVC_USER_DEFINED_CONTROL ( 0x0100 ) +struct QUERY_SERVICE_CONFIG { + uint32_t service_type; + uint32_t start_type; + uint32_t error_control; + const char *executablepath;/* [unique,range(0,8192),charset(UTF16)] */ + const char *loadordergroup;/* [unique,range(0,8192),charset(UTF16)] */ + uint32_t tag_id; + const char *dependencies;/* [unique,range(0,8192),charset(UTF16)] */ + const char *startname;/* [unique,range(0,8192),charset(UTF16)] */ + const char *displayname;/* [unique,range(0,8192),charset(UTF16)] */ +}/* [gensize,public] */; + struct svcctl_CloseServiceHandle { struct { @@ -359,12 +372,12 @@ struct svcctl_OpenServiceW { struct svcctl_QueryServiceConfigW { struct { struct policy_handle *handle;/* [ref] */ - uint32_t buf_size; + uint32_t buf_size;/* [range(0,8192)] */ } in; struct { - uint8_t *query; - uint32_t *bytes_needed;/* [ref] */ + struct QUERY_SERVICE_CONFIG *query;/* [ref] */ + uint32_t *bytes_needed;/* [ref,range(0,8192)] */ WERROR result; } out; diff --git a/source3/librpc/gen_ndr/tables.c b/source3/librpc/gen_ndr/tables.c new file mode 100644 index 0000000000..f2064d95ac --- /dev/null +++ b/source3/librpc/gen_ndr/tables.c @@ -0,0 +1,83 @@ + +/* Automatically generated by tables.pl. DO NOT EDIT */ + +#include "includes.h" +#include "librpc/ndr/libndr.h" +#include "librpc/ndr/ndr_table.h" +#include "librpc/gen_ndr/ndr_dfs.h" +#include "librpc/gen_ndr/ndr_drsblobs.h" +#include "librpc/gen_ndr/ndr_drsuapi.h" +#include "librpc/gen_ndr/ndr_dssetup.h" +#include "librpc/gen_ndr/ndr_echo.h" +#include "librpc/gen_ndr/ndr_epmapper.h" +#include "librpc/gen_ndr/ndr_eventlog.h" +#include "librpc/gen_ndr/ndr_initshutdown.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" +#include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_netlogon.h" +#include "librpc/gen_ndr/ndr_ntsvcs.h" +#include "librpc/gen_ndr/ndr_samr.h" +#include "librpc/gen_ndr/ndr_srvsvc.h" +#include "librpc/gen_ndr/ndr_svcctl.h" +#include "librpc/gen_ndr/ndr_winreg.h" +#include "librpc/gen_ndr/ndr_wkssvc.h" + +NTSTATUS ndr_table_register_builtin_tables(void) +{ + NTSTATUS status; + + status = ndr_table_register(&ndr_table_netdfs); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_drsblobs); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_drsuapi); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_dssetup); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_rpcecho); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_epmapper); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_eventlog); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_initshutdown); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_krb5pac); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_lsarpc); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_netlogon); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_ntsvcs); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_samr); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_srvsvc); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_svcctl); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_winreg); + if (NT_STATUS_IS_ERR(status)) return status; + + status = ndr_table_register(&ndr_table_wkssvc); + if (NT_STATUS_IS_ERR(status)) return status; + + + + return NT_STATUS_OK; +} diff --git a/source3/librpc/gen_ndr/winreg.h b/source3/librpc/gen_ndr/winreg.h index 4a06e3bc83..fbbab33c8d 100644 --- a/source3/librpc/gen_ndr/winreg.h +++ b/source3/librpc/gen_ndr/winreg.h @@ -3,7 +3,6 @@ #include #include "librpc/gen_ndr/lsa.h" -#include "librpc/gen_ndr/initshutdown.h" #include "librpc/gen_ndr/security.h" #ifndef _HEADER_winreg #define _HEADER_winreg @@ -85,17 +84,17 @@ enum winreg_CreateAction ; struct winreg_StringBuf { - uint16_t length;/* [value(strlen_m_term_null(name)*2)] */ - uint16_t size; - const char *name;/* [unique,length_is(length/2),charset(UTF16),size_is(size/2)] */ -}; - -struct winreg_ValNameBuf { uint16_t length;/* [value(strlen_m_term(name)*2)] */ uint16_t size; const char *name;/* [unique,length_is(length/2),charset(UTF16),size_is(size/2)] */ }; +/* bitmap winreg_NotifyChangeType */ +#define REG_NOTIFY_CHANGE_NAME ( 0x00000001 ) +#define REG_NOTIFY_CHANGE_ATTRIBUTES ( 0x00000002 ) +#define REG_NOTIFY_CHANGE_LAST_SET ( 0x00000004 ) +#define REG_NOTIFY_CHANGE_SECURITY ( 0x00000008 ) + struct KeySecurityAttribute { uint32_t data_size; struct KeySecurityData sec_data; @@ -262,7 +261,7 @@ struct winreg_EnumValue { struct { struct policy_handle *handle;/* [ref] */ uint32_t enum_index; - struct winreg_ValNameBuf *name;/* [ref] */ + struct winreg_StringBuf *name;/* [ref] */ enum winreg_Type *type;/* [unique] */ uint8_t *value;/* [unique,length_is(*length),size_is(*size)] */ uint32_t *size;/* [unique] */ @@ -270,7 +269,7 @@ struct winreg_EnumValue { } in; struct { - struct winreg_ValNameBuf *name;/* [ref] */ + struct winreg_StringBuf *name;/* [ref] */ enum winreg_Type *type;/* [unique] */ uint8_t *value;/* [unique,length_is(*length),size_is(*size)] */ uint32_t *size;/* [unique] */ @@ -383,16 +382,16 @@ struct winreg_QueryValue { struct policy_handle *handle;/* [ref] */ struct winreg_String *value_name;/* [ref] */ enum winreg_Type *type;/* [unique] */ - uint8_t *data;/* [unique,length_is(*value_length),size_is(*data_size)] */ + uint8_t *data;/* [unique,length_is(*data_length),size_is(*data_size)] */ uint32_t *data_size;/* [unique] */ - uint32_t *value_length;/* [unique] */ + uint32_t *data_length;/* [unique] */ } in; struct { enum winreg_Type *type;/* [unique] */ - uint8_t *data;/* [unique,length_is(*value_length),size_is(*data_size)] */ + uint8_t *data;/* [unique,length_is(*data_length),size_is(*data_size)] */ uint32_t *data_size;/* [unique] */ - uint32_t *value_length;/* [unique] */ + uint32_t *data_length;/* [unique] */ WERROR result; } out; @@ -438,7 +437,7 @@ struct winreg_SaveKey { struct winreg_SetKeySecurity { struct { struct policy_handle *handle;/* [ref] */ - uint32_t access_mask; + uint32_t sec_info; struct KeySecurityData *sd;/* [ref] */ } in; @@ -476,7 +475,7 @@ struct winreg_UnLoadKey { struct winreg_InitiateSystemShutdown { struct { uint16_t *hostname;/* [unique] */ - struct initshutdown_String *message;/* [unique] */ + struct lsa_StringLarge *message;/* [unique] */ uint32_t timeout; uint8_t force_apps; uint8_t do_reboot; @@ -564,7 +563,7 @@ struct winreg_QueryMultipleValues { struct winreg_InitiateSystemShutdownEx { struct { uint16_t *hostname;/* [unique] */ - struct initshutdown_String *message;/* [unique] */ + struct lsa_StringLarge *message;/* [unique] */ uint32_t timeout; uint8_t force_apps; uint8_t do_reboot; diff --git a/source3/librpc/gen_ndr/xattr.h b/source3/librpc/gen_ndr/xattr.h index b0b9db99c1..1d8da3f5e2 100644 --- a/source3/librpc/gen_ndr/xattr.h +++ b/source3/librpc/gen_ndr/xattr.h @@ -2,18 +2,75 @@ #include +#include "librpc/gen_ndr/security.h" #ifndef _HEADER_xattr #define _HEADER_xattr +#define XATTR_DOSATTRIB_NAME ( "user.DosAttrib" ) +#define XATTR_DOSATTRIB_ESTIMATED_SIZE ( 64 ) +#define XATTR_DOSEAS_NAME ( "user.DosEAs" ) +#define XATTR_DOSSTREAMS_NAME ( "user.DosStreams" ) +#define XATTR_STREAM_FLAG_INTERNAL ( 0x00000001 ) +#define XATTR_DOSSTREAM_PREFIX ( "user.DosStream." ) +#define XATTR_MAX_STREAM_SIZE ( 0x4000 ) +#define XATTR_MAX_STREAM_SIZE_TDB ( 0x100000 ) #define XATTR_NTACL_NAME ( "security.NTACL" ) -struct tdb_xattr { +struct xattr_DosInfo1 { + uint32_t attrib; + uint32_t ea_size; + uint64_t size; + uint64_t alloc_size; + NTTIME create_time; + NTTIME change_time; +}; + +struct xattr_DosInfo2Old { + uint32_t flags; + uint32_t attrib; + uint32_t ea_size; + uint64_t size; + uint64_t alloc_size; + NTTIME create_time; + NTTIME change_time; + NTTIME write_time; + const char * name;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ +}; + +union xattr_DosInfo { + struct xattr_DosInfo1 info1;/* [case] */ + struct xattr_DosInfo2Old oldinfo2;/* [case(2)] */ +}/* [switch_type(uint16)] */; + +struct xattr_DosAttrib { + uint16_t version; + union xattr_DosInfo info;/* [switch_is(version)] */ +}/* [public] */; + +struct xattr_EA { const char * name;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ DATA_BLOB value; +}; + +struct xattr_DosEAs { + uint16_t num_eas; + struct xattr_EA *eas;/* [unique,size_is(num_eas)] */ }/* [public] */; struct tdb_xattrs { - uint32_t num_xattrs; - struct tdb_xattr *xattrs; + uint32_t num_eas; + struct xattr_EA *eas; +}/* [public] */; + +struct xattr_DosStream { + uint32_t flags; + uint64_t size; + uint64_t alloc_size; + const char * name;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ +}; + +struct xattr_DosStreams { + uint32_t num_streams; + struct xattr_DosStream *streams;/* [unique,size_is(num_streams)] */ }/* [public] */; struct security_descriptor_timestamp { diff --git a/source3/librpc/idl/dfs.idl b/source3/librpc/idl/dfs.idl deleted file mode 100644 index a729b0e560..0000000000 --- a/source3/librpc/idl/dfs.idl +++ /dev/null @@ -1,417 +0,0 @@ -/* - dfs interface definition -*/ - -[ uuid("4fc742e0-4a10-11cf-8273-00aa004ae673"), - version(3.0), - pointer_default(unique), - helpstring("Settings for Microsoft Distributed File System"), - endpoint("ncacn_np:[\\pipe\\netdfs]", "ncacn_ip_tcp:", "ncalrpc:") -] interface netdfs -{ - /******************/ - /* Function: 0x00 */ - typedef [v1_enum] enum { - DFS_MANAGER_VERSION_NT4 = 1, - DFS_MANAGER_VERSION_W2K = 2, - DFS_MANAGER_VERSION_W2K3 = 4, - DFS_MANAGER_VERSION_W2K8 = 6 - } dfs_ManagerVersion; - - [public] void dfs_GetManagerVersion( - [out] dfs_ManagerVersion *version - ); - - - /******************/ - /* Function: 0x01 */ - WERROR dfs_Add ( - [in] [string,charset(UTF16)] uint16 *path, - [in] [string,charset(UTF16)] uint16 *server, - [in,unique] [string,charset(UTF16)] uint16 *share, - [in,unique] [string,charset(UTF16)] uint16 *comment, - [in] uint32 flags - ); - - /******************/ - /* Function: 0x02 */ - WERROR dfs_Remove ( - [in] [string,charset(UTF16)] uint16 *dfs_entry_path, - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in,unique] [string,charset(UTF16)] uint16 *sharename - ); - - /******************/ - /* Function: 0x03 */ - - typedef struct { - } dfs_Info0; - - typedef struct { - [string,charset(UTF16)] uint16 *path; - } dfs_Info1; - - typedef [public,bitmap32bit] bitmap { - DFS_VOLUME_STATE_OK = 0x1, - DFS_VOLUME_STATE_INCONSISTENT = 0x2, - DFS_VOLUME_STATE_OFFLINE = 0x3, - DFS_VOLUME_STATE_ONLINE = 0x4, - DFS_VOLUME_STATE_STANDALONE = DFS_VOLUME_FLAVOR_STANDALONE, - DFS_VOLUME_STATE_AD_BLOB = DFS_VOLUME_FLAVOR_AD_BLOB - } dfs_VolumeState; - - typedef struct { - [string,charset(UTF16)] uint16 *path; - [string,charset(UTF16)] uint16 *comment; - dfs_VolumeState state; - uint32 num_stores; - } dfs_Info2; - - const int DFS_STORAGE_STATES = 0xf; - - /* yes, this is a bitmap */ - typedef [public,bitmap32bit] bitmap { - DFS_STORAGE_STATE_OFFLINE = 1, - DFS_STORAGE_STATE_ONLINE = 2, - DFS_STORAGE_STATE_ACTIVE = 4 - } dfs_StorageState; - - typedef struct { - dfs_StorageState state; - [string,charset(UTF16)] uint16 *server; - [string,charset(UTF16)] uint16 *share; - } dfs_StorageInfo; - - typedef struct { - [string,charset(UTF16)] uint16 *path; - [string,charset(UTF16)] uint16 *comment; - dfs_VolumeState state; - uint32 num_stores; - [size_is(num_stores)] dfs_StorageInfo *stores; - } dfs_Info3; - - typedef struct { - [string,charset(UTF16)] uint16 *path; - [string,charset(UTF16)] uint16 *comment; - dfs_VolumeState state; - uint32 timeout; - GUID guid; - uint32 num_stores; - [size_is(num_stores)] dfs_StorageInfo *stores; - } dfs_Info4; - - /* verified with dfsutil */ - typedef [public,bitmap32bit] bitmap { - DFS_PROPERTY_FLAG_INSITE_REFERRALS = 0x01, - DFS_PROPERTY_FLAG_ROOT_SCALABILITY = 0x02, - DFS_PROPERTY_FLAG_SITE_COSTING = 0x04, - DFS_PROPERTY_FLAG_TARGET_FAILBACK = 0x08, - DFS_PROPERTY_FLAG_CLUSTER_ENABLED = 0x10 /* untested */ - } dfs_PropertyFlags; - - typedef struct { - [string,charset(UTF16)] uint16 *path; - [string,charset(UTF16)] uint16 *comment; - dfs_VolumeState state; - uint32 timeout; - GUID guid; - dfs_PropertyFlags flags; - uint32 pktsize; - uint32 num_stores; - } dfs_Info5; - - typedef [v1_enum] enum { - DFS_INVALID_PRIORITY_CLASS = -1, - DFS_SITE_COST_NORMAL_PRIORITY_CLASS = 0, - DFS_GLOBAL_HIGH_PRIORITY_CLASS = 1, - DFS_SITE_COST_HIGH_PRIORITY_CLASS = 2, - DFS_SITE_COST_LOW_PRIORITY_CLASS = 3, - DFS_GLOBAL_LOW_PRIORITY_CLASS = 4 - } dfs_Target_PriorityClass; - - typedef struct { - dfs_Target_PriorityClass target_priority_class; - uint16 target_priority_rank; - uint16 reserved; - } dfs_Target_Priority; - - typedef struct { - dfs_StorageInfo info; - dfs_Target_Priority target_priority; - } dfs_StorageInfo2; - - typedef struct { - [string,charset(UTF16)] uint16 *entry_path; - [string,charset(UTF16)] uint16 *comment; - dfs_VolumeState state; - uint32 timeout; - GUID guid; - dfs_PropertyFlags flags; - uint32 pktsize; - uint16 num_stores; - [size_is(num_stores)] dfs_StorageInfo2 *stores; - } dfs_Info6; - - typedef struct { - GUID generation_guid; - } dfs_Info7; - - typedef struct { - [string,charset(UTF16)] uint16 *comment; - } dfs_Info100; - - typedef struct { - dfs_StorageState state; - } dfs_Info101; - - typedef struct { - uint32 timeout; - } dfs_Info102; - - typedef struct { - dfs_PropertyFlags flags; - } dfs_Info103; - - typedef struct { - dfs_Target_Priority priority; - } dfs_Info104; - - typedef struct { - [string,charset(UTF16)] uint16 *comment; - dfs_VolumeState state; - uint32 timeout; - uint32 property_flag_mask; - uint32 property_flags; - } dfs_Info105; - - typedef struct { - dfs_StorageState state; - dfs_Target_Priority priority; - } dfs_Info106; - - typedef struct { - [string,charset(UTF16)] uint16 *dom_root; - } dfs_Info200; - - typedef enum { - DFS_VOLUME_FLAVOR_STANDALONE = 0x100, - DFS_VOLUME_FLAVOR_AD_BLOB = 0x200 - } dfs_VolumeFlavor; - - typedef struct { - dfs_VolumeFlavor flavor; - [string,charset(UTF16)] uint16 *dom_root; - } dfs_Info300; - - typedef union { - [case(0)] dfs_Info0 *info0; - [case(1)] dfs_Info1 *info1; - [case(2)] dfs_Info2 *info2; - [case(3)] dfs_Info3 *info3; - [case(4)] dfs_Info4 *info4; - [case(5)] dfs_Info5 *info5; - [case(6)] dfs_Info6 *info6; - [case(7)] dfs_Info7 *info7; - [case(100)] dfs_Info100 *info100; - [case(101)] dfs_Info101 *info101; - [case(102)] dfs_Info102 *info102; - [case(103)] dfs_Info103 *info103; - [case(104)] dfs_Info104 *info104; - [case(105)] dfs_Info105 *info105; - [case(106)] dfs_Info106 *info106; - } dfs_Info; - - WERROR dfs_SetInfo ( - [in] [string,charset(UTF16)] uint16 dfs_entry_path[], - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in,unique] [string,charset(UTF16)] uint16 *sharename, - [in] uint32 level, - [in,ref,switch_is(level)] dfs_Info *info - ); - - /******************/ - /* Function: 0x04 */ - WERROR dfs_GetInfo ( - [in] [string,charset(UTF16)] uint16 dfs_entry_path[], - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in,unique] [string,charset(UTF16)] uint16 *sharename, - [in] uint32 level, - [out,switch_is(level)] dfs_Info *info - ); - - /******************/ - /* Function: 0x05 */ - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info1 *s; - } dfs_EnumArray1; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info2 *s; - } dfs_EnumArray2; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info3 *s; - } dfs_EnumArray3; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info4 *s; - } dfs_EnumArray4; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info5 *s; - } dfs_EnumArray5; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info6 *s; - } dfs_EnumArray6; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info200 *s; - } dfs_EnumArray200; - - typedef struct { - uint32 count; - [size_is(count)] dfs_Info300 *s; - } dfs_EnumArray300; - - - typedef union { - [case(1)] dfs_EnumArray1 *info1; - [case(2)] dfs_EnumArray2 *info2; - [case(3)] dfs_EnumArray3 *info3; - [case(4)] dfs_EnumArray4 *info4; - [case(5)] dfs_EnumArray5 *info5; - [case(6)] dfs_EnumArray6 *info6; - [case(200)] dfs_EnumArray200 *info200; - [case(300)] dfs_EnumArray300 *info300; - } dfs_EnumInfo; - - typedef struct { - uint32 level; - [switch_is(level)] dfs_EnumInfo e; - } dfs_EnumStruct; - - WERROR dfs_Enum ( - [in] uint32 level, - [in] uint32 bufsize, - [in,out,unique] dfs_EnumStruct *info, - [in,out,unique] uint32 *total - ); - - /* Function 0x06 */ - WERROR dfs_Rename(); - - /* Function 0x07 */ - WERROR dfs_Move(); - - /* Function 0x08 */ - WERROR dfs_ManagerGetConfigInfo(); - - /* Function 0x09 */ - WERROR dfs_ManagerSendSiteInfo(); - - /* Function 0x0a */ - typedef struct { - uint32 unknown1; - [string,charset(UTF16)] uint16 *unknown2; - } dfs_UnknownStruct; - - WERROR dfs_AddFtRoot( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 dns_servername[], - [in] [string,charset(UTF16)] uint16 dfsname[], - [in] [string,charset(UTF16)] uint16 rootshare[], - [in] [string,charset(UTF16)] uint16 comment[], - [in] [string,charset(UTF16)] uint16 dfs_config_dn[], - [in] uint8 unknown1, - [in] uint32 flags, - [in,out,unique] dfs_UnknownStruct **unknown2 - ); - - /* Function 0x0b */ - WERROR dfs_RemoveFtRoot( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 dns_servername[], - [in] [string,charset(UTF16)] uint16 dfsname[], - [in] [string,charset(UTF16)] uint16 rootshare[], - [in] uint32 flags, - [in,out,unique] dfs_UnknownStruct **unknown - ); - - /* Function 0x0c */ - WERROR dfs_AddStdRoot( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 rootshare[], - [in] [string,charset(UTF16)] uint16 comment[], - [in] uint32 flags - ); - - /* Function 0x0d */ - WERROR dfs_RemoveStdRoot( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 rootshare[], - [in] uint32 flags - ); - - /* Function 0x0e */ - WERROR dfs_ManagerInitialize( - [in] [string,charset(UTF16)] uint16 *servername, - [in] uint32 flags - ); - - /* Function 0x0f */ - WERROR dfs_AddStdRootForced( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 rootshare[], - [in] [string,charset(UTF16)] uint16 comment[], - [in] [string,charset(UTF16)] uint16 store[] /* C:\\whatever */ - ); - - /* Function 0x10 */ - WERROR dfs_GetDcAddress( - [in] [string,charset(UTF16)] uint16 servername[], - [in,out,ref] [string,charset(UTF16)] uint16 **server_fullname, - [in,out,ref] boolean8 *is_root, - [in,out,ref] uint32 *ttl - ); - - /* Function 0x11 */ - WERROR dfs_SetDcAddress( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 server_fullname[], - [in] uint32 flags, - [in] uint32 ttl - ); - - /* Function 0x12 */ - WERROR dfs_FlushFtTable( - [in] [string,charset(UTF16)] uint16 servername[], - [in] [string,charset(UTF16)] uint16 rootshare[] - ); - - /* Function 0x13 */ - WERROR dfs_Add2(); - - /* Function 0x14 */ - WERROR dfs_Remove2(); - - /* Function 0x15 */ - [public] WERROR dfs_EnumEx( - [in] [string,charset(UTF16)] uint16 dfs_name[], - [in] uint32 level, - [in] uint32 bufsize, - [in,out,unique] dfs_EnumStruct *info, - [in,out,unique] uint32 *total - ); - - /* Function 0x16 */ - WERROR dfs_SetInfo2(); -} diff --git a/source3/librpc/idl/drsblobs.idl b/source3/librpc/idl/drsblobs.idl deleted file mode 100644 index 6fdca0ec43..0000000000 --- a/source3/librpc/idl/drsblobs.idl +++ /dev/null @@ -1,436 +0,0 @@ -#include "idl_types.h" - -import "drsuapi.idl", "misc.idl"; - -[ - uuid("12345778-1234-abcd-0001-00000001"), - version(0.0), - pointer_default(unique), - helpstring("Active Directory Replication LDAP Blobs") -] -interface drsblobs { - typedef bitmap drsuapi_DsReplicaSyncOptions drsuapi_DsReplicaSyncOptions; - typedef bitmap drsuapi_DsReplicaNeighbourFlags drsuapi_DsReplicaNeighbourFlags; - typedef [v1_enum] enum drsuapi_DsAttributeId drsuapi_DsAttributeId; - - /* - * replPropertyMetaData - * w2k uses version 1 - * w2k3 uses version 1 - */ - typedef struct { - drsuapi_DsAttributeId attid; - uint32 version; - NTTIME_1sec originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - } replPropertyMetaData1; - - typedef struct { - uint32 count; - uint32 reserved; - replPropertyMetaData1 array[count]; - } replPropertyMetaDataCtr1; - - typedef [nodiscriminant] union { - [case(1)] replPropertyMetaDataCtr1 ctr1; - } replPropertyMetaDataCtr; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] replPropertyMetaDataCtr ctr; - } replPropertyMetaDataBlob; - - void decode_replPropertyMetaData( - [in] replPropertyMetaDataBlob blob - ); - - /* - * replUpToDateVector - * w2k uses version 1 - * w2k3 uses version 2 - */ - typedef struct { - uint32 count; - uint32 reserved; - drsuapi_DsReplicaCursor cursors[count]; - } replUpToDateVectorCtr1; - - typedef struct { - uint32 count; - uint32 reserved; - drsuapi_DsReplicaCursor2 cursors[count]; - } replUpToDateVectorCtr2; - - typedef [nodiscriminant] union { - [case(1)] replUpToDateVectorCtr1 ctr1; - [case(2)] replUpToDateVectorCtr2 ctr2; - } replUpToDateVectorCtr; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] replUpToDateVectorCtr ctr; - } replUpToDateVectorBlob; - - void decode_replUpToDateVector( - [in] replUpToDateVectorBlob blob - ); - - /* - * repsFrom/repsTo - * w2k uses version 1 - * w2k3 uses version 1 - */ - typedef [public,gensize] struct { - [value(strlen(dns_name)+1)] uint32 __dns_name_size; - [charset(DOS)] uint8 dns_name[__dns_name_size]; - } repsFromTo1OtherInfo; - - typedef [public,gensize,flag(NDR_PAHEX)] struct { - /* this includes the 8 bytes of the repsFromToBlob header */ - [value(ndr_size_repsFromTo1(this, ndr->flags)+8)] uint32 blobsize; - uint32 consecutive_sync_failures; - NTTIME_1sec last_success; - NTTIME_1sec last_attempt; - WERROR result_last_attempt; - [relative] repsFromTo1OtherInfo *other_info; - [value(ndr_size_repsFromTo1OtherInfo(other_info, ndr->flags))] uint32 other_info_length; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint8 schedule[84]; - uint32 reserved; - drsuapi_DsReplicaHighWaterMark highwatermark; - GUID source_dsa_obj_guid; /* the 'objectGuid' field of the CN=NTDS Settings object */ - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - GUID transport_guid; - } repsFromTo1; - - typedef [nodiscriminant] union { - [case(1)] repsFromTo1 ctr1; - } repsFromTo; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] repsFromTo ctr; - } repsFromToBlob; - - void decode_repsFromTo( - [in] repsFromToBlob blob - ); - - /* - * partialAttributeSet - * w2k uses version 1 - * w2k3 uses version 1 - */ - typedef struct { - uint32 count; - drsuapi_DsAttributeId array[count]; - } partialAttributeSetCtr1; - - typedef [nodiscriminant] union { - [case(1)] partialAttributeSetCtr1 ctr1; - } partialAttributeSetCtr; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] partialAttributeSetCtr ctr; - } partialAttributeSetBlob; - - void decode_partialAttributeSet( - [in] partialAttributeSetBlob blob - ); - - /* - * prefixMap - * w2k unknown - * w2k3 unknown - * samba4 uses 0x44534442 'DSDB' - * - * as we windows don't return the prefixMap attribute when you ask for - * we don't know the format, but the attribute is not replicated - * so that we can choose our own format... - */ - typedef [v1_enum] enum { - PREFIX_MAP_VERSION_DSDB = 0x44534442 - } prefixMapVersion; - - typedef [nodiscriminant] union { - [case(PREFIX_MAP_VERSION_DSDB)] drsuapi_DsReplicaOIDMapping_Ctr dsdb; - } prefixMapCtr; - - typedef [public] struct { - prefixMapVersion version; - uint32 reserved; - [switch_is(version)] prefixMapCtr ctr; - } prefixMapBlob; - - void decode_prefixMap( - [in] prefixMapBlob blob - ); - - /* - * the cookie for the LDAP dirsync control - */ - typedef [nodiscriminant,gensize] union { - [case(0)]; - [default] replUpToDateVectorBlob uptodateness_vector; - } ldapControlDirSyncExtra; - - typedef struct { - [value(3)] uint32 u1; - NTTIME time; - uint32 u2; - uint32 u3; - [value(ndr_size_ldapControlDirSyncExtra(&extra, extra.uptodateness_vector.version, 0))] - uint32 extra_length; - drsuapi_DsReplicaHighWaterMark highwatermark; - GUID guid1; - [switch_is(extra_length)] ldapControlDirSyncExtra extra; - } ldapControlDirSyncBlob; - - typedef [public,relative_base] struct { - [charset(DOS),value("MSDS")] uint8 msds[4]; - [subcontext(0)] ldapControlDirSyncBlob blob; - } ldapControlDirSyncCookie; - - void decode_ldapControlDirSync( - [in] ldapControlDirSyncCookie cookie - ); - - typedef struct { - [value(2*strlen_m(name))] uint16 name_len; - [value(strlen(data))] uint16 data_len; - uint16 reserved; /* 2 for 'Packages', 1 for 'Primary:*', but should be ignored */ - [charset(UTF16)] uint8 name[name_len]; - /* - * the data field contains data as HEX strings - * - * 'Packages': - * data contains the list of packages - * as non termiated UTF16 strings with - * a UTF16 NULL byte as separator - * - * 'Primary:Kerberos-Newer-Keys': - * ... - * - * 'Primary:Kerberos': - * ... - * - * 'Primary:WDigest': - * ... - * - * 'Primary:CLEARTEXT': - * data contains the cleartext password - * as UTF16 string encoded as HEX string - */ - [charset(DOS)] uint8 data[data_len]; - } supplementalCredentialsPackage; - - /* this are 0x30 (48) whitespaces (0x20) */ - const string SUPPLEMENTAL_CREDENTIALS_PREFIX = " "; - - typedef [flag(NDR_PAHEX)] enum { - SUPPLEMENTAL_CREDENTIALS_SIGNATURE = 0x0050 - } supplementalCredentialsSignature; - - typedef [gensize] struct { - [value(SUPPLEMENTAL_CREDENTIALS_PREFIX),charset(UTF16)] uint16 prefix[0x30]; - [value(SUPPLEMENTAL_CREDENTIALS_SIGNATURE)] supplementalCredentialsSignature signature; - uint16 num_packages; - supplementalCredentialsPackage packages[num_packages]; - } supplementalCredentialsSubBlob; - - typedef [public] struct { - [value(0)] uint32 unknown1; - [value(ndr_size_supplementalCredentialsSubBlob(&sub, ndr->flags))] uint32 __ndr_size; - [value(0)] uint32 unknown2; - [subcontext(0),subcontext_size(__ndr_size)] supplementalCredentialsSubBlob sub; - [value(0)] uint8 unknown3; - } supplementalCredentialsBlob; - - void decode_supplementalCredentials( - [in] supplementalCredentialsBlob blob - ); - - typedef [public] struct { - [flag(STR_NOTERM|NDR_REMAINING)] string_array names; - } package_PackagesBlob; - - void decode_Packages( - [in] package_PackagesBlob blob - ); - - typedef struct { - [value(2*strlen_m(string))] uint16 length; - [value(2*strlen_m(string))] uint16 size; - [relative,subcontext(0),subcontext_size(size),flag(STR_NOTERM|NDR_REMAINING)] string *string; - } package_PrimaryKerberosString; - - typedef struct { - [value(0)] uint16 reserved1; - [value(0)] uint16 reserved2; - [value(0)] uint32 reserved3; - uint32 keytype; - [value((value?value->length:0))] uint32 value_len; - [relative,subcontext(0),subcontext_size(value_len),flag(NDR_REMAINING)] DATA_BLOB *value; - } package_PrimaryKerberosKey3; - - typedef struct { - uint16 num_keys; - uint16 num_old_keys; - package_PrimaryKerberosString salt; - package_PrimaryKerberosKey3 keys[num_keys]; - package_PrimaryKerberosKey3 old_keys[num_old_keys]; - [value(0)] uint32 padding1; - [value(0)] uint32 padding2; - [value(0)] uint32 padding3; - [value(0)] uint32 padding4; - [value(0)] uint32 padding5; - } package_PrimaryKerberosCtr3; - - typedef struct { - [value(0)] uint16 reserved1; - [value(0)] uint16 reserved2; - [value(0)] uint32 reserved3; - uint32 iteration_count; - uint32 keytype; - [value((value?value->length:0))] uint32 value_len; - [relative,subcontext(0),subcontext_size(value_len),flag(NDR_REMAINING)] DATA_BLOB *value; - } package_PrimaryKerberosKey4; - - typedef struct { - uint16 num_keys; - [value(0)] uint16 num_service_keys; - uint16 num_old_keys; - uint16 num_older_keys; - package_PrimaryKerberosString salt; - uint32 default_iteration_count; - package_PrimaryKerberosKey4 keys[num_keys]; - package_PrimaryKerberosKey4 service_keys[num_service_keys]; - package_PrimaryKerberosKey4 old_keys[num_old_keys]; - package_PrimaryKerberosKey4 older_keys[num_older_keys]; - } package_PrimaryKerberosCtr4; - - typedef [nodiscriminant] union { - [case(3)] package_PrimaryKerberosCtr3 ctr3; - [case(4)] package_PrimaryKerberosCtr4 ctr4; - } package_PrimaryKerberosCtr; - - typedef [public] struct { - uint16 version; - [value(0)] uint16 flags; - [switch_is(version)] package_PrimaryKerberosCtr ctr; - } package_PrimaryKerberosBlob; - - void decode_PrimaryKerberos( - [in] package_PrimaryKerberosBlob blob - ); - - typedef [public] struct { - [flag(STR_NOTERM|NDR_REMAINING)] string cleartext; - } package_PrimaryCLEARTEXTBlob; - - void decode_PrimaryCLEARTEXT( - [in] package_PrimaryCLEARTEXTBlob blob - ); - - typedef [flag(NDR_PAHEX)] struct { - uint8 hash[16]; - } package_PrimaryWDigestHash; - - typedef [public] struct { - [value(0x31)] uint16 unknown1; - [value(0x01)] uint8 unknown2; - uint8 num_hashes; - [value(0)] uint32 unknown3; - [value(0)] udlong uuknown4; - package_PrimaryWDigestHash hashes[num_hashes]; - } package_PrimaryWDigestBlob; - - void decode_PrimaryWDigest( - [in] package_PrimaryWDigestBlob blob - ); - - typedef struct { - NTTIME time1; - uint32 unknown1; - /* - * the secret value is encoded as UTF16 if it's a string - * but krb5 trusts have random bytes here, so converting to UTF16 - * mayfail... - * - * TODO: We should try handle the case of a random buffer in all places - * we deal with cleartext passwords from windows - * - * so we don't use this: - * - * uint32 value_len; - * [charset(UTF16)] uint8 value[value_len]; - */ - DATA_BLOB value; - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - } trustAuthInOutSecret1; - - typedef struct { - [relative] trustAuthInOutSecret1 *value1; - [relative] trustAuthInOutSecret1 *value2; - } trustAuthInOutCtr1; - - typedef struct { - NTTIME time1; - uint32 unknown1; - DATA_BLOB value; - NTTIME time2; - uint32 unknown2; - uint32 unknown3; - uint32 unknown4; - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - } trustAuthInOutSecret2V1; - - typedef struct { - NTTIME time1; - uint32 unknown1; - DATA_BLOB value; - NTTIME time2; - uint32 unknown2; - uint32 unknown3; - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - } trustAuthInOutSecret2V2; - - typedef struct { - [relative] trustAuthInOutSecret2V1 *value1; - [relative] trustAuthInOutSecret2V2 *value2; - } trustAuthInOutCtr2; - - typedef [nodiscriminant] union { - [case(1)] trustAuthInOutCtr1 ctr1; - [case(2)] trustAuthInOutCtr2 ctr2; - } trustAuthInOutCtr; - - typedef [public] struct { - uint32 version; - [switch_is(version)] trustAuthInOutCtr ctr; - } trustAuthInOutBlob; - - void decode_trustAuthInOut( - [in] trustAuthInOutBlob blob - ); - - typedef [public] struct { - uint32 marker; - DATA_BLOB data; - } DsCompressedChunk; - - typedef [public] struct { - DsCompressedChunk chunks[5]; - } DsCompressedBlob; - - void decode_DsCompressed( - [in] DsCompressedBlob blob - ); -} diff --git a/source3/librpc/idl/dssetup.idl b/source3/librpc/idl/dssetup.idl deleted file mode 100644 index af6350cc43..0000000000 --- a/source3/librpc/idl/dssetup.idl +++ /dev/null @@ -1,101 +0,0 @@ -/* - dssetup interface definition -*/ - -import "misc.idl"; - -[ - uuid("3919286a-b10c-11d0-9ba8-00c04fd92ef5"), - version(0.0), - endpoint("ncacn_np:[\\pipe\\lsarpc]", "ncacn_np:[\\pipe\\lsass]", "ncacn_ip_tcp:", "ncalrpc:"), - pointer_default(unique), - helpstring("Active Directory Setup") -] interface dssetup -{ - /**********************************************/ - /* Function 0x00 */ - - typedef enum { - DS_ROLE_STANDALONE_WORKSTATION = 0, - DS_ROLE_MEMBER_WORKSTATION = 1, - DS_ROLE_STANDALONE_SERVER = 2, - DS_ROLE_MEMBER_SERVER = 3, - DS_ROLE_BACKUP_DC = 4, - DS_ROLE_PRIMARY_DC = 5 - } dssetup_DsRole; - - typedef [bitmap32bit] bitmap { - DS_ROLE_PRIMARY_DS_RUNNING = 0x00000001, - DS_ROLE_PRIMARY_DS_MIXED_MODE = 0x00000002, - DS_ROLE_UPGRADE_IN_PROGRESS = 0x00000004, - DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT = 0x01000000 - } dssetup_DsRoleFlags; - - typedef struct { - dssetup_DsRole role; - dssetup_DsRoleFlags flags; - [charset(UTF16),string] uint16 *domain; - [charset(UTF16),string] uint16 *dns_domain; - [charset(UTF16),string] uint16 *forest; - GUID domain_guid; - } dssetup_DsRolePrimaryDomInfoBasic; - - typedef [v1_enum] enum { - DS_ROLE_NOT_UPGRADING = 0, - DS_ROLE_UPGRADING = 1 - } dssetup_DsUpgrade; - - typedef enum { - DS_ROLE_PREVIOUS_UNKNOWN = 0, - DS_ROLE_PREVIOUS_PRIMARY = 1, - DS_ROLE_PREVIOUS_BACKUP = 2 - } dssetup_DsPrevious; - - typedef struct { - dssetup_DsUpgrade upgrading; - dssetup_DsPrevious previous_role; - } dssetup_DsRoleUpgradeStatus; - - typedef enum { - DS_ROLE_OP_IDLE = 0, - DS_ROLE_OP_ACTIVE = 1, - DS_ROLE_OP_NEEDS_REBOOT = 2 - } dssetup_DsRoleOp; - - typedef struct { - dssetup_DsRoleOp status; - } dssetup_DsRoleOpStatus; - - typedef enum { - DS_ROLE_BASIC_INFORMATION = 1, - DS_ROLE_UPGRADE_STATUS = 2, - DS_ROLE_OP_STATUS = 3 - } dssetup_DsRoleInfoLevel; - - typedef [switch_type(dssetup_DsRoleInfoLevel)] union { - [case(DS_ROLE_BASIC_INFORMATION)] dssetup_DsRolePrimaryDomInfoBasic basic; - [case(DS_ROLE_UPGRADE_STATUS)] dssetup_DsRoleUpgradeStatus upgrade; - [case(DS_ROLE_OP_STATUS)] dssetup_DsRoleOpStatus opstatus; - } dssetup_DsRoleInfo; - - WERROR dssetup_DsRoleGetPrimaryDomainInformation( - [in] dssetup_DsRoleInfoLevel level, - [out,switch_is(level),unique] dssetup_DsRoleInfo *info - ); - - /* - w2k3 has removed all the calls below from their implementation. - These stubs are left here only as a way of documenting the names - of the calls in case they ever turn up on the wire. - */ - WERROR dssetup_DsRoleDnsNameToFlatName(); - WERROR dssetup_DsRoleDcAsDc(); - WERROR dssetup_DsRoleDcAsReplica(); - WERROR dssetup_DsRoleDemoteDc(); - WERROR dssetup_DsRoleGetDcOperationProgress(); - WERROR dssetup_DsRoleGetDcOperationResults(); - WERROR dssetup_DsRoleCancel(); - WERROR dssetup_DsRoleServerSaveStateForUpgrade(); - WERROR dssetup_DsRoleUpgradeDownlevelServer(); - WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(); -} diff --git a/source3/librpc/idl/echo.idl b/source3/librpc/idl/echo.idl deleted file mode 100644 index 5ea37f1ac1..0000000000 --- a/source3/librpc/idl/echo.idl +++ /dev/null @@ -1,127 +0,0 @@ - -[ - uuid("60a15ec5-4de8-11d7-a637-005056a20182"), - endpoint("ncacn_np:[\\pipe\\rpcecho]", "ncacn_ip_tcp:", "ncalrpc:"), - pointer_default(unique), - version(1.0), - helpstring("Simple echo pipe") -] -interface rpcecho -{ - /* Add one to an integer */ - void echo_AddOne( - [in] uint32 in_data, - [out] uint32 *out_data - ); - /* Echo an array of bytes back at the caller */ - void echo_EchoData( - [in] uint32 len, - [in] [size_is(len)] uint8 in_data[], - [out] [size_is(len)] uint8 out_data[] - ); - /* Sink data to the server */ - void echo_SinkData( - [in] uint32 len, - [in,size_is(len)] uint8 data[] - ); - /* Source data from server */ - void echo_SourceData( - [in] uint32 len, - [out,size_is(len)] uint8 data[] - ); - - /* test strings */ - void echo_TestCall ( - [in,string,charset(UTF16)] uint16 *s1, - [out,string,charset(UTF16)] uint16 **s2 - ); - - - /* test some alignment issues */ - typedef struct { - uint8 v; - } echo_info1; - - typedef struct { - uint16 v; - } echo_info2; - - typedef struct { - uint32 v; - } echo_info3; - - struct echo_info4 { - hyper v; - }; - - typedef struct { - uint8 v1; - hyper v2; - } echo_info5; - - typedef struct { - uint8 v1; - echo_info1 info1; - } echo_info6; - - typedef struct { - uint8 v1; - struct echo_info4 info4; - } echo_info7; - - typedef [switch_type(uint16)] union { - [case(1)] echo_info1 info1; - [case(2)] echo_info2 info2; - [case(3)] echo_info3 info3; - [case(4)] struct echo_info4 info4; - [case(5)] echo_info5 info5; - [case(6)] echo_info6 info6; - [case(7)] echo_info7 info7; - } echo_Info; - - NTSTATUS echo_TestCall2 ( - [in] uint16 level, - [out,switch_is(level)] echo_Info *info - ); - - uint32 echo_TestSleep( - [in] uint32 seconds - ); - - typedef enum { - ECHO_ENUM1 = 1, - ECHO_ENUM2 = 2 - } echo_Enum1; - - typedef [v1_enum] enum { - ECHO_ENUM1_32 = 1, - ECHO_ENUM2_32 = 2 - } echo_Enum1_32; - - typedef struct { - echo_Enum1 e1; - echo_Enum1_32 e2; - } echo_Enum2; - - typedef [switch_type(uint16)] union { - [case(ECHO_ENUM1)] echo_Enum1 e1; - [case(ECHO_ENUM2)] echo_Enum2 e2; - } echo_Enum3; - - void echo_TestEnum( - [in,out,ref] echo_Enum1 *foo1, - [in,out,ref] echo_Enum2 *foo2, - [in,out,ref,switch_is(*foo1)] echo_Enum3 *foo3 - ); - - typedef struct { - uint32 x; - [size_is(x)] uint16 surrounding[*]; - } echo_Surrounding; - - void echo_TestSurrounding( - [in,out,ref] echo_Surrounding *data - ); - - uint16 echo_TestDoublePointer([in] uint16 ***data); -} diff --git a/source3/librpc/idl/epmapper.idl b/source3/librpc/idl/epmapper.idl deleted file mode 100644 index 5611c3de18..0000000000 --- a/source3/librpc/idl/epmapper.idl +++ /dev/null @@ -1,302 +0,0 @@ -#include "idl_types.h" - -/* - endpoint mapper interface - Related links: - http://www.opengroup.org/onlinepubs/9629399/apdxl.htm : Details on towers -http://www.opengroup.org/onlinepubs/9629399/chap6.htm#tagcjh_11_02_03_01: binding strings - -*/ - -[ - uuid("e1af8308-5d1f-11c9-91a4-08002b14a0fa"), - version(3.0), - endpoint("ncacn_np:[\\pipe\\epmapper]", "ncacn_ip_tcp:[135]", - "ncalrpc:[EPMAPPER]"), - helpstring("EndPoint Mapper"), - pointer_default(ptr) -] -interface epmapper -{ - - /* - note that the following IDL won't work in MIDL, and in fact - that the full towers/floors representation of epm cannot be - represented in MIDL at all. I decided to represent it using - the extended IDL syntax in pidl to make it easier to work - with. - */ - - const int EPMAPPER_STATUS_NO_MORE_ENTRIES = 0x16c9a0d6; - const int EPMAPPER_STATUS_NO_MEMORY = 0x16C9A012; - const int EPMAPPER_STATUS_OK = 0; - - - - typedef [enum8bit] enum { - - /* Level 4 and higher */ - EPM_PROTOCOL_DNET_NSP = 0x04, - EPM_PROTOCOL_OSI_TP4 = 0x05, - EPM_PROTOCOL_OSI_CLNS = 0x06, - EPM_PROTOCOL_TCP = 0x07, - EPM_PROTOCOL_UDP = 0x08, - EPM_PROTOCOL_IP = 0x09, - /* These 4 are protocol identifiers, always at level 3 or lower */ - EPM_PROTOCOL_NCADG = 0x0a, /* Connectionless RPC */ - EPM_PROTOCOL_NCACN = 0x0b, - EPM_PROTOCOL_NCALRPC = 0x0c, /* Local RPC */ - EPM_PROTOCOL_UUID = 0x0d, - EPM_PROTOCOL_IPX = 0x0e, - EPM_PROTOCOL_SMB = 0x0f, - EPM_PROTOCOL_PIPE = 0x10, - EPM_PROTOCOL_NETBIOS = 0x11, - EPM_PROTOCOL_NETBEUI = 0x12, - EPM_PROTOCOL_SPX = 0x13, - EPM_PROTOCOL_NB_IPX = 0x14, /* NetBIOS over IPX */ - EPM_PROTOCOL_DSP = 0x16, /* AppleTalk Data Stream Protocol */ - EPM_PROTOCOL_DDP = 0x17, /* AppleTalk Data Datagram Protocol */ - EPM_PROTOCOL_APPLETALK = 0x18, /* AppleTalk */ - EPM_PROTOCOL_VINES_SPP = 0x1a, - EPM_PROTOCOL_VINES_IPC = 0x1b, /* Inter Process Communication */ - EPM_PROTOCOL_STREETTALK = 0x1c, /* Vines Streettalk */ - EPM_PROTOCOL_HTTP = 0x1f, - EPM_PROTOCOL_UNIX_DS = 0x20, /* Unix domain socket */ - EPM_PROTOCOL_NULL = 0x21 - } epm_protocol; - - typedef struct { - /*FIXME */ - } epm_rhs_dnet_nsp; - - typedef struct { - /*FIXME*/ - } epm_rhs_osi_tp4; - - typedef struct { - /*FIXME*/ - } epm_rhs_osi_clns; - - typedef struct { - uint16 port; - } epm_rhs_udp; - - typedef struct { - uint16 port; - } epm_rhs_tcp; - - typedef struct { - ipv4address ipaddr; - } epm_rhs_ip; - - typedef struct { - uint16 minor_version; - } epm_rhs_ncadg; - - typedef struct { - uint16 minor_version; - } epm_rhs_ncacn; - - typedef struct { - [flag(NDR_REMAINING)] DATA_BLOB unknown; - } epm_rhs_uuid; - - typedef struct { - /*FIXME */ - } epm_rhs_ipx; - - typedef struct { - astring unc; - } epm_rhs_smb; - - typedef struct { - astring path; - } epm_rhs_pipe; - - typedef struct { - astring name; - } epm_rhs_netbios; - - typedef struct { - } epm_rhs_netbeui; - - typedef struct { - } epm_rhs_spx; - - typedef struct { - } epm_rhs_nb_ipx; - - typedef struct { - uint16 port; - } epm_rhs_http; - - typedef struct { - astring path; - } epm_rhs_unix_ds; - - typedef struct { - } epm_rhs_null; - - typedef struct { - uint16 minor_version; - } epm_rhs_ncalrpc; - - typedef struct { - } epm_rhs_appletalk; - - typedef struct { - } epm_rhs_atalk_stream; - - typedef struct { - } epm_rhs_atalk_datagram; - - typedef struct { - uint16 port; - } epm_rhs_vines_spp; - - typedef struct { - uint16 port; - } epm_rhs_vines_ipc; - - typedef struct { - astring streettalk; - } epm_rhs_streettalk; - - typedef [flag(NDR_BIG_ENDIAN),nodiscriminant] union { - [case(EPM_PROTOCOL_DNET_NSP)] epm_rhs_dnet_nsp dnet_nsp; - [case(EPM_PROTOCOL_OSI_TP4)] epm_rhs_osi_tp4 osi_tp4; - [case(EPM_PROTOCOL_OSI_CLNS)] epm_rhs_osi_clns osi_clns; - [case(EPM_PROTOCOL_TCP)] epm_rhs_tcp tcp; - [case(EPM_PROTOCOL_UDP)] epm_rhs_udp udp; - [case(EPM_PROTOCOL_IP)] epm_rhs_ip ip; - [case(EPM_PROTOCOL_NCADG)] epm_rhs_ncadg ncadg; - [case(EPM_PROTOCOL_NCACN)] epm_rhs_ncacn ncacn; - [case(EPM_PROTOCOL_NCALRPC)] epm_rhs_ncalrpc ncalrpc; - [case(EPM_PROTOCOL_UUID)] epm_rhs_uuid uuid; - [case(EPM_PROTOCOL_IPX)] epm_rhs_ipx ipx; - [case(EPM_PROTOCOL_SMB)] epm_rhs_smb smb; - [case(EPM_PROTOCOL_PIPE)] epm_rhs_pipe pipe; - [case(EPM_PROTOCOL_NETBIOS)] epm_rhs_netbios netbios; - [case(EPM_PROTOCOL_NETBEUI)] epm_rhs_netbeui netbeui; - [case(EPM_PROTOCOL_SPX)] epm_rhs_spx spx; - [case(EPM_PROTOCOL_NB_IPX)] epm_rhs_nb_ipx nb_ipx; - [case(EPM_PROTOCOL_DSP)] epm_rhs_atalk_stream atalk_stream; - [case(EPM_PROTOCOL_DDP)] epm_rhs_atalk_datagram atalk_datagram; - [case(EPM_PROTOCOL_APPLETALK)] epm_rhs_appletalk appletalk; - [case(EPM_PROTOCOL_VINES_SPP)] epm_rhs_vines_spp vines_spp; - [case(EPM_PROTOCOL_VINES_IPC)] epm_rhs_vines_ipc vines_ipc; - [case(EPM_PROTOCOL_STREETTALK)] epm_rhs_streettalk streettalk; - [case(EPM_PROTOCOL_HTTP)] epm_rhs_http http; - [case(EPM_PROTOCOL_UNIX_DS)] epm_rhs_unix_ds unix_ds; - [case(EPM_PROTOCOL_NULL)] epm_rhs_null null; - [default] [flag(NDR_REMAINING)] DATA_BLOB unknown; - } epm_rhs; - - typedef struct { - epm_protocol protocol; - [flag(NDR_REMAINING)] DATA_BLOB lhs_data; - } epm_lhs; - - typedef struct { - [subcontext(2)] epm_lhs lhs; - [subcontext(2),switch_is(lhs.protocol)] epm_rhs rhs; - } epm_floor; - - /* note that the NDR_NOALIGN flag is inherited by all nested - structures. All of the towers/floors stuff is - non-aligned. I wonder what sort of wicked substance these - guys were smoking? - */ - typedef [gensize,flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN)] struct { - uint16 num_floors; - epm_floor floors[num_floors]; - } epm_tower; - - typedef struct { - [value(ndr_size_epm_tower(&tower, ndr->flags))] uint32 tower_length; - [subcontext(4)] epm_tower tower; - } epm_twr_t; - - typedef struct { - GUID object; - epm_twr_t *tower; - ascstr2 annotation; - } epm_entry_t; - - typedef struct { - GUID uuid; - uint16 vers_major; - uint16 vers_minor; - } rpc_if_id_t; - - /**********************/ - /* Function 0x0 */ - error_status_t epm_Insert( - [in] uint32 num_ents, - [in,size_is(num_ents)] epm_entry_t entries[], - [in] uint32 replace - ); - - /**********************/ - /* Function 0x1 */ - error_status_t epm_Delete( - [in] uint32 num_ents, - [in, size_is(num_ents)] epm_entry_t entries[] - ); - - /**********************/ - /* Function 0x02 */ - error_status_t epm_Lookup( - [in] uint32 inquiry_type, - [in,ptr] GUID *object, - [in,ptr] rpc_if_id_t *interface_id, - [in] uint32 vers_option, - [in,out] policy_handle *entry_handle, - [in] uint32 max_ents, - [out] uint32 *num_ents, - [out, length_is(*num_ents), size_is(max_ents)] epm_entry_t entries[] - ); - - - /**********************/ - /* Function 0x03 */ - - typedef struct { - epm_twr_t *twr; - } epm_twr_p_t; - - [public] error_status_t epm_Map( - [in,ptr] GUID *object, - [in,ptr] epm_twr_t *map_tower, - [in,out] policy_handle *entry_handle, - [in] uint32 max_towers, - [out] uint32 *num_towers, - [out, length_is(*num_towers), size_is(max_towers)] epm_twr_p_t towers[] - ); - - - /**********************/ - /* Function 0x04 */ - error_status_t epm_LookupHandleFree( - [in,out] policy_handle *entry_handle - ); - - /**********************/ - /* Function 0x05 */ - error_status_t epm_InqObject( - [in] GUID *epm_object - ); - - - /**********************/ - /* Function 0x06 */ - error_status_t epm_MgmtDelete( - [in] uint32 object_speced, - [in,ptr] GUID *object, - [in,ptr] epm_twr_t *tower - ); - - /**********************/ - /* Function 0x07 */ - error_status_t epm_MapAuth(); -} diff --git a/source3/librpc/idl/eventlog.idl b/source3/librpc/idl/eventlog.idl deleted file mode 100644 index 18b1a0e454..0000000000 --- a/source3/librpc/idl/eventlog.idl +++ /dev/null @@ -1,181 +0,0 @@ -#include "idl_types.h" - -/* - eventlog interface definition -*/ - -import "lsa.idl", "security.idl"; - -[ uuid("82273fdc-e32a-18c3-3f78-827929dc23ea"), - version(0.0), - helpstring("Event Logger") -] interface eventlog -{ - typedef bitmap { - EVENTLOG_SEQUENTIAL_READ = 0x0001, - EVENTLOG_SEEK_READ = 0x0002, - EVENTLOG_FORWARDS_READ = 0x0004, - EVENTLOG_BACKWARDS_READ = 0x0008 - } eventlogReadFlags; - - typedef bitmap { - EVENTLOG_SUCCESS = 0x0000, - EVENTLOG_ERROR_TYPE = 0x0001, - EVENTLOG_WARNING_TYPE = 0x0002, - EVENTLOG_INFORMATION_TYPE = 0x0004, - EVENTLOG_AUDIT_SUCCESS = 0x0008, - EVENTLOG_AUDIT_FAILURE = 0x0010 - } eventlogEventTypes; - - typedef struct { - uint16 unknown0; - uint16 unknown1; - } eventlog_OpenUnknown0; - - typedef [public] struct { - uint32 size; - uint32 reserved; - uint32 record_number; - uint32 time_generated; - uint32 time_written; - uint32 event_id; - uint16 event_type; - uint16 num_of_strings; - uint16 event_category; - uint16 reserved_flags; - uint32 closing_record_number; - uint32 stringoffset; - uint32 sid_length; - uint32 sid_offset; - uint32 data_length; - uint32 data_offset; - nstring source_name; - nstring computer_name; - nstring strings[num_of_strings]; - astring raw_data; - } eventlog_Record; - - /******************/ - /* Function: 0x00 */ - NTSTATUS eventlog_ClearEventLogW( - [in] policy_handle *handle, - [in,unique] lsa_String *backupfile - ); - - /******************/ - /* Function: 0x01 */ - NTSTATUS eventlog_BackupEventLogW(); - - /******************/ - /* Function: 0x02 */ - NTSTATUS eventlog_CloseEventLog( - [in,out] policy_handle *handle - ); - - /******************/ - /* Function: 0x03 */ - NTSTATUS eventlog_DeregisterEventSource(); - - /******************/ - /* Function: 0x04 */ - NTSTATUS eventlog_GetNumRecords( - [in] policy_handle *handle, - [out] uint32 *number - ); - - /******************/ - /* Function: 0x05 */ - NTSTATUS eventlog_GetOldestRecord( - [in] policy_handle *handle, - [out,ref] uint32 *oldest_entry - ); - - /******************/ - /* Function: 0x06 */ - NTSTATUS eventlog_ChangeNotify(); - - /******************/ - /* Function: 0x07 */ - NTSTATUS eventlog_OpenEventLogW( - [in,unique] eventlog_OpenUnknown0 *unknown0, - [in,ref] lsa_String *logname, - [in,ref] lsa_String *servername, - [in] uint32 unknown2, - [in] uint32 unknown3, - [out] policy_handle *handle - ); - - /******************/ - /* Function: 0x08 */ - NTSTATUS eventlog_RegisterEventSourceW(); - - /******************/ - /* Function: 0x09 */ - NTSTATUS eventlog_OpenBackupEventLogW(); - - /******************/ - /* Function: 0x0a */ - NTSTATUS eventlog_ReadEventLogW( - [in] policy_handle *handle, - [in] uint32 flags, - [in] uint32 offset, - [in] [range(0,0x7FFFF)] uint32 number_of_bytes, - [out,ref,size_is(number_of_bytes)] uint8 *data, - [out,ref] uint32 *sent_size, - [out,ref] uint32 *real_size - ); - - /*****************/ - /* Function 0x0b */ - NTSTATUS eventlog_ReportEventW(); - - /*****************/ - /* Function 0x0c */ - NTSTATUS eventlog_ClearEventLogA(); - - /******************/ - /* Function: 0x0d */ - NTSTATUS eventlog_BackupEventLogA(); - - /*****************/ - /* Function 0x0e */ - NTSTATUS eventlog_OpenEventLogA(); - - /*****************/ - /* Function 0x0f */ - NTSTATUS eventlog_RegisterEventSourceA(); - - /*****************/ - /* Function 0x10 */ - NTSTATUS eventlog_OpenBackupEventLogA(); - - /*****************/ - /* Function 0x11 */ - NTSTATUS eventlog_ReadEventLogA(); - - /*****************/ - /* Function 0x12 */ - NTSTATUS eventlog_ReportEventA(); - - /*****************/ - /* Function 0x13 */ - NTSTATUS eventlog_RegisterClusterSvc(); - - /*****************/ - /* Function 0x14 */ - NTSTATUS eventlog_DeregisterClusterSvc(); - - /*****************/ - /* Function 0x15 */ - NTSTATUS eventlog_WriteClusterEvents(); - - /*****************/ - /* Function 0x16 */ - NTSTATUS eventlog_GetLogIntormation(); - - /*****************/ - /* Function 0x17 */ - NTSTATUS eventlog_FlushEventLog( - [in] policy_handle *handle - ); -} diff --git a/source3/librpc/idl/idl_types.h b/source3/librpc/idl/idl_types.h deleted file mode 100644 index f21f3e660d..0000000000 --- a/source3/librpc/idl/idl_types.h +++ /dev/null @@ -1,86 +0,0 @@ -#define STR_ASCII LIBNDR_FLAG_STR_ASCII -#define STR_LEN4 LIBNDR_FLAG_STR_LEN4 -#define STR_SIZE4 LIBNDR_FLAG_STR_SIZE4 -#define STR_SIZE2 LIBNDR_FLAG_STR_SIZE2 -#define STR_NOTERM LIBNDR_FLAG_STR_NOTERM -#define STR_NULLTERM LIBNDR_FLAG_STR_NULLTERM -#define STR_BYTESIZE LIBNDR_FLAG_STR_BYTESIZE -#define STR_FIXLEN32 LIBNDR_FLAG_STR_FIXLEN32 -#define STR_FIXLEN15 LIBNDR_FLAG_STR_FIXLEN15 -#define STR_CONFORMANT LIBNDR_FLAG_STR_CONFORMANT -#define STR_CHARLEN LIBNDR_FLAG_STR_CHARLEN -#define STR_UTF8 LIBNDR_FLAG_STR_UTF8 - -/* - a UCS2 string prefixed with [size], 32 bits -*/ -#define lstring [flag(STR_SIZE4)] string - -/* - a null terminated UCS2 string -*/ -#define nstring [flag(STR_NULLTERM)] string - -/* - fixed length 32 character UCS-2 string -*/ -#define string32 [flag(STR_FIXLEN32)] string - -/* - fixed length 16 character ascii string -*/ -#define astring15 [flag(STR_ASCII|STR_FIXLEN15)] string - -/* - an ascii string prefixed with [offset] [length], both 32 bits - null terminated -*/ -#define ascstr2 [flag(STR_ASCII|STR_LEN4)] string - -/* - an ascii string prefixed with [size], 32 bits -*/ -#define asclstr [flag(STR_ASCII|STR_SIZE4)] string - -/* - an ascii string prefixed with [size], 16 bits - null terminated -*/ -#define ascstr3 [flag(STR_ASCII|STR_SIZE2)] string - -/* - an ascii string prefixed with [size] [offset] [length], all 32 bits - not null terminated -*/ -#define ascstr_noterm [flag(STR_NOTERM|STR_ASCII|STR_SIZE4|STR_LEN4)] string - -/* - a null terminated ascii string -*/ -#define astring [flag(STR_ASCII|STR_NULLTERM)] string - -/* - a null terminated UTF8 string -*/ -#define utf8string [flag(STR_UTF8|STR_NULLTERM)] string - -/* - a null terminated UCS2 string -*/ -#define nstring_array [flag(STR_NULLTERM)] string_array - -#define NDR_NOALIGN LIBNDR_FLAG_NOALIGN -#define NDR_REMAINING LIBNDR_FLAG_REMAINING -#define NDR_ALIGN2 LIBNDR_FLAG_ALIGN2 -#define NDR_ALIGN4 LIBNDR_FLAG_ALIGN4 -#define NDR_ALIGN8 LIBNDR_FLAG_ALIGN8 - -/* this flag is used to force a section of IDL as little endian. It is - needed for the epmapper IDL, which is defined as always being LE */ -#define NDR_LITTLE_ENDIAN LIBNDR_FLAG_LITTLE_ENDIAN -#define NDR_BIG_ENDIAN LIBNDR_FLAG_BIGENDIAN - -/* - this is used to control formatting of uint8 arrays -*/ -#define NDR_PAHEX LIBNDR_PRINT_ARRAY_HEX diff --git a/source3/librpc/idl/initshutdown.idl b/source3/librpc/idl/initshutdown.idl deleted file mode 100644 index 8815a9a29e..0000000000 --- a/source3/librpc/idl/initshutdown.idl +++ /dev/null @@ -1,46 +0,0 @@ -#include "idl_types.h" - -/* - initshutdown interface definition -*/ - -[ - uuid("894de0c0-0d55-11d3-a322-00c04fa321a1"), - version(1.0), - endpoint("ncacn_np:[\\pipe\\InitShutdown]"), - pointer_default(unique), - helpstring("Init shutdown service") -] interface initshutdown -{ - typedef struct { - [value(strlen_m_term(name))] uint32 name_size; - [flag(STR_LEN4|STR_NOTERM)] string name; - } initshutdown_String_sub; - - typedef [public] struct { - [value(strlen_m(name->name)*2)] uint16 name_len; - [value(strlen_m_term(name->name)*2)] uint16 name_size; - initshutdown_String_sub *name; - } initshutdown_String; - - WERROR initshutdown_Init( - [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, - [in] uint32 timeout, - [in] uint8 force_apps, - [in] uint8 do_reboot - ); - - WERROR initshutdown_Abort( - [in,unique] uint16 *server - ); - - WERROR initshutdown_InitEx( - [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, - [in] uint32 timeout, - [in] uint8 force_apps, - [in] uint8 do_reboot, - [in] uint32 reason - ); -} diff --git a/source3/librpc/idl/krb5pac.idl b/source3/librpc/idl/krb5pac.idl deleted file mode 100644 index c039502d23..0000000000 --- a/source3/librpc/idl/krb5pac.idl +++ /dev/null @@ -1,120 +0,0 @@ -/* - krb5 PAC -*/ - -#include "idl_types.h" - -import "security.idl", "netlogon.idl", "samr.idl"; - -[ - uuid("12345778-1234-abcd-0000-00000000"), - version(0.0), - pointer_default(unique), - helpstring("Active Directory KRB5 PAC") -] -interface krb5pac -{ - typedef struct { - NTTIME logon_time; - [value(2*strlen_m(account_name))] uint16 size; - [charset(UTF16)] uint8 account_name[size]; - } PAC_LOGON_NAME; - - typedef [public,flag(NDR_PAHEX)] struct { - uint32 type; - [flag(NDR_REMAINING)] DATA_BLOB signature; - } PAC_SIGNATURE_DATA; - - typedef [gensize] struct { - netr_SamInfo3 info3; - dom_sid2 *res_group_dom_sid; - samr_RidWithAttributeArray res_groups; - } PAC_LOGON_INFO; - - typedef struct { - [value(2*strlen_m(upn_name))] uint16 upn_size; - uint16 upn_offset; - [value(2*strlen_m(domain_name))] uint16 domain_size; - uint16 domain_offset; - uint16 unknown3; /* 0x01 */ - uint16 unknown4; - uint32 unknown5; - [charset(UTF16)] uint8 upn_name[upn_size+2]; - [charset(UTF16)] uint8 domain_name[domain_size+2]; - uint32 unknown6; /* padding */ - } PAC_UNKNOWN_12; - - typedef [public] struct { - [value(0x00081001)] uint32 unknown1; - [value(0xCCCCCCCC)] uint32 unknown2; - [value(NDR_ROUND(ndr_size_PAC_LOGON_INFO(info, ndr->flags)+4,8))] uint32 _ndr_size; - [value(0x00000000)] uint32 unknown3; - PAC_LOGON_INFO *info; - } PAC_LOGON_INFO_CTR; - - typedef [public,v1_enum] enum { - PAC_TYPE_LOGON_INFO = 1, - PAC_TYPE_SRV_CHECKSUM = 6, - PAC_TYPE_KDC_CHECKSUM = 7, - PAC_TYPE_LOGON_NAME = 10, - PAC_TYPE_CONSTRAINED_DELEGATION = 11, - PAC_TYPE_UNKNOWN_12 = 12 - } PAC_TYPE; - - typedef struct { - [flag(NDR_REMAINING)] DATA_BLOB remaining; - } DATA_BLOB_REM; - - typedef [public,nodiscriminant,gensize] union { - [case(PAC_TYPE_LOGON_INFO)] PAC_LOGON_INFO_CTR logon_info; - [case(PAC_TYPE_SRV_CHECKSUM)] PAC_SIGNATURE_DATA srv_cksum; - [case(PAC_TYPE_KDC_CHECKSUM)] PAC_SIGNATURE_DATA kdc_cksum; - [case(PAC_TYPE_LOGON_NAME)] PAC_LOGON_NAME logon_name; - [default] [subcontext(0)] DATA_BLOB_REM unknown; - /* [case(PAC_TYPE_UNKNOWN_12)] PAC_UNKNOWN_12 unknown; */ - } PAC_INFO; - - typedef [public,nopush,nopull,noprint] struct { - PAC_TYPE type; - [value(_ndr_size_PAC_INFO(info, type, 0))] uint32 _ndr_size; - [relative,switch_is(type),subcontext(0),subcontext_size(_subcontext_size_PAC_INFO(r, ndr->flags)),flag(NDR_ALIGN8)] PAC_INFO *info; - [value(0)] uint32 _pad; /* Top half of a 64 bit pointer? */ - } PAC_BUFFER; - - typedef [public] struct { - uint32 num_buffers; - uint32 version; - PAC_BUFFER buffers[num_buffers]; - } PAC_DATA; - - typedef [public] struct { - PAC_TYPE type; - uint32 ndr_size; - [relative,subcontext(0),subcontext_size(NDR_ROUND(ndr_size,8)),flag(NDR_ALIGN8)] DATA_BLOB_REM *info; - [value(0)] uint32 _pad; /* Top half of a 64 bit pointer? */ - } PAC_BUFFER_RAW; - - typedef [public] struct { - uint32 num_buffers; - uint32 version; - PAC_BUFFER_RAW buffers[num_buffers]; - } PAC_DATA_RAW; - - void decode_pac( - [in] PAC_DATA pac - ); - - void decode_pac_raw( - [in] PAC_DATA_RAW pac - ); - - void decode_login_info( - [in] PAC_LOGON_INFO logon_info - ); - - /* used for samba3 netsamlogon cache */ - typedef [public] struct { - time_t timestamp; - netr_SamInfo3 info3; - } netsamlogoncache_entry; -} diff --git a/source3/librpc/idl/libnetapi.idl b/source3/librpc/idl/libnetapi.idl index 039dcf4152..f2f4a16c12 100644 --- a/source3/librpc/idl/libnetapi.idl +++ b/source3/librpc/idl/libnetapi.idl @@ -517,7 +517,9 @@ interface libnetapi uint32 usriX_code_page; string usriX_profile; string usriX_home_dir_drive; + uint32 usriX_user_id; uint32 usriX_primary_group_id; + uint32 usriX_password_expired; } USER_INFO_X; [nopush,nopull] NET_API_STATUS NetUserAdd( diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index cb16f64dab..a443448871 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -4,7 +4,7 @@ lsa interface definition */ -import "security.idl"; +import "misc.idl", "security.idl"; [ uuid("12345778-1234-abcd-ef00-0123456789ab"), version(0.0), @@ -14,6 +14,7 @@ import "security.idl"; ] interface lsarpc { typedef bitmap security_secinfo security_secinfo; + typedef bitmap kerb_EncTypes kerb_EncTypes; typedef [public,noejs] struct { [value(2*strlen_m(string))] uint16 length; @@ -108,7 +109,7 @@ import "security.idl"; /******************/ /* Function: 0x05 */ - NTSTATUS lsa_ChangePassword (); + [todo] NTSTATUS lsa_ChangePassword (); /******************/ @@ -160,12 +161,11 @@ import "security.idl"; typedef struct { uint32 percent_full; - uint32 log_size; - NTTIME retention_time; + uint32 maximum_log_size; + hyper retention_time; uint8 shutdown_in_progress; - NTTIME time_to_shutdown; + hyper time_to_shutdown; uint32 next_audit_record; - uint32 unknown; } lsa_AuditLogInfo; typedef [v1_enum] enum { @@ -203,9 +203,13 @@ import "security.idl"; lsa_String name; } lsa_PDAccountInfo; + typedef [v1_enum] enum { + LSA_ROLE_BACKUP=2, + LSA_ROLE_PRIMARY=3 + } lsa_Role; + typedef struct { - uint16 unknown; /* an midl padding bug? */ - uint16 role; + lsa_Role role; } lsa_ServerRole; typedef struct { @@ -224,7 +228,7 @@ import "security.idl"; typedef struct { hyper modified_id; - NTTIME db_create_time; + NTTIME_hyper db_create_time; } lsa_ModificationInfo; typedef struct { @@ -232,7 +236,6 @@ import "security.idl"; } lsa_AuditFullSetInfo; typedef struct { - uint16 unknown; /* an midl padding bug? */ uint8 shutdown_on_full; uint8 log_is_full; } lsa_AuditFullQueryInfo; @@ -260,10 +263,12 @@ import "security.idl"; LSA_POLICY_INFO_ROLE=6, LSA_POLICY_INFO_REPLICA=7, LSA_POLICY_INFO_QUOTA=8, - LSA_POLICY_INFO_DB=9, + LSA_POLICY_INFO_MOD=9, LSA_POLICY_INFO_AUDIT_FULL_SET=10, LSA_POLICY_INFO_AUDIT_FULL_QUERY=11, - LSA_POLICY_INFO_DNS=12 + LSA_POLICY_INFO_DNS=12, + LSA_POLICY_INFO_DNS_INT=13, + LSA_POLICY_INFO_L_ACCOUNT_DOMAIN=14 } lsa_PolicyInfo; typedef [switch_type(uint16)] union { @@ -275,10 +280,12 @@ import "security.idl"; [case(LSA_POLICY_INFO_ROLE)] lsa_ServerRole role; [case(LSA_POLICY_INFO_REPLICA)] lsa_ReplicaSourceInfo replica; [case(LSA_POLICY_INFO_QUOTA)] lsa_DefaultQuotaInfo quota; - [case(LSA_POLICY_INFO_DB)] lsa_ModificationInfo db; + [case(LSA_POLICY_INFO_MOD)] lsa_ModificationInfo mod; [case(LSA_POLICY_INFO_AUDIT_FULL_SET)] lsa_AuditFullSetInfo auditfullset; [case(LSA_POLICY_INFO_AUDIT_FULL_QUERY)] lsa_AuditFullQueryInfo auditfullquery; [case(LSA_POLICY_INFO_DNS)] lsa_DnsDomainInfo dns; + [case(LSA_POLICY_INFO_DNS_INT)] lsa_DnsDomainInfo dns; + [case(LSA_POLICY_INFO_L_ACCOUNT_DOMAIN)] lsa_DomainInfo l_account_domain; } lsa_PolicyInformation; NTSTATUS lsa_QueryInfoPolicy( @@ -297,7 +304,7 @@ import "security.idl"; /******************/ /* Function: 0x09 */ - NTSTATUS lsa_ClearAuditLog (); + [todo] NTSTATUS lsa_ClearAuditLog (); /******************/ /* Function: 0x0a */ @@ -334,7 +341,7 @@ import "security.idl"; /* Function: 0x0c */ [public] NTSTATUS lsa_CreateTrustedDomain( - [in] policy_handle *handle, + [in] policy_handle *policy_handle, [in] lsa_DomainInfo *info, [in] uint32 access_mask, [out] policy_handle *trustdom_handle @@ -362,7 +369,7 @@ import "security.idl"; /******************/ /* Function: 0x0e */ - typedef enum { + typedef [public] enum { SID_NAME_USE_NONE = 0,/* NOTUSED */ SID_NAME_USER = 1, /* user */ SID_NAME_DOM_GRP = 2, /* domain group */ @@ -409,7 +416,8 @@ import "security.idl"; LSA_LOOKUP_NAMES_PRIMARY_DOMAIN_ONLY = 3, LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY = 4, LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY = 5, - LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 = 6 + LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 = 6, + LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC = 7 } lsa_LookupNamesLevel; [public] NTSTATUS lsa_LookupNames ( @@ -506,28 +514,44 @@ import "security.idl"; ); /* Function: 0x15 */ - NTSTATUS lsa_GetQuotasForAccount(); + [todo] NTSTATUS lsa_GetQuotasForAccount(); /* Function: 0x16 */ - NTSTATUS lsa_SetQuotasForAccount(); + [todo] NTSTATUS lsa_SetQuotasForAccount(); + typedef [bitmap32bit] bitmap { + LSA_POLICY_MODE_INTERACTIVE = 0x00000001, + LSA_POLICY_MODE_NETWORK = 0x00000002, + LSA_POLICY_MODE_BATCH = 0x00000004, + LSA_POLICY_MODE_SERVICE = 0x00000010, + LSA_POLICY_MODE_PROXY = 0x00000020, + LSA_POLICY_MODE_DENY_INTERACTIVE = 0x00000040, + LSA_POLICY_MODE_DENY_NETWORK = 0x00000080, + LSA_POLICY_MODE_DENY_BATCH = 0x00000100, + LSA_POLICY_MODE_DENY_SERVICE = 0x00000200, + LSA_POLICY_MODE_REMOTE_INTERACTIVE = 0x00000400, + LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE = 0x00000800, + LSA_POLICY_MODE_ALL = 0x00000FF7, + LSA_POLICY_MODE_ALL_NT4 = 0x00000037 + } lsa_SystemAccessModeFlags; + /* Function: 0x17 */ NTSTATUS lsa_GetSystemAccessAccount( - [in] policy_handle *handle, + [in] policy_handle *handle, [out,ref] uint32 *access_mask ); /* Function: 0x18 */ NTSTATUS lsa_SetSystemAccessAccount( - [in] policy_handle *handle, - [in] uint32 access_mask + [in] policy_handle *handle, + [in] uint32 access_mask ); /* Function: 0x19 */ NTSTATUS lsa_OpenTrustedDomain( [in] policy_handle *handle, [in] dom_sid2 *sid, - [in] uint32 access_mask, + [in] uint32 access_mask, [out] policy_handle *trustdom_handle ); @@ -543,22 +567,53 @@ import "security.idl"; } lsa_DATA_BUF2; typedef enum { - LSA_TRUSTED_DOMAIN_INFO_NAME = 1, - LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS_INFO = 2, - LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET = 3, - LSA_TRUSTED_DOMAIN_INFO_PASSWORD = 4, - LSA_TRUSTED_DOMAIN_INFO_BASIC = 5, - LSA_TRUSTED_DOMAIN_INFO_INFO_EX = 6, - LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO = 7, - LSA_TRUSTED_DOMAIN_INFO_FULL_INFO = 8, - LSA_TRUSTED_DOMAIN_INFO_11 = 11, - LSA_TRUSTED_DOMAIN_INFO_INFO_ALL = 12 + LSA_TRUSTED_DOMAIN_INFO_NAME = 1, + LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS = 2, + LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET = 3, + LSA_TRUSTED_DOMAIN_INFO_PASSWORD = 4, + LSA_TRUSTED_DOMAIN_INFO_BASIC = 5, + LSA_TRUSTED_DOMAIN_INFO_INFO_EX = 6, + LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO = 7, + LSA_TRUSTED_DOMAIN_INFO_FULL_INFO = 8, + LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL = 9, + LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL = 10, + LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL = 11, + LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL = 12, + LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES = 13 } lsa_TrustDomInfoEnum; + typedef [public,bitmap32bit] bitmap { + LSA_TRUST_DIRECTION_INBOUND = 0x00000001, + LSA_TRUST_DIRECTION_OUTBOUND = 0x00000002 + } lsa_TrustDirection; + + typedef [v1_enum] enum { + LSA_TRUST_TYPE_DOWNLEVEL = 0x00000001, + LSA_TRUST_TYPE_UPLEVEL = 0x00000002, + LSA_TRUST_TYPE_MIT = 0x00000003 + } lsa_TrustType; + + typedef [public,bitmap32bit] bitmap { + LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE = 0x00000001, + LSA_TRUST_ATTRIBUTE_UPLEVEL_ONLY = 0x00000002, + LSA_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN = 0x00000004, + LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE = 0x00000008, + LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION = 0x00000010, + LSA_TRUST_ATTRIBUTE_WITHIN_FOREST = 0x00000020, + LSA_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL = 0x00000040, + LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION = 0x00000080 + } lsa_TrustAttributes; + typedef struct { lsa_StringLarge netbios_name; } lsa_TrustDomainInfoName; + + typedef struct { + uint32 entries; + [size_is(entries)] lsa_StringLarge *netbios_names; + } lsa_TrustDomainInfoControllers; + typedef struct { uint32 posix_offset; } lsa_TrustDomainInfoPosixOffset; @@ -576,15 +631,22 @@ import "security.idl"; typedef struct { lsa_StringLarge domain_name; lsa_StringLarge netbios_name; - dom_sid2 *sid; - uint32 trust_direction; - uint32 trust_type; - uint32 trust_attributes; + dom_sid2 *sid; + lsa_TrustDirection trust_direction; + lsa_TrustType trust_type; + lsa_TrustAttributes trust_attributes; } lsa_TrustDomainInfoInfoEx; + typedef [public,v1_enum] enum { + TRUST_AUTH_TYPE_NONE = 0, + TRUST_AUTH_TYPE_NT4OWF = 1, + TRUST_AUTH_TYPE_CLEAR = 2, + TRUST_AUTH_TYPE_VERSION = 3 + } lsa_TrustAuthType; + typedef struct { NTTIME_hyper last_update_time; - uint32 secret_type; + lsa_TrustAuthType AuthType; lsa_DATA_BUF2 data; } lsa_TrustDomainInfoBuffer; @@ -604,27 +666,58 @@ import "security.idl"; } lsa_TrustDomainInfoFullInfo; typedef struct { - lsa_TrustDomainInfoInfoEx info_ex; - lsa_DATA_BUF2 data1; - } lsa_TrustDomainInfo11; + lsa_DATA_BUF2 auth_blob; + } lsa_TrustDomainInfoAuthInfoInternal; + + typedef struct { + lsa_TrustDomainInfoInfoEx info_ex; + lsa_TrustDomainInfoPosixOffset posix_offset; + lsa_TrustDomainInfoAuthInfoInternal auth_info; + } lsa_TrustDomainInfoFullInfoInternal; typedef struct { lsa_TrustDomainInfoInfoEx info_ex; - lsa_DATA_BUF2 data1; + uint32 forest_trust_length; + [size_is(forest_trust_length)] uint8 *forest_trust_data; + } lsa_TrustDomainInfoInfoEx2Internal; + + typedef struct { + lsa_TrustDomainInfoInfoEx2Internal info; lsa_TrustDomainInfoPosixOffset posix_offset; lsa_TrustDomainInfoAuthInfo auth_info; - } lsa_TrustDomainInfoInfoAll; + } lsa_TrustDomainInfoFullInfo2Internal; + + typedef struct { + kerb_EncTypes enc_types; + } lsa_TrustDomainInfoSupportedEncTypes; typedef [switch_type(lsa_TrustDomInfoEnum)] union { - [case(LSA_TRUSTED_DOMAIN_INFO_NAME)] lsa_TrustDomainInfoName name; - [case(LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET)] lsa_TrustDomainInfoPosixOffset posix_offset; - [case(LSA_TRUSTED_DOMAIN_INFO_PASSWORD)] lsa_TrustDomainInfoPassword password; - [case(LSA_TRUSTED_DOMAIN_INFO_BASIC)] lsa_TrustDomainInfoBasic info_basic; - [case(LSA_TRUSTED_DOMAIN_INFO_INFO_EX)] lsa_TrustDomainInfoInfoEx info_ex; - [case(LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO)] lsa_TrustDomainInfoAuthInfo auth_info; - [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)] lsa_TrustDomainInfoFullInfo full_info; - [case(LSA_TRUSTED_DOMAIN_INFO_11)] lsa_TrustDomainInfo11 info11; - [case(LSA_TRUSTED_DOMAIN_INFO_INFO_ALL)] lsa_TrustDomainInfoInfoAll info_all; + [case(LSA_TRUSTED_DOMAIN_INFO_NAME)] + lsa_TrustDomainInfoName name; + [case(LSA_TRUSTED_DOMAIN_INFO_CONTROLLERS)] + lsa_TrustDomainInfoControllers controllers; + [case(LSA_TRUSTED_DOMAIN_INFO_POSIX_OFFSET)] + lsa_TrustDomainInfoPosixOffset posix_offset; + [case(LSA_TRUSTED_DOMAIN_INFO_PASSWORD)] + lsa_TrustDomainInfoPassword password; + [case(LSA_TRUSTED_DOMAIN_INFO_BASIC)] + lsa_TrustDomainInfoBasic info_basic; + [case(LSA_TRUSTED_DOMAIN_INFO_INFO_EX)] + lsa_TrustDomainInfoInfoEx info_ex; + [case(LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO)] + lsa_TrustDomainInfoAuthInfo auth_info; + [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO)] + lsa_TrustDomainInfoFullInfo full_info; + [case(LSA_TRUSTED_DOMAIN_INFO_AUTH_INFO_INTERNAL)] + lsa_TrustDomainInfoAuthInfoInternal auth_info_internal; + [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_INTERNAL)] + lsa_TrustDomainInfoFullInfoInternal full_info_internal; + [case(LSA_TRUSTED_DOMAIN_INFO_INFO_EX2_INTERNAL)] + lsa_TrustDomainInfoInfoEx2Internal info_ex2_internal; + [case(LSA_TRUSTED_DOMAIN_INFO_FULL_INFO_2_INTERNAL)] + lsa_TrustDomainInfoFullInfo2Internal full_info2_internal; + [case(LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRTYPION_TYPES)] + lsa_TrustDomainInfoSupportedEncTypes enc_types; } lsa_TrustedDomainInfo; /* Function: 0x1a */ @@ -635,7 +728,11 @@ import "security.idl"; ); /* Function: 0x1b */ - NTSTATUS lsa_SetInformationTrustedDomain(); + NTSTATUS lsa_SetInformationTrustedDomain( + [in] policy_handle *trustdom_handle, + [in] lsa_TrustDomInfoEnum level, + [in,switch_is(level)] lsa_TrustedDomainInfo *info + ); /* Function: 0x1c */ [public] NTSTATUS lsa_OpenSecret( @@ -695,9 +792,10 @@ import "security.idl"; [out,ref] uint16 *returned_language_id ); - /* Function: 0x22 */ - NTSTATUS lsa_DeleteObject( - [in,out] policy_handle *handle + /*******************/ + /* Function: 0x22 */ + NTSTATUS lsa_DeleteObject ( + [in,out] policy_handle *handle ); /*******************/ @@ -732,7 +830,7 @@ import "security.idl"; [in,ref] dom_sid2 *sid, [in,ref] lsa_RightSet *rights ); - + /**********************/ /* Function: 0x26 */ NTSTATUS lsa_RemoveAccountRights ( @@ -751,7 +849,13 @@ import "security.idl"; ); /* Function: 0x28 */ - NTSTATUS lsa_SetTrustedDomainInfo(); + NTSTATUS lsa_SetTrustedDomainInfo( + [in] policy_handle *handle, + [in] dom_sid2 *dom_sid, + [in] lsa_TrustDomInfoEnum level, + [in,switch_is(level)] lsa_TrustedDomainInfo *info + ); + /* Function: 0x29 */ NTSTATUS lsa_DeleteTrustedDomain( [in] policy_handle *handle, @@ -759,9 +863,9 @@ import "security.idl"; ); /* Function: 0x2a */ - NTSTATUS lsa_StorePrivateData(); + [todo] NTSTATUS lsa_StorePrivateData(); /* Function: 0x2b */ - NTSTATUS lsa_RetrievePrivateData(); + [todo] NTSTATUS lsa_RetrievePrivateData(); /**********************/ @@ -811,7 +915,7 @@ import "security.idl"; NTSTATUS lsa_SetTrustedDomainInfoByName( [in] policy_handle *handle, [in] lsa_String trusted_domain, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [in,unique,switch_is(level)] lsa_TrustedDomainInfo *info ); @@ -832,9 +936,15 @@ import "security.idl"; [in] uint32 max_size ); - /* Function 0x33 */ - NTSTATUS lsa_CreateTrustedDomainEx(); + NTSTATUS lsa_CreateTrustedDomainEx( + [in] policy_handle *policy_handle, + [in] lsa_TrustDomainInfoInfoEx *info, + [in] lsa_TrustDomainInfoAuthInfoInternal *auth_info, + [in] uint32 access_mask, + [out] policy_handle *trustdom_handle + ); + /* Function 0x34 */ NTSTATUS lsa_CloseTrustedDomainEx( @@ -892,7 +1002,7 @@ import "security.idl"; ); /* Function 0x38 */ - NTSTATUS lsa_TestCall(); + [todo] NTSTATUS lsa_TestCall(); /**********************/ /* Function 0x39 */ @@ -943,36 +1053,42 @@ import "security.idl"; [in,out,ref] lsa_TransSidArray2 *sids, [in] lsa_LookupNamesLevel level, [in,out,ref] uint32 *count, - [in] uint32 unknown1, - [in] uint32 unknown2 + [in] uint32 lookup_options, + [in] uint32 client_revision /* LSA_CLIENT_REVISION* */ ); /* Function 0x3b */ - NTSTATUS lsa_CreateTrustedDomainEx2(); + NTSTATUS lsa_CreateTrustedDomainEx2( + [in] policy_handle *policy_handle, + [in] lsa_TrustDomainInfoInfoEx *info, + [in] lsa_TrustDomainInfoAuthInfoInternal *auth_info, + [in] uint32 access_mask, + [out] policy_handle *trustdom_handle + ); /* Function 0x3c */ - NTSTATUS lsa_CREDRWRITE(); + [todo] NTSTATUS lsa_CREDRWRITE(); /* Function 0x3d */ - NTSTATUS lsa_CREDRREAD(); + [todo] NTSTATUS lsa_CREDRREAD(); /* Function 0x3e */ - NTSTATUS lsa_CREDRENUMERATE(); + [todo] NTSTATUS lsa_CREDRENUMERATE(); /* Function 0x3f */ - NTSTATUS lsa_CREDRWRITEDOMAINCREDENTIALS(); + [todo] NTSTATUS lsa_CREDRWRITEDOMAINCREDENTIALS(); /* Function 0x40 */ - NTSTATUS lsa_CREDRREADDOMAINCREDENTIALS(); + [todo] NTSTATUS lsa_CREDRREADDOMAINCREDENTIALS(); /* Function 0x41 */ - NTSTATUS lsa_CREDRDELETE(); + [todo] NTSTATUS lsa_CREDRDELETE(); /* Function 0x42 */ - NTSTATUS lsa_CREDRGETTARGETINFO(); + [todo] NTSTATUS lsa_CREDRGETTARGETINFO(); /* Function 0x43 */ - NTSTATUS lsa_CREDRPROFILELOADED(); + [todo] NTSTATUS lsa_CREDRPROFILELOADED(); /**********************/ /* Function 0x44 */ @@ -980,7 +1096,7 @@ import "security.idl"; lsa_SidType sid_type; dom_sid2 *sid; uint32 sid_index; - uint32 unknown; + uint32 flags; } lsa_TranslatedSid3; typedef struct { @@ -996,21 +1112,21 @@ import "security.idl"; [in,out,ref] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, [in,out,ref] uint32 *count, - [in] uint32 unknown1, - [in] uint32 unknown2 + [in] uint32 lookup_options, + [in] uint32 client_revision /* LSA_CLIENT_REVISION* */ ); /* Function 0x45 */ - NTSTATUS lsa_CREDRGETSESSIONTYPES(); + [todo] NTSTATUS lsa_CREDRGETSESSIONTYPES(); /* Function 0x46 */ - NTSTATUS lsa_LSARREGISTERAUDITEVENT(); + [todo] NTSTATUS lsa_LSARREGISTERAUDITEVENT(); /* Function 0x47 */ - NTSTATUS lsa_LSARGENAUDITEVENT(); + [todo] NTSTATUS lsa_LSARGENAUDITEVENT(); /* Function 0x48 */ - NTSTATUS lsa_LSARUNREGISTERAUDITEVENT(); + [todo] NTSTATUS lsa_LSARUNREGISTERAUDITEVENT(); /* Function 0x49 */ typedef struct { @@ -1058,10 +1174,10 @@ import "security.idl"; ); /* Function 0x4a */ - NTSTATUS lsa_LSARSETFORESTTRUSTINFORMATION(); + [todo] NTSTATUS lsa_LSARSETFORESTTRUSTINFORMATION(); /* Function 0x4b */ - NTSTATUS lsa_CREDRRENAME(); + [todo] NTSTATUS lsa_CREDRRENAME(); /*****************/ /* Function 0x4c */ @@ -1076,6 +1192,11 @@ import "security.idl"; [in] uint32 unknown2 ); + const int LSA_CLIENT_REVISION_NO_DNS = 0x00000001; + const int LSA_CLIENT_REVISION_DNS = 0x00000002; + + const int LSA_LOOKUP_OPTIONS_NO_ISOLATED = 0x80000000; + /* Function 0x4d */ NTSTATUS lsa_LookupNames4( [in,range(0,1000)] uint32 num_names, @@ -1084,20 +1205,20 @@ import "security.idl"; [in,out,ref] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, [in,out,ref] uint32 *count, - [in] uint32 unknown1, - [in] uint32 unknown2 + [in] uint32 lookup_options, + [in] uint32 client_revision /* LSA_CLIENT_REVISION* */ ); /* Function 0x4e */ - NTSTATUS lsa_LSAROPENPOLICYSCE(); + [todo] NTSTATUS lsa_LSAROPENPOLICYSCE(); /* Function 0x4f */ - NTSTATUS lsa_LSARADTREGISTERSECURITYEVENTSOURCE(); + [todo] NTSTATUS lsa_LSARADTREGISTERSECURITYEVENTSOURCE(); /* Function 0x50 */ - NTSTATUS lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(); + [todo] NTSTATUS lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(); /* Function 0x51 */ - NTSTATUS lsa_LSARADTREPORTSECURITYEVENT(); + [todo] NTSTATUS lsa_LSARADTREPORTSECURITYEVENT(); } diff --git a/source3/librpc/idl/nbt.idl b/source3/librpc/idl/nbt.idl deleted file mode 100644 index 9f5c4a9a5f..0000000000 --- a/source3/librpc/idl/nbt.idl +++ /dev/null @@ -1,781 +0,0 @@ -#include "idl_types.h" - -/* - IDL structures for NBT operations - - NBT is not traditionally encoded using IDL/NDR. This is a bit of an - experiment, and I may well switch us back to a more traditional - encoding if it doesn't work out -*/ - -import "misc.idl", "security.idl", "svcctl.idl", "samr.idl"; -[ -helper("libcli/nbt/libnbt.h") -] -interface nbt -{ - const int NBT_NAME_SERVICE_PORT = 137; - const int NBT_DGRAM_SERVICE_PORT = 138; - - typedef [bitmap16bit] bitmap { - NBT_RCODE = 0x000F, - NBT_FLAG_BROADCAST = 0x0010, - NBT_FLAG_RECURSION_AVAIL = 0x0080, - NBT_FLAG_RECURSION_DESIRED = 0x0100, - NBT_FLAG_TRUNCATION = 0x0200, - NBT_FLAG_AUTHORITIVE = 0x0400, - NBT_OPCODE = 0x7800, - NBT_FLAG_REPLY = 0x8000 - } nbt_operation; - - /* the opcodes are in the operation field, masked with - NBT_OPCODE */ - typedef enum { - NBT_OPCODE_QUERY = (0x0<<11), - NBT_OPCODE_REGISTER = (0x5<<11), - NBT_OPCODE_RELEASE = (0x6<<11), - NBT_OPCODE_WACK = (0x7<<11), - NBT_OPCODE_REFRESH = (0x8<<11), - NBT_OPCODE_REFRESH2 = (0x9<<11), - NBT_OPCODE_MULTI_HOME_REG = (0xf<<11) - } nbt_opcode; - - /* rcode values */ - typedef enum { - NBT_RCODE_OK = 0x0, - NBT_RCODE_FMT = 0x1, - NBT_RCODE_SVR = 0x2, - NBT_RCODE_NAM = 0x3, - NBT_RCODE_IMP = 0x4, - NBT_RCODE_RFS = 0x5, - NBT_RCODE_ACT = 0x6, - NBT_RCODE_CFT = 0x7 - } nbt_rcode; - - /* we support any 8bit name type, but by defining the common - ones here we get better debug displays */ - typedef [enum8bit] enum { - NBT_NAME_CLIENT = 0x00, - NBT_NAME_MS = 0x01, - NBT_NAME_USER = 0x03, - NBT_NAME_SERVER = 0x20, - NBT_NAME_PDC = 0x1B, - NBT_NAME_LOGON = 0x1C, - NBT_NAME_MASTER = 0x1D, - NBT_NAME_BROWSER = 0x1E - } nbt_name_type; - - /* the ndr parser for nbt_name is separately defined in - nbtname.c (along with the parsers for nbt_string) */ - typedef [public,nopull,nopush] struct { - string name; - string scope; - nbt_name_type type; - } nbt_name; - - typedef [enum16bit] enum { - NBT_QCLASS_IP = 0x01 - } nbt_qclass; - - typedef [enum16bit] enum { - NBT_QTYPE_ADDRESS = 0x0001, - NBT_QTYPE_NAMESERVICE = 0x0002, - NBT_QTYPE_NULL = 0x000A, - NBT_QTYPE_NETBIOS = 0x0020, - NBT_QTYPE_STATUS = 0x0021 - } nbt_qtype; - - typedef struct { - nbt_name name; - nbt_qtype question_type; - nbt_qclass question_class; - } nbt_name_question; - - /* these are the possible values of the NBT_NM_OWNER_TYPE - field */ - typedef enum { - NBT_NODE_B = 0x0000, - NBT_NODE_P = 0x2000, - NBT_NODE_M = 0x4000, - NBT_NODE_H = 0x6000 - } nbt_node_type; - - typedef [bitmap16bit] bitmap { - NBT_NM_PERMANENT = 0x0200, - NBT_NM_ACTIVE = 0x0400, - NBT_NM_CONFLICT = 0x0800, - NBT_NM_DEREGISTER = 0x1000, - NBT_NM_OWNER_TYPE = 0x6000, - NBT_NM_GROUP = 0x8000 - } nb_flags; - - typedef struct { - nb_flags nb_flags; - ipv4address ipaddr; - } nbt_rdata_address; - - typedef struct { - uint16 length; - nbt_rdata_address addresses[length/6]; - } nbt_rdata_netbios; - - typedef struct { - uint8 unit_id[6]; - uint8 jumpers; - uint8 test_result; - uint16 version_number; - uint16 period_of_statistics; - uint16 number_of_crcs; - uint16 number_alignment_errors; - uint16 number_of_collisions; - uint16 number_send_aborts; - uint32 number_good_sends; - uint32 number_good_receives; - uint16 number_retransmits; - uint16 number_no_resource_conditions; - uint16 number_free_command_blocks; - uint16 total_number_command_blocks; - uint16 max_total_number_command_blocks; - uint16 number_pending_sessions; - uint16 max_number_pending_sessions; - uint16 max_total_sessions_possible; - uint16 session_data_packet_size; - } nbt_statistics; - - typedef struct { - [charset(DOS)] uint8 name[15]; - nbt_name_type type; - nb_flags nb_flags; - } nbt_status_name; - - typedef struct { - [value(num_names * 18 + 47)] uint16 length; - uint8 num_names; - nbt_status_name names[num_names]; - nbt_statistics statistics; - } nbt_rdata_status; - - typedef struct { - uint16 length; - uint8 data[length]; - } nbt_rdata_data; - - typedef [nodiscriminant] union { - [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios; - [case(NBT_QTYPE_STATUS)] nbt_rdata_status status; - [default] nbt_rdata_data data; - } nbt_rdata; - -/* - * this macro works arround the problem - * that we need to use nbt_rdata_data - * together with NBT_QTYPE_NETBIOS - * for WACK replies - */ -#define NBT_RES_REC_LEVEL(rr_type, rdata) (\ - (((rr_type) == NBT_QTYPE_NETBIOS) && \ - talloc_check_name(ndr, "struct ndr_push") && \ - ((rdata).data.length == 2)) \ - ? 0 : rr_type) - - typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct { - nbt_name name; - nbt_qtype rr_type; - nbt_qclass rr_class; - uint32 ttl; - [switch_is(NBT_RES_REC_LEVEL(rr_type, rdata))] nbt_rdata rdata; - } nbt_res_rec; - - typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct { - uint16 name_trn_id; - nbt_operation operation; - uint16 qdcount; - uint16 ancount; - uint16 nscount; - uint16 arcount; - nbt_name_question questions[qdcount]; - nbt_res_rec answers[ancount]; - nbt_res_rec nsrecs[nscount]; - nbt_res_rec additional[arcount]; - [flag(NDR_REMAINING)] DATA_BLOB padding; - } nbt_name_packet; - - - /* - NBT DGRAM packets (UDP/138) - */ - - typedef [enum8bit] enum { - DGRAM_DIRECT_UNIQUE = 0x10, - DGRAM_DIRECT_GROUP = 0x11, - DGRAM_BCAST = 0x12, - DGRAM_ERROR = 0x13, - DGRAM_QUERY = 0x14, - DGRAM_QUERY_POSITIVE = 0x15, - DGRAM_QUERY_NEGATIVE = 0x16 - } dgram_msg_type; - - typedef [bitmap8bit] bitmap { - DGRAM_FLAG_MORE = 0x01, - DGRAM_FLAG_FIRST = 0x02, - DGRAM_FLAG_NODE_TYPE = 0x0C - } dgram_flags; - - typedef [enum8bit] enum { - DGRAM_NODE_B = 0x00, - DGRAM_NODE_P = 0x04, - DGRAM_NODE_M = 0x08, - DGRAM_NODE_NBDD = 0x0C - } dgram_node_type; - - /* a dgram_message is the main dgram body in general use */ - - /* the most common datagram type is a SMB_TRANSACTION - operation, where a SMB packet is used in the data section - of a dgram_message to hold a trans request, which in turn - holds a small command structure. It's a very strange beast - indeed. To make the code cleaner we define a basic SMB - packet in IDL here. This is not a general purpose SMB - packet, and won't be used in the core SMB client/server - code, but it does make working with these types of dgrams - easier */ - - const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON"; - const string NBT_MAILSLOT_NTLOGON = "\\MAILSLOT\\NET\\NTLOGON"; - const string NBT_MAILSLOT_GETDC = "\\MAILSLOT\\NET\\GETDC"; - const string NBT_MAILSLOT_BROWSE = "\\MAILSLOT\\BROWSE"; - - typedef [enum8bit] enum { - SMB_TRANSACTION = 0x25 - } smb_command; - - typedef struct { - [range(17,17),value(17)] uint8 wct; - uint16 total_param_count; - uint16 total_data_count; - uint16 max_param_count; - uint16 max_data_count; - uint8 max_setup_count; - uint8 pad; - uint16 trans_flags; - uint32 timeout; - uint16 reserved; - uint16 param_count; - uint16 param_offset; - uint16 data_count; - uint16 data_offset; - [range(3,3),value(3)] uint8 setup_count; - uint8 pad2; - uint16 opcode; - uint16 priority; - uint16 _class; - [value(strlen(mailslot_name)+1+data.length)] - uint16 byte_count; - astring mailslot_name; - [flag(NDR_REMAINING)] DATA_BLOB data; - } smb_trans_body; - - typedef [nodiscriminant] union { - [case(SMB_TRANSACTION)] smb_trans_body trans; - } smb_body; - - - typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct { - smb_command smb_command; - uint8 err_class; - uint8 pad; - uint16 err_code; - uint8 flags; - uint16 flags2; - uint16 pid_high; - uint8 signature[8]; - uint16 reserved; - uint16 tid; - uint16 pid; - uint16 vuid; - uint16 mid; - [switch_is(smb_command)] smb_body body; - } dgram_smb_packet; - - const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */ - - typedef [nodiscriminant] union { - [case(DGRAM_SMB)] dgram_smb_packet smb; - } dgram_message_body; - - typedef struct { - uint16 length; - uint16 offset; - nbt_name source_name; - nbt_name dest_name; - uint32 dgram_body_type; - [switch_is(dgram_body_type)] dgram_message_body body; - } dgram_message; - - typedef [enum8bit] enum { - DGRAM_ERROR_NAME_NOT_PRESENT = 0x82, - DGRAM_ERROR_INVALID_SOURCE = 0x83, - DGRAM_ERROR_INVALID_DEST = 0x84 - } dgram_err_code; - - typedef [nodiscriminant] union { - [case(DGRAM_DIRECT_UNIQUE)] dgram_message msg; - [case(DGRAM_DIRECT_GROUP)] dgram_message msg; - [case(DGRAM_BCAST)] dgram_message msg; - [case(DGRAM_ERROR)] dgram_err_code error; - [case(DGRAM_QUERY)] nbt_name dest_name; - [case(DGRAM_QUERY_POSITIVE)] nbt_name dest_name; - [case(DGRAM_QUERY_NEGATIVE)] nbt_name dest_name; - } dgram_data; - - typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct { - dgram_msg_type msg_type; - dgram_flags flags; - uint16 dgram_id; - ipv4address src_addr; - uint16 src_port; - [switch_is(msg_type)] dgram_data data; - } nbt_dgram_packet; - - - /*******************************************/ - /* \MAILSLOT\NET\NETLOGON mailslot requests */ - typedef enum { - NETLOGON_QUERY_FOR_PDC = 0x7, - NETLOGON_ANNOUNCE_UAS = 0xa, - NETLOGON_RESPONSE_FROM_PDC = 0xc, - NETLOGON_QUERY_FOR_PDC2 = 0x12, - NETLOGON_RESPONSE_FROM_PDC2 = 0x17, - NETLOGON_RESPONSE_FROM_PDC_USER = 0x19 - } nbt_netlogon_command; - - typedef [flag(NDR_LITTLE_ENDIAN),bitmap32bit] bitmap { - NETLOGON_VERSION_1 = 0x00000001, - NETLOGON_VERSION_5 = 0x00000002, - NETLOGON_VERSION_5EX = 0x00000004, - NETLOGON_VERSION_5EX_WITH_IP = 0x00000008, - NETLOGON_VERSION_WITH_CLOSEST_SITE = 0x00000010, - NETLOGON_VERSION_AVOID_NT4_EMUL = 0x01000000, - NETLOGON_VERSION_PDC = 0x10000000, - NETLOGON_VERSION_IP = 0x20000000, - NETLOGON_VERSION_LOCAL = 0x40000000, - NETLOGON_VERSION_GC = 0x80000000 - } nbt_netlogon_version; - - /* query for pdc request */ - typedef struct { - astring computer_name; - astring mailslot_name; - [flag(NDR_ALIGN2)] DATA_BLOB _pad; - nstring unicode_name; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_query_for_pdc; - - /* query for pdc request - new style */ - typedef struct { - uint16 request_count; - nstring computer_name; - nstring user_name; - astring mailslot_name; - uint32 unknown[2]; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_query_for_pdc2; - - /* response from pdc */ - typedef struct { - astring pdc_name; - [flag(NDR_ALIGN2)] DATA_BLOB _pad; - nstring unicode_pdc_name; - nstring domain_name; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_response_from_pdc; - - typedef [bitmap32bit] bitmap { - NBT_SERVER_PDC = 0x00000001, - NBT_SERVER_GC = 0x00000004, - NBT_SERVER_LDAP = 0x00000008, - NBT_SERVER_DS = 0x00000010, - NBT_SERVER_KDC = 0x00000020, - NBT_SERVER_TIMESERV = 0x00000040, - NBT_SERVER_CLOSEST = 0x00000080, - NBT_SERVER_WRITABLE = 0x00000100, - NBT_SERVER_GOOD_TIMESERV = 0x00000200, - NBT_SERVER_NDNC = 0x00000400, - NBT_SERVER_SELECT_SECRET_DOMAIN_6 = 0x00000800, - NBT_SERVER_FULL_SECRET_DOMAIN_6 = 0x00001000 - } nbt_server_type; - - typedef struct { - uint32 family; - [flag(NDR_BIG_ENDIAN)] ipv4address pdc_ip; - [flag(NDR_REMAINING)] DATA_BLOB remaining; - } nbt_dc_sock_addr; - - /* response from pdc - type2 */ - typedef struct { - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - uint8 dc_sock_addr_size; - [subcontext(0),subcontext_size(dc_sock_addr_size)] nbt_dc_sock_addr dc_sock_addr; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_response_from_pdc2; - - typedef enum netr_SamDatabaseID netr_SamDatabaseID; - - /* announce change to UAS or SAM */ - typedef struct { - netr_SamDatabaseID db_index; - hyper serial; - NTTIME timestamp; - } nbt_db_change; - - /* used to announce SAM changes */ - typedef struct { - uint32 serial_lo; - time_t timestamp; - uint32 pulse; - uint32 random; - astring pdc_name; - astring domain; - [flag(NDR_ALIGN2)] DATA_BLOB _pad; - nstring unicode_pdc_name; - nstring unicode_domain; - uint32 db_count; - nbt_db_change dbchange[db_count]; - [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; - [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_netlogon_announce_uas; - - typedef [nodiscriminant] union { - [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc; - [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2; - [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas; - [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response; - [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2; - [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2; - } nbt_netlogon_request; - - typedef [flag(NDR_NOALIGN),public] struct { - nbt_netlogon_command command; - [switch_is(command)] nbt_netlogon_request req; - } nbt_netlogon_packet; - - /*******************************************/ - /* CLDAP netlogon response */ - - /* note that these structures are very similar to, but not - quite identical to, the netlogon structures above */ - - typedef struct { - nbt_netlogon_command type; - nstring pdc_name; - nstring user_name; - nstring domain_name; - [value(1)] nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_1; - - typedef struct { - nbt_netlogon_command type; - nstring pdc_name; - nstring user_name; - nstring domain_name; - GUID domain_uuid; - GUID unknown_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - ipv4address pdc_ip; - nbt_server_type server_type; - [value(3)] nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_3; - - typedef [public] struct { - nbt_netlogon_command type; - uint16 sbz; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - [value(5)] nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_5; - - typedef struct { - nbt_netlogon_command type; - uint16 sbz; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - uint8 dc_sock_addr_size; - [subcontext(0),subcontext_size(dc_sock_addr_size)] nbt_dc_sock_addr dc_sock_addr; - [value(13)] nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_13; - - typedef [public] struct { - nbt_netlogon_command type; - uint16 sbz; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - nbt_string next_closest_site; - [value(15)] nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_15; - - typedef [public] struct { - nbt_netlogon_command type; - uint16 sbz; - nbt_server_type server_type; - GUID domain_uuid; - nbt_string forest; - nbt_string dns_domain; - nbt_string pdc_dns_name; - nbt_string domain; - nbt_string pdc_name; - nbt_string user_name; - nbt_string server_site; - nbt_string client_site; - uint8 dc_sock_addr_size; - [subcontext(0),subcontext_size(dc_sock_addr_size)] nbt_dc_sock_addr dc_sock_addr; - nbt_string next_closest_site; - [value(29)] nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_cldap_netlogon_29; - - typedef [flag(NDR_NOALIGN),public,nodiscriminant] union { - [case(0)] nbt_cldap_netlogon_1 logon1; - [case(1)] nbt_cldap_netlogon_1 logon1; - [case(2)] nbt_cldap_netlogon_3 logon3; - [case(3)] nbt_cldap_netlogon_3 logon3; - [case(4)] nbt_cldap_netlogon_5 logon5; - [case(5)] nbt_cldap_netlogon_5 logon5; - [case(6)] nbt_cldap_netlogon_5 logon5; - [case(7)] nbt_cldap_netlogon_5 logon5; - [case(8)] nbt_cldap_netlogon_13 logon13; - [case(9)] nbt_cldap_netlogon_13 logon13; - [case(10)] nbt_cldap_netlogon_13 logon13; - [case(11)] nbt_cldap_netlogon_13 logon13; - [case(12)] nbt_cldap_netlogon_13 logon13; - [case(13)] nbt_cldap_netlogon_13 logon13; - [case(14)] nbt_cldap_netlogon_13 logon13; - [case(15)] nbt_cldap_netlogon_13 logon13; - [case(16)] nbt_cldap_netlogon_1 logon1; - [case(17)] nbt_cldap_netlogon_1 logon1; - [case(18)] nbt_cldap_netlogon_3 logon3; - [case(19)] nbt_cldap_netlogon_3 logon3; - [case(20)] nbt_cldap_netlogon_15 logon15; - [case(21)] nbt_cldap_netlogon_15 logon15; - [case(22)] nbt_cldap_netlogon_15 logon15; - [case(23)] nbt_cldap_netlogon_15 logon15; - [case(24)] nbt_cldap_netlogon_15 logon15; - [case(25)] nbt_cldap_netlogon_15 logon15; - [case(26)] nbt_cldap_netlogon_15 logon15; - [case(27)] nbt_cldap_netlogon_15 logon15; - [case(28)] nbt_cldap_netlogon_15 logon15; - [case(29)] nbt_cldap_netlogon_29 logon29; - [case(30)] nbt_cldap_netlogon_29 logon29; - [case(31)] nbt_cldap_netlogon_29 logon29; - } nbt_cldap_netlogon; - - /*******************************************/ - /* \MAILSLOT\NET\NTLOGON mailslot requests */ - typedef enum { - NTLOGON_SAM_LOGON = 0x12, - NTLOGON_SAM_LOGON_REPLY = 0x13, - NTLOGON_SAM_LOGON_REPLY15 = 0x15, - NTLOGON_RESPONSE_FROM_PDC2 = 0x17 - } nbt_ntlogon_command; - - typedef struct { - uint16 request_count; - nstring computer_name; - nstring user_name; - astring mailslot_name; - samr_AcctFlags acct_control; - [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; - [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_ntlogon_sam_logon; - - typedef struct { - nstring server; - nstring user_name; - nstring domain; - nbt_netlogon_version nt_version; - uint16 lmnt_token; - uint16 lm20_token; - } nbt_ntlogon_sam_logon_reply; - - typedef [nodiscriminant] union { - [case(NTLOGON_SAM_LOGON)] nbt_ntlogon_sam_logon logon; - [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply; - [case(NTLOGON_SAM_LOGON_REPLY15)] nbt_ntlogon_sam_logon_reply reply; - [case(NTLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 reply2; - } nbt_ntlogon_request; - - typedef [flag(NDR_NOALIGN),public] struct { - nbt_ntlogon_command command; - [switch_is(command)] nbt_ntlogon_request req; - } nbt_ntlogon_packet; - - /********************************************************/ - /* \MAILSLOT\BROWSE mailslot requests */ - /* for details see http://ubiqx.org/cifs/Browsing.html */ - /********************************************************/ - typedef bitmap svcctl_ServerType svcctl_ServerType; - - typedef [enum8bit] enum { - HostAnnouncement = 1, - AnnouncementRequest = 2, - Election = 8, - GetBackupListReq = 9, - GetBackupListResp = 10, - BecomeBackup = 11, - DomainAnnouncement = 12, - MasterAnnouncement = 13, - ResetBrowserState = 14, - LocalMasterAnnouncement = 15 - } nbt_browse_opcode; - - typedef struct { - uint8 UpdateCount; - uint32 Periodicity; - [charset(DOS)] uint8 ServerName[16]; - uint8 OSMajor; - uint8 OSMinor; - svcctl_ServerType ServerType; - uint8 BroMajorVer; - uint8 BroMinorVer; - uint16 Signature; - astring Comment; - } nbt_browse_host_announcement; - - typedef struct { - uint8 Unused; - astring ResponseName; - } nbt_browse_announcement_request; - - typedef struct { - uint8 Version; - uint32 Criteria; - uint32 UpTime; /* In milliseconds */ - uint32 Reserved; /* Must be zero */ - astring ServerName; - } nbt_browse_election_request; - - typedef struct { - uint8 ReqCount; - uint32 Token; - } nbt_browse_backup_list_request; - - typedef struct { - uint8 BackupCount; - uint32 Token; - nbt_name BackupServerList[BackupCount];/* TODO: this is wrong */ - } nbt_browse_backup_list_response; - - typedef struct { - astring BrowserName; - } nbt_browse_become_backup; - - typedef struct { - uint8 UpdateCount; - uint32 Periodicity; - [charset(DOS)] uint8 ServerName[16]; - uint8 OSMajor; - uint8 OSMinor; - svcctl_ServerType ServerType; - uint32 MysteriousField; - astring Comment; - } nbt_browse_domain_announcement; - - typedef struct { - astring ServerName; - } nbt_browse_master_announcement; - - typedef struct { - uint8 Command; - } nbt_browse_reset_state; - - typedef struct { - uint8 UpdateCount; - uint32 Periodicity; - [charset(DOS)] uint8 ServerName[16]; - uint8 OSMajor; - uint8 OSMinor; - svcctl_ServerType ServerType; - uint8 BroMajorVer; - uint8 BroMinorVer; - uint16 Signature; - astring Comment; - } nbt_browse_local_master_announcement; - - typedef [nodiscriminant] union { - [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement; - [case(AnnouncementRequest)] nbt_browse_announcement_request announcement_request; - [case(Election)] nbt_browse_election_request election_request; - [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request; - [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response; - [case(BecomeBackup)] nbt_browse_become_backup become_backup; - [case(DomainAnnouncement)] nbt_browse_domain_announcement domain_announcement; - [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement; - [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state; - [case(LocalMasterAnnouncement)] nbt_browse_local_master_announcement local_master_announcement; - } nbt_browse_payload; - - typedef [public,flag(NDR_NOALIGN)] struct { - nbt_browse_opcode opcode; - [switch_is(opcode)] nbt_browse_payload payload; - } nbt_browse_packet; -} diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index 74535fc073..b4e34a07ab 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -4,7 +4,7 @@ who contributed! */ -import "lsa.idl", "samr.idl", "security.idl", "nbt.idl"; +import "misc.idl", "lsa.idl", "samr.idl", "security.idl", "nbt.idl"; #include "idl_types.h" @@ -135,13 +135,32 @@ interface netlogon netr_ChallengeResponse lm; } netr_NetworkInfo; - typedef [public,switch_type(uint16)] union { - [case(1)] netr_PasswordInfo *password; - [case(2)] netr_NetworkInfo *network; - [case(3)] netr_PasswordInfo *password; - [case(5)] netr_PasswordInfo *password; - [case(6)] netr_NetworkInfo *network; - } netr_LogonInfo; + typedef [flag(NDR_PAHEX)] struct { + netr_IdentityInfo identity_info; + lsa_String package_name; + uint32 length; + [size_is(length)] uint8 *data; + } netr_GenericInfo; + + typedef enum { + NetlogonInteractiveInformation = 1, + NetlogonNetworkInformation = 2, + NetlogonServiceInformation = 3, + NetlogonGenericInformation = 4, + NetlogonInteractiveTransitiveInformation = 5, + NetlogonNetworkTransitiveInformation = 6, + NetlogonServiceTransitiveInformation = 7 + } netr_LogonInfoClass; + + typedef [public,switch_type(netr_LogonInfoClass)] union { + [case(NetlogonInteractiveInformation)] netr_PasswordInfo *password; + [case(NetlogonNetworkInformation)] netr_NetworkInfo *network; + [case(NetlogonServiceInformation)] netr_PasswordInfo *password; + [case(NetlogonGenericInformation)] netr_GenericInfo *generic; + [case(NetlogonInteractiveTransitiveInformation)] netr_PasswordInfo *password; + [case(NetlogonNetworkTransitiveInformation)] netr_NetworkInfo *network; + [case(NetlogonServiceTransitiveInformation)] netr_PasswordInfo *password; + } netr_LogonLevel; typedef [public,flag(NDR_PAHEX)] struct { uint8 key[16]; @@ -234,12 +253,25 @@ interface netlogon lsa_String unknown4; } netr_PacInfo; + typedef [flag(NDR_PAHEX)] struct { + uint32 length; + [size_is(length)] uint8 *data; + } netr_GenericInfo2; + + typedef enum { + NetlogonValidationUasInfo = 1, + NetlogonValidationSamInfo = 2, + NetlogonValidationSamInfo2 = 3, + NetlogonValidationGenericInfo2 = 5, + NetlogonValidationSamInfo4 = 6 + } netr_ValidationInfoClass; + typedef [public,switch_type(uint16)] union { - [case(2)] netr_SamInfo2 *sam2; - [case(3)] netr_SamInfo3 *sam3; + [case(NetlogonValidationSamInfo)] netr_SamInfo2 *sam2; + [case(NetlogonValidationSamInfo2)] netr_SamInfo3 *sam3; [case(4)] netr_PacInfo *pac; - [case(5)] netr_PacInfo *pac; - [case(6)] netr_SamInfo6 *sam6; + [case(NetlogonValidationGenericInfo2)] netr_GenericInfo2 *generic; + [case(NetlogonValidationSamInfo4)] netr_SamInfo6 *sam6; } netr_Validation; typedef [public, flag(NDR_PAHEX)] struct { @@ -251,21 +283,16 @@ interface netlogon time_t timestamp; } netr_Authenticator; - typedef enum { - INTERACTIVE_LOGON_TYPE = 1, - NET_LOGON_TYPE = 2 - } netr_LogonLevel; - NTSTATUS netr_LogonSamLogon( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *computer_name, - [in,unique] netr_Authenticator *credential, - [in,out,unique] netr_Authenticator *return_authenticator, - [in] netr_LogonLevel logon_level, - [in,ref] [switch_is(logon_level)] netr_LogonInfo *logon, - [in] uint16 validation_level, + [in,unique] [string,charset(UTF16)] uint16 *server_name, + [in,unique] [string,charset(UTF16)] uint16 *computer_name, + [in,unique] netr_Authenticator *credential, + [in,out,unique] netr_Authenticator *return_authenticator, + [in] netr_LogonInfoClass logon_level, + [in,ref] [switch_is(logon_level)] netr_LogonLevel *logon, + [in] uint16 validation_level, [out,ref] [switch_is(validation_level)] netr_Validation *validation, - [out,ref] uint8 *authoritative + [out,ref] uint8 *authoritative ); @@ -277,8 +304,8 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *computer_name, [in,unique] netr_Authenticator *credential, [in,out,unique] netr_Authenticator *return_authenticator, - [in] netr_LogonLevel logon_level, - [in] [switch_is(logon_level)] netr_LogonInfo logon + [in] netr_LogonInfoClass logon_level, + [in] [switch_is(logon_level)] netr_LogonLevel logon ); @@ -423,7 +450,7 @@ interface netlogon typedef struct { lsa_String domain_name; - lsa_String comment; + lsa_String oem_information; /* comment */ dlong force_logoff_time; uint16 min_password_length; uint16 password_history_length; @@ -1056,11 +1083,11 @@ interface netlogon /*****************/ /* Function 0x15 */ - WERROR netr_NETRLOGONDUMMYROUTINE1(); + [todo] WERROR netr_NETRLOGONDUMMYROUTINE1(); /****************/ /* Function 0x16 */ - WERROR netr_NETRLOGONSETSERVICEBITS(); + [todo] WERROR netr_NETRLOGONSETSERVICEBITS(); /****************/ /* Function 0x17 */ @@ -1072,11 +1099,11 @@ interface netlogon /****************/ /* Function 0x18 */ - WERROR netr_NETRLOGONCOMPUTESERVERDIGEST(); + [todo] WERROR netr_NETRLOGONCOMPUTESERVERDIGEST(); /****************/ /* Function 0x19 */ - WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST(); + [todo] WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST(); /****************/ /* Function 0x1a */ @@ -1111,6 +1138,16 @@ interface netlogon /****************/ /* Function 0x1d */ + typedef [bitmap32bit] bitmap { + NETR_TRUST_FLAG_IN_FOREST = 0x00000001, + NETR_TRUST_FLAG_OUTBOUND = 0x00000002, + NETR_TRUST_FLAG_TREEROOT = 0x00000004, + NETR_TRUST_FLAG_PRIMARY = 0x00000008, + NETR_TRUST_FLAG_NATIVE = 0x00000010, + NETR_TRUST_FLAG_INBOUND = 0x00000020, + NETR_TRUST_FLAG_MIT_KRB5 = 0x00000080, + NETR_TRUST_FLAG_AES = 0x00000100 + } netr_TrustFlags; typedef [flag(NDR_PAHEX)] struct { uint16 length; @@ -1138,26 +1175,61 @@ interface netlogon [case(2)] netr_DomainQuery1 *query1; } netr_DomainQuery; + typedef struct { + /* these first 3 values come from the fact windows + actually encodes this structure as a UNICODE_STRING + - see MS-NRPC section 2.2.1.3.9 */ + [value(8)] uint32 length; + [value(0)] uint32 dummy; + [value(8)] uint32 size; + netr_TrustFlags flags; + uint32 parent_index; + uint32 trust_type; + uint32 trust_attributes; + } netr_trust_extension; + + typedef struct { + uint16 length; /* value is 16 when info != NULL, otherwise 0 */ + [value(length)] uint16 size; /* value is 16 when info != NULL, otherwise 0 */ + netr_trust_extension *info; + } netr_trust_extension_container; + typedef struct { lsa_String domainname; lsa_String fulldomainname; lsa_String forest; GUID guid; dom_sid2 *sid; - netr_BinaryString unknown1[4]; - uint32 unknown[4]; + netr_trust_extension_container trust_extension; + lsa_String dummystring[3]; + uint32 dummy[4]; } netr_DomainTrustInfo; + typedef struct { + uint32 policy_size; + [size_is(policy_size)] uint8 *policy; + } netr_LsaPolicyInfo; + + typedef [public,bitmap32bit] bitmap { + NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS = 0x00000001, + NETR_WS_FLAG_HANDLES_SPN_UPDATE = 0x00000002 + } netr_WorkstationFlags; + typedef struct { netr_DomainTrustInfo domaininfo; uint32 num_trusts; [size_is(num_trusts)] netr_DomainTrustInfo *trusts; - uint32 unknown[14]; /* room for expansion? */ + netr_LsaPolicyInfo lsa_policy; + lsa_String dns_hostname; + lsa_String dummystring[3]; + netr_WorkstationFlags workstation_flags; + uint32 supported_enc_types; + uint32 dummy[2]; } netr_DomainInfo1; typedef union { [case(1)] netr_DomainInfo1 *info1; - [case(2)] netr_DomainInfo1 *info1; + [case(2)] netr_DomainInfo1 *info2; } netr_DomainInfo; NTSTATUS netr_LogonGetDomainInfo( @@ -1201,7 +1273,7 @@ interface netlogon /****************/ /* Function 0x20 */ - WERROR netr_NETRLOGONSENDTOSAM(); + [todo] WERROR netr_NETRLOGONSENDTOSAM(); /****************/ /* Function 0x21 */ @@ -1237,19 +1309,10 @@ interface netlogon /****************/ /* Function 0x23 */ - WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(); + [todo] WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(); /****************/ /* Function 0x24 */ - typedef [bitmap32bit] bitmap { - NETR_TRUST_FLAG_IN_FOREST = 0x00000001, - NETR_TRUST_FLAG_OUTBOUND = 0x00000002, - NETR_TRUST_FLAG_TREEROOT = 0x00000004, - NETR_TRUST_FLAG_PRIMARY = 0x00000008, - NETR_TRUST_FLAG_NATIVE = 0x00000010, - NETR_TRUST_FLAG_INBOUND = 0x00000020 - } netr_TrustFlags; - typedef [v1_enum] enum { NETR_TRUST_TYPE_DOWNLEVEL = 1, NETR_TRUST_TYPE_UPLEVEL = 2, @@ -1321,8 +1384,8 @@ interface netlogon NTSTATUS netr_LogonSamLogonEx( [in,unique] [string,charset(UTF16)] uint16 *server_name, [in,unique] [string,charset(UTF16)] uint16 *computer_name, - [in] netr_LogonLevel logon_level, - [in,ref] [switch_is(logon_level)] netr_LogonInfo *logon, + [in] netr_LogonInfoClass logon_level, + [in,ref] [switch_is(logon_level)] netr_LogonLevel *logon, [in] uint16 validation_level, [out,ref] [switch_is(validation_level)] netr_Validation *validation, [out,ref] uint8 *authoritative, @@ -1394,8 +1457,8 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *computer_name, [in,unique] netr_Authenticator *credential, [in,out,unique] netr_Authenticator *return_authenticator, - [in] netr_LogonLevel logon_level, - [in] [switch_is(logon_level)] netr_LogonInfo logon, + [in] netr_LogonInfoClass logon_level, + [in] [switch_is(logon_level)] netr_LogonLevel logon, [in] uint16 validation_level, [out,ref] [switch_is(validation_level)] netr_Validation *validation, [out,ref] uint8 *authoritative, @@ -1404,5 +1467,5 @@ interface netlogon /****************/ /* Function 0x2e */ - WERROR netr_NETRSERVERGETTRUSTINFO(); + [todo] WERROR netr_NETRSERVERGETTRUSTINFO(); } diff --git a/source3/librpc/idl/notify.idl b/source3/librpc/idl/notify.idl deleted file mode 100644 index c4e633c254..0000000000 --- a/source3/librpc/idl/notify.idl +++ /dev/null @@ -1,56 +0,0 @@ -#include "idl_types.h" - -/* - IDL structures for notify change code - - this defines the structures used in the notify database code, and - the change notify buffers -*/ - -[ - pointer_default(unique) -] -interface notify -{ - - /* structure used in the notify database */ - typedef [public] struct { - server_id server; - uint32 filter; /* filter to apply in this directory */ - uint32 subdir_filter; /* filter to apply in child directories */ - utf8string path; - uint32 path_len; /* saves some computation on search */ - pointer private_data; - } notify_entry; - - /* - to allow for efficient search for matching entries, we - divide them by the directory depth, with a separate array - per depth. The entries within each depth are sorted by path, - allowing for a bisection search. - - The max_mask and max_mask_subdir at each depth is the - bitwise or of the filters and subdir filters for all entries - at that depth. This allows a depth to be quickly skipped if - no entries will match the target filter - */ - typedef struct { - uint32 max_mask; - uint32 max_mask_subdir; - uint32 num_entries; - notify_entry entries[num_entries]; - } notify_depth; - - typedef [public] struct { - uint32 num_depths; - notify_depth depth[num_depths]; - } notify_array; - - /* structure sent between servers in notify messages */ - typedef [public] struct { - uint32 action; - utf8string path; - pointer private_data; - } notify_event; - -} diff --git a/source3/librpc/idl/samr.idl b/source3/librpc/idl/samr.idl index e823d1d77b..cd5fe07845 100644 --- a/source3/librpc/idl/samr.idl +++ b/source3/librpc/idl/samr.idl @@ -208,7 +208,7 @@ import "misc.idl", "lsa.idl", "security.idl"; typedef struct { NTTIME force_logoff_time; - lsa_String comment; + lsa_String oem_information; /* comment */ lsa_String domain_name; lsa_String primary; /* PDC name if this is a BDC */ udlong sequence_num; @@ -218,15 +218,15 @@ import "misc.idl", "lsa.idl", "security.idl"; uint32 num_users; uint32 num_groups; uint32 num_aliases; - } samr_DomInfo2; + } samr_DomGeneralInformation; typedef struct { NTTIME force_logoff_time; } samr_DomInfo3; typedef struct { - lsa_String comment; - } samr_DomInfo4; + lsa_String oem_information; /* comment */ + } samr_DomOEMInformation; typedef struct { lsa_String domain_name; @@ -250,11 +250,11 @@ import "misc.idl", "lsa.idl", "security.idl"; } samr_DomInfo9; typedef struct { - samr_DomInfo2 info2; + samr_DomGeneralInformation general; hyper lockout_duration; hyper lockout_window; uint16 lockout_threshold; - } samr_DomInfo11; + } samr_DomGeneralInformation2; typedef struct { hyper lockout_duration; @@ -271,15 +271,15 @@ import "misc.idl", "lsa.idl", "security.idl"; typedef [switch_type(uint16)] union { [case(1)] samr_DomInfo1 info1; - [case(2)] samr_DomInfo2 info2; + [case(2)] samr_DomGeneralInformation general; [case(3)] samr_DomInfo3 info3; - [case(4)] samr_DomInfo4 info4; + [case(4)] samr_DomOEMInformation oem; [case(5)] samr_DomInfo5 info5; [case(6)] samr_DomInfo6 info6; [case(7)] samr_DomInfo7 info7; [case(8)] samr_DomInfo8 info8; [case(9)] samr_DomInfo9 info9; - [case(11)] samr_DomInfo11 info11; + [case(11)] samr_DomGeneralInformation2 general2; [case(12)] samr_DomInfo12 info12; [case(13)] samr_DomInfo13 info13; } samr_DomainInfo; diff --git a/source3/librpc/idl/spoolss.idl b/source3/librpc/idl/spoolss.idl deleted file mode 100644 index 2144393ebd..0000000000 --- a/source3/librpc/idl/spoolss.idl +++ /dev/null @@ -1,1571 +0,0 @@ -#include "idl_types.h" - -/* - spoolss interface definitions -*/ -import "security.idl", "winreg.idl"; - -[ uuid("12345678-1234-abcd-ef00-0123456789ab"), - version(1.0), - endpoint("ncacn_np:[\\pipe\\spoolss]"), - pointer_default(unique), - helpstring("Spooler SubSystem"), - helper("librpc/ndr/ndr_spoolss_buf.h") -] interface spoolss -{ - typedef [v1_enum] enum winreg_Type winreg_Type; - typedef struct { - uint16 year; - uint16 month; - uint16 day_of_week; - uint16 day; - uint16 hour; - uint16 minute; - uint16 second; - uint16 millisecond; - } spoolss_Time; - - typedef struct { - [relative] nstring *printername; - [relative] nstring *servername; - uint32 cjobs; - uint32 total_jobs; - uint32 total_bytes; - spoolss_Time time; - uint32 global_counter; - uint32 total_pages; - uint32 version; - uint32 unknown10; - uint32 unknown11; - uint32 unknown12; - uint32 session_counter; - uint32 unknown14; - uint32 printer_errors; - uint32 unknown16; - uint32 unknown17; - uint32 unknown18; - uint32 unknown19; - uint32 change_id; - uint32 unknown21; - uint32 status; - uint32 unknown23; - uint32 c_setprinter; - uint16 unknown25; - uint16 unknown26; - uint32 unknown27; - uint32 unknown28; - uint32 unknown29; - } spoolss_PrinterInfo0; - - typedef [public,gensize] struct { - [charset(UTF16)] uint16 devicename[32]; - uint16 specversion; - uint16 driverversion; - uint16 size; - [value(r->driverextra_data.length)] uint16 __driverextra_length; - uint32 fields; - uint16 orientation; - uint16 papersize; - uint16 paperlength; - uint16 paperwidth; - uint16 scale; - uint16 copies; - uint16 defaultsource; - uint16 printquality; - uint16 color; - uint16 duplex; - uint16 yresolution; - uint16 ttoption; - uint16 collate; - [charset(UTF16)] uint16 formname[32]; - uint16 logpixels; - uint32 bitsperpel; - uint32 pelswidth; - uint32 pelsheight; - uint32 displayflags; - uint32 displayfrequency; - uint32 icmmethod; - uint32 icmintent; - uint32 mediatype; - uint32 dithertype; - uint32 reserved1; - uint32 reserved2; - uint32 panningwidth; - uint32 panningheight; - [subcontext_size(__driverextra_length),subcontext(0),flag(NDR_REMAINING)] DATA_BLOB driverextra_data; - } spoolss_DeviceMode; - - typedef [public] bitmap { - PRINTER_ENUM_DEFAULT = 0x00000001, - PRINTER_ENUM_LOCAL = 0x00000002, - PRINTER_ENUM_CONNECTIONS = 0x00000004, - PRINTER_ENUM_FAVORITE = 0x00000004, - PRINTER_ENUM_NAME = 0x00000008, - PRINTER_ENUM_REMOTE = 0x00000010, - PRINTER_ENUM_SHARED = 0x00000020, - PRINTER_ENUM_NETWORK = 0x00000040, - PRINTER_ENUM_EXPAND = 0x00004000, - PRINTER_ENUM_CONTAINER = 0x00008000, - PRINTER_ENUM_ICON1 = 0x00010000, - PRINTER_ENUM_ICON2 = 0x00020000, - PRINTER_ENUM_ICON3 = 0x00040000, - PRINTER_ENUM_ICON4 = 0x00080000, - PRINTER_ENUM_ICON5 = 0x00100000, - PRINTER_ENUM_ICON6 = 0x00200000, - PRINTER_ENUM_ICON7 = 0x00400000, - PRINTER_ENUM_ICON8 = 0x00800000, - PRINTER_ENUM_HIDE = 0x01000000 - } spoolss_EnumPrinterFlags; - - typedef struct { - spoolss_EnumPrinterFlags flags; - [relative] nstring *name; - [relative] nstring *description; - [relative] nstring *comment; - } spoolss_PrinterInfo1; - - typedef bitmap { - PRINTER_ATTRIBUTE_QUEUED = 0x00000001, - PRINTER_ATTRIBUTE_DIRECT = 0x00000002, - PRINTER_ATTRIBUTE_DEFAULT = 0x00000004, - PRINTER_ATTRIBUTE_SHARED = 0x00000008, - PRINTER_ATTRIBUTE_NETWORK = 0x00000010, - PRINTER_ATTRIBUTE_HIDDEN = 0x00000020, - PRINTER_ATTRIBUTE_LOCAL = 0x00000040, - PRINTER_ATTRIBUTE_ENABLE_DEVQ = 0x00000080, - PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 0x00000100, - PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x00000200, - PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x00000400, - PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x00000800, - PRINTER_ATTRIBUTE_RAW_ONLY = 0x00001000, - PRINTER_ATTRIBUTE_PUBLISHED = 0x00002000, - PRINTER_ATTRIBUTE_FAX = 0x00004000, - PRINTER_ATTRIBUTE_TS = 0x00008000 - } spoolss_PrinterAttributes; - - typedef bitmap { - PRINTER_STATUS_PAUSED = 0x00000001, - PRINTER_STATUS_ERROR = 0x00000002, - PRINTER_STATUS_PENDING_DELETION = 0x00000004, - PRINTER_STATUS_PAPER_JAM = 0x00000008, - PRINTER_STATUS_PAPER_OUT = 0x00000010, - PRINTER_STATUS_MANUAL_FEED = 0x00000020, - PRINTER_STATUS_PAPER_PROBLEM = 0x00000040, - PRINTER_STATUS_OFFLINE = 0x00000080, - PRINTER_STATUS_IO_ACTIVE = 0x00000100, - PRINTER_STATUS_BUSY = 0x00000200, - PRINTER_STATUS_PRINTING = 0x00000400, - PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800, - PRINTER_STATUS_NOT_AVAILABLE = 0x00001000, - PRINTER_STATUS_WAITING = 0x00002000, - PRINTER_STATUS_PROCESSING = 0x00004000, - PRINTER_STATUS_INITIALIZING = 0x00008000, - PRINTER_STATUS_WARMING_UP = 0x00010000, - PRINTER_STATUS_TONER_LOW = 0x00020000, - PRINTER_STATUS_NO_TONER = 0x00040000, - PRINTER_STATUS_PAGE_PUNT = 0x00080000, - PRINTER_STATUS_USER_INTERVENTION= 0x00100000, - PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000, - PRINTER_STATUS_DOOR_OPEN = 0x00400000, - PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000, - PRINTER_STATUS_POWER_SAVE = 0x01000000 - } spoolss_PrinterStatus; - - typedef struct { - [relative] nstring *servername; - [relative] nstring *printername; - [relative] nstring *sharename; - [relative] nstring *portname; - [relative] nstring *drivername; - [relative] nstring *comment; - [relative] nstring *location; - [relative,subcontext(0)] spoolss_DeviceMode *devmode; - [relative] nstring *sepfile; - [relative] nstring *printprocessor; - [relative] nstring *datatype; - [relative] nstring *parameters; - [relative,subcontext(0)] security_descriptor *secdesc; - spoolss_PrinterAttributes attributes; - uint32 priority; - uint32 defaultpriority; - uint32 starttime; - uint32 untiltime; - spoolss_PrinterStatus status; - uint32 cjobs; - uint32 averageppm; - } spoolss_PrinterInfo2; - - typedef struct { - [relative,subcontext(0)] security_descriptor *secdesc; - } spoolss_PrinterInfo3; - - typedef struct { - [relative] nstring *printername; - [relative] nstring *servername; - spoolss_PrinterAttributes attributes; - } spoolss_PrinterInfo4; - - typedef struct { - [relative] nstring *printername; - [relative] nstring *portname; - spoolss_PrinterAttributes attributes; - uint32 device_not_selected_timeout; - uint32 transmission_retry_timeout; - } spoolss_PrinterInfo5; - - typedef struct { - spoolss_PrinterStatus status; - } spoolss_PrinterInfo6; - - typedef bitmap { - DSPRINT_PUBLISH = 0x00000001, - DSPRINT_UPDATE = 0x00000002, - DSPRINT_UNPUBLISH = 0x00000004, - DSPRINT_REPUBLISH = 0x00000008, - DSPRINT_PENDING = 0x80000000 - } spoolss_DsPrintAction; - - typedef struct { - [relative] nstring *guid; /* text form of printer guid */ - spoolss_DsPrintAction action; - } spoolss_PrinterInfo7; - - typedef struct { - [relative,subcontext(0)] spoolss_DeviceMode *devmode; - } spoolss_DeviceModeInfo; - - typedef [nodiscriminant,relative_base,public] union { - [case(0)] spoolss_PrinterInfo0 info0; - [case(1)] spoolss_PrinterInfo1 info1; - [case(2)] spoolss_PrinterInfo2 info2; - [case(3)] spoolss_PrinterInfo3 info3; - [case(4)] spoolss_PrinterInfo4 info4; - [case(5)] spoolss_PrinterInfo5 info5; - [case(6)] spoolss_PrinterInfo6 info6; - [case(7)] spoolss_PrinterInfo7 info7; - [case(8)] spoolss_DeviceModeInfo info8; - [case(9)] spoolss_DeviceModeInfo info9; - [default]; - } spoolss_PrinterInfo; - - /******************/ - /* Function: 0x00 */ - /* we are using this as internal parsing code */ - [public,noopnum,noprint] WERROR _spoolss_EnumPrinters( - [in] spoolss_EnumPrinterFlags flags, - [in,unique] [string,charset(UTF16)] uint16 *server, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumPrinters( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_PrinterInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumPrinters( - [in] spoolss_EnumPrinterFlags flags, - [in,unique] [string,charset(UTF16)] uint16 *server, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - /* what we have here is a subcontext containing an array of no discriminant unions - * and the array has no size in front - */ - [out,unique,switch_is(level),size_is(count)] spoolss_PrinterInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x01 */ - typedef struct { - [value(_ndr_size_spoolss_DeviceMode(devmode, ndr->flags))] uint32 _ndr_size; - [subcontext(4),subcontext_size(_ndr_size)] spoolss_DeviceMode *devmode; - } spoolss_DevmodeContainer; - - [public] WERROR spoolss_OpenPrinter( - [in,unique] [string,charset(UTF16)] uint16 *printername, - [in,unique] [string,charset(UTF16)] uint16 *datatype, - [in] spoolss_DevmodeContainer devmode_ctr, - [in] uint32 access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x02 */ - typedef struct { - uint32 job_id; - [relative] nstring *printer_name; - [relative] nstring *server_name; - [relative] nstring *user_name; - [relative] nstring *document_name; - [relative] nstring *data_type; - [relative] nstring *text_status; - uint32 status; - uint32 priority; - uint32 position; - uint32 total_pages; - uint32 pages_printed; - spoolss_Time time; - } spoolss_JobInfo1; - - typedef [nodiscriminant,relative_base,public] union { - [case(1)] spoolss_JobInfo1 info1; - [case(2)]; /* TODO */ - [case(3)]; /* TODO */ - [default]; - } spoolss_JobInfo; - - typedef struct { - uint32 level; - [switch_is(level)] spoolss_JobInfo info; - } spoolss_JobInfoContainer; - - typedef [v1_enum] enum { - SPOOLSS_JOB_CONTROL_PAUSE = 1, - SPOOLSS_JOB_CONTROL_RESUME = 2, - SPOOLSS_JOB_CONTROL_CANCEL = 3, - SPOOLSS_JOB_CONTROL_RESTART = 4, - SPOOLSS_JOB_CONTROL_DELETE = 5, - SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER = 6, - SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED = 7 - } spoolss_JobControl; - - WERROR spoolss_SetJob( - [in,ref] policy_handle *handle, - [in] uint32 job_id, - [in,unique] spoolss_JobInfoContainer *ctr, - [in] spoolss_JobControl command - ); - - /******************/ - /* Function: 0x03 */ - WERROR spoolss_GetJob( - [in,ref] policy_handle *handle, - [in] uint32 job_id, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_JobInfo *info, - [out] uint32 needed - ); - - /******************/ - /* Function: 0x04 */ - [public,noopnum,noprint] WERROR _spoolss_EnumJobs( - [in,ref] policy_handle *handle, - [in] uint32 firstjob, - [in] uint32 numjobs, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumJobs( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_JobInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumJobs( - [in,ref] policy_handle *handle, - [in] uint32 firstjob, - [in] uint32 numjobs, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,switch_is(level),size_is(count)] spoolss_JobInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x05 */ - WERROR spoolss_AddPrinter( - /* This function is not implemented in Samba 3 as no - clients have been observed using it. */ - ); - - /******************/ - /* Function: 0x06 */ - WERROR spoolss_DeletePrinter( - ); - - /******************/ - /* Function: 0x07 */ - typedef [v1_enum] enum { - SPOOLSS_PRINTER_CONTROL_UNPAUSE = 0, - SPOOLSS_PRINTER_CONTROL_PAUSE = 1, - SPOOLSS_PRINTER_CONTROL_RESUME = 2, - SPOOLSS_PRINTER_CONTROL_PURGE = 3, - SPOOLSS_PRINTER_CONTROL_SET_STATUS = 4 - } spoolss_PrinterControl; - - typedef [switch_type(uint32)] union { - [case(0)] spoolss_PrinterInfo0 *info0; - [case(1)] spoolss_PrinterInfo1 *info1; - [case(2)] spoolss_PrinterInfo2 *info2; - [case(3)] spoolss_PrinterInfo3 *info3; - [case(4)] spoolss_PrinterInfo4 *info4; - [case(5)] spoolss_PrinterInfo5 *info5; - [case(6)] spoolss_PrinterInfo6 *info6; - [case(7)] spoolss_PrinterInfo7 *info7; - [case(8)] spoolss_DeviceModeInfo *info8; - [case(9)] spoolss_DeviceModeInfo *info9; - [default]; - } spoolss_SetPrinterInfo; - - WERROR spoolss_SetPrinter( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,switch_is(level)] spoolss_SetPrinterInfo info, - [in] spoolss_DevmodeContainer devmode_ctr, - [in] sec_desc_buf secdesc_ctr, - [in] spoolss_PrinterControl command - ); - - /******************/ - /* Function: 0x08 */ - [public] WERROR spoolss_GetPrinter( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_PrinterInfo *info, - [out] uint32 needed - ); - - /******************/ - /* Function: 0x09 */ - WERROR spoolss_AddPrinterDriver( - ); - - typedef struct { - [relative] nstring *driver_name; - } spoolss_DriverInfo1; - - typedef [v1_enum] enum { - SPOOLSS_DRIVER_VERSION_9X = 0, - SPOOLSS_DRIVER_VERSION_NT35 = 1, - SPOOLSS_DRIVER_VERSION_NT4 = 2, - SPOOLSS_DRIVER_VERSION_200X = 3 - } spoolss_DriverOSVersion; - - typedef struct { - spoolss_DriverOSVersion version; - [relative] nstring *driver_name; - [relative] nstring *architecture; - [relative] nstring *driver_path; - [relative] nstring *data_file; - [relative] nstring *config_file; - } spoolss_DriverInfo2; - - typedef struct { - spoolss_DriverOSVersion version; - [relative] nstring *driver_name; - [relative] nstring *architecture; - [relative] nstring *driver_path; - [relative] nstring *data_file; - [relative] nstring *config_file; - [relative] nstring *help_file; - [relative] nstring_array *dependent_files; - [relative] nstring *monitor_name; - [relative] nstring *default_datatype; - } spoolss_DriverInfo3; - - typedef struct { - spoolss_DriverOSVersion version; - [relative] nstring *driver_name; - [relative] nstring *architecture; - [relative] nstring *driver_path; - [relative] nstring *data_file; - [relative] nstring *config_file; - [relative] nstring *help_file; - [relative] nstring_array *dependent_files; - [relative] nstring *monitor_name; - [relative] nstring *default_datatype; - [relative] nstring_array *previous_names; - } spoolss_DriverInfo4; - - typedef struct { - spoolss_DriverOSVersion version; - [relative] nstring *driver_name; - [relative] nstring *architecture; - [relative] nstring *driver_path; - [relative] nstring *data_file; - [relative] nstring *config_file; - uint32 driver_attributes; - uint32 config_version; - uint32 driver_version; - } spoolss_DriverInfo5; - - typedef struct { - spoolss_DriverOSVersion version; - [relative] nstring *driver_name; - [relative] nstring *architecture; - [relative] nstring *driver_path; - [relative] nstring *data_file; - [relative] nstring *config_file; - [relative] nstring *help_file; - [relative] nstring_array *dependent_files; - [relative] nstring *monitor_name; - [relative] nstring *default_datatype; - [relative] nstring_array *previous_names; - NTTIME driver_data; - hyper driver_version; - [relative] nstring *manufacturer_name; - [relative] nstring *manufacturer_url; - [relative] nstring *hardware_id; - [relative] nstring *provider; - } spoolss_DriverInfo6; - - typedef [nodiscriminant,relative_base,public] union { - [case(1)] spoolss_DriverInfo1 info1; - [case(2)] spoolss_DriverInfo2 info2; - [case(3)] spoolss_DriverInfo3 info3; - [case(4)] spoolss_DriverInfo4 info4; - [case(5)] spoolss_DriverInfo5 info5; - [case(6)] spoolss_DriverInfo6 info6; - [default]; - } spoolss_DriverInfo; - - /******************/ - /* Function: 0x0a */ - [public,noopnum,noprint] WERROR _spoolss_EnumPrinterDrivers( - [in,unique] [string,charset(UTF16)] uint16 *server, - [in,unique] [string,charset(UTF16)] uint16 *environment, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumPrinterDrivers( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_DriverInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumPrinterDrivers( - [in,unique] [string,charset(UTF16)] uint16 *server, - [in,unique] [string,charset(UTF16)] uint16 *environment, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,switch_is(level),size_is(count)] spoolss_DriverInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x0b */ - WERROR spoolss_GetPrinterDriver( - ); - - /******************/ - /* Function: 0x0c */ - typedef struct { - nstring directory_name; - } spoolss_DriverDirectoryInfo1; - - /* NOTE: it's seems that w2k3 completly ignores the level - in its server code - */ - typedef [nodiscriminant,relative_base,gensize,public] union { - [case(1)] spoolss_DriverDirectoryInfo1 info1; - [default] spoolss_DriverDirectoryInfo1 info1; - } spoolss_DriverDirectoryInfo; - - [public] WERROR spoolss_GetPrinterDriverDirectory( - [in,unique] [string,charset(UTF16)] uint16 *server, - [in,unique] [string,charset(UTF16)] uint16 *environment, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_DriverDirectoryInfo *info, - [out] uint32 needed - ); - - /******************/ - /* Function: 0x0d */ - WERROR spoolss_DeletePrinterDriver( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *server, - [in] [string,charset(UTF16)] uint16 architecture[], - [in] [string,charset(UTF16)] uint16 driver[] - ); - - /******************/ - /* Function: 0x0e */ - WERROR spoolss_AddPrintProcessor( - ); - - /******************/ - /* Function: 0x0f */ - typedef struct { - [relative] nstring *print_processor_name; - } spoolss_PrintProcessorInfo1; - - typedef [nodiscriminant,relative_base,public] union { - [case(1)] spoolss_PrintProcessorInfo1 info1; - [default]; - } spoolss_PrintProcessorInfo; - - [public,noopnum,noprint] WERROR _spoolss_EnumPrintProcessors( - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in,unique] [string,charset(UTF16)] uint16 *environment, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumPrintProcessors( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_PrintProcessorInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumPrintProcessors( - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in,unique] [string,charset(UTF16)] uint16 *environment, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,switch_is(level),size_is(count)] spoolss_PrintProcessorInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x10 */ - WERROR spoolss_GetPrintProcessorDirectory( - ); - - /******************/ - /* Function: 0x11 */ - typedef struct { - [string,charset(UTF16)] uint16 *document_name; - [string,charset(UTF16)] uint16 *output_file; - [string,charset(UTF16)] uint16 *datatype; - } spoolss_DocumentInfo1; - - typedef [switch_type(uint32)] union { - [case(1)] spoolss_DocumentInfo1 *info1; - [case(2)]; /* TODO */ - [case(3)]; /* TODO */ - [default]; - } spoolss_DocumentInfo; - - WERROR spoolss_StartDocPrinter( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,switch_is(level)] spoolss_DocumentInfo info, - [out] uint32 job_id - ); - - /******************/ - /* Function: 0x12 */ - WERROR spoolss_StartPagePrinter( - [in,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x13 */ - WERROR spoolss_WritePrinter( - [in,ref] policy_handle *handle, - [in] DATA_BLOB data, - [in,value(r->in.data.length)] uint32 _data_size, - [out] uint32 num_written - ); - - /******************/ - /* Function: 0x14 */ - WERROR spoolss_EndPagePrinter( - [in,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x15 */ - WERROR spoolss_AbortPrinter( - [in,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x16 */ - WERROR spoolss_ReadPrinter( - [in,ref] policy_handle *handle, - [in] uint32 data_size, - [out] DATA_BLOB data, - [out,value(r->out.data.length)] uint32 _data_size - ); - - /******************/ - /* Function: 0x17 */ - WERROR spoolss_EndDocPrinter( - [in,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x18 */ - WERROR spoolss_AddJob( - ); - - /******************/ - /* Function: 0x19 */ - WERROR spoolss_ScheduleJob( - ); - - /******************/ - /* Function: 0x1a */ - const string SPOOLSS_ARCHITECTURE_NT_X86 = "Windows NT x86"; - - typedef [public,gensize] struct { - [value(ndr_size_spoolss_OSVersion(r,ndr->flags))] uint32 _ndr_size; - uint32 major; - uint32 minor; - uint32 build; - [value(2)] uint32 unknown; - [subcontext(0),subcontext_size(256)] nstring extra_string; - } spoolss_OSVersion; - - typedef [public,gensize] struct { - [value(ndr_size_spoolss_OSVersionEx(r,ndr->flags))] uint32 _ndr_size; - uint32 major; - uint32 minor; - uint32 build; - [value(2)] uint32 unknown1; - [subcontext(0),subcontext_size(256)] nstring extra_string; - uint32 unknown2;/* service pack number? I saw 0 from w2k3 and 1 from winxp sp1*/ - uint32 unknown3;/* hmm? w2k3: 131346(0x20112) winxp sp1: 503382272 0x1E010100 */ - } spoolss_OSVersionEx; - - typedef [v1_enum] enum { - SPOOLSS_PRINTER_DATA_TYPE_NULL = 0, - SPOOLSS_PRINTER_DATA_TYPE_STRING = 1, - SPOOLSS_PRINTER_DATA_TYPE_BINARY = 3, - SPOOLSS_PRINTER_DATA_TYPE_UINT32 = 4, - SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY = 7 - } spoolss_PrinterDataType; - - typedef [nodiscriminant,public,gensize] union { - [case(SPOOLSS_PRINTER_DATA_TYPE_NULL)]; - [case(SPOOLSS_PRINTER_DATA_TYPE_STRING)] nstring string; - [case(SPOOLSS_PRINTER_DATA_TYPE_BINARY),flag(NDR_REMAINING)] DATA_BLOB binary; - [case(SPOOLSS_PRINTER_DATA_TYPE_UINT32)] uint32 value; - [case(SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY)] nstring_array string_array; - [default,flag(NDR_REMAINING)] DATA_BLOB data; - } spoolss_PrinterData; - - [noopnum,noprint,public] WERROR _spoolss_GetPrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], - [in] uint32 offered, - [out] spoolss_PrinterDataType type, - [out] DATA_BLOB data, - [out] uint32 needed - ); - [noopnum,noprint,public] void __spoolss_GetPrinterData( - [in] spoolss_PrinterDataType type, - [out,switch_is(type)] spoolss_PrinterData data - ); - [nopull,nopush,public] WERROR spoolss_GetPrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], - [in] uint32 offered, - [out] spoolss_PrinterDataType type, - [out,subcontext(4),subcontext_size(offered),switch_is(type)] spoolss_PrinterData data, - [out] uint32 needed - ); - - /******************/ - /* Function: 0x1b */ - [noopnum,nopull,noprint,public] WERROR _spoolss_SetPrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], - [in] spoolss_PrinterDataType type, - [in] DATA_BLOB data, - [in] uint32 _offered - ); - [noopnum,nopull,noprint,public] void __spoolss_SetPrinterData( - [in] spoolss_PrinterDataType type, - [out,switch_is(type)] spoolss_PrinterData data - ); - [nopush] WERROR spoolss_SetPrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[], - [in] spoolss_PrinterDataType type, - [in,subcontext(4),switch_is(type)] spoolss_PrinterData data, - [in,value(ndr_size_spoolss_PrinterData(&data,type,flags))] uint32 _offered - ); - - /******************/ - /* Function: 0x1c */ - WERROR spoolss_WaitForPrinterChange( - ); - - /******************/ - /* Function: 0x1d */ - [public] WERROR spoolss_ClosePrinter( - [in,out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x1e */ - typedef [v1_enum] enum { - SPOOLSS_FORM_USER = 0, - SPOOLSS_FORM_BUILTIN = 1, - SPOOLSS_FORM_PRINTER = 2 - } spoolss_FormFlags; - - typedef struct { - uint32 width; - uint32 height; - } spoolss_FormSize; - - typedef struct { - uint32 left; - uint32 top; - uint32 right; - uint32 bottom; - } spoolss_FormArea; - - typedef struct { - spoolss_FormFlags flags; - [relative] nstring *form_name; - spoolss_FormSize size; - spoolss_FormArea area; - } spoolss_FormInfo1; - - typedef [nodiscriminant,relative_base,public,gensize] union { - [case(1)] spoolss_FormInfo1 info1; - [default]; - } spoolss_FormInfo; - - typedef struct { - spoolss_FormFlags flags; - [string,charset(UTF16)] uint16 *form_name; - spoolss_FormSize size; - spoolss_FormArea area; - } spoolss_AddFormInfo1; - - typedef [switch_type(uint32)] union { - [case(1)] spoolss_AddFormInfo1 *info1; - } spoolss_AddFormInfo; - - WERROR spoolss_AddForm( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,switch_is(level)] spoolss_AddFormInfo info - ); - - /******************/ - /* Function: 0x1f */ - WERROR spoolss_DeleteForm( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 form_name[] - ); - - /******************/ - /* Function: 0x20 */ - WERROR spoolss_GetForm( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 form_name[], - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_FormInfo *info, - [out] uint32 needed - ); - - /******************/ - /* Function: 0x21 */ - WERROR spoolss_SetForm( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 form_name[], - [in] uint32 level, - [in,switch_is(level)] spoolss_AddFormInfo info - ); - - /******************/ - /* Function: 0x22 */ - [public,noopnum,noprint] WERROR _spoolss_EnumForms( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumForms( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_FormInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumForms( - [in,ref] policy_handle *handle, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,switch_is(level),size_is(count)] spoolss_FormInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - typedef struct { - [relative] nstring *port_name; - } spoolss_PortInfo1; - - typedef bitmap { - SPOOLSS_PORT_TYPE_WRITE = 0x00000001, - SPOOLSS_PORT_TYPE_READ = 0x00000002, - SPOOLSS_PORT_TYPE_REDIRECTED = 0x00000004, - SPOOLSS_PORT_TYPE_NET_ATTACHED = 0x00000008 - } spoolss_PortType; - - typedef struct { - [relative] nstring *port_name; - [relative] nstring *monitor_name; - [relative] nstring *description; - spoolss_PortType port_type; - uint32 reserved; - } spoolss_PortInfo2; - - typedef [nodiscriminant,relative_base,public] union { - [case(1)] spoolss_PortInfo1 info1; - [case(2)] spoolss_PortInfo2 info2; - [case(3)]; /* TODO */ - [default]; - } spoolss_PortInfo; - - /******************/ - /* Function: 0x23 */ - [public,noopnum,noprint] WERROR _spoolss_EnumPorts( - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumPorts( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_PortInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumPorts( - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,switch_is(level),size_is(count)] spoolss_PortInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x24 */ - typedef struct { - [relative] nstring *monitor_name; - } spoolss_MonitorInfo1; - - typedef struct { - [relative] nstring *monitor_name; - [relative] nstring *environment; - [relative] nstring *dll_name; - } spoolss_MonitorInfo2; - - typedef [nodiscriminant,relative_base,public] union { - [case(1)] spoolss_MonitorInfo1 info1; - [case(2)] spoolss_MonitorInfo2 info2; - [default]; - } spoolss_MonitorInfo; - - [public,noopnum,noprint] WERROR _spoolss_EnumMonitors( - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 count - ); - [public,noopnum,noprint] void __spoolss_EnumMonitors( - [in] uint32 level, - [in] uint32 count, - [out,switch_is(level)] spoolss_MonitorInfo info[count] - ); - [nopull,nopush] WERROR spoolss_EnumMonitors( - [in,unique] [string,charset(UTF16)] uint16 *servername, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [out,unique,switch_is(level),size_is(count)] spoolss_MonitorInfo *info, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x25 */ - WERROR spoolss_AddPort( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in] uint32 unknown, - [in] [string,charset(UTF16)] uint16 monitor_name[] - ); - - /******************/ - /* Function: 0x26 */ - WERROR spoolss_ConfigurePort( - ); - - /******************/ - /* Function: 0x27 */ - WERROR spoolss_DeletePort( - ); - - /******************/ - /* Function: 0x28 */ - WERROR spoolss_CreatePrinterIC( - ); - - /******************/ - /* Function: 0x29 */ - WERROR spoolss_PlayGDIScriptOnPrinterIC( - ); - - /******************/ - /* Function: 0x2a */ - WERROR spoolss_DeletePrinterIC( - ); - - /******************/ - /* Function: 0x2b */ - WERROR spoolss_AddPrinterConnection( - ); - - /******************/ - /* Function: 0x2c */ - WERROR spoolss_DeletePrinterConnection( - ); - - /******************/ - /* Function: 0x2d */ - WERROR spoolss_PrinterMessageBox( - /* Marked as obsolete in MSDN. "Not necessary and has - no effect". */ - ); - - /******************/ - /* Function: 0x2e */ - WERROR spoolss_AddMonitor( - ); - - /******************/ - /* Function: 0x2f */ - WERROR spoolss_DeleteMonitor( - ); - - /******************/ - /* Function: 0x30 */ - WERROR spoolss_DeletePrintProcessor( - ); - - /******************/ - /* Function: 0x31 */ - WERROR spoolss_AddPrintProvidor( - ); - - /******************/ - /* Function: 0x32 */ - WERROR spoolss_DeletePrintProvidor( - ); - - /******************/ - /* Function: 0x33 */ - WERROR spoolss_EnumPrintProcDataTypes( - ); - - /******************/ - /* Function: 0x34 */ - WERROR spoolss_ResetPrinter( - ); - - /******************/ - /* Function: 0x35 */ - WERROR spoolss_GetPrinterDriver2( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *architecture, - [in] uint32 level, - [in,unique] DATA_BLOB *buffer, - [in] uint32 offered, - [in] uint32 client_major_version, - [in] uint32 client_minor_version, - [out,unique] DATA_BLOB *info, - [out] uint32 needed, - [out] uint32 server_major_version, - [out] uint32 server_minor_version - ); - - /******************/ - /* Function: 0x36 */ - WERROR spoolss_FindFirstPrinterChangeNotification( - ); - - /******************/ - /* Function: 0x37 */ - WERROR spoolss_FindNextPrinterChangeNotification( - ); - - /******************/ - /* Function: 0x38 */ - [public] WERROR spoolss_FindClosePrinterNotify( - [in,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x39 */ - WERROR spoolss_RouterFindFirstPrinterChangeNotificationOld( - ); - - /******************/ - /* Function: 0x3a */ - [public] WERROR spoolss_ReplyOpenPrinter( - [in,string,charset(UTF16)] uint16 server_name[], - [in] uint32 printer_local, - [in] winreg_Type type, - [in] uint32 unknown1, - [in] uint32 unknown2, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x3b */ - WERROR spoolss_RouterReplyPrinter( - ); - - /******************/ - /* Function: 0x3c */ - [public] WERROR spoolss_ReplyClosePrinter( - [in,out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x3d */ - WERROR spoolss_AddPortEx( - ); - - /******************/ - /* Function: 0x3e */ - WERROR spoolss_RouterFindFirstPrinterChangeNotification( - ); - - /******************/ - /* Function: 0x3f */ - WERROR spoolss_SpoolerInit( - ); - - /******************/ - /* Function: 0x40 */ - WERROR spoolss_ResetPrinterEx( - ); - - typedef [enum16bit] enum { - SPOOLSS_FIELD_SERVER_NAME = 0, - SPOOLSS_FIELD_PRINTER_NAME = 1, - SPOOLSS_FIELD_SHARE_NAME = 2, - SPOOLSS_FIELD_PORT_NAME = 3, - SPOOLSS_FIELD_DRIVER_NAME = 4, - SPOOLSS_FIELD_COMMENT = 5, - SPOOLSS_FIELD_LOCATION = 6, - SPOOLSS_FIELD_DEVMODE = 7, - SPOOLSS_FIELD_SEPFILE = 8, - SPOOLSS_FIELD_PRINT_PROCESSOR = 9, - SPOOLSS_FIELD_PARAMETERS = 10, - SPOOLSS_FIELD_DATATYPE = 11, - SPOOLSS_FIELD_SECURITY_DESCRIPTOR=12, - SPOOLSS_FIELD_ATTRIBUTES = 13, - SPOOLSS_FIELD_PRIORITY = 14, - SPOOLSS_FIELD_DEFAULT_PRIORITY = 15, - SPOOLSS_FIELD_START_TIME = 16, - SPOOLSS_FIELD_UNTIL_TIME = 17, - SPOOLSS_FIELD_STATUS = 18, - SPOOLSS_FIELD_STATUS_STRING = 19, - SPOOLSS_FIELD_CJOBS = 20, - SPOOLSS_FIELD_AVERAGE_PPM = 21, - SPOOLSS_FIELD_TOTAL_PAGES = 22, - SPOOLSS_FIELD_PAGES_PRINTED = 23, - SPOOLSS_FIELD_TOTAL_BYTES = 24, - SPOOLSS_FIELD_BYTES_PRINTED = 25 - } spoolss_Field; - - typedef [enum16bit] enum { - SPOOLSS_NOTIFY_PRINTER = 0, - SPOOLSS_NOTIFY_JOB = 1 - } spoolss_NotifyType; - - /******************/ - /* Function: 0x41 */ - typedef struct { - spoolss_NotifyType type; - uint16 u1; - uint32 u2; - uint32 u3; - uint32 count; - [size_is(count)] spoolss_Field *fields; - } spoolss_NotifyOptionsArray; - - typedef struct { - uint32 version; - uint32 flags; - uint32 count; - [size_is(count)] spoolss_NotifyOptionsArray *options; - } spoolss_NotifyOptionsContainer; - - [public] WERROR spoolss_RemoteFindFirstPrinterChangeNotifyEx( - [in,ref] policy_handle *handle, - [in] uint32 flags, - [in] uint32 options, - [in,unique] [string,charset(UTF16)] uint16 *str, - [in] uint32 printer_local, - [in,unique] spoolss_NotifyOptionsContainer *t1 - ); - - /******************/ - /* Function: 0x42 */ - WERROR spoolss_RouterRefreshPrinterChangeNotification( - ); - - typedef struct { - uint32 size; - [size_is(size/2),unique,charset(UTF16)] uint16 *string; - } spoolss_NotifyUTF16String; - - typedef struct { - uint32 size; - [size_is(size),charset(DOS)] uint8 *string; - } spoolss_NotifyDOSString; - - typedef struct { - uint16 data[8]; - } spoolss_NotifyBlobData; - - typedef struct { - uint32 len; - [unique] spoolss_NotifyBlobData *data; - } spoolss_NotifyBlob; - - typedef [switch_type(uint32)] union { - [case(1)] dlong integer; - [case(2)] spoolss_NotifyUTF16String utf16_string; - [case(3)] spoolss_NotifyDOSString ascii_string; - [case(4)] spoolss_NotifyBlob blob; - [case(5)] spoolss_NotifyDOSString ascii_string; - } spoolss_NotifyData; - - typedef struct { - spoolss_NotifyType type; - spoolss_Field field; - uint32 variable_type; - uint32 job_id; - [switch_is(variable_type)] spoolss_NotifyData data; - } spoolss_Notify; - - typedef struct { - uint32 version; - uint32 flags; - uint32 count; - [size_is(count)] spoolss_Notify notifies[]; - } spoolss_NotifyInfo; - - /******************/ - /* Function: 0x43 */ - [public] WERROR spoolss_RemoteFindNextPrinterChangeNotifyEx( - [in,ref] policy_handle *handle, - [in] uint32 change_low, - [in,unique] spoolss_NotifyOptionsContainer *container, - [out, unique] spoolss_NotifyInfo *info - ); - - /******************/ - /* Function: 0x44 */ - WERROR spoolss_44( - ); - - typedef struct { - uint32 size; - [string,charset(UTF16)] uint16 *client; - [string,charset(UTF16)] uint16 *user; - uint32 build; - uint32 major; - uint32 minor; - uint32 processor; - } spoolss_UserLevel1; - - typedef union { - [case(1)] spoolss_UserLevel1 *level1; - } spoolss_UserLevel; - - typedef bitmap { - SERVER_ACCESS_ADMINISTER = 0x00000001, - SERVER_ACCESS_ENUMERATE = 0x00000002, - PRINTER_ACCESS_ADMINISTER = 0x00000004, - PRINTER_ACCESS_USE = 0x00000008, - JOB_ACCESS_ADMINISTER = 0x00000010 - } spoolss_AccessRights; - - /* Access rights for print servers */ - const int SERVER_ALL_ACCESS = SEC_STD_REQUIRED | - SERVER_ACCESS_ADMINISTER | - SERVER_ACCESS_ENUMERATE; - - const int SERVER_READ = SEC_STD_READ_CONTROL | - SERVER_ACCESS_ENUMERATE; - - const int SERVER_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | - SERVER_ACCESS_ADMINISTER | - SERVER_ACCESS_ENUMERATE; - - const int SERVER_EXECUTE = SEC_STD_READ_CONTROL | - SERVER_ACCESS_ENUMERATE; - - /* Access rights for printers */ - const int PRINTER_ALL_ACCESS = SEC_STD_REQUIRED | - PRINTER_ACCESS_ADMINISTER | - PRINTER_ACCESS_USE; - - const int PRINTER_READ = SEC_STD_READ_CONTROL | - PRINTER_ACCESS_USE; - - const int PRINTER_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | - PRINTER_ACCESS_USE; - - const int PRINTER_EXECUTE = SEC_STD_READ_CONTROL | - PRINTER_ACCESS_USE; - - /* Access rights for jobs */ - const int JOB_ALL_ACCESS = SEC_STD_REQUIRED | - JOB_ACCESS_ADMINISTER; - - const int JOB_READ = SEC_STD_READ_CONTROL | - JOB_ACCESS_ADMINISTER; - - const int JOB_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | - JOB_ACCESS_ADMINISTER; - - const int JOB_EXECUTE = SEC_STD_READ_CONTROL | - JOB_ACCESS_ADMINISTER; - - /* ACE masks for various print permissions */ - const int PRINTER_ACE_FULL_CONTROL = SEC_GENERIC_ALL | - PRINTER_ALL_ACCESS; - - const int PRINTER_ACE_MANAGE_DOCUMENTS = SEC_GENERIC_ALL | - READ_CONTROL_ACCESS; - - const int PRINTER_ACE_PRINT = GENERIC_EXECUTE_ACCESS | - READ_CONTROL_ACCESS | - PRINTER_ACCESS_USE; - - /******************/ - /* Function: 0x45 */ - [public] WERROR spoolss_OpenPrinterEx( - [in,unique] [string,charset(UTF16)] uint16 *printername, - [in,unique] [string,charset(UTF16)] uint16 *datatype, - [in] spoolss_DevmodeContainer devmode_ctr, - [in] uint32 access_mask, - [in] uint32 level, - [in,switch_is(level)] spoolss_UserLevel userlevel, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x46 */ - WERROR spoolss_AddPrinterEx( - [in,unique] [string,charset(UTF16)] uint16 *server, - [in] uint32 level, - [in,unique,switch_is(level)] spoolss_PrinterInfo *info, - [in] spoolss_DevmodeContainer devmode_ctr, - [in,unique] security_descriptor *secdesc, - [in] uint32 ulevel, - [in,switch_is(ulevel)] spoolss_UserLevel userlevel - ); - - /******************/ - /* Function: 0x47 */ - WERROR spoolss_47( - ); - - /******************/ - /* Function: 0x48 */ - WERROR spoolss_EnumPrinterData( - [in,ref] policy_handle *handle, - [in] uint32 enum_index, - [out,ref,size_is(value_offered/2),charset(UTF16)] uint16 *value_name, - [in] uint32 value_offered, - [out,ref] uint32 *value_needed, - [out,ref] uint32 *printerdata_type, - [out,ref] DATA_BLOB *buffer, - [in] uint32 data_offered, - [out,ref] uint32 *data_needed - ); - - /******************/ - /* Function: 0x49 */ - WERROR spoolss_DeletePrinterData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 value_name[] - ); - - /******************/ - /* Function: 0x4a */ - WERROR spoolss_4a( - ); - - /******************/ - /* Function: 0x4b */ - WERROR spoolss_4b( - ); - - /******************/ - /* Function: 0x4c */ - WERROR spoolss_4c( - ); - - /******************/ - /* Function: 0x4d */ - WERROR spoolss_SetPrinterDataEx( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 key_name[], - [in] [string,charset(UTF16)] uint16 value_name[], - [in] uint32 type, - [in] DATA_BLOB buffer, - [in] uint32 offered - ); - - /******************/ - /* Function: 0x4e */ - WERROR spoolss_GetPrinterDataEx( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 key_name[], - [in] [string,charset(UTF16)] uint16 value_name[], - [in] uint32 offered, - [out] uint32 type, - [out] DATA_BLOB buffer, - [out] uint32 needed - ); - - /******************/ - /* Function: 0x4f */ - [public] WERROR spoolss_EnumPrinterDataEx( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 key_name[], - [in] uint32 offered, - [out] DATA_BLOB buffer, - [out] uint32 needed, - [out] uint32 count - ); - - /******************/ - /* Function: 0x50 */ - [public] WERROR spoolss_EnumPrinterKey( - [in, ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 key_name[], - [out] uint32 key_buffer_size, - [out] uint16 key_buffer[key_buffer_size], - [in,out] uint32 needed - ); - - /******************/ - /* Function: 0x51 */ - WERROR spoolss_DeletePrinterDataEx( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 key_name[], - [in] [string,charset(UTF16)] uint16 value_name[] - ); - - /******************/ - /* Function: 0x52 */ - WERROR spoolss_DeletePrinterKey( - ); - - /******************/ - /* Function: 0x53 */ - WERROR spoolss_53( - ); - - /******************/ - /* Function: 0x54 */ - WERROR spoolss_DeletePrinterDriverEx( - ); - - /******************/ - /* Function: 0x55 */ - WERROR spoolss_55( - ); - - /******************/ - /* Function: 0x56 */ - WERROR spoolss_56( - ); - - /******************/ - /* Function: 0x57 */ - WERROR spoolss_57( - ); - - /******************/ - /* Function: 0x58 */ - WERROR spoolss_XcvData( - [in,ref] policy_handle *handle, - [in] [string,charset(UTF16)] uint16 function_name[], - [in] DATA_BLOB in_data, - [in,value(r->in.in_data.length)] uint32 _in_data_length, - [in] uint32 offered, - [in] uint32 unknown1, - [out] DATA_BLOB out_data, - [out] uint32 needed, - [out] uint32 unknown2 - ); - - /******************/ - /* Function: 0x59 */ - [public] WERROR spoolss_AddPrinterDriverEx( - ); - - /******************/ - /* Function: 0x5a */ - WERROR spoolss_5a( - ); - - /******************/ - /* Function: 0x5b */ - WERROR spoolss_5b( - ); - - /******************/ - /* Function: 0x5c */ - WERROR spoolss_5c( - ); - - /******************/ - /* Function: 0x5d */ - WERROR spoolss_5d( - ); - - /******************/ - /* Function: 0x5e */ - WERROR spoolss_5e( - ); - - /******************/ - /* Function: 0x5f */ - WERROR spoolss_5f( - ); -} diff --git a/source3/librpc/idl/srvsvc.idl b/source3/librpc/idl/srvsvc.idl index 0bbd24a5dd..39d72b73da 100644 --- a/source3/librpc/idl/srvsvc.idl +++ b/source3/librpc/idl/srvsvc.idl @@ -3,7 +3,6 @@ /* srvsvc interface definitions */ - import "security.idl", "svcctl.idl"; [ uuid("4b324fc8-1670-01d3-1278-5a47bf6ee188"), @@ -1377,7 +1376,7 @@ import "security.idl", "svcctl.idl"; /******************/ /* Function: 0x22 */ - WERROR srvsvc_NETRPRNAMECANONICALIZE( + [todo] WERROR srvsvc_NETRPRNAMECANONICALIZE( ); /******************/ @@ -1470,56 +1469,56 @@ import "security.idl", "svcctl.idl"; /******************/ /* Function: 0x2b */ - WERROR srvsvc_NETRDFSGETVERSION( + [todo] WERROR srvsvc_NETRDFSGETVERSION( ); /******************/ /* Function: 0x2c */ - WERROR srvsvc_NETRDFSCREATELOCALPARTITION( + [todo] WERROR srvsvc_NETRDFSCREATELOCALPARTITION( ); /******************/ /* Function: 0x2d */ - WERROR srvsvc_NETRDFSDELETELOCALPARTITION( + [todo] WERROR srvsvc_NETRDFSDELETELOCALPARTITION( ); /******************/ /* Function: 0x2e */ - WERROR srvsvc_NETRDFSSETLOCALVOLUMESTATE( + [todo] WERROR srvsvc_NETRDFSSETLOCALVOLUMESTATE( ); /******************/ /* Function: 0x2f */ - WERROR srvsvc_NETRDFSSETSERVERINFO( + [todo] WERROR srvsvc_NETRDFSSETSERVERINFO( ); /******************/ /* Function: 0x30 */ - WERROR srvsvc_NETRDFSCREATEEXITPOINT( + [todo] WERROR srvsvc_NETRDFSCREATEEXITPOINT( ); /******************/ /* Function: 0x31 */ - WERROR srvsvc_NETRDFSDELETEEXITPOINT( + [todo] WERROR srvsvc_NETRDFSDELETEEXITPOINT( ); /******************/ /* Function: 0x32 */ - WERROR srvsvc_NETRDFSMODIFYPREFIX( + [todo] WERROR srvsvc_NETRDFSMODIFYPREFIX( ); /******************/ /* Function: 0x33 */ - WERROR srvsvc_NETRDFSFIXLOCALVOLUME( + [todo] WERROR srvsvc_NETRDFSFIXLOCALVOLUME( ); /******************/ /* Function: 0x34 */ - WERROR srvsvc_NETRDFSMANAGERREPORTSITEINFO( + [todo] WERROR srvsvc_NETRDFSMANAGERREPORTSITEINFO( ); /******************/ /* Function: 0x35 */ - WERROR srvsvc_NETRSERVERTRANSPORTDELEX( + [todo] WERROR srvsvc_NETRSERVERTRANSPORTDELEX( ); } diff --git a/source3/librpc/idl/winreg.idl b/source3/librpc/idl/winreg.idl deleted file mode 100644 index 2f02419af5..0000000000 --- a/source3/librpc/idl/winreg.idl +++ /dev/null @@ -1,395 +0,0 @@ -/* - winreg interface definition -*/ - -import "lsa.idl", "initshutdown.idl", "security.idl"; - -[ - uuid("338cd001-2244-31f1-aaaa-900038001003"), - version(1.0), - endpoint("ncacn_np:[\\pipe\\winreg]","ncacn_ip_tcp:","ncalrpc:"), - pointer_default(unique), - helpstring("Remote Registry Service") -] interface winreg -{ - typedef bitmap security_secinfo security_secinfo; - - typedef [bitmap32bit] bitmap { - KEY_QUERY_VALUE = 0x00001, - KEY_SET_VALUE = 0x00002, - KEY_CREATE_SUB_KEY = 0x00004, - KEY_ENUMERATE_SUB_KEYS = 0x00008, - KEY_NOTIFY = 0x00010, - KEY_CREATE_LINK = 0x00020, - KEY_WOW64_64KEY = 0x00100, - KEY_WOW64_32KEY = 0x00200 - } winreg_AccessMask; - - typedef [v1_enum] enum { - REG_NONE = 0, - REG_SZ = 1, - REG_EXPAND_SZ = 2, - REG_BINARY = 3, - REG_DWORD = 4, - REG_DWORD_BIG_ENDIAN = 5, - REG_LINK = 6, - REG_MULTI_SZ = 7, - REG_RESOURCE_LIST = 8, - REG_FULL_RESOURCE_DESCRIPTOR = 9, - REG_RESOURCE_REQUIREMENTS_LIST = 10, - REG_QWORD = 11 - } winreg_Type; - - typedef [public,noejs] struct { - [value(strlen_m_term(name)*2)] uint16 name_len; - [value(strlen_m_term(name)*2)] uint16 name_size; - [string,charset(UTF16)] uint16 *name; - } winreg_String; - - /******************/ - /* Function: 0x00 */ - WERROR winreg_OpenHKCR( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x01 */ - WERROR winreg_OpenHKCU( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x02 */ - WERROR winreg_OpenHKLM( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x03 */ - WERROR winreg_OpenHKPD( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x04 */ - WERROR winreg_OpenHKU( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x05 */ - WERROR winreg_CloseKey( - [in,out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x06 */ - - typedef struct { - [size_is(size),length_is(len)] uint8 *data; - uint32 size; - uint32 len; - } KeySecurityData; - - typedef struct { - uint32 length; - KeySecurityData sd; - boolean8 inherit; - } winreg_SecBuf; - - typedef [v1_enum] enum { - REG_ACTION_NONE = 0, /* used by caller */ - REG_CREATED_NEW_KEY = 1, - REG_OPENED_EXISTING_KEY = 2 - } winreg_CreateAction; - - WERROR winreg_CreateKey( - [in,ref] policy_handle *handle, - [in] winreg_String name, - [in] winreg_String keyclass, - [in] uint32 options, - [in] winreg_AccessMask access_mask, - [in,unique] winreg_SecBuf *secdesc, - [out,ref] policy_handle *new_handle, - [in,out,unique] winreg_CreateAction *action_taken - ); - - /******************/ - /* Function: 0x07 */ - WERROR winreg_DeleteKey( - [in,ref] policy_handle *handle, - [in] winreg_String key - ); - - /******************/ - /* Function: 0x08 */ - WERROR winreg_DeleteValue( - [in,ref] policy_handle *handle, - [in] winreg_String value - ); - - typedef struct { - [value(strlen_m_term_null(name)*2)] uint16 length; - /* size cannot be auto-set by value() as it is the - amount of space the server is allowed to use for this - string in the reply, not its current size */ - uint16 size; - [size_is(size/2),length_is(length/2),charset(UTF16)] uint16 *name; - } winreg_StringBuf; - - /******************/ - /* Function: 0x09 */ - WERROR winreg_EnumKey( - [in,ref] policy_handle *handle, - [in] uint32 enum_index, - [in,out,ref] winreg_StringBuf *name, - [in,out,unique] winreg_StringBuf *keyclass, - [in,out,unique] NTTIME *last_changed_time - ); - - typedef struct { - [value(strlen_m_term(name)*2)] uint16 length; - /* size cannot be auto-set by value() as it is the - amount of space the server is allowed to use for this - string in the reply, not its current size */ - uint16 size; - [size_is(size/2),length_is(length/2),charset(UTF16)] uint16 *name; - } winreg_ValNameBuf; - - /******************/ - /* Function: 0x0a */ - - WERROR winreg_EnumValue( - [in,ref] policy_handle *handle, - [in] uint32 enum_index, - [in,out,ref] winreg_ValNameBuf *name, - [in,out,unique] winreg_Type *type, - [in,out,unique,size_is(*size),length_is(*length)] uint8 *value, - [in,out,unique] uint32 *size, - [in,out,unique] uint32 *length - ); - - /******************/ - /* Function: 0x0b */ - WERROR winreg_FlushKey( - [in,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x0c */ - WERROR winreg_GetKeySecurity( - [in,ref] policy_handle *handle, - [in] security_secinfo sec_info, - [in,out,ref] KeySecurityData *sd - ); - - /******************/ - /* Function: 0x0d */ - WERROR winreg_LoadKey( - [in,ref] policy_handle *handle, - [in,unique] winreg_String *keyname, - [in,unique] winreg_String *filename - ); - - /******************/ - /* Function: 0x0e */ - WERROR winreg_NotifyChangeKeyValue( - [in,ref] policy_handle *handle, - [in] uint8 watch_subtree, - [in] uint32 notify_filter, - [in] uint32 unknown, - [in] winreg_String string1, - [in] winreg_String string2, - [in] uint32 unknown2 - ); - - /******************/ - /* Function: 0x0f */ - WERROR winreg_OpenKey( - [in,ref] policy_handle *parent_handle, - [in] winreg_String keyname, - [in] uint32 unknown, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x10 */ - WERROR winreg_QueryInfoKey( - [in,ref] policy_handle *handle, - [in,out,ref] winreg_String *classname, - [out,ref] uint32 *num_subkeys, - [out,ref] uint32 *max_subkeylen, - [out,ref] uint32 *max_classlen, - [out,ref] uint32 *num_values, - [out,ref] uint32 *max_valnamelen, - [out,ref] uint32 *max_valbufsize, - [out,ref] uint32 *secdescsize, - [out,ref] NTTIME *last_changed_time - ); - - /******************/ - /* Function: 0x11 */ - WERROR winreg_QueryValue( - [in,ref] policy_handle *handle, - [in,ref] winreg_String *value_name, - [in,out,unique] winreg_Type *type, - [in,out,unique,size_is(*data_size),length_is(*value_length)] uint8 *data, - [in,out,unique] uint32 *data_size, - [in,out,unique] uint32 *value_length - ); - - /******************/ - /* Function: 0x12 */ - WERROR winreg_ReplaceKey( - ); - - /******************/ - /* Function: 0x13 */ - WERROR winreg_RestoreKey( - [in,ref] policy_handle *handle, - [in,ref] winreg_String *filename, - [in] uint32 flags - ); - - /******************/ - /* Function: 0x14 */ - - typedef struct { - uint32 data_size; - KeySecurityData sec_data; - uint8 inherit; - } KeySecurityAttribute; - - WERROR winreg_SaveKey( - [in,ref] policy_handle *handle, - [in,ref] winreg_String *filename, - [in,unique] KeySecurityAttribute *sec_attrib - ); - - /******************/ - /* Function: 0x15 */ - WERROR winreg_SetKeySecurity( - [in,ref] policy_handle *handle, - [in] winreg_AccessMask access_mask, - [in,ref] KeySecurityData *sd - ); - - /******************/ - /* Function: 0x16 */ - WERROR winreg_SetValue( - [in,ref] policy_handle *handle, - [in] winreg_String name, - [in] winreg_Type type, - [in,size_is(size),ref] uint8 *data, - [in] uint32 size - ); - - /******************/ - /* Function: 0x17 */ - WERROR winreg_UnLoadKey( - ); - - /******************/ - /* Function: 0x18 */ - WERROR winreg_InitiateSystemShutdown( - [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, - [in] uint32 timeout, - [in] uint8 force_apps, - [in] uint8 do_reboot - ); - - /******************/ - /* Function: 0x19 */ - WERROR winreg_AbortSystemShutdown( - [in,unique] uint16 *server - ); - - /******************/ - /* Function: 0x1a */ - WERROR winreg_GetVersion( - [in,ref] policy_handle *handle, - [out,ref] uint32 *version - ); - - /******************/ - /* Function: 0x1b */ - WERROR winreg_OpenHKCC( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x1c */ - WERROR winreg_OpenHKDD( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - typedef struct { - winreg_String *name; - winreg_Type type; - uint32 offset; - uint32 length; - } QueryMultipleValue; - - /******************/ - /* Function: 0x1d */ - WERROR winreg_QueryMultipleValues( - [in,ref] policy_handle *key_handle, - [in,out,ref,size_is(num_values),length_is(num_values)] QueryMultipleValue *values, - [in] uint32 num_values, - [in,out,unique,size_is(*buffer_size),length_is(*buffer_size)] uint8 *buffer, - [in,out,ref] uint32 *buffer_size - ); - - /******************/ - /* Function: 0x1e */ - WERROR winreg_InitiateSystemShutdownEx( - [in,unique] uint16 *hostname, - [in,unique] initshutdown_String *message, - [in] uint32 timeout, - [in] uint8 force_apps, - [in] uint8 do_reboot, - [in] uint32 reason - ); - - /******************/ - /* Function: 0x1f */ - WERROR winreg_SaveKeyEx( - ); - - /******************/ - /* Function: 0x20 */ - WERROR winreg_OpenHKPT( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x21 */ - WERROR winreg_OpenHKPN( - [in,unique] uint16 *system_name, - [in] winreg_AccessMask access_mask, - [out,ref] policy_handle *handle - ); - - /******************/ - /* Function: 0x22 */ - WERROR winreg_QueryMultipleValues2( - ); -} diff --git a/source3/librpc/idl/xattr.idl b/source3/librpc/idl/xattr.idl deleted file mode 100644 index 23af2df404..0000000000 --- a/source3/librpc/idl/xattr.idl +++ /dev/null @@ -1,54 +0,0 @@ -#include "idl_types.h" - -/* - IDL structures for xattrs -*/ - -[ - pointer_default(unique) -] -interface xattr -{ - /* xattrs for file systems that don't have any */ - - typedef [public] struct { - utf8string name; - DATA_BLOB value; - } tdb_xattr; - - typedef [public] struct { - uint32 num_xattrs; - tdb_xattr xattrs[num_xattrs]; - } tdb_xattrs; - - /* we store the NT ACL a NTACL xattr. It is versioned so we - can later add other acl attribs (such as posix acl mapping) - - we put this xattr in the security namespace to ensure that - only trusted users can write to the ACL - - stored in "security.NTACL" - - Version 1. raw SD stored as Samba4 does it. - Version 2. raw SD + last changed timestamp so we - can discard if this doesn't match the POSIX st_ctime. - */ - - const char *XATTR_NTACL_NAME = "security.NTACL"; - - typedef [public] struct { - security_descriptor *sd; - NTTIME last_changed; - } security_descriptor_timestamp; - - typedef [switch_type(uint16)] union { - [case(1)] security_descriptor *sd; - [case(2)] security_descriptor_timestamp *sd_ts; - } xattr_NTACL_Info; - - typedef [public] struct { - uint16 version; - [switch_is(version)] xattr_NTACL_Info info; - } xattr_NTACL; - -} diff --git a/source3/librpc/ndr/libndr.h b/source3/librpc/ndr/libndr.h deleted file mode 100644 index 155f5f1f7d..0000000000 --- a/source3/librpc/ndr/libndr.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - Unix SMB/CIFS implementation. - rpc interface definitions - Copyright (C) Andrew Tridgell 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 . -*/ - -#ifndef __LIBNDR_H__ -#define __LIBNDR_H__ - -#define _PRINTF_ATTRIBUTE(a,b) - -#include "librpc/gen_ndr/misc.h" -#include "librpc/gen_ndr/security.h" - -/* - this provides definitions for the libcli/rpc/ MSRPC library -*/ - - -/* - this is used by the token store/retrieve code -*/ -struct ndr_token_list { - struct ndr_token_list *next, *prev; - const void *key; - uint32_t value; -}; - -/* this is the base structure passed to routines that - parse MSRPC formatted data - - note that in Samba4 we use separate routines and structures for - MSRPC marshalling and unmarshalling. Also note that these routines - are being kept deliberately very simple, and are not tied to a - particular transport -*/ -struct ndr_pull { - uint32_t flags; /* LIBNDR_FLAG_* */ - uint8_t *data; - uint32_t data_size; - uint32_t offset; - - uint32_t relative_base_offset; - struct ndr_token_list *relative_base_list; - - struct ndr_token_list *relative_list; - struct ndr_token_list *array_size_list; - struct ndr_token_list *array_length_list; - struct ndr_token_list *switch_list; - - TALLOC_CTX *current_mem_ctx; - - /* this is used to ensure we generate unique reference IDs - between request and reply */ - uint32_t ptr_count; -}; - -struct ndr_pull_save { - uint32_t data_size; - uint32_t offset; - struct ndr_pull_save *next; -}; - -/* structure passed to functions that generate NDR formatted data */ -struct ndr_push { - uint32_t flags; /* LIBNDR_FLAG_* */ - uint8_t *data; - uint32_t alloc_size; - uint32_t offset; - - uint32_t relative_base_offset; - struct ndr_token_list *relative_base_list; - - struct ndr_token_list *switch_list; - struct ndr_token_list *relative_list; - struct ndr_token_list *nbt_string_list; - struct ndr_token_list *full_ptr_list; - - /* this is used to ensure we generate unique reference IDs */ - uint32_t ptr_count; -}; - -struct ndr_push_save { - uint32_t offset; - struct ndr_push_save *next; -}; - - -/* structure passed to functions that print IDL structures */ -struct ndr_print { - uint32_t flags; /* LIBNDR_FLAG_* */ - uint32_t depth; - struct ndr_token_list *switch_list; - void (*print)(struct ndr_print *, const char *, ...) PRINTF_ATTRIBUTE(2,3); - void *private_data; -}; - -#define LIBNDR_FLAG_BIGENDIAN (1<<0) -#define LIBNDR_FLAG_NOALIGN (1<<1) - -#define LIBNDR_FLAG_STR_ASCII (1<<2) -#define LIBNDR_FLAG_STR_LEN4 (1<<3) -#define LIBNDR_FLAG_STR_SIZE4 (1<<4) -#define LIBNDR_FLAG_STR_NOTERM (1<<5) -#define LIBNDR_FLAG_STR_NULLTERM (1<<6) -#define LIBNDR_FLAG_STR_SIZE2 (1<<7) -#define LIBNDR_FLAG_STR_BYTESIZE (1<<8) -#define LIBNDR_FLAG_STR_FIXLEN32 (1<<9) -#define LIBNDR_FLAG_STR_CONFORMANT (1<<10) -#define LIBNDR_FLAG_STR_CHARLEN (1<<11) -#define LIBNDR_FLAG_STR_UTF8 (1<<12) -#define LIBNDR_FLAG_STR_FIXLEN15 (1<<13) -#define LIBNDR_STRING_FLAGS (0x7FFC) - - -#define LIBNDR_FLAG_REF_ALLOC (1<<20) -#define LIBNDR_FLAG_REMAINING (1<<21) -#define LIBNDR_FLAG_ALIGN2 (1<<22) -#define LIBNDR_FLAG_ALIGN4 (1<<23) -#define LIBNDR_FLAG_ALIGN8 (1<<24) - -#define LIBNDR_ALIGN_FLAGS (LIBNDR_FLAG_ALIGN2|LIBNDR_FLAG_ALIGN4|LIBNDR_FLAG_ALIGN8) - -#define LIBNDR_PRINT_ARRAY_HEX (1<<25) -#define LIBNDR_PRINT_SET_VALUES (1<<26) - -/* used to force a section of IDL to be little-endian */ -#define LIBNDR_FLAG_LITTLE_ENDIAN (1<<27) - -/* used to check if alignment padding is zero */ -#define LIBNDR_FLAG_PAD_CHECK (1<<28) - -/* set if an object uuid will be present */ -#define LIBNDR_FLAG_OBJECT_PRESENT (1<<30) - -/* set to avoid recursion in ndr_size_*() calculation */ -#define LIBNDR_FLAG_NO_NDR_SIZE (1<<31) - -/* useful macro for debugging with DEBUG */ -#define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p) -#define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_fn_t)ndr_print_ ##type, #p, level, p) -#define NDR_PRINT_FUNCTION_DEBUG(type, flags, p) ndr_print_function_debug((ndr_print_function_t)ndr_print_ ##type, #type, flags, p) -#define NDR_PRINT_BOTH_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_BOTH, p) -#define NDR_PRINT_OUT_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_OUT, p) -#define NDR_PRINT_IN_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_IN | NDR_SET_VALUES, p) - -/* useful macro for debugging in strings */ -#define NDR_PRINT_STRUCT_STRING(ctx, type, p) ndr_print_struct_string(ctx, (ndr_print_fn_t)ndr_print_ ##type, #p, p) -#define NDR_PRINT_UNION_STRING(ctx, type, level, p) ndr_print_union_string(ctx, (ndr_print_fn_t)ndr_print_ ##type, #p, level, p) -#define NDR_PRINT_FUNCTION_STRING(ctx, type, flags, p) ndr_print_function_string(ctx, (ndr_print_function_t)ndr_print_ ##type, #type, flags, p) -#define NDR_PRINT_BOTH_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_BOTH, p) -#define NDR_PRINT_OUT_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_OUT, p) -#define NDR_PRINT_IN_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_IN | NDR_SET_VALUES, p) - -#define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) - -enum ndr_err_code { - NDR_ERR_SUCCESS = 0, - NDR_ERR_ARRAY_SIZE, - NDR_ERR_BAD_SWITCH, - NDR_ERR_OFFSET, - NDR_ERR_RELATIVE, - NDR_ERR_CHARCNV, - NDR_ERR_LENGTH, - NDR_ERR_SUBCONTEXT, - NDR_ERR_COMPRESSION, - NDR_ERR_STRING, - NDR_ERR_VALIDATE, - NDR_ERR_BUFSIZE, - NDR_ERR_ALLOC, - NDR_ERR_RANGE, - NDR_ERR_TOKEN, - NDR_ERR_IPV4ADDRESS, - NDR_ERR_INVALID_POINTER, - NDR_ERR_UNREAD_BYTES -}; - -#define NDR_ERR_CODE_IS_SUCCESS(x) (x == NDR_ERR_SUCCESS) - -#define NDR_ERR_HAVE_NO_MEMORY(x) do { \ - if (NULL == (x)) { \ - return NDR_ERR_ALLOC; \ - } \ -} while (0) - -enum ndr_compression_alg { - NDR_COMPRESSION_MSZIP = 2, - NDR_COMPRESSION_XPRESS = 3 -}; - -/* - flags passed to control parse flow -*/ -#define NDR_SCALARS 1 -#define NDR_BUFFERS 2 - -/* - flags passed to ndr_print_*() -*/ -#define NDR_IN 1 -#define NDR_OUT 2 -#define NDR_BOTH 3 -#define NDR_SET_VALUES 4 - -#define NDR_PULL_NEED_BYTES(ndr, n) do { \ - if ((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size) { \ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull bytes %u", (unsigned)n); \ - } \ -} while(0) - -#define NDR_ALIGN(ndr, n) ndr_align_size(ndr->offset, n) - -#define NDR_ROUND(size, n) (((size)+((n)-1)) & ~((n)-1)) - -#define NDR_PULL_ALIGN(ndr, n) do { \ - if (!(ndr->flags & LIBNDR_FLAG_NOALIGN)) { \ - if (ndr->flags & LIBNDR_FLAG_PAD_CHECK) { \ - ndr_check_padding(ndr, n); \ - } \ - ndr->offset = (ndr->offset + (n-1)) & ~(n-1); \ - } \ - if (ndr->offset > ndr->data_size) { \ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull align %u", (unsigned)n); \ - } \ -} while(0) - -#define NDR_PUSH_NEED_BYTES(ndr, n) NDR_CHECK(ndr_push_expand(ndr, n)) - -#define NDR_PUSH_ALIGN(ndr, n) do { \ - if (!(ndr->flags & LIBNDR_FLAG_NOALIGN)) { \ - uint32_t _pad = ((ndr->offset + (n-1)) & ~(n-1)) - ndr->offset; \ - while (_pad--) NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, 0)); \ - } \ -} while(0) - -/* these are used to make the error checking on each element in libndr - less tedious, hopefully making the code more readable */ -#define NDR_CHECK(call) do { \ - enum ndr_err_code _status; \ - _status = call; \ - if (!NDR_ERR_CODE_IS_SUCCESS(_status)) { \ - return _status; \ - } \ -} while (0) - -#define NDR_PULL_GET_MEM_CTX(ndr) (ndr->current_mem_ctx) - -#define NDR_PULL_SET_MEM_CTX(ndr, mem_ctx, flgs) do {\ - if ( !(flgs) || (ndr->flags & flgs) ) {\ - if (!(mem_ctx)) {\ - return ndr_pull_error(ndr, NDR_ERR_ALLOC, "NDR_PULL_SET_MEM_CTX(NULL): %s\n", __location__); \ - }\ - ndr->current_mem_ctx = discard_const(mem_ctx);\ - }\ -} while(0) - -#define _NDR_PULL_FIX_CURRENT_MEM_CTX(ndr) do {\ - if (!ndr->current_mem_ctx) {\ - ndr->current_mem_ctx = talloc_new(ndr);\ - if (!ndr->current_mem_ctx) {\ - return ndr_pull_error(ndr, NDR_ERR_ALLOC, "_NDR_PULL_FIX_CURRENT_MEM_CTX() failed: %s\n", __location__); \ - }\ - }\ -} while(0) - -#define NDR_PULL_ALLOC(ndr, s) do { \ - _NDR_PULL_FIX_CURRENT_MEM_CTX(ndr);\ - (s) = talloc_ptrtype(ndr->current_mem_ctx, (s)); \ - if (!(s)) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Alloc %s failed: %s\n", # s, __location__); \ -} while (0) - -#define NDR_PULL_ALLOC_N(ndr, s, n) do { \ - _NDR_PULL_FIX_CURRENT_MEM_CTX(ndr);\ - (s) = talloc_array_ptrtype(ndr->current_mem_ctx, (s), n); \ - if (!(s)) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Alloc %u * %s failed: %s\n", (unsigned)n, # s, __location__); \ -} while (0) - - -#define NDR_PUSH_ALLOC_SIZE(ndr, s, size) do { \ - (s) = talloc_array(ndr, uint8_t, size); \ - if (!(s)) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %u failed: %s\n", (unsigned)size, __location__); \ -} while (0) - -#define NDR_PUSH_ALLOC(ndr, s) do { \ - (s) = talloc_ptrtype(ndr, (s)); \ - if (!(s)) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %s failed: %s\n", # s, __location__); \ -} while (0) - -/* these are used when generic fn pointers are needed for ndr push/pull fns */ -typedef enum ndr_err_code (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, const void *); -typedef enum ndr_err_code (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *); -typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, const void *); -typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, const void *); - -extern const struct ndr_syntax_id ndr_transfer_syntax; -extern const struct ndr_syntax_id ndr64_transfer_syntax; - -struct ndr_interface_call { - const char *name; - size_t struct_size; - ndr_push_flags_fn_t ndr_push; - ndr_pull_flags_fn_t ndr_pull; - ndr_print_function_t ndr_print; - bool async; -}; - -struct ndr_interface_string_array { - uint32_t count; - const char * const *names; -}; - -struct ndr_interface_table { - const char *name; - struct ndr_syntax_id syntax_id; - const char *helpstring; - uint32_t num_calls; - const struct ndr_interface_call *calls; - const struct ndr_interface_string_array *endpoints; - const struct ndr_interface_string_array *authservices; -}; - -struct ndr_interface_list { - struct ndr_interface_list *prev, *next; - const struct ndr_interface_table *table; -}; - -#define NDR_SCALAR_PROTO(name, type) \ -enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, type v); \ -enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type *v); \ -void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, type v); - -#define NDR_BUFFER_PROTO(name, type) \ -enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, const type *v); \ -enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type *v); \ -void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, const type *v); - - -void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid); -size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags); - -#endif /* __LIBNDR_H__ */ diff --git a/source3/librpc/ndr/ndr.c b/source3/librpc/ndr/ndr.c deleted file mode 100644 index d94d12e146..0000000000 --- a/source3/librpc/ndr/ndr.c +++ /dev/null @@ -1,1101 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - libndr interface - - Copyright (C) Andrew Tridgell 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 . -*/ - -/* - this provides the core routines for NDR parsing functions - - see http://www.opengroup.org/onlinepubs/9629399/chap14.htm for details - of NDR encoding rules -*/ - -#include "includes.h" - -#define NDR_BASE_MARSHALL_SIZE 1024 - -/* this guid indicates NDR encoding in a protocol tower */ -const struct ndr_syntax_id ndr_transfer_syntax = { - { 0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8}, {0x08,0x00,0x2b,0x10,0x48,0x60} }, - 2 -}; - -const struct ndr_syntax_id ndr64_transfer_syntax = { - { 0x71710533, 0xbeba, 0x4937, {0x83, 0x19}, {0xb5,0xdb,0xef,0x9c,0xcc,0x36} }, - 1 -}; - -/* - work out the number of bytes needed to align on a n byte boundary -*/ -_PUBLIC_ size_t ndr_align_size(uint32_t offset, size_t n) -{ - if ((offset & (n-1)) == 0) return 0; - return n - (offset & (n-1)); -} - -/* - initialise a ndr parse structure from a data blob -*/ -_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx) -{ - struct ndr_pull *ndr; - - ndr = talloc_zero(mem_ctx, struct ndr_pull); - if (!ndr) return NULL; - ndr->current_mem_ctx = mem_ctx; - - ndr->data = blob->data; - ndr->data_size = blob->length; - - return ndr; -} - -/* - advance by 'size' bytes -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size) -{ - ndr->offset += size; - if (ndr->offset > ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, - "ndr_pull_advance by %u failed", - size); - } - return NDR_ERR_SUCCESS; -} - -/* - set the parse offset to 'ofs' -*/ -static enum ndr_err_code ndr_pull_set_offset(struct ndr_pull *ndr, uint32_t ofs) -{ - ndr->offset = ofs; - if (ndr->offset > ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, - "ndr_pull_set_offset %u failed", - ofs); - } - return NDR_ERR_SUCCESS; -} - -/* save the offset/size of the current ndr state */ -_PUBLIC_ void ndr_pull_save(struct ndr_pull *ndr, struct ndr_pull_save *save) -{ - save->offset = ndr->offset; - save->data_size = ndr->data_size; -} - -/* restore the size/offset of a ndr structure */ -_PUBLIC_ void ndr_pull_restore(struct ndr_pull *ndr, struct ndr_pull_save *save) -{ - ndr->offset = save->offset; - ndr->data_size = save->data_size; -} - - -/* create a ndr_push structure, ready for some marshalling */ -_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx) -{ - struct ndr_push *ndr; - - ndr = talloc_zero(mem_ctx, struct ndr_push); - if (!ndr) { - return NULL; - } - - ndr->flags = 0; - ndr->alloc_size = NDR_BASE_MARSHALL_SIZE; - ndr->data = talloc_array(ndr, uint8_t, ndr->alloc_size); - if (!ndr->data) { - return NULL; - } - - return ndr; -} - -/* return a DATA_BLOB structure for the current ndr_push marshalled data */ -_PUBLIC_ DATA_BLOB ndr_push_blob(struct ndr_push *ndr) -{ - DATA_BLOB blob; - blob = data_blob_const(ndr->data, ndr->offset); - if (ndr->alloc_size > ndr->offset) { - ndr->data[ndr->offset] = 0; - } - return blob; -} - - -/* - expand the available space in the buffer to ndr->offset + extra_size -*/ -_PUBLIC_ enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size) -{ - uint32_t size = extra_size + ndr->offset; - - if (size < ndr->offset) { - /* extra_size overflowed the offset */ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE, "Overflow in push_expand to %u", - size); - } - - if (ndr->alloc_size > size) { - return NDR_ERR_SUCCESS; - } - - ndr->alloc_size += NDR_BASE_MARSHALL_SIZE; - if (size+1 > ndr->alloc_size) { - ndr->alloc_size = size+1; - } - ndr->data = talloc_realloc(ndr, ndr->data, uint8_t, ndr->alloc_size); - if (!ndr->data) { - return ndr_push_error(ndr, NDR_ERR_ALLOC, "Failed to push_expand to %u", - ndr->alloc_size); - } - - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) -{ - va_list ap; - char *s = NULL; - int i, ret; - - va_start(ap, format); - ret = vasprintf(&s, format, ap); - va_end(ap); - - if (ret == -1) { - return; - } - - for (i=0;idepth;i++) { - DEBUGADD(0,(" ")); - } - - DEBUGADD(0,("%s\n", s)); - free(s); -} - -_PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) -{ - va_list ap; - int i; - - for (i=0;idepth;i++) { - ndr->private_data = talloc_asprintf_append_buffer( - (char *)ndr->private_data, " "); - } - - va_start(ap, format); - ndr->private_data = talloc_vasprintf_append_buffer((char *)ndr->private_data, - format, ap); - va_end(ap); - ndr->private_data = talloc_asprintf_append_buffer((char *)ndr->private_data, - "\n"); -} - -/* - a useful helper function for printing idl structures via DEBUG() -*/ -_PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr) -{ - struct ndr_print *ndr; - - ndr = talloc_zero(NULL, struct ndr_print); - if (!ndr) return; - ndr->print = ndr_print_debug_helper; - ndr->depth = 1; - ndr->flags = 0; - fn(ndr, name, ptr); - talloc_free(ndr); -} - -/* - a useful helper function for printing idl unions via DEBUG() -*/ -_PUBLIC_ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr) -{ - struct ndr_print *ndr; - - ndr = talloc_zero(NULL, struct ndr_print); - if (!ndr) return; - ndr->print = ndr_print_debug_helper; - ndr->depth = 1; - ndr->flags = 0; - ndr_print_set_switch_value(ndr, ptr, level); - fn(ndr, name, ptr); - talloc_free(ndr); -} - -/* - a useful helper function for printing idl function calls via DEBUG() -*/ -_PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr) -{ - struct ndr_print *ndr; - - ndr = talloc_zero(NULL, struct ndr_print); - if (!ndr) return; - ndr->print = ndr_print_debug_helper; - ndr->depth = 1; - ndr->flags = 0; - fn(ndr, name, flags, ptr); - talloc_free(ndr); -} - -/* - a useful helper function for printing idl structures to a string -*/ -_PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, void *ptr) -{ - struct ndr_print *ndr; - char *ret = NULL; - - ndr = talloc_zero(mem_ctx, struct ndr_print); - if (!ndr) return NULL; - ndr->private_data = talloc_strdup(ndr, ""); - if (!ndr->private_data) { - goto failed; - } - ndr->print = ndr_print_string_helper; - ndr->depth = 1; - ndr->flags = 0; - fn(ndr, name, ptr); - ret = talloc_steal(mem_ctx, (char *)ndr->private_data); -failed: - talloc_free(ndr); - return ret; -} - -/* - a useful helper function for printing idl unions to a string -*/ -_PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr) -{ - struct ndr_print *ndr; - char *ret = NULL; - - ndr = talloc_zero(mem_ctx, struct ndr_print); - if (!ndr) return NULL; - ndr->private_data = talloc_strdup(ndr, ""); - if (!ndr->private_data) { - goto failed; - } - ndr->print = ndr_print_string_helper; - ndr->depth = 1; - ndr->flags = 0; - ndr_print_set_switch_value(ndr, ptr, level); - fn(ndr, name, ptr); - ret = talloc_steal(mem_ctx, (char *)ndr->private_data); -failed: - talloc_free(ndr); - return ret; -} - -/* - a useful helper function for printing idl function calls to a string -*/ -_PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx, - ndr_print_function_t fn, const char *name, - int flags, void *ptr) -{ - struct ndr_print *ndr; - char *ret = NULL; - - ndr = talloc_zero(mem_ctx, struct ndr_print); - if (!ndr) return NULL; - ndr->private_data = talloc_strdup(ndr, ""); - if (!ndr->private_data) { - goto failed; - } - ndr->print = ndr_print_string_helper; - ndr->depth = 1; - ndr->flags = 0; - fn(ndr, name, flags, ptr); - ret = talloc_steal(mem_ctx, (char *)ndr->private_data); -failed: - talloc_free(ndr); - return ret; -} - -_PUBLIC_ void ndr_set_flags(uint32_t *pflags, uint32_t new_flags) -{ - /* the big/little endian flags are inter-dependent */ - if (new_flags & LIBNDR_FLAG_LITTLE_ENDIAN) { - (*pflags) &= ~LIBNDR_FLAG_BIGENDIAN; - } - if (new_flags & LIBNDR_FLAG_BIGENDIAN) { - (*pflags) &= ~LIBNDR_FLAG_LITTLE_ENDIAN; - } - if (new_flags & LIBNDR_FLAG_REMAINING) { - (*pflags) &= ~LIBNDR_ALIGN_FLAGS; - } - if (new_flags & LIBNDR_ALIGN_FLAGS) { - (*pflags) &= ~LIBNDR_FLAG_REMAINING; - } - (*pflags) |= new_flags; -} - -NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err) -{ - switch (ndr_err) { - case NDR_ERR_SUCCESS: - return NT_STATUS_OK; - case NDR_ERR_BUFSIZE: - return NT_STATUS_BUFFER_TOO_SMALL; - case NDR_ERR_TOKEN: - return NT_STATUS_INTERNAL_ERROR; - case NDR_ERR_ALLOC: - return NT_STATUS_NO_MEMORY; - case NDR_ERR_ARRAY_SIZE: - return NT_STATUS_ARRAY_BOUNDS_EXCEEDED; - case NDR_ERR_INVALID_POINTER: - return NT_STATUS_INVALID_PARAMETER_MIX; - case NDR_ERR_UNREAD_BYTES: - return NT_STATUS_PORT_MESSAGE_TOO_LONG; - default: - break; - } - - /* we should map all error codes to different status codes */ - return NT_STATUS_INVALID_PARAMETER; -} - -/* - * Convert an ndr error to string - */ - -const char *ndr_errstr(enum ndr_err_code err) -{ - switch (err) { - case NDR_ERR_SUCCESS: - return "NDR_ERR_SUCCESS"; - break; - case NDR_ERR_ARRAY_SIZE: - return "NDR_ERR_ARRAY_SIZE"; - break; - case NDR_ERR_BAD_SWITCH: - return "NDR_ERR_BAD_SWITCH"; - break; - case NDR_ERR_OFFSET: - return "NDR_ERR_OFFSET"; - break; - case NDR_ERR_RELATIVE: - return "NDR_ERR_RELATIVE"; - break; - case NDR_ERR_CHARCNV: - return "NDR_ERR_CHARCNV"; - break; - case NDR_ERR_LENGTH: - return "NDR_ERR_LENGTH"; - break; - case NDR_ERR_SUBCONTEXT: - return "NDR_ERR_SUBCONTEXT"; - break; - case NDR_ERR_COMPRESSION: - return "NDR_ERR_COMPRESSION"; - break; - case NDR_ERR_STRING: - return "NDR_ERR_STRING"; - break; - case NDR_ERR_VALIDATE: - return "NDR_ERR_VALIDATE"; - break; - case NDR_ERR_BUFSIZE: - return "NDR_ERR_BUFSIZE"; - break; - case NDR_ERR_ALLOC: - return "NDR_ERR_ALLOC"; - break; - case NDR_ERR_RANGE: - return "NDR_ERR_RANGE"; - break; - case NDR_ERR_TOKEN: - return "NDR_ERR_TOKEN"; - break; - case NDR_ERR_IPV4ADDRESS: - return "NDR_ERR_IPV4ADDRESS"; - break; - case NDR_ERR_INVALID_POINTER: - return "NDR_ERR_INVALID_POINTER"; - break; - case NDR_ERR_UNREAD_BYTES: - return "NDR_ERR_UNREAD_BYTES"; - break; - } - - return talloc_asprintf(talloc_tos(), "Unknown NDR error: %d", err); -} - -/* - return and possibly log an NDR error -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, - enum ndr_err_code ndr_err, - const char *format, ...) _PRINTF_ATTRIBUTE(3,4) -{ - char *s=NULL; - va_list ap; - int ret; - - va_start(ap, format); - ret = vasprintf(&s, format, ap); - va_end(ap); - - if (ret == -1) { - return NDR_ERR_ALLOC; - } - - DEBUG(1,("ndr_pull_error(%u): %s\n", ndr_err, s)); - - free(s); - - return ndr_err; -} - -/* - return and possibly log an NDR error -*/ -_PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr, - enum ndr_err_code ndr_err, - const char *format, ...) _PRINTF_ATTRIBUTE(3,4) -{ - char *s=NULL; - va_list ap; - int ret; - - va_start(ap, format); - ret = vasprintf(&s, format, ap); - va_end(ap); - - if (ret == -1) { - return NDR_ERR_ALLOC; - } - - DEBUG(1,("ndr_push_error(%u): %s\n", ndr_err, s)); - - free(s); - - return ndr_err; -} - -/* - handle subcontext buffers, which in midl land are user-marshalled, but - we use magic in pidl to make them easier to cope with -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, - struct ndr_pull **_subndr, - size_t header_size, - ssize_t size_is) -{ - struct ndr_pull *subndr; - uint32_t r_content_size; - - switch (header_size) { - case 0: { - uint32_t content_size = ndr->data_size - ndr->offset; - if (size_is >= 0) { - content_size = size_is; - } - r_content_size = content_size; - break; - } - - case 2: { - uint16_t content_size; - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &content_size)); - if (size_is >= 0 && size_is != content_size) { - return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", - (int)size_is, (int)content_size); - } - r_content_size = content_size; - break; - } - - case 4: { - uint32_t content_size; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &content_size)); - if (size_is >= 0 && size_is != content_size) { - return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", - (int)size_is, (int)content_size); - } - r_content_size = content_size; - break; - } - default: - return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) header_size %d", - (int)header_size); - } - - NDR_PULL_NEED_BYTES(ndr, r_content_size); - - subndr = talloc_zero(ndr, struct ndr_pull); - NDR_ERR_HAVE_NO_MEMORY(subndr); - subndr->flags = ndr->flags; - subndr->current_mem_ctx = ndr->current_mem_ctx; - - subndr->data = ndr->data + ndr->offset; - subndr->offset = 0; - subndr->data_size = r_content_size; - - *_subndr = subndr; - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_subcontext_end(struct ndr_pull *ndr, - struct ndr_pull *subndr, - size_t header_size, - ssize_t size_is) -{ - uint32_t advance; - if (size_is >= 0) { - advance = size_is; - } else if (header_size > 0) { - advance = subndr->data_size; - } else { - advance = subndr->offset; - } - NDR_CHECK(ndr_pull_advance(ndr, advance)); - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr, - struct ndr_push **_subndr, - size_t header_size, - ssize_t size_is) -{ - struct ndr_push *subndr; - - subndr = ndr_push_init_ctx(ndr); - NDR_ERR_HAVE_NO_MEMORY(subndr); - subndr->flags = ndr->flags; - - *_subndr = subndr; - return NDR_ERR_SUCCESS; -} - -/* - push a subcontext header -*/ -_PUBLIC_ enum ndr_err_code ndr_push_subcontext_end(struct ndr_push *ndr, - struct ndr_push *subndr, - size_t header_size, - ssize_t size_is) -{ - if (size_is >= 0) { - ssize_t padding_len = size_is - subndr->offset; - if (padding_len > 0) { - NDR_CHECK(ndr_push_zero(subndr, padding_len)); - } else if (padding_len < 0) { - return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PUSH) content_size %d is larger than size_is(%d)", - (int)subndr->offset, (int)size_is); - } - } - - switch (header_size) { - case 0: - break; - - case 2: - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, subndr->offset)); - break; - - case 4: - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, subndr->offset)); - break; - - default: - return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext header size %d", - (int)header_size); - } - - NDR_CHECK(ndr_push_bytes(ndr, subndr->data, subndr->offset)); - return NDR_ERR_SUCCESS; -} - -/* - store a token in the ndr context, for later retrieval -*/ -_PUBLIC_ enum ndr_err_code ndr_token_store(TALLOC_CTX *mem_ctx, - struct ndr_token_list **list, - const void *key, - uint32_t value) -{ - struct ndr_token_list *tok; - tok = talloc(mem_ctx, struct ndr_token_list); - NDR_ERR_HAVE_NO_MEMORY(tok); - tok->key = key; - tok->value = value; - DLIST_ADD((*list), tok); - return NDR_ERR_SUCCESS; -} - -/* - retrieve a token from a ndr context, using cmp_fn to match the tokens -*/ -_PUBLIC_ enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v, - comparison_fn_t _cmp_fn, bool _remove_tok) -{ - struct ndr_token_list *tok; - for (tok=*list;tok;tok=tok->next) { - if (_cmp_fn && _cmp_fn(tok->key,key)==0) goto found; - else if (!_cmp_fn && tok->key == key) goto found; - } - return NDR_ERR_TOKEN; -found: - *v = tok->value; - if (_remove_tok) { - DLIST_REMOVE((*list), tok); - talloc_free(tok); - } - return NDR_ERR_SUCCESS; -} - -/* - retrieve a token from a ndr context -*/ -_PUBLIC_ enum ndr_err_code ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v) -{ - return ndr_token_retrieve_cmp_fn(list, key, v, NULL, true); -} - -/* - peek at but don't removed a token from a ndr context -*/ -_PUBLIC_ uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key) -{ - enum ndr_err_code status; - uint32_t v; - - status = ndr_token_retrieve_cmp_fn(list, key, &v, NULL, false); - if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - return 0; - } - - return v; -} - -/* - pull an array size field and add it to the array_size_list token list -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_array_size(struct ndr_pull *ndr, const void *p) -{ - uint32_t size; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &size)); - return ndr_token_store(ndr, &ndr->array_size_list, p, size); -} - -/* - get the stored array size field -*/ -_PUBLIC_ uint32_t ndr_get_array_size(struct ndr_pull *ndr, const void *p) -{ - return ndr_token_peek(&ndr->array_size_list, p); -} - -/* - check the stored array size field -*/ -_PUBLIC_ enum ndr_err_code ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t size) -{ - uint32_t stored; - stored = ndr_token_peek(&ndr->array_size_list, p); - if (stored != size) { - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, - "Bad array size - got %u expected %u\n", - stored, size); - } - return NDR_ERR_SUCCESS; -} - -/* - pull an array length field and add it to the array_length_list token list -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_array_length(struct ndr_pull *ndr, const void *p) -{ - uint32_t length, offset; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &offset)); - if (offset != 0) { - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, - "non-zero array offset %u\n", offset); - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length)); - return ndr_token_store(ndr, &ndr->array_length_list, p, length); -} - -/* - get the stored array length field -*/ -_PUBLIC_ uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p) -{ - return ndr_token_peek(&ndr->array_length_list, p); -} - -/* - check the stored array length field -*/ -_PUBLIC_ enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length) -{ - uint32_t stored; - stored = ndr_token_peek(&ndr->array_length_list, p); - if (stored != length) { - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, - "Bad array length - got %u expected %u\n", - stored, length); - } - return NDR_ERR_SUCCESS; -} - -/* - store a switch value - */ -_PUBLIC_ enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val) -{ - return ndr_token_store(ndr, &ndr->switch_list, p, val); -} - -_PUBLIC_ enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val) -{ - return ndr_token_store(ndr, &ndr->switch_list, p, val); -} - -_PUBLIC_ enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val) -{ - return ndr_token_store(ndr, &ndr->switch_list, p, val); -} - -/* - retrieve a switch value - */ -_PUBLIC_ uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, const void *p) -{ - return ndr_token_peek(&ndr->switch_list, p); -} - -_PUBLIC_ uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p) -{ - return ndr_token_peek(&ndr->switch_list, p); -} - -_PUBLIC_ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p) -{ - return ndr_token_peek(&ndr->switch_list, p); -} - -/* - pull a struct from a blob using NDR -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - ndr_pull_flags_fn_t fn) -{ - struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); - NDR_ERR_HAVE_NO_MEMORY(ndr); - NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - return NDR_ERR_SUCCESS; -} - -/* - pull a struct from a blob using NDR - failing if all bytes are not consumed -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - ndr_pull_flags_fn_t fn) -{ - struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); - NDR_ERR_HAVE_NO_MEMORY(ndr); - NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - if (ndr->offset < ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, - "not all bytes consumed ofs[%u] size[%u]", - ndr->offset, ndr->data_size); - } - return NDR_ERR_SUCCESS; -} - -/* - pull a union from a blob using NDR, given the union discriminator -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - uint32_t level, ndr_pull_flags_fn_t fn) -{ - struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); - NDR_ERR_HAVE_NO_MEMORY(ndr); - NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level)); - NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - return NDR_ERR_SUCCESS; -} - -/* - pull a union from a blob using NDR, given the union discriminator, - failing if all bytes are not consumed -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - uint32_t level, ndr_pull_flags_fn_t fn) -{ - struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); - NDR_ERR_HAVE_NO_MEMORY(ndr); - NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level)); - NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - if (ndr->offset < ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, - "not all bytes consumed ofs[%u] size[%u]", - ndr->offset, ndr->data_size); - } - return NDR_ERR_SUCCESS; -} - -/* - push a struct to a blob using NDR -*/ -_PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, - ndr_push_flags_fn_t fn) -{ - struct ndr_push *ndr; - ndr = ndr_push_init_ctx(mem_ctx); - NDR_ERR_HAVE_NO_MEMORY(ndr); - - NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - - *blob = ndr_push_blob(ndr); - talloc_steal(mem_ctx, blob->data); - talloc_free(ndr); - - return NDR_ERR_SUCCESS; -} - -/* - push a union to a blob using NDR -*/ -_PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, - uint32_t level, ndr_push_flags_fn_t fn) -{ - struct ndr_push *ndr; - ndr = ndr_push_init_ctx(mem_ctx); - NDR_ERR_HAVE_NO_MEMORY(ndr); - - NDR_CHECK(ndr_push_set_switch_value(ndr, p, level)); - NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - - *blob = ndr_push_blob(ndr); - talloc_steal(mem_ctx, blob->data); - talloc_free(ndr); - - return NDR_ERR_SUCCESS; -} - -/* - generic ndr_size_*() handler for structures -*/ -_PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push) -{ - struct ndr_push *ndr; - enum ndr_err_code status; - size_t ret; - - /* avoid recursion */ - if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0; - - ndr = ndr_push_init_ctx(NULL); - if (!ndr) return 0; - ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; - status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p)); - if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(ndr); - return 0; - } - ret = ndr->offset; - talloc_free(ndr); - return ret; -} - -/* - generic ndr_size_*() handler for unions -*/ -_PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push) -{ - struct ndr_push *ndr; - enum ndr_err_code status; - size_t ret; - - /* avoid recursion */ - if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0; - - ndr = ndr_push_init_ctx(NULL); - if (!ndr) return 0; - ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; - - status = ndr_push_set_switch_value(ndr, p, level); - if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(ndr); - return 0; - } - status = push(ndr, NDR_SCALARS|NDR_BUFFERS, p); - if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(ndr); - return 0; - } - ret = ndr->offset; - talloc_free(ndr); - return ret; -} - -/* - get the current base for relative pointers for the push -*/ -_PUBLIC_ uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr) -{ - return ndr->relative_base_offset; -} - -/* - restore the old base for relative pointers for the push -*/ -_PUBLIC_ void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset) -{ - ndr->relative_base_offset = offset; -} - -/* - setup the current base for relative pointers for the push - called in the NDR_SCALAR stage -*/ -_PUBLIC_ enum ndr_err_code ndr_push_setup_relative_base_offset1(struct ndr_push *ndr, const void *p, uint32_t offset) -{ - ndr->relative_base_offset = offset; - return ndr_token_store(ndr, &ndr->relative_base_list, p, offset); -} - -/* - setup the current base for relative pointers for the push - called in the NDR_BUFFERS stage -*/ -_PUBLIC_ enum ndr_err_code ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p) -{ - return ndr_token_retrieve(&ndr->relative_base_list, p, &ndr->relative_base_offset); -} - -/* - push a relative object - stage1 - this is called during SCALARS processing -*/ -_PUBLIC_ enum ndr_err_code ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p) -{ - if (p == NULL) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - return NDR_ERR_SUCCESS; - } - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_token_store(ndr, &ndr->relative_list, p, ndr->offset)); - return ndr_push_uint32(ndr, NDR_SCALARS, 0xFFFFFFFF); -} - -/* - push a relative object - stage2 - this is called during buffers processing -*/ -_PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2(struct ndr_push *ndr, const void *p) -{ - struct ndr_push_save save; - uint32_t ptr_offset = 0xFFFFFFFF; - if (p == NULL) { - return NDR_ERR_SUCCESS; - } - ndr_push_save(ndr, &save); - NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, p, &ptr_offset)); - if (ptr_offset > ndr->offset) { - return ndr_push_error(ndr, NDR_ERR_BUFSIZE, - "ndr_push_relative_ptr2 ptr_offset(%u) > ndr->offset(%u)", - ptr_offset, ndr->offset); - } - ndr->offset = ptr_offset; - if (save.offset < ndr->relative_base_offset) { - return ndr_push_error(ndr, NDR_ERR_BUFSIZE, - "ndr_push_relative_ptr2 save.offset(%u) < ndr->relative_base_offset(%u)", - save.offset, ndr->relative_base_offset); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, save.offset - ndr->relative_base_offset)); - ndr_push_restore(ndr, &save); - return NDR_ERR_SUCCESS; -} - -/* - get the current base for relative pointers for the pull -*/ -_PUBLIC_ uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr) -{ - return ndr->relative_base_offset; -} - -/* - restore the old base for relative pointers for the pull -*/ -_PUBLIC_ void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset) -{ - ndr->relative_base_offset = offset; -} - -/* - setup the current base for relative pointers for the pull - called in the NDR_SCALAR stage -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *p, uint32_t offset) -{ - ndr->relative_base_offset = offset; - return ndr_token_store(ndr, &ndr->relative_base_list, p, offset); -} - -/* - setup the current base for relative pointers for the pull - called in the NDR_BUFFERS stage -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_setup_relative_base_offset2(struct ndr_pull *ndr, const void *p) -{ - return ndr_token_retrieve(&ndr->relative_base_list, p, &ndr->relative_base_offset); -} - -/* - pull a relative object - stage1 - called during SCALARS processing -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset) -{ - rel_offset += ndr->relative_base_offset; - if (rel_offset > ndr->data_size) { - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, - "ndr_pull_relative_ptr1 rel_offset(%u) > ndr->data_size(%u)", - rel_offset, ndr->data_size); - } - return ndr_token_store(ndr, &ndr->relative_list, p, rel_offset); -} - -/* - pull a relative object - stage2 - called during BUFFERS processing -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p) -{ - uint32_t rel_offset; - NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, p, &rel_offset)); - return ndr_pull_set_offset(ndr, rel_offset); -} diff --git a/source3/librpc/ndr/ndr_basic.c b/source3/librpc/ndr/ndr_basic.c deleted file mode 100644 index c8fa70b185..0000000000 --- a/source3/librpc/ndr/ndr_basic.c +++ /dev/null @@ -1,859 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for marshalling/unmarshalling basic types - - Copyright (C) Andrew Tridgell 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 . -*/ - -#include "includes.h" -#include "system/network.h" -#include "librpc/ndr/libndr.h" - -#define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) -#define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs)) -#define NDR_IVALS(ndr, ofs) (NDR_BE(ndr)?RIVALS(ndr->data,ofs):IVALS(ndr->data,ofs)) -#define NDR_SSVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSSVAL(ndr->data,ofs,v); } else SSVAL(ndr->data,ofs,v); } while (0) -#define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0) -#define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0) - - -/* - check for data leaks from the server by looking for non-zero pad bytes - these could also indicate that real structure elements have been - mistaken for padding in the IDL -*/ -_PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n) -{ - size_t ofs2 = (ndr->offset + (n-1)) & ~(n-1); - int i; - for (i=ndr->offset;idata[i] != 0) { - break; - } - } - if (ioffset;idata[i])); - } - DEBUG(0,("\n")); - } - -} - -/* - parse a int8_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) -{ - NDR_PULL_NEED_BYTES(ndr, 1); - *v = (int8_t)CVAL(ndr->data, ndr->offset); - ndr->offset += 1; - return NDR_ERR_SUCCESS; -} - -/* - parse a uint8_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) -{ - NDR_PULL_NEED_BYTES(ndr, 1); - *v = CVAL(ndr->data, ndr->offset); - ndr->offset += 1; - return NDR_ERR_SUCCESS; -} - -/* - parse a int16_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) -{ - NDR_PULL_ALIGN(ndr, 2); - NDR_PULL_NEED_BYTES(ndr, 2); - *v = (uint16_t)NDR_SVAL(ndr, ndr->offset); - ndr->offset += 2; - return NDR_ERR_SUCCESS; -} - -/* - parse a uint16_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) -{ - NDR_PULL_ALIGN(ndr, 2); - NDR_PULL_NEED_BYTES(ndr, 2); - *v = NDR_SVAL(ndr, ndr->offset); - ndr->offset += 2; - return NDR_ERR_SUCCESS; -} - -/* - parse a int32_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) -{ - NDR_PULL_ALIGN(ndr, 4); - NDR_PULL_NEED_BYTES(ndr, 4); - *v = NDR_IVALS(ndr, ndr->offset); - ndr->offset += 4; - return NDR_ERR_SUCCESS; -} - -/* - parse a uint32_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) -{ - NDR_PULL_ALIGN(ndr, 4); - NDR_PULL_NEED_BYTES(ndr, 4); - *v = NDR_IVAL(ndr, ndr->offset); - ndr->offset += 4; - return NDR_ERR_SUCCESS; -} - -/* - parse a pointer referent identifier -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) -{ - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); - if (*v != 0) { - ndr->ptr_count++; - } - return NDR_ERR_SUCCESS; -} - -/* - parse a ref pointer referent identifier -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) -{ - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); - /* ref pointers always point to data */ - *v = 1; - return NDR_ERR_SUCCESS; -} - -/* - parse a udlong -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) -{ - NDR_PULL_ALIGN(ndr, 4); - NDR_PULL_NEED_BYTES(ndr, 8); - *v = NDR_IVAL(ndr, ndr->offset); - *v |= (uint64_t)(NDR_IVAL(ndr, ndr->offset+4)) << 32; - ndr->offset += 8; - return NDR_ERR_SUCCESS; -} - -/* - parse a udlongr -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) -{ - NDR_PULL_ALIGN(ndr, 4); - NDR_PULL_NEED_BYTES(ndr, 8); - *v = ((uint64_t)NDR_IVAL(ndr, ndr->offset)) << 32; - *v |= NDR_IVAL(ndr, ndr->offset+4); - ndr->offset += 8; - return NDR_ERR_SUCCESS; -} - -/* - parse a dlong -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) -{ - return ndr_pull_udlong(ndr, ndr_flags, (uint64_t *)v); -} - -/* - parse a hyper -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) -{ - NDR_PULL_ALIGN(ndr, 8); - return ndr_pull_udlong(ndr, ndr_flags, v); -} - -/* - parse a pointer -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) -{ - uintptr_t h; - NDR_PULL_ALIGN(ndr, sizeof(h)); - NDR_PULL_NEED_BYTES(ndr, sizeof(h)); - memcpy(&h, ndr->data+ndr->offset, sizeof(h)); - ndr->offset += sizeof(h); - *v = (void *)h; - return NDR_ERR_SUCCESS; -} - -/* - pull a NTSTATUS -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) -{ - uint32_t v; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); - *status = NT_STATUS(v); - return NDR_ERR_SUCCESS; -} - -/* - push a NTSTATUS -*/ -_PUBLIC_ enum ndr_err_code ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) -{ - return ndr_push_uint32(ndr, ndr_flags, NT_STATUS_V(status)); -} - -_PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r) -{ - ndr->print(ndr, "%-25s: %s", name, nt_errstr(r)); -} - -/* - pull a WERROR -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) -{ - uint32_t v; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); - *status = W_ERROR(v); - return NDR_ERR_SUCCESS; -} - -/* - push a WERROR -*/ -_PUBLIC_ enum ndr_err_code ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status) -{ - return ndr_push_uint32(ndr, NDR_SCALARS, W_ERROR_V(status)); -} - -_PUBLIC_ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) -{ - ndr->print(ndr, "%-25s: %s", name, win_errstr(r)); -} - -/* - parse a set of bytes -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) -{ - NDR_PULL_NEED_BYTES(ndr, n); - memcpy(data, ndr->data + ndr->offset, n); - ndr->offset += n; - return NDR_ERR_SUCCESS; -} - -/* - pull an array of uint8 -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) -{ - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - return ndr_pull_bytes(ndr, data, n); -} - -/* - push a int8_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) -{ - NDR_PUSH_NEED_BYTES(ndr, 1); - SCVAL(ndr->data, ndr->offset, (uint8_t)v); - ndr->offset += 1; - return NDR_ERR_SUCCESS; -} - -/* - push a uint8_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) -{ - NDR_PUSH_NEED_BYTES(ndr, 1); - SCVAL(ndr->data, ndr->offset, v); - ndr->offset += 1; - return NDR_ERR_SUCCESS; -} - -/* - push a int16_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) -{ - NDR_PUSH_ALIGN(ndr, 2); - NDR_PUSH_NEED_BYTES(ndr, 2); - NDR_SSVAL(ndr, ndr->offset, (uint16_t)v); - ndr->offset += 2; - return NDR_ERR_SUCCESS; -} - -/* - push a uint16_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) -{ - NDR_PUSH_ALIGN(ndr, 2); - NDR_PUSH_NEED_BYTES(ndr, 2); - NDR_SSVAL(ndr, ndr->offset, v); - ndr->offset += 2; - return NDR_ERR_SUCCESS; -} - -/* - push a int32_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) -{ - NDR_PUSH_ALIGN(ndr, 4); - NDR_PUSH_NEED_BYTES(ndr, 4); - NDR_SIVALS(ndr, ndr->offset, v); - ndr->offset += 4; - return NDR_ERR_SUCCESS; -} - -/* - push a uint32_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) -{ - NDR_PUSH_ALIGN(ndr, 4); - NDR_PUSH_NEED_BYTES(ndr, 4); - NDR_SIVAL(ndr, ndr->offset, v); - ndr->offset += 4; - return NDR_ERR_SUCCESS; -} - -/* - push a udlong -*/ -_PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) -{ - NDR_PUSH_ALIGN(ndr, 4); - NDR_PUSH_NEED_BYTES(ndr, 8); - NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF)); - NDR_SIVAL(ndr, ndr->offset+4, (v>>32)); - ndr->offset += 8; - return NDR_ERR_SUCCESS; -} - -/* - push a udlongr -*/ -_PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) -{ - NDR_PUSH_ALIGN(ndr, 4); - NDR_PUSH_NEED_BYTES(ndr, 8); - NDR_SIVAL(ndr, ndr->offset, (v>>32)); - NDR_SIVAL(ndr, ndr->offset+4, (v & 0xFFFFFFFF)); - ndr->offset += 8; - return NDR_ERR_SUCCESS; -} - -/* - push a dlong -*/ -_PUBLIC_ enum ndr_err_code ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) -{ - return ndr_push_udlong(ndr, NDR_SCALARS, (uint64_t)v); -} - -/* - push a hyper -*/ -_PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) -{ - NDR_PUSH_ALIGN(ndr, 8); - return ndr_push_udlong(ndr, NDR_SCALARS, v); -} - -/* - push a pointer -*/ -_PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) -{ - uintptr_t h = (intptr_t)v; - NDR_PUSH_ALIGN(ndr, sizeof(h)); - NDR_PUSH_NEED_BYTES(ndr, sizeof(h)); - memcpy(ndr->data+ndr->offset, &h, sizeof(h)); - ndr->offset += sizeof(h); - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_push_align(struct ndr_push *ndr, size_t size) -{ - NDR_PUSH_ALIGN(ndr, size); - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size) -{ - NDR_PULL_ALIGN(ndr, size); - return NDR_ERR_SUCCESS; -} - -/* - push some bytes -*/ -_PUBLIC_ enum ndr_err_code ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) -{ - NDR_PUSH_NEED_BYTES(ndr, n); - memcpy(ndr->data + ndr->offset, data, n); - ndr->offset += n; - return NDR_ERR_SUCCESS; -} - -/* - push some zero bytes -*/ -_PUBLIC_ enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, uint32_t n) -{ - NDR_PUSH_NEED_BYTES(ndr, n); - memset(ndr->data + ndr->offset, 0, n); - ndr->offset += n; - return NDR_ERR_SUCCESS; -} - -/* - push an array of uint8 -*/ -_PUBLIC_ enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) -{ - if (!(ndr_flags & NDR_SCALARS)) { - return NDR_ERR_SUCCESS; - } - return ndr_push_bytes(ndr, data, n); -} - -/* - save the current position - */ -_PUBLIC_ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) -{ - save->offset = ndr->offset; -} - -/* - restore the position - */ -_PUBLIC_ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) -{ - ndr->offset = save->offset; -} - -/* - push a unique non-zero value if a pointer is non-NULL, otherwise 0 -*/ -_PUBLIC_ enum ndr_err_code ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) -{ - uint32_t ptr = 0; - if (p) { - ptr = ndr->ptr_count * 4; - ptr |= 0x00020000; - ndr->ptr_count++; - } - return ndr_push_uint32(ndr, NDR_SCALARS, ptr); -} - -/* - push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0 -*/ -_PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p) -{ - uint32_t ptr = 0; - if (p) { - /* Check if the pointer already exists and has an id */ - ptr = ndr_token_peek(&ndr->full_ptr_list, p); - if (ptr == 0) { - ndr->ptr_count++; - ptr = ndr->ptr_count; - ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr); - } - } - return ndr_push_uint32(ndr, NDR_SCALARS, ptr); -} - -/* - push always a 0, if a pointer is NULL it's a fatal error -*/ -_PUBLIC_ enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr) -{ - return ndr_push_uint32(ndr, NDR_SCALARS, 0xAEF1AEF1); -} - - -/* - push a NTTIME -*/ -_PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) -{ - NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t)); - return NDR_ERR_SUCCESS; -} - -/* - pull a NTTIME -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) -{ - NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t)); - return NDR_ERR_SUCCESS; -} - -/* - push a NTTIME -*/ -_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) -{ - t /= 10000000; - NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); - return NDR_ERR_SUCCESS; -} - -/* - pull a NTTIME_1sec -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) -{ - NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); - (*t) *= 10000000; - return NDR_ERR_SUCCESS; -} - -/* - pull a NTTIME_hyper -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) -{ - NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); - return NDR_ERR_SUCCESS; -} - -/* - push a NTTIME_hyper -*/ -_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) -{ - NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); - return NDR_ERR_SUCCESS; -} - -/* - push a time_t -*/ -_PUBLIC_ enum ndr_err_code ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) -{ - return ndr_push_uint32(ndr, ndr_flags, t); -} - -/* - pull a time_t -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) -{ - uint32_t tt; - NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &tt)); - *t = tt; - return NDR_ERR_SUCCESS; -} - - -/* - pull a ipv4address -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) -{ - struct in_addr in; - NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.s_addr)); - in.s_addr = htonl(in.s_addr); - *address = talloc_strdup(ndr->current_mem_ctx, inet_ntoa(in)); - NDR_ERR_HAVE_NO_MEMORY(*address); - return NDR_ERR_SUCCESS; -} - -/* - push a ipv4address -*/ -_PUBLIC_ enum ndr_err_code ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) -{ - uint32_t addr; - if (!is_ipaddress(address)) { - return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS, - "Invalid IPv4 address: '%s'", - address); - } - addr = inet_addr(address); - NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr))); - return NDR_ERR_SUCCESS; -} - -/* - print a ipv4address -*/ -_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name, - const char *address) -{ - ndr->print(ndr, "%-25s: %s", name, address); -} - - -_PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) -{ - ndr->print(ndr, "%s: struct %s", name, type); -} - -_PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, - const char *val, uint32_t value) -{ - if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { - ndr->print(ndr, "%-25s: %s (0x%X)", name, val?val:"UNKNOWN_ENUM_VALUE", value); - } else { - ndr->print(ndr, "%-25s: %s (%d)", name, val?val:"UNKNOWN_ENUM_VALUE", value); - } -} - -_PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value) -{ - /* this is an attempt to support multi-bit bitmap masks */ - value &= flag; - - while (!(flag & 1)) { - flag >>= 1; - value >>= 1; - } - if (flag == 1) { - ndr->print(ndr, " %d: %-25s", value, flag_name); - } else { - ndr->print(ndr, "0x%02x: %-25s (%d)", value, flag_name, value); - } -} - -_PUBLIC_ void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v) -{ - ndr->print(ndr, "%-25s: %d", name, v); -} - -_PUBLIC_ void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) -{ - ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); -} - -_PUBLIC_ void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v) -{ - ndr->print(ndr, "%-25s: %d", name, v); -} - -_PUBLIC_ void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v) -{ - ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); -} - -_PUBLIC_ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) -{ - ndr->print(ndr, "%-25s: %d", name, v); -} - -_PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) -{ - ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); -} - -_PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) -{ - ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, (unsigned long long)v, (unsigned long long)v); -} - -_PUBLIC_ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) -{ - ndr_print_udlong(ndr, name, v); -} - -_PUBLIC_ void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) -{ - ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, (unsigned long long)v, (long long)v); -} - -_PUBLIC_ void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v) -{ - ndr_print_dlong(ndr, name, v); -} - -_PUBLIC_ void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v) -{ - ndr->print(ndr, "%-25s: %p", name, v); -} - -_PUBLIC_ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) -{ - if (p) { - ndr->print(ndr, "%-25s: *", name); - } else { - ndr->print(ndr, "%-25s: NULL", name); - } -} - -_PUBLIC_ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) -{ - ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); -} - -_PUBLIC_ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) -{ - /* this is a standard NTTIME here - * as it's already converted in the pull/push code - */ - ndr_print_NTTIME(ndr, name, t); -} - -_PUBLIC_ void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t) -{ - ndr_print_NTTIME(ndr, name, t); -} - -_PUBLIC_ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) -{ - if (t == (time_t)-1 || t == 0) { - ndr->print(ndr, "%-25s: (time_t)%d", name, (int)t); - } else { - ndr->print(ndr, "%-25s: %s", name, timestring(ndr, t)); - } -} - -_PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type) -{ - if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { - ndr->print(ndr, "%-25s: union %s(case 0x%X)", name, type, level); - } else { - ndr->print(ndr, "%-25s: union %s(case %d)", name, type, level); - } -} - -_PUBLIC_ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level) -{ - ndr->print(ndr, "UNKNOWN LEVEL %u", level); -} - -_PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, - const uint8_t *data, uint32_t count) -{ - int i; - - if (count <= 600 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { - char s[1202]; - for (i=0;iprint(ndr, "%-25s: %s", name, s); - return; - } - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;idepth--; -} - -_PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) -{ - ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, (unsigned)r.length); - if (r.length) { - dump_data(10, r.data, r.length); - } -} - - -/* - push a DATA_BLOB onto the wire. -*/ -_PUBLIC_ enum ndr_err_code ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) -{ - if (ndr->flags & LIBNDR_ALIGN_FLAGS) { - if (ndr->flags & LIBNDR_FLAG_ALIGN2) { - blob.length = NDR_ALIGN(ndr, 2); - } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) { - blob.length = NDR_ALIGN(ndr, 4); - } else if (ndr->flags & LIBNDR_FLAG_ALIGN8) { - blob.length = NDR_ALIGN(ndr, 8); - } - NDR_PUSH_ALLOC_SIZE(ndr, blob.data, blob.length); - data_blob_clear(&blob); - } else if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length)); - } - NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); - return NDR_ERR_SUCCESS; -} - -/* - pull a DATA_BLOB from the wire. -*/ -_PUBLIC_ enum ndr_err_code ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) -{ - uint32_t length = 0; - - if (ndr->flags & LIBNDR_ALIGN_FLAGS) { - if (ndr->flags & LIBNDR_FLAG_ALIGN2) { - length = NDR_ALIGN(ndr, 2); - } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) { - length = NDR_ALIGN(ndr, 4); - } else if (ndr->flags & LIBNDR_FLAG_ALIGN8) { - length = NDR_ALIGN(ndr, 8); - } - if (ndr->data_size - ndr->offset < length) { - length = ndr->data_size - ndr->offset; - } - } else if (ndr->flags & LIBNDR_FLAG_REMAINING) { - length = ndr->data_size - ndr->offset; - } else { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length)); - } - NDR_PULL_NEED_BYTES(ndr, length); - *blob = data_blob_talloc(ndr->current_mem_ctx, ndr->data+ndr->offset, length); - ndr->offset += length; - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) -{ - if (!data) return ret; - return ret + data->length; -} - -_PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b) -{ - ndr->print(ndr, "%-25s: %s", name, b?"true":"false"); -} - -_PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss) -{ - char addr[INET6_ADDRSTRLEN]; - ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss)); -} diff --git a/source3/librpc/ndr/ndr_compression.c b/source3/librpc/ndr/ndr_compression.c deleted file mode 100644 index 9da0773f28..0000000000 --- a/source3/librpc/ndr/ndr_compression.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - libndr compression support - - Copyright (C) Stefan Metzmacher 2005 - - 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 . -*/ - -#include "includes.h" -#include "lib/compression/mszip.h" -#include "librpc/ndr/libndr.h" -#include "librpc/ndr/ndr_compression.h" - -static enum ndr_err_code ndr_pull_compression_mszip_chunk(struct ndr_pull *ndrpull, - struct ndr_push *ndrpush, - struct decomp_state *decomp_state, - bool *last) -{ - DATA_BLOB comp_chunk; - uint32_t comp_chunk_offset; - uint32_t comp_chunk_size; - DATA_BLOB plain_chunk; - uint32_t plain_chunk_offset; - uint32_t plain_chunk_size; - int ret; - - NDR_CHECK(ndr_pull_uint32(ndrpull, NDR_SCALARS, &plain_chunk_size)); - if (plain_chunk_size > 0x00008000) { - return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, "Bad MSZIP plain chunk size %08X > 0x00008000 (PULL)", - plain_chunk_size); - } - - NDR_CHECK(ndr_pull_uint32(ndrpull, NDR_SCALARS, &comp_chunk_size)); - - DEBUG(10,("MSZIP plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", - plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); - - comp_chunk_offset = ndrpull->offset; - NDR_CHECK(ndr_pull_advance(ndrpull, comp_chunk_size)); - comp_chunk.length = comp_chunk_size; - comp_chunk.data = ndrpull->data + comp_chunk_offset; - - plain_chunk_offset = ndrpush->offset; - NDR_CHECK(ndr_push_zero(ndrpush, plain_chunk_size)); - plain_chunk.length = plain_chunk_size; - plain_chunk.data = ndrpush->data + plain_chunk_offset; - - ret = ZIPdecompress(decomp_state, &comp_chunk, &plain_chunk); - if (ret != DECR_OK) { - return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, "Bad ZIPdecompress() error %d (PULL)", - ret); - } - - if ((plain_chunk_size < 0x00008000) || (ndrpull->offset+4 >= ndrpull->data_size)) { - /* this is the last chunk */ - *last = true; - } - - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_compression_mszip(struct ndr_pull *subndr, - struct ndr_pull **_comndr, - ssize_t decompressed_len) -{ - struct ndr_push *ndrpush; - struct ndr_pull *comndr; - DATA_BLOB uncompressed; - uint32_t payload_header[4]; - uint32_t payload_size; - uint32_t payload_offset; - uint8_t *payload; - struct decomp_state *decomp_state; - bool last = false; - - ndrpush = ndr_push_init_ctx(subndr); - NDR_ERR_HAVE_NO_MEMORY(ndrpush); - - decomp_state = ZIPdecomp_state(subndr); - NDR_ERR_HAVE_NO_MEMORY(decomp_state); - - while (!last) { - NDR_CHECK(ndr_pull_compression_mszip_chunk(subndr, ndrpush, decomp_state, &last)); - } - - uncompressed = ndr_push_blob(ndrpush); - - if (uncompressed.length != decompressed_len) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP uncompressed_len [%u] != [%d] (PULL)", - (int)uncompressed.length, (int)decompressed_len); - } - - comndr = talloc_zero(subndr, struct ndr_pull); - NDR_ERR_HAVE_NO_MEMORY(comndr); - comndr->flags = subndr->flags; - comndr->current_mem_ctx = subndr->current_mem_ctx; - - comndr->data = uncompressed.data; - comndr->data_size = uncompressed.length; - comndr->offset = 0; - - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[0])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[1])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[2])); - NDR_CHECK(ndr_pull_uint32(comndr, NDR_SCALARS, &payload_header[3])); - - if (payload_header[0] != 0x00081001) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP payload_header[0] [0x%08X] != [0x00081001] (PULL)", - payload_header[0]); - } - if (payload_header[1] != 0xCCCCCCCC) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP payload_header[1] [0x%08X] != [0xCCCCCCCC] (PULL)", - payload_header[1]); - } - - payload_size = payload_header[2]; - - if (payload_header[3] != 0x00000000) { - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad MSZIP payload_header[3] [0x%08X] != [0x00000000] (PULL)", - payload_header[3]); - } - - payload_offset = comndr->offset; - NDR_CHECK(ndr_pull_advance(comndr, payload_size)); - payload = comndr->data + payload_offset; - - comndr->data = payload; - comndr->data_size = payload_size; - comndr->offset = 0; - - *_comndr = comndr; - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_push_compression_mszip(struct ndr_push *subndr, - struct ndr_push *comndr) -{ - return ndr_push_error(subndr, NDR_ERR_COMPRESSION, "Sorry MSZIP compression is not supported yet (PUSH)"); -} - -static enum ndr_err_code ndr_pull_compression_xpress_chunk(struct ndr_pull *ndrpull, - struct ndr_push *ndrpush, - bool *last) -{ - DATA_BLOB comp_chunk; - uint32_t comp_chunk_offset; - uint32_t comp_chunk_size; - uint32_t plain_chunk_size; - - comp_chunk_offset = ndrpull->offset; - - NDR_CHECK(ndr_pull_uint32(ndrpull, NDR_SCALARS, &plain_chunk_size)); - if (plain_chunk_size > 0x00010000) { - return ndr_pull_error(ndrpull, NDR_ERR_COMPRESSION, "Bad XPRESS plain chunk size %08X > 0x00010000 (PULL)", - plain_chunk_size); - } - - NDR_CHECK(ndr_pull_uint32(ndrpull, NDR_SCALARS, &comp_chunk_size)); - - NDR_CHECK(ndr_pull_advance(ndrpull, comp_chunk_size)); - comp_chunk.length = comp_chunk_size + 8; - comp_chunk.data = ndrpull->data + comp_chunk_offset; - - DEBUG(10,("XPRESS plain_chunk_size: %08X (%u) comp_chunk_size: %08X (%u)\n", - plain_chunk_size, plain_chunk_size, comp_chunk_size, comp_chunk_size)); - - /* For now, we just copy over the compressed blob */ - NDR_CHECK(ndr_push_bytes(ndrpush, comp_chunk.data, comp_chunk.length)); - - if ((plain_chunk_size < 0x00010000) || (ndrpull->offset+4 >= ndrpull->data_size)) { - /* this is the last chunk */ - *last = true; - } - - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_pull_compression_xpress(struct ndr_pull *subndr, - struct ndr_pull **_comndr, - ssize_t decompressed_len) -{ - struct ndr_push *ndrpush; - struct ndr_pull *comndr; - DATA_BLOB uncompressed; - bool last = false; - - ndrpush = ndr_push_init_ctx(subndr); - NDR_ERR_HAVE_NO_MEMORY(ndrpush); - - while (!last) { - NDR_CHECK(ndr_pull_compression_xpress_chunk(subndr, ndrpush, &last)); - } - - uncompressed = ndr_push_blob(ndrpush); - - comndr = talloc_zero(subndr, struct ndr_pull); - NDR_ERR_HAVE_NO_MEMORY(comndr); - comndr->flags = subndr->flags; - comndr->current_mem_ctx = subndr->current_mem_ctx; - - comndr->data = uncompressed.data; - comndr->data_size = uncompressed.length; - comndr->offset = 0; - - *_comndr = comndr; - return NDR_ERR_SUCCESS; -} - -static enum ndr_err_code ndr_push_compression_xpress(struct ndr_push *subndr, - struct ndr_push *comndr) -{ - return ndr_push_error(subndr, NDR_ERR_COMPRESSION, "XPRESS compression is not supported yet (PUSH)"); -} - -/* - handle compressed subcontext buffers, which in midl land are user-marshalled, but - we use magic in pidl to make them easier to cope with -*/ -enum ndr_err_code ndr_pull_compression_start(struct ndr_pull *subndr, - struct ndr_pull **_comndr, - enum ndr_compression_alg compression_alg, - ssize_t decompressed_len) -{ - switch (compression_alg) { - case NDR_COMPRESSION_MSZIP: - return ndr_pull_compression_mszip(subndr, _comndr, decompressed_len); - case NDR_COMPRESSION_XPRESS: - return ndr_pull_compression_xpress(subndr, _comndr, decompressed_len); - default: - return ndr_pull_error(subndr, NDR_ERR_COMPRESSION, "Bad compression algorithm %d (PULL)", - compression_alg); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_compression_end(struct ndr_pull *subndr, - struct ndr_pull *comndr, - enum ndr_compression_alg compression_alg, - ssize_t decompressed_len) -{ - return NDR_ERR_SUCCESS; -} - -/* - push a compressed subcontext -*/ -enum ndr_err_code ndr_push_compression_start(struct ndr_push *subndr, - struct ndr_push **_comndr, - enum ndr_compression_alg compression_alg, - ssize_t decompressed_len) -{ - struct ndr_push *comndr; - - comndr = ndr_push_init_ctx(subndr); - NDR_ERR_HAVE_NO_MEMORY(comndr); - comndr->flags = subndr->flags; - - *_comndr = comndr; - return NDR_ERR_SUCCESS; -} - -/* - push a compressed subcontext -*/ -enum ndr_err_code ndr_push_compression_end(struct ndr_push *subndr, - struct ndr_push *comndr, - enum ndr_compression_alg compression_alg, - ssize_t decompressed_len) -{ - switch (compression_alg) { - case NDR_COMPRESSION_MSZIP: - return ndr_push_compression_mszip(subndr, comndr); - case NDR_COMPRESSION_XPRESS: - return ndr_push_compression_xpress(subndr, comndr); - default: - return ndr_push_error(subndr, NDR_ERR_COMPRESSION, "Bad compression algorithm %d (PUSH)", - compression_alg); - } - return NDR_ERR_SUCCESS; -} diff --git a/source3/librpc/ndr/ndr_drsuapi.c b/source3/librpc/ndr/ndr_drsuapi.c deleted file mode 100644 index aeb81c87bd..0000000000 --- a/source3/librpc/ndr/ndr_drsuapi.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for printing some linked list structs in DRSUAPI - - Copyright (C) Stefan (metze) Metzmacher 2005 - - 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 . -*/ - - -#include "includes.h" -#include "librpc/gen_ndr/ndr_drsuapi.h" -#include "librpc/gen_ndr/ndr_misc.h" - -void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, - const struct drsuapi_DsReplicaObjectListItem *r) -{ - ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItem"); - ndr->depth++; - ndr_print_ptr(ndr, "next_object", r->next_object); - ndr_print_drsuapi_DsReplicaObject(ndr, "object", &r->object); - ndr->depth--; - if (r->next_object) { - ndr_print_drsuapi_DsReplicaObjectListItem(ndr, "next_object", r->next_object); - } -} - -void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaObjectListItemEx *r) -{ - ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItemEx"); - ndr->depth++; - ndr_print_ptr(ndr, "next_object", r->next_object); - ndr_print_drsuapi_DsReplicaObject(ndr, "object", &r->object); - ndr_print_uint32(ndr, "is_nc_prefix", r->is_nc_prefix); - ndr_print_ptr(ndr, "parent_object_guid", r->parent_object_guid); - ndr->depth++; - if (r->parent_object_guid) { - ndr_print_GUID(ndr, "parent_object_guid", r->parent_object_guid); - } - ndr->depth--; - ndr_print_ptr(ndr, "meta_data_ctr", r->meta_data_ctr); - ndr->depth++; - if (r->meta_data_ctr) { - ndr_print_drsuapi_DsReplicaMetaDataCtr(ndr, "meta_data_ctr", r->meta_data_ctr); - } - ndr->depth--; - ndr->depth--; - if (r->next_object) { - ndr_print_drsuapi_DsReplicaObjectListItemEx(ndr, "next_object", r->next_object); - } -} - -#define _OID_PUSH_CHECK(call) do { \ - bool _status; \ - _status = call; \ - if (_status != true) { \ - return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \ - } \ -} while (0) - -#define _OID_PULL_CHECK(call) do { \ - bool _status; \ - _status = call; \ - if (_status != true) { \ - return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \ - } \ -} while (0) - -enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_drsuapi_DsReplicaOID_oid(r->oid, 0))); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->oid)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->oid) { - DATA_BLOB blob; - - if (StrnCaseCmp("ff", r->oid, 2) == 0) { - blob = strhex_to_data_blob(NULL, r->oid); - if (!blob.data) { - return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, - "HEX String Conversion Error: %s\n", - __location__); - } - } else { - _OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid)); - } - talloc_steal(ndr, blob.data); - - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length)); - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r) -{ - uint32_t _ptr_oid; - TALLOC_CTX *_mem_save_oid_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__ndr_size)); - if (r->__ndr_size < 0 || r->__ndr_size > 10000) { - return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_oid)); - if (_ptr_oid) { - NDR_PULL_ALLOC(ndr, r->oid); - } else { - r->oid = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->oid) { - DATA_BLOB _oid_array; - const char *_oid; - - _mem_save_oid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, ndr, 0); - NDR_CHECK(ndr_pull_array_size(ndr, &r->oid)); - _oid_array.length = ndr_get_array_size(ndr, &r->oid); - NDR_PULL_ALLOC_N(ndr, _oid_array.data, _oid_array.length); - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, _oid_array.data, _oid_array.length)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_oid_0, 0); - - if (_oid_array.length && _oid_array.data[0] == 0xFF) { - _oid = data_blob_hex_string(ndr, &_oid_array); - NDR_ERR_HAVE_NO_MEMORY(_oid); - } else { - _OID_PULL_CHECK(ber_read_OID_String(ndr, _oid_array, &_oid)); - } - TALLOC_FREE(_oid_array.data); - talloc_steal(r->oid, _oid); - r->oid = _oid; - } - if (r->oid) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->oid, r->__ndr_size)); - } - } - return NDR_ERR_SUCCESS; -} - -size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags) -{ - DATA_BLOB _blob; - size_t ret = 0; - - if (!oid) return 0; - - if (StrnCaseCmp("ff", oid, 2) == 0) { - _blob = strhex_to_data_blob(NULL, oid); - if (_blob.data) { - ret = _blob.length; - } - } else { - if (ber_write_OID_String(&_blob, oid)) { - ret = _blob.length; - } - } - data_blob_free(&_blob); - return ret; -} diff --git a/source3/librpc/ndr/ndr_drsuapi.h b/source3/librpc/ndr/ndr_drsuapi.h deleted file mode 100644 index c663eadd7a..0000000000 --- a/source3/librpc/ndr/ndr_drsuapi.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for printing some linked list structs in DRSUAPI - - Copyright (C) Stefan (metze) Metzmacher 2005-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 . -*/ - -#ifndef _LIBRPC_NDR_NDR_DRSUAPI_H -#define _LIBRPC_NDR_NDR_DRSUAPI_H - -void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, - const struct drsuapi_DsReplicaObjectListItem *r); - -void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, - const struct drsuapi_DsReplicaObjectListItemEx *r); - -enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r); -enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r); -size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags); - -#endif /* _LIBRPC_NDR_NDR_DRSUAPI_H */ diff --git a/source3/librpc/ndr/ndr_krb5pac.c b/source3/librpc/ndr/ndr_krb5pac.c deleted file mode 100644 index b0eab44012..0000000000 --- a/source3/librpc/ndr/ndr_krb5pac.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for marshalling/unmarshalling spoolss subcontext buffer structures - - Copyright (C) Stefan Metzmacher 2005 - - 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 . -*/ - - -#include "includes.h" - -#include "librpc/gen_ndr/ndr_krb5pac.h" - -static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) -{ - size_t s = ndr_size_PAC_INFO(r, level, flags); - switch (level) { - case PAC_TYPE_LOGON_INFO: - return NDR_ROUND(s,8); - default: - return s; - } -} - -static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags) -{ - size_t s = ndr_size_PAC_INFO(r, level, flags); - return NDR_ROUND(s,8); -} - -enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,0))); - { - uint32_t _flags_save_PAC_INFO = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info)); - ndr->flags = _flags_save_PAC_INFO; - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - } - if (ndr_flags & NDR_BUFFERS) { - { - uint32_t _flags_save_PAC_INFO = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); - if (r->info) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->info)); - { - struct ndr_push *_ndr_info; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0))); - NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type)); - NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info)); - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0))); - } - } - ndr->flags = _flags_save_PAC_INFO; - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r) -{ - uint32_t _ptr_info; - TALLOC_CTX *_mem_save_info_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); - { - uint32_t _flags_save_PAC_INFO = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); - if (_ptr_info) { - NDR_PULL_ALLOC(ndr, r->info); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info)); - } else { - r->info = NULL; - } - ndr->flags = _flags_save_PAC_INFO; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad)); - } - if (ndr_flags & NDR_BUFFERS) { - { - uint32_t _flags_save_PAC_INFO = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8); - if (r->info) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info)); - _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->info, 0); - { - struct ndr_pull *_ndr_info; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 0, r->_ndr_size)); - NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type)); - NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 0, r->_ndr_size)); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); - ndr->offset = _relative_save_offset; - } - ndr->flags = _flags_save_PAC_INFO; - } - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r) -{ - ndr_print_struct(ndr, name, "PAC_BUFFER"); - ndr->depth++; - ndr_print_PAC_TYPE(ndr, "type", r->type); - ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,0):r->_ndr_size); - ndr_print_ptr(ndr, "info", r->info); - ndr->depth++; - if (r->info) { - ndr_print_set_switch_value(ndr, r->info, r->type); - ndr_print_PAC_INFO(ndr, "info", r->info); - } - ndr->depth--; - ndr_print_uint32(ndr, "_pad", r->_pad); - ndr->depth--; -} diff --git a/source3/librpc/ndr/ndr_misc.c b/source3/librpc/ndr/ndr_misc.c deleted file mode 100644 index e86842527c..0000000000 --- a/source3/librpc/ndr/ndr_misc.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - UUID/GUID/policy_handle functions - - Copyright (C) Theodore Ts'o 1996, 1997, - Copyright (C) Jim McDonough 2002. - Copyright (C) Andrew Tridgell 2003. - Copyright (C) Stefan (metze) Metzmacher 2004. - - 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 . -*/ - -#include "includes.h" - -/** - * see if a range of memory is all zero. A NULL pointer is considered - * to be all zero - */ -bool all_zero(const uint8_t *ptr, size_t size) -{ - int i; - if (!ptr) return True; - for (i=0;iprint(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); -} - -bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, - const struct ndr_syntax_id *i2) -{ - return GUID_equal(&i1->uuid, &i2->uuid) - && (i1->if_version == i2->if_version); -} - -enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, - (uint32_t)r->pid)); -#ifdef CLUSTER_SUPPORT - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, - (uint32_t)r->vnn)); -#endif - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r) -{ - if (ndr_flags & NDR_SCALARS) { - uint32_t pid; - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pid)); -#ifdef CLUSTER_SUPPORT - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->vnn)); -#endif - r->pid = (pid_t)pid; - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r) -{ - ndr_print_struct(ndr, name, "server_id"); - ndr->depth++; - ndr_print_uint32(ndr, "id", (uint32_t)r->pid); -#ifdef CLUSTER_SUPPORT - ndr_print_uint32(ndr, "vnn", (uint32_t)r->vnn); -#endif - ndr->depth--; -} diff --git a/source3/librpc/ndr/ndr_string.c b/source3/librpc/ndr/ndr_string.c index e2c9ed5946..86d7b26586 100644 --- a/source3/librpc/ndr/ndr_string.c +++ b/source3/librpc/ndr/ndr_string.c @@ -89,7 +89,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } } NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul)); @@ -127,7 +127,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } } NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); @@ -166,7 +166,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } } NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); @@ -201,7 +201,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } } NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul)); @@ -233,7 +233,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } } NDR_CHECK(ndr_pull_advance(ndr, len3)); @@ -252,28 +252,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } NDR_CHECK(ndr_pull_advance(ndr, len1)); *s = as; break; - case LIBNDR_FLAG_STR_FIXLEN15: - case LIBNDR_FLAG_STR_FIXLEN32: - len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; - NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); - if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX, - ndr->data+ndr->offset, len1*byte_mul, - (void **)(void *)&as, - &converted_size, false)) - { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); - *s = as; - break; - case LIBNDR_FLAG_STR_NOTERM: if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) { return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x (missing NDR_REMAINING)\n", @@ -293,7 +277,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } } NDR_CHECK(ndr_pull_advance(ndr, len1)); @@ -346,17 +330,14 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, flags &= ~LIBNDR_FLAG_STR_CONFORMANT; - if (!(flags & - (LIBNDR_FLAG_STR_NOTERM | - LIBNDR_FLAG_STR_FIXLEN15 | - LIBNDR_FLAG_STR_FIXLEN32))) { + if (!(flags & LIBNDR_FLAG_STR_NOTERM)) { s_len++; } if (!convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, (void **)(void *)&dest, &d_len, false)) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } if (flags & LIBNDR_FLAG_STR_BYTESIZE) { @@ -397,21 +378,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, NDR_CHECK(ndr_push_bytes(ndr, dest, d_len)); break; - case LIBNDR_FLAG_STR_FIXLEN15: - case LIBNDR_FLAG_STR_FIXLEN32: { - ssize_t fix_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; - uint32_t pad_len = fix_len - d_len; - if (d_len > fix_len) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); - } - NDR_CHECK(ndr_push_bytes(ndr, dest, d_len)); - if (pad_len != 0) { - NDR_CHECK(ndr_push_zero(ndr, pad_len)); - } - break; - } - default: if (ndr->flags & LIBNDR_FLAG_REMAINING) { NDR_CHECK(ndr_push_bytes(ndr, dest, d_len)); @@ -437,13 +403,6 @@ _PUBLIC_ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) unsigned byte_mul = 2; unsigned c_len_term = 1; - if (flags & LIBNDR_FLAG_STR_FIXLEN32) { - return 32; - } - if (flags & LIBNDR_FLAG_STR_FIXLEN15) { - return 15; - } - c_len = s?strlen_m(s):0; if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) { @@ -653,21 +612,21 @@ _PUBLIC_ uint32_t ndr_string_length(const void *_var, uint32_t element_size) _PUBLIC_ enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size) { uint32_t i; - struct ndr_pull_save save_offset; + uint32_t save_offset; - ndr_pull_save(ndr, &save_offset); + save_offset = ndr->offset; ndr_pull_advance(ndr, (count - 1) * element_size); NDR_PULL_NEED_BYTES(ndr, element_size); for (i = 0; i < element_size; i++) { if (ndr->data[ndr->offset+i] != 0) { - ndr_pull_restore(ndr, &save_offset); + ndr->offset = save_offset; return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "String terminator not present or outside string boundaries"); } } - ndr_pull_restore(ndr, &save_offset); + ndr->offset = save_offset; return NDR_ERR_SUCCESS; } @@ -693,7 +652,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, &converted_size, false)) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } NDR_CHECK(ndr_pull_advance(ndr, length*byte_mul)); @@ -716,7 +675,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, ndr->data+ndr->offset, required, false); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad char conversion"); + "Bad character conversion"); } /* Make sure the remaining part of the string is filled with zeroes */ diff --git a/source3/librpc/ndr/util.c b/source3/librpc/ndr/util.c new file mode 100644 index 0000000000..457615ce22 --- /dev/null +++ b/source3/librpc/ndr/util.c @@ -0,0 +1,174 @@ +/* + Unix SMB/CIFS implementation. + + libndr interface + + Copyright (C) Andrew Tridgell 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 . +*/ + +#include "includes.h" + +NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err) +{ + switch (ndr_err) { + case NDR_ERR_SUCCESS: + return NT_STATUS_OK; + case NDR_ERR_BUFSIZE: + return NT_STATUS_BUFFER_TOO_SMALL; + case NDR_ERR_TOKEN: + return NT_STATUS_INTERNAL_ERROR; + case NDR_ERR_ALLOC: + return NT_STATUS_NO_MEMORY; + case NDR_ERR_ARRAY_SIZE: + return NT_STATUS_ARRAY_BOUNDS_EXCEEDED; + case NDR_ERR_INVALID_POINTER: + return NT_STATUS_INVALID_PARAMETER_MIX; + case NDR_ERR_UNREAD_BYTES: + return NT_STATUS_PORT_MESSAGE_TOO_LONG; + default: + break; + } + + /* we should map all error codes to different status codes */ + return NT_STATUS_INVALID_PARAMETER; +} + +/* + * Convert an ndr error to string + */ + +const char *ndr_errstr(enum ndr_err_code err) +{ + switch (err) { + case NDR_ERR_SUCCESS: + return "NDR_ERR_SUCCESS"; + break; + case NDR_ERR_ARRAY_SIZE: + return "NDR_ERR_ARRAY_SIZE"; + break; + case NDR_ERR_BAD_SWITCH: + return "NDR_ERR_BAD_SWITCH"; + break; + case NDR_ERR_OFFSET: + return "NDR_ERR_OFFSET"; + break; + case NDR_ERR_RELATIVE: + return "NDR_ERR_RELATIVE"; + break; + case NDR_ERR_CHARCNV: + return "NDR_ERR_CHARCNV"; + break; + case NDR_ERR_LENGTH: + return "NDR_ERR_LENGTH"; + break; + case NDR_ERR_SUBCONTEXT: + return "NDR_ERR_SUBCONTEXT"; + break; + case NDR_ERR_COMPRESSION: + return "NDR_ERR_COMPRESSION"; + break; + case NDR_ERR_STRING: + return "NDR_ERR_STRING"; + break; + case NDR_ERR_VALIDATE: + return "NDR_ERR_VALIDATE"; + break; + case NDR_ERR_BUFSIZE: + return "NDR_ERR_BUFSIZE"; + break; + case NDR_ERR_ALLOC: + return "NDR_ERR_ALLOC"; + break; + case NDR_ERR_RANGE: + return "NDR_ERR_RANGE"; + break; + case NDR_ERR_TOKEN: + return "NDR_ERR_TOKEN"; + break; + case NDR_ERR_IPV4ADDRESS: + return "NDR_ERR_IPV4ADDRESS"; + break; + case NDR_ERR_INVALID_POINTER: + return "NDR_ERR_INVALID_POINTER"; + break; + case NDR_ERR_UNREAD_BYTES: + return "NDR_ERR_UNREAD_BYTES"; + break; + } + + return talloc_asprintf(talloc_tos(), "Unknown NDR error: %d", err); +} + +enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, + (uint32_t)r->pid)); +#ifdef CLUSTER_SUPPORT + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, + (uint32_t)r->vnn)); +#endif + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r) +{ + if (ndr_flags & NDR_SCALARS) { + uint32_t pid; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pid)); +#ifdef CLUSTER_SUPPORT + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->vnn)); +#endif + r->pid = (pid_t)pid; + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r) +{ + ndr_print_struct(ndr, name, "server_id"); + ndr->depth++; + ndr_print_uint32(ndr, "id", (uint32_t)r->pid); +#ifdef CLUSTER_SUPPORT + ndr_print_uint32(ndr, "vnn", (uint32_t)r->vnn); +#endif + ndr->depth--; +} + +_PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b) +{ + ndr->print(ndr, "%-25s: %s", name, b?"true":"false"); +} + +_PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss) +{ + char addr[INET6_ADDRSTRLEN]; + ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss)); +} + +void *global_loadparm; +void *cmdline_lp_ctx; +struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx) +{ + return NULL; +} diff --git a/source3/librpc/ndr/uuid.c b/source3/librpc/ndr/uuid.c deleted file mode 100644 index e92df22494..0000000000 --- a/source3/librpc/ndr/uuid.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - UUID/GUID functions - - Copyright (C) Theodore Ts'o 1996, 1997, - Copyright (C) Jim McDonough 2002. - Copyright (C) Andrew Tridgell 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 . -*/ - -#include "includes.h" -#include "librpc/ndr/libndr.h" - -/** - build a GUID from a string -*/ -_PUBLIC_ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) -{ - NTSTATUS status = NT_STATUS_INVALID_PARAMETER; - uint32_t time_low; - uint32_t time_mid, time_hi_and_version; - uint32_t clock_seq[2]; - uint32_t node[6]; - int i; - - if (s == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - if (11 == sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } else if (11 == sscanf(s, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - guid->time_low = time_low; - guid->time_mid = time_mid; - guid->time_hi_and_version = time_hi_and_version; - guid->clock_seq[0] = clock_seq[0]; - guid->clock_seq[1] = clock_seq[1]; - for (i=0;i<6;i++) { - guid->node[i] = node[i]; - } - - return NT_STATUS_OK; -} - -/** - build a GUID from a string -*/ -_PUBLIC_ NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid) -{ - NTSTATUS status = NT_STATUS_INVALID_PARAMETER; - uint32_t time_low; - uint32_t time_mid, time_hi_and_version; - uint32_t clock_seq[2]; - uint32_t node[6]; - int i; - - if (s == NULL) { - return NT_STATUS_INVALID_PARAMETER; - } - - if (11 == sscanf(s, "%08x-%04x%04x-%02x%02x%02x%02x-%02x%02x%02x%02x", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - guid->time_low = time_low; - guid->time_mid = time_mid; - guid->time_hi_and_version = time_hi_and_version; - guid->clock_seq[0] = clock_seq[0]; - guid->clock_seq[1] = clock_seq[1]; - for (i=0;i<6;i++) { - guid->node[i] = node[i]; - } - - return NT_STATUS_OK; -} - -/** - * generate a random GUID - */ -struct GUID GUID_random(void) -{ - struct GUID guid; - - generate_random_buffer((uint8_t *)&guid, sizeof(guid)); - guid.clock_seq[0] = (guid.clock_seq[0] & 0x3F) | 0x80; - guid.time_hi_and_version = (guid.time_hi_and_version & 0x0FFF) | 0x4000; - - return guid; -} - -/** - * generate an empty GUID - */ -_PUBLIC_ struct GUID GUID_zero(void) -{ - struct GUID guid; - - ZERO_STRUCT(guid); - - return guid; -} - -_PUBLIC_ bool GUID_all_zero(const struct GUID *u) -{ - if (u->time_low != 0 || - u->time_mid != 0 || - u->time_hi_and_version != 0 || - u->clock_seq[0] != 0 || - u->clock_seq[1] != 0 || - !all_zero(u->node, 6)) { - return false; - } - return true; -} - -_PUBLIC_ bool GUID_equal(const struct GUID *u1, const struct GUID *u2) -{ - if (u1->time_low != u2->time_low || - u1->time_mid != u2->time_mid || - u1->time_hi_and_version != u2->time_hi_and_version || - u1->clock_seq[0] != u2->clock_seq[0] || - u1->clock_seq[1] != u2->clock_seq[1] || - memcmp(u1->node, u2->node, 6) != 0) { - return false; - } - return true; -} - -_PUBLIC_ int GUID_compare(const struct GUID *u1, const struct GUID *u2) -{ - if (u1->time_low != u2->time_low) { - return u1->time_low - u2->time_low; - } - - if (u1->time_mid != u2->time_mid) { - return u1->time_mid - u2->time_mid; - } - - if (u1->time_hi_and_version != u2->time_hi_and_version) { - return u1->time_hi_and_version - u2->time_hi_and_version; - } - - if (u1->clock_seq[0] != u2->clock_seq[0]) { - return u1->clock_seq[0] - u2->clock_seq[0]; - } - - if (u1->clock_seq[1] != u2->clock_seq[1]) { - return u1->clock_seq[1] - u2->clock_seq[1]; - } - - return memcmp(u1->node, u2->node, 6); -} - -/** - its useful to be able to display these in debugging messages -*/ -_PUBLIC_ char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - return talloc_asprintf(mem_ctx, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - guid->time_low, guid->time_mid, - guid->time_hi_and_version, - guid->clock_seq[0], - guid->clock_seq[1], - guid->node[0], guid->node[1], - guid->node[2], guid->node[3], - guid->node[4], guid->node[5]); -} - -_PUBLIC_ char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - char *ret, *s = GUID_string(mem_ctx, guid); - ret = talloc_asprintf(mem_ctx, "{%s}", s); - talloc_free(s); - return ret; -} - -_PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - return talloc_asprintf(mem_ctx, - "%08x-%04x%04x-%02x%02x%02x%02x-%02x%02x%02x%02x", - guid->time_low, guid->time_mid, - guid->time_hi_and_version, - guid->clock_seq[0], - guid->clock_seq[1], - guid->node[0], guid->node[1], - guid->node[2], guid->node[3], - guid->node[4], guid->node[5]); -} - -_PUBLIC_ bool policy_handle_empty(struct policy_handle *h) -{ - return (h->handle_type == 0 && GUID_all_zero(&h->uuid)); -} diff --git a/source3/librpc/rpc/binding.c b/source3/librpc/rpc/binding.c deleted file mode 100644 index 01e3479c23..0000000000 --- a/source3/librpc/rpc/binding.c +++ /dev/null @@ -1,709 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - dcerpc utility functions - - Copyright (C) Andrew Tridgell 2003 - Copyright (C) Jelmer Vernooij 2004 - Copyright (C) Andrew Bartlett 2005 - Copyright (C) Rafal Szczesniak 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 . -*/ - -#include "includes.h" - -#define MAX_PROTSEQ 10 - -static const struct { - const char *name; - enum dcerpc_transport_t transport; - int num_protocols; - enum epm_protocol protseq[MAX_PROTSEQ]; -} transports[] = { - { "ncacn_np", NCACN_NP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }}, - { "ncacn_ip_tcp", NCACN_IP_TCP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } }, - { "ncacn_http", NCACN_HTTP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP, EPM_PROTOCOL_IP } }, - { "ncadg_ip_udp", NCACN_IP_UDP, 3, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } }, - { "ncalrpc", NCALRPC, 2, - { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } }, - { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } }, - { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } }, - { "ncacn_at_dsp", NCACN_AT_DSP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } }, - { "ncadg_at_ddp", NCADG_AT_DDP, 3, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } }, - { "ncacn_vns_ssp", NCACN_VNS_SPP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } }, - { "ncacn_vns_ipc", NCACN_VNS_IPC, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, }, - { "ncadg_ipx", NCADG_IPX, 2, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_IPX }, - }, - { "ncacn_spx", NCACN_SPX, 3, - /* I guess some MS programmer confused the identifier for - * EPM_PROTOCOL_UUID (0x0D or 13) with the one for - * EPM_PROTOCOL_SPX (0x13) here. -- jelmer*/ - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID }, - }, -}; - -static const struct { - const char *name; - uint32_t flag; -} ncacn_options[] = { - { "", 0 } -}; - -const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) -{ - struct ndr_syntax_id syntax; - NTSTATUS status; - - switch(epm_floor->lhs.protocol) { - case EPM_PROTOCOL_UUID: - status = dcerpc_floor_get_lhs_data(epm_floor, &syntax); - if (NT_STATUS_IS_OK(status)) { - /* lhs is used: UUID */ - char *uuidstr; - - if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax.uuid)) { - return "NDR"; - } - - if (GUID_equal(&syntax.uuid, &ndr64_transfer_syntax.uuid)) { - return "NDR64"; - } - - uuidstr = GUID_string(mem_ctx, &syntax.uuid); - - return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version); - } else { /* IPX */ - return NULL; - } - - case EPM_PROTOCOL_NCACN: - return "RPC-C"; - - case EPM_PROTOCOL_NCADG: - return "RPC"; - - case EPM_PROTOCOL_NCALRPC: - return "NCALRPC"; - - case EPM_PROTOCOL_DNET_NSP: - return "DNET/NSP"; - - case EPM_PROTOCOL_IP: - return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr); - - case EPM_PROTOCOL_PIPE: - return talloc_asprintf(mem_ctx, "PIPE:%s", epm_floor->rhs.pipe.path); - - case EPM_PROTOCOL_SMB: - return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc); - - case EPM_PROTOCOL_UNIX_DS: - return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path); - - case EPM_PROTOCOL_NETBIOS: - return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name); - - case EPM_PROTOCOL_NETBEUI: - return "NETBeui"; - - case EPM_PROTOCOL_SPX: - return "SPX"; - - case EPM_PROTOCOL_NB_IPX: - return "NB_IPX"; - - case EPM_PROTOCOL_HTTP: - return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port); - - case EPM_PROTOCOL_TCP: - return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port); - - case EPM_PROTOCOL_UDP: - return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port); - - default: - return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol); - } -} - - -/* - form a binding string from a binding structure -*/ -_PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b) -{ - char *s = talloc_strdup(mem_ctx, ""); - int i; - const char *t_name = NULL; - - if (b->transport != NCA_UNKNOWN) { - for (i=0;itransport) { - t_name = transports[i].name; - } - } - if (!t_name) { - return NULL; - } - } - - if (!GUID_all_zero(&b->object.uuid)) { - s = talloc_asprintf(s, "%s@", - GUID_string(mem_ctx, &b->object.uuid)); - } - - if (t_name != NULL) { - s = talloc_asprintf_append_buffer(s, "%s:", t_name); - if (s == NULL) { - return NULL; - } - } - - if (b->host) { - s = talloc_asprintf_append_buffer(s, "%s", b->host); - } - - if (!b->endpoint && !b->options && !b->flags) { - return s; - } - - s = talloc_asprintf_append_buffer(s, "["); - - if (b->endpoint) { - s = talloc_asprintf_append_buffer(s, "%s", b->endpoint); - } - - /* this is a *really* inefficent way of dealing with strings, - but this is rarely called and the strings are always short, - so I don't care */ - for (i=0;b->options && b->options[i];i++) { - s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]); - if (!s) return NULL; - } - - for (i=0;iflags & ncacn_options[i].flag) { - s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name); - if (!s) return NULL; - } - } - - s = talloc_asprintf_append_buffer(s, "]"); - - return s; -} - -/* - parse a binding string into a dcerpc_binding structure -*/ -_PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out) -{ - struct dcerpc_binding *b; - char *options; - char *p; - int i, j, comma_count; - - b = talloc(mem_ctx, struct dcerpc_binding); - if (!b) { - return NT_STATUS_NO_MEMORY; - } - - p = strchr(s, '@'); - - if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */ - NTSTATUS status; - - status = GUID_from_string(s, &b->object.uuid); - - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Failed parsing UUID\n")); - return status; - } - - s = p + 1; - } else { - ZERO_STRUCT(b->object); - } - - b->object.if_version = 0; - - p = strchr(s, ':'); - - if (p == NULL) { - b->transport = NCA_UNKNOWN; - } else { - char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s)); - if (!type) { - return NT_STATUS_NO_MEMORY; - } - - for (i=0;itransport = transports[i].transport; - break; - } - } - - if (i==ARRAY_SIZE(transports)) { - DEBUG(0,("Unknown dcerpc transport '%s'\n", type)); - return NT_STATUS_INVALID_PARAMETER; - } - - talloc_free(type); - - s = p+1; - } - - p = strchr(s, '['); - if (p) { - b->host = talloc_strndup(b, s, PTR_DIFF(p, s)); - options = talloc_strdup(mem_ctx, p+1); - if (options[strlen(options)-1] != ']') { - return NT_STATUS_INVALID_PARAMETER; - } - options[strlen(options)-1] = 0; - } else { - b->host = talloc_strdup(b, s); - options = NULL; - } - if (!b->host) { - return NT_STATUS_NO_MEMORY; - } - - b->target_hostname = b->host; - - b->options = NULL; - b->flags = 0; - b->assoc_group_id = 0; - b->endpoint = NULL; - - if (!options) { - *b_out = b; - return NT_STATUS_OK; - } - - comma_count = count_chars(options, ','); - - b->options = talloc_array(b, const char *, comma_count+2); - if (!b->options) { - return NT_STATUS_NO_MEMORY; - } - - for (i=0; (p = strchr(options, ',')); i++) { - b->options[i] = talloc_strndup(b, options, PTR_DIFF(p, options)); - if (!b->options[i]) { - return NT_STATUS_NO_MEMORY; - } - options = p+1; - } - b->options[i] = options; - b->options[i+1] = NULL; - - /* some options are pre-parsed for convenience */ - for (i=0;b->options[i];i++) { - for (j=0;joptions[i]) == 0) { - int k; - b->flags |= ncacn_options[j].flag; - for (k=i;b->options[k];k++) { - b->options[k] = b->options[k+1]; - } - i--; - break; - } - } - } - - if (b->options[0]) { - /* Endpoint is first option */ - b->endpoint = b->options[0]; - if (strlen(b->endpoint) == 0) b->endpoint = NULL; - - for (i=0;b->options[i];i++) { - b->options[i] = b->options[i+1]; - } - } - - if (b->options[0] == NULL) - b->options = NULL; - - *b_out = b; - return NT_STATUS_OK; -} - -_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax) -{ - TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data"); - struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx); - enum ndr_err_code ndr_err; - uint16_t if_version=0; - - ndr->flags |= LIBNDR_FLAG_NOALIGN; - - ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(mem_ctx); - return ndr_map_error2ntstatus(ndr_err); - } - - ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(mem_ctx); - return ndr_map_error2ntstatus(ndr_err); - } - - syntax->if_version = if_version; - - talloc_free(mem_ctx); - - return NT_STATUS_OK; -} - -static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax) -{ - struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx); - - ndr->flags |= LIBNDR_FLAG_NOALIGN; - - ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid); - ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version); - - return ndr_push_blob(ndr); -} - -const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) -{ - switch (epm_floor->lhs.protocol) { - case EPM_PROTOCOL_TCP: - if (epm_floor->rhs.tcp.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port); - - case EPM_PROTOCOL_UDP: - if (epm_floor->rhs.udp.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port); - - case EPM_PROTOCOL_HTTP: - if (epm_floor->rhs.http.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port); - - case EPM_PROTOCOL_IP: - return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr); - - case EPM_PROTOCOL_NCACN: - return NULL; - - case EPM_PROTOCOL_NCADG: - return NULL; - - case EPM_PROTOCOL_SMB: - if (strlen(epm_floor->rhs.smb.unc) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.smb.unc); - - case EPM_PROTOCOL_PIPE: - if (strlen(epm_floor->rhs.pipe.path) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.pipe.path); - - case EPM_PROTOCOL_NETBIOS: - if (strlen(epm_floor->rhs.netbios.name) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.netbios.name); - - case EPM_PROTOCOL_NCALRPC: - return NULL; - - case EPM_PROTOCOL_VINES_SPP: - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port); - - case EPM_PROTOCOL_VINES_IPC: - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port); - - case EPM_PROTOCOL_STREETTALK: - return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk); - - case EPM_PROTOCOL_UNIX_DS: - if (strlen(epm_floor->rhs.unix_ds.path) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.unix_ds.path); - - case EPM_PROTOCOL_NULL: - return NULL; - - default: - DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol)); - break; - } - - return NULL; -} - -static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, - struct epm_floor *epm_floor, - const char *data) -{ - switch (epm_floor->lhs.protocol) { - case EPM_PROTOCOL_TCP: - epm_floor->rhs.tcp.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_UDP: - epm_floor->rhs.udp.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_HTTP: - epm_floor->rhs.http.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_IP: - epm_floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.ip.ipaddr); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NCACN: - epm_floor->rhs.ncacn.minor_version = 0; - return NT_STATUS_OK; - - case EPM_PROTOCOL_NCADG: - epm_floor->rhs.ncadg.minor_version = 0; - return NT_STATUS_OK; - - case EPM_PROTOCOL_SMB: - epm_floor->rhs.smb.unc = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.smb.unc); - return NT_STATUS_OK; - - case EPM_PROTOCOL_PIPE: - epm_floor->rhs.pipe.path = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.pipe.path); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NETBIOS: - epm_floor->rhs.netbios.name = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.netbios.name); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NCALRPC: - return NT_STATUS_OK; - - case EPM_PROTOCOL_VINES_SPP: - epm_floor->rhs.vines_spp.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_VINES_IPC: - epm_floor->rhs.vines_ipc.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_STREETTALK: - epm_floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.streettalk.streettalk); - return NT_STATUS_OK; - - case EPM_PROTOCOL_UNIX_DS: - epm_floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.unix_ds.path); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NULL: - return NT_STATUS_OK; - - default: - DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol)); - break; - } - - return NT_STATUS_NOT_SUPPORTED; -} - -enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot) -{ - int i; - - /* Find a transport that has 'prot' as 4th protocol */ - for (i=0;i= 2 && - transports[i].protseq[1] == prot) { - return transports[i].transport; - } - } - - /* Unknown transport */ - return (unsigned int)-1; -} - -_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower) -{ - int i; - - /* Find a transport that matches this tower */ - for (i=0;inum_floors - 2) { - continue; - } - - for (j = 0; j < transports[i].num_protocols; j++) { - if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) { - break; - } - } - - if (j == transports[i].num_protocols) { - return transports[i].transport; - } - } - - /* Unknown transport */ - return (unsigned int)-1; -} - -_PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, - struct epm_tower *tower, - struct dcerpc_binding **b_out) -{ - NTSTATUS status; - struct dcerpc_binding *binding; - - binding = talloc(mem_ctx, struct dcerpc_binding); - NT_STATUS_HAVE_NO_MEMORY(binding); - - ZERO_STRUCT(binding->object); - binding->options = NULL; - binding->host = NULL; - binding->target_hostname = NULL; - binding->flags = 0; - binding->assoc_group_id = 0; - - binding->transport = dcerpc_transport_by_tower(tower); - - if (binding->transport == (unsigned int)-1) { - return NT_STATUS_NOT_SUPPORTED; - } - - if (tower->num_floors < 1) { - return NT_STATUS_OK; - } - - /* Set object uuid */ - status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status))); - return status; - } - - /* Ignore floor 1, it contains the NDR version info */ - - binding->options = NULL; - - /* Set endpoint */ - if (tower->num_floors >= 4) { - binding->endpoint = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[3]); - } else { - binding->endpoint = NULL; - } - - /* Set network address */ - if (tower->num_floors >= 5) { - binding->host = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[4]); - NT_STATUS_HAVE_NO_MEMORY(binding->host); - binding->target_hostname = binding->host; - } - *b_out = binding; - return NT_STATUS_OK; -} - -_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower) -{ - const enum epm_protocol *protseq = NULL; - int num_protocols = -1, i; - NTSTATUS status; - - /* Find transport */ - for (i=0;itransport) { - protseq = transports[i].protseq; - num_protocols = transports[i].num_protocols; - break; - } - } - - if (num_protocols == -1) { - DEBUG(0, ("Unable to find transport with id '%d'\n", binding->transport)); - return NT_STATUS_UNSUCCESSFUL; - } - - tower->num_floors = 2 + num_protocols; - tower->floors = talloc_array(mem_ctx, struct epm_floor, tower->num_floors); - - /* Floor 0 */ - tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID; - - tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object); - - tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2); - - /* Floor 1 */ - tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID; - - tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, - &ndr_transfer_syntax); - - tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2); - - /* Floor 2 to num_protocols */ - for (i = 0; i < num_protocols; i++) { - tower->floors[2 + i].lhs.protocol = protseq[i]; - tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(mem_ctx, NULL, 0); - ZERO_STRUCT(tower->floors[2 + i].rhs); - dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[2 + i], ""); - } - - /* The 4th floor contains the endpoint */ - if (num_protocols >= 2 && binding->endpoint) { - status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->endpoint); - if (NT_STATUS_IS_ERR(status)) { - return status; - } - } - - /* The 5th contains the network address */ - if (num_protocols >= 3 && binding->host) { - if (is_ipaddress(binding->host)) { - status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4], - binding->host); - } else { - /* note that we don't attempt to resolve the - name here - when we get a hostname here we - are in the client code, and want to put in - a wildcard all-zeros IP for the server to - fill in */ - status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4], - "0.0.0.0"); - } - if (NT_STATUS_IS_ERR(status)) { - return status; - } - } - - return NT_STATUS_OK; -} diff --git a/source3/librpc/rpc/dcerpc.c b/source3/librpc/rpc/dcerpc.c index 58d676a9d9..77bb7b33a2 100644 --- a/source3/librpc/rpc/dcerpc.c +++ b/source3/librpc/rpc/dcerpc.c @@ -43,7 +43,7 @@ struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p, const struct ret->call = call; ret->r = r; - push = ndr_push_init_ctx(mem_ctx); + push = ndr_push_init_ctx(mem_ctx, NULL); if (!push) { return NULL; } @@ -100,7 +100,7 @@ NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req) prs_mem_free( &r_ps ); - pull = ndr_pull_init_blob(&blob, req); + pull = ndr_pull_init_blob(&blob, req, NULL); if (pull == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/librpc/rpc/dcerpc.h b/source3/librpc/rpc/dcerpc.h index 739e60a341..1a1fd83060 100644 --- a/source3/librpc/rpc/dcerpc.h +++ b/source3/librpc/rpc/dcerpc.h @@ -72,4 +72,52 @@ struct dcerpc_binding { uint32_t assoc_group_id; }; + +/* dcerpc pipe flags */ +#define DCERPC_DEBUG_PRINT_IN (1<<0) +#define DCERPC_DEBUG_PRINT_OUT (1<<1) +#define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT) + +#define DCERPC_DEBUG_VALIDATE_IN (1<<2) +#define DCERPC_DEBUG_VALIDATE_OUT (1<<3) +#define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT) + +#define DCERPC_CONNECT (1<<4) +#define DCERPC_SIGN (1<<5) +#define DCERPC_SEAL (1<<6) + +#define DCERPC_PUSH_BIGENDIAN (1<<7) +#define DCERPC_PULL_BIGENDIAN (1<<8) + +#define DCERPC_SCHANNEL (1<<9) + +/* use a 128 bit session key */ +#define DCERPC_SCHANNEL_128 (1<<12) + +/* check incoming pad bytes */ +#define DCERPC_DEBUG_PAD_CHECK (1<<13) + +/* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */ +#define DCERPC_NDR_REF_ALLOC (1<<14) + +#define DCERPC_AUTH_OPTIONS (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL|DCERPC_AUTH_SPNEGO|DCERPC_AUTH_KRB5|DCERPC_AUTH_NTLM) + +/* select spnego auth */ +#define DCERPC_AUTH_SPNEGO (1<<15) + +/* select krb5 auth */ +#define DCERPC_AUTH_KRB5 (1<<16) + +#define DCERPC_SMB2 (1<<17) + +/* select NTLM auth */ +#define DCERPC_AUTH_NTLM (1<<18) + +/* this triggers the DCERPC_PFC_FLAG_CONC_MPX flag in the bind request */ +#define DCERPC_CONCURRENT_MULTIPLEX (1<<19) + +/* this triggers the DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag in the bind request */ +#define DCERPC_HEADER_SIGNING (1<<20) + + #endif /* __DCERPC_H__ */ diff --git a/source3/librpc/rpc/dcerpc_util.c b/source3/librpc/rpc/dcerpc_util.c deleted file mode 100644 index 3b8768ccc2..0000000000 --- a/source3/librpc/rpc/dcerpc_util.c +++ /dev/null @@ -1,1438 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - dcerpc utility functions - - Copyright (C) Andrew Tridgell 2003 - Copyright (C) Jelmer Vernooij 2004 - Copyright (C) Andrew Bartlett 2005 - Copyright (C) Rafal Szczesniak 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 . -*/ - -#include "includes.h" -#include "lib/events/events.h" -#include "libcli/composite/composite.h" -#include "librpc/gen_ndr/ndr_epmapper_c.h" -#include "librpc/gen_ndr/ndr_dcerpc.h" -#include "librpc/gen_ndr/ndr_misc.h" -#include "librpc/rpc/dcerpc_proto.h" -#include "auth/credentials/credentials.h" -#include "param/param.h" - -/* - find a dcerpc call on an interface by name -*/ -const struct ndr_interface_call *dcerpc_iface_find_call(const struct ndr_interface_table *iface, - const char *name) -{ - int i; - for (i=0;inum_calls;i++) { - if (strcmp(iface->calls[i].name, name) == 0) { - return &iface->calls[i]; - } - } - return NULL; -} - -/* - push a ncacn_packet into a blob, potentially with auth info -*/ -NTSTATUS ncacn_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, - struct smb_iconv_convenience *iconv_convenience, - struct ncacn_packet *pkt, - struct dcerpc_auth *auth_info) -{ - struct ndr_push *ndr; - enum ndr_err_code ndr_err; - - ndr = ndr_push_init_ctx(mem_ctx, iconv_convenience); - if (!ndr) { - return NT_STATUS_NO_MEMORY; - } - - if (!(pkt->drep[0] & DCERPC_DREP_LE)) { - ndr->flags |= LIBNDR_FLAG_BIGENDIAN; - } - - if (pkt->pfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) { - ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT; - } - - if (auth_info) { - pkt->auth_length = auth_info->credentials.length; - } else { - pkt->auth_length = 0; - } - - ndr_err = ndr_push_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, pkt); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return ndr_map_error2ntstatus(ndr_err); - } - - if (auth_info) { - ndr_err = ndr_push_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth_info); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return ndr_map_error2ntstatus(ndr_err); - } - } - - *blob = ndr_push_blob(ndr); - - /* fill in the frag length */ - dcerpc_set_frag_length(blob, blob->length); - - return NT_STATUS_OK; -} - -#define MAX_PROTSEQ 10 - -static const struct { - const char *name; - enum dcerpc_transport_t transport; - int num_protocols; - enum epm_protocol protseq[MAX_PROTSEQ]; -} transports[] = { - { "ncacn_np", NCACN_NP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }}, - { "ncacn_ip_tcp", NCACN_IP_TCP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } }, - { "ncacn_http", NCACN_HTTP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP, EPM_PROTOCOL_IP } }, - { "ncadg_ip_udp", NCACN_IP_UDP, 3, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } }, - { "ncalrpc", NCALRPC, 2, - { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } }, - { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } }, - { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } }, - { "ncacn_at_dsp", NCACN_AT_DSP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } }, - { "ncadg_at_ddp", NCADG_AT_DDP, 3, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } }, - { "ncacn_vns_ssp", NCACN_VNS_SPP, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } }, - { "ncacn_vns_ipc", NCACN_VNS_IPC, 3, - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, }, - { "ncadg_ipx", NCADG_IPX, 2, - { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_IPX }, - }, - { "ncacn_spx", NCACN_SPX, 3, - /* I guess some MS programmer confused the identifier for - * EPM_PROTOCOL_UUID (0x0D or 13) with the one for - * EPM_PROTOCOL_SPX (0x13) here. -- jelmer*/ - { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID }, - }, -}; - -static const struct { - const char *name; - uint32_t flag; -} ncacn_options[] = { - {"sign", DCERPC_SIGN}, - {"seal", DCERPC_SEAL}, - {"connect", DCERPC_CONNECT}, - {"spnego", DCERPC_AUTH_SPNEGO}, - {"ntlm", DCERPC_AUTH_NTLM}, - {"krb5", DCERPC_AUTH_KRB5}, - {"validate", DCERPC_DEBUG_VALIDATE_BOTH}, - {"print", DCERPC_DEBUG_PRINT_BOTH}, - {"padcheck", DCERPC_DEBUG_PAD_CHECK}, - {"bigendian", DCERPC_PUSH_BIGENDIAN}, - {"smb2", DCERPC_SMB2} -}; - -const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) -{ - struct ndr_syntax_id syntax; - NTSTATUS status; - - switch(epm_floor->lhs.protocol) { - case EPM_PROTOCOL_UUID: - status = dcerpc_floor_get_lhs_data(epm_floor, &syntax); - if (NT_STATUS_IS_OK(status)) { - /* lhs is used: UUID */ - char *uuidstr; - - if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax.uuid)) { - return "NDR"; - } - - if (GUID_equal(&syntax.uuid, &ndr64_transfer_syntax.uuid)) { - return "NDR64"; - } - - uuidstr = GUID_string(mem_ctx, &syntax.uuid); - - return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version); - } else { /* IPX */ - return talloc_asprintf(mem_ctx, "IPX:%s", - data_blob_hex_string(mem_ctx, &epm_floor->rhs.uuid.unknown)); - } - - case EPM_PROTOCOL_NCACN: - return "RPC-C"; - - case EPM_PROTOCOL_NCADG: - return "RPC"; - - case EPM_PROTOCOL_NCALRPC: - return "NCALRPC"; - - case EPM_PROTOCOL_DNET_NSP: - return "DNET/NSP"; - - case EPM_PROTOCOL_IP: - return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr); - - case EPM_PROTOCOL_PIPE: - return talloc_asprintf(mem_ctx, "PIPE:%s", epm_floor->rhs.pipe.path); - - case EPM_PROTOCOL_SMB: - return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc); - - case EPM_PROTOCOL_UNIX_DS: - return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path); - - case EPM_PROTOCOL_NETBIOS: - return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name); - - case EPM_PROTOCOL_NETBEUI: - return "NETBeui"; - - case EPM_PROTOCOL_SPX: - return "SPX"; - - case EPM_PROTOCOL_NB_IPX: - return "NB_IPX"; - - case EPM_PROTOCOL_HTTP: - return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port); - - case EPM_PROTOCOL_TCP: - return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port); - - case EPM_PROTOCOL_UDP: - return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port); - - default: - return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol); - } -} - - -/* - form a binding string from a binding structure -*/ -_PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b) -{ - char *s = talloc_strdup(mem_ctx, ""); - int i; - const char *t_name = NULL; - - if (b->transport != NCA_UNKNOWN) { - for (i=0;itransport) { - t_name = transports[i].name; - } - } - if (!t_name) { - return NULL; - } - } - - if (!GUID_all_zero(&b->object.uuid)) { - s = talloc_asprintf(s, "%s@", - GUID_string(mem_ctx, &b->object.uuid)); - } - - if (t_name != NULL) { - s = talloc_asprintf_append_buffer(s, "%s:", t_name); - if (s == NULL) { - return NULL; - } - } - - if (b->host) { - s = talloc_asprintf_append_buffer(s, "%s", b->host); - } - - if (!b->endpoint && !b->options && !b->flags) { - return s; - } - - s = talloc_asprintf_append_buffer(s, "["); - - if (b->endpoint) { - s = talloc_asprintf_append_buffer(s, "%s", b->endpoint); - } - - /* this is a *really* inefficent way of dealing with strings, - but this is rarely called and the strings are always short, - so I don't care */ - for (i=0;b->options && b->options[i];i++) { - s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]); - if (!s) return NULL; - } - - for (i=0;iflags & ncacn_options[i].flag) { - s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name); - if (!s) return NULL; - } - } - - s = talloc_asprintf_append_buffer(s, "]"); - - return s; -} - -/* - parse a binding string into a dcerpc_binding structure -*/ -_PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out) -{ - struct dcerpc_binding *b; - char *options; - char *p; - int i, j, comma_count; - - b = talloc(mem_ctx, struct dcerpc_binding); - if (!b) { - return NT_STATUS_NO_MEMORY; - } - - p = strchr(s, '@'); - - if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */ - NTSTATUS status; - - status = GUID_from_string(s, &b->object.uuid); - - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Failed parsing UUID\n")); - return status; - } - - s = p + 1; - } else { - ZERO_STRUCT(b->object); - } - - b->object.if_version = 0; - - p = strchr(s, ':'); - - if (p == NULL) { - b->transport = NCA_UNKNOWN; - } else { - char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s)); - if (!type) { - return NT_STATUS_NO_MEMORY; - } - - for (i=0;itransport = transports[i].transport; - break; - } - } - - if (i==ARRAY_SIZE(transports)) { - DEBUG(0,("Unknown dcerpc transport '%s'\n", type)); - return NT_STATUS_INVALID_PARAMETER; - } - - talloc_free(type); - - s = p+1; - } - - p = strchr(s, '['); - if (p) { - b->host = talloc_strndup(b, s, PTR_DIFF(p, s)); - options = talloc_strdup(mem_ctx, p+1); - if (options[strlen(options)-1] != ']') { - return NT_STATUS_INVALID_PARAMETER; - } - options[strlen(options)-1] = 0; - } else { - b->host = talloc_strdup(b, s); - options = NULL; - } - if (!b->host) { - return NT_STATUS_NO_MEMORY; - } - - b->target_hostname = b->host; - - b->options = NULL; - b->flags = 0; - b->assoc_group_id = 0; - b->endpoint = NULL; - - if (!options) { - *b_out = b; - return NT_STATUS_OK; - } - - comma_count = count_chars(options, ','); - - b->options = talloc_array(b, const char *, comma_count+2); - if (!b->options) { - return NT_STATUS_NO_MEMORY; - } - - for (i=0; (p = strchr(options, ',')); i++) { - b->options[i] = talloc_strndup(b, options, PTR_DIFF(p, options)); - if (!b->options[i]) { - return NT_STATUS_NO_MEMORY; - } - options = p+1; - } - b->options[i] = options; - b->options[i+1] = NULL; - - /* some options are pre-parsed for convenience */ - for (i=0;b->options[i];i++) { - for (j=0;joptions[i]) == 0) { - int k; - b->flags |= ncacn_options[j].flag; - for (k=i;b->options[k];k++) { - b->options[k] = b->options[k+1]; - } - i--; - break; - } - } - } - - if (b->options[0]) { - /* Endpoint is first option */ - b->endpoint = b->options[0]; - if (strlen(b->endpoint) == 0) b->endpoint = NULL; - - for (i=0;b->options[i];i++) { - b->options[i] = b->options[i+1]; - } - } - - if (b->options[0] == NULL) - b->options = NULL; - - *b_out = b; - return NT_STATUS_OK; -} - -_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax) -{ - TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data"); - struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx, NULL); - enum ndr_err_code ndr_err; - uint16_t if_version=0; - - ndr->flags |= LIBNDR_FLAG_NOALIGN; - - ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(mem_ctx); - return ndr_map_error2ntstatus(ndr_err); - } - - ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(mem_ctx); - return ndr_map_error2ntstatus(ndr_err); - } - - syntax->if_version = if_version; - - talloc_free(mem_ctx); - - return NT_STATUS_OK; -} - -static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax) -{ - struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL); - - ndr->flags |= LIBNDR_FLAG_NOALIGN; - - ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid); - ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version); - - return ndr_push_blob(ndr); -} - -const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) -{ - switch (epm_floor->lhs.protocol) { - case EPM_PROTOCOL_TCP: - if (epm_floor->rhs.tcp.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port); - - case EPM_PROTOCOL_UDP: - if (epm_floor->rhs.udp.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port); - - case EPM_PROTOCOL_HTTP: - if (epm_floor->rhs.http.port == 0) return NULL; - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port); - - case EPM_PROTOCOL_IP: - return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr); - - case EPM_PROTOCOL_NCACN: - return NULL; - - case EPM_PROTOCOL_NCADG: - return NULL; - - case EPM_PROTOCOL_SMB: - if (strlen(epm_floor->rhs.smb.unc) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.smb.unc); - - case EPM_PROTOCOL_PIPE: - if (strlen(epm_floor->rhs.pipe.path) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.pipe.path); - - case EPM_PROTOCOL_NETBIOS: - if (strlen(epm_floor->rhs.netbios.name) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.netbios.name); - - case EPM_PROTOCOL_NCALRPC: - return NULL; - - case EPM_PROTOCOL_VINES_SPP: - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port); - - case EPM_PROTOCOL_VINES_IPC: - return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port); - - case EPM_PROTOCOL_STREETTALK: - return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk); - - case EPM_PROTOCOL_UNIX_DS: - if (strlen(epm_floor->rhs.unix_ds.path) == 0) return NULL; - return talloc_strdup(mem_ctx, epm_floor->rhs.unix_ds.path); - - case EPM_PROTOCOL_NULL: - return NULL; - - default: - DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol)); - break; - } - - return NULL; -} - -static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, - struct epm_floor *epm_floor, - const char *data) -{ - switch (epm_floor->lhs.protocol) { - case EPM_PROTOCOL_TCP: - epm_floor->rhs.tcp.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_UDP: - epm_floor->rhs.udp.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_HTTP: - epm_floor->rhs.http.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_IP: - epm_floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.ip.ipaddr); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NCACN: - epm_floor->rhs.ncacn.minor_version = 0; - return NT_STATUS_OK; - - case EPM_PROTOCOL_NCADG: - epm_floor->rhs.ncadg.minor_version = 0; - return NT_STATUS_OK; - - case EPM_PROTOCOL_SMB: - epm_floor->rhs.smb.unc = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.smb.unc); - return NT_STATUS_OK; - - case EPM_PROTOCOL_PIPE: - epm_floor->rhs.pipe.path = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.pipe.path); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NETBIOS: - epm_floor->rhs.netbios.name = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.netbios.name); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NCALRPC: - return NT_STATUS_OK; - - case EPM_PROTOCOL_VINES_SPP: - epm_floor->rhs.vines_spp.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_VINES_IPC: - epm_floor->rhs.vines_ipc.port = atoi(data); - return NT_STATUS_OK; - - case EPM_PROTOCOL_STREETTALK: - epm_floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.streettalk.streettalk); - return NT_STATUS_OK; - - case EPM_PROTOCOL_UNIX_DS: - epm_floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data); - NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.unix_ds.path); - return NT_STATUS_OK; - - case EPM_PROTOCOL_NULL: - return NT_STATUS_OK; - - default: - DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol)); - break; - } - - return NT_STATUS_NOT_SUPPORTED; -} - -enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot) -{ - int i; - - /* Find a transport that has 'prot' as 4th protocol */ - for (i=0;i= 2 && - transports[i].protseq[1] == prot) { - return transports[i].transport; - } - } - - /* Unknown transport */ - return (unsigned int)-1; -} - -_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower) -{ - int i; - - /* Find a transport that matches this tower */ - for (i=0;inum_floors - 2) { - continue; - } - - for (j = 0; j < transports[i].num_protocols; j++) { - if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) { - break; - } - } - - if (j == transports[i].num_protocols) { - return transports[i].transport; - } - } - - /* Unknown transport */ - return (unsigned int)-1; -} - -_PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, - struct epm_tower *tower, - struct dcerpc_binding **b_out) -{ - NTSTATUS status; - struct dcerpc_binding *binding; - - binding = talloc(mem_ctx, struct dcerpc_binding); - NT_STATUS_HAVE_NO_MEMORY(binding); - - ZERO_STRUCT(binding->object); - binding->options = NULL; - binding->host = NULL; - binding->target_hostname = NULL; - binding->flags = 0; - binding->assoc_group_id = 0; - - binding->transport = dcerpc_transport_by_tower(tower); - - if (binding->transport == (unsigned int)-1) { - return NT_STATUS_NOT_SUPPORTED; - } - - if (tower->num_floors < 1) { - return NT_STATUS_OK; - } - - /* Set object uuid */ - status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status))); - return status; - } - - /* Ignore floor 1, it contains the NDR version info */ - - binding->options = NULL; - - /* Set endpoint */ - if (tower->num_floors >= 4) { - binding->endpoint = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[3]); - } else { - binding->endpoint = NULL; - } - - /* Set network address */ - if (tower->num_floors >= 5) { - binding->host = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[4]); - NT_STATUS_HAVE_NO_MEMORY(binding->host); - binding->target_hostname = binding->host; - } - *b_out = binding; - return NT_STATUS_OK; -} - -_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower) -{ - const enum epm_protocol *protseq = NULL; - int num_protocols = -1, i; - NTSTATUS status; - - /* Find transport */ - for (i=0;itransport) { - protseq = transports[i].protseq; - num_protocols = transports[i].num_protocols; - break; - } - } - - if (num_protocols == -1) { - DEBUG(0, ("Unable to find transport with id '%d'\n", binding->transport)); - return NT_STATUS_UNSUCCESSFUL; - } - - tower->num_floors = 2 + num_protocols; - tower->floors = talloc_array(mem_ctx, struct epm_floor, tower->num_floors); - - /* Floor 0 */ - tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID; - - tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object); - - tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2); - - /* Floor 1 */ - tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID; - - tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, - &ndr_transfer_syntax); - - tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2); - - /* Floor 2 to num_protocols */ - for (i = 0; i < num_protocols; i++) { - tower->floors[2 + i].lhs.protocol = protseq[i]; - tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(mem_ctx, NULL, 0); - ZERO_STRUCT(tower->floors[2 + i].rhs); - dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[2 + i], ""); - } - - /* The 4th floor contains the endpoint */ - if (num_protocols >= 2 && binding->endpoint) { - status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->endpoint); - if (NT_STATUS_IS_ERR(status)) { - return status; - } - } - - /* The 5th contains the network address */ - if (num_protocols >= 3 && binding->host) { - if (is_ipaddress(binding->host)) { - status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4], - binding->host); - } else { - /* note that we don't attempt to resolve the - name here - when we get a hostname here we - are in the client code, and want to put in - a wildcard all-zeros IP for the server to - fill in */ - status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4], - "0.0.0.0"); - } - if (NT_STATUS_IS_ERR(status)) { - return status; - } - } - - return NT_STATUS_OK; -} - - -struct epm_map_binding_state { - struct dcerpc_binding *binding; - const struct ndr_interface_table *table; - struct dcerpc_pipe *pipe; - struct policy_handle handle; - struct GUID guid; - struct epm_twr_t twr; - struct epm_twr_t *twr_r; - struct epm_Map r; -}; - - -static void continue_epm_recv_binding(struct composite_context *ctx); -static void continue_epm_map(struct rpc_request *req); - - -/* - Stage 2 of epm_map_binding: Receive connected rpc pipe and send endpoint - mapping rpc request -*/ -static void continue_epm_recv_binding(struct composite_context *ctx) -{ - struct rpc_request *map_req; - - struct composite_context *c = talloc_get_type(ctx->async.private_data, - struct composite_context); - struct epm_map_binding_state *s = talloc_get_type(c->private_data, - struct epm_map_binding_state); - - /* receive result of rpc pipe connect request */ - c->status = dcerpc_pipe_connect_b_recv(ctx, c, &s->pipe); - if (!composite_is_ok(c)) return; - - s->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC; - - /* prepare requested binding parameters */ - s->binding->object = s->table->syntax_id; - - c->status = dcerpc_binding_build_tower(s->pipe, s->binding, &s->twr.tower); - if (!composite_is_ok(c)) return; - - /* with some nice pretty paper around it of course */ - s->r.in.object = &s->guid; - s->r.in.map_tower = &s->twr; - s->r.in.entry_handle = &s->handle; - s->r.in.max_towers = 1; - s->r.out.entry_handle = &s->handle; - - /* send request for an endpoint mapping - a rpc request on connected pipe */ - map_req = dcerpc_epm_Map_send(s->pipe, c, &s->r); - if (composite_nomem(map_req, c)) return; - - composite_continue_rpc(c, map_req, continue_epm_map, c); -} - - -/* - Stage 3 of epm_map_binding: Receive endpoint mapping and provide binding details -*/ -static void continue_epm_map(struct rpc_request *req) -{ - struct composite_context *c = talloc_get_type(req->async.private_data, - struct composite_context); - struct epm_map_binding_state *s = talloc_get_type(c->private_data, - struct epm_map_binding_state); - - /* receive result of a rpc request */ - c->status = dcerpc_ndr_request_recv(req); - if (!composite_is_ok(c)) return; - - /* check the details */ - if (s->r.out.result != 0 || *s->r.out.num_towers != 1) { - composite_error(c, NT_STATUS_PORT_UNREACHABLE); - return; - } - - s->twr_r = s->r.out.towers[0].twr; - if (s->twr_r == NULL) { - composite_error(c, NT_STATUS_PORT_UNREACHABLE); - return; - } - - if (s->twr_r->tower.num_floors != s->twr.tower.num_floors || - s->twr_r->tower.floors[3].lhs.protocol != s->twr.tower.floors[3].lhs.protocol) { - composite_error(c, NT_STATUS_PORT_UNREACHABLE); - return; - } - - /* get received endpoint */ - s->binding->endpoint = talloc_reference(s->binding, - dcerpc_floor_get_rhs_data(c, &s->twr_r->tower.floors[3])); - if (composite_nomem(s->binding->endpoint, c)) return; - - composite_done(c); -} - - -/* - Request for endpoint mapping of dcerpc binding - try to request for endpoint - unless there is default one. -*/ -struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx, - struct dcerpc_binding *binding, - const struct ndr_interface_table *table, - struct event_context *ev, - struct loadparm_context *lp_ctx) -{ - struct composite_context *c; - struct epm_map_binding_state *s; - struct composite_context *pipe_connect_req; - struct cli_credentials *anon_creds; - struct event_context *new_ev = NULL; - - NTSTATUS status; - struct dcerpc_binding *epmapper_binding; - int i; - - /* Try to find event context in memory context in case passed - * event_context (argument) was NULL. If there's none, just - * create a new one. - */ - if (ev == NULL) { - ev = event_context_find(mem_ctx); - if (ev == NULL) { - new_ev = event_context_init(mem_ctx); - if (new_ev == NULL) return NULL; - ev = new_ev; - } - } - - /* composite context allocation and setup */ - c = composite_create(mem_ctx, ev); - if (c == NULL) { - talloc_free(new_ev); - return NULL; - } - talloc_steal(c, new_ev); - - s = talloc_zero(c, struct epm_map_binding_state); - if (composite_nomem(s, c)) return c; - c->private_data = s; - - s->binding = binding; - s->table = table; - - /* anonymous credentials for rpc connection used to get endpoint mapping */ - anon_creds = cli_credentials_init(mem_ctx); - cli_credentials_set_event_context(anon_creds, ev); - cli_credentials_set_anonymous(anon_creds); - - /* - First, check if there is a default endpoint specified in the IDL - */ - if (table != NULL) { - struct dcerpc_binding *default_binding; - - /* Find one of the default pipes for this interface */ - for (i = 0; i < table->endpoints->count; i++) { - status = dcerpc_parse_binding(mem_ctx, table->endpoints->names[i], &default_binding); - - if (NT_STATUS_IS_OK(status)) { - if (binding->transport == NCA_UNKNOWN) - binding->transport = default_binding->transport; - if (default_binding->transport == binding->transport && - default_binding->endpoint) { - binding->endpoint = talloc_reference(binding, default_binding->endpoint); - talloc_free(default_binding); - - composite_done(c); - return c; - - } else { - talloc_free(default_binding); - } - } - } - } - - epmapper_binding = talloc_zero(c, struct dcerpc_binding); - if (composite_nomem(epmapper_binding, c)) return c; - - /* basic endpoint mapping data */ - epmapper_binding->transport = binding->transport; - epmapper_binding->host = talloc_reference(epmapper_binding, binding->host); - epmapper_binding->target_hostname = epmapper_binding->host; - epmapper_binding->options = NULL; - epmapper_binding->flags = 0; - epmapper_binding->assoc_group_id = 0; - epmapper_binding->endpoint = NULL; - - /* initiate rpc pipe connection */ - pipe_connect_req = dcerpc_pipe_connect_b_send(c, epmapper_binding, - &ndr_table_epmapper, - anon_creds, c->event_ctx, - lp_ctx); - if (composite_nomem(pipe_connect_req, c)) return c; - - composite_continue(c, pipe_connect_req, continue_epm_recv_binding, c); - return c; -} - - -/* - Receive result of endpoint mapping request - */ -NTSTATUS dcerpc_epm_map_binding_recv(struct composite_context *c) -{ - NTSTATUS status = composite_wait(c); - - talloc_free(c); - return status; -} - - -/* - Get endpoint mapping for rpc connection -*/ -_PUBLIC_ NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, - const struct ndr_interface_table *table, struct event_context *ev, - struct loadparm_context *lp_ctx) -{ - struct composite_context *c; - - c = dcerpc_epm_map_binding_send(mem_ctx, binding, table, ev, lp_ctx); - return dcerpc_epm_map_binding_recv(c); -} - - -struct pipe_auth_state { - struct dcerpc_pipe *pipe; - struct dcerpc_binding *binding; - const struct ndr_interface_table *table; - struct loadparm_context *lp_ctx; - struct cli_credentials *credentials; -}; - - -static void continue_auth_schannel(struct composite_context *ctx); -static void continue_auth(struct composite_context *ctx); -static void continue_auth_none(struct composite_context *ctx); -static void continue_ntlmssp_connection(struct composite_context *ctx); -static void continue_spnego_after_wrong_pass(struct composite_context *ctx); - - -/* - Stage 2 of pipe_auth: Receive result of schannel bind request -*/ -static void continue_auth_schannel(struct composite_context *ctx) -{ - struct composite_context *c = talloc_get_type(ctx->async.private_data, - struct composite_context); - - c->status = dcerpc_bind_auth_schannel_recv(ctx); - if (!composite_is_ok(c)) return; - - composite_done(c); -} - - -/* - Stage 2 of pipe_auth: Receive result of authenticated bind request -*/ -static void continue_auth(struct composite_context *ctx) -{ - struct composite_context *c = talloc_get_type(ctx->async.private_data, - struct composite_context); - - c->status = dcerpc_bind_auth_recv(ctx); - if (!composite_is_ok(c)) return; - - composite_done(c); -} -/* - Stage 2 of pipe_auth: Receive result of authenticated bind request, but handle fallbacks: - SPNEGO -> NTLMSSP -*/ -static void continue_auth_auto(struct composite_context *ctx) -{ - struct composite_context *c = talloc_get_type(ctx->async.private_data, - struct composite_context); - struct pipe_auth_state *s = talloc_get_type(c->private_data, struct pipe_auth_state); - struct composite_context *sec_conn_req; - - c->status = dcerpc_bind_auth_recv(ctx); - if (NT_STATUS_EQUAL(c->status, NT_STATUS_INVALID_PARAMETER)) { - /* - * Retry with NTLMSSP auth as fallback - * send a request for secondary rpc connection - */ - sec_conn_req = dcerpc_secondary_connection_send(s->pipe, - s->binding); - composite_continue(c, sec_conn_req, continue_ntlmssp_connection, c); - return; - } else if (NT_STATUS_EQUAL(c->status, NT_STATUS_LOGON_FAILURE)) { - if (cli_credentials_wrong_password(s->credentials)) { - /* - * Retry SPNEGO with a better password - * send a request for secondary rpc connection - */ - sec_conn_req = dcerpc_secondary_connection_send(s->pipe, - s->binding); - composite_continue(c, sec_conn_req, continue_spnego_after_wrong_pass, c); - return; - } - } - - if (!composite_is_ok(c)) return; - - composite_done(c); -} - -/* - Stage 3 of pipe_auth (fallback to NTLMSSP case): Receive secondary - rpc connection (the first one can't be used any more, due to the - bind nak) and perform authenticated bind request -*/ -static void continue_ntlmssp_connection(struct composite_context *ctx) -{ - struct composite_context *c; - struct pipe_auth_state *s; - struct composite_context *auth_req; - struct dcerpc_pipe *p2; - - c = talloc_get_type(ctx->async.private_data, struct composite_context); - s = talloc_get_type(c->private_data, struct pipe_auth_state); - - /* receive secondary rpc connection */ - c->status = dcerpc_secondary_connection_recv(ctx, &p2); - if (!composite_is_ok(c)) return; - - talloc_steal(s, p2); - talloc_steal(p2, s->pipe); - s->pipe = p2; - - /* initiate a authenticated bind */ - auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table, - s->credentials, s->lp_ctx, - DCERPC_AUTH_TYPE_NTLMSSP, - dcerpc_auth_level(s->pipe->conn), - s->table->authservices->names[0]); - composite_continue(c, auth_req, continue_auth, c); -} - -/* - Stage 3 of pipe_auth (retry on wrong password): Receive secondary - rpc connection (the first one can't be used any more, due to the - bind nak) and perform authenticated bind request -*/ -static void continue_spnego_after_wrong_pass(struct composite_context *ctx) -{ - struct composite_context *c; - struct pipe_auth_state *s; - struct composite_context *auth_req; - struct dcerpc_pipe *p2; - - c = talloc_get_type(ctx->async.private_data, struct composite_context); - s = talloc_get_type(c->private_data, struct pipe_auth_state); - - /* receive secondary rpc connection */ - c->status = dcerpc_secondary_connection_recv(ctx, &p2); - if (!composite_is_ok(c)) return; - - talloc_steal(s, p2); - talloc_steal(p2, s->pipe); - s->pipe = p2; - - /* initiate a authenticated bind */ - auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table, - s->credentials, s->lp_ctx, DCERPC_AUTH_TYPE_SPNEGO, - dcerpc_auth_level(s->pipe->conn), - s->table->authservices->names[0]); - composite_continue(c, auth_req, continue_auth, c); -} - - -/* - Stage 2 of pipe_auth: Receive result of non-authenticated bind request -*/ -static void continue_auth_none(struct composite_context *ctx) -{ - struct composite_context *c = talloc_get_type(ctx->async.private_data, - struct composite_context); - - c->status = dcerpc_bind_auth_none_recv(ctx); - if (!composite_is_ok(c)) return; - - composite_done(c); -} - - -/* - Request to perform an authenticated bind if required. Authentication - is determined using credentials passed and binding flags. -*/ -struct composite_context *dcerpc_pipe_auth_send(struct dcerpc_pipe *p, - struct dcerpc_binding *binding, - const struct ndr_interface_table *table, - struct cli_credentials *credentials, - struct loadparm_context *lp_ctx) -{ - struct composite_context *c; - struct pipe_auth_state *s; - struct composite_context *auth_schannel_req; - struct composite_context *auth_req; - struct composite_context *auth_none_req; - struct dcerpc_connection *conn; - uint8_t auth_type; - - /* composite context allocation and setup */ - c = composite_create(p, p->conn->event_ctx); - if (c == NULL) return NULL; - - s = talloc_zero(c, struct pipe_auth_state); - if (composite_nomem(s, c)) return c; - c->private_data = s; - - /* store parameters in state structure */ - s->binding = binding; - s->table = table; - s->credentials = credentials; - s->pipe = p; - s->lp_ctx = lp_ctx; - - conn = s->pipe->conn; - conn->flags = binding->flags; - - /* remember the binding string for possible secondary connections */ - conn->binding_string = dcerpc_binding_string(p, binding); - - if (cli_credentials_is_anonymous(s->credentials)) { - auth_none_req = dcerpc_bind_auth_none_send(c, s->pipe, s->table); - composite_continue(c, auth_none_req, continue_auth_none, c); - return c; - } - - if ((binding->flags & DCERPC_SCHANNEL) && - !cli_credentials_get_netlogon_creds(s->credentials)) { - /* If we don't already have netlogon credentials for - * the schannel bind, then we have to get these - * first */ - auth_schannel_req = dcerpc_bind_auth_schannel_send(c, s->pipe, s->table, - s->credentials, s->lp_ctx, - dcerpc_auth_level(conn)); - composite_continue(c, auth_schannel_req, continue_auth_schannel, c); - return c; - } - - /* - * we rely on the already authenticated CIFS connection - * if not doing sign or seal - */ - if (conn->transport.transport == NCACN_NP && - !(s->binding->flags & (DCERPC_SIGN|DCERPC_SEAL))) { - auth_none_req = dcerpc_bind_auth_none_send(c, s->pipe, s->table); - composite_continue(c, auth_none_req, continue_auth_none, c); - return c; - } - - - /* Perform an authenticated DCE-RPC bind - */ - if (!(conn->flags & (DCERPC_SIGN|DCERPC_SEAL))) { - /* - we are doing an authenticated connection, - but not using sign or seal. We must force - the CONNECT dcerpc auth type as a NONE auth - type doesn't allow authentication - information to be passed. - */ - conn->flags |= DCERPC_CONNECT; - } - - if (s->binding->flags & DCERPC_AUTH_SPNEGO) { - auth_type = DCERPC_AUTH_TYPE_SPNEGO; - - } else if (s->binding->flags & DCERPC_AUTH_KRB5) { - auth_type = DCERPC_AUTH_TYPE_KRB5; - - } else if (s->binding->flags & DCERPC_SCHANNEL) { - auth_type = DCERPC_AUTH_TYPE_SCHANNEL; - - } else if (s->binding->flags & DCERPC_AUTH_NTLM) { - auth_type = DCERPC_AUTH_TYPE_NTLMSSP; - - } else { - /* try SPNEGO with fallback to NTLMSSP */ - auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table, - s->credentials, s->lp_ctx, DCERPC_AUTH_TYPE_SPNEGO, - dcerpc_auth_level(conn), - s->table->authservices->names[0]); - composite_continue(c, auth_req, continue_auth_auto, c); - return c; - } - - auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table, - s->credentials, s->lp_ctx, auth_type, - dcerpc_auth_level(conn), - s->table->authservices->names[0]); - composite_continue(c, auth_req, continue_auth, c); - return c; -} - - -/* - Receive result of authenticated bind request on dcerpc pipe - - This returns *p, which may be different to the one originally - supllied, as it rebinds to a new pipe due to authentication fallback - -*/ -NTSTATUS dcerpc_pipe_auth_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, - struct dcerpc_pipe **p) -{ - NTSTATUS status; - - struct pipe_auth_state *s = talloc_get_type(c->private_data, - struct pipe_auth_state); - status = composite_wait(c); - if (!NT_STATUS_IS_OK(status)) { - char *uuid_str = GUID_string(s->pipe, &s->table->syntax_id.uuid); - DEBUG(0, ("Failed to bind to uuid %s - %s\n", uuid_str, nt_errstr(status))); - talloc_free(uuid_str); - } else { - talloc_steal(mem_ctx, s->pipe); - *p = s->pipe; - } - - talloc_free(c); - return status; -} - - -/* - Perform an authenticated bind if needed - sync version - - This may change *p, as it rebinds to a new pipe due to authentication fallback -*/ -_PUBLIC_ NTSTATUS dcerpc_pipe_auth(TALLOC_CTX *mem_ctx, - struct dcerpc_pipe **p, - struct dcerpc_binding *binding, - const struct ndr_interface_table *table, - struct cli_credentials *credentials, - struct loadparm_context *lp_ctx) -{ - struct composite_context *c; - - c = dcerpc_pipe_auth_send(*p, binding, table, credentials, lp_ctx); - return dcerpc_pipe_auth_recv(c, mem_ctx, p); -} - - -NTSTATUS dcerpc_generic_session_key(struct dcerpc_connection *c, - DATA_BLOB *session_key) -{ - /* this took quite a few CPU cycles to find ... */ - session_key->data = discard_const_p(unsigned char, "SystemLibraryDTC"); - session_key->length = 16; - return NT_STATUS_OK; -} - -/* - fetch the user session key - may be default (above) or the SMB session key -*/ -_PUBLIC_ NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p, - DATA_BLOB *session_key) -{ - return p->conn->security_state.session_key(p->conn, session_key); -} - - -/* - log a rpc packet in a format suitable for ndrdump. This is especially useful - for sealed packets, where ethereal cannot easily see the contents - - this triggers on a debug level of >= 10 -*/ -_PUBLIC_ void dcerpc_log_packet(const struct ndr_interface_table *ndr, - uint32_t opnum, uint32_t flags, - DATA_BLOB *pkt) -{ - const int num_examples = 20; - int i; - - if (DEBUGLEVEL < 10) return; - - for (i=0;iname, opnum, i, - (flags&NDR_IN)?"in":"out"); - if (name == NULL) { - return; - } - if (!file_exist(name)) { - if (file_save(name, pkt->data, pkt->length)) { - DEBUG(10,("Logged rpc packet to %s\n", name)); - } - free(name); - break; - } - free(name); - } -} - - - -/* - create a secondary context from a primary connection - - this uses dcerpc_alter_context() to create a new dcerpc context_id -*/ -_PUBLIC_ NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p, - struct dcerpc_pipe **pp2, - const struct ndr_interface_table *table) -{ - NTSTATUS status; - struct dcerpc_pipe *p2; - - p2 = talloc_zero(p, struct dcerpc_pipe); - if (p2 == NULL) { - return NT_STATUS_NO_MEMORY; - } - p2->conn = talloc_reference(p2, p->conn); - p2->request_timeout = p->request_timeout; - - p2->context_id = ++p->conn->next_context_id; - - p2->syntax = table->syntax_id; - - p2->transfer_syntax = ndr_transfer_syntax; - - p2->binding = talloc_reference(p2, p->binding); - - status = dcerpc_alter_context(p2, p2, &p2->syntax, &p2->transfer_syntax); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(p2); - return status; - } - - *pp2 = p2; - - return NT_STATUS_OK; -} diff --git a/source3/librpc/tools/ndrdump.c b/source3/librpc/tools/ndrdump.c index dc7f2be32f..5b96e152bb 100644 --- a/source3/librpc/tools/ndrdump.c +++ b/source3/librpc/tools/ndrdump.c @@ -281,11 +281,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug exit(1); } -#if (_SAMBA_BUILD_ >= 4) - data = (uint8_t *)file_load(ctx_filename, &size, mem_ctx); -#else - data = (uint8_t *)file_load(ctx_filename, &size, 0); -#endif + data = (uint8_t *)file_load(ctx_filename, &size, 0, mem_ctx); if (!data) { perror(ctx_filename); exit(1); @@ -294,7 +290,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug blob.data = data; blob.length = size; - ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx, NULL); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st); @@ -312,11 +308,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug } if (filename) -#if (_SAMBA_BUILD_ >= 4) - data = (uint8_t *)file_load(filename, &size, mem_ctx); -#else - data = (uint8_t *)file_load(filename, &size, 0); -#endif + data = (uint8_t *)file_load(filename, &size, 0, mem_ctx); else data = (uint8_t *)stdin_load(mem_ctx, &size); @@ -331,7 +323,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug blob.data = data; blob.length = size; - ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx, NULL); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_pull, flags, st); @@ -368,7 +360,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug uint8_t byte_a, byte_b; bool differ; - ndr_v_push = ndr_push_init_ctx(mem_ctx); + ndr_v_push = ndr_push_init_ctx(mem_ctx, NULL); ndr_err = f->ndr_push(ndr_v_push, flags, st); status = ndr_map_error2ntstatus(ndr_err); @@ -385,7 +377,7 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug dump_data(0, v_blob.data, v_blob.length); } - ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); + ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx, NULL); ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_v_pull, flags, v_st); diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index d5eac07b48..d371e057e3 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -924,7 +924,7 @@ static void cli_state_handler(struct event_context *event_ctx, } cli->evt_inbuf = tmp; - res = recv(cli->fd, cli->evt_inbuf + old_size, available, 0); + res = sys_recv(cli->fd, cli->evt_inbuf + old_size, available, 0); if (res == -1) { DEBUG(10, ("recv failed: %s\n", strerror(errno))); status = map_nt_error_from_unix(errno); @@ -970,7 +970,7 @@ static void cli_state_handler(struct event_context *event_ctx, return; } - sent = send(cli->fd, req->outbuf + req->sent, + sent = sys_send(cli->fd, req->outbuf + req->sent, to_send - req->sent, 0); if (sent < 0) { diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index 8b35a69def..349a8331b4 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -136,8 +136,8 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, struct in_addr dc_ip; const char *my_acct_name = NULL; const char *my_mailslot = NULL; - struct nbt_ntlogon_packet packet; - struct nbt_ntlogon_sam_logon *s; + struct nbt_netlogon_packet packet; + struct NETLOGON_SAM_LOGON_REQUEST *s; enum ndr_err_code ndr_err; DATA_BLOB blob; struct dom_sid my_sid; @@ -164,7 +164,7 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, return false; } - packet.command = NTLOGON_SAM_LOGON; + packet.command = LOGON_SAM_LOGON_REQUEST; s = &packet.req.logon; s->request_count = 0; @@ -178,11 +178,11 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, s->lm20_token = 0xffff; if (DEBUGLEVEL >= 10) { - NDR_PRINT_DEBUG(nbt_ntlogon_packet, &packet); + NDR_PRINT_DEBUG(nbt_netlogon_packet, &packet); } - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &packet, - (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &packet, + (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return false; } @@ -199,15 +199,16 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, const char *domain_name, uint32_t *nt_version, const char **dc_name, - union nbt_cldap_netlogon **reply) + struct netlogon_samlogon_response **_r) { struct packet_struct *packet; const char *my_mailslot = NULL; struct in_addr dc_ip; DATA_BLOB blob; - union nbt_cldap_netlogon r; + struct netlogon_samlogon_response r; union dgram_message_body p; enum ndr_err_code ndr_err; + NTSTATUS status; const char *returned_dc = NULL; const char *returned_domain = NULL; @@ -248,7 +249,7 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, blob.data += 4; blob.length -= 4; - ndr_err = ndr_pull_union_blob_all(&blob, mem_ctx, &p, DGRAM_SMB, + ndr_err = ndr_pull_union_blob_all(&blob, mem_ctx, NULL, &p, DGRAM_SMB, (ndr_pull_flags_fn_t)ndr_pull_dgram_smb_packet); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0,("failed to parse packet\n")); @@ -266,66 +267,20 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, blob = p.smb.body.trans.data; - if (!pull_mailslot_cldap_reply(mem_ctx, &blob, - &r, nt_version)) - { + ZERO_STRUCT(r); + + status = pull_netlogon_samlogon_response(&blob, mem_ctx, NULL, &r); + if (!NT_STATUS_IS_OK(status)) { return false; } - switch (*nt_version) { - case 1: - case 16: - case 17: - - returned_domain = r.logon1.domain_name; - returned_dc = r.logon1.pdc_name; - break; - case 2: - case 3: - case 18: - case 19: - returned_domain = r.logon3.domain_name; - returned_dc = r.logon3.pdc_name; - break; - case 4: - case 5: - case 6: - case 7: - returned_domain = r.logon5.domain; - returned_dc = r.logon5.pdc_name; - break; - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - returned_domain = r.logon13.domain; - returned_dc = r.logon13.pdc_name; - break; - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - returned_domain = r.logon15.domain; - returned_dc = r.logon15.pdc_name; - break; - case 29: - case 30: - case 31: - returned_domain = r.logon29.domain; - returned_dc = r.logon29.pdc_name; - break; - default: - return false; - } + map_netlogon_samlogon_response(&r); + + /* do we still need this ? */ + *nt_version = r.ntver; + + returned_domain = r.data.nt5_ex.domain; + returned_dc = r.data.nt5_ex.pdc_name; if (!strequal(returned_domain, domain_name)) { DEBUG(3, ("GetDC: Expected domain %s, got %s\n", @@ -341,10 +296,10 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, if (**dc_name == '\\') *dc_name += 1; if (**dc_name == '\\') *dc_name += 1; - if (reply) { - *reply = (union nbt_cldap_netlogon *)talloc_memdup( - mem_ctx, &r, sizeof(union nbt_cldap_netlogon)); - if (!*reply) { + if (_r) { + *_r = (struct netlogon_samlogon_response *)talloc_memdup( + mem_ctx, &r, sizeof(struct netlogon_samlogon_response)); + if (!*_r) { return false; } } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 9d65fb4e94..8a5aedfde5 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -464,13 +464,11 @@ struct cli_state *cli_initialise(void) return NULL; } - cli = talloc(NULL, struct cli_state); + cli = TALLOC_ZERO_P(NULL, struct cli_state); if (!cli) { return NULL; } - ZERO_STRUCTP(cli); - cli->port = 0; cli->fd = -1; cli->cnum = -1; diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 36746419f7..54f8a7a43c 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -236,142 +236,6 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode) *ecode = SVAL(cli->inbuf,smb_err); } -/* Return a UNIX errno from a NT status code */ -static const struct { - NTSTATUS status; - int error; -} nt_errno_map[] = { - {NT_STATUS_ACCESS_VIOLATION, EACCES}, - {NT_STATUS_INVALID_HANDLE, EBADF}, - {NT_STATUS_ACCESS_DENIED, EACCES}, - {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, - {NT_STATUS_OBJECT_PATH_NOT_FOUND, ENOENT}, - {NT_STATUS_SHARING_VIOLATION, EBUSY}, - {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, - {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, - {NT_STATUS_PATH_NOT_COVERED, ENOENT}, - {NT_STATUS_UNSUCCESSFUL, EINVAL}, - {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, - {NT_STATUS_IN_PAGE_ERROR, EFAULT}, - {NT_STATUS_BAD_NETWORK_NAME, ENOENT}, -#ifdef EDQUOT - {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, - {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, - {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, - {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, -#endif -#ifdef ETIME - {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, -#endif - {NT_STATUS_INVALID_PARAMETER, EINVAL}, - {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, - {NT_STATUS_NO_SUCH_FILE, ENOENT}, -#ifdef ENODATA - {NT_STATUS_END_OF_FILE, ENODATA}, -#endif -#ifdef ENOMEDIUM - {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM}, - {NT_STATUS_NO_MEDIA, ENOMEDIUM}, -#endif - {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE}, - {NT_STATUS_NO_MEMORY, ENOMEM}, - {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE}, - {NT_STATUS_NOT_MAPPED_VIEW, EINVAL}, - {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE}, - {NT_STATUS_ACCESS_DENIED, EACCES}, - {NT_STATUS_BUFFER_TOO_SMALL, ENOBUFS}, - {NT_STATUS_WRONG_PASSWORD, EACCES}, - {NT_STATUS_LOGON_FAILURE, EACCES}, - {NT_STATUS_INVALID_WORKSTATION, EACCES}, - {NT_STATUS_INVALID_LOGON_HOURS, EACCES}, - {NT_STATUS_PASSWORD_EXPIRED, EACCES}, - {NT_STATUS_ACCOUNT_DISABLED, EACCES}, - {NT_STATUS_DISK_FULL, ENOSPC}, - {NT_STATUS_INVALID_PIPE_STATE, EPIPE}, - {NT_STATUS_PIPE_BUSY, EPIPE}, - {NT_STATUS_PIPE_DISCONNECTED, EPIPE}, - {NT_STATUS_PIPE_NOT_AVAILABLE, ENOSYS}, - {NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR}, - {NT_STATUS_NOT_SUPPORTED, ENOSYS}, - {NT_STATUS_NOT_A_DIRECTORY, ENOTDIR}, - {NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY}, - {NT_STATUS_NETWORK_UNREACHABLE, ENETUNREACH}, - {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH}, - {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED}, - {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED}, - {NT_STATUS_TOO_MANY_LINKS, EMLINK}, - {NT_STATUS_NETWORK_BUSY, EBUSY}, - {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, -#ifdef ELIBACC - {NT_STATUS_DLL_NOT_FOUND, ELIBACC}, -#endif - {NT_STATUS_PIPE_BROKEN, EPIPE}, - {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED}, - {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES}, - {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE}, -#ifdef EPROTO - {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO}, -#endif - {NT_STATUS_FLOAT_OVERFLOW, ERANGE}, - {NT_STATUS_FLOAT_UNDERFLOW, ERANGE}, - {NT_STATUS_INTEGER_OVERFLOW, ERANGE}, - {NT_STATUS_MEDIA_WRITE_PROTECTED, EROFS}, - {NT_STATUS_PIPE_CONNECTED, EISCONN}, - {NT_STATUS_MEMORY_NOT_ALLOCATED, EFAULT}, - {NT_STATUS_FLOAT_INEXACT_RESULT, ERANGE}, - {NT_STATUS_ILL_FORMED_PASSWORD, EACCES}, - {NT_STATUS_PASSWORD_RESTRICTION, EACCES}, - {NT_STATUS_ACCOUNT_RESTRICTION, EACCES}, - {NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED}, - {NT_STATUS_NAME_TOO_LONG, ENAMETOOLONG}, - {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN}, - {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED}, - {NT_STATUS_CONNECTION_RESET, ENETRESET}, -#ifdef ENOTUNIQ - {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ}, - {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ}, -#endif - {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE}, - {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT}, - {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE}, - {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, - {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, - {NT_STATUS_RETRY, EAGAIN}, -#ifdef ENOTUNIQ - {NT_STATUS_DUPLICATE_NAME, ENOTUNIQ}, -#endif -#ifdef ECOMM - {NT_STATUS_NET_WRITE_FAULT, ECOMM}, -#endif -#ifdef EXDEV - {NT_STATUS_NOT_SAME_DEVICE, EXDEV}, -#endif - {NT_STATUS(0), 0} -}; - -/**************************************************************************** - The following mappings need tidying up and moving into libsmb/errormap.c... -****************************************************************************/ - -static int cli_errno_from_nt(NTSTATUS status) -{ - int i; - DEBUG(10,("cli_errno_from_nt: 32 bit codes: code=%08x\n", NT_STATUS_V(status))); - - /* Status codes without this bit set are not errors */ - - if (!(NT_STATUS_V(status) & 0xc0000000)) { - return 0; - } - - for (i=0;nt_errno_map[i].error;i++) { - if (NT_STATUS_V(nt_errno_map[i].status) == - NT_STATUS_V(status)) return nt_errno_map[i].error; - } - - /* for all other cases - a default code */ - return EINVAL; -} /* Return a UNIX errno appropriate for the error received in the last packet. */ @@ -382,7 +246,7 @@ int cli_errno(struct cli_state *cli) if (cli_is_nt_error(cli)) { status = cli_nt_error(cli); - return cli_errno_from_nt(status); + return map_errno_from_nt_status(status); } if (cli_is_dos_error(cli)) { @@ -391,7 +255,7 @@ int cli_errno(struct cli_state *cli) cli_dos_error(cli, &eclass, &ecode); status = dos_to_ntstatus(eclass, ecode); - return cli_errno_from_nt(status); + return map_errno_from_nt_status(status); } /* diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index d3819af444..1c525363f7 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -1234,7 +1234,7 @@ bool cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) ****************************************************************************/ bool cli_lock64(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type) + uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type) { char *p; int saved_timeout = cli->timeout; @@ -1294,7 +1294,7 @@ bool cli_lock64(struct cli_state *cli, int fnum, Unlock a file with 64 bit offsets. ****************************************************************************/ -bool cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len) +bool cli_unlock64(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len) { char *p; @@ -1341,7 +1341,7 @@ bool cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_ ****************************************************************************/ static bool cli_posix_lock_internal(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, bool wait_lock, enum brl_type lock_type) + uint64_t offset, uint64_t len, bool wait_lock, enum brl_type lock_type) { unsigned int param_len = 4; unsigned int data_len = POSIX_LOCK_DATA_SIZE; @@ -1412,7 +1412,7 @@ static bool cli_posix_lock_internal(struct cli_state *cli, int fnum, ****************************************************************************/ bool cli_posix_lock(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, + uint64_t offset, uint64_t len, bool wait_lock, enum brl_type lock_type) { if (lock_type != READ_LOCK && lock_type != WRITE_LOCK) { @@ -1425,7 +1425,7 @@ bool cli_posix_lock(struct cli_state *cli, int fnum, POSIX Unlock a file. ****************************************************************************/ -bool cli_posix_unlock(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len) +bool cli_posix_unlock(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len) { return cli_posix_lock_internal(cli, fnum, offset, len, False, UNLOCK_LOCK); } @@ -1434,7 +1434,7 @@ bool cli_posix_unlock(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_ POSIX Get any lock covering a file. ****************************************************************************/ -bool cli_posix_getlock(struct cli_state *cli, int fnum, SMB_BIG_UINT *poffset, SMB_BIG_UINT *plen) +bool cli_posix_getlock(struct cli_state *cli, int fnum, uint64_t *poffset, uint64_t *plen) { return True; } diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index b8afb57977..790e8d5369 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -607,7 +607,7 @@ static bool ads_cleanup_expired_creds(krb5_context context, DEBUG(3, ("ads_cleanup_expired_creds: Ticket in ccache[%s:%s] expiration %s\n", cc_type, krb5_cc_get_name(context, ccache), - http_timestring(credsp->times.endtime))); + http_timestring(talloc_tos(), credsp->times.endtime))); /* we will probably need new tickets if the current ones will expire within 10 seconds. @@ -704,7 +704,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s:%s) is valid until: (%s - %u)\n", principal, krb5_cc_get_type(context, ccache), krb5_cc_get_name(context, ccache), - http_timestring((unsigned)credsp->times.endtime), + http_timestring(talloc_tos(), (unsigned)credsp->times.endtime), (unsigned)credsp->times.endtime)); if (expire_time) { diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index f369d28dff..1462aa7a6a 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -2,17 +2,17 @@ Unix SMB/CIFS implementation. client quota functions 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 . */ @@ -25,7 +25,7 @@ bool cli_get_quota_handle(struct cli_state *cli, int *quota_fnum) 0x00000016, DESIRED_ACCESS_PIPE, 0x00000000, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x00000000, 0x03); - + if (*quota_fnum == (-1)) { return False; } @@ -37,7 +37,7 @@ void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list) { if (!qt_list) return; - + if ((*qt_list)->mem_ctx) talloc_destroy((*qt_list)->mem_ctx); @@ -60,7 +60,7 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, if (rdata_count < 40) { return False; } - + /* offset to next quota record. * 4 bytes IVAL(rdata,0) * unused here... @@ -78,10 +78,10 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, * maybe its the change time in NTTIME */ - /* the used space 8 bytes (SMB_BIG_UINT)*/ - qt.usedspace = (SMB_BIG_UINT)IVAL(rdata,16); + /* the used space 8 bytes (uint64_t)*/ + qt.usedspace = (uint64_t)IVAL(rdata,16); #ifdef LARGE_SMB_OFF_T - qt.usedspace |= (((SMB_BIG_UINT)IVAL(rdata,20)) << 32); + qt.usedspace |= (((uint64_t)IVAL(rdata,20)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,20) != 0)&& ((qt.usedspace != 0xFFFFFFFF)|| @@ -91,10 +91,10 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, } #endif /* LARGE_SMB_OFF_T */ - /* the soft quotas 8 bytes (SMB_BIG_UINT)*/ - qt.softlim = (SMB_BIG_UINT)IVAL(rdata,24); + /* the soft quotas 8 bytes (uint64_t)*/ + qt.softlim = (uint64_t)IVAL(rdata,24); #ifdef LARGE_SMB_OFF_T - qt.softlim |= (((SMB_BIG_UINT)IVAL(rdata,28)) << 32); + qt.softlim |= (((uint64_t)IVAL(rdata,28)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| @@ -104,10 +104,10 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, } #endif /* LARGE_SMB_OFF_T */ - /* the hard quotas 8 bytes (SMB_BIG_UINT)*/ - qt.hardlim = (SMB_BIG_UINT)IVAL(rdata,32); + /* the hard quotas 8 bytes (uint64_t)*/ + qt.hardlim = (uint64_t)IVAL(rdata,32); #ifdef LARGE_SMB_OFF_T - qt.hardlim |= (((SMB_BIG_UINT)IVAL(rdata,36)) << 32); + qt.hardlim |= (((uint64_t)IVAL(rdata,36)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| @@ -116,7 +116,7 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, return False; } #endif /* LARGE_SMB_OFF_T */ - + sid_parse(rdata+40,sid_len,&qt.sid); qt.qtype = SMB_USER_QUOTA_TYPE; @@ -149,13 +149,13 @@ bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC SIVAL(params, 4,0x00000024); SIVAL(params, 8,0x00000000); SIVAL(params,12,0x00000024); - + sid_len = ndr_size_dom_sid(&pqt->sid, 0); data_len = sid_len+8; SIVAL(data, 0, 0x00000000); SIVAL(data, 4, sid_len); sid_linearize(data+8, sid_len, &pqt->sid); - + if (!cli_send_nt_trans(cli, NT_TRANSACT_GET_USER_QUOTA, 0, @@ -204,7 +204,7 @@ bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC unsigned int rparam_count=0, rdata_count=0; unsigned int sid_len; memset(data,'\0',112); - + if (!cli||!pqt) { smb_panic("cli_set_user_quota() called with NULL Pointer!"); } @@ -216,12 +216,12 @@ bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC sid_len = ndr_size_dom_sid(&pqt->sid, 0); SIVAL(data,0,0); SIVAL(data,4,sid_len); - SBIG_UINT(data, 8,(SMB_BIG_UINT)0); + SBIG_UINT(data, 8,(uint64_t)0); SBIG_UINT(data,16,pqt->usedspace); SBIG_UINT(data,24,pqt->softlim); SBIG_UINT(data,32,pqt->hardlim); sid_linearize(data+40, sid_len, &pqt->sid); - + if (!cli_send_nt_trans(cli, NT_TRANSACT_SET_USER_QUOTA, 0, @@ -278,7 +278,7 @@ bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST SIVAL(params, 4,0x00000000); SIVAL(params, 8,0x00000000); SIVAL(params,12,0x00000000); - + if (!cli_send_nt_trans(cli, NT_TRANSACT_GET_USER_QUOTA, 0, @@ -353,7 +353,7 @@ bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); goto cleanup; } - + SAFE_FREE(rparam); SAFE_FREE(rdata); if (!cli_receive_nt_trans(cli, @@ -369,7 +369,7 @@ bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST } else { ret = True; } - + if (rdata_count == 0) { break; } @@ -389,26 +389,26 @@ bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST talloc_destroy(mem_ctx); goto cleanup; } - + if ((tmp_list_ent->quotas=TALLOC_ZERO_P(mem_ctx,SMB_NTQUOTA_STRUCT))==NULL) { DEBUG(0,("TALLOC_ZERO() failed\n")); talloc_destroy(mem_ctx); goto cleanup; } - + memcpy(tmp_list_ent->quotas,&qt,sizeof(qt)); tmp_list_ent->mem_ctx = mem_ctx; - + DLIST_ADD((*pqt_list),tmp_list_ent); } } - + ret = True; cleanup: SAFE_FREE(rparam); SAFE_FREE(rdata); - + return ret; } @@ -427,9 +427,9 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST } setup = TRANSACT2_QFSINFO; - + SSVAL(param,0,SMB_FS_QUOTA_INFORMATION); - + if (!cli_send_trans(cli, SMBtrans2, NULL, 0, 0, @@ -438,7 +438,7 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST NULL, 0, 560)) { goto cleanup; } - + if (!cli_receive_trans(cli, SMBtrans2, &rparam, &rparam_count, &rdata, &rdata_count)) { @@ -455,13 +455,13 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST if (rdata_count < 48) { goto cleanup; } - + /* unknown_1 24 NULL bytes in pdata*/ - /* the soft quotas 8 bytes (SMB_BIG_UINT)*/ - qt.softlim = (SMB_BIG_UINT)IVAL(rdata,24); + /* the soft quotas 8 bytes (uint64_t)*/ + qt.softlim = (uint64_t)IVAL(rdata,24); #ifdef LARGE_SMB_OFF_T - qt.softlim |= (((SMB_BIG_UINT)IVAL(rdata,28)) << 32); + qt.softlim |= (((uint64_t)IVAL(rdata,28)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| @@ -471,10 +471,10 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST } #endif /* LARGE_SMB_OFF_T */ - /* the hard quotas 8 bytes (SMB_BIG_UINT)*/ - qt.hardlim = (SMB_BIG_UINT)IVAL(rdata,32); + /* the hard quotas 8 bytes (uint64_t)*/ + qt.hardlim = (uint64_t)IVAL(rdata,32); #ifdef LARGE_SMB_OFF_T - qt.hardlim |= (((SMB_BIG_UINT)IVAL(rdata,36)) << 32); + qt.hardlim |= (((uint64_t)IVAL(rdata,36)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(rdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| @@ -541,7 +541,7 @@ bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST data, 48, 0)) { goto cleanup; } - + if (!cli_receive_trans(cli, SMBtrans2, &rparam, &rparam_count, &rdata, &rdata_count)) { @@ -562,18 +562,14 @@ cleanup: return ret; } -static const char *quota_str_static(SMB_BIG_UINT val, bool special, bool _numeric) +static const char *quota_str_static(uint64_t val, bool special, bool _numeric) { const char *result; if (!_numeric&&special&&(val == SMB_NTQUOTAS_NO_LIMIT)) { return "NO LIMIT"; } -#if defined(HAVE_LONGLONG) - result = talloc_asprintf(talloc_tos(), "%llu", val); -#else - result = talloc_asprintf(talloc_tos(), "%lu", val); -#endif + result = talloc_asprintf(talloc_tos(), "%"PRIu64, val); SMB_ASSERT(result != NULL); return result; } @@ -604,7 +600,7 @@ void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_ case SMB_USER_QUOTA_TYPE: { fstring username_str = {0}; - + if (_sidtostring) { _sidtostring(username_str,&qt->sid,_numeric); } else { diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index ec63281630..cc982683d0 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -70,10 +70,10 @@ struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx, SSVAL(vwv + 8, 0, 0); SSVAL(vwv + 9, 0, 0); - if ((SMB_BIG_UINT)offset >> 32) { + if ((uint64_t)offset >> 32) { bigoffset = True; SIVAL(vwv + 10, 0, - (((SMB_BIG_UINT)offset)>>32) & 0xffffffff); + (((uint64_t)offset)>>32) & 0xffffffff); wct += 2; } @@ -543,7 +543,7 @@ static bool cli_issue_write(struct cli_state *cli, smb_buf(cli->outbuf) - smb_base(cli->outbuf) + 1); if (large_writex) { - SIVAL(cli->outbuf,smb_vwv12,(((SMB_BIG_UINT)offset)>>32) & 0xffffffff); + SIVAL(cli->outbuf,smb_vwv12,(((uint64_t)offset)>>32) & 0xffffffff); } p = smb_base(cli->outbuf) + SVAL(cli->outbuf,smb_vwv11) -1; diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index 2a445cbd5a..08ab8cad14 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -35,8 +35,7 @@ struct ip_service_name { static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx, uint32_t flags, struct sockaddr_storage *ss, - uint32_t nt_version, - union nbt_cldap_netlogon *r, + struct NETLOGON_SAM_LOGON_RESPONSE_EX *r, struct netr_DsRGetDCNameInfo **info); /**************************************************************** @@ -186,176 +185,51 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx, /**************************************************************** ****************************************************************/ -#define SET_STRING(x) \ - talloc_strdup(mem_ctx, x); \ - NT_STATUS_HAVE_NO_MEMORY(x); - -static NTSTATUS map_logon29_from_cldap_reply(TALLOC_CTX *mem_ctx, - uint32_t flags, - struct sockaddr_storage *ss, - uint32_t nt_version, - union nbt_cldap_netlogon *r, - struct nbt_cldap_netlogon_29 *p) -{ - char addr[INET6_ADDRSTRLEN]; - - ZERO_STRUCTP(p); - - print_sockaddr(addr, sizeof(addr), ss); - - /* FIXME */ - p->dc_sock_addr_size = 0x10; /* the w32 winsock addr size */ - p->dc_sock_addr.family = 2; /* AF_INET */ - p->dc_sock_addr.pdc_ip = talloc_strdup(mem_ctx, addr); - - switch (nt_version & 0x0000001f) { - case 0: - return NT_STATUS_INVALID_PARAMETER; - case 1: - case 16: - case 17: - p->pdc_name = SET_STRING(r->logon1.pdc_name); - p->domain = SET_STRING(r->logon1.domain_name); - - if (flags & DS_PDC_REQUIRED) { - p->server_type = NBT_SERVER_WRITABLE | - NBT_SERVER_PDC; - } - break; - case 2: - case 3: - case 18: - case 19: - p->pdc_name = SET_STRING(r->logon3.pdc_name); - p->domain = SET_STRING(r->logon3.domain_name); - p->pdc_dns_name = SET_STRING(r->logon3.pdc_dns_name); - p->dns_domain = SET_STRING(r->logon3.dns_domain); - p->server_type = r->logon3.server_type; - p->forest = SET_STRING(r->logon3.forest); - p->domain_uuid = r->logon3.domain_uuid; - - break; - case 4: - case 5: - case 6: - case 7: - p->pdc_name = SET_STRING(r->logon5.pdc_name); - p->domain = SET_STRING(r->logon5.domain); - p->pdc_dns_name = SET_STRING(r->logon5.pdc_dns_name); - p->dns_domain = SET_STRING(r->logon5.dns_domain); - p->server_type = r->logon5.server_type; - p->forest = SET_STRING(r->logon5.forest); - p->domain_uuid = r->logon5.domain_uuid; - p->server_site = SET_STRING(r->logon5.server_site); - p->client_site = SET_STRING(r->logon5.client_site); - - break; - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - p->pdc_name = SET_STRING(r->logon13.pdc_name); - p->domain = SET_STRING(r->logon13.domain); - p->pdc_dns_name = SET_STRING(r->logon13.pdc_dns_name); - p->dns_domain = SET_STRING(r->logon13.dns_domain); - p->server_type = r->logon13.server_type; - p->forest = SET_STRING(r->logon13.forest); - p->domain_uuid = r->logon13.domain_uuid; - p->server_site = SET_STRING(r->logon13.server_site); - p->client_site = SET_STRING(r->logon13.client_site); - - break; - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - p->pdc_name = SET_STRING(r->logon15.pdc_name); - p->domain = SET_STRING(r->logon15.domain); - p->pdc_dns_name = SET_STRING(r->logon15.pdc_dns_name); - p->dns_domain = SET_STRING(r->logon15.dns_domain); - p->server_type = r->logon15.server_type; - p->forest = SET_STRING(r->logon15.forest); - p->domain_uuid = r->logon15.domain_uuid; - p->server_site = SET_STRING(r->logon15.server_site); - p->client_site = SET_STRING(r->logon15.client_site); - - break; - case 29: - case 30: - case 31: - p->pdc_name = SET_STRING(r->logon29.pdc_name); - p->domain = SET_STRING(r->logon29.domain); - p->pdc_dns_name = SET_STRING(r->logon29.pdc_dns_name); - p->dns_domain = SET_STRING(r->logon29.dns_domain); - p->server_type = r->logon29.server_type; - p->forest = SET_STRING(r->logon29.forest); - p->domain_uuid = r->logon29.domain_uuid; - p->server_site = SET_STRING(r->logon29.server_site); - p->client_site = SET_STRING(r->logon29.client_site); - p->next_closest_site = SET_STRING(r->logon29.next_closest_site); - - break; - default: - return NT_STATUS_INVALID_PARAMETER; - } - - return NT_STATUS_OK; -} - -/**************************************************************** -****************************************************************/ - static NTSTATUS store_cldap_reply(TALLOC_CTX *mem_ctx, uint32_t flags, struct sockaddr_storage *ss, uint32_t nt_version, - union nbt_cldap_netlogon *r) + struct NETLOGON_SAM_LOGON_RESPONSE_EX *r) { DATA_BLOB blob; enum ndr_err_code ndr_err; NTSTATUS status; - struct nbt_cldap_netlogon_29 logon29; + char addr[INET6_ADDRSTRLEN]; - status = map_logon29_from_cldap_reply(mem_ctx, flags, ss, - nt_version, r, &logon29); - if (!NT_STATUS_IS_OK(status)) { - return status; - } + print_sockaddr(addr, sizeof(addr), ss); + + /* FIXME */ + r->sockaddr_size = 0x10; /* the w32 winsock addr size */ + r->sockaddr.sockaddr_family = 2; /* AF_INET */ + r->sockaddr.pdc_ip = talloc_strdup(mem_ctx, addr); - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &logon29, - (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon_29); + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, r, + (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return ndr_map_error2ntstatus(ndr_err); } - if (logon29.domain) { - status = dsgetdcname_cache_store(mem_ctx, logon29.domain, &blob); + if (r->domain) { + status = dsgetdcname_cache_store(mem_ctx, r->domain, &blob); if (!NT_STATUS_IS_OK(status)) { goto done; } - if (logon29.client_site) { - sitename_store(logon29.domain, logon29.client_site); + if (r->client_site) { + sitename_store(r->domain, r->client_site); } } - if (logon29.dns_domain) { - status = dsgetdcname_cache_store(mem_ctx, logon29.dns_domain, &blob); + if (r->dns_domain) { + status = dsgetdcname_cache_store(mem_ctx, r->dns_domain, &blob); if (!NT_STATUS_IS_OK(status)) { goto done; } - if (logon29.client_site) { - sitename_store(logon29.dns_domain, logon29.client_site); + if (r->client_site) { + sitename_store(r->dns_domain, r->client_site); } } + status = NT_STATUS_OK; + done: data_blob_free(&blob); @@ -387,7 +261,7 @@ static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx, /**************************************************************** ****************************************************************/ -static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r, +static uint32_t get_cldap_reply_server_flags(struct netlogon_samlogon_response *r, uint32_t nt_version) { switch (nt_version & 0x0000001f) { @@ -400,12 +274,12 @@ static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r, case 3: case 18: case 19: - return r->logon3.server_type; + return r->data.nt5.server_type; case 4: case 5: case 6: case 7: - return r->logon5.server_type; + return r->data.nt5_ex.server_type; case 8: case 9: case 10: @@ -414,7 +288,7 @@ static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r, case 13: case 14: case 15: - return r->logon13.server_type; + return r->data.nt5_ex.server_type; case 20: case 21: case 22: @@ -424,11 +298,11 @@ static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r, case 26: case 27: case 28: - return r->logon15.server_type; + return r->data.nt5_ex.server_type; case 29: case 30: case 31: - return r->logon29.server_type; + return r->data.nt5_ex.server_type; default: return 0; } @@ -486,8 +360,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, DATA_BLOB blob; enum ndr_err_code ndr_err; struct netr_DsRGetDCNameInfo *info; - union nbt_cldap_netlogon p; - struct nbt_cldap_netlogon_29 r; + struct NETLOGON_SAM_LOGON_RESPONSE_EX r; NTSTATUS status; if (!gencache_init()) { @@ -508,8 +381,8 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon_29); + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &r, + (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX); data_blob_free(&blob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -517,11 +390,8 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, return ndr_map_error2ntstatus(ndr_err); } - p.logon29 = r; - status = make_dc_info_from_cldap_reply(mem_ctx, flags, NULL, - 29, - &p, &info); + &r, &info); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -916,8 +786,7 @@ static void map_dc_and_domain_names(uint32_t flags, static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx, uint32_t flags, struct sockaddr_storage *ss, - uint32_t nt_version, - union nbt_cldap_netlogon *r, + struct NETLOGON_SAM_LOGON_RESPONSE_EX *r, struct netr_DsRGetDCNameInfo **info) { const char *dc_hostname = NULL; @@ -938,163 +807,28 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx, dc_address_type = DS_ADDRESS_TYPE_INET; } - switch (nt_version & 0x0000001f) { - case 0: - case 1: - case 16: - case 17: - if (!ss) { - dc_address = r->logon1.pdc_name; - dc_address_type = DS_ADDRESS_TYPE_NETBIOS; - } - - map_dc_and_domain_names(flags, - r->logon1.pdc_name, - r->logon1.domain_name, - NULL, - NULL, - &dc_flags, - &dc_hostname, - &dc_domain_name); - - if (flags & DS_PDC_REQUIRED) { - dc_flags = NBT_SERVER_WRITABLE | NBT_SERVER_PDC; - } - break; - case 2: - case 3: - case 18: - case 19: - if (!ss) { - dc_address = r->logon3.pdc_ip; - dc_address_type = DS_ADDRESS_TYPE_INET; - } - - map_dc_and_domain_names(flags, - r->logon3.pdc_name, - r->logon3.domain_name, - r->logon3.pdc_dns_name, - r->logon3.dns_domain, - &dc_flags, - &dc_hostname, - &dc_domain_name); - - dc_flags |= r->logon3.server_type; - dc_forest = r->logon3.forest; - dc_domain_guid = &r->logon3.domain_uuid; - - break; - case 4: - case 5: - case 6: - case 7: - if (!ss) { - dc_address = r->logon5.pdc_name; - dc_address_type = DS_ADDRESS_TYPE_NETBIOS; - } - - map_dc_and_domain_names(flags, - r->logon5.pdc_name, - r->logon5.domain, - r->logon5.pdc_dns_name, - r->logon5.dns_domain, - &dc_flags, - &dc_hostname, - &dc_domain_name); - - dc_flags |= r->logon5.server_type; - dc_forest = r->logon5.forest; - dc_domain_guid = &r->logon5.domain_uuid; - dc_server_site = r->logon5.server_site; - dc_client_site = r->logon5.client_site; - - break; - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - if (!ss) { - dc_address = r->logon13.dc_sock_addr.pdc_ip; - dc_address_type = DS_ADDRESS_TYPE_INET; - } - - map_dc_and_domain_names(flags, - r->logon13.pdc_name, - r->logon13.domain, - r->logon13.pdc_dns_name, - r->logon13.dns_domain, - &dc_flags, - &dc_hostname, - &dc_domain_name); - - dc_flags |= r->logon13.server_type; - dc_forest = r->logon13.forest; - dc_domain_guid = &r->logon13.domain_uuid; - dc_server_site = r->logon13.server_site; - dc_client_site = r->logon13.client_site; - - break; - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - if (!ss) { - dc_address = r->logon15.pdc_name; - dc_address_type = DS_ADDRESS_TYPE_NETBIOS; - } + if (!ss && r->sockaddr.pdc_ip) { + dc_address = r->sockaddr.pdc_ip; + dc_address_type = DS_ADDRESS_TYPE_INET; + } else { + dc_address = r->pdc_name; + dc_address_type = DS_ADDRESS_TYPE_NETBIOS; + } - map_dc_and_domain_names(flags, - r->logon15.pdc_name, - r->logon15.domain, - r->logon15.pdc_dns_name, - r->logon15.dns_domain, - &dc_flags, - &dc_hostname, - &dc_domain_name); - - dc_flags |= r->logon15.server_type; - dc_forest = r->logon15.forest; - dc_domain_guid = &r->logon15.domain_uuid; - dc_server_site = r->logon15.server_site; - dc_client_site = r->logon15.client_site; - - break; - case 29: - case 30: - case 31: - if (!ss) { - dc_address = r->logon29.dc_sock_addr.pdc_ip; - dc_address_type = DS_ADDRESS_TYPE_INET; - } + map_dc_and_domain_names(flags, + r->pdc_name, + r->domain, + r->pdc_dns_name, + r->dns_domain, + &dc_flags, + &dc_hostname, + &dc_domain_name); - map_dc_and_domain_names(flags, - r->logon29.pdc_name, - r->logon29.domain, - r->logon29.pdc_dns_name, - r->logon29.dns_domain, - &dc_flags, - &dc_hostname, - &dc_domain_name); - - dc_flags |= r->logon29.server_type; - dc_forest = r->logon29.forest; - dc_domain_guid = &r->logon29.domain_uuid; - dc_server_site = r->logon29.server_site; - dc_client_site = r->logon29.client_site; - - break; - default: - return NT_STATUS_INVALID_PARAMETER; - } + dc_flags |= r->server_type; + dc_forest = r->forest; + dc_domain_guid = &r->domain_uuid; + dc_server_site = r->server_site; + dc_client_site = r->client_site; return make_domain_controller_info(mem_ctx, dc_hostname, @@ -1117,19 +851,19 @@ static uint32_t map_ds_flags_to_nt_version(uint32_t flags) uint32_t nt_version = 0; if (flags & DS_PDC_REQUIRED) { - nt_version |= NETLOGON_VERSION_PDC; + nt_version |= NETLOGON_NT_VERSION_PDC; } if (flags & DS_GC_SERVER_REQUIRED) { - nt_version |= NETLOGON_VERSION_GC; + nt_version |= NETLOGON_NT_VERSION_GC; } if (flags & DS_TRY_NEXTCLOSEST_SITE) { - nt_version |= NETLOGON_VERSION_WITH_CLOSEST_SITE; + nt_version |= NETLOGON_NT_VERSION_WITH_CLOSEST_SITE; } if (flags & DS_IP_REQUIRED) { - nt_version |= NETLOGON_VERSION_IP; + nt_version |= NETLOGON_NT_VERSION_IP; } return nt_version; @@ -1147,9 +881,9 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, { int i = 0; bool valid_dc = false; - union nbt_cldap_netlogon *r = NULL; - uint32_t nt_version = NETLOGON_VERSION_5 | - NETLOGON_VERSION_5EX; + struct netlogon_samlogon_response *r = NULL; + uint32_t nt_version = NETLOGON_NT_VERSION_5 | + NETLOGON_NT_VERSION_5EX; uint32_t ret_flags = 0; NTSTATUS status; @@ -1161,9 +895,10 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, if (ads_cldap_netlogon(mem_ctx, dclist[i].hostname, domain_name, - &nt_version, + nt_version, &r)) { + nt_version = r->ntver; ret_flags = get_cldap_reply_server_flags(r, nt_version); if (check_cldap_reply_required_flags(ret_flags, flags)) { @@ -1180,10 +915,10 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, } status = make_dc_info_from_cldap_reply(mem_ctx, flags, &dclist[i].ss, - nt_version, r, info); + &r->data.nt5_ex, info); if (NT_STATUS_IS_OK(status)) { return store_cldap_reply(mem_ctx, flags, &dclist[i].ss, - nt_version, r); + nt_version, &r->data.nt5_ex); } return status; @@ -1234,11 +969,11 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, int i; const char *dc_name = NULL; fstring tmp_dc_name; - union nbt_cldap_netlogon *r = NULL; + struct netlogon_samlogon_response *r = NULL; bool store_cache = false; - uint32_t nt_version = NETLOGON_VERSION_1 | - NETLOGON_VERSION_5 | - NETLOGON_VERSION_5EX_WITH_IP; + uint32_t nt_version = NETLOGON_NT_VERSION_1 | + NETLOGON_NT_VERSION_5 | + NETLOGON_NT_VERSION_5EX_WITH_IP; if (!msg_ctx) { msg_ctx = msg_context(mem_ctx); @@ -1288,21 +1023,22 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, &dclist[i].ss, tmp_dc_name)) { - struct nbt_cldap_netlogon_1 logon1; + struct NETLOGON_SAM_LOGON_RESPONSE_NT40 logon1; - r = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon); + r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response); NT_STATUS_HAVE_NO_MEMORY(r); ZERO_STRUCT(logon1); - nt_version = NETLOGON_VERSION_1; + nt_version = NETLOGON_NT_VERSION_1; logon1.nt_version = nt_version; - logon1.pdc_name = tmp_dc_name; - logon1.domain_name = talloc_strdup_upper(mem_ctx, domain_name); - NT_STATUS_HAVE_NO_MEMORY(logon1.domain_name); + logon1.server = tmp_dc_name; + logon1.domain = talloc_strdup_upper(mem_ctx, domain_name); + NT_STATUS_HAVE_NO_MEMORY(logon1.domain); - r->logon1 = logon1; + r->data.nt4 = logon1; + r->ntver = nt_version; namecache_store(tmp_dc_name, NBT_NAME_SERVER, 1, &ip_list); @@ -1315,10 +1051,10 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, make_reply: status = make_dc_info_from_cldap_reply(mem_ctx, flags, &dclist[i].ss, - nt_version, r, info); + &r->data.nt5_ex, info); if (NT_STATUS_IS_OK(status) && store_cache) { return store_cldap_reply(mem_ctx, flags, &dclist[i].ss, - nt_version, r); + nt_version, &r->data.nt5_ex); } return status; diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index f1b3d1415e..ea2c46953c 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -266,7 +266,7 @@ parse_ace(struct cli_state *ipc_cli, unsigned int aflags; unsigned int amask; DOM_SID sid; - SEC_ACCESS mask; + uint32_t mask; const struct perm_value *v; struct perm_value { const char *perm; diff --git a/source3/libsmb/ntlmssp_sign.c b/source3/libsmb/ntlmssp_sign.c index 8413c8066b..d3d358d332 100644 --- a/source3/libsmb/ntlmssp_sign.c +++ b/source3/libsmb/ntlmssp_sign.c @@ -35,6 +35,12 @@ * */ +static void dump_arc4_state(const char *description, + struct arcfour_state *state) +{ + dump_data_pw(description, state->sbox, sizeof(state->sbox)); +} + static void calc_ntlmv2_key(unsigned char subkey[16], DATA_BLOB session_key, const char *constant) @@ -101,10 +107,10 @@ static NTSTATUS ntlmssp_make_packet_signature(NTLMSSP_STATE *ntlmssp_state, if (encrypt_sig && (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)) { switch (direction) { case NTLMSSP_SEND: - smb_arc4_crypt(ntlmssp_state->send_seal_arc4_state, digest, 8); + arcfour_crypt_sbox(&ntlmssp_state->send_seal_arc4_state, digest, 8); break; case NTLMSSP_RECEIVE: - smb_arc4_crypt(ntlmssp_state->recv_seal_arc4_state, digest, 8); + arcfour_crypt_sbox(&ntlmssp_state->recv_seal_arc4_state, digest, 8); break; } } @@ -117,16 +123,15 @@ static NTSTATUS ntlmssp_make_packet_signature(NTLMSSP_STATE *ntlmssp_state, } else { uint32 crc; - crc = crc32_calc_buffer((const char *)data, length); + crc = crc32_calc_buffer(data, length); if (!msrpc_gen(sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, ntlmssp_state->ntlmv1_seq_num)) { return NT_STATUS_NO_MEMORY; } ntlmssp_state->ntlmv1_seq_num++; - dump_data_pw("ntlmssp hash:\n", ntlmssp_state->ntlmv1_arc4_state, - sizeof(ntlmssp_state->ntlmv1_arc4_state)); - smb_arc4_crypt(ntlmssp_state->ntlmv1_arc4_state, sig->data+4, sig->length-4); + dump_arc4_state("ntlmssp hash: \n", &ntlmssp_state->ntlmv1_arc4_state); + arcfour_crypt_sbox(&ntlmssp_state->ntlmv1_arc4_state, sig->data+4, sig->length-4); } return NT_STATUS_OK; } @@ -259,13 +264,13 @@ NTSTATUS ntlmssp_seal_packet(NTLMSSP_STATE *ntlmssp_state, return nt_status; } - smb_arc4_crypt(ntlmssp_state->send_seal_arc4_state, data, length); + arcfour_crypt_sbox(&ntlmssp_state->send_seal_arc4_state, data, length); if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH) { - smb_arc4_crypt(ntlmssp_state->send_seal_arc4_state, sig->data+4, 8); + arcfour_crypt_sbox(&ntlmssp_state->send_seal_arc4_state, sig->data+4, 8); } } else { uint32 crc; - crc = crc32_calc_buffer((const char *)data, length); + crc = crc32_calc_buffer(data, length); if (!msrpc_gen(sig, "dddd", NTLMSSP_SIGN_VERSION, 0, crc, ntlmssp_state->ntlmv1_seq_num)) { return NT_STATUS_NO_MEMORY; } @@ -274,14 +279,14 @@ NTSTATUS ntlmssp_seal_packet(NTLMSSP_STATE *ntlmssp_state, then seal the sequence number - this is becouse the ntlmv1_arc4_state is not constant, but is is rather updated with each iteration */ - dump_data_pw("ntlmv1 arc4 state:\n", ntlmssp_state->ntlmv1_arc4_state, - sizeof(ntlmssp_state->ntlmv1_arc4_state)); - smb_arc4_crypt(ntlmssp_state->ntlmv1_arc4_state, data, length); + dump_arc4_state("ntlmv1 arc4 state:\n", + &ntlmssp_state->ntlmv1_arc4_state); + arcfour_crypt_sbox(&ntlmssp_state->ntlmv1_arc4_state, data, length); - dump_data_pw("ntlmv1 arc4 state:\n", ntlmssp_state->ntlmv1_arc4_state, - sizeof(ntlmssp_state->ntlmv1_arc4_state)); + dump_arc4_state("ntlmv1 arc4 state:\n", + &ntlmssp_state->ntlmv1_arc4_state); - smb_arc4_crypt(ntlmssp_state->ntlmv1_arc4_state, sig->data+4, sig->length-4); + arcfour_crypt_sbox(&ntlmssp_state->ntlmv1_arc4_state, sig->data+4, sig->length-4); ntlmssp_state->ntlmv1_seq_num++; } @@ -311,10 +316,10 @@ NTSTATUS ntlmssp_unseal_packet(NTLMSSP_STATE *ntlmssp_state, if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) { /* First unseal the data. */ - smb_arc4_crypt(ntlmssp_state->recv_seal_arc4_state, data, length); + arcfour_crypt_sbox(&ntlmssp_state->recv_seal_arc4_state, data, length); dump_data_pw("ntlmv2 clear data\n", data, length); } else { - smb_arc4_crypt(ntlmssp_state->ntlmv1_arc4_state, data, length); + arcfour_crypt_sbox(&ntlmssp_state->ntlmv1_arc4_state, data, length); dump_data_pw("ntlmv1 clear data\n", data, length); } return ntlmssp_check_packet(ntlmssp_state, data, length, whole_pdu, pdu_length, sig); @@ -349,6 +354,7 @@ NTSTATUS ntlmssp_sign_init(NTLMSSP_STATE *ntlmssp_state) const char *send_seal_const; const char *recv_sign_const; const char *recv_seal_const; + DATA_BLOB send_seal_key_blob, recv_seal_blob; switch (ntlmssp_state->role) { case NTLMSSP_CLIENT: @@ -397,12 +403,13 @@ NTSTATUS ntlmssp_sign_init(NTLMSSP_STATE *ntlmssp_state) dump_data_pw("NTLMSSP send seal key:\n", ntlmssp_state->send_seal_key, 16); - smb_arc4_init(ntlmssp_state->send_seal_arc4_state, - ntlmssp_state->send_seal_key, 16); + send_seal_key_blob.data = ntlmssp_state->send_seal_key; + send_seal_key_blob.length = 16; + arcfour_init(&ntlmssp_state->send_seal_arc4_state, + &send_seal_key_blob); - dump_data_pw("NTLMSSP send seal arc4 state:\n", - ntlmssp_state->send_seal_arc4_state, - sizeof(ntlmssp_state->send_seal_arc4_state)); + dump_arc4_state("NTLMSSP send seal arc4 state:\n", + &ntlmssp_state->send_seal_arc4_state); /* RECV: sign key */ calc_ntlmv2_key(ntlmssp_state->recv_sign_key, @@ -417,12 +424,13 @@ NTSTATUS ntlmssp_sign_init(NTLMSSP_STATE *ntlmssp_state) dump_data_pw("NTLMSSP recv seal key:\n", ntlmssp_state->recv_seal_key, 16); - smb_arc4_init(ntlmssp_state->recv_seal_arc4_state, - ntlmssp_state->recv_seal_key, 16); + recv_seal_blob.data = ntlmssp_state->recv_seal_key; + recv_seal_blob.length = 16; + arcfour_init(&ntlmssp_state->recv_seal_arc4_state, + &recv_seal_blob); - dump_data_pw("NTLMSSP recv seal arc4 state:\n", - ntlmssp_state->recv_seal_arc4_state, - sizeof(ntlmssp_state->recv_seal_arc4_state)); + dump_arc4_state("NTLMSSP recv seal arc4 state:\n", + &ntlmssp_state->recv_seal_arc4_state); ntlmssp_state->ntlm2_send_seq_num = 0; ntlmssp_state->ntlm2_recv_seq_num = 0; @@ -454,11 +462,11 @@ NTSTATUS ntlmssp_sign_init(NTLMSSP_STATE *ntlmssp_state) DEBUG(5, ("NTLMSSP Sign/Seal - using NTLM1\n")); - smb_arc4_init(ntlmssp_state->ntlmv1_arc4_state, - weak_session_key.data, weak_session_key.length); + arcfour_init(&ntlmssp_state->ntlmv1_arc4_state, + &weak_session_key); - dump_data_pw("NTLMv1 arc4 state:\n", ntlmssp_state->ntlmv1_arc4_state, - sizeof(ntlmssp_state->ntlmv1_arc4_state)); + dump_arc4_state("NTLMv1 arc4 state:\n", + &ntlmssp_state->ntlmv1_arc4_state); ntlmssp_state->ntlmv1_seq_num = 0; } diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index 4abe5bb6de..7af93cf2e0 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" #define NETSAMLOGON_TDB "netsamlogon_cache.tdb" @@ -141,7 +142,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3) NDR_PRINT_DEBUG(netsamlogoncache_entry, &r); } - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &r, + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &r, (ndr_push_flags_fn_t)ndr_push_netsamlogoncache_entry); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0,("netsamlogon_cache_store: failed to push entry to cache\n")); @@ -197,7 +198,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID * blob = data_blob_const(data.dptr, data.dsize); - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &r, (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry); if (DEBUGLEVEL >= 10) { diff --git a/source3/libsmb/smbdes.c b/source3/libsmb/smbdes.c index 98d5cd05b7..8087d66799 100644 --- a/source3/libsmb/smbdes.c +++ b/source3/libsmb/smbdes.c @@ -388,18 +388,19 @@ void des_crypt112_16(unsigned char out[16], unsigned char in[16], const unsigned void SamOEMhash( unsigned char *data, const unsigned char key[16], size_t len) { - unsigned char arc4_state[258]; + struct arcfour_state arc4_state; + const DATA_BLOB keyblob = data_blob_const(key, 16); - smb_arc4_init(arc4_state, key, 16); - smb_arc4_crypt(arc4_state, data, len); + arcfour_init(&arc4_state, &keyblob); + arcfour_crypt_sbox(&arc4_state, data, len); } void SamOEMhashBlob( unsigned char *data, size_t len, DATA_BLOB *key) { - unsigned char arc4_state[258]; + struct arcfour_state arc4_state; - smb_arc4_init(arc4_state, key->data, key->length); - smb_arc4_crypt(arc4_state, data, len); + arcfour_init(&arc4_state, key); + arcfour_crypt_sbox(&arc4_state, data, len); } /* Decode a sam password hash into a password. The password hash is the diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c index 0742976635..ee162b1b2d 100644 --- a/source3/libsmb/smbencrypt.c +++ b/source3/libsmb/smbencrypt.c @@ -22,7 +22,7 @@ */ #include "includes.h" -#include "byteorder.h" +#include "../lib/util/byteorder.h" void SMBencrypt_hash(const uchar lm_hash[16], const uchar *c8, uchar p24[24]) { @@ -847,7 +847,7 @@ DATA_BLOB decrypt_drsuapi_blob(TALLOC_CTX *mem_ctx, * of the remaining bytes */ crc32_given = IVAL(dec_buffer.data, 0); - crc32_calc = crc32_calc_buffer((const char *)dec_buffer.data + 4 , dec_buffer.length - 4); + crc32_calc = crc32_calc_buffer(dec_buffer.data + 4 , dec_buffer.length - 4); if (crc32_given != crc32_calc) { DEBUG(1,("CRC32: given[0x%08X] calc[0x%08X]\n", crc32_given, crc32_calc)); diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c index 08a49930b4..f0595695d2 100644 --- a/source3/libsmb/trusts_util.c +++ b/source3/libsmb/trusts_util.c @@ -20,104 +20,6 @@ #include "includes.h" -/********************************************************* - Change the domain password on the PDC. - - Just changes the password betwen the two values specified. - - Caller must have the cli connected to the netlogon pipe - already. -**********************************************************/ - -static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - const unsigned char orig_trust_passwd_hash[16], - const char *new_trust_pwd_cleartext, - const unsigned char new_trust_passwd_hash[16], - uint32 sec_channel_type) -{ - NTSTATUS result; - uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS; - - result = rpccli_netlogon_setup_creds(cli, - cli->desthost, /* server name */ - lp_workgroup(), /* domain */ - global_myname(), /* client name */ - global_myname(), /* machine account name */ - orig_trust_passwd_hash, - sec_channel_type, - &neg_flags); - - if (!NT_STATUS_IS_OK(result)) { - DEBUG(3,("just_change_the_password: unable to setup creds (%s)!\n", - nt_errstr(result))); - return result; - } - - if (neg_flags & NETLOGON_NEG_PASSWORD_SET2) { - - struct netr_Authenticator clnt_creds, srv_cred; - struct netr_CryptPassword new_password; - struct samr_CryptPassword password_buf; - - netlogon_creds_client_step(cli->dc, &clnt_creds); - - encode_pw_buffer(password_buf.data, new_trust_pwd_cleartext, STR_UNICODE); - - SamOEMhash(password_buf.data, cli->dc->sess_key, 516); - memcpy(new_password.data, password_buf.data, 512); - new_password.length = IVAL(password_buf.data, 512); - - result = rpccli_netr_ServerPasswordSet2(cli, mem_ctx, - cli->dc->remote_machine, - cli->dc->mach_acct, - sec_channel_type, - global_myname(), - &clnt_creds, - &srv_cred, - &new_password); - - /* Always check returned credentials. */ - if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) { - DEBUG(0,("rpccli_netr_ServerPasswordSet2: " - "credentials chain check failed\n")); - return NT_STATUS_ACCESS_DENIED; - } - - } else { - - struct netr_Authenticator clnt_creds, srv_cred; - struct samr_Password new_password; - - netlogon_creds_client_step(cli->dc, &clnt_creds); - - cred_hash3(new_password.hash, - new_trust_passwd_hash, - cli->dc->sess_key, 1); - - result = rpccli_netr_ServerPasswordSet(cli, mem_ctx, - cli->dc->remote_machine, - cli->dc->mach_acct, - sec_channel_type, - global_myname(), - &clnt_creds, - &srv_cred, - &new_password); - - /* Always check returned credentials. */ - if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) { - DEBUG(0,("rpccli_netr_ServerPasswordSet: " - "credentials chain check failed\n")); - return NT_STATUS_ACCESS_DENIED; - } - } - - if (!NT_STATUS_IS_OK(result)) { - DEBUG(0,("just_change_the_password: unable to change password (%s)!\n", - nt_errstr(result))); - } - return result; -} - /********************************************************* Change the domain password on the PDC. Store the password ourselves, but use the supplied password @@ -131,24 +33,23 @@ NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *m { unsigned char new_trust_passwd_hash[16]; char *new_trust_passwd; - char *str; NTSTATUS nt_status; /* Create a random machine account password */ - str = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); + new_trust_passwd = generate_random_str(mem_ctx, DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); - if ((new_trust_passwd = talloc_strdup(mem_ctx, str)) == NULL) { + if (new_trust_passwd == NULL) { DEBUG(0, ("talloc_strdup failed\n")); return NT_STATUS_NO_MEMORY; } E_md4hash(new_trust_passwd, new_trust_passwd_hash); - nt_status = just_change_the_password(cli, mem_ctx, - orig_trust_passwd_hash, - new_trust_passwd, - new_trust_passwd_hash, - sec_channel_type); + nt_status = rpccli_netlogon_set_trust_password(cli, mem_ctx, + orig_trust_passwd_hash, + new_trust_passwd, + new_trust_passwd_hash, + sec_channel_type); if (NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("%s : trust_pw_change_and_store_it: Changed password.\n", diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 368ab1687c..33717f1bb9 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -77,8 +77,8 @@ const char *lock_flav_name(enum brl_flavour lock_flav) bool is_locked(files_struct *fsp, uint32 smbpid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_type lock_type) { int strict_locking = lp_strict_locking(fsp->conn->params); @@ -144,8 +144,8 @@ bool is_locked(files_struct *fsp, NTSTATUS query_lock(files_struct *fsp, uint32 *psmbpid, - SMB_BIG_UINT *pcount, - SMB_BIG_UINT *poffset, + uint64_t *pcount, + uint64_t *poffset, enum brl_type *plock_type, enum brl_flavour lock_flav) { @@ -184,8 +184,8 @@ NTSTATUS query_lock(files_struct *fsp, struct byte_range_lock *do_lock(struct messaging_context *msg_ctx, files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_type lock_type, enum brl_flavour lock_flav, bool blocking_lock, @@ -251,8 +251,8 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx, NTSTATUS do_unlock(struct messaging_context *msg_ctx, files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_flavour lock_flav) { bool ok = False; @@ -304,8 +304,8 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx, NTSTATUS do_lock_cancel(files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT count, - SMB_BIG_UINT offset, + uint64_t count, + uint64_t offset, enum brl_flavour lock_flav) { bool ok = False; diff --git a/source3/locking/posix.c b/source3/locking/posix.c index 32e1ee9fbf..c036ee597c 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -79,7 +79,7 @@ static const char *posix_lock_type_name(int lock_type) ****************************************************************************/ static bool posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out, - SMB_BIG_UINT u_offset, SMB_BIG_UINT u_count) + uint64_t u_offset, uint64_t u_count) { SMB_OFF_T offset = (SMB_OFF_T)u_offset; SMB_OFF_T count = (SMB_OFF_T)u_count; @@ -132,9 +132,9 @@ static bool posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out, * ignore this lock. */ - if (u_offset & ~((SMB_BIG_UINT)max_positive_lock_offset)) { + if (u_offset & ~((uint64_t)max_positive_lock_offset)) { DEBUG(10,("posix_lock_in_range: (offset = %.0f) offset > %.0f and we cannot handle this. Ignoring lock.\n", - (double)u_offset, (double)((SMB_BIG_UINT)max_positive_lock_offset) )); + (double)u_offset, (double)((uint64_t)max_positive_lock_offset) )); return False; } @@ -142,7 +142,7 @@ static bool posix_lock_in_range(SMB_OFF_T *offset_out, SMB_OFF_T *count_out, * We must truncate the count to less than max_positive_lock_offset. */ - if (u_count & ~((SMB_BIG_UINT)max_positive_lock_offset)) { + if (u_count & ~((uint64_t)max_positive_lock_offset)) { count = max_positive_lock_offset; } @@ -271,8 +271,8 @@ static bool posix_fcntl_getlock(files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T ****************************************************************************/ bool is_posix_locked(files_struct *fsp, - SMB_BIG_UINT *pu_offset, - SMB_BIG_UINT *pu_count, + uint64_t *pu_offset, + uint64_t *pu_count, enum brl_type *plock_type, enum brl_flavour lock_flav) { @@ -302,8 +302,8 @@ bool is_posix_locked(files_struct *fsp, if (lock_flav == POSIX_LOCK) { /* Only POSIX lock queries need to know the details. */ - *pu_offset = (SMB_BIG_UINT)offset; - *pu_count = (SMB_BIG_UINT)count; + *pu_offset = (uint64_t)offset; + *pu_count = (uint64_t)count; *plock_type = (posix_lock_type == F_RDLCK) ? READ_LOCK : WRITE_LOCK; } return True; @@ -929,8 +929,8 @@ lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, ( ****************************************************************************/ bool set_posix_lock_windows_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, enum brl_type lock_type, const struct lock_context *lock_ctx, const struct lock_struct *plocks, @@ -1066,8 +1066,8 @@ bool set_posix_lock_windows_flavour(files_struct *fsp, ****************************************************************************/ bool release_posix_lock_windows_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, enum brl_type deleted_lock_type, const struct lock_context *lock_ctx, const struct lock_struct *plocks, @@ -1189,8 +1189,8 @@ bool release_posix_lock_windows_flavour(files_struct *fsp, ****************************************************************************/ bool set_posix_lock_posix_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, enum brl_type lock_type, int *errno_ret) { @@ -1229,8 +1229,8 @@ bool set_posix_lock_posix_flavour(files_struct *fsp, ****************************************************************************/ bool release_posix_lock_posix_flavour(files_struct *fsp, - SMB_BIG_UINT u_offset, - SMB_BIG_UINT u_count, + uint64_t u_offset, + uint64_t u_count, const struct lock_context *lock_ctx, const struct lock_struct *plocks, int num_locks) diff --git a/source3/m4/aclocal.m4 b/source3/m4/aclocal.m4 index 9a4213d976..aae729c825 100644 --- a/source3/m4/aclocal.m4 +++ b/source3/m4/aclocal.m4 @@ -886,4 +886,4 @@ int main(void) ]) ]) -m4_include(lib/replace/libreplace.m4) +m4_include(../lib/replace/libreplace.m4) diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4 index 7aa8c213e0..40a97d3674 100644 --- a/source3/m4/check_path.m4 +++ b/source3/m4/check_path.m4 @@ -18,6 +18,7 @@ AC_PREFIX_DEFAULT(/usr/local/samba) rootsbindir="\${SBINDIR}" lockdir="\${VARDIR}/locks" piddir="\${VARDIR}/locks" +ncalrpcdir="\${VARDIR}/ncalrpc" test "${mandir}" || mandir="\${prefix}/man" logfilebase="\${VARDIR}" privatedir="\${prefix}/private" @@ -46,6 +47,7 @@ AC_ARG_WITH(fhs, codepagedir="\${MODULESDIR}" statedir="\${VARDIR}/lib/samba" cachedir="\${VARDIR}/lib/samba" + ncalrpcdir="\${VARDIR}/ncalrpc" AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths]) ;; esac]) @@ -114,6 +116,22 @@ AC_ARG_WITH(piddir, ;; esac]) +################################################# +# set ncalrpc directory location +AC_ARG_WITH(ncalprcdir, +[AS_HELP_STRING([--with-ncalprcdir=DIR], [Where to put ncalrpc sockets ($ac_default_prefix/var/ncalrpc)])], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-ncalrpcdir called without argument - will use default]) + ;; + * ) + ncalrpcdir="$withval" + ;; + esac]) + ################################################# # set SWAT directory location AC_ARG_WITH(swatdir, @@ -227,6 +245,7 @@ AC_ARG_WITH(mandir, AC_SUBST(configdir) AC_SUBST(lockdir) AC_SUBST(piddir) +AC_SUBST(ncalrpcdir) AC_SUBST(logfilebase) AC_SUBST(ctdbdir) AC_SUBST(privatedir) diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 9e28db8b39..f411176590 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -44,10 +44,6 @@ typedef struct _SMB_ACL4_INT_T SMB_ACE4_INT_T *last; } SMB_ACL4_INT_T; -extern int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid); -extern NTSTATUS unpack_nt_owners(int snum, uid_t *puser, gid_t *pgrp, - uint32 security_info_sent, SEC_DESC *psd); - static SMB_ACL4_INT_T *get_validated_aclint(SMB4ACL_T *acl) { SMB_ACL4_INT_T *aclint = (SMB_ACL4_INT_T *)acl; @@ -225,7 +221,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *acl, /* in */ } for (aceint=aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) { - SEC_ACCESS mask; + uint32_t mask; DOM_SID sid; SMB_ACE4PROP_T *ace = &aceint->prop; @@ -260,7 +256,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *acl, /* in */ DEBUG(10, ("mapped %d to %s\n", ace->who.id, sid_string_dbg(&sid))); - init_sec_access(&mask, ace->aceMask); + mask = ace->aceMask; init_sec_ace(&nt_ace_list[good_aces++], &sid, ace->aceType, mask, ace->aceFlags & 0xf); @@ -518,7 +514,7 @@ static bool smbacl4_fill_ace4( smbacl4_vfs_params *params, uid_t ownerUID, gid_t ownerGID, - SEC_ACE *ace_nt, /* input */ + const SEC_ACE *ace_nt, /* input */ SMB_ACE4PROP_T *ace_v4 /* output */ ) { @@ -650,7 +646,7 @@ static int smbacl4_MergeIgnoreReject( static SMB4ACL_T *smbacl4_win2nfs4( const char *filename, - SEC_ACL *dacl, + const SEC_ACL *dacl, smbacl4_vfs_params *pparams, uid_t ownerUID, gid_t ownerGID @@ -694,7 +690,7 @@ static SMB4ACL_T *smbacl4_win2nfs4( NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp, uint32 security_info_sent, - SEC_DESC *psd, + const SEC_DESC *psd, set_nfs4acl_native_fn_t set_nfs4_native) { smbacl4_vfs_params params; diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c new file mode 100644 index 0000000000..241751c6a6 --- /dev/null +++ b/source3/modules/vfs_acl_xattr.c @@ -0,0 +1,361 @@ +/* + * Store Windows ACLs in xattrs. + * + * Copyright (C) Volker Lendecke, 2008 + * Copyright (C) Jeremy Allison, 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 . + */ + +/* NOTE: This is an experimental module, not yet finished. JRA. */ + +#include "includes.h" +#include "librpc/gen_ndr/xattr.h" +#include "librpc/gen_ndr/ndr_xattr.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +static NTSTATUS parse_acl_blob(const DATA_BLOB *pblob, + const struct timespec cts, + uint32 security_info, + struct security_descriptor **ppdesc) +{ + TALLOC_CTX *ctx = talloc_tos(); + struct xattr_NTACL xacl; + enum ndr_err_code ndr_err; + size_t sd_size; + struct timespec ts; + + ndr_err = ndr_pull_struct_blob(pblob, ctx, NULL, &xacl, + (ndr_pull_flags_fn_t)ndr_pull_xattr_NTACL); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(5, ("parse_acl_blob: ndr_pull_xattr_NTACL failed: %s\n", + ndr_errstr(ndr_err))); + return ndr_map_error2ntstatus(ndr_err);; + } + + if (xacl.version != 2) { + return NT_STATUS_REVISION_MISMATCH; + } + + /* + * Check that the ctime timestamp is ealier + * than the stored timestamp. + */ + + ts = nt_time_to_unix_timespec(&xacl.info.sd_ts->last_changed); + + if (timespec_compare(&cts, &ts) > 0) { + DEBUG(5, ("parse_acl_blob: stored ACL out of date.\n")); + return NT_STATUS_EA_CORRUPT_ERROR; + } + + *ppdesc = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, + (security_info & OWNER_SECURITY_INFORMATION) + ? xacl.info.sd_ts->sd->owner_sid : NULL, + (security_info & GROUP_SECURITY_INFORMATION) + ? xacl.info.sd_ts->sd->group_sid : NULL, + (security_info & SACL_SECURITY_INFORMATION) + ? xacl.info.sd_ts->sd->sacl : NULL, + (security_info & DACL_SECURITY_INFORMATION) + ? xacl.info.sd_ts->sd->dacl : NULL, + &sd_size); + + TALLOC_FREE(xacl.info.sd); + + return (*ppdesc != NULL) ? NT_STATUS_OK : NT_STATUS_NO_MEMORY; +} + +static NTSTATUS get_acl_blob(TALLOC_CTX *ctx, + vfs_handle_struct *handle, + files_struct *fsp, + const char *name, + DATA_BLOB *pblob) +{ + size_t size = 1024; + uint8_t *val = NULL; + uint8_t *tmp; + ssize_t sizeret; + int saved_errno = 0; + + ZERO_STRUCTP(pblob); + + again: + + tmp = TALLOC_REALLOC_ARRAY(ctx, val, uint8_t, size); + if (tmp == NULL) { + TALLOC_FREE(val); + return NT_STATUS_NO_MEMORY; + } + val = tmp; + + become_root(); + if (fsp && fsp->fh->fd != -1) { + sizeret = SMB_VFS_FGETXATTR(fsp, XATTR_NTACL_NAME, val, size); + } else { + sizeret = SMB_VFS_GETXATTR(handle->conn, name, + XATTR_NTACL_NAME, val, size); + } + if (sizeret == -1) { + saved_errno = errno; + } + unbecome_root(); + + /* Max ACL size is 65536 bytes. */ + if (sizeret == -1) { + errno = saved_errno; + if ((errno == ERANGE) && (size != 65536)) { + /* Too small, try again. */ + size = 65536; + goto again; + } + + /* Real error - exit here. */ + TALLOC_FREE(val); + return map_nt_error_from_unix(errno); + } + + pblob->data = val; + pblob->length = sizeret; + return NT_STATUS_OK; +} + +static NTSTATUS get_nt_acl_xattr_internal(vfs_handle_struct *handle, + files_struct *fsp, + const char *name, + uint32 security_info, + SEC_DESC **ppdesc) +{ + TALLOC_CTX *ctx = talloc_tos(); + DATA_BLOB blob; + SMB_STRUCT_STAT sbuf; + NTSTATUS status; + + if (fsp && name == NULL) { + name = fsp->fsp_name; + } + + DEBUG(10, ("get_nt_acl_xattr_internal: name=%s\n", name)); + + status = get_acl_blob(ctx, handle, fsp, name, &blob); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("get_acl_blob returned %s\n", nt_errstr(status))); + return status; + } + + if (fsp && fsp->fh->fd != -1) { + if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) { + return map_nt_error_from_unix(errno); + } + } else { + if (SMB_VFS_STAT(handle->conn, name, &sbuf) == -1) { + return map_nt_error_from_unix(errno); + } + } + + status = parse_acl_blob(&blob, get_ctimespec(&sbuf), + security_info, ppdesc); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("parse_acl_blob returned %s\n", + nt_errstr(status))); + return status; + } + + TALLOC_FREE(blob.data); + return status; +} + +static int mkdir_acl_xattr(vfs_handle_struct *handle, const char *path, mode_t mode) +{ + return SMB_VFS_NEXT_MKDIR(handle, path, mode); +} + +/********************************************************************* + * Currently this only works for existing files. Need to work on + * inheritance for new files. +*********************************************************************/ + +static int open_acl_xattr(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) +{ + uint32_t access_granted = 0; + SEC_DESC *pdesc = NULL; + NTSTATUS status = get_nt_acl_xattr_internal(handle, + NULL, + fname, + (OWNER_SECURITY_INFORMATION | + GROUP_SECURITY_INFORMATION | + DACL_SECURITY_INFORMATION), + &pdesc); + if (NT_STATUS_IS_OK(status)) { + /* See if we can access it. */ + if (!se_access_check(pdesc, + handle->conn->server_info->ptok, + fsp->access_mask, + &access_granted, + &status)) { + errno = map_errno_from_nt_status(status); + return -1; + } + } + + return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); +} + +static NTSTATUS fget_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp, + uint32 security_info, SEC_DESC **ppdesc) +{ + NTSTATUS status = get_nt_acl_xattr_internal(handle, fsp, + NULL, security_info, ppdesc); + if (NT_STATUS_IS_OK(status)) { + return NT_STATUS_OK; + } + return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, + security_info, ppdesc); +} + +static NTSTATUS get_nt_acl_xattr(vfs_handle_struct *handle, + const char *name, uint32 security_info, SEC_DESC **ppdesc) +{ + NTSTATUS status = get_nt_acl_xattr_internal(handle, NULL, + name, security_info, ppdesc); + if (NT_STATUS_IS_OK(status)) { + return NT_STATUS_OK; + } + return SMB_VFS_NEXT_GET_NT_ACL(handle, name, + security_info, ppdesc); +} + +static NTSTATUS create_acl_blob(const SEC_DESC *psd, DATA_BLOB *pblob) +{ + struct xattr_NTACL xacl; + struct security_descriptor_timestamp sd_ts; + enum ndr_err_code ndr_err; + TALLOC_CTX *ctx = talloc_tos(); + struct timespec curr = timespec_current(); + + ZERO_STRUCT(xacl); + ZERO_STRUCT(sd_ts); + + /* Horrid hack as setting an xattr changes the ctime + * on Linux. This gives a race of 1 second during + * which we would not see a POSIX ACL set. + */ + curr.tv_sec += 1; + + xacl.version = 2; + xacl.info.sd_ts = &sd_ts; + xacl.info.sd_ts->sd = CONST_DISCARD(SEC_DESC *, psd); + unix_timespec_to_nt_time(&xacl.info.sd_ts->last_changed, curr); + + ndr_err = ndr_push_struct_blob( + pblob, ctx, NULL, &xacl, + (ndr_push_flags_fn_t)ndr_push_xattr_NTACL); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(5, ("create_acl_blob: ndr_push_xattr_NTACL failed: %s\n", + ndr_errstr(ndr_err))); + return ndr_map_error2ntstatus(ndr_err);; + } + + return NT_STATUS_OK; +} + +static NTSTATUS store_acl_blob(files_struct *fsp, + DATA_BLOB *pblob) +{ + int ret; + int saved_errno = 0; + + DEBUG(10,("store_acl_blob: storing blob length %u on file %s\n", + (unsigned int)pblob->length, fsp->fsp_name)); + + become_root(); + if (fsp->fh->fd != -1) { + ret = SMB_VFS_FSETXATTR(fsp, XATTR_NTACL_NAME, + pblob->data, pblob->length, 0); + } else { + ret = SMB_VFS_SETXATTR(fsp->conn, fsp->fsp_name, + XATTR_NTACL_NAME, + pblob->data, pblob->length, 0); + } + if (ret) { + saved_errno = errno; + } + unbecome_root(); + if (ret) { + errno = saved_errno; + DEBUG(5, ("store_acl_blob: setting attr failed for file %s" + "with error %s\n", + fsp->fsp_name, + strerror(errno) )); + return map_nt_error_from_unix(errno); + } + return NT_STATUS_OK; +} + +static NTSTATUS fset_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp, + uint32 security_info_sent, const SEC_DESC *psd) +{ + NTSTATUS status; + DATA_BLOB blob; + + status = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if ((security_info_sent & DACL_SECURITY_INFORMATION) && + psd->dacl != NULL && + (psd->type & (SE_DESC_DACL_AUTO_INHERITED| + SE_DESC_DACL_AUTO_INHERIT_REQ))== + (SE_DESC_DACL_AUTO_INHERITED| + SE_DESC_DACL_AUTO_INHERIT_REQ) ) { + SEC_DESC *new_psd = NULL; + status = append_parent_acl(fsp, psd, &new_psd); + if (!NT_STATUS_IS_OK(status)) { + /* Lower level acl set succeeded, + * so still return OK. */ + return NT_STATUS_OK; + } + psd = new_psd; + } + + create_acl_blob(psd, &blob); + store_acl_blob(fsp, &blob); + + return NT_STATUS_OK; +} + +/* VFS operations structure */ + +static vfs_op_tuple skel_op_tuples[] = +{ + {SMB_VFS_OP(mkdir_acl_xattr), SMB_VFS_OP_MKDIR, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(open_acl_xattr), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT}, + + /* NT File ACL operations */ + + {SMB_VFS_OP(fget_nt_acl_xattr),SMB_VFS_OP_FGET_NT_ACL,SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(get_nt_acl_xattr), SMB_VFS_OP_GET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(fset_nt_acl_xattr),SMB_VFS_OP_FSET_NT_ACL,SMB_VFS_LAYER_TRANSPARENT}, + + {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +}; + +NTSTATUS vfs_acl_xattr_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "acl_xattr", skel_op_tuples); +} diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index 9409f3fa20..8c89d2fd9f 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -592,7 +592,6 @@ static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl, { SEC_ACE *nt_ace_list; DOM_SID owner_sid, group_sid; - SEC_ACCESS mask; SEC_ACL *psa = NULL; int good_aces; size_t sd_size; @@ -616,7 +615,7 @@ static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl, good_aces = 0; while (afs_ace != NULL) { - uint32 nt_rights; + uint32_t nt_rights; uint8 flag = SEC_ACE_FLAG_OBJECT_INHERIT | SEC_ACE_FLAG_CONTAINER_INHERIT; @@ -633,9 +632,8 @@ static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl, else nt_rights = afs_to_nt_file_rights(afs_ace->rights); - init_sec_access(&mask, nt_rights); init_sec_ace(&nt_ace_list[good_aces++], &(afs_ace->sid), - SEC_ACE_TYPE_ACCESS_ALLOWED, mask, flag); + SEC_ACE_TYPE_ACCESS_ALLOWED, nt_rights, flag); afs_ace = afs_ace->next; } @@ -717,12 +715,12 @@ static bool mappable_sid(const DOM_SID *sid) static bool nt_to_afs_acl(const char *filename, uint32 security_info_sent, - struct security_descriptor *psd, + const struct security_descriptor *psd, uint32 (*nt_to_afs_rights)(const char *filename, const SEC_ACE *ace), struct afs_acl *afs_acl) { - SEC_ACL *dacl; + const SEC_ACL *dacl; int i; /* Currently we *only* look at the dacl */ @@ -737,7 +735,7 @@ static bool nt_to_afs_acl(const char *filename, dacl = psd->dacl; for (i = 0; i < dacl->num_aces; i++) { - SEC_ACE *ace = &(dacl->aces[i]); + const SEC_ACE *ace = &(dacl->aces[i]); const char *dom_name, *name; enum lsa_SidType name_type; char *p; @@ -887,7 +885,7 @@ static void merge_unknown_aces(struct afs_acl *src, struct afs_acl *dst) static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, - struct security_descriptor *psd) + const struct security_descriptor *psd) { struct afs_acl old_afs_acl, new_afs_acl; struct afs_acl dir_acl, file_acl; @@ -1040,7 +1038,7 @@ static NTSTATUS afsacl_get_nt_acl(struct vfs_handle_struct *handle, NTSTATUS afsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, - SEC_DESC *psd) + const SEC_DESC *psd) { return afs_set_nt_acl(handle, fsp, security_info_sent, psd); } diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c index 23c4d88134..a078b9f9f6 100644 --- a/source3/modules/vfs_aixacl2.c +++ b/source3/modules/vfs_aixacl2.c @@ -371,7 +371,7 @@ static bool aixjfs2_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) return True; } -static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd) { acl_type_t acl_type_info; NTSTATUS result = NT_STATUS_ACCESS_DENIED; @@ -395,7 +395,7 @@ static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_inf return result; } -NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) +NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd) { return aixjfs2_set_nt_acl_common(fsp, security_info_sent, psd); } diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 79537367d6..6950ab2168 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -28,15 +28,15 @@ static char *capencode(TALLOC_CTX *ctx, const char *from); static char *capdecode(TALLOC_CTX *ctx, const char *from); -static SMB_BIG_UINT cap_disk_free(vfs_handle_struct *handle, const char *path, - bool small_query, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +static uint64_t cap_disk_free(vfs_handle_struct *handle, const char *path, + bool small_query, uint64_t *bsize, + uint64_t *dfree, uint64_t *dsize) { char *cappath = capencode(talloc_tos(), path); if (!cappath) { errno = ENOMEM; - return (SMB_BIG_UINT)-1; + return (uint64_t)-1; } return SMB_VFS_NEXT_DISK_FREE(handle, cappath, small_query, bsize, dfree, dsize); diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 381aa18561..275c2f53c4 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -40,10 +40,10 @@ static void vfswrap_disconnect(vfs_handle_struct *handle) /* Disk operations */ -static SMB_BIG_UINT vfswrap_disk_free(vfs_handle_struct *handle, const char *path, bool small_query, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +static uint64_t vfswrap_disk_free(vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize, + uint64_t *dfree, uint64_t *dsize) { - SMB_BIG_UINT result; + uint64_t result; result = sys_disk_free(handle->conn, path, small_query, bsize, dfree, dsize); return result; @@ -1036,7 +1036,7 @@ static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle, return result; } -static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd) { NTSTATUS result; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 1224ec3edb..6342c4a14e 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -74,10 +74,10 @@ struct vfs_full_audit_private_data { static int smb_full_audit_connect(vfs_handle_struct *handle, const char *svc, const char *user); static void smb_full_audit_disconnect(vfs_handle_struct *handle); -static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle, +static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle, const char *path, - bool small_query, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); + bool small_query, uint64_t *bsize, + uint64_t *dfree, uint64_t *dsize); static int smb_full_audit_get_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt); @@ -202,7 +202,7 @@ static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, SEC_DESC **ppdesc); static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, - SEC_DESC *psd); + const SEC_DESC *psd); static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode); static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, @@ -910,12 +910,12 @@ static void smb_full_audit_disconnect(vfs_handle_struct *handle) return; } -static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle, +static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle, const char *path, - bool small_query, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) + bool small_query, uint64_t *bsize, + uint64_t *dfree, uint64_t *dsize) { - SMB_BIG_UINT result; + uint64_t result; result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, dfree, dsize); @@ -1582,7 +1582,7 @@ static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, - SEC_DESC *psd) + const SEC_DESC *psd) { NTSTATUS result; diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 39d2bb6c38..fa0b4e97a5 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -179,7 +179,7 @@ static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl) "who: %d\n", gace->aceType, gace->aceIFlags, gace->aceFlags, gace->aceMask, gace->aceWho)); - memset(&smbace, 0, sizeof(SMB4ACE_T)); + ZERO_STRUCT(smbace); if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) { smbace.flags |= SMB_ACE4_ID_SPECIAL; switch (gace->aceWho) { @@ -365,7 +365,7 @@ static bool gpfsacl_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) return True; } -static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd) { struct gpfs_acl *acl; NTSTATUS result = NT_STATUS_ACCESS_DENIED; @@ -386,7 +386,7 @@ static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_i return result; } -static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd) { return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd); } @@ -739,7 +739,7 @@ static int gpfsacl_emu_chmod(const char *path, mode_t mode) if (haveAllowEntry[i]==True) continue; - memset(&ace, 0, sizeof(SMB_ACE4PROP_T)); + ZERO_STRUCT(ace); ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE; ace.flags |= SMB_ACE4_ID_SPECIAL; ace.who.special_id = i; @@ -761,7 +761,7 @@ static int gpfsacl_emu_chmod(const char *path, mode_t mode) } /* don't add complementary DENY ACEs here */ - memset(&fake_fsp, 0, sizeof(struct files_struct)); + ZERO_STRUCT(fake_fsp); fake_fsp.fsp_name = (char *)path; /* no file_new is needed here */ /* put the acl */ diff --git a/source3/modules/vfs_smb_traffic_analyzer.c b/source3/modules/vfs_smb_traffic_analyzer.c new file mode 100644 index 0000000000..9456afb811 --- /dev/null +++ b/source3/modules/vfs_smb_traffic_analyzer.c @@ -0,0 +1,427 @@ +/* + * traffic-analyzer VFS module. Measure the smb traffic users create + * on the net. + * + * Copyright (C) Holger Hetterich, 2008 + * Copyright (C) Jeremy Allison, 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 . + */ + +#include "includes.h" + +/* abstraction for the send_over_network function */ + +enum sock_type {INTERNET_SOCKET = 0, UNIX_DOMAIN_SOCKET}; + +#define LOCAL_PATHNAME "/var/tmp/stadsocket" + +static int vfs_smb_traffic_analyzer_debug_level = DBGC_VFS; + +static enum sock_type smb_traffic_analyzer_connMode(vfs_handle_struct *handle) +{ + connection_struct *conn = handle->conn; + const char *Mode; + Mode=lp_parm_const_string(SNUM(conn), "smb_traffic_analyzer","mode", \ + "internet_socket"); + if (strstr(Mode,"unix_domain_socket")) { + return UNIX_DOMAIN_SOCKET; + } else { + return INTERNET_SOCKET; + } +} + + +/* Connect to an internet socket */ + +static int smb_traffic_analyzer_connect_inet_socket(vfs_handle_struct *handle, + const char *name, uint16_t port) +{ + /* Create a streaming Socket */ + int sockfd = -1; + struct addrinfo hints; + struct addrinfo *ailist = NULL; + struct addrinfo *res = NULL; + int ret; + + ZERO_STRUCT(hints); + /* By default make sure it supports TCP. */ + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_ADDRCONFIG; + + ret = getaddrinfo(name, + NULL, + &hints, + &ailist); + + if (ret) { + DEBUG(3,("smb_traffic_analyzer_connect_inet_socket: " + "getaddrinfo failed for name %s [%s]\n", + name, + gai_strerror(ret) )); + return -1; + } + + DEBUG(3,("smb_traffic_analyzer: Internet socket mode. Hostname: %s," + "Port: %i\n", name, port)); + + for (res = ailist; res; res = res->ai_next) { + struct sockaddr_storage ss; + + if (!res->ai_addr || res->ai_addrlen == 0) { + continue; + } + + ZERO_STRUCT(ss); + memcpy(&ss, res->ai_addr, res->ai_addrlen); + + sockfd = open_socket_out(SOCK_STREAM, &ss, port, 10000); + if (sockfd != -1) { + break; + } + } + + if (ailist) { + freeaddrinfo(ailist); + } + + if (sockfd == -1) { + DEBUG(1, ("smb_traffic_analyzer: unable to create " + "socket, error is %s", + strerror(errno))); + return -1; + } + + return sockfd; +} + +/* Connect to a unix domain socket */ + +static int smb_traffic_analyzer_connect_unix_socket(vfs_handle_struct *handle, + const char *name) +{ + /* Create the socket to stad */ + int len, sock; + struct sockaddr_un remote; + + DEBUG(7, ("smb_traffic_analyzer_connect_unix_socket: " + "Unix domain socket mode. Using %s\n", + name )); + + if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { + DEBUG(1, ("smb_traffic_analyzer_connect_unix_socket: " + "Couldn't create socket, " + "make sure stad is running!\n")); + } + remote.sun_family = AF_UNIX; + strlcpy(remote.sun_path, name, + sizeof(remote.sun_path)); + len=strlen(remote.sun_path) + sizeof(remote.sun_family); + if (connect(sock, (struct sockaddr *)&remote, len) == -1 ) { + DEBUG(1, ("smb_traffic_analyzer_connect_unix_socket: " + "Could not connect to " + "socket, make sure\nstad is running!\n")); + close(sock); + return -1; + } + return sock; +} + +/* Private data allowing shared connection sockets. */ + +struct refcounted_sock { + struct refcounted_sock *next, *prev; + char *name; + uint16_t port; + int sock; + unsigned int ref_count; +}; + +/* Send data over a socket */ + +static void smb_traffic_analyzer_send_data(vfs_handle_struct *handle, + ssize_t result, + const char *file_name, + bool Write) +{ + struct refcounted_sock *rf_sock = NULL; + struct timeval tv; + time_t tv_sec; + struct tm *tm = NULL; + int seconds; + char *str = NULL; + char *username = NULL; + const char *anon_prefix = NULL; + size_t len; + + SMB_VFS_HANDLE_GET_DATA(handle, rf_sock, struct refcounted_sock, return); + + if (rf_sock == NULL || rf_sock->sock == -1) { + DEBUG(1, ("smb_traffic_analyzer_send_data: socket is " + "closed\n")); + return; + } + + GetTimeOfDay(&tv); + tv_sec = convert_timespec_to_time_t(convert_timeval_to_timespec(tv)); + tm = localtime(&tv_sec); + if (!tm) { + return; + } + seconds=(float) (tv.tv_usec / 1000); + + /* check if anonymization is required */ + + anon_prefix=lp_parm_const_string(SNUM(handle->conn),"smb_traffic_analyzer",\ + "anonymize_prefix", NULL ); + if (anon_prefix!=NULL) { + username = talloc_asprintf(talloc_tos(), + "%s%i", + anon_prefix, + str_checksum( + handle->conn->server_info->sanitized_username ) ); + } else { + username = handle->conn->server_info->sanitized_username; + } + + if (!username) { + return; + } + + str = talloc_asprintf(talloc_tos(), + "V1,%u,\"%s\",\"%s\",\"%c\",\"%s\",\"%s\"," + "\"%04d-%02d-%02d %02d:%02d:%02d.%03d\"\n", + (unsigned int)result, + username, + pdb_get_domain(handle->conn->server_info->sam_account), + Write ? 'W' : 'R', + handle->conn->connectpath, + file_name, + tm->tm_year+1900, + tm->tm_mon+1, + tm->tm_mday, + tm->tm_hour, + tm->tm_min, + tm->tm_sec, + (int)seconds); + + if (!str) { + return; + } + + len = strlen(str); + + DEBUG(10, ("smb_traffic_analyzer_send_data_socket: sending %s\n", + str)); + if (write_data(rf_sock->sock, str, len) != len) { + DEBUG(1, ("smb_traffic_analyzer_send_data_socket: " + "error sending data to socket!\n")); + return ; + } +} + +static struct refcounted_sock *sock_list; + +static void smb_traffic_analyzer_free_data(void **pptr) +{ + struct refcounted_sock *rf_sock = *(struct refcounted_sock **)pptr; + if (rf_sock == NULL) { + return; + } + rf_sock->ref_count--; + if (rf_sock->ref_count != 0) { + return; + } + if (rf_sock->sock != -1) { + close(rf_sock->sock); + } + DLIST_REMOVE(sock_list, rf_sock); + TALLOC_FREE(rf_sock); +} + +static int smb_traffic_analyzer_connect(struct vfs_handle_struct *handle, + const char *service, + const char *user) +{ + connection_struct *conn = handle->conn; + enum sock_type st = smb_traffic_analyzer_connMode(handle); + struct refcounted_sock *rf_sock = NULL; + const char *name = (st == UNIX_DOMAIN_SOCKET) ? LOCAL_PATHNAME : + lp_parm_const_string(SNUM(conn), + "smb_traffic_analyzer", + "host", "localhost"); + uint16_t port = (st == UNIX_DOMAIN_SOCKET) ? 0 : + atoi( lp_parm_const_string(SNUM(conn), + "smb_traffic_analyzer", "port", "9430")); + + /* Are we already connected ? */ + for (rf_sock = sock_list; rf_sock; rf_sock = rf_sock->next) { + if (port == rf_sock->port && + (strcmp(name, rf_sock->name) == 0)) { + break; + } + } + + /* If we're connected already, just increase the + * reference count. */ + if (rf_sock) { + rf_sock->ref_count++; + } else { + /* New connection. */ + rf_sock = TALLOC_ZERO_P(NULL, struct refcounted_sock); + if (rf_sock == NULL) { + errno = ENOMEM; + return -1; + } + rf_sock->name = talloc_strdup(rf_sock, name); + if (rf_sock->name == NULL) { + TALLOC_FREE(rf_sock); + errno = ENOMEM; + return -1; + } + rf_sock->port = port; + rf_sock->ref_count = 1; + + if (st == UNIX_DOMAIN_SOCKET) { + rf_sock->sock = smb_traffic_analyzer_connect_unix_socket(handle, + name); + } else { + + rf_sock->sock = smb_traffic_analyzer_connect_inet_socket(handle, + name, + port); + } + if (rf_sock->sock == -1) { + TALLOC_FREE(rf_sock); + return -1; + } + DLIST_ADD(sock_list, rf_sock); + } + + /* Store the private data. */ + SMB_VFS_HANDLE_SET_DATA(handle, rf_sock, smb_traffic_analyzer_free_data, + struct refcounted_sock, return -1); + return SMB_VFS_NEXT_CONNECT(handle, service, user); +} + +/* VFS Functions: write, read, pread, pwrite for now */ + +static ssize_t smb_traffic_analyzer_read(vfs_handle_struct *handle, \ + files_struct *fsp, void *data, size_t n) +{ + ssize_t result; + + result = SMB_VFS_NEXT_READ(handle, fsp, data, n); + DEBUG(10, ("smb_traffic_analyzer_read: READ: %s\n", fsp->fsp_name )); + + smb_traffic_analyzer_send_data(handle, + result, + fsp->fsp_name, + false); + return result; +} + + +static ssize_t smb_traffic_analyzer_pread(vfs_handle_struct *handle, \ + files_struct *fsp, void *data, size_t n, SMB_OFF_T offset) +{ + ssize_t result; + + result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); + + DEBUG(10, ("smb_traffic_analyzer_pread: PREAD: %s\n", fsp->fsp_name )); + + smb_traffic_analyzer_send_data(handle, + result, + fsp->fsp_name, + false); + + return result; +} + +static ssize_t smb_traffic_analyzer_write(vfs_handle_struct *handle, \ + files_struct *fsp, const void *data, size_t n) +{ + ssize_t result; + + result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n); + + DEBUG(10, ("smb_traffic_analyzer_write: WRITE: %s\n", fsp->fsp_name )); + + smb_traffic_analyzer_send_data(handle, + result, + fsp->fsp_name, + true); + return result; +} + +static ssize_t smb_traffic_analyzer_pwrite(vfs_handle_struct *handle, \ + files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset) +{ + ssize_t result; + + result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); + + DEBUG(10, ("smb_traffic_analyzer_pwrite: PWRITE: %s\n", fsp->fsp_name )); + + smb_traffic_analyzer_send_data(handle, + result, + fsp->fsp_name, + true); + return result; +} + +/* VFS operations we use */ + +static vfs_op_tuple smb_traffic_analyzer_tuples[] = { + + {SMB_VFS_OP(smb_traffic_analyzer_connect), SMB_VFS_OP_CONNECT, + SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_traffic_analyzer_read), SMB_VFS_OP_READ, + SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_traffic_analyzer_pread), SMB_VFS_OP_PREAD, + SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_traffic_analyzer_write), SMB_VFS_OP_WRITE, + SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_traffic_analyzer_pwrite), SMB_VFS_OP_PWRITE, + SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(NULL),SMB_VFS_OP_NOOP,SMB_VFS_LAYER_NOOP} +}; + +/* Module initialization */ + +NTSTATUS vfs_smb_traffic_analyzer_init(void) +{ + NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, \ + "smb_traffic_analyzer", smb_traffic_analyzer_tuples); + + if (!NT_STATUS_IS_OK(ret)) { + return ret; + } + + vfs_smb_traffic_analyzer_debug_level = + debug_add_class("smb_traffic_analyzer"); + + if (vfs_smb_traffic_analyzer_debug_level == -1) { + vfs_smb_traffic_analyzer_debug_level = DBGC_VFS; + DEBUG(1, ("smb_traffic_analyzer_init: Couldn't register custom" + "debugging class!\n")); + } else { + DEBUG(3, ("smb_traffic_analyzer_init: Debug class number of" + "'smb_traffic_analyzer': %d\n", \ + vfs_smb_traffic_analyzer_debug_level)); + } + + return ret; +} diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index 7b5e510747..8320a5820a 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -48,7 +48,7 @@ static NTSTATUS xattr_tdb_pull_attrs(TALLOC_CTX *mem_ctx, blob = data_blob_const(data->dptr, data->dsize); ndr_err = ndr_pull_struct_blob( - &blob, result, result, + &blob, result, NULL, result, (ndr_pull_flags_fn_t)ndr_pull_tdb_xattrs); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -74,7 +74,7 @@ static NTSTATUS xattr_tdb_push_attrs(TALLOC_CTX *mem_ctx, enum ndr_err_code ndr_err; ndr_err = ndr_push_struct_blob( - &blob, mem_ctx, attribs, + &blob, mem_ctx, NULL, attribs, (ndr_push_flags_fn_t)ndr_push_tdb_xattrs); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -177,25 +177,25 @@ static ssize_t xattr_tdb_getattr(struct db_context *db_ctx, return -1; } - for (i=0; inum_xattrs; i++) { - if (strcmp(attribs->xattrs[i].name, name) == 0) { + for (i=0; inum_eas; i++) { + if (strcmp(attribs->eas[i].name, name) == 0) { break; } } - if (i == attribs->num_xattrs) { + if (i == attribs->num_eas) { errno = ENOATTR; goto fail; } - if (attribs->xattrs[i].value.length > size) { + if (attribs->eas[i].value.length > size) { errno = ERANGE; goto fail; } - memcpy(value, attribs->xattrs[i].value.data, - attribs->xattrs[i].value.length); - result = attribs->xattrs[i].value.length; + memcpy(value, attribs->eas[i].value.data, + attribs->eas[i].value.length); + result = attribs->eas[i].value.length; fail: TALLOC_FREE(attribs); @@ -273,8 +273,8 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, return -1; } - for (i=0; inum_xattrs; i++) { - if (strcmp(attribs->xattrs[i].name, name) == 0) { + for (i=0; inum_eas; i++) { + if (strcmp(attribs->eas[i].name, name) == 0) { if (flags & XATTR_CREATE) { TALLOC_FREE(rec); errno = EEXIST; @@ -284,8 +284,8 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, } } - if (i == attribs->num_xattrs) { - struct tdb_xattr *tmp; + if (i == attribs->num_eas) { + struct xattr_EA *tmp; if (flags & XATTR_REPLACE) { TALLOC_FREE(rec); @@ -294,8 +294,8 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, } tmp = TALLOC_REALLOC_ARRAY( - attribs, attribs->xattrs, struct tdb_xattr, - attribs->num_xattrs + 1); + attribs, attribs->eas, struct xattr_EA, + attribs->num_eas+ 1); if (tmp == NULL) { DEBUG(0, ("TALLOC_REALLOC_ARRAY failed\n")); @@ -304,13 +304,13 @@ static int xattr_tdb_setattr(struct db_context *db_ctx, return -1; } - attribs->xattrs = tmp; - attribs->num_xattrs += 1; + attribs->eas = tmp; + attribs->num_eas += 1; } - attribs->xattrs[i].name = name; - attribs->xattrs[i].value.data = CONST_DISCARD(uint8 *, value); - attribs->xattrs[i].value.length = size; + attribs->eas[i].name = name; + attribs->eas[i].value.data = CONST_DISCARD(uint8 *, value); + attribs->eas[i].value.length = size; status = xattr_tdb_save_attrs(rec, attribs); @@ -386,15 +386,15 @@ static ssize_t xattr_tdb_listattr(struct db_context *db_ctx, } DEBUG(10, ("xattr_tdb_listattr: Found %d xattrs\n", - attribs->num_xattrs)); + attribs->num_eas)); - for (i=0; inum_xattrs; i++) { + for (i=0; inum_eas; i++) { size_t tmp; DEBUG(10, ("xattr_tdb_listattr: xattrs[i].name: %s\n", - attribs->xattrs[i].name)); + attribs->eas[i].name)); - tmp = strlen(attribs->xattrs[i].name); + tmp = strlen(attribs->eas[i].name); /* * Try to protect against overflow @@ -420,10 +420,10 @@ static ssize_t xattr_tdb_listattr(struct db_context *db_ctx, len = 0; - for (i=0; inum_xattrs; i++) { - strlcpy(list+len, attribs->xattrs[i].name, + for (i=0; inum_eas; i++) { + strlcpy(list+len, attribs->eas[i].name, size-len); - len += (strlen(attribs->xattrs[i].name) + 1); + len += (strlen(attribs->eas[i].name) + 1); } TALLOC_FREE(attribs); @@ -496,23 +496,23 @@ static int xattr_tdb_removeattr(struct db_context *db_ctx, return -1; } - for (i=0; inum_xattrs; i++) { - if (strcmp(attribs->xattrs[i].name, name) == 0) { + for (i=0; inum_eas; i++) { + if (strcmp(attribs->eas[i].name, name) == 0) { break; } } - if (i == attribs->num_xattrs) { + if (i == attribs->num_eas) { TALLOC_FREE(rec); errno = ENOATTR; return -1; } - attribs->xattrs[i] = - attribs->xattrs[attribs->num_xattrs-1]; - attribs->num_xattrs -= 1; + attribs->eas[i] = + attribs->eas[attribs->num_eas-1]; + attribs->num_eas -= 1; - if (attribs->num_xattrs == 0) { + if (attribs->num_eas == 0) { rec->delete_rec(rec); TALLOC_FREE(rec); return 0; diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index e933e47317..3688b2386e 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -166,7 +166,7 @@ static bool zfs_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl) */ static NTSTATUS zfs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, - struct security_descriptor *psd) + const struct security_descriptor *psd) { return smb_set_nt_acl_nfs4(fsp, security_info_sent, psd, zfs_process_smbacl); @@ -207,7 +207,7 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle, static NTSTATUS zfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, - SEC_DESC *psd) + const SEC_DESC *psd) { return zfs_set_nt_acl(handle, fsp, security_info_sent, psd); } diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index d9f2af4c10..28de212d69 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -332,7 +332,7 @@ static bool reload_nmbd_services(bool test) if ( lp_loaded() ) { const char *fname = lp_configfile(); - if (file_exist(fname,NULL) && !strcsequal(fname,get_dyn_CONFIGFILE())) { + if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; } @@ -905,7 +905,7 @@ static bool open_sockets(bool isdaemon, int port) } #endif - if (!directory_exist(lp_lockdir(), NULL)) { + if (!directory_exist(lp_lockdir())) { mkdir(lp_lockdir(), 0755); } diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index 474ae1ca18..9ee0709cb5 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -178,7 +178,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); break; } - case QUERYFORPDC: + case LOGON_PRIMARY_QUERY: { fstring mach_str, getdc_str; fstring source_name; @@ -253,7 +253,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); /* Construct reply. */ q = outbuf; - SSVAL(q, 0, QUERYFORPDC_R); + SSVAL(q, 0, NETLOGON_RESPONSE_FROM_PDC); q += 2; fstrcpy(reply_name,my_name); @@ -292,7 +292,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); DEBUG(5,("process_logon_packet: GETDC request from %s at IP %s, \ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", mach_str,inet_ntoa(p->ip), reply_name, lp_workgroup(), - QUERYFORPDC_R, (uint32)ntversion, (uint32)lmnttoken, + NETLOGON_RESPONSE_FROM_PDC, (uint32)ntversion, (uint32)lmnttoken, (uint32)lm20token )); dump_data(4, (uint8 *)outbuf, PTR_DIFF(q, outbuf)); @@ -309,7 +309,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", return; } - case SAMLOGON: + case LOGON_SAM_LOGON_REQUEST: { fstring getdc_str; @@ -351,7 +351,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", domainsidsize = IVAL(q, 0); q += 4; - DEBUG(5,("process_logon_packet: SAMLOGON sidsize %d, len = %d\n", domainsidsize, len)); + DEBUG(5,("process_logon_packet: LOGON_SAM_LOGON_REQUEST sidsize %d, len = %d\n", domainsidsize, len)); if (domainsidsize < (len - PTR_DIFF(q, buf)) && (domainsidsize != 0)) { q += domainsidsize; @@ -383,7 +383,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", lm20token = SVAL(q, 6); q += 8; - DEBUG(3,("process_logon_packet: SAMLOGON sidsize %d ntv %d\n", domainsidsize, ntversion)); + DEBUG(3,("process_logon_packet: LOGON_SAM_LOGON_REQUEST sidsize %d ntv %d\n", domainsidsize, ntversion)); /* * we respond regadless of whether the machine is in our password @@ -392,14 +392,14 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", */ pull_ucs2_fstring(ascuser, uniuser); pull_ucs2_fstring(asccomp, unicomp); - DEBUG(5,("process_logon_packet: SAMLOGON user %s\n", ascuser)); + DEBUG(5,("process_logon_packet: LOGON_SAM_LOGON_REQUEST user %s\n", ascuser)); fstrcpy(reply_name, "\\\\"); /* Here it wants \\LOGONSERVER. */ fstrcat(reply_name, my_name); - DEBUG(5,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n", + DEBUG(5,("process_logon_packet: LOGON_SAM_LOGON_REQUEST request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n", asccomp,inet_ntoa(p->ip), ascuser, reply_name, lp_workgroup(), - SAMLOGON_R ,lmnttoken)); + LOGON_SAM_LOGON_RESPONSE ,lmnttoken)); /* Construct reply. */ @@ -408,9 +408,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", /* never, at least for now */ if ((ntversion < 11) || (SEC_ADS != lp_security()) || (ROLE_DOMAIN_PDC != lp_server_role())) { if (SVAL(uniuser, 0) == 0) { - SSVAL(q, 0, SAMLOGON_UNK_R); /* user unknown */ + SSVAL(q, 0, LOGON_SAM_LOGON_USER_UNKNOWN); /* user unknown */ } else { - SSVAL(q, 0, SAMLOGON_R); + SSVAL(q, 0, LOGON_SAM_LOGON_RESPONSE); } q += 2; @@ -442,7 +442,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", ("get_mydnsdomname failed.\n")); return; } - hostname = get_myname(talloc_tos()); + hostname = talloc_get_myname(talloc_tos()); if (!hostname) { DEBUG(2, ("get_myname failed.\n")); @@ -453,9 +453,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", return; } if (SVAL(uniuser, 0) == 0) { - SIVAL(q, 0, SAMLOGON_AD_UNK_R); /* user unknown */ + SIVAL(q, 0, LOGON_SAM_LOGON_USER_UNKNOWN_EX); /* user unknown */ } else { - SIVAL(q, 0, SAMLOGON_AD_R); + SIVAL(q, 0, LOGON_SAM_LOGON_RESPONSE_EX); } q += 4; @@ -684,8 +684,8 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", /* Announce change to UAS or SAM. Send by the domain controller when a replication event is required. */ - case SAM_UAS_CHANGE: - DEBUG(5, ("Got SAM_UAS_CHANGE\n")); + case NETLOGON_ANNOUNCE_UAS: + DEBUG(5, ("Got NETLOGON_ANNOUNCE_UAS\n")); break; default: diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c index 96938b011a..5ee6e83138 100644 --- a/source3/nmbd/nmbd_winsserver.c +++ b/source3/nmbd/nmbd_winsserver.c @@ -124,7 +124,7 @@ static struct name_record *wins_record_to_name_record(TDB_DATA key, TDB_DATA dat namerec->data.refresh_time = (time_t)refresh_time; namerec->data.id = id_low; #if defined(HAVE_LONGLONG) - namerec->data.id |= ((SMB_BIG_UINT)id_high << 32); + namerec->data.id |= ((uint64_t)id_high << 32); #endif namerec->data.wins_ip.s_addr = saddr; namerec->data.wins_flags = wins_flags, @@ -412,14 +412,14 @@ static void update_wins_flag(struct name_record *namerec, int flags) Return the general ID value and increase it if requested. *****************************************************************************/ -static void get_global_id_and_update(SMB_BIG_UINT *current_id, bool update) +static void get_global_id_and_update(uint64_t *current_id, bool update) { /* * it's kept as a static here, to prevent people from messing * with the value directly */ - static SMB_BIG_UINT general_id = 1; + static uint64_t general_id = 1; DEBUG(5,("get_global_id_and_update: updating version ID: %d\n", (int)general_id)); diff --git a/source3/nsswitch/libwbclient/wbc_guid.c b/source3/nsswitch/libwbclient/wbc_guid.c new file mode 100644 index 0000000000..0cb33e9868 --- /dev/null +++ b/source3/nsswitch/libwbclient/wbc_guid.c @@ -0,0 +1,118 @@ +/* + Unix SMB/CIFS implementation. + + Winbind client API + + Copyright (C) Gerald (Jerry) Carter 2007 + + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +/* Required Headers */ + +#include "libwbclient.h" + +/** @brief Convert a binary GUID to a character string + * + * @param guid Binary Guid + * @param **guid_string Resulting character string + * + * @return #wbcErr + **/ + +wbcErr wbcGuidToString(const struct wbcGuid *guid, + char **guid_string) +{ + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + + if (!guid) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + *guid_string = talloc_asprintf(NULL, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid->time_low, guid->time_mid, + guid->time_hi_and_version, + guid->clock_seq[0], + guid->clock_seq[1], + guid->node[0], guid->node[1], + guid->node[2], guid->node[3], + guid->node[4], guid->node[5]); + BAIL_ON_PTR_ERROR((*guid_string), wbc_status); + + wbc_status = WBC_ERR_SUCCESS; + +done: + return wbc_status; +} + +/** @brief Convert a character string to a binary GUID + * + * @param *str Character string + * @param guid Resulting binary GUID + * + * @return #wbcErr + **/ + +wbcErr wbcStringToGuid(const char *str, + struct wbcGuid *guid) +{ + uint32_t time_low; + uint32_t time_mid, time_hi_and_version; + uint32_t clock_seq[2]; + uint32_t node[6]; + int i; + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + + if (!guid) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (!str) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (11 == sscanf(str, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + &time_low, &time_mid, &time_hi_and_version, + &clock_seq[0], &clock_seq[1], + &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { + wbc_status = WBC_ERR_SUCCESS; + } else if (11 == sscanf(str, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + &time_low, &time_mid, &time_hi_and_version, + &clock_seq[0], &clock_seq[1], + &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { + wbc_status = WBC_ERR_SUCCESS; + } + + BAIL_ON_WBC_ERROR(wbc_status); + + guid->time_low = time_low; + guid->time_mid = time_mid; + guid->time_hi_and_version = time_hi_and_version; + guid->clock_seq[0] = clock_seq[0]; + guid->clock_seq[1] = clock_seq[1]; + + for (i=0;i<6;i++) { + guid->node[i] = node[i]; + } + + wbc_status = WBC_ERR_SUCCESS; + +done: + return wbc_status; +} diff --git a/source3/nsswitch/libwbclient/wbc_idmap.c b/source3/nsswitch/libwbclient/wbc_idmap.c index e32d66cd71..1615fd33ee 100644 --- a/source3/nsswitch/libwbclient/wbc_idmap.c +++ b/source3/nsswitch/libwbclient/wbc_idmap.c @@ -394,7 +394,7 @@ wbcErr wbcSetUidHwm(uid_t uid_hwm) /** @brief Set the highwater mark for allocated gids. * - * @param uid_hwm The new gid highwater mark value + * @param gid_hwm The new gid highwater mark value * * @return #wbcErr **/ diff --git a/source3/nsswitch/libwbclient/wbc_pam.c b/source3/nsswitch/libwbclient/wbc_pam.c index 20b42b6efb..713ba2e65b 100644 --- a/source3/nsswitch/libwbclient/wbc_pam.c +++ b/source3/nsswitch/libwbclient/wbc_pam.c @@ -4,6 +4,7 @@ Winbind client API Copyright (C) Gerald (Jerry) Carter 2007 + Copyright (C) Guenther Deschner 2008 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -260,6 +261,50 @@ done: return wbc_status; } +static wbcErr wbc_create_logon_info(TALLOC_CTX *mem_ctx, + const struct winbindd_response *resp, + struct wbcLogonUserInfo **_i) +{ + wbcErr wbc_status = WBC_ERR_SUCCESS; + struct wbcLogonUserInfo *i; + + i = talloc_zero(mem_ctx, struct wbcLogonUserInfo); + BAIL_ON_PTR_ERROR(i, wbc_status); + + wbc_status = wbc_create_auth_info(i, resp, &i->info); + BAIL_ON_WBC_ERROR(wbc_status); + + if (resp->data.auth.krb5ccname) { + wbc_status = wbcAddNamedBlob(&i->num_blobs, + &i->blobs, + "krb5ccname", + 0, + (uint8_t *)resp->data.auth.krb5ccname, + strlen(resp->data.auth.krb5ccname)+1); + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (resp->data.auth.unix_username) { + wbc_status = wbcAddNamedBlob(&i->num_blobs, + &i->blobs, + "unix_username", + 0, + (uint8_t *)resp->data.auth.unix_username, + strlen(resp->data.auth.unix_username)+1); + BAIL_ON_WBC_ERROR(wbc_status); + } + + *_i = i; + i = NULL; +done: + if (!WBC_ERROR_IS_OK(wbc_status) && i) { + wbcFreeMemory(i->blobs); + } + + talloc_free(i); + return wbc_status; +} + /** @brief Authenticate with more detailed information * * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH @@ -331,6 +376,7 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, params->account_name, sizeof(request.data.auth.user)-1); } + strncpy(request.data.auth.pass, params->password.plaintext, sizeof(request.data.auth.pass)-1); @@ -416,6 +462,10 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, BAIL_ON_WBC_ERROR(wbc_status); } + if (params->flags) { + request.flags |= params->flags; + } + wbc_status = wbcRequestResponse(cmd, &request, &response); @@ -497,6 +547,101 @@ wbcErr wbcCheckTrustCredentials(const char *domain, return wbc_status; } +/** @brief Trigger an extended logoff notification to Winbind for a specific user + * + * @param params A wbcLogoffUserParams structure + * @param error User output details on error + * + * @return #wbcErr + * + **/ + +wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, + struct wbcAuthErrorInfo **error) +{ + struct winbindd_request request; + struct winbindd_response response; + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + int i; + + /* validate input */ + + if (!params || !params->username) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if ((params->num_blobs > 0) && (params->blobs == NULL)) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + if ((params->num_blobs == 0) && (params->blobs != NULL)) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + strncpy(request.data.logoff.user, params->username, + sizeof(request.data.logoff.user)-1); + + for (i=0; inum_blobs; i++) { + + if (strcasecmp(params->blobs[i].name, "ccfilename") == 0) { + if (params->blobs[i].blob.data) { + strncpy(request.data.logoff.krb5ccname, + (const char *)params->blobs[i].blob.data, + sizeof(request.data.logoff.krb5ccname) - 1); + } + continue; + } + + if (strcasecmp(params->blobs[i].name, "user_uid") == 0) { + if (params->blobs[i].blob.data) { + memcpy(&request.data.logoff.uid, + params->blobs[i].blob.data, + MIN(params->blobs[i].blob.length, + sizeof(request.data.logoff.uid))); + } + continue; + } + + if (strcasecmp(params->blobs[i].name, "flags") == 0) { + if (params->blobs[i].blob.data) { + memcpy(&request.flags, + params->blobs[i].blob.data, + MIN(params->blobs[i].blob.length, + sizeof(request.flags))); + } + continue; + } + } + + /* Send request */ + + wbc_status = wbcRequestResponse(WINBINDD_PAM_LOGOFF, + &request, + &response); + + /* Take the response above and return it to the caller */ + if (response.data.auth.nt_status != 0) { + if (error) { + wbc_status = wbc_create_error_info(NULL, + &response, + error); + BAIL_ON_WBC_ERROR(wbc_status); + } + + wbc_status = WBC_ERR_AUTH_ERROR; + BAIL_ON_WBC_ERROR(wbc_status); + } + BAIL_ON_WBC_ERROR(wbc_status); + + done: + return wbc_status; +} + /** @brief Trigger a logoff notification to Winbind for a specific user * * @param username Name of user to remove from Winbind's list of @@ -794,3 +939,159 @@ wbcErr wbcChangeUserPassword(const char *username, done: return wbc_status; } + +/** @brief Logon a User + * + * @param[in] params Pointer to a wbcLogonUserParams structure + * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure + * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure + * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure + * + * @return #wbcErr + * + **/ + +wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, + struct wbcLogonUserInfo **info, + struct wbcAuthErrorInfo **error, + struct wbcUserPasswordPolicyInfo **policy) +{ + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + int cmd = 0; + struct winbindd_request request; + struct winbindd_response response; + uint32_t i; + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + if (info) { + *info = NULL; + } + if (error) { + *error = NULL; + } + if (policy) { + *policy = NULL; + } + + if (!params) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (!params->username) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + if ((params->num_blobs > 0) && (params->blobs == NULL)) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + if ((params->num_blobs == 0) && (params->blobs != NULL)) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + /* Initialize request */ + + cmd = WINBINDD_PAM_AUTH; + request.flags = WBFLAG_PAM_INFO3_TEXT | + WBFLAG_PAM_USER_SESSION_KEY | + WBFLAG_PAM_LMKEY; + + if (!params->password) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + strncpy(request.data.auth.user, + params->username, + sizeof(request.data.auth.user)-1); + + strncpy(request.data.auth.pass, + params->password, + sizeof(request.data.auth.pass)-1); + + for (i=0; inum_blobs; i++) { + + if (strcasecmp(params->blobs[i].name, "krb5_cc_type") == 0) { + if (params->blobs[i].blob.data) { + strncpy(request.data.auth.krb5_cc_type, + (const char *)params->blobs[i].blob.data, + sizeof(request.data.auth.krb5_cc_type) - 1); + } + continue; + } + + if (strcasecmp(params->blobs[i].name, "user_uid") == 0) { + if (params->blobs[i].blob.data) { + memcpy(&request.data.auth.uid, + params->blobs[i].blob.data, + MIN(sizeof(request.data.auth.uid), + params->blobs[i].blob.length)); + } + continue; + } + + if (strcasecmp(params->blobs[i].name, "flags") == 0) { + if (params->blobs[i].blob.data) { + uint32_t flags; + memcpy(&flags, + params->blobs[i].blob.data, + MIN(sizeof(flags), + params->blobs[i].blob.length)); + request.flags |= flags; + } + continue; + } + + if (strcasecmp(params->blobs[i].name, "membership_of") == 0) { + if (params->blobs[i].blob.data && + params->blobs[i].blob.data[0] > 0) { + strncpy(request.data.auth.require_membership_of_sid, + (const char *)params->blobs[i].blob.data, + sizeof(request.data.auth.require_membership_of_sid) - 1); + } + continue; + } + } + + wbc_status = wbcRequestResponse(cmd, + &request, + &response); + + if (response.data.auth.nt_status != 0) { + if (error) { + wbc_status = wbc_create_error_info(NULL, + &response, + error); + BAIL_ON_WBC_ERROR(wbc_status); + } + + wbc_status = WBC_ERR_AUTH_ERROR; + BAIL_ON_WBC_ERROR(wbc_status); + } + BAIL_ON_WBC_ERROR(wbc_status); + + if (info) { + wbc_status = wbc_create_logon_info(NULL, + &response, + info); + BAIL_ON_WBC_ERROR(wbc_status); + } + + if (policy) { + wbc_status = wbc_create_password_policy_info(NULL, + &response, + policy); + BAIL_ON_WBC_ERROR(wbc_status); + } + +done: + if (response.extra_data.data) + free(response.extra_data.data); + + return wbc_status; +} diff --git a/source3/nsswitch/libwbclient/wbc_pwd.c b/source3/nsswitch/libwbclient/wbc_pwd.c index b5f167369c..0d17b312ef 100644 --- a/source3/nsswitch/libwbclient/wbc_pwd.c +++ b/source3/nsswitch/libwbclient/wbc_pwd.c @@ -380,7 +380,7 @@ wbcErr wbcGetgrent(struct group **grp) * * @param *account The given user name * @param *num_groups Number of elements returned in the groups array - * @param **groups Pointer to resulting gid_t array. + * @param **_groups Pointer to resulting gid_t array. * * @return #wbcErr **/ diff --git a/source3/nsswitch/libwbclient/wbc_sid.c b/source3/nsswitch/libwbclient/wbc_sid.c index f4ffa4e5ca..4cfdd792b5 100644 --- a/source3/nsswitch/libwbclient/wbc_sid.c +++ b/source3/nsswitch/libwbclient/wbc_sid.c @@ -223,9 +223,9 @@ wbcErr wbcLookupName(const char *domain, /** @brief Convert a SID to a domain and name * * @param *sid Pointer to the domain SID to be resolved - * @param domain Resolved Domain name (possibly "") - * @param name Resolved User or group name - * @param *name_type Pointet to the resolved SID type + * @param pdomain Resolved Domain name (possibly "") + * @param pname Resolved User or group name + * @param *pname_type Pointet to the resolved SID type * * @return #wbcErr * diff --git a/source3/nsswitch/libwbclient/wbc_util.c b/source3/nsswitch/libwbclient/wbc_util.c index 24568f9101..b4868748ae 100644 --- a/source3/nsswitch/libwbclient/wbc_util.c +++ b/source3/nsswitch/libwbclient/wbc_util.c @@ -496,7 +496,7 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains) /** @brief Enumerate the domain trusts known by Winbind * * @param domain Name of the domain to query for a DC - * @flags Bit flags used to control the domain location query + * @param flags Bit flags used to control the domain location query * @param *dc_info Pointer to the returned domain controller information * * @return #wbcErr @@ -550,3 +550,187 @@ done: return wbc_status; } + +static wbcErr wbc_create_domain_controller_info_ex(TALLOC_CTX *mem_ctx, + const struct winbindd_response *resp, + struct wbcDomainControllerInfoEx **_i) +{ + wbcErr wbc_status = WBC_ERR_SUCCESS; + struct wbcDomainControllerInfoEx *i; + struct wbcGuid guid; + + i = talloc(mem_ctx, struct wbcDomainControllerInfoEx); + BAIL_ON_PTR_ERROR(i, wbc_status); + + i->dc_unc = talloc_strdup(i, resp->data.dsgetdcname.dc_unc); + BAIL_ON_PTR_ERROR(i->dc_unc, wbc_status); + + i->dc_address = talloc_strdup(i, resp->data.dsgetdcname.dc_address); + BAIL_ON_PTR_ERROR(i->dc_address, wbc_status); + + i->dc_address_type = resp->data.dsgetdcname.dc_address_type; + + wbc_status = wbcStringToGuid(resp->data.dsgetdcname.domain_guid, &guid); + if (WBC_ERROR_IS_OK(wbc_status)) { + i->domain_guid = talloc(i, struct wbcGuid); + BAIL_ON_PTR_ERROR(i->domain_guid, wbc_status); + + *i->domain_guid = guid; + } else { + i->domain_guid = NULL; + } + + i->domain_name = talloc_strdup(i, resp->data.dsgetdcname.domain_name); + BAIL_ON_PTR_ERROR(i->domain_name, wbc_status); + + if (resp->data.dsgetdcname.forest_name[0] != '\0') { + i->forest_name = talloc_strdup(i, + resp->data.dsgetdcname.forest_name); + BAIL_ON_PTR_ERROR(i->forest_name, wbc_status); + } else { + i->forest_name = NULL; + } + + i->dc_flags = resp->data.dsgetdcname.dc_flags; + + if (resp->data.dsgetdcname.dc_site_name[0] != '\0') { + i->dc_site_name = talloc_strdup(i, + resp->data.dsgetdcname.dc_site_name); + BAIL_ON_PTR_ERROR(i->dc_site_name, wbc_status); + } else { + i->dc_site_name = NULL; + } + + if (resp->data.dsgetdcname.client_site_name[0] != '\0') { + i->client_site_name = talloc_strdup(i, + resp->data.dsgetdcname.client_site_name); + BAIL_ON_PTR_ERROR(i->client_site_name, wbc_status); + } else { + i->client_site_name = NULL; + } + + *_i = i; + i = NULL; + +done: + talloc_free(i); + return wbc_status; +} + +/** @brief Get extended domain controller information + * + * @param domain Name of the domain to query for a DC + * @param guid Guid of the domain to query for a DC + * @param site Site of the domain to query for a DC + * @param flags Bit flags used to control the domain location query + * @param *dc_info Pointer to the returned extended domain controller information + * + * @return #wbcErr + * + **/ + +wbcErr wbcLookupDomainControllerEx(const char *domain, + struct wbcGuid *guid, + const char *site, + uint32_t flags, + struct wbcDomainControllerInfoEx **dc_info) +{ + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + struct winbindd_request request; + struct winbindd_response response; + + /* validate input params */ + + if (!domain || !dc_info) { + wbc_status = WBC_ERR_INVALID_PARAM; + BAIL_ON_WBC_ERROR(wbc_status); + } + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + request.data.dsgetdcname.flags = flags; + + strncpy(request.data.dsgetdcname.domain_name, domain, + sizeof(request.data.dsgetdcname.domain_name)-1); + + if (site) { + strncpy(request.data.dsgetdcname.site_name, site, + sizeof(request.data.dsgetdcname.site_name)-1); + } + + if (guid) { + char *str = NULL; + + wbc_status = wbcGuidToString(guid, &str); + BAIL_ON_WBC_ERROR(wbc_status); + + strncpy(request.data.dsgetdcname.domain_guid, str, + sizeof(request.data.dsgetdcname.domain_guid)-1); + + wbcFreeMemory(str); + } + + /* Send request */ + + wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME, + &request, + &response); + BAIL_ON_WBC_ERROR(wbc_status); + + if (dc_info) { + wbc_status = wbc_create_domain_controller_info_ex(NULL, + &response, + dc_info); + BAIL_ON_WBC_ERROR(wbc_status); + } + + wbc_status = WBC_ERR_SUCCESS; +done: + return wbc_status; +} + +/** @brief Initialize a named blob and add to list of blobs + * + * @param[in,out] num_blobs Pointer to the number of blobs + * @param[in,out] blobs Pointer to an array of blobs + * @param[in] name Name of the new named blob + * @param[in] flags Flags of the new named blob + * @param[in] data Blob data of new blob + * @param[in] length Blob data length of new blob + * + * @return #wbcErr + * + **/ + +wbcErr wbcAddNamedBlob(size_t *num_blobs, + struct wbcNamedBlob **blobs, + const char *name, + uint32_t flags, + uint8_t *data, + size_t length) +{ + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + struct wbcNamedBlob blob; + + *blobs = talloc_realloc(NULL, *blobs, struct wbcNamedBlob, + *(num_blobs)+1); + BAIL_ON_PTR_ERROR(*blobs, wbc_status); + + blob.name = talloc_strdup(*blobs, name); + BAIL_ON_PTR_ERROR(blob.name, wbc_status); + blob.flags = flags; + blob.blob.length = length; + blob.blob.data = (uint8_t *)talloc_memdup(*blobs, data, length); + BAIL_ON_PTR_ERROR(blob.blob.data, wbc_status); + + (*(blobs))[*num_blobs] = blob; + *(num_blobs) += 1; + + wbc_status = WBC_ERR_SUCCESS; +done: + if (!WBC_ERROR_IS_OK(wbc_status) && blobs) { + wbcFreeMemory(*blobs); + } + return wbc_status; +} diff --git a/source3/nsswitch/libwbclient/wbclient.h b/source3/nsswitch/libwbclient/wbclient.h index cae3feec5b..00a3c98966 100644 --- a/source3/nsswitch/libwbclient/wbclient.h +++ b/source3/nsswitch/libwbclient/wbclient.h @@ -136,6 +136,19 @@ struct wbcSidWithAttr { #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000 +/** + * @brief Windows GUID + * + **/ + +struct wbcGuid { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint8_t clock_seq[2]; + uint8_t node[6]; +}; + /** * @brief Domain Information **/ @@ -205,6 +218,36 @@ struct wbcAuthUserParams { } password; }; +/** + * @brief Generic Blob + **/ + +struct wbcBlob { + uint8_t *data; + size_t length; +}; + +/** + * @brief Named Blob + **/ + +struct wbcNamedBlob { + const char *name; + uint32_t flags; + struct wbcBlob blob; +}; + +/** + * @brief Logon User Parameters + **/ + +struct wbcLogonUserParams { + const char *username; + const char *password; + size_t num_blobs; + struct wbcNamedBlob *blobs; +}; + /** * @brief ChangePassword Parameters **/ @@ -297,6 +340,18 @@ struct wbcAuthUserInfo { struct wbcSidWithAttr *sids; }; +/** + * @brief Logon User Information + * + * Some of the strings are maybe NULL + **/ + +struct wbcLogonUserInfo { + struct wbcAuthUserInfo *info; + size_t num_blobs; + struct wbcNamedBlob *blobs; +}; + /* wbcAuthUserInfo->user_flags */ #define WBC_AUTH_USER_INFO_GUEST 0x00000001 @@ -372,6 +427,16 @@ enum wbcPasswordChangeRejectReason { WBC_PWD_CHANGE_REJECT_COMPLEXITY=5 }; +/** + * @brief Logoff User Parameters + **/ + +struct wbcLogoffUserParams { + const char *username; + size_t num_blobs; + struct wbcNamedBlob *blobs; +}; + /* * DomainControllerInfo struct */ @@ -379,7 +444,20 @@ struct wbcDomainControllerInfo { char *dc_name; }; - +/* + * DomainControllerInfoEx struct + */ +struct wbcDomainControllerInfoEx { + const char *dc_unc; + const char *dc_address; + uint16_t dc_address_type; + struct wbcGuid *domain_guid; + const char *domain_name; + const char *forest_name; + uint32_t dc_flags; + const char *dc_site_name; + const char *client_site_name; +}; /* * Memory Management @@ -398,6 +476,16 @@ wbcErr wbcSidToString(const struct wbcDomainSid *sid, wbcErr wbcStringToSid(const char *sid_string, struct wbcDomainSid *sid); +/* + * Utility functions for dealing with GUIDs + */ + +wbcErr wbcGuidToString(const struct wbcGuid *guid, + char **guid_string); + +wbcErr wbcStringToGuid(const char *guid_string, + struct wbcGuid *guid); + wbcErr wbcPing(void); wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details); @@ -531,6 +619,12 @@ wbcErr wbcLookupDomainController(const char *domain, uint32_t flags, struct wbcDomainControllerInfo **dc_info); +wbcErr wbcLookupDomainControllerEx(const char *domain, + struct wbcGuid *guid, + const char *site, + uint32_t flags, + struct wbcDomainControllerInfoEx **dc_info); + /* * Athenticate functions */ @@ -542,10 +636,18 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params, struct wbcAuthUserInfo **info, struct wbcAuthErrorInfo **error); +wbcErr wbcLogonUser(const struct wbcLogonUserParams *params, + struct wbcLogonUserInfo **info, + struct wbcAuthErrorInfo **error, + struct wbcUserPasswordPolicyInfo **policy); + wbcErr wbcLogoffUser(const char *username, uid_t uid, const char *ccfilename); +wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params, + struct wbcAuthErrorInfo **error); + wbcErr wbcChangeUserPassword(const char *username, const char *old_password, const char *new_password); @@ -566,6 +668,14 @@ wbcErr wbcResolveWinsByIP(const char *ip, char **name); */ wbcErr wbcCheckTrustCredentials(const char *domain, struct wbcAuthErrorInfo **error); - +/* + * Helper functions + */ +wbcErr wbcAddNamedBlob(size_t *num_blobs, + struct wbcNamedBlob **blobs, + const char *name, + uint32_t flags, + uint8_t *data, + size_t length); #endif /* _WBCLIENT_H */ diff --git a/source3/nsswitch/pam_winbind.c b/source3/nsswitch/pam_winbind.c index c28c5d2697..8d8868d0ef 100644 --- a/source3/nsswitch/pam_winbind.c +++ b/source3/nsswitch/pam_winbind.c @@ -12,6 +12,42 @@ #include "pam_winbind.h" +static int wbc_error_to_pam_error(wbcErr status) +{ + switch (status) { + case WBC_ERR_SUCCESS: + return PAM_SUCCESS; + case WBC_ERR_NOT_IMPLEMENTED: + return PAM_SERVICE_ERR; + case WBC_ERR_UNKNOWN_FAILURE: + break; + case WBC_ERR_NO_MEMORY: + return PAM_BUF_ERR; + case WBC_ERR_INVALID_SID: + case WBC_ERR_INVALID_PARAM: + break; + case WBC_ERR_WINBIND_NOT_AVAILABLE: + return PAM_AUTHINFO_UNAVAIL; + case WBC_ERR_DOMAIN_NOT_FOUND: + return PAM_AUTHINFO_UNAVAIL; + case WBC_ERR_INVALID_RESPONSE: + return PAM_BUF_ERR; + case WBC_ERR_NSS_ERROR: + return PAM_USER_UNKNOWN; + case WBC_ERR_AUTH_ERROR: + return PAM_AUTH_ERR; + case WBC_ERR_UNKNOWN_USER: + return PAM_USER_UNKNOWN; + case WBC_ERR_UNKNOWN_GROUP: + return PAM_USER_UNKNOWN; + case WBC_ERR_PWD_CHANGE_FAILED: + break; + } + + /* be paranoid */ + return PAM_AUTH_ERR; +} + static const char *_pam_error_code_str(int err) { switch (err) { @@ -71,14 +107,22 @@ static const char *_pam_error_code_str(int err) return "PAM_ABORT"; case PAM_AUTHTOK_EXPIRED: return "PAM_AUTHTOK_EXPIRED"; +#ifdef PAM_MODULE_UNKNOWN case PAM_MODULE_UNKNOWN: return "PAM_MODULE_UNKNOWN"; +#endif +#ifdef PAM_BAD_ITEM case PAM_BAD_ITEM: return "PAM_BAD_ITEM"; +#endif +#ifdef PAM_CONV_AGAIN case PAM_CONV_AGAIN: return "PAM_CONV_AGAIN"; +#endif +#ifdef PAM_INCOMPLETE case PAM_INCOMPLETE: return "PAM_INCOMPLETE"; +#endif default: return NULL; } @@ -393,6 +437,10 @@ static int _pam_parse(const pam_handle_t *pamh, ctrl |= WINBIND_WARN_PWD_EXPIRE; } + if (iniparser_getboolean(d, "global:mkhomedir", false)) { + ctrl |= WINBIND_MKHOMEDIR; + } + config_from_pam: /* step through arguments */ for (i=argc,v=argv; i-- > 0; ++v) { @@ -425,6 +473,8 @@ config_from_pam: ctrl |= WINBIND_KRB5_CCACHE_TYPE; else if (!strcasecmp(*v, "cached_login")) ctrl |= WINBIND_CACHED_LOGIN; + else if (!strcasecmp(*v, "mkhomedir")) + ctrl |= WINBIND_MKHOMEDIR; else { __pam_log(pamh, ctrl, LOG_ERR, "pam_parse: unknown option: %s", *v); @@ -444,13 +494,17 @@ config_from_pam: return ctrl; }; -static void _pam_winbind_free_context(struct pwb_context *ctx) +static int _pam_winbind_free_context(struct pwb_context *ctx) { + if (!ctx) { + return 0; + } + if (ctx->dict) { iniparser_freedict(ctx->dict); } - SAFE_FREE(ctx); + return 0; } static int _pam_winbind_init_context(pam_handle_t *pamh, @@ -461,12 +515,12 @@ static int _pam_winbind_init_context(pam_handle_t *pamh, { struct pwb_context *r = NULL; - r = (struct pwb_context *)malloc(sizeof(struct pwb_context)); + r = TALLOC_ZERO_P(NULL, struct pwb_context); if (!r) { return PAM_BUF_ERR; } - ZERO_STRUCTP(r); + talloc_set_destructor(r, _pam_winbind_free_context); r->pamh = pamh; r->flags = flags; @@ -474,7 +528,7 @@ static int _pam_winbind_init_context(pam_handle_t *pamh, r->argv = argv; r->ctrl = _pam_parse(pamh, flags, argc, argv, &r->dict); if (r->ctrl == -1) { - _pam_winbind_free_context(r); + TALLOC_FREE(r); return PAM_SYSTEM_ERR; } @@ -494,7 +548,7 @@ static void _pam_winbind_cleanup_func(pam_handle_t *pamh, "(error_status = %d)", pamh, data, error_status); } - SAFE_FREE(data); + TALLOC_FREE(data); } @@ -636,80 +690,11 @@ static int _make_remark_format(struct pwb_context *ctx, int type, const char *fo return ret; } -static int pam_winbind_request(struct pwb_context *ctx, - enum winbindd_cmd req_type, - struct winbindd_request *request, - struct winbindd_response *response) -{ - /* Fill in request and send down pipe */ - winbindd_init_request(request, req_type); - - if (winbind_write_sock(request, sizeof(*request), 0, 0) == -1) { - _pam_log(ctx, LOG_ERR, - "pam_winbind_request: write to socket failed!"); - winbind_close_sock(); - return PAM_SERVICE_ERR; - } - - /* Wait for reply */ - if (winbindd_read_reply(response) == -1) { - _pam_log(ctx, LOG_ERR, - "pam_winbind_request: read from socket failed!"); - winbind_close_sock(); - return PAM_SERVICE_ERR; - } - - /* We are done with the socket - close it and avoid mischeif */ - winbind_close_sock(); - - /* Copy reply data from socket */ - if (response->result == WINBINDD_OK) { - return PAM_SUCCESS; - } - - /* no need to check for pam_error codes for getpwnam() */ - switch (req_type) { - - case WINBINDD_GETPWNAM: - case WINBINDD_LOOKUPNAME: - if (strlen(response->data.auth.nt_status_string) > 0) { - _pam_log(ctx, LOG_ERR, - "request failed, NT error was %s", - response->data.auth.nt_status_string); - } else { - _pam_log(ctx, LOG_ERR, "request failed"); - } - return PAM_USER_UNKNOWN; - default: - break; - } - - if (response->data.auth.pam_error != PAM_SUCCESS) { - _pam_log(ctx, LOG_ERR, - "request failed: %s, " - "PAM error was %s (%d), NT error was %s", - response->data.auth.error_string, - pam_strerror(ctx->pamh, response->data.auth.pam_error), - response->data.auth.pam_error, - response->data.auth.nt_status_string); - return response->data.auth.pam_error; - } - - _pam_log(ctx, LOG_ERR, "request failed, but PAM error 0!"); - - return PAM_SERVICE_ERR; -} - static int pam_winbind_request_log(struct pwb_context *ctx, - enum winbindd_cmd req_type, - struct winbindd_request *request, - struct winbindd_response *response, - const char *user) + int retval, + const char *user, + const char *fn) { - int retval; - - retval = pam_winbind_request(ctx, req_type, request, response); - switch (retval) { case PAM_AUTH_ERR: /* incorrect password */ @@ -741,33 +726,65 @@ static int pam_winbind_request_log(struct pwb_context *ctx, return retval; case PAM_SUCCESS: /* Otherwise, the authentication looked good */ - switch (req_type) { - case WINBINDD_INFO: - break; - case WINBINDD_PAM_AUTH: - _pam_log(ctx, LOG_NOTICE, - "user '%s' granted access", user); - break; - case WINBINDD_PAM_CHAUTHTOK: - _pam_log(ctx, LOG_NOTICE, - "user '%s' password changed", user); - break; - default: - _pam_log(ctx, LOG_NOTICE, - "user '%s' OK", user); - break; + if (strcmp(fn, "wbcLogonUser") == 0) { + _pam_log(ctx, LOG_NOTICE, + "user '%s' granted access", user); + } else { + _pam_log(ctx, LOG_NOTICE, + "user '%s' OK", user); } - return retval; default: /* we don't know anything about this return value */ _pam_log(ctx, LOG_ERR, - "internal module error (retval = %d, user = '%s')", - retval, user); + "internal module error (retval = %s(%d), user = '%s')", + _pam_error_code_str(retval), retval, user); return retval; } } +static int wbc_auth_error_to_pam_error(struct pwb_context *ctx, + struct wbcAuthErrorInfo *e, + wbcErr status, + const char *username, + const char *fn) +{ + int ret = PAM_AUTH_ERR; + + if (WBC_ERROR_IS_OK(status)) { + _pam_log_debug(ctx, LOG_DEBUG, "request %s succeeded", + fn); + ret = PAM_SUCCESS; + return pam_winbind_request_log(ctx, ret, username, fn); + } + + if (e) { + if (e->pam_error != PAM_SUCCESS) { + _pam_log(ctx, LOG_ERR, + "request %s failed: %s, " + "PAM error: %s (%d), NTSTATUS: %s, " + "Error message was: %s", + fn, + wbcErrorString(status), + _pam_error_code_str(e->pam_error), + e->pam_error, + e->nt_string, + e->display_string); + ret = e->pam_error; + return pam_winbind_request_log(ctx, ret, username, fn); + } + + _pam_log(ctx, LOG_ERR, "request %s failed, but PAM error 0!", fn); + + ret = PAM_SERVICE_ERR; + return pam_winbind_request_log(ctx, ret, username, fn); + } + + ret = wbc_error_to_pam_error(status); + return pam_winbind_request_log(ctx, ret, username, fn); +} + + /** * send a password expiry message if required * @@ -840,29 +857,34 @@ static bool _pam_send_password_expiry_message(struct pwb_context *ctx, */ static void _pam_warn_password_expiry(struct pwb_context *ctx, - const struct winbindd_response *response, + const struct wbcAuthUserInfo *info, + const struct wbcUserPasswordPolicyInfo *policy, int warn_pwd_expire, bool *already_expired) { time_t now = time(NULL); time_t next_change = 0; + if (!info || !policy) { + return; + } + if (already_expired) { *already_expired = false; } - /* accounts with ACB_PWNOEXP set never receive a warning */ - if (response->data.auth.info3.acct_flags & ACB_PWNOEXP) { + /* accounts with WBC_ACB_PWNOEXP set never receive a warning */ + if (info->acct_flags & WBC_ACB_PWNOEXP) { return; } /* no point in sending a warning if this is a grace logon */ - if (PAM_WB_GRACE_LOGON(response->data.auth.info3.user_flgs)) { + if (PAM_WB_GRACE_LOGON(info->user_flags)) { return; } /* check if the info3 must change timestamp has been set */ - next_change = response->data.auth.info3.pass_must_change_time; + next_change = info->pass_must_change_time; if (_pam_send_password_expiry_message(ctx, next_change, now, warn_pwd_expire, @@ -873,12 +895,11 @@ static void _pam_warn_password_expiry(struct pwb_context *ctx, /* now check for the global password policy */ /* good catch from Ralf Haferkamp: an expiry of "never" is translated * to -1 */ - if (response->data.auth.policy.expire <= 0) { + if (policy->expire <= 0) { return; } - next_change = response->data.auth.info3.pass_last_set_time + - response->data.auth.policy.expire; + next_change = info->pass_last_set_time + policy->expire; if (_pam_send_password_expiry_message(ctx, next_change, now, warn_pwd_expire, @@ -936,33 +957,33 @@ static bool winbind_name_to_sid_string(struct pwb_context *ctx, int sid_list_buffer_size) { const char* sid_string; - struct winbindd_response sid_response; /* lookup name? */ if (IS_SID_STRING(name)) { sid_string = name; } else { - struct winbindd_request sid_request; - - ZERO_STRUCT(sid_request); - ZERO_STRUCT(sid_response); + wbcErr wbc_status; + struct wbcDomainSid sid; + enum wbcSidType type; + char *sid_str; _pam_log_debug(ctx, LOG_DEBUG, "no sid given, looking up: %s\n", name); - /* fortunatly winbindd can handle non-separated names */ - strncpy(sid_request.data.name.name, name, - sizeof(sid_request.data.name.name) - 1); - - if (pam_winbind_request_log(ctx, WINBINDD_LOOKUPNAME, - &sid_request, &sid_response, - user)) { + wbc_status = wbcLookupName("", name, &sid, &type); + if (!WBC_ERROR_IS_OK(wbc_status)) { _pam_log(ctx, LOG_INFO, "could not lookup name: %s\n", name); return false; } - sid_string = sid_response.data.sid.sid; + wbc_status = wbcSidToString(&sid, &sid_str); + if (!WBC_ERROR_IS_OK(wbc_status)) { + return false; + } + + wbcFreeMemory(sid_str); + sid_string = sid_str; } if (!safe_append_string(sid_list_buffer, sid_string, @@ -1047,15 +1068,28 @@ out: */ static void _pam_setup_krb5_env(struct pwb_context *ctx, - const char *krb5ccname) + struct wbcLogonUserInfo *info) { char var[PATH_MAX]; int ret; + uint32_t i; + const char *krb5ccname = NULL; if (off(ctx->ctrl, WINBIND_KRB5_AUTH)) { return; } + if (!info) { + return; + } + + for (i=0; i < info->num_blobs; i++) { + if (strcasecmp(info->blobs[i].name, "krb5ccname") == 0) { + krb5ccname = (const char *)info->blobs[i].blob.data; + break; + } + } + if (!krb5ccname || (strlen(krb5ccname) == 0)) { return; } @@ -1075,6 +1109,41 @@ static void _pam_setup_krb5_env(struct pwb_context *ctx, } } +/** + * Copy unix username if available (further processed in PAM). + * + * @param ctx PAM winbind context + * @param user_ret A pointer that holds a pointer to a string + * @param unix_username A username + * + * @return void. + */ + +static void _pam_setup_unix_username(struct pwb_context *ctx, + char **user_ret, + struct wbcLogonUserInfo *info) +{ + const char *unix_username = NULL; + uint32_t i; + + if (!user_ret || !info) { + return; + } + + for (i=0; i < info->num_blobs; i++) { + if (strcasecmp(info->blobs[i].name, "unix_username") == 0) { + unix_username = (const char *)info->blobs[i].blob.data; + break; + } + } + + if (!unix_username || !unix_username[0]) { + return; + } + + *user_ret = strdup(unix_username); +} + /** * Set string into the PAM stack. * @@ -1096,14 +1165,13 @@ static void _pam_set_data_string(struct pwb_context *ctx, return; } - ret = pam_set_data(ctx->pamh, data_name, (void *)strdup(value), + ret = pam_set_data(ctx->pamh, data_name, talloc_strdup(NULL, value), _pam_winbind_cleanup_func); if (ret) { _pam_log_debug(ctx, LOG_DEBUG, "Could not set data %s: %s\n", data_name, pam_strerror(ctx->pamh, ret)); } - } /** @@ -1117,16 +1185,16 @@ static void _pam_set_data_string(struct pwb_context *ctx, */ static void _pam_set_data_info3(struct pwb_context *ctx, - struct winbindd_response *response) + const struct wbcAuthUserInfo *info) { _pam_set_data_string(ctx, PAM_WINBIND_HOMEDIR, - response->data.auth.info3.home_dir); + info->home_directory); _pam_set_data_string(ctx, PAM_WINBIND_LOGONSCRIPT, - response->data.auth.info3.logon_script); + info->logon_script); _pam_set_data_string(ctx, PAM_WINBIND_LOGONSERVER, - response->data.auth.info3.logon_srv); + info->logon_server); _pam_set_data_string(ctx, PAM_WINBIND_PROFILEPATH, - response->data.auth.info3.profile_path); + info->profile_path); } /** @@ -1208,80 +1276,235 @@ static void _pam_warn_krb5_failure(struct pwb_context *ctx, } } +static bool _pam_check_remark_auth_err(struct pwb_context *ctx, + const struct wbcAuthErrorInfo *e, + const char *nt_status_string, + int *pam_error) +{ + const char *ntstatus = NULL; + const char *error_string = NULL; + + if (!e || !pam_error) { + return false; + } + + ntstatus = e->nt_string; + if (!ntstatus) { + return false; + } + + if (strcasecmp(ntstatus, nt_status_string) == 0) { + + error_string = _get_ntstatus_error_string(nt_status_string); + if (error_string) { + _make_remark(ctx, PAM_ERROR_MSG, error_string); + *pam_error = e->pam_error; + return true; + } + + if (e->display_string) { + _make_remark(ctx, PAM_ERROR_MSG, e->display_string); + *pam_error = e->pam_error; + return true; + } + + _make_remark(ctx, PAM_ERROR_MSG, nt_status_string); + *pam_error = e->pam_error; + + return true; + } + + return false; +}; + /** * Compose Password Restriction String for a PAM_ERROR_MSG conversation. * - * @param response The struct winbindd_response. + * @param i The wbcUserPasswordPolicyInfo struct. * - * @return string (caller needs to free). + * @return string (caller needs to talloc_free). */ -static char *_pam_compose_pwd_restriction_string(struct winbindd_response *response) +static char *_pam_compose_pwd_restriction_string(struct pwb_context *ctx, + struct wbcUserPasswordPolicyInfo *i) { char *str = NULL; - size_t offset = 0, ret = 0, str_size = 1024; - str = (char *)malloc(str_size); - if (!str) { - return NULL; + if (!i) { + goto failed; } - memset(str, '\0', str_size); - - offset = snprintf(str, str_size, "Your password "); - if (offset == -1) { + str = talloc_asprintf(ctx, "Your password "); + if (!str) { goto failed; } - if (response->data.auth.policy.min_length_password > 0) { - ret = snprintf(str+offset, str_size-offset, + if (i->min_length_password > 0) { + str = talloc_asprintf_append(str, "must be at least %d characters; ", - response->data.auth.policy.min_length_password); - if (ret == -1) { + i->min_length_password); + if (!str) { goto failed; } - offset += ret; } - if (response->data.auth.policy.password_history > 0) { - ret = snprintf(str+offset, str_size-offset, + if (i->password_history > 0) { + str = talloc_asprintf_append(str, "cannot repeat any of your previous %d " "passwords; ", - response->data.auth.policy.password_history); - if (ret == -1) { + i->password_history); + if (!str) { goto failed; } - offset += ret; } - if (response->data.auth.policy.password_properties & - DOMAIN_PASSWORD_COMPLEX) { - ret = snprintf(str+offset, str_size-offset, + if (i->password_properties & WBC_DOMAIN_PASSWORD_COMPLEX) { + str = talloc_asprintf_append(str, "must contain capitals, numerals " "or punctuation; " "and cannot contain your account " "or full name; "); - if (ret == -1) { + if (!str) { goto failed; } - offset += ret; } - ret = snprintf(str+offset, str_size-offset, + str = talloc_asprintf_append(str, "Please type a different password. " "Type a password which meets these requirements in " "both text boxes."); - if (ret == -1) { + if (!str) { goto failed; } return str; failed: - SAFE_FREE(str); + TALLOC_FREE(str); return NULL; } +static int _pam_create_homedir(struct pwb_context *ctx, + const char *dirname, + mode_t mode) +{ + struct stat sbuf; + + if (stat(dirname, &sbuf) == 0) { + return PAM_SUCCESS; + } + + if (mkdir(dirname, mode) != 0) { + + _make_remark_format(ctx, PAM_TEXT_INFO, + "Creating directory: %s failed: %s", + dirname, strerror(errno)); + _pam_log(ctx, LOG_ERR, "could not create dir: %s (%s)", + dirname, strerror(errno)); + return PAM_PERM_DENIED; + } + + return PAM_SUCCESS; +} + +static int _pam_chown_homedir(struct pwb_context *ctx, + const char *dirname, + uid_t uid, + gid_t gid) +{ + if (chown(dirname, uid, gid) != 0) { + _pam_log(ctx, LOG_ERR, "failed to chown user homedir: %s (%s)", + dirname, strerror(errno)); + return PAM_PERM_DENIED; + } + + return PAM_SUCCESS; +} + +static int _pam_mkhomedir(struct pwb_context *ctx) +{ + struct passwd *pwd = NULL; + char *token = NULL; + char *create_dir = NULL; + char *user_dir = NULL; + int ret; + const char *username; + mode_t mode = 0700; + char *safe_ptr = NULL; + char *p = NULL; + + /* Get the username */ + ret = pam_get_user(ctx->pamh, &username, NULL); + if ((ret != PAM_SUCCESS) || (!username)) { + _pam_log_debug(ctx, LOG_DEBUG, "can not get the username"); + return PAM_SERVICE_ERR; + } + + pwd = getpwnam(username); + if (pwd == NULL) { + _pam_log_debug(ctx, LOG_DEBUG, "can not get the username"); + return PAM_USER_UNKNOWN; + } + _pam_log_debug(ctx, LOG_DEBUG, "homedir is: %s", pwd->pw_dir); + + ret = _pam_create_homedir(ctx, pwd->pw_dir, 0700); + if (ret == PAM_SUCCESS) { + ret = _pam_chown_homedir(ctx, pwd->pw_dir, + pwd->pw_uid, + pwd->pw_gid); + } + + if (ret == PAM_SUCCESS) { + return ret; + } + + /* maybe we need to create parent dirs */ + create_dir = talloc_strdup(ctx, "/"); + if (!create_dir) { + return PAM_BUF_ERR; + } + + /* find final directory */ + user_dir = strrchr(pwd->pw_dir, '/'); + if (!user_dir) { + return PAM_BUF_ERR; + } + user_dir++; + + _pam_log(ctx, LOG_DEBUG, "final directory: %s", user_dir); + + p = pwd->pw_dir; + + while ((token = strtok_r(p, "/", &safe_ptr)) != NULL) { + + mode = 0755; + + p = NULL; + + _pam_log_debug(ctx, LOG_DEBUG, "token is %s", token); + + create_dir = talloc_asprintf_append(create_dir, "%s/", token); + if (!create_dir) { + return PAM_BUF_ERR; + } + _pam_log_debug(ctx, LOG_DEBUG, "current_dir is %s", create_dir); + + if (strcmp(token, user_dir) == 0) { + _pam_log_debug(ctx, LOG_DEBUG, "assuming last directory: %s", token); + mode = 0700; + } + + ret = _pam_create_homedir(ctx, create_dir, mode); + if (ret) { + return ret; + } + } + + return _pam_chown_homedir(ctx, create_dir, + pwd->pw_uid, + pwd->pw_gid); +} + /* talk to winbindd */ static int winbind_auth_request(struct pwb_context *ctx, const char *user, @@ -1289,37 +1512,52 @@ static int winbind_auth_request(struct pwb_context *ctx, const char *member, const char *cctype, const int warn_pwd_expire, - struct winbindd_response *p_response, + struct wbcAuthErrorInfo **p_error, + struct wbcLogonUserInfo **p_info, + struct wbcUserPasswordPolicyInfo **p_policy, time_t *pwd_last_set, char **user_ret) { - struct winbindd_request request; - struct winbindd_response response; - int ret; - bool already_expired = false; + wbcErr wbc_status; + + struct wbcLogonUserParams logon; + char membership_of[1024]; + uid_t user_uid = -1; + uint32_t flags = WBFLAG_PAM_INFO3_TEXT | + WBFLAG_PAM_GET_PWD_POLICY; + + struct wbcLogonUserInfo *info = NULL; + struct wbcAuthUserInfo *user_info = NULL; + struct wbcAuthErrorInfo *error = NULL; + struct wbcUserPasswordPolicyInfo *policy = NULL; - ZERO_STRUCT(request); - ZERO_STRUCT(response); + int ret = PAM_AUTH_ERR; + int i; + const char *codes[] = { + "NT_STATUS_PASSWORD_EXPIRED", + "NT_STATUS_PASSWORD_MUST_CHANGE", + "NT_STATUS_INVALID_WORKSTATION", + "NT_STATUS_INVALID_LOGON_HOURS", + "NT_STATUS_ACCOUNT_EXPIRED", + "NT_STATUS_ACCOUNT_DISABLED", + "NT_STATUS_ACCOUNT_LOCKED_OUT", + "NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT", + "NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT", + "NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT", + "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", + "NT_STATUS_NO_LOGON_SERVERS", + "NT_STATUS_WRONG_PASSWORD", + "NT_STATUS_ACCESS_DENIED" + }; if (pwd_last_set) { *pwd_last_set = 0; } - strncpy(request.data.auth.user, user, - sizeof(request.data.auth.user)-1); - - strncpy(request.data.auth.pass, pass, - sizeof(request.data.auth.pass)-1); - - request.data.auth.krb5_cc_type[0] = '\0'; - request.data.auth.uid = -1; - - request.flags = WBFLAG_PAM_INFO3_TEXT | WBFLAG_PAM_GET_PWD_POLICY; - /* Krb5 auth always has to go against the KDC of the user's realm */ if (ctx->ctrl & WINBIND_KRB5_AUTH) { - request.flags |= WBFLAG_PAM_CONTACT_TRUSTDOM; + flags |= WBFLAG_PAM_CONTACT_TRUSTDOM; } if (ctx->ctrl & (WINBIND_KRB5_AUTH|WINBIND_CACHED_LOGIN)) { @@ -1329,7 +1567,7 @@ static int winbind_auth_request(struct pwb_context *ctx, if (pwd == NULL) { return PAM_USER_UNKNOWN; } - request.data.auth.uid = pwd->pw_uid; + user_uid = pwd->pw_uid; } if (ctx->ctrl & WINBIND_KRB5_AUTH) { @@ -1337,38 +1575,34 @@ static int winbind_auth_request(struct pwb_context *ctx, _pam_log_debug(ctx, LOG_DEBUG, "enabling krb5 login flag\n"); - request.flags |= WBFLAG_PAM_KRB5 | - WBFLAG_PAM_FALLBACK_AFTER_KRB5; + flags |= WBFLAG_PAM_KRB5 | + WBFLAG_PAM_FALLBACK_AFTER_KRB5; } if (ctx->ctrl & WINBIND_CACHED_LOGIN) { _pam_log_debug(ctx, LOG_DEBUG, "enabling cached login flag\n"); - request.flags |= WBFLAG_PAM_CACHED_LOGIN; + flags |= WBFLAG_PAM_CACHED_LOGIN; } if (user_ret) { *user_ret = NULL; - request.flags |= WBFLAG_PAM_UNIX_NAME; + flags |= WBFLAG_PAM_UNIX_NAME; } if (cctype != NULL) { - strncpy(request.data.auth.krb5_cc_type, cctype, - sizeof(request.data.auth.krb5_cc_type) - 1); _pam_log_debug(ctx, LOG_DEBUG, "enabling request for a %s krb5 ccache\n", cctype); } - request.data.auth.require_membership_of_sid[0] = '\0'; - if (member != NULL) { - if (!winbind_name_list_to_sid_string_list(ctx, user, - member, - request.data.auth.require_membership_of_sid, - sizeof(request.data.auth.require_membership_of_sid))) { + ZERO_STRUCT(membership_of); + if (!winbind_name_list_to_sid_string_list(ctx, user, member, + membership_of, + sizeof(membership_of))) { _pam_log_debug(ctx, LOG_ERR, "failed to serialize membership of sid " "\"%s\"\n", member); @@ -1376,60 +1610,100 @@ static int winbind_auth_request(struct pwb_context *ctx, } } - ret = pam_winbind_request_log(ctx, WINBINDD_PAM_AUTH, - &request, &response, user); + ZERO_STRUCT(logon); - if (pwd_last_set) { - *pwd_last_set = response.data.auth.info3.pass_last_set_time; + logon.username = user; + logon.password = pass; + + wbc_status = wbcAddNamedBlob(&logon.num_blobs, + &logon.blobs, + "krb5_cc_type", + 0, + (uint8_t *)cctype, + strlen(cctype)+1); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; + } + + wbc_status = wbcAddNamedBlob(&logon.num_blobs, + &logon.blobs, + "flags", + 0, + (uint8_t *)&flags, + sizeof(flags)); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; } - if (p_response) { - /* We want to process the response in the caller. */ - *p_response = response; + wbc_status = wbcAddNamedBlob(&logon.num_blobs, + &logon.blobs, + "user_uid", + 0, + (uint8_t *)&user_uid, + sizeof(user_uid)); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; + } + + wbc_status = wbcAddNamedBlob(&logon.num_blobs, + &logon.blobs, + "membership_of", + 0, + (uint8_t *)membership_of, + sizeof(membership_of)); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto done; + } + + wbc_status = wbcLogonUser(&logon, &info, &error, &policy); + ret = wbc_auth_error_to_pam_error(ctx, error, wbc_status, + user, "wbcLogonUser"); + wbcFreeMemory(logon.blobs); + logon.blobs = NULL; + + if (info && info->info) { + user_info = info->info; + } + + if (pwd_last_set && user_info) { + *pwd_last_set = user_info->pass_last_set_time; + } + + if (p_info && info) { + *p_info = info; + } + + if (p_policy && policy) { + *p_policy = policy; + } + + if (p_error && error) { + /* We want to process the error in the caller. */ + *p_error = error; return ret; } - if (ret) { - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_PASSWORD_EXPIRED"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_PASSWORD_MUST_CHANGE"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_INVALID_WORKSTATION"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_INVALID_LOGON_HOURS"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_ACCOUNT_EXPIRED"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_ACCOUNT_DISABLED"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_ACCOUNT_LOCKED_OUT"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_NO_LOGON_SERVERS"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_WRONG_PASSWORD"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_ACCESS_DENIED"); + for (i=0; ipass_last_set_time; + _pam_log_debug(ctx, LOG_DEBUG, "Password has expired " "(Password was last set: %lld, " @@ -1437,33 +1711,44 @@ static int winbind_auth_request(struct pwb_context *ctx, "%lld (now it's: %lu))\n", (long long int)last_set, (long long int)last_set + - response.data.auth.policy.expire, + policy->expire, time(NULL)); return PAM_AUTHTOK_EXPIRED; } /* inform about logon type */ - _pam_warn_logon_type(ctx, user, - response.data.auth.info3.user_flgs); + _pam_warn_logon_type(ctx, user, user_info->user_flags); /* inform about krb5 failures */ - _pam_warn_krb5_failure(ctx, user, - response.data.auth.info3.user_flgs); + _pam_warn_krb5_failure(ctx, user, user_info->user_flags); /* set some info3 info for other modules in the stack */ - _pam_set_data_info3(ctx, &response); + _pam_set_data_info3(ctx, user_info); /* put krb5ccname into env */ - _pam_setup_krb5_env(ctx, response.data.auth.krb5ccname); + _pam_setup_krb5_env(ctx, info); /* If winbindd returned a username, return the pointer to it * here. */ - if (user_ret && response.data.auth.unix_username[0]) { - /* We have to trust it's a null terminated string. */ - *user_ret = strndup(response.data.auth.unix_username, - sizeof(response.data.auth.unix_username) - 1); - } + _pam_setup_unix_username(ctx, user_ret, info); + } + + done: + if (logon.blobs) { + wbcFreeMemory(logon.blobs); + } + if (info && info->blobs) { + wbcFreeMemory(info->blobs); + } + if (error && !p_error) { + wbcFreeMemory(error); + } + if (info && !p_info) { + wbcFreeMemory(info); + } + if (policy && !p_policy) { + wbcFreeMemory(policy); } return ret; @@ -1476,99 +1761,95 @@ static int winbind_chauthtok_request(struct pwb_context *ctx, const char *newpass, time_t pwd_last_set) { - struct winbindd_request request; - struct winbindd_response response; - int ret; + wbcErr wbc_status; + struct wbcChangePasswordParams params; + struct wbcAuthErrorInfo *error = NULL; + struct wbcUserPasswordPolicyInfo *policy = NULL; + enum wbcPasswordChangeRejectReason reject_reason = -1; + uint32_t flags = 0; - ZERO_STRUCT(request); - ZERO_STRUCT(response); + int i; + const char *codes[] = { + "NT_STATUS_BACKUP_CONTROLLER", + "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", + "NT_STATUS_NO_LOGON_SERVERS", + "NT_STATUS_ACCESS_DENIED", + "NT_STATUS_PWD_TOO_SHORT", /* TODO: tell the min pwd length ? */ + "NT_STATUS_PWD_TOO_RECENT", /* TODO: tell the minage ? */ + "NT_STATUS_PWD_HISTORY_CONFLICT" /* TODO: tell the history length ? */ + }; + int ret = PAM_AUTH_ERR; + + ZERO_STRUCT(params); - if (request.data.chauthtok.user == NULL) { - return -2; + if (ctx->ctrl & WINBIND_KRB5_AUTH) { + flags |= WBFLAG_PAM_KRB5 | + WBFLAG_PAM_CONTACT_TRUSTDOM; } - strncpy(request.data.chauthtok.user, user, - sizeof(request.data.chauthtok.user) - 1); - - if (oldpass != NULL) { - strncpy(request.data.chauthtok.oldpass, oldpass, - sizeof(request.data.chauthtok.oldpass) - 1); - } else { - request.data.chauthtok.oldpass[0] = '\0'; + if (ctx->ctrl & WINBIND_CACHED_LOGIN) { + flags |= WBFLAG_PAM_CACHED_LOGIN; } - if (newpass != NULL) { - strncpy(request.data.chauthtok.newpass, newpass, - sizeof(request.data.chauthtok.newpass) - 1); - } else { - request.data.chauthtok.newpass[0] = '\0'; - } + params.account_name = user; + params.level = WBC_AUTH_USER_LEVEL_PLAIN; + params.old_password.plaintext = oldpass; + params.new_password.plaintext = newpass; + params.flags = flags; - if (ctx->ctrl & WINBIND_KRB5_AUTH) { - request.flags = WBFLAG_PAM_KRB5 | - WBFLAG_PAM_CONTACT_TRUSTDOM; - } + wbc_status = wbcChangeUserPasswordEx(¶ms, &error, &reject_reason, &policy); + ret = wbc_auth_error_to_pam_error(ctx, error, wbc_status, + user, "wbcChangeUserPasswordEx"); - if (ctx->ctrl & WINBIND_CACHED_LOGIN) { - request.flags |= WBFLAG_PAM_CACHED_LOGIN; + if (WBC_ERROR_IS_OK(wbc_status)) { + _pam_log(ctx, LOG_NOTICE, + "user '%s' password changed", user); + return PAM_SUCCESS; } - ret = pam_winbind_request_log(ctx, WINBINDD_PAM_CHAUTHTOK, - &request, &response, user); - - if (ret == PAM_SUCCESS) { + if (!error) { + wbcFreeMemory(policy); return ret; } - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_BACKUP_CONTROLLER"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_NO_LOGON_SERVERS"); - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_ACCESS_DENIED"); - - /* TODO: tell the min pwd length ? */ - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_PWD_TOO_SHORT"); - - /* TODO: tell the minage ? */ - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_PWD_TOO_RECENT"); - - /* TODO: tell the history length ? */ - PAM_WB_REMARK_CHECK_RESPONSE_RET(ctx, response, - "NT_STATUS_PWD_HISTORY_CONFLICT"); + for (i=0; int_string, "NT_STATUS_PASSWORD_RESTRICTION")) { char *pwd_restriction_string = NULL; - SMB_TIME_T min_pwd_age; - uint32_t reject_reason = response.data.auth.reject_reason; - min_pwd_age = response.data.auth.policy.min_passwordage; + SMB_TIME_T min_pwd_age = 0; + + if (policy) { + min_pwd_age = policy->min_passwordage; + } /* FIXME: avoid to send multiple PAM messages after another */ switch (reject_reason) { case -1: break; - case SAMR_REJECT_OTHER: + case WBC_PWD_CHANGE_REJECT_OTHER: if ((min_pwd_age > 0) && (pwd_last_set + min_pwd_age > time(NULL))) { PAM_WB_REMARK_DIRECT(ctx, "NT_STATUS_PWD_TOO_RECENT"); } break; - case SAMR_REJECT_TOO_SHORT: + case WBC_PWD_CHANGE_REJECT_TOO_SHORT: PAM_WB_REMARK_DIRECT(ctx, "NT_STATUS_PWD_TOO_SHORT"); break; - case SAMR_REJECT_IN_HISTORY: + case WBC_PWD_CHANGE_REJECT_IN_HISTORY: PAM_WB_REMARK_DIRECT(ctx, "NT_STATUS_PWD_HISTORY_CONFLICT"); break; - case SAMR_REJECT_COMPLEXITY: + case WBC_PWD_CHANGE_REJECT_COMPLEXITY: _make_remark(ctx, PAM_ERROR_MSG, "Password does not meet " "complexity requirements"); @@ -1582,13 +1863,16 @@ static int winbind_chauthtok_request(struct pwb_context *ctx, } pwd_restriction_string = - _pam_compose_pwd_restriction_string(&response); + _pam_compose_pwd_restriction_string(ctx, policy); if (pwd_restriction_string) { _make_remark(ctx, PAM_ERROR_MSG, pwd_restriction_string); - SAFE_FREE(pwd_restriction_string); + TALLOC_FREE(pwd_restriction_string); } } + done: + wbcFreeMemory(error); + wbcFreeMemory(policy); return ret; } @@ -1608,29 +1892,26 @@ static int valid_user(struct pwb_context *ctx, * sure it's really a winbind user, this is important when stacking PAM * modules in the 'account' or 'password' facility. */ + wbcErr wbc_status; struct passwd *pwd = NULL; - struct winbindd_request request; - struct winbindd_response response; - int ret; - - ZERO_STRUCT(request); - ZERO_STRUCT(response); + struct passwd *wb_pwd = NULL; pwd = getpwnam(user); if (pwd == NULL) { return 1; } - strncpy(request.data.username, user, - sizeof(request.data.username) - 1); - - ret = pam_winbind_request_log(ctx, WINBINDD_GETPWNAM, - &request, &response, user); + wbc_status = wbcGetpwnam(user, &wb_pwd); + wbcFreeMemory(wb_pwd); + if (!WBC_ERROR_IS_OK(wbc_status)) { + _pam_log(ctx, LOG_DEBUG, "valid_user: wbcGetpwnam gave %s\n", + wbcErrorString(wbc_status)); + } - switch (ret) { - case PAM_USER_UNKNOWN: + switch (wbc_status) { + case WBC_ERR_UNKNOWN_USER: return 1; - case PAM_SUCCESS: + case WBC_ERR_SUCCESS: return 0; default: break; @@ -1838,12 +2119,13 @@ static const char *get_conf_item_string(struct pwb_context *ctx, if (ctx->dict) { char *key = NULL; - if (!asprintf(&key, "global:%s", item)) { + key = talloc_asprintf(ctx, "global:%s", item); + if (!key) { goto out; } parm_opt = iniparser_getstr(ctx->dict, key); - SAFE_FREE(key); + TALLOC_FREE(key); _pam_log_debug(ctx, LOG_INFO, "CONFIG file: %s '%s'\n", item, parm_opt); @@ -1885,12 +2167,13 @@ static int get_config_item_int(struct pwb_context *ctx, if (ctx->dict) { char *key = NULL; - if (!asprintf(&key, "global:%s", item)) { + key = talloc_asprintf(ctx, "global:%s", item); + if (!key) { goto out; } parm_opt = iniparser_getint(ctx->dict, key, -1); - SAFE_FREE(key); + TALLOC_FREE(key); _pam_log_debug(ctx, LOG_INFO, "CONFIG file: %s '%d'\n", @@ -1940,20 +2223,25 @@ static int get_warn_pwd_expire_from_config(struct pwb_context *ctx) static char winbind_get_separator(struct pwb_context *ctx) { - struct winbindd_request request; - struct winbindd_response response; + wbcErr wbc_status; + static struct wbcInterfaceDetails *details = NULL; - ZERO_STRUCT(request); - ZERO_STRUCT(response); + wbc_status = wbcInterfaceDetails(&details); + if (!WBC_ERROR_IS_OK(wbc_status)) { + _pam_log(ctx, LOG_ERR, + "Could not retrieve winbind interface details: %s", + wbcErrorString(wbc_status)); + return '\0'; + } - if (pam_winbind_request_log(ctx, WINBINDD_INFO, - &request, &response, NULL)) { + if (!details) { return '\0'; } - return response.data.info.winbind_separator; + return details->winbind_separator; } + /** * Convert a upn to a name. * @@ -1966,12 +2254,12 @@ static char winbind_get_separator(struct pwb_context *ctx) static char* winbind_upn_to_username(struct pwb_context *ctx, const char *upn) { - struct winbindd_request req; - struct winbindd_response resp; - int retval; - char *account_name; - int account_name_len; char sep; + wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; + struct wbcDomainSid sid; + enum wbcSidType type; + char *domain; + char *name; /* This cannot work when the winbind separator = @ */ @@ -1982,35 +2270,19 @@ static char* winbind_upn_to_username(struct pwb_context *ctx, /* Convert the UPN to a SID */ - ZERO_STRUCT(req); - ZERO_STRUCT(resp); - - strncpy(req.data.name.dom_name, "", - sizeof(req.data.name.dom_name) - 1); - strncpy(req.data.name.name, upn, - sizeof(req.data.name.name) - 1); - retval = pam_winbind_request_log(ctx, WINBINDD_LOOKUPNAME, - &req, &resp, upn); - if (retval != PAM_SUCCESS) { + wbc_status = wbcLookupName("", upn, &sid, &type); + if (!WBC_ERROR_IS_OK(wbc_status)) { return NULL; } /* Convert the the SID back to the sAMAccountName */ - ZERO_STRUCT(req); - strncpy(req.data.sid, resp.data.sid.sid, sizeof(req.data.sid)-1); - ZERO_STRUCT(resp); - retval = pam_winbind_request_log(ctx, WINBINDD_LOOKUPSID, - &req, &resp, upn); - if (retval != PAM_SUCCESS) { + wbc_status = wbcLookupSid(&sid, &domain, &name, &type); + if (!WBC_ERROR_IS_OK(wbc_status)) { return NULL; } - account_name_len = asprintf(&account_name, "%s\\%s", - resp.data.name.dom_name, - resp.data.name.name); - - return account_name; + return talloc_asprintf(ctx, "%s\\%s", domain, name); } PAM_EXTERN @@ -2079,7 +2351,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, real_username); if (samaccountname) { free(real_username); - real_username = samaccountname; + real_username = strdup(samaccountname); } } @@ -2111,7 +2383,8 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, /* Now use the username to look up password */ retval = winbind_auth_request(ctx, real_username, password, - member, cctype, warn_pwd_expire, NULL, + member, cctype, warn_pwd_expire, + NULL, NULL, NULL, NULL, &username_ret); if (retval == PAM_NEW_AUTHTOK_REQD || @@ -2119,7 +2392,8 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, char *new_authtok_required_during_auth = NULL; - if (!asprintf(&new_authtok_required, "%d", retval)) { + new_authtok_required = talloc_asprintf(NULL, "%d", retval); + if (!new_authtok_required) { retval = PAM_BUF_ERR; goto out; } @@ -2130,7 +2404,8 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, retval = PAM_SUCCESS; - if (!asprintf(&new_authtok_required_during_auth, "%d", true)) { + new_authtok_required_during_auth = talloc_asprintf(NULL, "%d", true); + if (!new_authtok_required_during_auth) { retval = PAM_BUF_ERR; goto out; } @@ -2164,7 +2439,7 @@ out: _PAM_LOG_FUNCTION_LEAVE("pam_sm_authenticate", ctx, retval); - _pam_winbind_free_context(ctx); + TALLOC_FREE(ctx); return retval; } @@ -2212,7 +2487,7 @@ int pam_sm_setcred(pam_handle_t *pamh, int flags, _PAM_LOG_FUNCTION_LEAVE("pam_sm_setcred", ctx, ret); - _pam_winbind_free_context(ctx); + TALLOC_FREE(ctx); return ret; } @@ -2313,7 +2588,7 @@ int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, _PAM_LOG_FUNCTION_LEAVE("pam_sm_acct_mgmt", ctx, ret); - _pam_winbind_free_context(ctx); + TALLOC_FREE(ctx); return ret; } @@ -2322,7 +2597,7 @@ PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) { - int ret = PAM_SYSTEM_ERR; + int ret = PAM_SUCCESS; struct pwb_context *ctx = NULL; ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx); @@ -2332,12 +2607,14 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, _PAM_LOG_FUNCTION_ENTER("pam_sm_open_session", ctx); - ret = PAM_SUCCESS; - + if (ctx->ctrl & WINBIND_MKHOMEDIR) { + /* check and create homedir */ + ret = _pam_mkhomedir(ctx); + } out: _PAM_LOG_FUNCTION_LEAVE("pam_sm_open_session", ctx, ret); - _pam_winbind_free_context(ctx); + TALLOC_FREE(ctx); return ret; } @@ -2348,6 +2625,7 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags, { int retval = PAM_SUCCESS; struct pwb_context *ctx = NULL; + struct wbcLogoffUserParams logoff; retval = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx); if (retval) { @@ -2364,15 +2642,15 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags, if (ctx->ctrl & WINBIND_KRB5_AUTH) { /* destroy the ccache here */ - struct winbindd_request request; - struct winbindd_response response; + + wbcErr wbc_status; + struct wbcAuthErrorInfo *error = NULL; + + uint32_t flags = 0; const char *user; const char *ccname = NULL; struct passwd *pwd = NULL; - ZERO_STRUCT(request); - ZERO_STRUCT(response); - retval = pam_get_user(pamh, &user, "Username: "); if (retval) { _pam_log(ctx, LOG_ERR, @@ -2396,34 +2674,70 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags, "user has no KRB5CCNAME environment"); } - strncpy(request.data.logoff.user, user, - sizeof(request.data.logoff.user) - 1); - - if (ccname) { - strncpy(request.data.logoff.krb5ccname, ccname, - sizeof(request.data.logoff.krb5ccname) - 1); - } - pwd = getpwnam(user); if (pwd == NULL) { retval = PAM_USER_UNKNOWN; goto out; } - request.data.logoff.uid = pwd->pw_uid; - request.flags = WBFLAG_PAM_KRB5 | - WBFLAG_PAM_CONTACT_TRUSTDOM; + flags = WBFLAG_PAM_KRB5 | + WBFLAG_PAM_CONTACT_TRUSTDOM; + + ZERO_STRUCT(logoff); + + logoff.username = user; - retval = pam_winbind_request_log(ctx, - WINBINDD_PAM_LOGOFF, - &request, &response, user); + wbc_status = wbcAddNamedBlob(&logoff.num_blobs, + &logoff.blobs, + "ccfilename", + 0, + (uint8_t *)ccname, + strlen(ccname)+1); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto out; + } + + wbc_status = wbcAddNamedBlob(&logoff.num_blobs, + &logoff.blobs, + "flags", + 0, + (uint8_t *)&flags, + sizeof(flags)); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto out; + } + + wbc_status = wbcAddNamedBlob(&logoff.num_blobs, + &logoff.blobs, + "user_uid", + 0, + (uint8_t *)&pwd->pw_uid, + sizeof(pwd->pw_uid)); + if (!WBC_ERROR_IS_OK(wbc_status)) { + goto out; + } + + wbc_status = wbcLogoffUserEx(&logoff, &error); + retval = wbc_auth_error_to_pam_error(ctx, error, wbc_status, + user, "wbcLogoffUser"); + wbcFreeMemory(error); + wbcFreeMemory(logoff.blobs); + + if (!WBC_ERROR_IS_OK(wbc_status)) { + _pam_log(ctx, LOG_INFO, + "failed to logoff user %s: %s\n", + user, wbcErrorString(wbc_status)); + } } out: + if (logoff.blobs) { + wbcFreeMemory(logoff.blobs); + } _PAM_LOG_FUNCTION_LEAVE("pam_sm_close_session", ctx, retval); - _pam_winbind_free_context(ctx); + TALLOC_FREE(ctx); return retval; } @@ -2495,11 +2809,9 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, int retry = 0; char *username_ret = NULL; - struct winbindd_response response; + struct wbcAuthErrorInfo *error = NULL; struct pwb_context *ctx = NULL; - ZERO_STRUCT(response); - ret = _pam_winbind_init_context(pamh, flags, argc, argv, &ctx); if (ret) { goto out; @@ -2552,16 +2864,15 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, time_t pwdlastset_prelim = 0; /* instruct user what is happening */ -#define greeting "Changing password for " - Announce = (char *) malloc(sizeof(greeting) + strlen(user)); - if (Announce == NULL) { + +#define greeting "Changing password for" + Announce = talloc_asprintf(ctx, "%s %s", greeting, user); + if (!Announce) { _pam_log(ctx, LOG_CRIT, "password - out of memory"); ret = PAM_BUF_ERR; goto out; } - (void) strcpy(Announce, greeting); - (void) strcpy(Announce + sizeof(greeting) - 1, user); #undef greeting lctrl = ctx->ctrl | WINBIND__OLD_PASSWORD; @@ -2570,6 +2881,7 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, "(current) NT password: ", NULL, (const char **) &pass_old); + TALLOC_FREE(Announce); if (ret != PAM_SUCCESS) { _pam_log(ctx, LOG_NOTICE, "password - (old) token not obtained"); @@ -2579,7 +2891,8 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, /* verify that this is the password for this user */ ret = winbind_auth_request(ctx, user, pass_old, - NULL, NULL, 0, &response, + NULL, NULL, 0, + &error, NULL, NULL, &pwdlastset_prelim, NULL); if (ret != PAM_ACCT_EXPIRED && @@ -2688,6 +3001,8 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, const char *member = NULL; const char *cctype = NULL; int warn_pwd_expire; + struct wbcLogonUserInfo *info = NULL; + struct wbcUserPasswordPolicyInfo *policy = NULL; member = get_member_from_config(ctx); cctype = get_krb5_cc_type_from_config(ctx); @@ -2702,7 +3017,8 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, * */ ret = winbind_auth_request(ctx, user, pass_new, - member, cctype, 0, &response, + member, cctype, 0, + &error, &info, &policy, NULL, &username_ret); _pam_overwrite(pass_new); _pam_overwrite(pass_old); @@ -2710,19 +3026,24 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, if (ret == PAM_SUCCESS) { + struct wbcAuthUserInfo *user_info = NULL; + + if (info && info->info) { + user_info = info->info; + } + /* warn a user if the password is about to * expire soon */ - _pam_warn_password_expiry(ctx, &response, + _pam_warn_password_expiry(ctx, user_info, policy, warn_pwd_expire, NULL); /* set some info3 info for other modules in the * stack */ - _pam_set_data_info3(ctx, &response); + _pam_set_data_info3(ctx, user_info); /* put krb5ccname into env */ - _pam_setup_krb5_env(ctx, - response.data.auth.krb5ccname); + _pam_setup_krb5_env(ctx, info); if (username_ret) { pam_set_item(pamh, PAM_USER, @@ -2732,6 +3053,9 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, username_ret); free(username_ret); } + + wbcFreeMemory(info); + wbcFreeMemory(policy); } goto out; @@ -2741,18 +3065,28 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, } out: + { + /* Deal with offline errors. */ + int i; + const char *codes[] = { + "NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND", + "NT_STATUS_NO_LOGON_SERVERS", + "NT_STATUS_ACCESS_DENIED" + }; + + for (i=0; i +#include "libwbclient/wbclient.h" #define MODULE_NAME "pam_winbind" #define PAM_SM_AUTH @@ -97,6 +99,7 @@ do { \ #define WINBIND_SILENT 0x00000800 #define WINBIND_DEBUG_STATE 0x00001000 #define WINBIND_WARN_PWD_EXPIRE 0x00002000 +#define WINBIND_MKHOMEDIR 0x00004000 /* * here is the string to inform the user that the new passwords they @@ -133,73 +136,11 @@ do { \ };\ }; -#define PAM_WB_REMARK_DIRECT_RET(h,f,x)\ -{\ - const char *error_string = NULL; \ - error_string = _get_ntstatus_error_string(x);\ - if (error_string != NULL) {\ - _make_remark(h, f, PAM_ERROR_MSG, error_string);\ - return ret;\ - };\ - _make_remark(h, f, PAM_ERROR_MSG, x);\ - return ret;\ -}; - -#define PAM_WB_REMARK_CHECK_RESPONSE(c,x,y)\ -{\ - const char *ntstatus = x.data.auth.nt_status_string; \ - const char *error_string = NULL; \ - if (!strcasecmp(ntstatus,y)) {\ - error_string = _get_ntstatus_error_string(y);\ - if (error_string != NULL) {\ - _make_remark(c, PAM_ERROR_MSG, error_string);\ - };\ - if (x.data.auth.error_string[0] != '\0') {\ - _make_remark(c, PAM_ERROR_MSG, x.data.auth.error_string);\ - };\ - _make_remark(c, PAM_ERROR_MSG, y);\ - };\ -}; - -#define PAM_WB_REMARK_CHECK_RESPONSE_RET(c,x,y)\ -{\ - const char *ntstatus = x.data.auth.nt_status_string; \ - const char *error_string = NULL; \ - if (!strcasecmp(ntstatus,y)) {\ - error_string = _get_ntstatus_error_string(y);\ - if (error_string != NULL) {\ - _make_remark(c, PAM_ERROR_MSG, error_string);\ - return ret;\ - };\ - if (x.data.auth.error_string[0] != '\0') {\ - _make_remark(c, PAM_ERROR_MSG, x.data.auth.error_string);\ - return ret;\ - };\ - _make_remark(c, PAM_ERROR_MSG, y);\ - return ret;\ - };\ -}; - -/* from samr.idl */ -#define DOMAIN_PASSWORD_COMPLEX 0x00000001 - -#define SAMR_REJECT_OTHER 0x00000000 -#define SAMR_REJECT_TOO_SHORT 0x00000001 -#define SAMR_REJECT_IN_HISTORY 0x00000002 -#define SAMR_REJECT_COMPLEXITY 0x00000005 - -#define ACB_PWNOEXP 0x00000200 - -/* from netlogon.idl */ -#define NETLOGON_CACHED_ACCOUNT 0x00000004 -#define NETLOGON_GRACE_LOGON 0x01000000 - -/* from include/rpc_netlogon.h */ #define LOGON_KRB5_FAIL_CLOCK_SKEW 0x02000000 -#define PAM_WB_CACHED_LOGON(x) (x & NETLOGON_CACHED_ACCOUNT) +#define PAM_WB_CACHED_LOGON(x) (x & WBC_AUTH_USER_INFO_CACHED_ACCOUNT) #define PAM_WB_KRB5_CLOCK_SKEW(x) (x & LOGON_KRB5_FAIL_CLOCK_SKEW) -#define PAM_WB_GRACE_LOGON(x) ((NETLOGON_CACHED_ACCOUNT|NETLOGON_GRACE_LOGON) == ( x & (NETLOGON_CACHED_ACCOUNT|NETLOGON_GRACE_LOGON))) +#define PAM_WB_GRACE_LOGON(x) ((WBC_AUTH_USER_INFO_CACHED_ACCOUNT|WBC_AUTH_USER_INFO_GRACE_LOGON) == ( x & (WBC_AUTH_USER_INFO_CACHED_ACCOUNT|WBC_AUTH_USER_INFO_GRACE_LOGON))) struct pwb_context { pam_handle_t *pamh; @@ -209,3 +150,8 @@ struct pwb_context { dictionary *dict; uint32_t ctrl; }; + +#define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0) +#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) + diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 60524d1d1b..fc49be4314 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -538,8 +538,8 @@ static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags) ZERO_STRUCT(request); ZERO_STRUCT(response); - fstrcpy(request.domain_name, domain_name); - request.flags = flags; + fstrcpy(request.data.dsgetdcname.domain_name, domain_name); + request.data.dsgetdcname.flags = flags; request.flags |= DS_DIRECTORY_SERVICE_REQUIRED; @@ -553,7 +553,15 @@ static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags) /* Display response */ - d_printf("%s\n", response.data.dc_name); + d_printf("%s\n", response.data.dsgetdcname.dc_unc); + d_printf("%s\n", response.data.dsgetdcname.dc_address); + d_printf("%d\n", response.data.dsgetdcname.dc_address_type); + d_printf("%s\n", response.data.dsgetdcname.domain_guid); + d_printf("%s\n", response.data.dsgetdcname.domain_name); + d_printf("%s\n", response.data.dsgetdcname.forest_name); + d_printf("0x%08x\n", response.data.dsgetdcname.dc_flags); + d_printf("%s\n", response.data.dsgetdcname.dc_site_name); + d_printf("%s\n", response.data.dsgetdcname.client_site_name); return true; } diff --git a/source3/nsswitch/winbind_krb5_locator.c b/source3/nsswitch/winbind_krb5_locator.c index 990c2cae50..b9e35bdec5 100644 --- a/source3/nsswitch/winbind_krb5_locator.c +++ b/source3/nsswitch/winbind_krb5_locator.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. kerberos locator plugin - Copyright (C) Guenther Deschner 2007 + Copyright (C) Guenther Deschner 2007-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 @@ -18,6 +18,7 @@ */ #include "nsswitch/winbind_client.h" +#include "libwbclient/wbclient.h" #ifndef DEBUG_KRB5 #undef DEBUG_KRB5 @@ -244,37 +245,50 @@ static void smb_krb5_locator_close(void *private_data) static bool ask_winbind(const char *realm, char **dcname) { - NSS_STATUS status; - struct winbindd_request request; - struct winbindd_response response; + wbcErr wbc_status; + const char *dc = NULL; + struct wbcDomainControllerInfoEx *dc_info = NULL; + uint32_t flags; - ZERO_STRUCT(request); - ZERO_STRUCT(response); + flags = WBC_LOOKUP_DC_KDC_REQUIRED | + WBC_LOOKUP_DC_IS_DNS_NAME | + WBC_LOOKUP_DC_RETURN_DNS_NAME | + WBC_LOOKUP_DC_IP_REQUIRED; - request.flags = 0x40020600; - /* DS_KDC_REQUIRED | - DS_IS_DNS_NAME | - DS_RETURN_DNS_NAME | - DS_IP_REQUIRED */ + wbc_status = wbcLookupDomainControllerEx(realm, NULL, NULL, flags, &dc_info); - strncpy(request.domain_name, realm, - sizeof(request.domain_name)-1); - - status = winbindd_request_response(WINBINDD_DSGETDCNAME, - &request, &response); - if (status != NSS_STATUS_SUCCESS) { + if (!WBC_ERROR_IS_OK(wbc_status)) { #ifdef DEBUG_KRB5 fprintf(stderr,"[%5u]: smb_krb5_locator_lookup: failed with: %s\n", - (unsigned int)getpid(), nss_err_str(status)); + (unsigned int)getpid(), wbcErrorString(wbc_status)); #endif return false; } - *dcname = strdup(response.data.dc_name); + if (dc_info->dc_address) { + dc = dc_info->dc_address; + if (dc[0] == '\\') dc++; + if (dc[0] == '\\') dc++; + } + + if (!dc && dc_info->dc_unc) { + dc = dc_info->dc_unc; + if (dc[0] == '\\') dc++; + if (dc[0] == '\\') dc++; + } + + if (!dc) { + wbcFreeMemory(dc_info); + return false; + } + + *dcname = strdup(dc); if (!*dcname) { + wbcFreeMemory(dc_info); return false; } + wbcFreeMemory(dc_info); return true; } diff --git a/source3/nsswitch/winbind_nss_config.h b/source3/nsswitch/winbind_nss_config.h index 64d52af771..bed507fdeb 100644 --- a/source3/nsswitch/winbind_nss_config.h +++ b/source3/nsswitch/winbind_nss_config.h @@ -39,7 +39,7 @@ /* Include header files from data in config.h file */ #ifndef NO_CONFIG_H -#include "lib/replace/replace.h" +#include "../replace/replace.h" #endif #include "system/filesys.h" diff --git a/source3/nsswitch/winbind_nss_irix.c b/source3/nsswitch/winbind_nss_irix.c index 4726c1e13f..5bc0fa54da 100644 --- a/source3/nsswitch/winbind_nss_irix.c +++ b/source3/nsswitch/winbind_nss_irix.c @@ -32,7 +32,6 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #endif #ifdef HAVE_NS_API_H -#undef VOLATILE #undef STATIC #undef DYNAMIC #include diff --git a/source3/nsswitch/winbind_struct_protocol.h b/source3/nsswitch/winbind_struct_protocol.h index e81813c77b..ff52dbddaf 100644 --- a/source3/nsswitch/winbind_struct_protocol.h +++ b/source3/nsswitch/winbind_struct_protocol.h @@ -313,6 +313,12 @@ struct winbindd_request { uint32_t initial_blob_len; /* blobs in extra_data */ uint32_t challenge_blob_len; } ccache_ntlm_auth; + struct { + fstring domain_name; + fstring domain_guid; + fstring site_name; + uint32_t flags; + } dsgetdcname; /* padding -- needed to fix alignment between 32bit and 64bit libs. The size is the sizeof the union without the padding aligned on @@ -453,6 +459,17 @@ struct winbindd_response { struct { uint32_t auth_blob_len; /* blob in extra_data */ } ccache_ntlm_auth; + struct { + fstring dc_unc; + fstring dc_address; + uint32_t dc_address_type; + fstring domain_guid; + fstring domain_name; + fstring forest_name; + uint32_t dc_flags; + fstring dc_site_name; + fstring client_site_name; + } dsgetdcname; } data; /* Variable length return data */ diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c index 7d42381986..2f82997aaf 100644 --- a/source3/nsswitch/wins.c +++ b/source3/nsswitch/wins.c @@ -20,7 +20,6 @@ #include "includes.h" #ifdef HAVE_NS_API_H -#undef VOLATILE #include #endif diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 60a1fa4858..d91d34d29b 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -52,6 +52,7 @@ */ #include "includes.h" +#include "printing.h" bool bLoaded = False; @@ -340,6 +341,7 @@ struct global { int iKeepalive; int iminreceivefile; struct param_opt_struct *param_opt; + int cups_connection_timeout; }; static struct global Globals; @@ -2594,6 +2596,15 @@ static struct parm_struct parm_table[] = { .enum_list = NULL, .flags = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL, }, + { + .label = "cups connection timeout", + .type = P_INTEGER, + .p_class = P_GLOBAL, + .ptr = &Globals.cups_connection_timeout, + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED, + }, { .label = "iprint server", .type = P_STRING, @@ -4561,6 +4572,54 @@ static void init_printer_values(struct service *pService) } } +/** + * Free the allocated data for one parameter for a given share. + */ +static void free_parameter(int snum, struct parm_struct parm) +{ + void *parm_ptr; + + if (parm.ptr == NULL); { + return; + } + + if (snum < 0) { + parm_ptr = parm.ptr; + } else if (parm.p_class != P_LOCAL) { + return; + } else { + parm_ptr = lp_local_ptr(snum, parm.ptr); + } + + if ((parm.type == P_STRING) || + (parm.type == P_USTRING)) + { + string_free((char**)parm_ptr); + } else if (parm.type == P_LIST) { + TALLOC_FREE(*((char***)parm_ptr)); + } +} + +/** + * Free the allocated parameter data for a share. + */ +static void free_parameters(int snum) +{ + uint32_t i; + + for (i=0; parm_table[i].label; i++) { + free_parameter(snum, parm_table[i]); + } +} + +/** + * Free the allocated global parameters. + */ +static void free_global_parameters(void) +{ + free_parameters(GLOBAL_SECTION_SNUM); +} + /*************************************************************************** Initialise the global parameter structure. ***************************************************************************/ @@ -4585,14 +4644,7 @@ static void init_globals(bool first_time_only) } done_init = True; } else { - for (i = 0; parm_table[i].label; i++) { - if ((parm_table[i].type == P_STRING || - parm_table[i].type == P_USTRING) && - parm_table[i].ptr) - { - string_free((char **)parm_table[i].ptr); - } - } + free_global_parameters(); } memset((void *)&Globals, '\0', sizeof(Globals)); @@ -4794,6 +4846,7 @@ static void init_globals(bool first_time_only) * to never expire, though, when this runs out the afs client will * forget the token. Set to 0 to get NEVERDATE.*/ Globals.iAfsTokenLifetime = 604800; + Globals.cups_connection_timeout = CUPS_DEFAULT_CONNECTION_TIMEOUT; /* these parameters are set to defaults that are more appropriate for the increasing samba install base: @@ -5235,6 +5288,7 @@ FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList) FN_LOCAL_STRING(lp_cups_options, szCupsOptions) FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer) FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer) +FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout) FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket) FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses) FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering) @@ -5377,6 +5431,7 @@ static bool do_section(const char *pszSectionName, void *userdata); static void init_copymap(struct service *pservice); static bool hash_a_service(const char *name, int number); static void free_service_byindex(int iService); +static void free_param_opts(struct param_opt_struct **popts); static char * canonicalize_servicename(const char *name); static void show_parameter(int parmIndex); static bool is_synonym_of(int parm1, int parm2, bool *inverse); @@ -5631,14 +5686,42 @@ static void init_service(struct service *pservice) copy_service(pservice, &sDefault, NULL); } + +/** + * free a param_opts structure. + * param_opts handling should be moved to talloc; + * then this whole functions reduces to a TALLOC_FREE(). + */ + +static void free_param_opts(struct param_opt_struct **popts) +{ + struct param_opt_struct *opt, *next_opt; + + if (popts == NULL) { + return; + } + + if (*popts != NULL) { + DEBUG(5, ("Freeing parametrics:\n")); + } + opt = *popts; + while (opt != NULL) { + string_free(&opt->key); + string_free(&opt->value); + TALLOC_FREE(opt->list); + next_opt = opt->next; + SAFE_FREE(opt); + opt = next_opt; + } + *popts = NULL; +} + /*************************************************************************** Free the dynamically allocated parts of a service struct. ***************************************************************************/ static void free_service(struct service *pservice) { - int i; - struct param_opt_struct *data, *pdata; if (!pservice) return; @@ -5646,36 +5729,12 @@ static void free_service(struct service *pservice) DEBUG(5, ("free_service: Freeing service %s\n", pservice->szService)); + free_parameters(getservicebyname(pservice->szService, NULL)); + string_free(&pservice->szService); bitmap_free(pservice->copymap); - for (i = 0; parm_table[i].label; i++) { - if ((parm_table[i].type == P_STRING || - parm_table[i].type == P_USTRING) && - parm_table[i].p_class == P_LOCAL) - string_free((char **) - (((char *)pservice) + - PTR_DIFF(parm_table[i].ptr, &sDefault))); - else if (parm_table[i].type == P_LIST && - parm_table[i].p_class == P_LOCAL) - TALLOC_FREE(*((char ***) - (((char *)pservice) + - PTR_DIFF(parm_table[i].ptr, - &sDefault)))); - } - - data = pservice->param_opt; - if (data) - DEBUG(5,("Freeing parametrics:\n")); - while (data) { - DEBUG(5,("[%s = %s]\n", data->key, data->value)); - string_free(&data->key); - string_free(&data->value); - TALLOC_FREE(data->list); - pdata = data->next; - SAFE_FREE(data); - data = pdata; - } + free_param_opts(&pservice->param_opt); ZERO_STRUCTP(pservice); } @@ -5717,7 +5776,6 @@ static int add_a_service(const struct service *pservice, const char *name) int i; struct service tservice; int num_to_alloc = iNumServices + 1; - struct param_opt_struct *data, *pdata; tservice = *pservice; @@ -5727,16 +5785,7 @@ static int add_a_service(const struct service *pservice, const char *name) if (i >= 0) { /* Clean all parametric options for service */ /* They will be added during parsing again */ - data = ServicePtrs[i]->param_opt; - while (data) { - string_free(&data->key); - string_free(&data->value); - TALLOC_FREE(data->list); - pdata = data->next; - SAFE_FREE(data); - data = pdata; - } - ServicePtrs[i]->param_opt = NULL; + free_param_opts(&ServicePtrs[i]->param_opt); return (i); } } @@ -6395,13 +6444,51 @@ static int getservicebyname(const char *pszServiceName, struct service *pservice If pcopymapDest is NULL then copy all fields ***************************************************************************/ +/** + * Add a parametric option to a param_opt_struct, + * replacing old value, if already present. + */ +static void set_param_opt(struct param_opt_struct **opt_list, + const char *opt_name, + const char *opt_value) +{ + struct param_opt_struct *new_opt, *opt; + bool not_added; + + if (opt_list == NULL) { + return; + } + + opt = *opt_list; + not_added = true; + + /* Traverse destination */ + while (opt) { + /* If we already have same option, override it */ + if (strwicmp(opt->key, opt_name) == 0) { + string_free(&opt->value); + TALLOC_FREE(opt->list); + opt->value = SMB_STRDUP(opt_value); + not_added = false; + break; + } + opt = opt->next; + } + if (not_added) { + new_opt = SMB_XMALLOC_P(struct param_opt_struct); + new_opt->key = SMB_STRDUP(opt_name); + new_opt->value = SMB_STRDUP(opt_value); + new_opt->list = NULL; + DLIST_ADD(*opt_list, new_opt); + } +} + static void copy_service(struct service *pserviceDest, struct service *pserviceSource, struct bitmap *pcopymapDest) { int i; bool bcopyall = (pcopymapDest == NULL); - struct param_opt_struct *data, *pdata, *paramo; - bool not_added; + struct param_opt_struct *data; for (i = 0; parm_table[i].label; i++) if (parm_table[i].ptr && parm_table[i].p_class == P_LOCAL && @@ -6442,7 +6529,7 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS break; case P_LIST: TALLOC_FREE(*((char ***)dest_ptr)); - str_list_copy(NULL, (char ***)dest_ptr, + *((char ***)dest_ptr) = str_list_copy(NULL, *(const char ***)src_ptr); break; default: @@ -6459,27 +6546,7 @@ static void copy_service(struct service *pserviceDest, struct service *pserviceS data = pserviceSource->param_opt; while (data) { - not_added = True; - pdata = pserviceDest->param_opt; - /* Traverse destination */ - while (pdata) { - /* If we already have same option, override it */ - if (strwicmp(pdata->key, data->key) == 0) { - string_free(&pdata->value); - TALLOC_FREE(data->list); - pdata->value = SMB_STRDUP(data->value); - not_added = False; - break; - } - pdata = pdata->next; - } - if (not_added) { - paramo = SMB_XMALLOC_P(struct param_opt_struct); - paramo->key = SMB_STRDUP(data->key); - paramo->value = SMB_STRDUP(data->value); - paramo->list = NULL; - DLIST_ADD(pserviceDest->param_opt, paramo); - } + set_param_opt(&pserviceDest->param_opt, data->key, data->value); data = data->next; } } @@ -6547,7 +6614,7 @@ static struct smbconf_ctx *lp_smbconf_ctx(void) return conf_ctx; } -static bool process_registry_service(struct smbconf_service *service) +static bool process_smbconf_service(struct smbconf_service *service) { uint32_t count; bool ret; @@ -6603,7 +6670,7 @@ static bool process_registry_globals(void) goto done; } - ret = process_registry_service(service); + ret = process_smbconf_service(service); if (!ret) { goto done; } @@ -6641,7 +6708,7 @@ static bool process_registry_shares(void) if (strequal(service[count]->name, GLOBAL_NAME)) { continue; } - ret = process_registry_service(service[count]); + ret = process_smbconf_service(service[count]); if (!ret) { goto done; } @@ -6863,7 +6930,7 @@ static bool handle_include(int snum, const char *pszParmValue, char **ptr) string_set(ptr, fname); - if (file_exist(fname, NULL)) { + if (file_exist(fname)) { bool ret = pm_process(fname, do_section, do_parameter, NULL); SAFE_FREE(fname); return ret; @@ -7144,14 +7211,11 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue int parmnum, i; void *parm_ptr = NULL; /* where we are going to store the result */ void *def_ptr = NULL; - struct param_opt_struct *paramo, *data; - bool not_added; + struct param_opt_struct **opt_list; parmnum = map_parameter(pszParmName); if (parmnum < 0) { - TALLOC_CTX *frame; - if (strchr(pszParmName, ':') == NULL) { DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName)); @@ -7162,37 +7226,10 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue * We've got a parametric option */ - frame = talloc_stackframe(); + opt_list = (snum < 0) + ? &Globals.param_opt : &ServicePtrs[snum]->param_opt; + set_param_opt(opt_list, pszParmName, pszParmValue); - not_added = True; - data = (snum < 0) - ? Globals.param_opt : ServicePtrs[snum]->param_opt; - /* Traverse destination */ - while (data) { - /* If we already have same option, override it */ - if (strwicmp(data->key, pszParmName) == 0) { - string_free(&data->value); - TALLOC_FREE(data->list); - data->value = SMB_STRDUP(pszParmValue); - not_added = False; - break; - } - data = data->next; - } - if (not_added) { - paramo = SMB_XMALLOC_P(struct param_opt_struct); - paramo->key = SMB_STRDUP(pszParmName); - paramo->value = SMB_STRDUP(pszParmValue); - paramo->list = NULL; - if (snum < 0) { - DLIST_ADD(Globals.param_opt, paramo); - } else { - DLIST_ADD(ServicePtrs[snum]->param_opt, - paramo); - } - } - - TALLOC_FREE(frame); return (True); } @@ -7213,9 +7250,7 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue pszParmName)); return (True); } - parm_ptr = - ((char *)ServicePtrs[snum]) + PTR_DIFF(def_ptr, - &sDefault); + parm_ptr = lp_local_ptr(snum, def_ptr); } if (snum >= 0) { @@ -7388,7 +7423,7 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2) return (*((char *)ptr1) == *((char *)ptr2)); case P_LIST: - return str_list_compare(*(char ***)ptr1, *(char ***)ptr2); + return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2); case P_STRING: case P_USTRING: @@ -7477,8 +7512,8 @@ static bool is_default(int i) return False; switch (parm_table[i].type) { case P_LIST: - return str_list_compare (parm_table[i].def.lvalue, - *(char ***)parm_table[i].ptr); + return str_list_equal((const char **)parm_table[i].def.lvalue, + *(const char ***)parm_table[i].ptr); case P_STRING: case P_USTRING: return strequal(parm_table[i].def.svalue, @@ -7813,7 +7848,7 @@ static void lp_add_auto_services(char *str) Auto-load one printer. ***************************************************************************/ -void lp_add_one_printer(char *name, char *comment) +void lp_add_one_printer(const char *name, const char *comment, void *pdata) { int printers = lp_servicenumber(PRINTERS_NAME); int i; @@ -7892,9 +7927,8 @@ static void lp_save_defaults(void) continue; switch (parm_table[i].type) { case P_LIST: - str_list_copy( - NULL, &(parm_table[i].def.lvalue), - *(const char ***)parm_table[i].ptr); + parm_table[i].def.lvalue = str_list_copy( + NULL, *(const char ***)parm_table[i].ptr); break; case P_STRING: case P_USTRING: @@ -8351,7 +8385,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i return -1; } - lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE); + lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL); close(fd); if (lines == NULL) { @@ -8366,7 +8400,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i /* Should we allow printers to be shared... ? */ ctx = talloc_init("usershare_sd_xctx"); if (!ctx) { - file_lines_free(lines); + TALLOC_FREE(lines); return 1; } @@ -8374,11 +8408,11 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i iService, lines, numlines, &sharepath, &comment, &psd, &guest_ok) != USERSHARE_OK) { talloc_destroy(ctx); - file_lines_free(lines); + TALLOC_FREE(lines); return -1; } - file_lines_free(lines); + TALLOC_FREE(lines); /* Everything ok - add the service possibly using a template. */ if (iService < 0) { @@ -8721,17 +8755,7 @@ void gfree_loadparm(void) /* Now release all resources allocated to global parameters and the default service */ - for (i = 0; parm_table[i].label; i++) - { - if ( parm_table[i].type == P_STRING - || parm_table[i].type == P_USTRING ) - { - string_free( (char**)parm_table[i].ptr ); - } - else if (parm_table[i].type == P_LIST) { - TALLOC_FREE( *((char***)parm_table[i].ptr) ); - } - } + free_global_parameters(); } @@ -8752,9 +8776,6 @@ bool lp_is_in_client(void) return in_client; } - - - /*************************************************************************** Load the services array from the services file. Return True on success, False on failure. @@ -8770,7 +8791,6 @@ bool lp_load_ex(const char *pszFname, { char *n2 = NULL; bool bRetval; - struct param_opt_struct *data, *pdata; bRetval = False; @@ -8788,22 +8808,11 @@ bool lp_load_ex(const char *pszFname, lp_save_defaults(); } + free_param_opts(&Globals.param_opt); + /* We get sections first, so have to start 'behind' to make up */ iServiceIndex = -1; - if (Globals.param_opt != NULL) { - data = Globals.param_opt; - while (data) { - string_free(&data->key); - string_free(&data->value); - TALLOC_FREE(data->list); - pdata = data->next; - SAFE_FREE(data); - data = pdata; - } - Globals.param_opt = NULL; - } - if (lp_config_backend_is_file()) { n2 = alloc_sub_basic(get_current_username(), current_user_info.domain, diff --git a/source3/param/params.c b/source3/param/params.c deleted file mode 100644 index 478376c9e9..0000000000 --- a/source3/param/params.c +++ /dev/null @@ -1,590 +0,0 @@ -/* -------------------------------------------------------------------------- ** - * Microsoft Network Services for Unix, AKA., Andrew Tridgell's SAMBA. - * - * This module Copyright (C) 1990-1998 Karl Auer - * - * Rewritten almost completely by Christopher R. Hertel, 1997. - * This module Copyright (C) 1997-1998 by Christopher R. Hertel - * - * -------------------------------------------------------------------------- ** - * - * 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 . - * - * -------------------------------------------------------------------------- ** - * - * Module name: params - * - * -------------------------------------------------------------------------- ** - * - * This module performs lexical analysis and initial parsing of a - * Windows-like parameter file. It recognizes and handles four token - * types: section-name, parameter-name, parameter-value, and - * end-of-file. Comments and line continuation are handled - * internally. - * - * The entry point to the module is function pm_process(). This - * function opens the source file, calls the Parse() function to parse - * the input, and then closes the file when either the EOF is reached - * or a fatal error is encountered. - * - * A sample parameter file might look like this: - * - * [section one] - * parameter one = value string - * parameter two = another value - * [section two] - * new parameter = some value or t'other - * - * The parameter file is divided into sections by section headers: - * section names enclosed in square brackets (eg. [section one]). - * Each section contains parameter lines, each of which consist of a - * parameter name and value delimited by an equal sign. Roughly, the - * syntax is: - * - * :== {
} EOF - * - *
:==
{ } - * - *
:== '[' NAME ']' - * - * :== NAME '=' VALUE '\n' - * - * Blank lines and comment lines are ignored. Comment lines are lines - * beginning with either a semicolon (';') or a pound sign ('#'). - * - * All whitespace in section names and parameter names is compressed - * to single spaces. Leading and trailing whitespace is stipped from - * both names and values. - * - * Only the first equals sign in a parameter line is significant. - * Parameter values may contain equals signs, square brackets and - * semicolons. Internal whitespace is retained in parameter values, - * with the exception of the '\r' character, which is stripped for - * historic reasons. Parameter names may not start with a left square - * bracket, an equal sign, a pound sign, or a semicolon, because these - * are used to identify other tokens. - * - * -------------------------------------------------------------------------- ** - */ - -#include "includes.h" - -/* -------------------------------------------------------------------------- ** - * Constants... - */ - -#define BUFR_INC 1024 - - -/* -------------------------------------------------------------------------- ** - * Variables... - * - * DEBUGLEVEL - The ubiquitous DEBUGLEVEL. This determines which DEBUG() - * messages will be produced. - * bufr - pointer to a global buffer. This is probably a kludge, - * but it was the nicest kludge I could think of (for now). - * bSize - The size of the global buffer . - */ - -/* we can't use FILE* due to the 256 fd limit - use this cheap hack - instead */ -typedef struct { - char *buf; - char *p; - size_t size; - char *end_section_p; -} myFILE; - -static int mygetc(myFILE *f) -{ - if (f->p >= f->buf+f->size) - return EOF; - /* be sure to return chars >127 as positive values */ - return (int)( *(f->p++) & 0x00FF ); -} - -static void myfile_close(myFILE *f) -{ - if (!f) - return; - SAFE_FREE(f->buf); - SAFE_FREE(f); -} - -/* Find the end of the section. We must use mb functions for this. */ -static int FindSectionEnd(myFILE *f) -{ - f->end_section_p = strchr_m(f->p, ']'); - return f->end_section_p ? 1 : 0; -} - -static int AtSectionEnd(myFILE *f) -{ - if (f->p == f->end_section_p + 1) { - f->end_section_p = NULL; - return 1; - } - return 0; -} - -/* -------------------------------------------------------------------------- ** - * Functions... - */ - /* ------------------------------------------------------------------------ ** - * Scan past whitespace (see ctype(3C)) and return the first non-whitespace - * character, or newline, or EOF. - * - * Input: InFile - Input source. - * - * Output: The next non-whitespace character in the input stream. - * - * Notes: Because the config files use a line-oriented grammar, we - * explicitly exclude the newline character from the list of - * whitespace characters. - * - Note that both EOF (-1) and the nul character ('\0') are - * considered end-of-file markers. - * - * ------------------------------------------------------------------------ ** - */ - -static int EatWhitespace( myFILE *InFile ) -{ - int c; - - for( c = mygetc( InFile ); isspace( c ) && ('\n' != c); c = mygetc( InFile ) ) - ; - return( c ); -} - - /* ------------------------------------------------------------------------ ** - * Scan to the end of a comment. - * - * Input: InFile - Input source. - * - * Output: The character that marks the end of the comment. Normally, - * this will be a newline, but it *might* be an EOF. - * - * Notes: Because the config files use a line-oriented grammar, we - * explicitly exclude the newline character from the list of - * whitespace characters. - * - Note that both EOF (-1) and the nul character ('\0') are - * considered end-of-file markers. - * - * ------------------------------------------------------------------------ ** - */ - -static int EatComment( myFILE *InFile ) -{ - int c; - - for( c = mygetc( InFile ); ('\n'!=c) && (EOF!=c) && (c>0); c = mygetc( InFile ) ) - ; - return( c ); -} - -/***************************************************************************** - * Scan backards within a string to discover if the last non-whitespace - * character is a line-continuation character ('\\'). - * - * Input: line - A pointer to a buffer containing the string to be - * scanned. - * pos - This is taken to be the offset of the end of the - * string. This position is *not* scanned. - * - * Output: The offset of the '\\' character if it was found, or -1 to - * indicate that it was not. - * - *****************************************************************************/ - -static int Continuation(uint8_t *line, int pos ) -{ - pos--; - while( (pos >= 0) && isspace((int)line[pos])) - pos--; - - return (((pos >= 0) && ('\\' == line[pos])) ? pos : -1 ); -} - -/* ------------------------------------------------------------------------ ** - * Scan a section name, and pass the name to function sfunc(). - * - * Input: InFile - Input source. - * sfunc - Pointer to the function to be called if the section - * name is successfully read. - * - * Output: True if the section name was read and True was returned from - * . False if failed or if a lexical error was - * encountered. - * - * ------------------------------------------------------------------------ ** - */ - -static bool Section( DATA_BLOB *buf, myFILE *InFile, bool (*sfunc)(const char *, void *), void *userdata ) -{ - int c; - int i; - int end; - const char *func = "params.c:Section() -"; - - i = 0; /* is the offset of the next free byte in bufr[] and */ - end = 0; /* is the current "end of string" offset. In most */ - /* cases these will be the same, but if the last */ - /* character written to bufr[] is a space, then */ - /* will be one less than . */ - - - /* Find the end of the section. We must use mb functions for this. */ - if (!FindSectionEnd(InFile)) { - DEBUG(0, ("%s No terminating ']' character in section.\n", func) ); - return False; - } - - c = EatWhitespace( InFile ); /* We've already got the '['. Scan */ - /* past initial white space. */ - - while( (EOF != c) && (c > 0) ) { - /* Check that the buffer is big enough for the next character. */ - if( i > (buf->length - 2) ) { - uint8_t *tb = (uint8_t *)SMB_REALLOC_KEEP_OLD_ON_ERROR(buf->data, buf->length+BUFR_INC ); - if(!tb) { - DEBUG(0, ("%s Memory re-allocation failure.", func) ); - return False; - } - buf->data = tb; - buf->length += BUFR_INC; - } - - /* Handle a single character other than section end. */ - switch( c ) { - case '\n': /* Got newline before closing ']'. */ - i = Continuation( buf->data, i ); /* Check for line continuation. */ - if( i < 0 ) { - buf->data[end] = '\0'; - DEBUG(0, ("%s Badly formed line in configuration file: %s\n", func, buf->data )); - return False; - } - end = ( (i > 0) && (' ' == buf->data[i - 1]) ) ? (i - 1) : (i); - c = mygetc( InFile ); /* Continue with next line. */ - break; - - default: /* All else are a valid name chars. */ - if(isspace( c )) { - /* One space per whitespace region. */ - buf->data[end] = ' '; - i = end + 1; - c = EatWhitespace( InFile ); - } else { - buf->data[i++] = c; - end = i; - c = mygetc( InFile ); - } - } - - if (AtSectionEnd(InFile)) { - /* Got to the closing bracket. */ - buf->data[end] = '\0'; - if( 0 == end ) { - /* Don't allow an empty name. */ - DEBUG(0, ("%s Empty section name in configuration file.\n", func )); - return False; - } - if( !sfunc((char *)buf->data, userdata) ) /* Got a valid name. Deal with it. */ - return False; - EatComment( InFile ); /* Finish off the line. */ - return True; - } - - } - - /* We arrive here if we've met the EOF before the closing bracket. */ - DEBUG(0, ("%s Unexpected EOF in the configuration file: %s\n", func, buf->data )); - return False; -} - -/* ------------------------------------------------------------------------ ** - * Scan a parameter name and value, and pass these two fields to pfunc(). - * - * Input: InFile - The input source. - * pfunc - A pointer to the function that will be called to - * process the parameter, once it has been scanned. - * c - The first character of the parameter name, which - * would have been read by Parse(). Unlike a comment - * line or a section header, there is no lead-in - * character that can be discarded. - * - * Output: True if the parameter name and value were scanned and processed - * successfully, else False. - * - * Notes: This function is in two parts. The first loop scans the - * parameter name. Internal whitespace is compressed, and an - * equal sign (=) terminates the token. Leading and trailing - * whitespace is discarded. The second loop scans the parameter - * value. When both have been successfully identified, they are - * passed to pfunc() for processing. - * - * ------------------------------------------------------------------------ ** - */ - -static bool Parameter( DATA_BLOB *buf, myFILE *InFile, bool (*pfunc)(const char *, const char *, void *), int c, void *userdata ) -{ - int i = 0; /* Position within bufr. */ - int end = 0; /* bufr[end] is current end-of-string. */ - int vstart = 0; /* Starting position of the parameter value. */ - const char *func = "params.c:Parameter() -"; - - /* Read the parameter name. */ - while( 0 == vstart ) { - /* Loop until we've found the start of the value. */ - if( i > (buf->length - 2) ) { - /* Ensure there's space for next char. */ - uint8_t *tb = (uint8_t *)SMB_REALLOC_KEEP_OLD_ON_ERROR( buf->data, buf->length + BUFR_INC ); - if (!tb) { - DEBUG(0, ("%s Memory re-allocation failure.", func) ); - return False; - } - buf->data = tb; - buf->length += BUFR_INC; - } - - switch(c) { - case '=': /* Equal sign marks end of param name. */ - if( 0 == end ) { - /* Don't allow an empty name. */ - DEBUG(0, ("%s Invalid parameter name in config. file.\n", func )); - return False; - } - buf->data[end++] = '\0'; /* Mark end of string & advance. */ - i = end; /* New string starts here. */ - vstart = end; /* New string is parameter value. */ - buf->data[i] = '\0'; /* New string is nul, for now. */ - break; - - case '\n': /* Find continuation char, else error. */ - i = Continuation( buf->data, i ); - if( i < 0 ) { - buf->data[end] = '\0'; - DEBUG(1,("%s Ignoring badly formed line in configuration file: %s\n", func, buf->data )); - return True; - } - end = ( (i > 0) && (' ' == buf->data[i - 1]) ) ? (i - 1) : (i); - c = mygetc( InFile ); /* Read past eoln. */ - break; - - case '\0': /* Shouldn't have EOF within param name. */ - case EOF: - buf->data[i] = '\0'; - DEBUG(1,("%s Unexpected end-of-file at: %s\n", func, buf->data )); - return True; - - default: - if(isspace( c )) { - /* One ' ' per whitespace region. */ - buf->data[end] = ' '; - i = end + 1; - c = EatWhitespace( InFile ); - } else { - buf->data[i++] = c; - end = i; - c = mygetc( InFile ); - } - } - } - - /* Now parse the value. */ - c = EatWhitespace( InFile ); /* Again, trim leading whitespace. */ - while( (EOF !=c) && (c > 0) ) { - if( i > (buf->length - 2) ) { - /* Make sure there's enough room. */ - uint8_t *tb = (uint8_t *)SMB_REALLOC_KEEP_OLD_ON_ERROR( buf->data, buf->length + BUFR_INC ); - if (!tb) { - DEBUG(0, ("%s Memory re-allocation failure.", func)); - return False; - } - buf->data = tb; - buf->length += BUFR_INC; - } - - switch(c) { - case '\r': /* Explicitly remove '\r' because the older */ - c = mygetc( InFile ); /* version called fgets_slash() which also */ - break; /* removes them. */ - - case '\n': /* Marks end of value unless there's a '\'. */ - i = Continuation( buf->data, i ); - if( i < 0 ) { - c = 0; - } else { - for( end = i; (end >= 0) && isspace((int)buf->data[end]); end-- ) - ; - c = mygetc( InFile ); - } - break; - - default: /* All others verbatim. Note that spaces do not advance . This allows trimming */ - buf->data[i++] = c; - if( !isspace( c ) ) /* of whitespace at the end of the line. */ - end = i; - c = mygetc( InFile ); - break; - } - } - buf->data[end] = '\0'; /* End of value. */ - - return( pfunc( (char *)buf->data, (char *)&buf->data[vstart], userdata ) ); /* Pass name & value to pfunc(). */ -} - -/* ------------------------------------------------------------------------ ** - * Scan & parse the input. - * - * Input: InFile - Input source. - * sfunc - Function to be called when a section name is scanned. - * See Section(). - * pfunc - Function to be called when a parameter is scanned. - * See Parameter(). - * - * Output: True if the file was successfully scanned, else False. - * - * Notes: The input can be viewed in terms of 'lines'. There are four - * types of lines: - * Blank - May contain whitespace, otherwise empty. - * Comment - First non-whitespace character is a ';' or '#'. - * The remainder of the line is ignored. - * Section - First non-whitespace character is a '['. - * Parameter - The default case. - * - * ------------------------------------------------------------------------ ** - */ - -static bool Parse( DATA_BLOB *buf, myFILE *InFile, - bool (*sfunc)(const char *, void *), - bool (*pfunc)(const char *, const char *, void *), - void *userdata) -{ - int c; - - c = EatWhitespace( InFile ); - while( (EOF != c) && (c > 0) ) { - switch( c ) { - case '\n': /* Blank line. */ - c = EatWhitespace( InFile ); - break; - - case ';': /* Comment line. */ - case '#': - c = EatComment( InFile ); - break; - - case '[': /* Section Header. */ - if( !Section( buf, InFile, sfunc, userdata ) ) - return False; - c = EatWhitespace( InFile ); - break; - - case '\\': /* Bogus backslash. */ - c = EatWhitespace( InFile ); - break; - - default: /* Parameter line. */ - if( !Parameter( buf, InFile, pfunc, c, userdata ) ) - return False; - c = EatWhitespace( InFile ); - break; - } - } - return True; -} - -/* ------------------------------------------------------------------------ ** - * Open a configuration file. - * - * Input: FileName - The pathname of the config file to be opened. - * - * Output: A pointer of type (char **) to the lines of the file - * - * ------------------------------------------------------------------------ ** - */ - -static myFILE *OpenConfFile( const char *FileName ) -{ - const char *func = "params.c:OpenConfFile() -"; - int lvl = lp_is_in_client() ? 1 : 0; - myFILE *ret; - - ret = SMB_MALLOC_P(myFILE); - if (!ret) - return NULL; - - ret->buf = file_load(FileName, &ret->size, 0); - if( NULL == ret->buf ) { - DEBUG( lvl, ("%s Unable to open configuration file \"%s\":\n\t%s\n", - func, FileName, strerror(errno)) ); - SAFE_FREE(ret); - return NULL; - } - - ret->p = ret->buf; - ret->end_section_p = NULL; - return( ret ); -} - -/* ------------------------------------------------------------------------ ** - * Process the named parameter file. - * - * Input: FileName - The pathname of the parameter file to be opened. - * sfunc - A pointer to a function that will be called when - * a section name is discovered. - * pfunc - A pointer to a function that will be called when - * a parameter name and value are discovered. - * - * Output: TRUE if the file was successfully parsed, else FALSE. - * - * ------------------------------------------------------------------------ ** - */ - -bool pm_process( const char *FileName, - bool (*sfunc)(const char *, void *), - bool (*pfunc)(const char *, const char *, void *), - void *userdata) -{ - int result; - myFILE *InFile; - const char *func = "params.c:pm_process() -"; - DATA_BLOB buf; - - InFile = OpenConfFile( FileName ); /* Open the config file. */ - if( NULL == InFile ) - return False; - - DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) ); - - buf = data_blob(NULL, 256); - - if (buf.data == NULL) { - DEBUG(0,("%s memory allocation failure.\n", func)); - myfile_close(InFile); - return False; - } - - result = Parse( &buf, InFile, sfunc, pfunc, userdata ); - data_blob_free(&buf); - - myfile_close(InFile); - - if( !result ) { - DEBUG(0,("%s Failed. Error returned from params.c:parse().\n", func)); - return False; - } - - return True; -} diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c new file mode 100644 index 0000000000..1ec123e70a --- /dev/null +++ b/source3/param/test_lp_load.c @@ -0,0 +1,88 @@ +/* + * Unix SMB/CIFS implementation. + * Test for lp_load() + * 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 . + */ + +#include "includes.h" + +extern bool AllowDebugChange; + +int main(int argc, const char **argv) +{ + const char *config_file = get_dyn_CONFIGFILE(); + int ret = 0; + poptContext pc; + char *count_str = NULL; + int i, count = 1; + + struct poptOption long_options[] = { + POPT_AUTOHELP + {"count", 'c', POPT_ARG_STRING, &count_str, 1, + "Load config number of times"}, + POPT_COMMON_DEBUGLEVEL + POPT_TABLEEND + }; + + TALLOC_CTX *frame = talloc_stackframe(); + + load_case_tables(); + DEBUGLEVEL_CLASS[DBGC_ALL] = 0; + + pc = poptGetContext(NULL, argc, argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + poptSetOtherOptionHelp(pc, "[OPTION...] "); + + while(poptGetNextOpt(pc) != -1); + + setup_logging(poptGetArg(pc), True); + + if (poptPeekArg(pc)) { + config_file = poptGetArg(pc); + } + + poptFreeContext(pc); + + if (count_str != NULL) { + count = atoi(count_str); + } + + dbf = x_stderr; + /* Don't let the debuglevel be changed by smb.conf. */ + AllowDebugChange = False; + + for (i=0; i < count; i++) { + printf("call lp_load() #%d: ", i+1); + if (!lp_load_with_registry_shares(config_file, + False, /* global only */ + True, /* save defaults */ + False, /*add_ipc */ + True)) /*init globals */ + { + printf("ERROR.\n"); + ret = 1; + goto done; + } + printf("ok.\n"); + } + + +done: + gfree_loadparm(); + TALLOC_FREE(frame); + return ret; +} + diff --git a/source3/passdb/machine_sid.c b/source3/passdb/machine_sid.c index ff2c9bcb0d..c7c3cc474b 100644 --- a/source3/passdb/machine_sid.c +++ b/source3/passdb/machine_sid.c @@ -41,15 +41,15 @@ static bool read_sid_from_file(const char *fname, DOM_SID *sid) int numlines; bool ret; - lines = file_lines_load(fname, &numlines,0); + lines = file_lines_load(fname, &numlines,0, NULL); if (!lines || numlines < 1) { - if (lines) file_lines_free(lines); + if (lines) TALLOC_FREE(lines); return False; } ret = string_to_sid(sid, lines[0]); - file_lines_free(lines); + TALLOC_FREE(lines); return ret; } diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index 4527ae7127..a6adb904e2 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -238,7 +238,7 @@ bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid) if (!dyn_guid) { if (lp_server_role() == ROLE_DOMAIN_PDC) { - smb_uuid_generate_random(&new_guid); + new_guid = GUID_random(); if (!secrets_store_domain_guid(domain, &new_guid)) return False; dyn_guid = (struct GUID *)secrets_fetch(key, &size); @@ -259,6 +259,31 @@ bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid) return True; } +bool secrets_store_local_schannel_key(uint8_t schannel_key[16]) +{ + return secrets_store(SECRETS_LOCAL_SCHANNEL_KEY, schannel_key, 16); +} + +bool secrets_fetch_local_schannel_key(uint8_t schannel_key[16]) +{ + size_t size = 0; + uint8_t *key; + + key = (uint8_t *)secrets_fetch(SECRETS_LOCAL_SCHANNEL_KEY, &size); + if (key == NULL) { + return false; + } + + if (size != 16) { + SAFE_FREE(key); + return false; + } + + memcpy(schannel_key, key, 16); + SAFE_FREE(key); + return true; +} + /** * Form a key for fetching the machine trust account sec channel type * diff --git a/source3/printing/load.c b/source3/printing/load.c index 23144d5a95..fc21f271bd 100644 --- a/source3/printing/load.c +++ b/source3/printing/load.c @@ -60,5 +60,5 @@ void load_printers(void) /* load all printcap printers */ if (lp_load_printers() && lp_servicenumber(PRINTERS_NAME) >= 0) - pcap_printer_fn(lp_add_one_printer); + pcap_printer_fn(lp_add_one_printer, NULL); } diff --git a/source3/printing/notify.c b/source3/printing/notify.c index 23df17c389..f6599c413d 100644 --- a/source3/printing/notify.c +++ b/source3/printing/notify.c @@ -34,6 +34,7 @@ static struct notify_queue { size_t buflen; } *notify_queue_head = NULL; +static struct timed_event *notify_event; static bool create_send_ctx(void) { @@ -214,6 +215,22 @@ void print_notify_send_messages(struct messaging_context *msg_ctx, num_messages = 0; } +/******************************************************************* + Event handler to send the messages. +*******************************************************************/ + +static void print_notify_event_send_messages(struct event_context *event_ctx, + struct timed_event *te, + const struct timeval *now, + void *private_data) +{ + /* Remove this timed event handler. */ + TALLOC_FREE(notify_event); + + change_to_root_user(); + print_notify_send_messages(smbd_messaging_context(), 0); +} + /********************************************************************** deep copy a SPOOLSS_NOTIFY_MSG structure using a TALLOC_CTX *********************************************************************/ @@ -304,6 +321,15 @@ to notify_queue_head\n", msg->type, msg->field, msg->printer)); DLIST_ADD_END(notify_queue_head, pnqueue, struct notify_queue *); num_messages++; + + if (smbd_event_context()) { + /* Add an event for 1 second's time to send this queue. */ + notify_event = event_add_timed(smbd_event_context(), NULL, + timeval_current_ofs(1,0), + "print_notify", + print_notify_event_send_messages, NULL); + } + } static void send_notify_field_values(const char *sharename, uint32 type, diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index ded985c260..1826fa88ed 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -280,7 +280,7 @@ static bool upgrade_to_version_3(void) DEBUG(0,("upgrade_to_version_3: upgrading print tdb's to version 3\n")); for (kbuf = tdb_firstkey(tdb_drivers); kbuf.dptr; - newkey = tdb_nextkey(tdb_drivers, kbuf), safe_free(kbuf.dptr), kbuf=newkey) { + newkey = tdb_nextkey(tdb_drivers, kbuf), free(kbuf.dptr), kbuf=newkey) { dbuf = tdb_fetch(tdb_drivers, kbuf); @@ -807,7 +807,7 @@ int get_ntforms(nt_forms_struct **list) for (kbuf = tdb_firstkey(tdb_forms); kbuf.dptr; - newkey = tdb_nextkey(tdb_forms, kbuf), safe_free(kbuf.dptr), kbuf=newkey) + newkey = tdb_nextkey(tdb_forms, kbuf), free(kbuf.dptr), kbuf=newkey) { if (strncmp((const char *)kbuf.dptr, FORMS_PREFIX, strlen(FORMS_PREFIX)) != 0) continue; @@ -1024,7 +1024,7 @@ int get_ntdrivers(fstring **list, const char *architecture, uint32 version) for (kbuf = tdb_firstkey(tdb_drivers); kbuf.dptr; - newkey = tdb_nextkey(tdb_drivers, kbuf), safe_free(kbuf.dptr), kbuf=newkey) { + newkey = tdb_nextkey(tdb_drivers, kbuf), free(kbuf.dptr), kbuf=newkey) { if (strncmp((const char *)kbuf.dptr, key, strlen(key)) != 0) continue; @@ -1376,7 +1376,8 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n", old_create_time)); } } - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); + fsp = NULL; /* Get file version info (if available) for new file */ filepath = driver_unix_convert(conn,new_file,&stat_buf); @@ -1416,7 +1417,8 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n", new_create_time)); } } - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); + fsp = NULL; if (use_version && (new_major != old_major || new_minor != old_minor)) { /* Compare versions and choose the larger version number */ @@ -1445,7 +1447,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr error_exit: if(fsp) - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); return -1; } @@ -1581,7 +1583,7 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_ DEBUG(10,("get_correct_cversion: Driver file [%s] cversion = %d\n", driverpath, cversion)); - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); close_cnum(conn, user->vuid); unbecome_user(); *perr = WERR_OK; @@ -1591,7 +1593,7 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_ error_exit: if(fsp) - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); close_cnum(conn, user->vuid); unbecome_user(); @@ -3121,8 +3123,7 @@ static void map_single_multi_sz_into_ctr(REGVAL_CTR *ctr, const char *val_name, regval_ctr_delvalue(ctr, val_name); regval_ctr_addvalue(ctr, val_name, REG_MULTI_SZ, (char *) conv_strs, str_size); - safe_free(conv_strs); - + SAFE_FREE(conv_strs); } /**************************************************************************** @@ -3219,7 +3220,7 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2, ZERO_STRUCT( unistr_guid ); - init_unistr2( &unistr_guid, smb_uuid_string(talloc_tos(), guid), + init_unistr2( &unistr_guid, GUID_string(talloc_tos(), &guid), UNI_STR_TERMINATE ); regval_ctr_addvalue(ctr, "objectGUID", REG_SZ, @@ -3534,7 +3535,7 @@ bool is_printer_published(Printer_entry *print_hnd, int snum, case REG_SZ: rpcstr_pull( guid_str, regval_data_p(guid_val), sizeof(guid_str)-1, -1, STR_TERMINATE ); - ret = smb_string_to_uuid( guid_str, guid ); + ret = NT_STATUS_IS_OK(GUID_from_string( guid_str, guid )); break; case REG_BINARY: if ( regval_size(guid_val) != sizeof(struct GUID) ) { @@ -3839,7 +3840,7 @@ static int unpack_values(NT_PRINTER_DATA *printer_data, const uint8 *buf, int bu memcpy( &guid, data_p, sizeof(struct GUID) ); init_unistr2( &unistr_guid, - smb_uuid_string(talloc_tos(), guid), + GUID_string(talloc_tos(), &guid), UNI_STR_TERMINATE ); regval_ctr_addvalue( printer_data->keys[key_index].values, @@ -3923,10 +3924,10 @@ static void map_to_os2_driver(fstring drivername) return; } - lines = file_lines_load(mapfile, &numlines,0); + lines = file_lines_load(mapfile, &numlines,0,NULL); if (numlines == 0 || lines == NULL) { DEBUG(0,("No entries in OS/2 driver map %s\n",mapfile)); - SAFE_FREE(lines); + TALLOC_FREE(lines); return; } @@ -3970,12 +3971,12 @@ static void map_to_os2_driver(fstring drivername) DEBUG(3,("Mapped windows driver %s to os2 driver%s\n",drivername,os2_name)); set_last_from_to(drivername,os2_name); fstrcpy(drivername,os2_name); - file_lines_free(lines); + TALLOC_FREE(lines); return; } } - file_lines_free(lines); + TALLOC_FREE(lines); } /**************************************************************************** @@ -5491,7 +5492,7 @@ static SEC_DESC_BUF *construct_default_printer_sdb(TALLOC_CTX *ctx) { SEC_ACE ace[5]; /* max number of ace entries */ int i = 0; - SEC_ACCESS sa; + uint32_t sa; SEC_ACL *psa = NULL; SEC_DESC_BUF *sdb = NULL; SEC_DESC *psd = NULL; @@ -5500,7 +5501,7 @@ static SEC_DESC_BUF *construct_default_printer_sdb(TALLOC_CTX *ctx) /* Create an ACE where Everyone is allowed to print */ - init_sec_access(&sa, PRINTER_ACE_PRINT); + sa = PRINTER_ACE_PRINT; init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, SEC_ACE_FLAG_CONTAINER_INHERIT); @@ -5512,7 +5513,7 @@ static SEC_DESC_BUF *construct_default_printer_sdb(TALLOC_CTX *ctx) sid_copy(&domadmins_sid, get_global_sam_sid()); sid_append_rid(&domadmins_sid, DOMAIN_GROUP_RID_ADMINS); - init_sec_access(&sa, PRINTER_ACE_FULL_CONTROL); + sa = PRINTER_ACE_FULL_CONTROL; init_sec_ace(&ace[i++], &domadmins_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, SEC_ACE_FLAG_OBJECT_INHERIT | SEC_ACE_FLAG_INHERIT_ONLY); @@ -5522,7 +5523,7 @@ static SEC_DESC_BUF *construct_default_printer_sdb(TALLOC_CTX *ctx) else if (secrets_fetch_domain_sid(lp_workgroup(), &adm_sid)) { sid_append_rid(&adm_sid, DOMAIN_USER_RID_ADMIN); - init_sec_access(&sa, PRINTER_ACE_FULL_CONTROL); + sa = PRINTER_ACE_FULL_CONTROL; init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, SEC_ACE_FLAG_OBJECT_INHERIT | SEC_ACE_FLAG_INHERIT_ONLY); @@ -5532,7 +5533,7 @@ static SEC_DESC_BUF *construct_default_printer_sdb(TALLOC_CTX *ctx) /* add BUILTIN\Administrators as FULL CONTROL */ - init_sec_access(&sa, PRINTER_ACE_FULL_CONTROL); + sa = PRINTER_ACE_FULL_CONTROL; init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, SEC_ACE_FLAG_OBJECT_INHERIT | SEC_ACE_FLAG_INHERIT_ONLY); diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index 30cb254a29..a6bf52a0a4 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -63,41 +63,51 @@ #include "includes.h" -typedef struct pcap_cache { +struct pcap_cache { char *name; char *comment; struct pcap_cache *next; -} pcap_cache_t; +}; -static pcap_cache_t *pcap_cache = NULL; +/* The systemwide printcap cache. */ +static struct pcap_cache *pcap_cache = NULL; -bool pcap_cache_add(const char *name, const char *comment) +bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment) { - pcap_cache_t *p; + struct pcap_cache *p; - if (name == NULL || ((p = SMB_MALLOC_P(pcap_cache_t)) == NULL)) - return False; + if (name == NULL || ((p = SMB_MALLOC_P(struct pcap_cache)) == NULL)) + return false; p->name = SMB_STRDUP(name); p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL; - p->next = pcap_cache; - pcap_cache = p; + DEBUG(11,("pcap_cache_add_specific: Adding name %s info %s\n", + p->name, p->comment ? p->comment : "")); + + p->next = *ppcache; + *ppcache = p; - return True; + return true; } -static void pcap_cache_destroy(pcap_cache_t *cache) +void pcap_cache_destroy_specific(struct pcap_cache **pp_cache) { - pcap_cache_t *p, *next; + struct pcap_cache *p, *next; - for (p = cache; p != NULL; p = next) { + for (p = *pp_cache; p != NULL; p = next) { next = p->next; SAFE_FREE(p->name); SAFE_FREE(p->comment); SAFE_FREE(p); } + *pp_cache = NULL; +} + +bool pcap_cache_add(const char *name, const char *comment) +{ + return pcap_cache_add_specific(&pcap_cache, name, comment); } bool pcap_cache_loaded(void) @@ -105,11 +115,21 @@ bool pcap_cache_loaded(void) return (pcap_cache != NULL); } +void pcap_cache_replace(const struct pcap_cache *pcache) +{ + const struct pcap_cache *p; + + pcap_cache_destroy_specific(&pcap_cache); + for (p = pcache; p; p = p->next) { + pcap_cache_add(p->name, p->comment); + } +} + void pcap_cache_reload(void) { const char *pcap_name = lp_printcapname(); bool pcap_reloaded = False; - pcap_cache_t *tmp_cache = NULL; + struct pcap_cache *tmp_cache = NULL; XFILE *pcap_file; char *pcap_line; @@ -159,7 +179,7 @@ void pcap_cache_reload(void) goto done; } - for (; (pcap_line = fgets_slash(NULL, 1024, pcap_file)) != NULL; safe_free(pcap_line)) { + for (; (pcap_line = fgets_slash(NULL, 1024, pcap_file)) != NULL; free(pcap_line)) { char name[MAXPRINTERLEN+1]; char comment[62]; char *p, *q; @@ -223,9 +243,9 @@ done: DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error")); if (pcap_reloaded) - pcap_cache_destroy(tmp_cache); + pcap_cache_destroy_specific(&tmp_cache); else { - pcap_cache_destroy(pcap_cache); + pcap_cache_destroy_specific(&pcap_cache); pcap_cache = tmp_cache; } @@ -235,7 +255,7 @@ done: bool pcap_printername_ok(const char *printername) { - pcap_cache_t *p; + struct pcap_cache *p; for (p = pcap_cache; p != NULL; p = p->next) if (strequal(p->name, printername)) @@ -245,19 +265,22 @@ bool pcap_printername_ok(const char *printername) } /*************************************************************************** -run a function on each printer name in the printcap file. The function is -passed the primary name and the comment (if possible). Note the fn() takes -strings in DOS codepage. This means the xxx_printer_fn() calls must be fixed -to return DOS codepage. FIXME !! JRA. - -XXX: I'm not sure if this comment still applies.. Anyone? -Rob +run a function on each printer name in the printcap file. ***************************************************************************/ -void pcap_printer_fn(void (*fn)(char *, char *)) + +void pcap_printer_fn_specific(const struct pcap_cache *pc, + void (*fn)(const char *, const char *, void *), + void *pdata) { - pcap_cache_t *p; + const struct pcap_cache *p; - for (p = pcap_cache; p != NULL; p = p->next) - fn(p->name, p->comment); + for (p = pc; p != NULL; p = p->next) + fn(p->name, p->comment, pdata); return; } + +void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *pdata) +{ + pcap_printer_fn_specific(pcap_cache, fn, pdata); +} diff --git a/source3/printing/print_aix.c b/source3/printing/print_aix.c index 57590cc39e..523be77f35 100644 --- a/source3/printing/print_aix.c +++ b/source3/printing/print_aix.c @@ -49,7 +49,7 @@ bool aix_cache_reload(void) iEtat = 0; /* scan qconfig file for searching : */ - for (;(line = fgets_slash(NULL, 1024, pfile)); safe_free(line)) { + for (;(line = fgets_slash(NULL, 1024, pfile)); free(line)) { if (*line == '*' || *line == 0) continue; @@ -65,7 +65,7 @@ bool aix_cache_reload(void) if (strcmp(p, "bsh") != 0) { name = talloc_strdup(ctx, p); if (!name) { - safe_free(line); + SAFE_FREE(line); x_fclose(pfile); TALLOC_FREE(ctx); return false; @@ -85,7 +85,7 @@ bool aix_cache_reload(void) /* probably a good printer ??? */ iEtat = 0; if (!pcap_cache_add(name, NULL)) { - safe_free(line); + SAFE_FREE(line); x_fclose(pfile); TALLOC_FREE(ctx); return false; @@ -100,7 +100,7 @@ bool aix_cache_reload(void) /* it's a good virtual printer */ iEtat = 0; if (!pcap_cache_add(name, NULL)) { - safe_free(line); + SAFE_FREE(line); x_fclose(pfile); TALLOC_FREE(ctx); return false; diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index 593c5c7a1f..ca3415ca5a 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -2,21 +2,26 @@ * Support code for the Common UNIX Printing System ("CUPS") * * Copyright 1999-2003 by Michael R Sweet. + * Copyright 2008 Jeremy Allison. * * 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 . */ +/* + * JRA. Converted to utf8 pull/push. + */ + #include "includes.h" #include "printing.h" @@ -24,6 +29,17 @@ #include #include +static SIG_ATOMIC_T gotalarm; + +/*************************************************************** + Signal function to tell us we timed out. +****************************************************************/ + +static void gotalarm_sig(void) +{ + gotalarm = 1; +} + extern userdom_struct current_user_info; /* @@ -40,16 +56,23 @@ cups_passwd_cb(const char *prompt) /* I - Prompt */ return (NULL); } -static http_t *cups_connect(void) +static http_t *cups_connect(TALLOC_CTX *frame) { - http_t *http; - char *server, *p; + http_t *http = NULL; + char *server = NULL, *p = NULL; int port; - + int timeout = lp_cups_connection_timeout(); + size_t size; + if (lp_cups_server() != NULL && strlen(lp_cups_server()) > 0) { - server = smb_xstrdup(lp_cups_server()); + if (!push_utf8_talloc(frame, &server, lp_cups_server(), &size)) { + return NULL; + } } else { - server = smb_xstrdup(cupsServer()); + server = talloc_strdup(frame,cupsServer()); + } + if (!server) { + return NULL; } p = strchr(server, ':'); @@ -59,23 +82,70 @@ static http_t *cups_connect(void) } else { port = ippPort(); } - + DEBUG(10, ("connecting to cups server %s:%d\n", server, port)); - if ((http = httpConnect(server, port)) == NULL) { - DEBUG(0,("Unable to connect to CUPS server %s:%d - %s\n", + gotalarm = 0; + + if (timeout) { + CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); + alarm(timeout); + } + + http = httpConnect(server, port); + + CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); + alarm(0); + + if (http == NULL) { + DEBUG(0,("Unable to connect to CUPS server %s:%d - %s\n", server, port, strerror(errno))); - SAFE_FREE(server); - return NULL; } - SAFE_FREE(server); return http; } -bool cups_cache_reload(void) +static void send_pcap_info(const char *name, const char *info, void *pd) +{ + int fd = *(int *)pd; + size_t namelen = name ? strlen(name)+1 : 0; + size_t infolen = info ? strlen(info)+1 : 0; + + DEBUG(11,("send_pcap_info: writing namelen %u\n", (unsigned int)namelen)); + if (sys_write(fd, &namelen, sizeof(namelen)) != sizeof(namelen)) { + DEBUG(10,("send_pcap_info: namelen write failed %s\n", + strerror(errno))); + return; + } + DEBUG(11,("send_pcap_info: writing infolen %u\n", (unsigned int)infolen)); + if (sys_write(fd, &infolen, sizeof(infolen)) != sizeof(infolen)) { + DEBUG(10,("send_pcap_info: infolen write failed %s\n", + strerror(errno))); + return; + } + if (namelen) { + DEBUG(11,("send_pcap_info: writing name %s\n", name)); + if (sys_write(fd, name, namelen) != namelen) { + DEBUG(10,("send_pcap_info: name write failed %s\n", + strerror(errno))); + return; + } + } + if (infolen) { + DEBUG(11,("send_pcap_info: writing info %s\n", info)); + if (sys_write(fd, info, infolen) != infolen) { + DEBUG(10,("send_pcap_info: info write failed %s\n", + strerror(errno))); + return; + } + } +} + +static bool cups_cache_reload_async(int fd) { + TALLOC_CTX *frame = talloc_stackframe(); + struct pcap_cache *tmp_pcap_cache = NULL; http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ @@ -87,8 +157,9 @@ bool cups_cache_reload(void) { "printer-name", "printer-info" - }; + }; bool ret = False; + size_t size; DEBUG(5, ("reloading cups printcap cache\n")); @@ -102,7 +173,7 @@ bool cups_cache_reload(void) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -123,7 +194,7 @@ bool cups_cache_reload(void) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -163,12 +234,24 @@ bool cups_cache_reload(void) while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) { if (strcmp(attr->name, "printer-name") == 0 && - attr->value_tag == IPP_TAG_NAME) - name = attr->values[0].string.text; + attr->value_tag == IPP_TAG_NAME) { + if (!pull_utf8_talloc(frame, + &name, + attr->values[0].string.text, + &size)) { + goto out; + } + } if (strcmp(attr->name, "printer-info") == 0 && - attr->value_tag == IPP_TAG_TEXT) - info = attr->values[0].string.text; + attr->value_tag == IPP_TAG_TEXT) { + if (!pull_utf8_talloc(frame, + &info, + attr->values[0].string.text, + &size)) { + goto out; + } + } attr = attr->next; } @@ -180,7 +263,7 @@ bool cups_cache_reload(void) if (name == NULL) break; - if (!pcap_cache_add(name, info)) { + if (!pcap_cache_add_specific(&tmp_pcap_cache, name, info)) { goto out; } } @@ -203,7 +286,7 @@ bool cups_cache_reload(void) request->request.op.request_id = 1; ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -243,12 +326,24 @@ bool cups_cache_reload(void) while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) { if (strcmp(attr->name, "printer-name") == 0 && - attr->value_tag == IPP_TAG_NAME) - name = attr->values[0].string.text; + attr->value_tag == IPP_TAG_NAME) { + if (!pull_utf8_talloc(frame, + &name, + attr->values[0].string.text, + &size)) { + goto out; + } + } if (strcmp(attr->name, "printer-info") == 0 && - attr->value_tag == IPP_TAG_TEXT) - info = attr->values[0].string.text; + attr->value_tag == IPP_TAG_TEXT) { + if (!pull_utf8_talloc(frame, + &info, + attr->values[0].string.text, + &size)) { + goto out; + } + } attr = attr->next; } @@ -260,7 +355,7 @@ bool cups_cache_reload(void) if (name == NULL) break; - if (!pcap_cache_add(name, info)) { + if (!pcap_cache_add_specific(&tmp_pcap_cache, name, info)) { goto out; } } @@ -277,9 +372,229 @@ bool cups_cache_reload(void) if (http) httpClose(http); + /* Send all the entries up the pipe. */ + if (tmp_pcap_cache) { + pcap_printer_fn_specific(tmp_pcap_cache, + send_pcap_info, + (void *)&fd); + + pcap_cache_destroy_specific(&tmp_pcap_cache); + } + TALLOC_FREE(frame); return ret; } +static struct pcap_cache *local_pcap_copy; +struct fd_event *cache_fd_event; + +static bool cups_pcap_load_async(int *pfd) +{ + int fds[2]; + pid_t pid; + + *pfd = -1; + + if (cache_fd_event) { + DEBUG(3,("cups_pcap_load_async: already waiting for " + "a refresh event\n" )); + return false; + } + + DEBUG(5,("cups_pcap_load_async: asynchronously loading cups printers\n")); + + if (pipe(fds) == -1) { + return false; + } + + pid = sys_fork(); + if (pid == (pid_t)-1) { + DEBUG(10,("cups_pcap_load_async: fork failed %s\n", + strerror(errno) )); + close(fds[0]); + close(fds[1]); + return false; + } + + if (pid) { + DEBUG(10,("cups_pcap_load_async: child pid = %u\n", + (unsigned int)pid )); + /* Parent. */ + close(fds[1]); + *pfd = fds[0]; + return true; + } + + /* Child. */ + if (!reinit_after_fork(smbd_messaging_context(), true)) { + DEBUG(0,("cups_pcap_load_async: reinit_after_fork() failed\n")); + smb_panic("cups_pcap_load_async: reinit_after_fork() failed"); + } + + close(fds[0]); + cups_cache_reload_async(fds[1]); + close(fds[1]); + _exit(0); +} + +static void cups_async_callback(struct event_context *event_ctx, + struct fd_event *event, + uint16 flags, + void *p) +{ + TALLOC_CTX *frame = talloc_stackframe(); + int fd = *(int *)p; + struct pcap_cache *tmp_pcap_cache = NULL; + + DEBUG(5,("cups_async_callback: callback received for printer data. " + "fd = %d\n", fd)); + + while (1) { + char *name = NULL, *info = NULL; + size_t namelen = 0, infolen = 0; + ssize_t ret = -1; + + ret = sys_read(fd, &namelen, sizeof(namelen)); + if (ret == 0) { + /* EOF */ + break; + } + if (ret != sizeof(namelen)) { + DEBUG(10,("cups_async_callback: namelen read failed %d %s\n", + errno, strerror(errno))); + break; + } + + DEBUG(11,("cups_async_callback: read namelen %u\n", + (unsigned int)namelen)); + + ret = sys_read(fd, &infolen, sizeof(infolen)); + if (ret == 0) { + /* EOF */ + break; + } + if (ret != sizeof(infolen)) { + DEBUG(10,("cups_async_callback: infolen read failed %s\n", + strerror(errno))); + break; + } + + DEBUG(11,("cups_async_callback: read infolen %u\n", + (unsigned int)infolen)); + + if (namelen) { + name = TALLOC_ARRAY(frame, char, namelen); + if (!name) { + break; + } + ret = sys_read(fd, name, namelen); + if (ret == 0) { + /* EOF */ + break; + } + if (ret != namelen) { + DEBUG(10,("cups_async_callback: name read failed %s\n", + strerror(errno))); + break; + } + DEBUG(11,("cups_async_callback: read name %s\n", + name)); + } else { + name = NULL; + } + if (infolen) { + info = TALLOC_ARRAY(frame, char, infolen); + if (!info) { + break; + } + ret = sys_read(fd, info, infolen); + if (ret == 0) { + /* EOF */ + break; + } + if (ret != infolen) { + DEBUG(10,("cups_async_callback: info read failed %s\n", + strerror(errno))); + break; + } + DEBUG(11,("cups_async_callback: read info %s\n", + info)); + } else { + info = NULL; + } + + /* Add to our local pcap cache. */ + pcap_cache_add_specific(&tmp_pcap_cache, name, info); + TALLOC_FREE(name); + TALLOC_FREE(info); + } + + TALLOC_FREE(frame); + if (tmp_pcap_cache) { + /* We got a namelist, replace our local cache. */ + pcap_cache_destroy_specific(&local_pcap_copy); + local_pcap_copy = tmp_pcap_cache; + + /* And the systemwide pcap cache. */ + pcap_cache_replace(local_pcap_copy); + } else { + DEBUG(2,("cups_async_callback: failed to read a new " + "printer list\n")); + } + close(fd); + TALLOC_FREE(p); + TALLOC_FREE(cache_fd_event); +} + +bool cups_cache_reload(void) +{ + int *p_pipe_fd = TALLOC_P(NULL, int); + + if (!p_pipe_fd) { + return false; + } + + *p_pipe_fd = -1; + + /* Set up an async refresh. */ + if (!cups_pcap_load_async(p_pipe_fd)) { + return false; + } + if (!local_pcap_copy) { + /* We have no local cache, wait directly for + * async refresh to complete. + */ + DEBUG(10,("cups_cache_reload: sync read on fd %d\n", + *p_pipe_fd )); + + cups_async_callback(smbd_event_context(), + NULL, + EVENT_FD_READ, + (void *)p_pipe_fd); + if (!local_pcap_copy) { + return false; + } + } else { + /* Replace the system cache with our + * local copy. */ + pcap_cache_replace(local_pcap_copy); + + DEBUG(10,("cups_cache_reload: async read on fd %d\n", + *p_pipe_fd )); + + /* Trigger an event when the pipe can be read. */ + cache_fd_event = event_add_fd(smbd_event_context(), + NULL, *p_pipe_fd, + EVENT_FD_READ, + cups_async_callback, + (void *)p_pipe_fd); + if (!cache_fd_event) { + close(*p_pipe_fd); + TALLOC_FREE(p_pipe_fd); + return false; + } + } + return true; +} /* * 'cups_job_delete()' - Delete a job. @@ -287,13 +602,15 @@ bool cups_cache_reload(void) static int cups_job_delete(const char *sharename, const char *lprm_command, struct printjob *pjob) { + TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ cups_lang_t *language = NULL; /* Default language */ + char *user = NULL; char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - + size_t size; DEBUG(5,("cups_job_delete(%s, %p (%d))\n", sharename, pjob, pjob->sysjob)); @@ -307,7 +624,7 @@ static int cups_job_delete(const char *sharename, const char *lprm_command, stru * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -329,7 +646,7 @@ static int cups_job_delete(const char *sharename, const char *lprm_command, stru language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -338,8 +655,12 @@ static int cups_job_delete(const char *sharename, const char *lprm_command, stru ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri); + if (!push_utf8_talloc(frame, &user, pjob->user, &size)) { + goto out; + } + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, pjob->user); + NULL, user); /* * Do the request and get back a response... @@ -367,6 +688,7 @@ static int cups_job_delete(const char *sharename, const char *lprm_command, stru if (http) httpClose(http); + TALLOC_FREE(frame); return ret; } @@ -377,13 +699,15 @@ static int cups_job_delete(const char *sharename, const char *lprm_command, stru static int cups_job_pause(int snum, struct printjob *pjob) { + TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ cups_lang_t *language = NULL; /* Default language */ + char *user = NULL; char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - + size_t size; DEBUG(5,("cups_job_pause(%d, %p (%d))\n", snum, pjob, pjob->sysjob)); @@ -397,7 +721,7 @@ static int cups_job_pause(int snum, struct printjob *pjob) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -419,7 +743,7 @@ static int cups_job_pause(int snum, struct printjob *pjob) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -428,8 +752,11 @@ static int cups_job_pause(int snum, struct printjob *pjob) ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri); + if (!push_utf8_talloc(frame, &user, pjob->user, &size)) { + goto out; + } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, pjob->user); + NULL, user); /* * Do the request and get back a response... @@ -457,6 +784,7 @@ static int cups_job_pause(int snum, struct printjob *pjob) if (http) httpClose(http); + TALLOC_FREE(frame); return ret; } @@ -467,13 +795,15 @@ static int cups_job_pause(int snum, struct printjob *pjob) static int cups_job_resume(int snum, struct printjob *pjob) { + TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ cups_lang_t *language = NULL; /* Default language */ + char *user = NULL; char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - + size_t size; DEBUG(5,("cups_job_resume(%d, %p (%d))\n", snum, pjob, pjob->sysjob)); @@ -487,7 +817,7 @@ static int cups_job_resume(int snum, struct printjob *pjob) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -509,7 +839,7 @@ static int cups_job_resume(int snum, struct printjob *pjob) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -518,8 +848,11 @@ static int cups_job_resume(int snum, struct printjob *pjob) ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri); + if (!push_utf8_talloc(frame, &user, pjob->user, &size)) { + goto out; + } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, pjob->user); + NULL, user); /* * Do the request and get back a response... @@ -547,6 +880,7 @@ static int cups_job_resume(int snum, struct printjob *pjob) if (http) httpClose(http); + TALLOC_FREE(frame); return ret; } @@ -557,6 +891,7 @@ static int cups_job_resume(int snum, struct printjob *pjob) static int cups_job_submit(int snum, struct printjob *pjob) { + TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ @@ -567,6 +902,12 @@ static int cups_job_submit(int snum, struct printjob *pjob) char *new_jobname = NULL; int num_options = 0; cups_option_t *options = NULL; + char *printername = NULL; + char *user = NULL; + char *jobname = NULL; + char *cupsoptions = NULL; + char *filename = NULL; + size_t size; char addr[INET6_ADDRSTRLEN]; DEBUG(5,("cups_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob)); @@ -581,7 +922,7 @@ static int cups_job_submit(int snum, struct printjob *pjob) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -604,19 +945,25 @@ static int cups_job_submit(int snum, struct printjob *pjob) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); + if (!push_utf8_talloc(frame, &printername, PRINTERNAME(snum), &size)) { + goto out; + } slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s", - PRINTERNAME(snum)); + printername); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); + if (!push_utf8_talloc(frame, &user, pjob->user, &size)) { + goto out; + } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, pjob->user); + NULL, user); clientname = client_name(get_client_fd()); if (strcmp(clientname, "UNKNOWN") == 0) { @@ -627,31 +974,43 @@ static int cups_job_submit(int snum, struct printjob *pjob) "job-originating-host-name", NULL, clientname); - if (asprintf(&new_jobname,"%s%.8u %s", PRINT_SPOOL_PREFIX, - (unsigned int)pjob->smbjob, pjob->jobname) < 0) { + if (!push_utf8_talloc(frame, &jobname, pjob->jobname, &size)) { + goto out; + } + new_jobname = talloc_asprintf(frame, + "%s%.8u %s", PRINT_SPOOL_PREFIX, + (unsigned int)pjob->smbjob, + jobname); + if (new_jobname == NULL) { goto out; } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL, new_jobname); - /* - * add any options defined in smb.conf + /* + * add any options defined in smb.conf */ + if (!push_utf8_talloc(frame, &cupsoptions, lp_cups_options(snum), &size)) { + goto out; + } num_options = 0; options = NULL; - num_options = cupsParseOptions(lp_cups_options(snum), num_options, &options); + num_options = cupsParseOptions(cupsoptions, num_options, &options); if ( num_options ) - cupsEncodeOptions(request, num_options, options); + cupsEncodeOptions(request, num_options, options); /* * Do the request and get back a response... */ - slprintf(uri, sizeof(uri) - 1, "/printers/%s", PRINTERNAME(snum)); + slprintf(uri, sizeof(uri) - 1, "/printers/%s", printername); + if (!push_utf8_talloc(frame, &filename, pjob->filename, &size)) { + goto out; + } if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) { if (response->request.status.status_code >= IPP_OK_CONFLICT) { DEBUG(0,("Unable to print file to %s - %s\n", PRINTERNAME(snum), @@ -678,7 +1037,7 @@ static int cups_job_submit(int snum, struct printjob *pjob) if (http) httpClose(http); - SAFE_FREE(new_jobname); + TALLOC_FREE(frame); return ret; } @@ -690,10 +1049,11 @@ static int cups_job_submit(int snum, struct printjob *pjob) static int cups_queue_get(const char *sharename, enum printing_types printing_type, char *lpq_command, - print_queue_struct **q, + print_queue_struct **q, print_status_struct *status) { - fstring printername; + TALLOC_CTX *frame = talloc_stackframe(); + char *printername = NULL; http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ @@ -704,13 +1064,14 @@ static int cups_queue_get(const char *sharename, qalloc = 0; /* Number of queue entries allocated */ print_queue_struct *queue = NULL, /* Queue entries */ *temp; /* Temporary pointer for queue */ - const char *user_name, /* job-originating-user-name attribute */ - *job_name; /* job-name attribute */ + char *user_name = NULL, /* job-originating-user-name attribute */ + *job_name = NULL; /* job-name attribute */ int job_id; /* job-id attribute */ int job_k_octets; /* job-k-octets attribute */ time_t job_time; /* time-at-creation attribute */ ipp_jstate_t job_status; /* job-status attribute */ int job_priority; /* job-priority attribute */ + size_t size; static const char *jattrs[] = /* Requested job attributes */ { "job-id", @@ -729,15 +1090,16 @@ static int cups_queue_get(const char *sharename, *q = NULL; - /* HACK ALERT!!! The problem with support the 'printer name' - option is that we key the tdb off the sharename. So we will - overload the lpq_command string to pass in the printername - (which is basically what we do for non-cups printers ... using + /* HACK ALERT!!! The problem with support the 'printer name' + option is that we key the tdb off the sharename. So we will + overload the lpq_command string to pass in the printername + (which is basically what we do for non-cups printers ... using the lpq_command to get the queue listing). */ - fstrcpy( printername, lpq_command ); - - DEBUG(5,("cups_queue_get(%s, %p, %p)\n", printername, q, status)); + if (!push_utf8_talloc(frame, &printername, lpq_command, &size)) { + goto out; + } + DEBUG(5,("cups_queue_get(%s, %p, %p)\n", lpq_command, q, status)); /* * Make sure we don't ask for passwords... @@ -749,7 +1111,7 @@ static int cups_queue_get(const char *sharename, * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -777,7 +1139,7 @@ static int cups_queue_get(const char *sharename, language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -882,12 +1244,24 @@ static int cups_queue_get(const char *sharename, job_time = attr->values[0].integer; if (strcmp(attr->name, "job-name") == 0 && - attr->value_tag == IPP_TAG_NAME) - job_name = attr->values[0].string.text; + attr->value_tag == IPP_TAG_NAME) { + if (!pull_utf8_talloc(frame, + &job_name, + attr->values[0].string.text, + &size)) { + goto out; + } + } if (strcmp(attr->name, "job-originating-user-name") == 0 && - attr->value_tag == IPP_TAG_NAME) - user_name = attr->values[0].string.text; + attr->value_tag == IPP_TAG_NAME) { + if (!pull_utf8_talloc(frame, + &user_name, + attr->values[0].string.text, + &size)) { + goto out; + } + } attr = attr->next; } @@ -911,8 +1285,8 @@ static int cups_queue_get(const char *sharename, LPQ_PRINTING; temp->priority = job_priority; temp->time = job_time; - strncpy(temp->fs_user, user_name, sizeof(temp->fs_user) - 1); - strncpy(temp->fs_file, job_name, sizeof(temp->fs_file) - 1); + strlcpy(temp->fs_user, user_name, sizeof(temp->fs_user)); + strlcpy(temp->fs_file, job_name, sizeof(temp->fs_file)); qcount ++; @@ -939,7 +1313,7 @@ static int cups_queue_get(const char *sharename, request->request.op.request_id = 1; ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); @@ -982,8 +1356,15 @@ static int cups_queue_get(const char *sharename, } if ((attr = ippFindAttribute(response, "printer-state-message", - IPP_TAG_TEXT)) != NULL) - fstrcpy(status->message, attr->values[0].string.text); + IPP_TAG_TEXT)) != NULL) { + char *msg = NULL; + if (!pull_utf8_talloc(frame, &msg, + attr->values[0].string.text, + &size)) { + goto out; + } + fstrcpy(status->message, msg); + } /* * Return the job queue... @@ -1001,6 +1382,7 @@ static int cups_queue_get(const char *sharename, if (http) httpClose(http); + TALLOC_FREE(frame); return qcount; } @@ -1011,13 +1393,16 @@ static int cups_queue_get(const char *sharename, static int cups_queue_pause(int snum) { + TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ cups_lang_t *language = NULL; /* Default language */ + char *printername = NULL; + char *username = NULL; char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - + size_t size; DEBUG(5,("cups_queue_pause(%d)\n", snum)); @@ -1031,7 +1416,7 @@ static int cups_queue_pause(int snum) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -1053,18 +1438,24 @@ static int cups_queue_pause(int snum) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); + if (!push_utf8_talloc(frame, &printername, PRINTERNAME(snum), &size)) { + goto out; + } slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s", - PRINTERNAME(snum)); + printername); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); + if (!push_utf8_talloc(frame, &username, current_user_info.unix_name, &size)) { + goto out; + } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, current_user_info.unix_name); + NULL, username); /* * Do the request and get back a response... @@ -1092,6 +1483,7 @@ static int cups_queue_pause(int snum) if (http) httpClose(http); + TALLOC_FREE(frame); return ret; } @@ -1102,13 +1494,16 @@ static int cups_queue_pause(int snum) static int cups_queue_resume(int snum) { + TALLOC_CTX *frame = talloc_stackframe(); int ret = 1; /* Return value */ http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ cups_lang_t *language = NULL; /* Default language */ + char *printername = NULL; + char *username = NULL; char uri[HTTP_MAX_URI]; /* printer-uri attribute */ - + size_t size; DEBUG(5,("cups_queue_resume(%d)\n", snum)); @@ -1122,7 +1517,7 @@ static int cups_queue_resume(int snum) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -1144,18 +1539,24 @@ static int cups_queue_resume(int snum) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); + if (!push_utf8_talloc(frame, &printername, PRINTERNAME(snum), &size)) { + goto out; + } slprintf(uri, sizeof(uri) - 1, "ipp://localhost/printers/%s", - PRINTERNAME(snum)); + printername); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); + if (!push_utf8_talloc(frame, &username, current_user_info.unix_name, &size)) { + goto out; + } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, current_user_info.unix_name); + NULL, username); /* * Do the request and get back a response... @@ -1183,6 +1584,7 @@ static int cups_queue_resume(int snum) if (http) httpClose(http); + TALLOC_FREE(frame); return ret; } @@ -1204,15 +1606,16 @@ struct printif cups_printif = bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer) { + TALLOC_CTX *frame = talloc_stackframe(); http_t *http = NULL; /* HTTP connection to server */ ipp_t *request = NULL, /* IPP Request */ *response = NULL; /* IPP Response */ ipp_attribute_t *attr; /* Current attribute */ cups_lang_t *language = NULL; /* Default language */ - char *name, /* printer-name attribute */ - *info, /* printer-info attribute */ - *location; /* printer-location attribute */ char uri[HTTP_MAX_URI]; + char *server = NULL; + char *sharename = NULL; + char *name = NULL; static const char *requested[] =/* Requested attributes */ { "printer-name", @@ -1220,6 +1623,7 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer) "printer-location" }; bool ret = False; + size_t size; DEBUG(5, ("pulling %s location\n", printer->sharename)); @@ -1233,7 +1637,7 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer) * Try to connect to the server... */ - if ((http = cups_connect()) == NULL) { + if ((http = cups_connect(frame)) == NULL) { goto out; } @@ -1245,13 +1649,26 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer) language = cupsLangDefault(); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, - "attributes-charset", NULL, cupsLangEncoding(language)); + "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, language->language); + if (lp_cups_server() != NULL && strlen(lp_cups_server()) > 0) { + if (!push_utf8_talloc(frame, &server, lp_cups_server(), &size)) { + goto out; + } + } else { + server = talloc_strdup(frame,cupsServer()); + } + if (server) { + goto out; + } + if (!push_utf8_talloc(frame, &sharename, printer->sharename, &size)) { + goto out; + } slprintf(uri, sizeof(uri) - 1, "ipp://%s/printers/%s", - lp_cups_server(), printer->sharename); + server, sharename); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -1286,43 +1703,64 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer) * Pull the needed attributes from this printer... */ - name = NULL; - info = NULL; - location = NULL; - while ( attr && (attr->group_tag == IPP_TAG_PRINTER) ) { + if (strcmp(attr->name, "printer-name") == 0 && + attr->value_tag == IPP_TAG_NAME) { + if (!pull_utf8_talloc(frame, + &name, + attr->values[0].string.text, + &size)) { + goto out; + } + } + /* Grab the comment if we don't have one */ if ( (strcmp(attr->name, "printer-info") == 0) && (attr->value_tag == IPP_TAG_TEXT) - && !strlen(printer->comment) ) + && !strlen(printer->comment) ) { + char *comment = NULL; + if (!pull_utf8_talloc(frame, + &comment, + attr->values[0].string.text, + &size)) { + goto out; + } DEBUG(5,("cups_pull_comment_location: Using cups comment: %s\n", - attr->values[0].string.text)); + comment)); strlcpy(printer->comment, - attr->values[0].string.text, - sizeof(printer->comment)); + comment, + sizeof(printer->comment)); } - /* Grab the location if we don't have one */ + /* Grab the location if we don't have one */ if ( (strcmp(attr->name, "printer-location") == 0) - && (attr->value_tag == IPP_TAG_TEXT) + && (attr->value_tag == IPP_TAG_TEXT) && !strlen(printer->location) ) { + char *location = NULL; + if (!pull_utf8_talloc(frame, + &location, + attr->values[0].string.text, + &size)) { + goto out; + } DEBUG(5,("cups_pull_comment_location: Using cups location: %s\n", - attr->values[0].string.text)); - fstrcpy(printer->location,attr->values[0].string.text); + location)); + strlcpy(printer->location, + location, + sizeof(printer->location)); } attr = attr->next; } /* - * See if we have everything needed... + * We have everything needed... */ - if (name == NULL) + if (name != NULL) break; - } ret = True; @@ -1337,6 +1775,7 @@ bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer) if (http) httpClose(http); + TALLOC_FREE(frame); return ret; } diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c index 2a324fdd5c..5806b29206 100644 --- a/source3/printing/print_generic.c +++ b/source3/printing/print_generic.c @@ -104,7 +104,7 @@ static int generic_job_delete( const char *sharename, const char *lprm_command, slprintf(jobstr, sizeof(jobstr)-1, "%d", pjob->sysjob); return print_run_command( -1, sharename, False, lprm_command, NULL, "%j", jobstr, - "%T", http_timestring(pjob->starttime), + "%T", http_timestring(talloc_tos(), pjob->starttime), NULL); } @@ -238,7 +238,7 @@ static int generic_queue_get(const char *printer_name, } numlines = 0; - qlines = fd_lines_load(fd, &numlines,0); + qlines = fd_lines_load(fd, &numlines,0,NULL); close(fd); /* turn the lpq output into a series of job structures */ @@ -247,7 +247,7 @@ static int generic_queue_get(const char *printer_name, if (numlines && qlines) { queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1); if (!queue) { - file_lines_free(qlines); + TALLOC_FREE(qlines); *q = NULL; return 0; } @@ -262,7 +262,7 @@ static int generic_queue_get(const char *printer_name, } } - file_lines_free(qlines); + TALLOC_FREE(qlines); *q = queue; return qcount; } diff --git a/source3/printing/print_svid.c b/source3/printing/print_svid.c index 7e91d3a677..681b2bf459 100644 --- a/source3/printing/print_svid.c +++ b/source3/printing/print_svid.c @@ -59,12 +59,12 @@ bool sysv_cache_reload(void) scheduler = file_lines_pload("/usr/bin/lpstat -r", NULL); if(!strcmp(*scheduler,"scheduler is running")){ DEBUG(3,("No Printers found!!!\n")); - file_lines_free(scheduler); + TALLOC_FREE(scheduler); return True; } else{ DEBUG(3,("Scheduler is not running!!!\n")); - file_lines_free(scheduler); + TALLOC_FREE(scheduler); return False; } #else @@ -111,12 +111,12 @@ bool sysv_cache_reload(void) /* add it to the cache */ if (!pcap_cache_add(name, NULL)) { - file_lines_free(lines); + TALLOC_FREE(lines); return False; } } - file_lines_free(lines); + TALLOC_FREE(lines); return True; } diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c index c6749226fd..a247cd8427 100644 --- a/source3/printing/printfsp.c +++ b/source3/printing/printfsp.c @@ -25,7 +25,8 @@ open a print file and setup a fsp for it. This is a wrapper around print_job_start(). ***************************************************************************/ -NTSTATUS print_fsp_open(connection_struct *conn, const char *fname, +NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn, + const char *fname, uint16_t current_vuid, files_struct **result) { int jobid; @@ -34,7 +35,7 @@ NTSTATUS print_fsp_open(connection_struct *conn, const char *fname, fstring name; NTSTATUS status; - status = file_new(conn, &fsp); + status = file_new(req, conn, &fsp); if(!NT_STATUS_IS_OK(status)) { return status; } @@ -52,7 +53,7 @@ NTSTATUS print_fsp_open(connection_struct *conn, const char *fname, jobid = print_job_start(conn->server_info, SNUM(conn), name, NULL); if (jobid == -1) { status = map_nt_error_from_unix(errno); - file_free(fsp); + file_free(req, fsp); return status; } @@ -61,7 +62,7 @@ NTSTATUS print_fsp_open(connection_struct *conn, const char *fname, if (fsp->rap_print_jobid == 0) { /* We need to delete the entry in the tdb. */ pjob_delete(lp_const_servicename(SNUM(conn)), jobid); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_ACCESS_DENIED; /* No errno around here */ } diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 1016e6183d..3c8c60f0e0 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -2389,9 +2389,9 @@ uint32 print_job_start(struct auth_serversupplied_info *server_info, int snum, /* see if we have sufficient disk space */ if (lp_minprintspace(snum)) { - SMB_BIG_UINT dspace, dsize; + uint64_t dspace, dsize; if (sys_fsusage(path, &dspace, &dsize) == 0 && - dspace < 2*(SMB_BIG_UINT)lp_minprintspace(snum)) { + dspace < 2*(uint64_t)lp_minprintspace(snum)) { DEBUG(3, ("print_job_start: disk space check failed.\n")); release_print_db(pdb); errno = ENOSPC; diff --git a/testsuite/printing/README.vlp b/source3/printing/tests/README.vlp similarity index 53% rename from testsuite/printing/README.vlp rename to source3/printing/tests/README.vlp index 48d2c8c0a2..fc0b91ad69 100644 --- a/testsuite/printing/README.vlp +++ b/source3/printing/tests/README.vlp @@ -6,22 +6,7 @@ virtual full-function printer. Setup -1) Configure and build Samba. - For this to work, you need to add: - -DDEVELOPER - to your CFLAGS, and add: - --srcdir= - when running configure. Generally - ./configure --srcdir=`pwd` - should work. - -2) Build and install vlp. - # cd testsuite/printing - # make -f Makefile.vlp vlp - # su - # cp vlp /usr/local/samba/bin - -3) Set up Samba to use vlp. +Set up Samba to use vlp. In your smb.conf file under [global], add the following option: printing = vlp and then add any number of print shares, without needing to make them @@ -31,5 +16,4 @@ Setup printable = yes is all you need for the most basic virtual printer. - - + diff --git a/testsuite/printing/vlp.c b/source3/printing/tests/vlp.c similarity index 100% rename from testsuite/printing/vlp.c rename to source3/printing/tests/vlp.c diff --git a/source3/registry/reg_dispatcher.c b/source3/registry/reg_dispatcher.c index c68ecdedeb..d06410a1b3 100644 --- a/source3/registry/reg_dispatcher.c +++ b/source3/registry/reg_dispatcher.c @@ -37,7 +37,6 @@ static const struct generic_mapping reg_generic_map = static WERROR construct_registry_sd(TALLOC_CTX *ctx, SEC_DESC **psd) { SEC_ACE ace[3]; - SEC_ACCESS mask; size_t i = 0; SEC_DESC *sd; SEC_ACL *acl; @@ -45,21 +44,18 @@ static WERROR construct_registry_sd(TALLOC_CTX *ctx, SEC_DESC **psd) /* basic access for Everyone */ - init_sec_access(&mask, REG_KEY_READ); init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, - mask, 0); + REG_KEY_READ, 0); /* Full Access 'BUILTIN\Administrators' */ - init_sec_access(&mask, REG_KEY_ALL); init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, - SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + SEC_ACE_TYPE_ACCESS_ALLOWED, REG_KEY_ALL, 0); /* Full Access 'NT Authority\System' */ - init_sec_access(&mask, REG_KEY_ALL ); init_sec_ace(&ace[i++], &global_sid_System, SEC_ACE_TYPE_ACCESS_ALLOWED, - mask, 0); + REG_KEY_ALL, 0); /* create the security descriptor */ diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c index e608847048..eda44ace19 100644 --- a/source3/registry/reg_perfcount.c +++ b/source3/registry/reg_perfcount.c @@ -63,7 +63,7 @@ void perfcount_init_keys( void ) /* no registry keys; just create the perfmon directory */ - if ( !directory_exist( p, NULL ) ) + if ( !directory_exist( p ) ) mkdir( p, 0755 ); return; @@ -450,7 +450,7 @@ static uint32 _reg_perfcount_get_size_field(uint32 CounterType) /********************************************************************* *********************************************************************/ -static uint32 _reg_perfcount_compute_scale(SMB_BIG_INT data) +static uint32 _reg_perfcount_compute_scale(int64_t data) { int scale = 0; if(data == 0) @@ -482,7 +482,7 @@ static bool _reg_perfcount_get_counter_info(PERF_DATA_BLOCK *block, char buf[PERFCOUNT_MAX_LEN]; size_t dsize, padding; long int data32, dbuf[2]; - SMB_BIG_INT data64; + int64_t data64; uint32 counter_size; obj->counters[obj->NumCounters].DefaultScale = 0; @@ -521,7 +521,7 @@ static bool _reg_perfcount_get_counter_info(PERF_DATA_BLOCK *block, memcpy(buf, data.dptr, data.dsize); data32 = strtol(buf, NULL, 0); if((obj->counters[obj->NumCounters].CounterType & 0x00000F00) == PERF_TYPE_NUMBER) - obj->counters[obj->NumCounters].DefaultScale = _reg_perfcount_compute_scale((SMB_BIG_INT)data32); + obj->counters[obj->NumCounters].DefaultScale = _reg_perfcount_compute_scale((int64_t)data32); else obj->counters[obj->NumCounters].DefaultScale = 0; dbuf[0] = data32; @@ -823,7 +823,7 @@ static int _reg_perfcount_assemble_global(PERF_DATA_BLOCK *block, /********************************************************************* *********************************************************************/ -static bool _reg_perfcount_get_64(SMB_BIG_UINT *retval, +static bool _reg_perfcount_get_64(uint64_t *retval, TDB_CONTEXT *tdb, int key_part1, const char *key_part2) @@ -855,7 +855,7 @@ static bool _reg_perfcount_get_64(SMB_BIG_UINT *retval, static bool _reg_perfcount_init_data_block_perf(PERF_DATA_BLOCK *block, TDB_CONTEXT *names) { - SMB_BIG_UINT PerfFreq, PerfTime, PerfTime100nSec; + uint64_t PerfFreq, PerfTime, PerfTime100nSec; TDB_CONTEXT *counters; bool status = False; const char *fname = counters_directory( DATA_DB ); diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index df87ed13d1..5f115e537b 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -146,7 +146,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; struct netr_Authenticator clnt_creds; struct netr_Authenticator ret_creds; - union netr_LogonInfo *logon; + union netr_LogonLevel *logon; union netr_Validation validation; uint8_t authoritative; int validation_level = 3; @@ -156,7 +156,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, ZERO_STRUCT(ret_creds); ZERO_STRUCT(zeros); - logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonInfo); + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); if (!logon) { return NT_STATUS_NO_MEMORY; } @@ -172,7 +172,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, netlogon_creds_client_step(cli->dc, &clnt_creds); switch (logon_type) { - case INTERACTIVE_LOGON_TYPE: { + case NetlogonInteractiveInformation: { struct netr_PasswordInfo *password_info; @@ -231,7 +231,7 @@ NTSTATUS rpccli_netlogon_sam_logon(struct rpc_pipe_client *cli, break; } - case NET_LOGON_TYPE: { + case NetlogonNetworkInformation: { struct netr_NetworkInfo *network_info; uint8 chal[8]; unsigned char local_lm_response[24]; @@ -327,7 +327,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, uint8 zeros[16]; struct netr_Authenticator clnt_creds; struct netr_Authenticator ret_creds; - union netr_LogonInfo *logon = NULL; + union netr_LogonLevel *logon = NULL; struct netr_NetworkInfo *network_info; uint8_t authoritative; union netr_Validation validation; @@ -342,7 +342,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, ZERO_STRUCT(lm); ZERO_STRUCT(nt); - logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonInfo); + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); if (!logon) { return NT_STATUS_NO_MEMORY; } @@ -398,7 +398,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli, global_myname(), &clnt_creds, &ret_creds, - NET_LOGON_TYPE, + NetlogonNetworkInformation, logon, validation_level, &validation, @@ -447,7 +447,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, const char *workstation_name_slash; const char *server_name_slash; uint8 zeros[16]; - union netr_LogonInfo *logon = NULL; + union netr_LogonLevel *logon = NULL; struct netr_NetworkInfo *network_info; uint8_t authoritative; union netr_Validation validation; @@ -462,7 +462,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, ZERO_STRUCT(lm); ZERO_STRUCT(nt); - logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonInfo); + logon = TALLOC_ZERO_P(mem_ctx, union netr_LogonLevel); if (!logon) { return NT_STATUS_NO_MEMORY; } @@ -514,7 +514,7 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, result = rpccli_netr_LogonSamLogonEx(cli, mem_ctx, server_name_slash, global_myname(), - NET_LOGON_TYPE, + NetlogonNetworkInformation, logon, validation_level, &validation, @@ -538,3 +538,94 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli, return result; } + +/********************************************************* + Change the domain password on the PDC. + + Just changes the password betwen the two values specified. + + Caller must have the cli connected to the netlogon pipe + already. +**********************************************************/ + +NTSTATUS rpccli_netlogon_set_trust_password(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const unsigned char orig_trust_passwd_hash[16], + const char *new_trust_pwd_cleartext, + const unsigned char new_trust_passwd_hash[16], + uint32_t sec_channel_type) +{ + NTSTATUS result; + uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS; + struct netr_Authenticator clnt_creds, srv_cred; + + result = rpccli_netlogon_setup_creds(cli, + cli->desthost, /* server name */ + lp_workgroup(), /* domain */ + global_myname(), /* client name */ + global_myname(), /* machine account name */ + orig_trust_passwd_hash, + sec_channel_type, + &neg_flags); + + if (!NT_STATUS_IS_OK(result)) { + DEBUG(3,("rpccli_netlogon_set_trust_password: unable to setup creds (%s)!\n", + nt_errstr(result))); + return result; + } + + netlogon_creds_client_step(cli->dc, &clnt_creds); + + if (neg_flags & NETLOGON_NEG_PASSWORD_SET2) { + + struct netr_CryptPassword new_password; + + init_netr_CryptPassword(new_trust_pwd_cleartext, + cli->dc->sess_key, + &new_password); + + result = rpccli_netr_ServerPasswordSet2(cli, mem_ctx, + cli->dc->remote_machine, + cli->dc->mach_acct, + sec_channel_type, + global_myname(), + &clnt_creds, + &srv_cred, + &new_password); + if (!NT_STATUS_IS_OK(result)) { + DEBUG(0,("rpccli_netr_ServerPasswordSet2 failed: %s\n", + nt_errstr(result))); + return result; + } + } else { + + struct samr_Password new_password; + + cred_hash3(new_password.hash, + new_trust_passwd_hash, + cli->dc->sess_key, 1); + + result = rpccli_netr_ServerPasswordSet(cli, mem_ctx, + cli->dc->remote_machine, + cli->dc->mach_acct, + sec_channel_type, + global_myname(), + &clnt_creds, + &srv_cred, + &new_password); + if (!NT_STATUS_IS_OK(result)) { + DEBUG(0,("rpccli_netr_ServerPasswordSet failed: %s\n", + nt_errstr(result))); + return result; + } + } + + /* Always check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + + return result; +} + diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index f32a33fdb6..ca9d3392e7 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -2810,7 +2810,7 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path, result->abstract_syntax = *abstract_syntax; result->transfer_syntax = ndr_transfer_syntax; - result->desthost = get_myname(result); + result->desthost = talloc_get_myname(result); result->srv_name_slash = talloc_asprintf_strupper_m( result, "\\\\%s", result->desthost); if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) { @@ -2906,7 +2906,7 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli, fnum = cli_nt_create(cli, result->trans.np.pipe_name, DESIRED_ACCESS_PIPE); if (fnum == -1) { - DEBUG(1,("rpc_pipe_open_np: cli_nt_create failed on pipe %s " + DEBUG(3,("rpc_pipe_open_np: cli_nt_create failed on pipe %s " "to machine %s. Error was %s\n", result->trans.np.pipe_name, cli->desthost, cli_errstr(cli))); diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index 3c29dcdee8..51678083d3 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -90,79 +90,3 @@ WERROR rpccli_svcctl_enumerate_services( struct rpc_pipe_client *cli, TALLOC_CTX return out.status; } - -/******************************************************************* -*******************************************************************/ - -WERROR rpccli_svcctl_query_config(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hService, SERVICE_CONFIG *config ) -{ - SVCCTL_Q_QUERY_SERVICE_CONFIG in; - SVCCTL_R_QUERY_SERVICE_CONFIG out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - memcpy( &in.handle, hService, sizeof(POLICY_HND) ); - in.buffer_size = 0; - - - CLI_DO_RPC_WERR( cli, mem_ctx, &ndr_table_svcctl.syntax_id, - SVCCTL_QUERY_SERVICE_CONFIG_W, - in, out, - qbuf, rbuf, - svcctl_io_q_query_service_config, - svcctl_io_r_query_service_config, - WERR_GENERAL_FAILURE ); - - if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { - in.buffer_size = out.needed; - - CLI_DO_RPC_WERR( cli, mem_ctx, &ndr_table_svcctl.syntax_id, - SVCCTL_QUERY_SERVICE_CONFIG_W, - in, out, - qbuf, rbuf, - svcctl_io_q_query_service_config, - svcctl_io_r_query_service_config, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( config, &out.config, sizeof(SERVICE_CONFIG) ); - - config->executablepath = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - config->loadordergroup = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - config->dependencies = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - config->startname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - config->displayname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - - if ( out.config.executablepath ) { - config->executablepath = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - copy_unistr2( config->executablepath, out.config.executablepath ); - } - - if ( out.config.loadordergroup ) { - config->loadordergroup = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - copy_unistr2( config->loadordergroup, out.config.loadordergroup ); - } - - if ( out.config.dependencies ) { - config->dependencies = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - copy_unistr2( config->dependencies, out.config.dependencies ); - } - - if ( out.config.startname ) { - config->startname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - copy_unistr2( config->startname, out.config.startname ); - } - - if ( out.config.displayname ) { - config->displayname = TALLOC_ZERO_P( mem_ctx, UNISTR2 ); - copy_unistr2( config->displayname, out.config.displayname ); - } - - return out.status; -} diff --git a/source3/rpc_client/init_netlogon.c b/source3/rpc_client/init_netlogon.c index 61841953fc..e4c39e739e 100644 --- a/source3/rpc_client/init_netlogon.c +++ b/source3/rpc_client/init_netlogon.c @@ -391,3 +391,20 @@ void init_netr_PasswordInfo(struct netr_PasswordInfo *r, r->lmpassword = lmpassword; r->ntpassword = ntpassword; } + +/************************************************************************* + inits a netr_CryptPassword structure + *************************************************************************/ + +void init_netr_CryptPassword(const char *pwd, + unsigned char session_key[16], + struct netr_CryptPassword *pwd_buf) +{ + struct samr_CryptPassword password_buf; + + encode_pw_buffer(password_buf.data, pwd, STR_UNICODE); + + SamOEMhash(password_buf.data, session_key, 516); + memcpy(pwd_buf->data, password_buf.data, 512); + pwd_buf->length = IVAL(password_buf.data, 512); +} diff --git a/source3/rpc_client/init_samr.c b/source3/rpc_client/init_samr.c index 2e757531ce..283be0d98b 100644 --- a/source3/rpc_client/init_samr.c +++ b/source3/rpc_client/init_samr.c @@ -41,21 +41,21 @@ void init_samr_DomInfo1(struct samr_DomInfo1 *r, inits a structure. ********************************************************************/ -void init_samr_DomInfo2(struct samr_DomInfo2 *r, - NTTIME force_logoff_time, - const char *comment, - const char *domain_name, - const char *primary, - uint64_t sequence_num, - uint32_t unknown2, - enum samr_Role role, - uint32_t unknown3, - uint32_t num_users, - uint32_t num_groups, - uint32_t num_aliases) +void init_samr_DomGeneralInformation(struct samr_DomGeneralInformation *r, + NTTIME force_logoff_time, + const char *oem_information, + const char *domain_name, + const char *primary, + uint64_t sequence_num, + uint32_t unknown2, + enum samr_Role role, + uint32_t unknown3, + uint32_t num_users, + uint32_t num_groups, + uint32_t num_aliases) { r->force_logoff_time = force_logoff_time; - init_lsa_String(&r->comment, comment); + init_lsa_String(&r->oem_information, oem_information); init_lsa_String(&r->domain_name, domain_name); init_lsa_String(&r->primary, primary); r->sequence_num = sequence_num; @@ -81,10 +81,10 @@ void init_samr_DomInfo3(struct samr_DomInfo3 *r, inits a structure. ********************************************************************/ -void init_samr_DomInfo4(struct samr_DomInfo4 *r, - const char *comment) +void init_samr_DomOEMInformation(struct samr_DomOEMInformation *r, + const char *oem_information) { - init_lsa_String(&r->comment, comment); + init_lsa_String(&r->oem_information, oem_information); } /******************************************************************* diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c index 72a33137a6..9ada47a3f5 100644 --- a/source3/rpc_client/ndr.c +++ b/source3/rpc_client/ndr.c @@ -41,7 +41,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, call = &table->calls[opnum]; - push = ndr_push_init_ctx(mem_ctx); + push = ndr_push_init_ctx(mem_ctx, NULL); if (!push) { return NT_STATUS_NO_MEMORY; } @@ -77,7 +77,7 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli, prs_mem_free( &r_ps ); - pull = ndr_pull_init_blob(&blob, mem_ctx); + pull = ndr_pull_init_blob(&blob, mem_ctx, NULL); if (pull == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index c5d93864ba..7d31f4b2f0 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -58,51 +58,6 @@ static bool svcctl_io_service_status( const char *desc, SERVICE_STATUS *status, /******************************************************************* ********************************************************************/ -static bool svcctl_io_service_config( const char *desc, SERVICE_CONFIG *config, prs_struct *ps, int depth ) -{ - - prs_debug(ps, depth, desc, "svcctl_io_service_config"); - depth++; - - if(!prs_uint32("service_type", ps, depth, &config->service_type)) - return False; - if(!prs_uint32("start_type", ps, depth, &config->start_type)) - return False; - if(!prs_uint32("error_control", ps, depth, &config->error_control)) - return False; - - if (!prs_io_unistr2_p("", ps, depth, &config->executablepath)) - return False; - if (!prs_io_unistr2_p("", ps, depth, &config->loadordergroup)) - return False; - - if(!prs_uint32("tag_id", ps, depth, &config->tag_id)) - return False; - - if (!prs_io_unistr2_p("", ps, depth, &config->dependencies)) - return False; - if (!prs_io_unistr2_p("", ps, depth, &config->startname)) - return False; - if (!prs_io_unistr2_p("", ps, depth, &config->displayname)) - return False; - - if (!prs_io_unistr2("", ps, depth, config->executablepath)) - return False; - if (!prs_io_unistr2("", ps, depth, config->loadordergroup)) - return False; - if (!prs_io_unistr2("", ps, depth, config->dependencies)) - return False; - if (!prs_io_unistr2("", ps, depth, config->startname)) - return False; - if (!prs_io_unistr2("", ps, depth, config->displayname)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_enum_services_status( const char *desc, ENUM_SERVICES_STATUS *enum_status, RPC_BUFFER *buffer, int depth ) { prs_struct *ps=&buffer->prs; @@ -175,26 +130,6 @@ static uint32 sizeof_unistr2( UNISTR2 *string ) return size; } -/******************************************************************** -********************************************************************/ - -uint32 svcctl_sizeof_service_config( SERVICE_CONFIG *config ) -{ - uint32 size = 0; - - size = sizeof(uint32) * 4; /* static uint32 fields */ - - /* now add the UNISTR2 + pointer sizes */ - - size += sizeof(uint32) * sizeof_unistr2(config->executablepath); - size += sizeof(uint32) * sizeof_unistr2(config->loadordergroup); - size += sizeof(uint32) * sizeof_unistr2(config->dependencies); - size += sizeof(uint32) * sizeof_unistr2(config->startname); - size += sizeof(uint32) * sizeof_unistr2(config->displayname); - - return size; -} - /******************************************************************* ********************************************************************/ @@ -262,57 +197,6 @@ bool svcctl_io_r_enum_services_status(const char *desc, SVCCTL_R_ENUM_SERVICES_S /******************************************************************* ********************************************************************/ -bool svcctl_io_q_query_service_config(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_q_query_service_config"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("service_pol", &q_u->handle, ps, depth)) - return False; - - if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool svcctl_io_r_query_service_config(const char *desc, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "svcctl_io_r_query_service_config"); - depth++; - - - if(!prs_align(ps)) - return False; - - if(!svcctl_io_service_config("config", &r_u->config, ps, depth)) - return False; - - if(!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - - return True; -} - -/******************************************************************* -********************************************************************/ - bool svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, prs_struct *ps, int depth) { if (q_u == NULL) diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index da761c905e..973be28040 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/srv_eventlog.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index e232a30078..9215a86d3f 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -344,7 +344,7 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) /* make sure that the eventlog dir exists */ eventlogdir = state_path( "eventlog" ); - if ( !directory_exist( eventlogdir, NULL ) ) + if ( !directory_exist( eventlogdir ) ) mkdir( eventlogdir, 0755 ); /* get the path on disk */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 94517f3478..2fa705daf3 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -290,22 +290,18 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s DOM_SID adm_sid; SEC_ACE ace[3]; - SEC_ACCESS mask; SEC_ACL *psa = NULL; - init_sec_access(&mask, LSA_POLICY_EXECUTE); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, LSA_POLICY_EXECUTE, 0); sid_copy(&adm_sid, get_global_sam_sid()); sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS); - init_sec_access(&mask, LSA_POLICY_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, LSA_POLICY_ALL_ACCESS, 0); sid_copy(&local_adm_sid, &global_sid_Builtin); sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS); - init_sec_access(&mask, LSA_POLICY_ALL_ACCESS); - init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, LSA_POLICY_ALL_ACCESS, 0); if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; @@ -434,7 +430,7 @@ NTSTATUS _lsa_OpenPolicy(pipes_struct *p, lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) { - if (geteuid() != 0) { + if (p->pipe_user.ut.uid != sec_initial_uid()) { return status; } DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", @@ -1206,8 +1202,8 @@ NTSTATUS _lsa_LookupNames4(pipes_struct *p, q.in.num_names = r->in.num_names; q.in.names = r->in.names; q.in.level = r->in.level; - q.in.unknown1 = r->in.unknown1; - q.in.unknown2 = r->in.unknown2; + q.in.lookup_options = r->in.lookup_options; + q.in.client_revision = r->in.client_revision; q.in.sids = r->in.sids; q.in.count = r->in.count; @@ -1466,6 +1462,16 @@ NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_String *account_name = NULL; struct lsa_String *authority_name = NULL; + if (r->in.account_name && + *r->in.account_name) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (r->in.authority_name && + *r->in.authority_name) { + return NT_STATUS_INVALID_PARAMETER; + } + if (p->server_info->guest) { /* * I'm 99% sure this is not the right place to do this, @@ -1481,21 +1487,24 @@ NTSTATUS _lsa_GetUserName(pipes_struct *p, domname = pdb_get_domain(p->server_info->sam_account); } - account_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String); + account_name = TALLOC_P(p->mem_ctx, struct lsa_String); if (!account_name) { return NT_STATUS_NO_MEMORY; } + init_lsa_String(account_name, username); - authority_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String); - if (!authority_name) { - return NT_STATUS_NO_MEMORY; + if (r->out.authority_name) { + authority_name = TALLOC_P(p->mem_ctx, struct lsa_String); + if (!authority_name) { + return NT_STATUS_NO_MEMORY; + } + init_lsa_String(authority_name, domname); } - init_lsa_String(account_name, username); - init_lsa_String(authority_name, domname); - *r->out.account_name = account_name; - *r->out.authority_name = authority_name; + if (r->out.authority_name) { + *r->out.authority_name = authority_name; + } return NT_STATUS_OK; } @@ -1526,7 +1535,8 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + if ( p->pipe_user.ut.uid != sec_initial_uid() + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; if ( is_privileged_sid( r->in.sid ) ) @@ -1612,6 +1622,9 @@ NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -1672,6 +1685,9 @@ NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL)) return NT_STATUS_ACCESS_DENIED; @@ -1706,7 +1722,8 @@ NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + if ( p->pipe_user.ut.uid != sec_initial_uid() + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; if (!pdb_getgrsid(&map, info->sid)) @@ -1816,7 +1833,6 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - switch (r->in.sec_info) { case 1: /* SD contains only the owner */ @@ -2074,6 +2090,9 @@ NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ @@ -2116,6 +2135,9 @@ NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + name = r->in.name->string; DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name)); diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4e211cfb81..2dc6cd6393 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -756,7 +756,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, { NTSTATUS status = NT_STATUS_OK; struct netr_SamInfo3 *sam3 = NULL; - union netr_LogonInfo *logon = r->in.logon; + union netr_LogonLevel *logon = r->in.logon; fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; @@ -838,7 +838,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, } switch (r->in.logon_level) { - case INTERACTIVE_LOGON_TYPE: + case NetlogonInteractiveInformation: fstrcpy(nt_username, logon->password->identity_info.account_name.string); fstrcpy(nt_domain, @@ -848,7 +848,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; - case NET_LOGON_TYPE: + case NetlogonNetworkInformation: fstrcpy(nt_username, logon->network->identity_info.account_name.string); fstrcpy(nt_domain, @@ -873,7 +873,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, status = NT_STATUS_OK; switch (r->in.logon_level) { - case NET_LOGON_TYPE: + case NetlogonNetworkInformation: { const char *wksname = nt_workstation; @@ -902,7 +902,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, } break; } - case INTERACTIVE_LOGON_TYPE: + case NetlogonInteractiveInformation: /* 'Interactive' authentication, supplies the password in its MD4 form, encrypted with the session key. We will convert this to challenge/response for the auth subsystem to chew diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 100d577010..5010990b58 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -18,6 +18,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/srv_ntsvcs.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 3968d41168..c8037e6e43 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -24,30 +24,8 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define PIPE "\\PIPE\\" -#define PIPELEN strlen(PIPE) - -static smb_np_struct *chain_p; static int pipes_open; -/* - * Sometimes I can't decide if I hate Windows printer driver - * writers more than I hate the Windows spooler service driver - * writers. This gets around a combination of bugs in the spooler - * and the HP 8500 PCL driver that causes a spooler spin. JRA. - * - * bumped up from 20 -> 64 after viewing traffic from WordPerfect - * 2002 running on NT 4.- SP6 - * bumped up from 64 -> 256 after viewing traffic from con2prt - * for lots of printers on a WinNT 4.x SP6 box. - */ - -#ifndef MAX_OPEN_SPOOLSS_PIPES -#define MAX_OPEN_SPOOLSS_PIPES 256 -#endif -static int current_spoolss_pipes_open; - -static smb_np_struct *Pipes; static pipes_struct *InternalPipes; static struct bitmap *bmap; @@ -93,15 +71,6 @@ void set_pipe_handle_offset(int max_open_files) } } -/**************************************************************************** - Reset pipe chain handle number. -****************************************************************************/ - -void reset_chain_p(void) -{ - chain_p = NULL; -} - /**************************************************************************** Initialise pipe handle states. ****************************************************************************/ @@ -144,133 +113,21 @@ static bool pipe_init_outgoing_data(pipes_struct *p) return True; } -/**************************************************************************** - Find first available pipe slot. -****************************************************************************/ - -smb_np_struct *open_rpc_pipe_p(const char *pipe_name, - connection_struct *conn, uint16 vuid) -{ - int i; - smb_np_struct *p, *p_it; - static int next_pipe; - bool is_spoolss_pipe = False; - - DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", - pipe_name, pipes_open)); - - if (strstr(pipe_name, "spoolss")) { - is_spoolss_pipe = True; - } - - if (is_spoolss_pipe && current_spoolss_pipes_open >= MAX_OPEN_SPOOLSS_PIPES) { - DEBUG(10,("open_rpc_pipe_p: spooler bug workaround. Denying open on pipe %s\n", - pipe_name )); - return NULL; - } - - /* not repeating pipe numbers makes it easier to track things in - log files and prevents client bugs where pipe numbers are reused - over connection restarts */ - - if (next_pipe == 0) { - next_pipe = (sys_getpid() ^ time(NULL)) % MAX_OPEN_PIPES; - } - - i = bitmap_find(bmap, next_pipe); - - if (i == -1) { - DEBUG(0,("ERROR! Out of pipe structures\n")); - return NULL; - } - - next_pipe = (i+1) % MAX_OPEN_PIPES; - - for (p = Pipes; p; p = p->next) { - DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum)); - } - - p = talloc(NULL, smb_np_struct); - if (!p) { - DEBUG(0,("ERROR! no memory for smb_np_struct!\n")); - return NULL; - } - - ZERO_STRUCTP(p); - - p->name = talloc_strdup(p, pipe_name); - if (p->name == NULL) { - TALLOC_FREE(p); - DEBUG(0,("ERROR! no memory for pipe name!\n")); - return NULL; - } - - /* add a dso mechanism instead of this, here */ - - p->namedpipe_create = make_internal_rpc_pipe_p; - p->namedpipe_read = read_from_internal_pipe; - p->namedpipe_write = write_to_internal_pipe; - - p->np_state = p->namedpipe_create(pipe_name, conn->client_address, - conn->server_info, vuid); - - if (p->np_state == NULL) { - DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); - TALLOC_FREE(p); - return NULL; - } - - DLIST_ADD(Pipes, p); - - /* - * Initialize the incoming RPC data buffer with one PDU worth of memory. - * We cheat here and say we're marshalling, as we intend to add incoming - * data directly into the prs_struct and we want it to auto grow. We will - * change the type to UNMARSALLING before processing the stream. - */ - - bitmap_set(bmap, i); - i += pipe_handle_offset; - - pipes_open++; - - p->pnum = i; - - p->open = True; - p->device_state = 0; - p->priority = 0; - p->conn = conn; - p->vuid = vuid; - - p->max_trans_reply = 0; - - DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", - pipe_name, i, pipes_open)); - - chain_p = p; - - /* Iterate over p_it as a temp variable, to display all open pipes */ - for (p_it = Pipes; p_it; p_it = p_it->next) { - DEBUG(5,("open pipes: name %s pnum=%x\n", p_it->name, p_it->pnum)); - } - - return chain_p; -} - /**************************************************************************** Make an internal namedpipes structure ****************************************************************************/ -struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name, - const char *client_address, - struct auth_serversupplied_info *server_info, - uint16_t vuid) +static struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, + const char *pipe_name, + const char *client_address, + struct auth_serversupplied_info *server_info, + uint16_t vuid) { pipes_struct *p; DEBUG(4,("Create pipe requested %s\n", pipe_name)); - p = TALLOC_ZERO_P(NULL, pipes_struct); + p = TALLOC_ZERO_P(mem_ctx, struct pipes_struct); if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); @@ -902,27 +759,11 @@ incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned return (ssize_t)data_to_copy; } -/**************************************************************************** - Accepts incoming data on an rpc pipe. -****************************************************************************/ - -ssize_t write_to_pipe(smb_np_struct *p, char *data, size_t n) -{ - DEBUG(6,("write_to_pipe: %x", p->pnum)); - - DEBUG(6,(" name: %s open: %s len: %d\n", - p->name, BOOLSTR(p->open), (int)n)); - - dump_data(50, (uint8 *)data, n); - - return p->namedpipe_write(p->np_state, data, n); -} - /**************************************************************************** Accepts incoming data on an internal rpc pipe. ****************************************************************************/ -ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n) +static ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n) { size_t data_left = n; @@ -957,32 +798,8 @@ ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n) have been prepared into arrays of headers + data stream sections. ****************************************************************************/ -ssize_t read_from_pipe(smb_np_struct *p, char *data, size_t n, - bool *is_data_outstanding) -{ - if (!p || !p->open) { - DEBUG(0,("read_from_pipe: pipe not open\n")); - return -1; - } - - DEBUG(6,("read_from_pipe: %x", p->pnum)); - - return p->namedpipe_read(p->np_state, data, n, is_data_outstanding); -} - -/**************************************************************************** - Replies to a request to read data from a pipe. - - Headers are interspersed with the data at PDU intervals. By the time - this function is called, the start of the data could possibly have been - read by an SMBtrans (file_offset != 0). - - Calling create_rpc_reply() here is a hack. The data should already - have been prepared into arrays of headers + data stream sections. -****************************************************************************/ - -ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, size_t n, - bool *is_data_outstanding) +static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, size_t n, + bool *is_data_outstanding) { uint32 pdu_remaining = 0; ssize_t data_returned = 0; @@ -1071,106 +888,6 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, return data_returned; } -/**************************************************************************** - Wait device state on a pipe. Exactly what this is for is unknown... -****************************************************************************/ - -bool wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) -{ - if (p == NULL) { - return False; - } - - if (p->open) { - DEBUG(3,("wait_rpc_pipe_hnd_state: Setting pipe wait state priority=%x on pipe (name=%s)\n", - priority, p->name)); - - p->priority = priority; - - return True; - } - - DEBUG(3,("wait_rpc_pipe_hnd_state: Error setting pipe wait state priority=%x (name=%s)\n", - priority, p->name)); - return False; -} - - -/**************************************************************************** - Set device state on a pipe. Exactly what this is for is unknown... -****************************************************************************/ - -bool set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state) -{ - if (p == NULL) { - return False; - } - - if (p->open) { - DEBUG(3,("set_rpc_pipe_hnd_state: Setting pipe device state=%x on pipe (name=%s)\n", - device_state, p->name)); - - p->device_state = device_state; - - return True; - } - - DEBUG(3,("set_rpc_pipe_hnd_state: Error setting pipe device state=%x (name=%s)\n", - device_state, p->name)); - return False; -} - - -/**************************************************************************** - Close an rpc pipe. -****************************************************************************/ - -bool close_rpc_pipe_hnd(smb_np_struct *p) -{ - if (!p) { - DEBUG(0,("Invalid pipe in close_rpc_pipe_hnd\n")); - return False; - } - - TALLOC_FREE(p->np_state); - - bitmap_clear(bmap, p->pnum - pipe_handle_offset); - - pipes_open--; - - DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", - p->name, p->pnum, pipes_open)); - - DLIST_REMOVE(Pipes, p); - - /* TODO: Remove from pipe open db */ - - if ( !delete_pipe_opendb( p ) ) { - DEBUG(3,("close_rpc_pipe_hnd: failed to delete %s " - "pipe from open db.\n", p->name)); - } - - TALLOC_FREE(p); - - return True; -} - -/**************************************************************************** - Close all pipes on a connection. -****************************************************************************/ - -void pipe_close_conn(connection_struct *conn) -{ - smb_np_struct *p, *next; - - for (p=Pipes;p;p=next) { - next = p->next; - if (p->conn == conn) { - close_rpc_pipe_hnd(p); - } - } -} - /**************************************************************************** Close an rpc pipe. ****************************************************************************/ @@ -1210,40 +927,92 @@ static int close_internal_rpc_pipe_hnd(struct pipes_struct *p) return True; } -/**************************************************************************** - Find an rpc pipe given a pipe handle in a buffer and an offset. -****************************************************************************/ +bool fsp_is_np(struct files_struct *fsp) +{ + return ((fsp != NULL) + && (fsp->fake_file_handle != NULL) + && (fsp->fake_file_handle->type == FAKE_FILE_TYPE_NAMED_PIPE)); +} -smb_np_struct *get_rpc_pipe_p(uint16 pnum) +NTSTATUS np_open(struct smb_request *smb_req, struct connection_struct *conn, + const char *name, struct files_struct **pfsp) { - if (chain_p) { - return chain_p; + NTSTATUS status; + struct files_struct *fsp; + struct pipes_struct *p; + + status = file_new(smb_req, conn, &fsp); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("file_new failed: %s\n", nt_errstr(status))); + return status; } - return get_rpc_pipe(pnum); -} + fsp->conn = conn; + fsp->fh->fd = -1; + fsp->vuid = smb_req->vuid; + fsp->can_lock = false; + fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA; + string_set(&fsp->fsp_name, name); -/**************************************************************************** - Find an rpc pipe given a pipe handle. -****************************************************************************/ + fsp->fake_file_handle = talloc(NULL, struct fake_file_handle); + if (fsp->fake_file_handle == NULL) { + file_free(smb_req, fsp); + return NT_STATUS_NO_MEMORY; + } + fsp->fake_file_handle->type = FAKE_FILE_TYPE_NAMED_PIPE; -smb_np_struct *get_rpc_pipe(int pnum) -{ - smb_np_struct *p; + p = make_internal_rpc_pipe_p(fsp->fake_file_handle, name, + conn->client_address, conn->server_info, + smb_req->vuid); + if (p == NULL) { + file_free(smb_req, fsp); + return NT_STATUS_PIPE_NOT_AVAILABLE; + } + fsp->fake_file_handle->private_data = p; + + *pfsp = fsp; - DEBUG(4,("search for pipe pnum=%x\n", pnum)); + return NT_STATUS_OK; +} + +NTSTATUS np_write(struct files_struct *fsp, uint8_t *data, size_t len, + ssize_t *nwritten) +{ + struct pipes_struct *p; - for (p=Pipes;p;p=p->next) { - DEBUG(5,("pipe name %s pnum=%x (pipes_open=%d)\n", - p->name, p->pnum, pipes_open)); + if (!fsp_is_np(fsp)) { + return NT_STATUS_INVALID_HANDLE; } - for (p=Pipes;p;p=p->next) { - if (p->pnum == pnum) { - chain_p = p; - return p; - } + p = talloc_get_type_abort( + fsp->fake_file_handle->private_data, struct pipes_struct); + + DEBUG(6, ("np_write: %x name: %s len: %d\n", (int)fsp->fnum, + fsp->fsp_name, (int)len)); + dump_data(50, data, len); + + *nwritten = write_to_internal_pipe(p, (char *)data, len); + + return ((*nwritten) >= 0) + ? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR; +} + +NTSTATUS np_read(struct files_struct *fsp, uint8_t *data, size_t len, + ssize_t *nread, bool *is_data_outstanding) +{ + struct pipes_struct *p; + + if (!fsp_is_np(fsp)) { + return NT_STATUS_INVALID_HANDLE; } - return NULL; + p = talloc_get_type_abort( + fsp->fake_file_handle->private_data, struct pipes_struct); + + *nread = read_from_internal_pipe(p, (char *)data, len, + is_data_outstanding); + + return ((*nread) >= 0) + ? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR; + } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1b1e98c049..261d77ca65 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -113,36 +113,35 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd { DOM_SID domadmin_sid; SEC_ACE ace[5]; /* at most 5 entries */ - SEC_ACCESS mask; size_t i = 0; SEC_ACL *psa = NULL; /* basic access for Everyone */ - init_sec_access(&mask, map->generic_execute | map->generic_read ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, + map->generic_execute | map->generic_read, 0); /* add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */ - init_sec_access(&mask, map->generic_all); - - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &global_sid_Builtin_Account_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, + SEC_ACE_TYPE_ACCESS_ALLOWED, map->generic_all, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Account_Operators, + SEC_ACE_TYPE_ACCESS_ALLOWED, map->generic_all, 0); /* Add Full Access for Domain Admins if we are a DC */ if ( IS_DC ) { sid_copy( &domadmin_sid, get_global_sam_sid() ); sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); - init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &domadmin_sid, + SEC_ACE_TYPE_ACCESS_ALLOWED, map->generic_all, 0); } /* if we have a sid, give it some special access */ if ( sid ) { - init_sec_access( &mask, sid_access ); - init_sec_ace(&ace[i++], sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], sid, SEC_ACE_TYPE_ACCESS_ALLOWED, sid_access, 0); } /* create the security descriptor */ @@ -826,6 +825,13 @@ NTSTATUS _samr_QuerySecurity(pipes_struct *p, DEBUG(10,("_samr_QuerySecurity: querying security on SID: %s\n", sid_string_dbg(&pol_sid))); + status = access_check_samr_function(acc_granted, + STD_RIGHT_READ_CONTROL_ACCESS, + "_samr_QuerySecurity"); + if (NT_STATUS_IS_OK(status)) { + return status; + } + /* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */ /* To query the security of the SAM it self an invalid SID with S-0-0 is passed to this function */ @@ -1154,6 +1160,9 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + DEBUG(5,("_samr_EnumDomainAliases: sid %s\n", + sid_string_dbg(&info->sid))); + status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_EnumDomainAliases"); @@ -1161,9 +1170,6 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, return status; } - DEBUG(5,("_samr_EnumDomainAliases: sid %s\n", - sid_string_dbg(&info->sid))); - samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray); if (!samr_array) { return NT_STATUS_NO_MEMORY; @@ -1430,6 +1436,13 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_QueryDisplayInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + /* * calculate how many entries we will return. * based on @@ -2063,6 +2076,13 @@ NTSTATUS _samr_LookupRids(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; + status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr__LookupRids"); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + if (num_rids > 1000) { DEBUG(0, ("Got asked for %d rids (more than 1000) -- according " "to samba4 idl this is not possible\n", num_rids)); @@ -2438,7 +2458,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, if (munged_dial) { blob = base64_decode_data_blob(munged_dial); } else { - blob = data_blob_string_const(""); + blob = data_blob_string_const_null(""); } status = init_samr_parameters_string(mem_ctx, &blob, ¶meters); @@ -2547,7 +2567,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, if (munged_dial) { blob = base64_decode_data_blob(munged_dial); } else { - blob = data_blob_string_const(""); + blob = data_blob_string_const_null(""); } status = init_samr_parameters_string(mem_ctx, &blob, ¶meters); @@ -2633,6 +2653,13 @@ NTSTATUS _samr_QueryUserInfo(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.user_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_QueryUserInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + domain_sid = info->sid; sid_split_rid(&domain_sid, &rid); @@ -2881,6 +2908,13 @@ static NTSTATUS samr_QueryDomainInfo_internal(const char *fn_name, return NT_STATUS_INVALID_HANDLE; } + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_SAM_OPEN_DOMAIN, + "_samr_QueryDomainInfo_internal" ); + + if ( !NT_STATUS_IS_OK(status) ) + return status; + switch (level) { case 0x01: @@ -2910,6 +2944,10 @@ static NTSTATUS samr_QueryDomainInfo_internal(const char *fn_name, unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); + if (lp_check_password_script() && *lp_check_password_script()) { + password_properties |= DOMAIN_PASSWORD_COMPLEX; + } + init_samr_DomInfo1(&dom_info->info1, (uint16)min_pass_len, (uint16)pass_hist, @@ -2943,18 +2981,18 @@ static NTSTATUS samr_QueryDomainInfo_internal(const char *fn_name, if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; - init_samr_DomInfo2(&dom_info->info2, - nt_logout, - lp_serverstring(), - lp_workgroup(), - global_myname(), - seq_num, - 1, - server_role, - 1, - num_users, - num_groups, - num_aliases); + init_samr_DomGeneralInformation(&dom_info->general, + nt_logout, + lp_serverstring(), + lp_workgroup(), + global_myname(), + seq_num, + 1, + server_role, + 1, + num_users, + num_groups, + num_aliases); break; case 0x03: @@ -2979,8 +3017,8 @@ static NTSTATUS samr_QueryDomainInfo_internal(const char *fn_name, break; case 0x04: - init_samr_DomInfo4(&dom_info->info4, - lp_serverstring()); + init_samr_DomOEMInformation(&dom_info->oem, + lp_serverstring()); break; case 0x05: init_samr_DomInfo5(&dom_info->info5, @@ -5602,16 +5640,32 @@ NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, NTSTATUS _samr_SetDomainInfo(pipes_struct *p, struct samr_SetDomainInfo *r) { + struct samr_info *info = NULL; time_t u_expire, u_min_age; time_t u_logout; time_t u_lock_duration, u_reset_time; + NTSTATUS result; DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, r->in.domain_handle, NULL)) + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + /* We do have different access bits for info + * levels here, but we're really just looking for + * GENERIC_RIGHTS_DOMAIN_WRITE access. Unfortunately + * this maps to different specific bits. So + * assume if we have SA_RIGHT_DOMAIN_SET_INFO_1 + * set we are ok. */ + + result = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_SET_INFO_1, + "_samr_SetDomainInfo"); + + if (!NT_STATUS_IS_OK(result)) + return result; + DEBUG(5,("_samr_SetDomainInfo: level: %d\n", r->in.level)); switch (r->in.level) { @@ -5669,6 +5723,7 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, int i; uint32_t num_account = 0; struct samr_displayentry *entries = NULL; + NTSTATUS status; DEBUG(5,("_samr_GetDisplayEnumerationIndex: %d\n", __LINE__)); @@ -5677,6 +5732,13 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; } + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_GetDisplayEnumerationIndex"); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + if ((r->in.level < 1) || (r->in.level > 3)) { DEBUG(0,("_samr_GetDisplayEnumerationIndex: " "Unknown info level (%u)\n", diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 635898a9d5..af9246c49f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4373,7 +4373,7 @@ static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p if (is_printer_published(print_hnd, snum, &guid)) { if (asprintf(&guid_str, "{%s}", - smb_uuid_string(talloc_tos(), guid)) == -1) { + GUID_string(talloc_tos(), &guid)) == -1) { return false; } strupper_m(guid_str); @@ -6280,7 +6280,7 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV numlines = 0; /* Get lines and convert them back to dos-codepage */ - qlines = fd_lines_load(fd, &numlines, 0); + qlines = fd_lines_load(fd, &numlines, 0, NULL); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -6293,7 +6293,7 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV DEBUGADD(6,("Line[0] = [%s]\n", qlines[0])); } - file_lines_free(qlines); + TALLOC_FREE(qlines); return True; } @@ -7512,7 +7512,7 @@ WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ) } numlines = 0; - qlines = fd_lines_load(fd, &numlines, 0); + qlines = fd_lines_load(fd, &numlines, 0, NULL); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); } @@ -7537,7 +7537,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need result = enumports_hook(talloc_tos(), &numlines, &qlines ); if (!W_ERROR_IS_OK(result)) { - file_lines_free(qlines); + TALLOC_FREE(qlines); return result; } @@ -7545,7 +7545,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { DEBUG(10,("Returning WERR_NOMEM [%s]\n", dos_errstr(WERR_NOMEM))); - file_lines_free(qlines); + TALLOC_FREE(qlines); return WERR_NOMEM; } @@ -7554,7 +7554,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need fill_port_1(&ports[i], qlines[i]); } } - file_lines_free(qlines); + TALLOC_FREE(qlines); *returned = numlines; @@ -7603,13 +7603,13 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need result = enumports_hook(talloc_tos(), &numlines, &qlines ); if ( !W_ERROR_IS_OK(result)) { - file_lines_free(qlines); + TALLOC_FREE(qlines); return result; } if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { - file_lines_free(qlines); + TALLOC_FREE(qlines); return WERR_NOMEM; } @@ -7619,7 +7619,7 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need } } - file_lines_free(qlines); + TALLOC_FREE(qlines); *returned = numlines; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index bb9c3687fb..b99c77c9b8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1700,7 +1700,9 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__)); - *r->out.parm_error = 0; + if (r->out.parm_error) { + *r->out.parm_error = 0; + } get_current_user(&user,p); @@ -2110,7 +2112,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, psd->dacl->revision = NT4_ACL_REVISION; - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); vfs_ChDir(conn, oldcwd); conn_free_internal(conn); return WERR_OK; @@ -2118,7 +2120,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, error_exit: if (fsp) { - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); } if (oldcwd) { @@ -2148,6 +2150,8 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, connection_struct *conn = NULL; int snum; char *oldcwd = NULL; + struct security_descriptor *psd = NULL; + uint32_t security_info_sent = 0; ZERO_STRUCT(st); @@ -2196,9 +2200,29 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, goto error_exit; } + psd = r->in.sd_buf->sd; + security_info_sent = r->in.securityinformation; + + if (psd->owner_sid==0) { + security_info_sent &= ~OWNER_SECURITY_INFORMATION; + } + if (psd->group_sid==0) { + security_info_sent &= ~GROUP_SECURITY_INFORMATION; + } + if (psd->sacl==0) { + security_info_sent &= ~SACL_SECURITY_INFORMATION; + } + if (psd->dacl==0) { + security_info_sent &= ~DACL_SECURITY_INFORMATION; + } + + /* Convert all the generic bits. */ + security_acl_map_generic(psd->dacl, &file_generic_mapping); + security_acl_map_generic(psd->sacl, &file_generic_mapping); + nt_status = SMB_VFS_FSET_NT_ACL(fsp, - r->in.securityinformation, - r->in.sd_buf->sd); + security_info_sent, + psd); if (!NT_STATUS_IS_OK(nt_status) ) { DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL " @@ -2207,7 +2231,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, goto error_exit; } - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); vfs_ChDir(conn, oldcwd); conn_free_internal(conn); return WERR_OK; @@ -2215,7 +2239,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, error_exit: if (fsp) { - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); } if (oldcwd) { diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 483fb8e1e9..4b3fdda3cb 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -18,6 +18,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/srv_svcctl.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -155,23 +156,7 @@ static bool api_svcctl_control_service(pipes_struct *p) static bool api_svcctl_query_service_config(pipes_struct *p) { - SVCCTL_Q_QUERY_SERVICE_CONFIG q_u; - SVCCTL_R_QUERY_SERVICE_CONFIG r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_query_service_config("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_query_service_config(p, &q_u, &r_u); - - if(!svcctl_io_r_query_service_config("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, SVCCTL_QUERY_SERVICE_CONFIG_W); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 6bb538a311..a7215ac686 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -6,6 +6,7 @@ * * Largely Rewritten (Again) by: * Copyright (C) Gerald (Jerry) Carter 2005. + * 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 @@ -61,7 +62,7 @@ static const struct generic_mapping svc_generic_map = bool init_service_op_table( void ) { const char **service_list = lp_svcctl_list(); - int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list ); + int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_length( service_list ); int i; if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) { @@ -140,7 +141,6 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) { SEC_ACE ace[2]; - SEC_ACCESS mask; size_t i = 0; SEC_DESC *sd; SEC_ACL *acl; @@ -148,13 +148,13 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) /* basic access for Everyone */ - init_sec_access(&mask, SC_MANAGER_READ_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_World, + SEC_ACE_TYPE_ACCESS_ALLOWED, SC_MANAGER_READ_ACCESS, 0); /* Full Access 'BUILTIN\Administrators' */ - init_sec_access(&mask,SC_MANAGER_ALL_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, + SEC_ACE_TYPE_ACCESS_ALLOWED, SC_MANAGER_ALL_ACCESS, 0); /* create the security descriptor */ @@ -611,7 +611,9 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ /******************************************************************** ********************************************************************/ -static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG *config, NT_USER_TOKEN *token ) +static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, + struct QUERY_SERVICE_CONFIG *config, + NT_USER_TOKEN *token ) { REGVAL_CTR *values; REGISTRY_VALUE *val; @@ -623,20 +625,17 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG /* now fill in the individual values */ - config->displayname = TALLOC_ZERO_P( ctx, UNISTR2 ); if ( (val = regval_ctr_getvalue( values, "DisplayName" )) != NULL ) - init_unistr2( config->displayname, regval_sz( val ), UNI_STR_TERMINATE ); + config->displayname = regval_sz(val); else - init_unistr2( config->displayname, name, UNI_STR_TERMINATE ); + config->displayname = name; if ( (val = regval_ctr_getvalue( values, "ObjectName" )) != NULL ) { - config->startname = TALLOC_ZERO_P( ctx, UNISTR2 ); - init_unistr2( config->startname, regval_sz( val ), UNI_STR_TERMINATE ); + config->startname = regval_sz(val); } if ( (val = regval_ctr_getvalue( values, "ImagePath" )) != NULL ) { - config->executablepath = TALLOC_ZERO_P( ctx, UNISTR2 ); - init_unistr2( config->executablepath, regval_sz( val ), UNI_STR_TERMINATE ); + config->executablepath = regval_sz(val); } /* a few hard coded values */ @@ -664,11 +663,13 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG } /******************************************************************** + _svcctl_QueryServiceConfigW ********************************************************************/ -WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ) +WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, + struct svcctl_QueryServiceConfigW *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); uint32 buffer_size; WERROR wresult; @@ -683,17 +684,17 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ - r_u->needed = q_u->buffer_size; + *r->out.bytes_needed = r->in.buf_size; - wresult = fill_svc_config( p->mem_ctx, info->name, &r_u->config, p->pipe_user.nt_user_token ); + wresult = fill_svc_config( p->mem_ctx, info->name, r->out.query, p->pipe_user.nt_user_token ); if ( !W_ERROR_IS_OK(wresult) ) return wresult; - buffer_size = svcctl_sizeof_service_config( &r_u->config ); - r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; + buffer_size = ndr_size_QUERY_SERVICE_CONFIG(r->out.query, 0); + *r->out.bytes_needed = (buffer_size > r->in.buf_size) ? buffer_size : r->in.buf_size; - if (buffer_size > q_u->buffer_size ) { - ZERO_STRUCTP( &r_u->config ); + if (buffer_size > r->in.buf_size ) { + TALLOC_FREE(r->out.query); return WERR_INSUFFICIENT_BUFFER; } @@ -957,12 +958,6 @@ WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesSt return WERR_NOT_SUPPORTED; } -WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServiceLockStatusW *r) { p->rng_fault_state = True; diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 3991c5ae02..7e842ed54d 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -230,11 +230,11 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) if ( !regkey ) return WERR_BADFID; - if ((r->out.value_length == NULL) || (r->out.type == NULL)) { + if ((r->out.data_length == NULL) || (r->out.type == NULL)) { return WERR_INVALID_PARAM; } - *r->out.value_length = *r->out.type = REG_NONE; + *r->out.data_length = *r->out.type = REG_NONE; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->key->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->key->type)); @@ -290,8 +290,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) if (r->out.data_size) { *r->out.data_size = 0; } - if (r->out.value_length) { - *r->out.value_length = 0; + if (r->out.data_length) { + *r->out.data_length = 0; } return status; } @@ -306,18 +306,18 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) *r->out.type = val->type; } - *r->out.value_length = outbuf_size; + *r->out.data_length = outbuf_size; if ( *r->in.data_size == 0 || !r->out.data ) { status = WERR_OK; - } else if ( *r->out.value_length > *r->in.data_size ) { + } else if ( *r->out.data_length > *r->in.data_size ) { status = WERR_MORE_DATA; } else { - memcpy( r->out.data, outbuf, *r->out.value_length ); + memcpy( r->out.data, outbuf, *r->out.data_length ); status = WERR_OK; } - *r->out.data_size = *r->out.value_length; + *r->out.data_size = *r->out.data_length; if (free_prs) prs_mem_free(&prs_hkpd); if (free_buf) SAFE_FREE(outbuf); @@ -514,8 +514,8 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS /* pull the message string and perform necessary sanity checks on it */ - if ( r->in.message && r->in.message->name && r->in.message->name->name ) { - if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->name->name )) == NULL ) { + if ( r->in.message && r->in.message->string ) { + if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->string )) == NULL ) { return WERR_NOMEM; } chkmsg = TALLOC_ARRAY(p->mem_ctx, char, strlen(msg)+1); diff --git a/source3/rpcclient/cmd_drsuapi.c b/source3/rpcclient/cmd_drsuapi.c index 71757f5ea3..8fbd798ed0 100644 --- a/source3/rpcclient/cmd_drsuapi.c +++ b/source3/rpcclient/cmd_drsuapi.c @@ -103,7 +103,7 @@ static WERROR cmd_drsuapi_cracknames(struct rpc_pipe_client *cli, werr = cracknames(cli, mem_ctx, &bind_handle, - DRSUAPI_DS_NAME_FORMAT_UKNOWN, + DRSUAPI_DS_NAME_FORMAT_UNKNOWN, DRSUAPI_DS_NAME_FORMAT_FQDN_1779, 1, argv+1, @@ -419,7 +419,7 @@ static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli, werr = cracknames(cli, mem_ctx, &bind_handle, - DRSUAPI_DS_NAME_FORMAT_UKNOWN, + DRSUAPI_DS_NAME_FORMAT_UNKNOWN, DRSUAPI_DS_NAME_FORMAT_FQDN_1779, 1, &name, @@ -495,9 +495,9 @@ static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli, if (level_out == 1) { out_level = 1; ctr1 = &ctr.ctr1; - } else if (level_out == 2) { + } else if (level_out == 2 && ctr.ctr2.mszip1.ts) { out_level = 1; - ctr1 = ctr.ctr2.ctr.mszip1.ctr1; + ctr1 = &ctr.ctr2.mszip1.ts->ctr1; } status = cli_get_session_key(mem_ctx, cli, &session_key); @@ -527,9 +527,16 @@ static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli, ctr6 = &ctr.ctr6; } else if (level_out == 7 && ctr.ctr7.level == 6 - && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) { + && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP + && ctr.ctr7.ctr.mszip6.ts) { out_level = 6; - ctr6 = ctr.ctr7.ctr.mszip6.ctr6; + ctr6 = &ctr.ctr7.ctr.mszip6.ts->ctr6; + } else if (level_out == 7 + && ctr.ctr7.level == 6 + && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS + && ctr.ctr7.ctr.xpress6.ts) { + out_level = 6; + ctr6 = &ctr.ctr7.ctr.xpress6.ts->ctr6; } if (out_level == 6) { diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 5b5b4ff78c..aa8662ce9d 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -61,12 +61,11 @@ done: static void display_query_info_1(struct lsa_AuditLogInfo *r) { d_printf("percent_full:\t%d\n", r->percent_full); - d_printf("log_size:\t%d\n", r->log_size); + d_printf("maximum_log_size:\t%d\n", r->maximum_log_size); d_printf("retention_time:\t%lld\n", (long long)r->retention_time); d_printf("shutdown_in_progress:\t%d\n", r->shutdown_in_progress); d_printf("time_to_shutdown:\t%lld\n", (long long)r->time_to_shutdown); d_printf("next_audit_record:\t%d\n", r->next_audit_record); - d_printf("unknown:\t%d\n", r->unknown); } static void display_query_info_2(struct lsa_AuditEventsInfo *r) @@ -103,7 +102,6 @@ static void display_query_info_11(struct lsa_AuditFullQueryInfo *r) { d_printf("Shutdown on full: %d\n", r->shutdown_on_full); d_printf("Log is full: %d\n", r->log_is_full); - d_printf("Unknown: %d\n", r->unknown); } static void display_query_info_12(struct lsa_DnsDomainInfo *r) @@ -112,8 +110,8 @@ static void display_query_info_12(struct lsa_DnsDomainInfo *r) d_printf("Domain DNS Name: %s\n", r->dns_domain.string); d_printf("Domain Forest Name: %s\n", r->dns_forest.string); d_printf("Domain Sid: %s\n", sid_string_tos(r->sid)); - d_printf("Domain GUID: %s\n", smb_uuid_string(talloc_tos(), - r->domain_guid)); + d_printf("Domain GUID: %s\n", GUID_string(talloc_tos(), + &r->domain_guid)); } static void display_lsa_query_info(union lsa_PolicyInformation *info, @@ -1184,7 +1182,8 @@ static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli, /* Print results */ printf("Account Name: %s, Authority Name: %s\n", - account_name->string, authority_name->string); + account_name->string, authority_name ? authority_name->string : + ""); rpccli_lsa_Close(cli, mem_ctx, &pol); done: diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 87ba65c14b..cdcc0ec28d 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -688,7 +688,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - int logon_type = NET_LOGON_TYPE; + int logon_type = NetlogonNetworkInformation; const char *username, *password; int auth_level = 2; uint32 logon_param = 0; diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index fa1e0fda4d..3494e9123a 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -79,17 +79,17 @@ static void display_samr_user_info_21(struct samr_UserInfo21 *r) dump_data(0, (uint8_t *)r->parameters.array, r->parameters.length*2); printf("\tLogon Time :\t%s\n", - http_timestring(nt_time_to_unix(r->last_logon))); + http_timestring(talloc_tos(), nt_time_to_unix(r->last_logon))); printf("\tLogoff Time :\t%s\n", - http_timestring(nt_time_to_unix(r->last_logoff))); + http_timestring(talloc_tos(), nt_time_to_unix(r->last_logoff))); printf("\tKickoff Time :\t%s\n", - http_timestring(nt_time_to_unix(r->acct_expiry))); + http_timestring(talloc_tos(), nt_time_to_unix(r->acct_expiry))); printf("\tPassword last set Time :\t%s\n", - http_timestring(nt_time_to_unix(r->last_password_change))); + http_timestring(talloc_tos(), nt_time_to_unix(r->last_password_change))); printf("\tPassword can change Time :\t%s\n", - http_timestring(nt_time_to_unix(r->allow_password_change))); + http_timestring(talloc_tos(), nt_time_to_unix(r->allow_password_change))); printf("\tPassword must change Time:\t%s\n", - http_timestring(nt_time_to_unix(r->force_password_change))); + http_timestring(talloc_tos(), nt_time_to_unix(r->force_password_change))); printf("\tunknown_2[0..31]...\n"); /* user passwords? */ @@ -146,24 +146,24 @@ static void display_sam_dom_info_1(struct samr_DomInfo1 *info1) display_time(info1->min_password_age)); } -static void display_sam_dom_info_2(struct samr_DomInfo2 *info2) +static void display_sam_dom_info_2(struct samr_DomGeneralInformation *general) { - printf("Domain:\t\t%s\n", info2->domain_name.string); - printf("Server:\t\t%s\n", info2->primary.string); - printf("Comment:\t%s\n", info2->comment.string); + printf("Domain:\t\t%s\n", general->domain_name.string); + printf("Server:\t\t%s\n", general->primary.string); + printf("Comment:\t%s\n", general->oem_information.string); - printf("Total Users:\t%d\n", info2->num_users); - printf("Total Groups:\t%d\n", info2->num_groups); - printf("Total Aliases:\t%d\n", info2->num_aliases); + printf("Total Users:\t%d\n", general->num_users); + printf("Total Groups:\t%d\n", general->num_groups); + printf("Total Aliases:\t%d\n", general->num_aliases); - printf("Sequence No:\t%llu\n", (unsigned long long)info2->sequence_num); + printf("Sequence No:\t%llu\n", (unsigned long long)general->sequence_num); printf("Force Logoff:\t%d\n", - (int)nt_time_to_unix_abs(&info2->force_logoff_time)); + (int)nt_time_to_unix_abs(&general->force_logoff_time)); - printf("Unknown 2:\t0x%x\n", info2->unknown2); - printf("Server Role:\t%s\n", server_role_str(info2->role)); - printf("Unknown 3:\t0x%x\n", info2->unknown3); + printf("Unknown 2:\t0x%x\n", general->unknown2); + printf("Server Role:\t%s\n", server_role_str(general->role)); + printf("Unknown 3:\t0x%x\n", general->unknown3); } static void display_sam_dom_info_3(struct samr_DomInfo3 *info3) @@ -172,9 +172,9 @@ static void display_sam_dom_info_3(struct samr_DomInfo3 *info3) (int)nt_time_to_unix_abs(&info3->force_logoff_time)); } -static void display_sam_dom_info_4(struct samr_DomInfo4 *info4) +static void display_sam_dom_info_4(struct samr_DomOEMInformation *oem) { - printf("Comment:\t%s\n", info4->comment.string); + printf("Comment:\t%s\n", oem->oem_information.string); } static void display_sam_dom_info_5(struct samr_DomInfo5 *info5) @@ -196,7 +196,7 @@ static void display_sam_dom_info_8(struct samr_DomInfo8 *info8) { printf("Sequence No:\t%llu\n", (unsigned long long)info8->sequence_num); printf("Domain Create Time:\t%s\n", - http_timestring(nt_time_to_unix(info8->domain_create_time))); + http_timestring(talloc_tos(), nt_time_to_unix(info8->domain_create_time))); } static void display_sam_dom_info_9(struct samr_DomInfo9 *info9) @@ -218,7 +218,7 @@ static void display_sam_dom_info_13(struct samr_DomInfo13 *info13) { printf("Sequence No:\t%llu\n", (unsigned long long)info13->sequence_num); printf("Domain Create Time:\t%s\n", - http_timestring(nt_time_to_unix(info13->domain_create_time))); + http_timestring(talloc_tos(), nt_time_to_unix(info13->domain_create_time))); printf("Unknown1:\t%d\n", info13->unknown1); printf("Unknown2:\t%d\n", info13->unknown2); @@ -1607,13 +1607,13 @@ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli, display_sam_dom_info_1(&info->info1); break; case 2: - display_sam_dom_info_2(&info->info2); + display_sam_dom_info_2(&info->general); break; case 3: display_sam_dom_info_3(&info->info3); break; case 4: - display_sam_dom_info_4(&info->info4); + display_sam_dom_info_4(&info->oem); break; case 5: display_sam_dom_info_5(&info->info5); diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 2a9f2b82bb..378ec891a7 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -691,7 +691,7 @@ static void display_reg_value(REGISTRY_VALUE value) printf("%s: REG_SZ: %s\n", value.valuename, text ? text : ""); break; case REG_BINARY: { - char *hex = hex_encode(NULL, value.data_p, value.size); + char *hex = hex_encode_talloc(NULL, value.data_p, value.size); size_t i, len; printf("%s: REG_BINARY:", value.valuename); len = strlen(hex); diff --git a/source3/samba4-templates.mk b/source3/samba4-templates.mk new file mode 100644 index 0000000000..e691af59e9 --- /dev/null +++ b/source3/samba4-templates.mk @@ -0,0 +1,144 @@ +# Templates file for Samba 4 +# This relies on GNU make. +# +# © 2008 Jelmer Vernooij +# +############################################################################### +# Templates +############################################################################### + +# Partially link +# Arguments: target object file, source object files +define partial_link_template +$(1): $(2) ; + @echo Partially linking $$@ + @mkdir -p $$(@D) + @$$(PARTLINK) -o $$@ $$^ +endef + +# Link a binary +# Arguments: target file, depends, flags +define binary_link_template +$(1)4: $(2) $(LIBREPLACE_OBJ) ; + @echo Linking $$@ + @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBS) $$(LIBREPLACE_OBJ) +clean:: + @rm -f $(1) + +everything:: $(1)4 + +endef + +# Link a host-machine binary +# Arguments: target file, depends, flags +define host_binary_link_template +$(1)4: $(2) $(LIBREPLACE_OBJ) ; + @echo Linking $$@ + @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBREPLACE_OBJ) + +clean:: + rm -f $(1) + +binaries:: $(1)4 + + +endef + +# Create a prototype header +# Arguments: header file, c files +define proto_header_template +echo:: ; + echo $(1) ; + +proto:: $(1) ; + +clean:: ; + rm -f $(1) ; + +$(1): $(2) ; + @echo "Creating $$@" + @$$(PERL) $$(srcdir)/../source4/script/mkproto.pl --srcdir=$$(srcdir)/../source4 --builddir=$$(builddir)/../source4 --public=/dev/null --private=$$@ $$^ +endef + +# Shared module +# Arguments: Target, dependencies, objects +define shared_module_template + +$(1): $(2) ; + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) + +PLUGINS += $(1) + +endef + +# Shared library +# Arguments: Target, dependencies, link flags, soname +define shared_library_template +$(1): $(2) + @echo Linking $$@ + @mkdir -p $$(@D) + @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \ + $(3) \ + $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4))) $$(LIBS) + +ifneq ($(notdir $(1)),$(notdir $(4))) +$(4): $(1) + @echo "Creating symbolic link for $$@" + @ln -fs $$(= 1.2.0, + [], + [ + SMB_INCLUDE_MK(../lib/talloc/config.mk) + ] +) + +SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.3, + [], + [ + m4_include(../lib/tdb/libtdb.m4) + SMB_INCLUDE_MK(../lib/tdb/config.mk) + ] +) + +SMB_INCLUDE_MK(../lib/tdb/python.mk) + +SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1, + [ + SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk) + SMB_INCLUDE_MK(lib/ldb/tools/config.mk) + define_ldb_modulesdir=no + ], + [ + # Here we need to do some tricks + # with AC_CONFIG_COMMANDS_PRE + # as that's the deferrs the commands + # to location after $prefix and $exec_prefix + # have usefull values and directly before + # creating config.status. + # + # The 'eval eval echo' trick is used to + # actually get the raw absolute directory + # path as this is needed in config.h + define_ldb_modulesdir=yes + AC_CONFIG_COMMANDS_PRE([ + if test x"$define_ldb_modulesdir" = x"yes";then + LDB_MODULESDIR=`eval eval echo ${modulesdir}/ldb` + AC_DEFINE_UNQUOTED(LDB_MODULESDIR, "${LDB_MODULESDIR}" , [ldb Modules directory]) + fi + ]) + ldbdir="\$(abspath \$(srcdir)/../source4/lib/ldb)" + AC_SUBST(ldbdir) + m4_include(lib/ldb/sqlite3.m4) + m4_include(lib/ldb/libldb.m4) + SMB_INCLUDE_MK(lib/ldb/config.mk) + AC_CONFIG_FILES(../source4/lib/ldb/ldb.pc) + ] +) +SMB_INCLUDE_MK(lib/ldb/python.mk) + +# Not sure why we need this.. +SMB_ENABLE(swig_ldb,YES) + +m4_include(lib/tls/config.m4) +eventsdir="../source4/lib/events" +m4_include(lib/events/libevents.m4) + +dnl m4_include(auth/kerberos/config.m4) +m4_include(auth/gensec/config.m4) +m4_include(smbd/process_model.m4) +m4_include(ntvfs/posix/config.m4) +m4_include(ntvfs/unixuid/config.m4) +m4_include(auth/config.m4) +m4_include(kdc/config.m4) +m4_include(ntvfs/sysdep/config.m4) +m4_include(nsswitch/config.m4) + +dnl Samba 4 files +AC_SUBST(LD) +AC_LIBREPLACE_SHLD_FLAGS +SMB_WRITE_MAKEVARS(samba4-config.mk, [prefix exec_prefix CPPFLAGS LDSHFLAGS POPT_OBJ CFLAGS TALLOC_OBJ POPT_LIBS]) + +oldbuilddir="$builddir" +builddir="$builddir/../source4" +SMB_WRITE_PERLVARS(../source4/build/smb_build/config.pm) +builddir="$oldbuilddir" + +echo "configure: creating ../source4/config.mk" +cat >../source4/config.mk<> ${builddir}/Makefile +]) + diff --git a/source3/samba4.mk b/source3/samba4.mk new file mode 100644 index 0000000000..93022c5239 --- /dev/null +++ b/source3/samba4.mk @@ -0,0 +1,171 @@ +# samba 4 bits + +PROG_LD = $(LD) +BNLD = $(CC) +HOSTLD = $(CC) +PARTLINK = $(PROG_LD) -r +MDLD = $(SHLD) +MDLD_FLAGS = $(LDSHFLAGS) + +samba4srcdir = $(srcdir)/../source4 + +# Flags used for the samba 4 files +# $(srcdir)/include is required for config.h +SAMBA4_CFLAGS = -I.. -I$(samba4srcdir) -I$(samba4srcdir)/include \ + -I$(samba4srcdir)/../lib/replace -I$(samba4srcdir)/lib \ + -I$(heimdalsrcdir)/lib/hcrypto -I$(tallocdir) \ + -I$(srcdir)/include -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H + +.SUFFIXES: .ho + +# No cross compilation for now, thanks +.c.ho: + @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ + dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi + @if test -n "$(CC_CHECKER)"; then \ + echo "Checking $*.c with '$(CC_CHECKER)'";\ + $(CHECK_CC); \ + fi + @echo Compiling $*.c + @$(COMPILE) && exit 0;\ + echo "The following command failed:" 1>&2;\ + echo "$(subst ",\",$(COMPILE_CC))" 1>&2;\ + $(COMPILE_CC) >/dev/null 2>&1 + +# The order really does matter here! GNU Make 3.80 will break if the more specific +# overrides are not specified first. +ifeq ($(MAKE_VERSION),3.81) +%.o: CFLAGS+=$(FLAGS) +$(samba4srcdir)/%.o: CFLAGS=$(SAMBA4_CFLAGS) +$(samba4srcdir)/%.ho: CFLAGS=$(SAMBA4_CFLAGS) +$(heimdalsrcdir)/%.o: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +$(heimdalsrcdir)/%.ho: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +else +$(heimdalsrcdir)/%.o: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +$(heimdalsrcdir)/%.ho: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir) +$(samba4srcdir)/%.o: CFLAGS=$(SAMBA4_CFLAGS) +$(samba4srcdir)/%.ho: CFLAGS=$(SAMBA4_CFLAGS) +%.o: CFLAGS+=$(FLAGS) +endif + +# Create a static library +%.a: + @echo Linking $@ + @rm -f $@ + @mkdir -p $(@D) + @$(AR) -rc $@ $^ + +INTERN_LDFLAGS = -L${builddir}/bin/static -L${builddir}/bin/shared + +pidldir = $(samba4srcdir)/../pidl +include $(pidldir)/config.mk +include samba4-config.mk +include samba4-templates.mk + +zlibsrcdir := $(samba4srcdir)/../lib/zlib +dynconfigsrcdir := $(samba4srcdir)/dynconfig +heimdalsrcdir := $(samba4srcdir)/heimdal +dsdbsrcdir := $(samba4srcdir)/dsdb +smbdsrcdir := $(samba4srcdir)/smbd +clustersrcdir := $(samba4srcdir)/cluster +libnetsrcdir := $(samba4srcdir)/libnet +authsrcdir := $(samba4srcdir)/auth +nsswitchsrcdir := $(samba4srcdir)/nsswitch +libsrcdir := $(samba4srcdir)/lib +libsocketsrcdir := $(samba4srcdir)/lib/socket +libcharsetsrcdir := $(samba4srcdir)/lib/charset +ldb_sambasrcdir := $(samba4srcdir)/lib/ldb-samba +libtlssrcdir := $(samba4srcdir)/lib/tls +libregistrysrcdir := $(samba4srcdir)/lib/registry +libmessagingsrcdir := $(samba4srcdir)/lib/messaging +libeventssrcdir := $(samba4srcdir)/lib/events +libcmdlinesrcdir := $(samba4srcdir)/lib/cmdline +poptsrcdir := $(samba4srcdir)/../lib/popt +socketwrappersrcdir := $(samba4srcdir)/../lib/socket_wrapper +nsswrappersrcdir := $(samba4srcdir)/../lib/nss_wrapper +libstreamsrcdir := $(samba4srcdir)/lib/stream +libutilsrcdir := $(samba4srcdir)/../lib/util +libtdrsrcdir := $(samba4srcdir)/lib/tdr +libdbwrapsrcdir := $(samba4srcdir)/lib/dbwrap +libcryptosrcdir := $(samba4srcdir)/../lib/crypto +libtorturesrcdir := $(samba4srcdir)/lib/torture +libcompressionsrcdir := $(samba4srcdir)/../lib/compression +libgencachesrcdir := $(samba4srcdir)/lib +paramsrcdir := $(samba4srcdir)/param +smb_serversrcdir := $(samba4srcdir)/smb_server +rpc_serversrcdir := $(samba4srcdir)/rpc_server +ldap_serversrcdir := $(samba4srcdir)/ldap_server +web_serversrcdir := $(samba4srcdir)/web_server +winbindsrcdir := $(samba4srcdir)/winbind +nbt_serversrcdir := $(samba4srcdir)/nbt_server +wrepl_serversrcdir := $(samba4srcdir)/wrepl_server +cldap_serversrcdir := $(samba4srcdir)/cldap_server +librpcsrcdir := $(samba4srcdir)/librpc +torturesrcdir := $(samba4srcdir)/torture +utilssrcdir := $(samba4srcdir)/utils +ntvfssrcdir := $(samba4srcdir)/ntvfs +ntptrsrcdir := $(samba4srcdir)/ntptr +clientsrcdir := $(samba4srcdir)/client +libclisrcdir := $(samba4srcdir)/libcli +libclinbtsrcdir := $(samba4srcdir)/../libcli/nbt +pyscriptsrcdir := $(samba4srcdir)/scripting/python +kdcsrcdir := $(samba4srcdir)/kdc +smbreadlinesrcdir := $(samba4srcdir)/lib/smbreadline +ntp_signdsrcdir := $(samba4srcdir)/ntp_signd +tdbsrcdir := $(samba4srcdir)/../lib/tdb +ldbsrcdir := $(samba4srcdir)/lib/ldb +tallocsrcdir := $(samba4srcdir)/../lib/talloc +comsrcdir := $(samba4srcdir)/lib/com +override ASN1C = bin/asn1_compile4 +override ET_COMPILER = bin/compile_et4 +include samba4-data.mk +include $(samba4srcdir)/static_deps.mk +include $(samba4srcdir)/build/make/python.mk + +INSTALLPERMS = 0755 + +$(DESTDIR)$(bindir)/%: bin/%4 installdirs + @mkdir -p $(@D) + @echo Installing $(@F) as $@ + @if test -f $@; then rm -f $@.old; mv $@ $@.old; fi + @cp $< $@ + @chmod $(INSTALLPERMS) $@ + +$(DESTDIR)$(sbindir)/%: bin/%4 installdirs + @mkdir -p $(@D) + @echo Installing $(@F) as $@ + @if test -f $@; then rm -f $@.old; mv $@ $@.old; fi + @cp $< $@ + @chmod $(INSTALLPERMS) $@ + +clean:: + @echo Removing samba 4 objects + @-find $(samba4srcdir) -name '*.o' -exec rm -f '{}' \; + @echo Removing samba 4 hostcc objects + @-find $(samba4srcdir) -name '*.ho' -exec rm -f '{}' \; + @echo Removing samba 4 libraries + @-rm -f $(STATIC_LIBS) $(SHARED_LIBS) + @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o + @echo Removing samba 4 modules + @-rm -f bin/modules/*/*.$(SHLIBEXT) + @-rm -f bin/*_init_module.c + @echo Removing samba 4 dummy targets + @-rm -f bin/.*_* + @echo Removing samba 4 generated files + @-rm -f bin/*_init_module.c + @-rm -rf $(samba4srcdir)/librpc/gen_* + +proto:: $(PROTO_HEADERS) +modules:: $(PLUGINS) + +all:: basics bin/samba4 bin/regpatch4 bin/regdiff4 bin/regshell4 bin/regtree4 bin/smbclient4 +torture:: basics bin/smbtorture4 +everything:: basics $(patsubst %,%4,$(BINARIES)) + + +etags:: + etags --append=yes `find $(samba4srcdir) -name "*.[ch]"` + +ctags:: + ctags --append=yes `find $(samba4srcdir) -name "*.[ch]"` + diff --git a/source3/script/build_idl.sh b/source3/script/build_idl.sh index 7aaddc70c7..34f262ee00 100755 --- a/source3/script/build_idl.sh +++ b/source3/script/build_idl.sh @@ -1,18 +1,14 @@ #!/bin/sh -PIDL_ARGS="--outputdir librpc/gen_ndr --header --ndr-parser --samba3-ndr-server --samba3-ndr-client --" -PIDL_EXTRA_ARGS="$*" +ARGS="--includedir=../librpc/idl --outputdir librpc/gen_ndr --header --ndr-parser --samba3-ndr-server --samba3-ndr-client $PIDL_ARGS --" +IDL_FILES="$*" oldpwd=`pwd` cd ${srcdir} [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1 -if [ -z "$PIDL" ] ; then - PIDL=pidl -fi - -PIDL="$PIDL ${PIDL_ARGS} ${PIDL_EXTRA_ARGS}" +PIDL="$PIDL $ARGS" ## ## Find newer files rather than rebuild all of them @@ -23,12 +19,12 @@ for f in ${IDL_FILES}; do basename=`basename $f .idl` ndr="librpc/gen_ndr/ndr_$basename.c" - if [ -f $ndr ] && false; then - if [ "x`find librpc/idl/$f -newer $ndr -print`" = "xlibrpc/idl/$f" ]; then - list="$list librpc/idl/$f" + if [ -f $ndr ]; then + if [ "x`find $f -newer $ndr -print`" = "x$f" ]; then + list="$list $f" fi else - list="$list librpc/idl/$f" + list="$list $f" fi done diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index 15e48b00ef..0894b2507d 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -166,9 +166,9 @@ cat >$SERVERCONFFILE<. + +tempdir=`mktemp -d /tmp/wb_padXXXXXX` +test -n "$tempdir" || exit 1 +cat >> $tempdir/wb_pad.c << _EOF +#include "nsswitch/winbind_client.h" + +int main(int argc, const char **argv) +{ + struct winbindd_request req; + struct winbindd_response resp; + + if (argc != 2) { + printf("usage: %s [req|resp]\n", argv[0]); + return 0; + } + + if (strcmp(argv[1], "req") == 0) { + printf("%d\n", (uint32_t)sizeof(req)); + } + if (strcmp(argv[1], "resp") == 0) { + printf("%d\n", (uint32_t)sizeof(resp)); + } + + return 0; +} +_EOF + +cleanup() { + rm -f $tempdir/wb_pad_32 $tempdir/wb_pad_64 $tempdir/wb_pad.c + rmdir $tempdir +} + +cflags="-I. -I./../lib/replace -Iinclude" +${CC:-gcc} -m32 $RPM_OPT_FLAGS $CFLAGS -o $tempdir/wb_pad_32 $cflags $tempdir/wb_pad.c +if [ $? -ne 0 ]; then + cleanup + exit 1 +fi +${CC:-gcc} -m64 $RPM_OPT_FLAGS $CFLAGS -o $tempdir/wb_pad_64 $cflags $tempdir/wb_pad.c +if [ $? -ne 0 ]; then + cleanup + exit 1 +fi + +out_64_req=`$tempdir/wb_pad_64 req` +out_64_resp=`$tempdir/wb_pad_64 resp` +out_32_req=`$tempdir/wb_pad_32 req` +out_32_resp=`$tempdir/wb_pad_32 resp` + +cleanup + +if test "$out_64_req" != "$out_32_req"; then + echo "winbind request size differs!" + echo "64bit: $out_64_req" + echo "32bit: $out_32_req" + exit 1 +fi + +if test "$out_64_resp" != "$out_32_resp"; then + echo "winbind response size differs!" + echo "64bit: $out_64_resp" + echo "32bit: $out_32_resp" + exit 1 +fi + +exit 0 diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 49761c3233..0f5264bcd8 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -89,23 +89,23 @@ struct service_display_info common_unix_svcs[] = { static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx ) { SEC_ACE ace[4]; - SEC_ACCESS mask; size_t i = 0; - SEC_DESC *sd; - SEC_ACL *acl; + SEC_DESC *sd = NULL; + SEC_ACL *acl = NULL; size_t sd_size; /* basic access for Everyone */ - init_sec_access(&mask, SERVICE_READ_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_World, + SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_READ_ACCESS, 0); - init_sec_access(&mask,SERVICE_EXECUTE_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users, + SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_EXECUTE_ACCESS, 0); - init_sec_access(&mask,SERVICE_ALL_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators, + SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_ALL_ACCESS, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, + SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_ALL_ACCESS, 0); /* create the security descriptor */ @@ -188,11 +188,11 @@ static char *cleanup_string( const char *string ) static bool read_init_file( const char *servicename, struct rcinit_file_information **service_info ) { - struct rcinit_file_information *info; + struct rcinit_file_information *info = NULL; char *filepath = NULL; char str[1024]; - XFILE *f; - char *p; + XFILE *f = NULL; + char *p = NULL; if ( !(info = TALLOC_ZERO_P( NULL, struct rcinit_file_information ) ) ) return False; @@ -335,12 +335,12 @@ static void fill_service_values( const char *name, REGVAL_CTR *values ) static void add_new_svc_name( REGISTRY_KEY *key_parent, REGSUBKEY_CTR *subkeys, const char *name ) { - REGISTRY_KEY *key_service, *key_secdesc; + REGISTRY_KEY *key_service = NULL, *key_secdesc = NULL; WERROR wresult; char *path = NULL; - REGVAL_CTR *values; - REGSUBKEY_CTR *svc_subkeys; - SEC_DESC *sd; + REGVAL_CTR *values = NULL; + REGSUBKEY_CTR *svc_subkeys = NULL; + SEC_DESC *sd = NULL; DATA_BLOB sd_blob; NTSTATUS status; @@ -444,7 +444,7 @@ void svcctl_init_keys( void ) { const char **service_list = lp_svcctl_list(); int i; - REGSUBKEY_CTR *subkeys; + REGSUBKEY_CTR *subkeys = NULL; REGISTRY_KEY *key = NULL; WERROR wresult; @@ -502,9 +502,9 @@ void svcctl_init_keys( void ) SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token ) { - REGISTRY_KEY *key; - REGVAL_CTR *values; - REGISTRY_VALUE *val; + REGISTRY_KEY *key = NULL; + REGVAL_CTR *values = NULL; + REGISTRY_VALUE *val = NULL; SEC_DESC *ret_sd = NULL; char *path= NULL; WERROR wresult; @@ -563,10 +563,10 @@ done: bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, NT_USER_TOKEN *token ) { - REGISTRY_KEY *key; + REGISTRY_KEY *key = NULL; WERROR wresult; char *path = NULL; - REGVAL_CTR *values; + REGVAL_CTR *values = NULL; prs_struct ps; bool ret = False; @@ -620,8 +620,8 @@ const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, NT_USER_TO { char *display_name = NULL; REGISTRY_KEY *key = NULL; - REGVAL_CTR *values; - REGISTRY_VALUE *val; + REGVAL_CTR *values = NULL; + REGISTRY_VALUE *val = NULL; char *path = NULL; WERROR wresult; @@ -670,8 +670,8 @@ const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, NT_USER { char *description = NULL; REGISTRY_KEY *key = NULL; - REGVAL_CTR *values; - REGISTRY_VALUE *val; + REGVAL_CTR *values = NULL; + REGISTRY_VALUE *val = NULL; char *path = NULL; WERROR wresult; @@ -715,7 +715,7 @@ const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, NT_USER REGVAL_CTR *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token ) { REGISTRY_KEY *key = NULL; - REGVAL_CTR *values; + REGVAL_CTR *values = NULL; char *path = NULL; WERROR wresult; diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 74275368bd..c3fd0a2bc0 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -24,7 +24,17 @@ /* The signal we'll use to signify aio done. */ #ifndef RT_SIGNAL_AIO -#define RT_SIGNAL_AIO (SIGRTMIN+3) +#ifndef SIGRTMIN +#define SIGRTMIN NSIG +#endif +#define RT_SIGNAL_AIO (SIGRTMIN+3) +#endif + +#ifndef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR +#ifdef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR +#define sival_int sigval_int +#define sival_ptr sigval_ptr +#endif #endif /**************************************************************************** @@ -581,6 +591,11 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr) { int err; + if(!aio_ex) { + DEBUG(3, ("handle_aio_completed: Non-existing aio_ex passed\n")); + return false; + } + /* Ensure the operation has really completed. */ if (SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb) == EINPROGRESS) { DEBUG(10,( "handle_aio_completed: operation mid %u still in " diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index 479361a8c1..4374b50eac 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -33,10 +33,10 @@ typedef struct _blocking_lock_record { files_struct *fsp; struct timeval expire_time; int lock_num; - SMB_BIG_UINT offset; - SMB_BIG_UINT count; - uint32 lock_pid; - uint32 blocking_pid; /* PID that blocks us. */ + uint64_t offset; + uint64_t count; + uint32_t lock_pid; + uint32_t blocking_pid; /* PID that blocks us. */ enum brl_flavour lock_flav; enum brl_type lock_type; char *inbuf; @@ -154,12 +154,12 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck, files_struct *fsp, int lock_timeout, int lock_num, - uint32 lock_pid, + uint32_t lock_pid, enum brl_type lock_type, enum brl_flavour lock_flav, - SMB_BIG_UINT offset, - SMB_BIG_UINT count, - uint32 blocking_pid) + uint64_t offset, + uint64_t count, + uint32_t blocking_pid) { static bool set_lock_msg; size_t length = smb_len(req->inbuf)+4; @@ -331,7 +331,7 @@ static void reply_lockingX_error(blocking_lock_record *blr, NTSTATUS status) char *inbuf = blr->inbuf; files_struct *fsp = blr->fsp; uint16 num_ulocks = SVAL(inbuf,smb_vwv6); - SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT) 0; + uint64_t count = (uint64_t)0, offset = (uint64_t) 0; uint32 lock_pid; unsigned char locktype = CVAL(inbuf,smb_vwv3); bool large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES); @@ -420,7 +420,7 @@ static bool process_lockingX(blocking_lock_record *blr) files_struct *fsp = blr->fsp; uint16 num_ulocks = SVAL(inbuf,smb_vwv6); uint16 num_locks = SVAL(inbuf,smb_vwv7); - SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT)0; + uint64_t count = (uint64_t)0, offset = (uint64_t)0; uint32 lock_pid; bool large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES); char *data; @@ -704,7 +704,6 @@ static void process_blocking_lock_queue(void) * sitting around.... */ chain_size = 0; - file_chain_reset(); fsp = blr->fsp; conn = conn_find(SVAL(blr->inbuf,smb_tid)); @@ -875,8 +874,8 @@ static void process_blocking_lock_cancel_message(struct messaging_context *ctx, bool blocking_lock_cancel(files_struct *fsp, uint32 lock_pid, - SMB_BIG_UINT offset, - SMB_BIG_UINT count, + uint64_t offset, + uint64_t count, enum brl_flavour lock_flav, unsigned char locktype, NTSTATUS err) diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index 2596e73380..64a4311256 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -1131,7 +1131,7 @@ NTSTATUS change_oem_password(struct samu *hnd, char *old_passwd, char *new_passw if ((can_change_time != 0) && (time(NULL) < can_change_time)) { DEBUG(1, ("user %s cannot change password now, must " "wait until %s\n", username, - http_timestring(can_change_time))); + http_timestring(talloc_tos(), can_change_time))); if (samr_reject_reason) { *samr_reject_reason = SAMR_REJECT_OTHER; } diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 818b4c70a8..d4c531ab19 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -505,7 +505,8 @@ static NTSTATUS update_write_time_on_close(struct files_struct *fsp) delete on close is done on normal and shutdown close. ****************************************************************************/ -static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_type) +static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp, + enum file_close_type close_type) { NTSTATUS status = NT_STATUS_OK; NTSTATUS saved_status1 = NT_STATUS_OK; @@ -536,7 +537,7 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_ if (fsp->print_file) { print_fsp_end(fsp, close_type); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_OK; } @@ -585,7 +586,7 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_ conn->num_files_open, nt_errstr(status) )); - file_free(fsp); + file_free(req, fsp); return status; } @@ -593,7 +594,8 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_ Close a directory opened by an NT SMB call. ****************************************************************************/ -static NTSTATUS close_directory(files_struct *fsp, enum file_close_type close_type) +static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, + enum file_close_type close_type) { struct share_mode_lock *lck = 0; bool delete_dir = False; @@ -698,7 +700,7 @@ static NTSTATUS close_directory(files_struct *fsp, enum file_close_type close_ty * Do the code common to files and directories. */ close_filestruct(fsp); - file_free(fsp); + file_free(req, fsp); return status; } @@ -706,17 +708,18 @@ static NTSTATUS close_directory(files_struct *fsp, enum file_close_type close_ty Close a files_struct. ****************************************************************************/ -NTSTATUS close_file(files_struct *fsp, enum file_close_type close_type) +NTSTATUS close_file(struct smb_request *req, files_struct *fsp, + enum file_close_type close_type) { NTSTATUS status; struct files_struct *base_fsp = fsp->base_fsp; if(fsp->is_directory) { - status = close_directory(fsp, close_type); + status = close_directory(req, fsp, close_type); } else if (fsp->fake_file_handle != NULL) { - status = close_fake_file(fsp); + status = close_fake_file(req, fsp); } else { - status = close_normal_file(fsp, close_type); + status = close_normal_file(req, fsp, close_type); } if ((base_fsp != NULL) && (close_type != SHUTDOWN_CLOSE)) { @@ -731,7 +734,7 @@ NTSTATUS close_file(files_struct *fsp, enum file_close_type close_type) */ SMB_ASSERT(base_fsp->base_fsp == NULL); - close_file(base_fsp, close_type); + close_file(req, base_fsp, close_type); } return status; @@ -768,5 +771,5 @@ void msg_close_file(struct messaging_context *msg_ctx, DEBUG(10,("msg_close_file: failed to find file.\n")); return; } - close_file(fsp, NORMAL_CLOSE); + close_file(NULL, fsp, NORMAL_CLOSE); } diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index b9433bb965..7f34d2b8e2 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -252,8 +252,8 @@ void conn_free_internal(connection_struct *conn) /* Free vfs_connection_struct */ handle = conn->vfs_handles; while(handle) { - DLIST_REMOVE(conn->vfs_handles, handle); thandle = handle->next; + DLIST_REMOVE(conn->vfs_handles, handle); if (handle->free_data) handle->free_data(&handle->data); handle = thandle; diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 8dd5964f5f..3b72a9505a 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -2,17 +2,17 @@ Unix SMB/CIFS implementation. connection claim routines Copyright (C) Andrew Tridgell 1998 - + 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 . */ @@ -63,7 +63,7 @@ static int count_fn(struct db_record *rec, void *udp) { struct count_stat *cs = (struct count_stat *)udp; - + if (crec->cnum == -1) { return 0; } @@ -159,7 +159,7 @@ bool claim_connection(connection_struct *conn, const char *name, } crec.start = time(NULL); crec.bcast_msg_flags = msg_flags; - + strlcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)); strlcpy(crec.addr,conn?conn->client_address: client_addr(get_client_fd(),addr,sizeof(addr)), @@ -224,109 +224,3 @@ bool register_message_flags(bool doreg, uint32 msg_flags) return True; } - -/********************************************************************* -*********************************************************************/ - -static TDB_DATA* make_pipe_rec_key( struct pipe_open_rec *prec ) -{ - TDB_DATA *kbuf = NULL; - fstring key_string; - - if ( !prec ) - return NULL; - - if ( (kbuf = TALLOC_P(prec, TDB_DATA)) == NULL ) { - return NULL; - } - - snprintf( key_string, sizeof(key_string), "%s/%d/%d", - prec->name, procid_to_pid(&prec->pid), prec->pnum ); - - *kbuf = string_term_tdb_data(talloc_strdup(prec, key_string)); - if (kbuf->dptr == NULL ) - return NULL; - - return kbuf; -} - -/********************************************************************* -*********************************************************************/ - -static void fill_pipe_open_rec( struct pipe_open_rec *prec, smb_np_struct *p ) -{ - prec->pid = pid_to_procid(sys_getpid()); - prec->pnum = p->pnum; - prec->uid = geteuid(); - fstrcpy( prec->name, p->name ); - - return; -} - -/********************************************************************* -*********************************************************************/ - -bool store_pipe_opendb( smb_np_struct *p ) -{ - struct db_record *dbrec; - struct pipe_open_rec *prec; - TDB_DATA *key; - TDB_DATA data; - bool ret = False; - - if ( (prec = TALLOC_P( NULL, struct pipe_open_rec)) == NULL ) { - DEBUG(0,("store_pipe_opendb: talloc failed!\n")); - return False; - } - - fill_pipe_open_rec( prec, p ); - if ( (key = make_pipe_rec_key( prec )) == NULL ) { - goto done; - } - - data.dptr = (uint8 *)prec; - data.dsize = sizeof(struct pipe_open_rec); - - if (!(dbrec = connections_fetch_record(prec, *key))) { - DEBUG(0, ("connections_fetch_record failed\n")); - goto done; - } - - ret = NT_STATUS_IS_OK(dbrec->store(dbrec, data, TDB_REPLACE)); - -done: - TALLOC_FREE( prec ); - return ret; -} - -/********************************************************************* -*********************************************************************/ - -bool delete_pipe_opendb( smb_np_struct *p ) -{ - struct db_record *dbrec; - struct pipe_open_rec *prec; - TDB_DATA *key; - bool ret = False; - - if ( (prec = TALLOC_P( NULL, struct pipe_open_rec)) == NULL ) { - DEBUG(0,("store_pipe_opendb: talloc failed!\n")); - return False; - } - - fill_pipe_open_rec( prec, p ); - if ( (key = make_pipe_rec_key( prec )) == NULL ) { - goto done; - } - - if (!(dbrec = connections_fetch_record(prec, *key))) { - DEBUG(0, ("connections_fetch_record failed\n")); - goto done; - } - - ret = NT_STATUS_IS_OK(dbrec->delete_rec(dbrec)); - -done: - TALLOC_FREE( prec ); - return ret; -} diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 1ddcd48d40..cd09d73923 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -23,10 +23,10 @@ Normalise for DOS usage. ****************************************************************************/ -static void disk_norm(bool small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +static void disk_norm(bool small_query, uint64_t *bsize,uint64_t *dfree,uint64_t *dsize) { /* check if the disk is beyond the max disk size */ - SMB_BIG_UINT maxdisksize = lp_maxdisksize(); + uint64_t maxdisksize = lp_maxdisksize(); if (maxdisksize) { /* convert to blocks - and don't overflow */ maxdisksize = ((maxdisksize*1024)/(*bsize))*1024; @@ -62,13 +62,13 @@ static void disk_norm(bool small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, Return number of 1K blocks available on a path and total number. ****************************************************************************/ -SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small_query, - SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_query, + uint64_t *bsize,uint64_t *dfree,uint64_t *dsize) { - SMB_BIG_UINT dfree_retval; - SMB_BIG_UINT dfree_q = 0; - SMB_BIG_UINT bsize_q = 0; - SMB_BIG_UINT dsize_q = 0; + uint64_t dfree_retval; + uint64_t dfree_q = 0; + uint64_t bsize_q = 0; + uint64_t dsize_q = 0; const char *dfree_command; (*dfree) = (*dsize) = 0; @@ -90,7 +90,7 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small path); if (!syscmd) { - return (SMB_BIG_UINT)-1; + return (uint64_t)-1; } DEBUG (3, ("disk_free: Running command %s\n", syscmd)); @@ -112,7 +112,7 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small *bsize = STR_TO_SMB_BIG_UINT(p, NULL); else *bsize = 1024; - file_lines_free(lines); + TALLOC_FREE(lines); DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n", (unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize)); @@ -126,14 +126,14 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small if (sys_fsusage(path, dfree, dsize) != 0) { DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", strerror(errno) )); - return (SMB_BIG_UINT)-1; + return (uint64_t)-1; } } } else { if (sys_fsusage(path, dfree, dsize) != 0) { DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", strerror(errno) )); - return (SMB_BIG_UINT)-1; + return (uint64_t)-1; } } @@ -174,16 +174,16 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small Potentially returned cached dfree info. ****************************************************************************/ -SMB_BIG_UINT get_dfree_info(connection_struct *conn, +uint64_t get_dfree_info(connection_struct *conn, const char *path, bool small_query, - SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, - SMB_BIG_UINT *dsize) + uint64_t *bsize, + uint64_t *dfree, + uint64_t *dsize) { int dfree_cache_time = lp_dfree_cache_time(SNUM(conn)); struct dfree_cached_info *dfc = conn->dfree_info; - SMB_BIG_UINT dfree_ret; + uint64_t dfree_ret; if (!dfree_cache_time) { return SMB_VFS_DISK_FREE(conn,path,small_query,bsize,dfree,dsize); @@ -199,7 +199,7 @@ SMB_BIG_UINT get_dfree_info(connection_struct *conn, dfree_ret = SMB_VFS_DISK_FREE(conn,path,small_query,bsize,dfree,dsize); - if (dfree_ret == (SMB_BIG_UINT)-1) { + if (dfree_ret == (uint64_t)-1) { /* Don't cache bad data. */ return dfree_ret; } diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 88c6a51770..784b36d9bd 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -277,14 +277,15 @@ static bool set_ea_dos_attribute(connection_struct *conn, const char *path, SMB_ * are not violating security in doing the setxattr. */ - if (!NT_STATUS_IS_OK(open_file_fchmod(conn,path,sbuf,&fsp))) + if (!NT_STATUS_IS_OK(open_file_fchmod(NULL, conn, path, sbuf, + &fsp))) return ret; become_root(); if (SMB_VFS_SETXATTR(conn, path, SAMBA_XATTR_DOS_ATTRIB, attrstr, strlen(attrstr), 0) == 0) { ret = True; } unbecome_root(); - close_file_fchmod(fsp); + close_file_fchmod(NULL, fsp); return ret; } DEBUG(10,("set_ea_dos_attribute: set EA %s on file %s\n", attrstr, path)); @@ -540,12 +541,13 @@ int file_set_dosmode(connection_struct *conn, const char *fname, * break batch oplocks open by others. JRA. */ files_struct *fsp; - if (!NT_STATUS_IS_OK(open_file_fchmod(conn,fname,st,&fsp))) + if (!NT_STATUS_IS_OK(open_file_fchmod(NULL, conn, fname, st, + &fsp))) return -1; become_root(); ret = SMB_VFS_FCHMOD(fsp, unixmode); unbecome_root(); - close_file_fchmod(fsp); + close_file_fchmod(NULL, fsp); if (!newfile) { notify_fname(conn, NOTIFY_ACTION_MODIFIED, FILE_NOTIFY_CHANGE_ATTRIBUTES, fname); diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 8dd9abee1a..58b09604c4 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -98,7 +98,7 @@ enum FAKE_FILE_TYPE is_fake_file(const char *fname) Open a fake quota file with a share mode. ****************************************************************************/ -NTSTATUS open_fake_file(connection_struct *conn, +NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn, uint16_t current_vuid, enum FAKE_FILE_TYPE fake_file_type, const char *fname, @@ -118,7 +118,7 @@ NTSTATUS open_fake_file(connection_struct *conn, } - status = file_new(conn, &fsp); + status = file_new(req, conn, &fsp); if(!NT_STATUS_IS_OK(status)) { return status; } @@ -137,7 +137,7 @@ NTSTATUS open_fake_file(connection_struct *conn, fsp->fake_file_handle = init_fake_file_handle(fake_file_type); if (fsp->fake_file_handle==NULL) { - file_free(fsp); + file_free(req, fsp); return NT_STATUS_NO_MEMORY; } @@ -146,16 +146,8 @@ NTSTATUS open_fake_file(connection_struct *conn, return NT_STATUS_OK; } -void destroy_fake_file_handle(struct fake_file_handle **fh) +NTSTATUS close_fake_file(struct smb_request *req, files_struct *fsp) { - if (!fh) { - return; - } - TALLOC_FREE(*fh); -} - -NTSTATUS close_fake_file(files_struct *fsp) -{ - file_free(fsp); + file_free(req, fsp); return NT_STATUS_OK; } diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 41a0b9296a..562f1e8d94 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -101,8 +101,7 @@ get any fatal errors that should immediately terminate the calling SMB processing whilst resolving. If the saved_last_component != 0, then the unmodified last component -of the pathname is returned there. This is used in an exceptional -case in reply_mv (so far). If saved_last_component == 0 then nothing +of the pathname is returned there. If saved_last_component == 0 then nothing is returned there. If last_component_wcard is true then a MS wildcard was detected and diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 17c473f028..4a27d02cfe 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -28,9 +28,6 @@ static int real_max_open_files; static struct bitmap *file_bmap; static files_struct *Files; - -/* a fsp to use when chaining */ -static files_struct *chain_fsp = NULL; static int files_used; @@ -57,7 +54,8 @@ static unsigned long get_gen_count(void) Find first available file slot. ****************************************************************************/ -NTSTATUS file_new(connection_struct *conn, files_struct **result) +NTSTATUS file_new(struct smb_request *req, connection_struct *conn, + files_struct **result) { int i; static int first_file; @@ -120,13 +118,17 @@ NTSTATUS file_new(connection_struct *conn, files_struct **result) DEBUG(5,("allocated file structure %d, fnum = %d (%d used)\n", i, fsp->fnum, files_used)); - chain_fsp = fsp; - - /* A new fsp invalidates a negative fsp_fi_cache. */ - if (fsp_fi_cache.fsp == NULL) { - ZERO_STRUCT(fsp_fi_cache); + if (req != NULL) { + req->chain_fsp = fsp; } + /* A new fsp invalidates the positive and + negative fsp_fi_cache as the new fsp is pushed + at the start of the list and we search from + a cache hit to the *end* of the list. */ + + ZERO_STRUCT(fsp_fi_cache); + *result = fsp; return NT_STATUS_OK; } @@ -142,7 +144,7 @@ void file_close_conn(connection_struct *conn) for (fsp=Files;fsp;fsp=next) { next = fsp->next; if (fsp->conn == conn) { - close_file(fsp,SHUTDOWN_CLOSE); + close_file(NULL, fsp, SHUTDOWN_CLOSE); } } } @@ -158,7 +160,7 @@ void file_close_pid(uint16 smbpid, int vuid) for (fsp=Files;fsp;fsp=next) { next = fsp->next; if ((fsp->file_pid == smbpid) && (fsp->vuid == vuid)) { - close_file(fsp,SHUTDOWN_CLOSE); + close_file(NULL, fsp, SHUTDOWN_CLOSE); } } } @@ -216,7 +218,7 @@ void file_close_user(int vuid) for (fsp=Files;fsp;fsp=next) { next=fsp->next; if (fsp->vuid == vuid) { - close_file(fsp,SHUTDOWN_CLOSE); + close_file(NULL, fsp, SHUTDOWN_CLOSE); } } } @@ -326,8 +328,7 @@ files_struct *file_find_di_first(struct file_id id) fsp_fi_cache.id = id; for (fsp=Files;fsp;fsp=fsp->next) { - if ( fsp->fh->fd != -1 && - file_id_equal(&fsp->file_id, &id)) { + if (file_id_equal(&fsp->file_id, &id)) { /* Setup positive cache. */ fsp_fi_cache.fsp = fsp; return fsp; @@ -348,8 +349,7 @@ files_struct *file_find_di_next(files_struct *start_fsp) files_struct *fsp; for (fsp = start_fsp->next;fsp;fsp=fsp->next) { - if ( fsp->fh->fd != -1 && - file_id_equal(&fsp->file_id, &start_fsp->file_id)) { + if (file_id_equal(&fsp->file_id, &start_fsp->file_id)) { return fsp; } } @@ -394,15 +394,13 @@ void file_sync_all(connection_struct *conn) Free up a fsp. ****************************************************************************/ -void file_free(files_struct *fsp) +void file_free(struct smb_request *req, files_struct *fsp) { DLIST_REMOVE(Files, fsp); string_free(&fsp->fsp_name); - if (fsp->fake_file_handle) { - destroy_fake_file_handle(&fsp->fake_file_handle); - } + TALLOC_FREE(fsp->fake_file_handle); if (fsp->fh->ref_count == 1) { SAFE_FREE(fsp->fh); @@ -431,8 +429,8 @@ void file_free(files_struct *fsp) information */ ZERO_STRUCTP(fsp); - if (fsp == chain_fsp) { - chain_fsp = NULL; + if ((req != NULL) && (fsp == req->chain_fsp)) { + req->chain_fsp = NULL; } /* Closing a file can invalidate the positive cache. */ @@ -472,44 +470,33 @@ files_struct *file_fnum(uint16 fnum) Get an fsp from a packet given the offset of a 16 bit fnum. ****************************************************************************/ -files_struct *file_fsp(uint16 fid) +files_struct *file_fsp(struct smb_request *req, uint16 fid) { files_struct *fsp; - if (chain_fsp) { - return chain_fsp; + if ((req != NULL) && (req->chain_fsp != NULL)) { + return req->chain_fsp; } fsp = file_fnum(fid); - if (fsp) { - chain_fsp = fsp; + if ((fsp != NULL) && (req != NULL)) { + req->chain_fsp = fsp; } return fsp; } -/**************************************************************************** - Reset the chained fsp - done at the start of a packet reply. -****************************************************************************/ - -void file_chain_reset(void) -{ - chain_fsp = NULL; -} - /**************************************************************************** Duplicate the file handle part for a DOS or FCB open. ****************************************************************************/ -NTSTATUS dup_file_fsp(files_struct *fsp, - uint32 access_mask, - uint32 share_access, - uint32 create_options, - files_struct **result) +NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *fsp, + uint32 access_mask, uint32 share_access, + uint32 create_options, files_struct **result) { NTSTATUS status; files_struct *dup_fsp; - status = file_new(fsp->conn, &dup_fsp); + status = file_new(NULL, fsp->conn, &dup_fsp); if (!NT_STATUS_IS_OK(status)) { return status; diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index f4c45999ba..0ce226809e 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -5,17 +5,17 @@ SMB Version handling Copyright (C) John H Terpstra 1995-1998 - + 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 . */ @@ -162,7 +162,7 @@ void send_trans_reply(connection_struct *conn, const uint8_t *inbuf, copy_trans_params_and_data(outbuf, align, rparam, tot_param_sent, this_lparam, rdata, tot_data_sent, this_ldata); - + SSVAL(outbuf,smb_vwv3,this_lparam); SSVAL(outbuf,smb_vwv4,smb_offset(smb_buf(outbuf)+1,outbuf)); SSVAL(outbuf,smb_vwv5,tot_param_sent); @@ -194,11 +194,15 @@ void send_trans_reply(connection_struct *conn, const uint8_t *inbuf, Start the first part of an RPC reply which began with an SMBtrans request. ****************************************************************************/ -static void api_rpc_trans_reply(connection_struct *conn, struct smb_request *req, smb_np_struct *p) +static void api_rpc_trans_reply(connection_struct *conn, + struct smb_request *req, + files_struct *fsp, + int max_trans_reply) { bool is_data_outstanding; - char *rdata = (char *)SMB_MALLOC(p->max_trans_reply); - int data_len; + uint8_t *rdata = SMB_MALLOC_ARRAY(uint8_t, max_trans_reply); + ssize_t data_len; + NTSTATUS status; if(rdata == NULL) { DEBUG(0,("api_rpc_trans_reply: malloc fail.\n")); @@ -206,14 +210,15 @@ static void api_rpc_trans_reply(connection_struct *conn, struct smb_request *req return; } - if((data_len = read_from_pipe( p, rdata, p->max_trans_reply, - &is_data_outstanding)) < 0) { + status = np_read(fsp, rdata, max_trans_reply, &data_len, + &is_data_outstanding); + if (!NT_STATUS_IS_OK(status)) { SAFE_FREE(rdata); api_no_reply(conn,req); return; } - send_trans_reply(conn, req->inbuf, NULL, 0, rdata, data_len, + send_trans_reply(conn, req->inbuf, NULL, 0, (char *)rdata, data_len, is_data_outstanding); SAFE_FREE(rdata); return; @@ -223,25 +228,18 @@ static void api_rpc_trans_reply(connection_struct *conn, struct smb_request *req WaitNamedPipeHandleState ****************************************************************************/ -static void api_WNPHS(connection_struct *conn, struct smb_request *req, smb_np_struct *p, - char *param, int param_len) +static void api_WNPHS(connection_struct *conn, struct smb_request *req, + struct files_struct *fsp, char *param, int param_len) { - uint16 priority; - if (!param || param_len < 2) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } - priority = SVAL(param,0); - DEBUG(4,("WaitNamedPipeHandleState priority %x\n", priority)); + DEBUG(4,("WaitNamedPipeHandleState priority %x\n", + (int)SVAL(param,0))); - if (wait_rpc_pipe_hnd_state(p, priority)) { - /* now send the reply */ - send_trans_reply(conn, req->inbuf, NULL, 0, NULL, 0, False); - return; - } - api_no_reply(conn,req); + send_trans_reply(conn, req->inbuf, NULL, 0, NULL, 0, False); } @@ -249,25 +247,17 @@ static void api_WNPHS(connection_struct *conn, struct smb_request *req, smb_np_s SetNamedPipeHandleState ****************************************************************************/ -static void api_SNPHS(connection_struct *conn, struct smb_request *req, smb_np_struct *p, - char *param, int param_len) +static void api_SNPHS(connection_struct *conn, struct smb_request *req, + struct files_struct *fsp, char *param, int param_len) { - uint16 id; - if (!param || param_len < 2) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } - id = SVAL(param,0); - DEBUG(4,("SetNamedPipeHandleState to code %x\n", id)); + DEBUG(4,("SetNamedPipeHandleState to code %x\n", (int)SVAL(param,0))); - if (set_rpc_pipe_hnd_state(p, id)) { - /* now send the reply */ - send_trans_reply(conn, req->inbuf, NULL, 0, NULL, 0, False); - return; - } - api_no_reply(conn,req); + send_trans_reply(conn, req->inbuf, NULL, 0, NULL, 0, False); } @@ -297,14 +287,14 @@ static void api_no_reply(connection_struct *conn, struct smb_request *req) static void api_fd_reply(connection_struct *conn, uint16 vuid, struct smb_request *req, - uint16 *setup, char *data, char *params, + uint16 *setup, uint8_t *data, char *params, int suwcnt, int tdscnt, int tpscnt, int mdrcnt, int mprcnt) { - bool reply = False; - smb_np_struct *p = NULL; + struct files_struct *fsp; int pnum; int subcommand; + NTSTATUS status; DEBUG(5,("api_fd_reply\n")); @@ -318,12 +308,14 @@ static void api_fd_reply(connection_struct *conn, uint16 vuid, /* Get the file handle and hence the file name. */ /* * NB. The setup array has already been transformed - * via SVAL and so is in gost byte order. + * via SVAL and so is in host byte order. */ pnum = ((int)setup[1]) & 0xFFFF; subcommand = ((int)setup[0]) & 0xFFFF; - if(!(p = get_rpc_pipe(pnum))) { + fsp = file_fsp(req, pnum); + + if (!fsp_is_np(fsp)) { if (subcommand == TRANSACT_WAITNAMEDPIPEHANDLESTATE) { /* Win9x does this call with a unicode pipe name, not a pnum. */ /* Just return success for now... */ @@ -338,37 +330,37 @@ static void api_fd_reply(connection_struct *conn, uint16 vuid, return; } - if (vuid != p->vuid) { + if (vuid != fsp->vuid) { DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %d, " - "expected %d\n", pnum, vuid, p->vuid)); + "expected %d\n", pnum, vuid, fsp->vuid)); reply_nterror(req, NT_STATUS_INVALID_HANDLE); return; } - DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)\n", subcommand, p->name, pnum)); - - /* record maximum data length that can be transmitted in an SMBtrans */ - p->max_trans_reply = mdrcnt; + DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)\n", + subcommand, fsp->fsp_name, pnum)); - DEBUG(10,("api_fd_reply: p:%p max_trans_reply: %d\n", p, p->max_trans_reply)); + DEBUG(10, ("api_fd_reply: p:%p max_trans_reply: %d\n", fsp, mdrcnt)); switch (subcommand) { - case TRANSACT_DCERPCCMD: + case TRANSACT_DCERPCCMD: { /* dce/rpc command */ - reply = write_to_pipe(p, data, tdscnt); - if (!reply) { + ssize_t nwritten; + status = np_write(fsp, data, tdscnt, &nwritten); + if (!NT_STATUS_IS_OK(status)) { api_no_reply(conn, req); return; } - api_rpc_trans_reply(conn, req, p); + api_rpc_trans_reply(conn, req, fsp, mdrcnt); break; + } case TRANSACT_WAITNAMEDPIPEHANDLESTATE: /* Wait Named Pipe Handle state */ - api_WNPHS(conn, req, p, params, tpscnt); + api_WNPHS(conn, req, fsp, params, tpscnt); break; case TRANSACT_SETNAMEDPIPEHANDLESTATE: /* Set Named Pipe Handle state */ - api_SNPHS(conn, req, p, params, tpscnt); + api_SNPHS(conn, req, fsp, params, tpscnt); break; default: reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -406,7 +398,7 @@ static void named_pipe(connection_struct *conn, uint16 vuid, DEBUG(4,("named pipe command from Win95 (wow!)\n")); api_fd_reply(conn, vuid, req, - setup, data, params, + setup, (uint8_t *)data, params, suwcnt, tdscnt, tpscnt, mdrcnt, mprcnt); return; @@ -414,7 +406,7 @@ static void named_pipe(connection_struct *conn, uint16 vuid, if (strlen(name) < 1) { api_fd_reply(conn, vuid, req, - setup, data, + setup, (uint8_t *)data, params, suwcnt, tdscnt, tpscnt, mdrcnt, mprcnt); return; @@ -735,11 +727,11 @@ void reply_transs(struct smb_request *req) state->received_param += pcnt; state->received_data += dcnt; - + if ((state->received_data > state->total_data) || (state->received_param > state->total_param)) goto bad_param; - + if (pcnt) { if (pdisp > state->total_param || pcnt > state->total_param || diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index fe1d766b9d..0c866da706 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -1154,7 +1154,7 @@ static int get_server_info(uint32 servertype, bool local_list_only; int i; - lines = file_lines_load(lock_path(SERVER_LIST), NULL, 0); + lines = file_lines_load(lock_path(SERVER_LIST), NULL, 0, NULL); if (!lines) { DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno))); return 0; @@ -1186,7 +1186,7 @@ static int get_server_info(uint32 servertype, *servers = SMB_REALLOC_ARRAY(*servers,struct srv_info_struct, alloced); if (!*servers) { DEBUG(0,("get_server_info: failed to enlarge servers info struct!\n")); - file_lines_free(lines); + TALLOC_FREE(lines); return 0; } memset((char *)((*servers)+count),'\0',sizeof(**servers)*(alloced-count)); @@ -1267,7 +1267,7 @@ static int get_server_info(uint32 servertype, } } - file_lines_free(lines); + TALLOC_FREE(lines); return count; } diff --git a/source3/smbd/map_username.c b/source3/smbd/map_username.c index 7536758bcb..a8899dd538 100644 --- a/source3/smbd/map_username.c +++ b/source3/smbd/map_username.c @@ -116,7 +116,7 @@ bool map_username(fstring user) } numlines = 0; - qlines = fd_lines_load(fd, &numlines,0); + qlines = fd_lines_load(fd, &numlines,0, NULL); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -127,7 +127,7 @@ bool map_username(fstring user) fstrcpy( user, qlines[0] ); } - file_lines_free(qlines); + TALLOC_FREE(qlines); return numlines != 0; } diff --git a/source3/smbd/noquotas.c b/source3/smbd/noquotas.c index c8ff8edf62..392b32437a 100644 --- a/source3/smbd/noquotas.c +++ b/source3/smbd/noquotas.c @@ -23,14 +23,14 @@ * Needed for auto generation of proto.h. */ -bool disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize) { (*bsize) = 512; /* This value should be ignored */ /* And just to be sure we set some values that hopefully */ /* will be larger that any possible real-world value */ - (*dfree) = (SMB_BIG_UINT)-1; - (*dsize) = (SMB_BIG_UINT)-1; + (*dfree) = (uint64_t)-1; + (*dsize) = (uint64_t)-1; /* As we have select not to use quotas, allways fail */ return False; diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c index 84b8e1098e..06da717799 100644 --- a/source3/smbd/notify_internal.c +++ b/source3/smbd/notify_internal.c @@ -166,7 +166,7 @@ static NTSTATUS notify_load(struct notify_context *notify, struct db_record *rec status = NT_STATUS_OK; if (blob.length > 0) { enum ndr_err_code ndr_err; - ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array, + ndr_err = ndr_pull_struct_blob(&blob, notify->array, NULL, notify->array, (ndr_pull_flags_fn_t)ndr_pull_notify_array); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); @@ -220,7 +220,7 @@ static NTSTATUS notify_save(struct notify_context *notify, struct db_record *rec tmp_ctx = talloc_new(notify); NT_STATUS_HAVE_NO_MEMORY(tmp_ctx); - ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, NULL, notify->array, (ndr_push_flags_fn_t)ndr_push_notify_array); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -258,7 +258,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data return; } - ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev, + ndr_err = ndr_pull_struct_blob(data, tmp_ctx, NULL, &ev, (ndr_pull_flags_fn_t)ndr_pull_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); @@ -561,7 +561,7 @@ static NTSTATUS notify_send(struct notify_context *notify, struct notify_entry * tmp_ctx = talloc_new(notify); - ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, + ndr_err = ndr_push_struct_blob(&data, tmp_ctx, NULL, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); diff --git a/source3/smbd/ntquotas.c b/source3/smbd/ntquotas.c index c616c494dc..ae7034011e 100644 --- a/source3/smbd/ntquotas.c +++ b/source3/smbd/ntquotas.c @@ -22,14 +22,14 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_QUOTA -static SMB_BIG_UINT limit_nt2unix(SMB_BIG_UINT in, SMB_BIG_UINT bsize) +static uint64_t limit_nt2unix(uint64_t in, uint64_t bsize) { - SMB_BIG_UINT ret = (SMB_BIG_UINT)0; + uint64_t ret = (uint64_t)0; - ret = (SMB_BIG_UINT)(in/bsize); + ret = (uint64_t)(in/bsize); if (in>0 && ret==0) { /* we have to make sure that a overflow didn't set NO_LIMIT */ - ret = (SMB_BIG_UINT)1; + ret = (uint64_t)1; } if (in == SMB_NTQUOTAS_NO_LIMIT) @@ -42,11 +42,11 @@ static SMB_BIG_UINT limit_nt2unix(SMB_BIG_UINT in, SMB_BIG_UINT bsize) return ret; } -static SMB_BIG_UINT limit_unix2nt(SMB_BIG_UINT in, SMB_BIG_UINT bsize) +static uint64_t limit_unix2nt(uint64_t in, uint64_t bsize) { - SMB_BIG_UINT ret = (SMB_BIG_UINT)0; + uint64_t ret = (uint64_t)0; - ret = (SMB_BIG_UINT)(in*bsize); + ret = (uint64_t)(in*bsize); if (ret < in) { /* we overflow */ @@ -59,14 +59,14 @@ static SMB_BIG_UINT limit_unix2nt(SMB_BIG_UINT in, SMB_BIG_UINT bsize) return ret; } -static SMB_BIG_UINT limit_blk2inodes(SMB_BIG_UINT in) +static uint64_t limit_blk2inodes(uint64_t in) { - SMB_BIG_UINT ret = (SMB_BIG_UINT)0; + uint64_t ret = (uint64_t)0; - ret = (SMB_BIG_UINT)(in/2); + ret = (uint64_t)(in/2); if (ret == 0 && in != 0) - ret = (SMB_BIG_UINT)1; + ret = (uint64_t)1; return ret; } @@ -100,7 +100,7 @@ int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid, return ret; } - qt->usedspace = (SMB_BIG_UINT)D.curblocks*D.bsize; + qt->usedspace = (uint64_t)D.curblocks*D.bsize; qt->softlim = limit_unix2nt(D.softlimit, D.bsize); qt->hardlim = limit_unix2nt(D.hardlimit, D.bsize); qt->qflags = D.qflags; @@ -121,7 +121,7 @@ int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, DOM_SID *psid, id.uid = -1; - D.bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; + D.bsize = (uint64_t)QUOTABLOCK_SIZE; D.softlimit = limit_nt2unix(qt->softlim,D.bsize); D.hardlimit = limit_nt2unix(qt->hardlim,D.bsize); diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 584399c86c..69ddcdae8d 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -22,6 +22,7 @@ extern int max_send; extern enum protocol_types Protocol; +extern const struct generic_mapping file_generic_mapping; static char *nttrans_realloc(char **ptr, size_t size) { @@ -267,7 +268,8 @@ bool is_ntfs_stream_name(const char *fname) static void nt_open_pipe(char *fname, connection_struct *conn, struct smb_request *req, int *ppnum) { - smb_np_struct *p = NULL; + files_struct *fsp; + NTSTATUS status; DEBUG(4,("nt_open_pipe: Opening pipe %s.\n", fname)); @@ -284,19 +286,13 @@ static void nt_open_pipe(char *fname, connection_struct *conn, DEBUG(3,("nt_open_pipe: Known pipe %s opening.\n", fname)); - p = open_rpc_pipe_p(fname, conn, req->vuid); - if (!p) { - reply_doserror(req, ERRSRV, ERRnofids); + status = np_open(req, conn, fname, &fsp); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); return; } - /* TODO: Add pipe to db */ - - if ( !store_pipe_opendb( p ) ) { - DEBUG(3,("nt_open_pipe: failed to store %s pipe open.\n", fname)); - } - - *ppnum = p->pnum; + *ppnum = fsp->fnum; return; } @@ -390,7 +386,7 @@ void reply_ntcreate_and_X(struct smb_request *req) uint32 create_disposition; uint32 create_options; uint16 root_dir_fid; - SMB_BIG_UINT allocation_size; + uint64_t allocation_size; /* Breakout the oplock request bits so we can set the reply bits separately. */ uint32 fattr=0; @@ -422,10 +418,10 @@ void reply_ntcreate_and_X(struct smb_request *req) create_options = IVAL(req->inbuf,smb_ntcreate_CreateOptions); root_dir_fid = (uint16)IVAL(req->inbuf,smb_ntcreate_RootDirectoryFid); - allocation_size = (SMB_BIG_UINT)IVAL(req->inbuf, + allocation_size = (uint64_t)IVAL(req->inbuf, smb_ntcreate_AllocationSize); #ifdef LARGE_SMB_OFF_T - allocation_size |= (((SMB_BIG_UINT)IVAL( + allocation_size |= (((uint64_t)IVAL( req->inbuf, smb_ntcreate_AllocationSize + 4)) << 32); #endif @@ -739,6 +735,10 @@ static NTSTATUS set_sd(files_struct *fsp, uint8 *data, uint32 sd_len, security_info_sent &= ~DACL_SECURITY_INFORMATION; } + /* Convert all the generic bits. */ + security_acl_map_generic(psd->dacl, &file_generic_mapping); + security_acl_map_generic(psd->sacl, &file_generic_mapping); + status = SMB_VFS_FSET_NT_ACL(fsp, security_info_sent, psd); TALLOC_FREE(psd); @@ -814,7 +814,7 @@ static void call_nt_transact_create(connection_struct *conn, struct ea_list *ea_list = NULL; NTSTATUS status; size_t param_len; - SMB_BIG_UINT allocation_size; + uint64_t allocation_size; int oplock_request; uint8_t oplock_granted; TALLOC_CTX *ctx = talloc_tos(); @@ -857,9 +857,9 @@ static void call_nt_transact_create(connection_struct *conn, sd_len = IVAL(params,36); ea_len = IVAL(params,40); root_dir_fid = (uint16)IVAL(params,4); - allocation_size = (SMB_BIG_UINT)IVAL(params,12); + allocation_size = (uint64_t)IVAL(params,12); #ifdef LARGE_SMB_OFF_T - allocation_size |= (((SMB_BIG_UINT)IVAL(params,16)) << 32); + allocation_size |= (((uint64_t)IVAL(params,16)) << 32); #endif /* @@ -1183,7 +1183,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx, &info, &fsp2); if (!NT_STATUS_IS_OK(status)) { - close_file(fsp1,ERROR_CLOSE); + close_file(NULL, fsp1, ERROR_CLOSE); return status; } @@ -1197,12 +1197,12 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx, * Thus we don't look at the error return from the * close of fsp1. */ - close_file(fsp1,NORMAL_CLOSE); + close_file(NULL, fsp1, NORMAL_CLOSE); /* Ensure the modtime is set correctly on the destination file. */ set_close_write_time(fsp2, get_mtimespec(&sbuf1)); - status = close_file(fsp2,NORMAL_CLOSE); + status = close_file(NULL, fsp2, NORMAL_CLOSE); /* Grrr. We have to do this as open_file_ntcreate adds aARCH when it creates the file. This isn't the correct thing to do in the copy @@ -1394,7 +1394,7 @@ static void call_nt_transact_notify_change(connection_struct *conn, return; } - fsp = file_fsp(SVAL(setup,4)); + fsp = file_fsp(req, SVAL(setup,4)); filter = IVAL(setup, 0); recursive = (SVAL(setup, 6) != 0) ? True : False; @@ -1494,7 +1494,7 @@ static void call_nt_transact_rename(connection_struct *conn, return; } - fsp = file_fsp(SVAL(params, 0)); + fsp = file_fsp(req, SVAL(params, 0)); if (!check_fsp(conn, req, fsp)) { return; } @@ -1563,7 +1563,7 @@ static void call_nt_transact_query_security_desc(connection_struct *conn, return; } - fsp = file_fsp(SVAL(params,0)); + fsp = file_fsp(req, SVAL(params,0)); if(!fsp) { reply_doserror(req, ERRDOS, ERRbadfid); return; @@ -1659,7 +1659,7 @@ static void call_nt_transact_set_security_desc(connection_struct *conn, return; } - if((fsp = file_fsp(SVAL(params,0))) == NULL) { + if((fsp = file_fsp(req, SVAL(params,0))) == NULL) { reply_doserror(req, ERRDOS, ERRbadfid); return; } @@ -1723,7 +1723,7 @@ static void call_nt_transact_ioctl(connection_struct *conn, DEBUG(10,("call_nt_transact_ioctl: function[0x%08X] FID[0x%04X] isFSctl[0x%02X] compfilter[0x%02X]\n", function, fidnum, isFSctl, compfilter)); - fsp=file_fsp(fidnum); + fsp=file_fsp(req, fidnum); /* this check is done in each implemented function case for now because I don't want to break anything... --metze FSP_BELONGS_CONN(fsp,conn);*/ @@ -2030,7 +2030,7 @@ static void call_nt_transact_get_user_quota(connection_struct *conn, } /* maybe we can check the quota_fnum */ - fsp = file_fsp(SVAL(params,0)); + fsp = file_fsp(req, SVAL(params,0)); if (!check_fsp_ntquota_handle(conn, req, fsp)) { DEBUG(3,("TRANSACT_GET_USER_QUOTA: no valid QUOTA HANDLE\n")); reply_nterror(req, NT_STATUS_INVALID_HANDLE); @@ -2127,16 +2127,16 @@ static void call_nt_transact_get_user_quota(connection_struct *conn, /* then the len of the SID 4 bytes */ SIVAL(entry,4,sid_len); - /* unknown data 8 bytes SMB_BIG_UINT */ - SBIG_UINT(entry,8,(SMB_BIG_UINT)0); /* this is not 0 in windows...-metze*/ + /* unknown data 8 bytes uint64_t */ + SBIG_UINT(entry,8,(uint64_t)0); /* this is not 0 in windows...-metze*/ - /* the used disk space 8 bytes SMB_BIG_UINT */ + /* the used disk space 8 bytes uint64_t */ SBIG_UINT(entry,16,tmp_list->quotas->usedspace); - /* the soft quotas 8 bytes SMB_BIG_UINT */ + /* the soft quotas 8 bytes uint64_t */ SBIG_UINT(entry,24,tmp_list->quotas->softlim); - /* the hard quotas 8 bytes SMB_BIG_UINT */ + /* the hard quotas 8 bytes uint64_t */ SBIG_UINT(entry,32,tmp_list->quotas->hardlim); /* and now the SID */ @@ -2225,16 +2225,16 @@ static void call_nt_transact_get_user_quota(connection_struct *conn, /* then the len of the SID 4 bytes */ SIVAL(entry,4,sid_len); - /* unknown data 8 bytes SMB_BIG_UINT */ - SBIG_UINT(entry,8,(SMB_BIG_UINT)0); /* this is not 0 in windows...-mezte*/ + /* unknown data 8 bytes uint64_t */ + SBIG_UINT(entry,8,(uint64_t)0); /* this is not 0 in windows...-mezte*/ - /* the used disk space 8 bytes SMB_BIG_UINT */ + /* the used disk space 8 bytes uint64_t */ SBIG_UINT(entry,16,qt.usedspace); - /* the soft quotas 8 bytes SMB_BIG_UINT */ + /* the soft quotas 8 bytes uint64_t */ SBIG_UINT(entry,24,qt.softlim); - /* the hard quotas 8 bytes SMB_BIG_UINT */ + /* the hard quotas 8 bytes uint64_t */ SBIG_UINT(entry,32,qt.hardlim); /* and now the SID */ @@ -2297,7 +2297,7 @@ static void call_nt_transact_set_user_quota(connection_struct *conn, } /* maybe we can check the quota_fnum */ - fsp = file_fsp(SVAL(params,0)); + fsp = file_fsp(req, SVAL(params,0)); if (!check_fsp_ntquota_handle(conn, req, fsp)) { DEBUG(3,("TRANSACT_GET_USER_QUOTA: no valid QUOTA HANDLE\n")); reply_nterror(req, NT_STATUS_INVALID_HANDLE); @@ -2328,10 +2328,10 @@ static void call_nt_transact_set_user_quota(connection_struct *conn, * maybe its the change time in NTTIME */ - /* the used space 8 bytes (SMB_BIG_UINT)*/ - qt.usedspace = (SMB_BIG_UINT)IVAL(pdata,16); + /* the used space 8 bytes (uint64_t)*/ + qt.usedspace = (uint64_t)IVAL(pdata,16); #ifdef LARGE_SMB_OFF_T - qt.usedspace |= (((SMB_BIG_UINT)IVAL(pdata,20)) << 32); + qt.usedspace |= (((uint64_t)IVAL(pdata,20)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(pdata,20) != 0)&& ((qt.usedspace != 0xFFFFFFFF)|| @@ -2342,10 +2342,10 @@ static void call_nt_transact_set_user_quota(connection_struct *conn, } #endif /* LARGE_SMB_OFF_T */ - /* the soft quotas 8 bytes (SMB_BIG_UINT)*/ - qt.softlim = (SMB_BIG_UINT)IVAL(pdata,24); + /* the soft quotas 8 bytes (uint64_t)*/ + qt.softlim = (uint64_t)IVAL(pdata,24); #ifdef LARGE_SMB_OFF_T - qt.softlim |= (((SMB_BIG_UINT)IVAL(pdata,28)) << 32); + qt.softlim |= (((uint64_t)IVAL(pdata,28)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(pdata,28) != 0)&& ((qt.softlim != 0xFFFFFFFF)|| @@ -2356,10 +2356,10 @@ static void call_nt_transact_set_user_quota(connection_struct *conn, } #endif /* LARGE_SMB_OFF_T */ - /* the hard quotas 8 bytes (SMB_BIG_UINT)*/ - qt.hardlim = (SMB_BIG_UINT)IVAL(pdata,32); + /* the hard quotas 8 bytes (uint64_t)*/ + qt.hardlim = (uint64_t)IVAL(pdata,32); #ifdef LARGE_SMB_OFF_T - qt.hardlim |= (((SMB_BIG_UINT)IVAL(pdata,36)) << 32); + qt.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(pdata,36) != 0)&& ((qt.hardlim != 0xFFFFFFFF)|| diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 8b32907a4b..d858fb969f 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -890,7 +890,8 @@ static bool open_match_attributes(connection_struct *conn, Try and find a duplicated file handle. ****************************************************************************/ -static files_struct *fcb_or_dos_open(connection_struct *conn, +static files_struct *fcb_or_dos_open(struct smb_request *req, + connection_struct *conn, const char *fname, struct file_id id, uint16 file_pid, @@ -940,7 +941,7 @@ static files_struct *fcb_or_dos_open(connection_struct *conn, } /* We need to duplicate this fsp. */ - if (!NT_STATUS_IS_OK(dup_file_fsp(fsp, access_mask, share_access, + if (!NT_STATUS_IS_OK(dup_file_fsp(req, fsp, access_mask, share_access, create_options, &dup_fsp))) { return NULL; } @@ -1178,7 +1179,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, DEBUG(10, ("open_file_ntcreate: printer open fname=%s\n", fname)); - return print_fsp_open(conn, fname, req->vuid, result); + return print_fsp_open(req, conn, fname, req->vuid, result); } if (!parent_dirname_talloc(talloc_tos(), fname, &parent_dir, @@ -1435,7 +1436,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, return NT_STATUS_ACCESS_DENIED; } - status = file_new(conn, &fsp); + status = file_new(req, conn, &fsp); if(!NT_STATUS_IS_OK(status)) { return status; } @@ -1464,7 +1465,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, fname, &old_write_time); if (lck == NULL) { - file_free(fsp); + file_free(req, fsp); DEBUG(0, ("Could not get share mode lock\n")); return NT_STATUS_SHARING_VIOLATION; } @@ -1475,7 +1476,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, oplock_request)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } @@ -1495,7 +1496,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, oplock_request)) { schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } } @@ -1503,7 +1504,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, if (NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { /* DELETE_PENDING is not deferred for a second */ TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); return status; } @@ -1524,13 +1525,13 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, DEBUG(0, ("DOS open without an SMB " "request!\n")); TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_INTERNAL_ERROR; } /* Use the client requested access mask here, * not the one we open with. */ - fsp_dup = fcb_or_dos_open(conn, fname, id, + fsp_dup = fcb_or_dos_open(req, conn, fname, id, req->smbpid, req->vuid, access_mask, @@ -1539,7 +1540,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, if (fsp_dup) { TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); if (pinfo) { *pinfo = FILE_WAS_OPENED; } @@ -1625,7 +1626,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, } else { status = NT_STATUS_ACCESS_DENIED; } - file_free(fsp); + file_free(req, fsp); return status; } @@ -1663,7 +1664,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, if (lck != NULL) { TALLOC_FREE(lck); } - file_free(fsp); + file_free(req, fsp); return fsp_open; } @@ -1694,7 +1695,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, DEBUG(0, ("open_file_ntcreate: Could not get share " "mode lock for %s\n", fname)); fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } @@ -1705,7 +1706,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } @@ -1724,7 +1725,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, schedule_defer_open(lck, request_time, req); TALLOC_FREE(lck); fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } } @@ -1733,7 +1734,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, struct deferred_open_record state; fd_close(fsp); - file_free(fsp); + file_free(req, fsp); state.delayed_for_oplocks = False; state.id = id; @@ -1775,7 +1776,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, TALLOC_FREE(lck); fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } @@ -1801,7 +1802,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, status = map_nt_error_from_unix(errno); TALLOC_FREE(lck); fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return status; } } @@ -1852,7 +1853,8 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, /* Handle strange delete on close create semantics. */ if ((create_options & FILE_DELETE_ON_CLOSE) - && (is_ntfs_stream_name(fname) + && (((conn->fs_capabilities & FILE_NAMED_STREAMS) + && is_ntfs_stream_name(fname)) || can_set_initial_delete_on_close(lck))) { status = can_set_delete_on_close(fsp, True, new_dos_attributes); @@ -1861,7 +1863,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, del_share_mode(lck, fsp); TALLOC_FREE(lck); fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return status; } /* Note that here we set the *inital* delete on close flag, @@ -1947,7 +1949,8 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, Open a file for for write to ensure that we can fchmod it. ****************************************************************************/ -NTSTATUS open_file_fchmod(connection_struct *conn, const char *fname, +NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn, + const char *fname, SMB_STRUCT_STAT *psbuf, files_struct **result) { files_struct *fsp = NULL; @@ -1957,7 +1960,7 @@ NTSTATUS open_file_fchmod(connection_struct *conn, const char *fname, return NT_STATUS_INVALID_PARAMETER; } - status = file_new(conn, &fsp); + status = file_new(req, conn, &fsp); if(!NT_STATUS_IS_OK(status)) { return status; } @@ -1974,7 +1977,7 @@ NTSTATUS open_file_fchmod(connection_struct *conn, const char *fname, */ if (!NT_STATUS_IS_OK(status)) { - file_free(fsp); + file_free(req, fsp); return status; } @@ -1986,10 +1989,10 @@ NTSTATUS open_file_fchmod(connection_struct *conn, const char *fname, Close the fchmod file fd - ensure no locks are lost. ****************************************************************************/ -NTSTATUS close_file_fchmod(files_struct *fsp) +NTSTATUS close_file_fchmod(struct smb_request *req, files_struct *fsp) { NTSTATUS status = fd_close(fsp); - file_free(fsp); + file_free(req, fsp); return status; } @@ -2116,7 +2119,9 @@ NTSTATUS open_directory(connection_struct *conn, (unsigned int)create_disposition, (unsigned int)file_attributes)); - if (!(file_attributes & FILE_FLAG_POSIX_SEMANTICS) && is_ntfs_stream_name(fname)) { + if (!(file_attributes & FILE_FLAG_POSIX_SEMANTICS) && + (conn->fs_capabilities & FILE_NAMED_STREAMS) && + is_ntfs_stream_name(fname)) { DEBUG(2, ("open_directory: %s is a stream name!\n", fname)); return NT_STATUS_NOT_A_DIRECTORY; } @@ -2195,7 +2200,7 @@ NTSTATUS open_directory(connection_struct *conn, return NT_STATUS_NOT_A_DIRECTORY; } - status = file_new(conn, &fsp); + status = file_new(req, conn, &fsp); if(!NT_STATUS_IS_OK(status)) { return status; } @@ -2233,7 +2238,7 @@ NTSTATUS open_directory(connection_struct *conn, if (lck == NULL) { DEBUG(0, ("open_directory: Could not get share mode lock for %s\n", fname)); - file_free(fsp); + file_free(req, fsp); return NT_STATUS_SHARING_VIOLATION; } @@ -2243,7 +2248,7 @@ NTSTATUS open_directory(connection_struct *conn, if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); return status; } @@ -2256,7 +2261,7 @@ NTSTATUS open_directory(connection_struct *conn, status = can_set_delete_on_close(fsp, True, 0); if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) { TALLOC_FREE(lck); - file_free(fsp); + file_free(req, fsp); return status; } @@ -2297,7 +2302,7 @@ NTSTATUS create_directory(connection_struct *conn, struct smb_request *req, cons &fsp); if (NT_STATUS_IS_OK(status)) { - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); } return status; @@ -2507,7 +2512,7 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn, DEBUG(10, ("Closing stream # %d, %s\n", i, streams[i]->fsp_name)); - close_file(streams[i], NORMAL_CLOSE); + close_file(NULL, streams[i], NORMAL_CLOSE); } fail: @@ -2528,7 +2533,7 @@ NTSTATUS create_file_unixpath(connection_struct *conn, uint32_t create_options, uint32_t file_attributes, uint32_t oplock_request, - SMB_BIG_UINT allocation_size, + uint64_t allocation_size, struct security_descriptor *sd, struct ea_list *ea_list, @@ -2605,9 +2610,7 @@ NTSTATUS create_file_unixpath(connection_struct *conn, && (create_disposition != FILE_CREATE) && (share_access & FILE_SHARE_DELETE) && (access_mask & DELETE_ACCESS) - && (((dos_mode(conn, fname, &sbuf) & FILE_ATTRIBUTE_READONLY) - && !lp_delete_readonly(SNUM(conn))) - || !can_delete_file_in_directory(conn, fname))) { + && (!can_delete_file_in_directory(conn, fname))) { status = NT_STATUS_ACCESS_DENIED; goto fail; } @@ -2763,6 +2766,10 @@ NTSTATUS create_file_unixpath(connection_struct *conn, fsp->access_mask = FILE_GENERIC_ALL; + /* Convert all the generic bits. */ + security_acl_map_generic(sd->dacl, &file_generic_mapping); + security_acl_map_generic(sd->sacl, &file_generic_mapping); + status = SMB_VFS_FSET_NT_ACL(fsp, sec_info_sent, sd); fsp->access_mask = saved_access_mask; @@ -2802,7 +2809,7 @@ NTSTATUS create_file_unixpath(connection_struct *conn, } } else { fsp->initial_allocation_size = smb_roundup( - fsp->conn, (SMB_BIG_UINT)sbuf.st_size); + fsp->conn, (uint64_t)sbuf.st_size); } } @@ -2836,11 +2843,11 @@ NTSTATUS create_file_unixpath(connection_struct *conn, DEBUG(10, ("create_file_unixpath: %s\n", nt_errstr(status))); if (fsp != NULL) { - close_file(fsp, ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); fsp = NULL; } if (base_fsp != NULL) { - close_file(base_fsp, ERROR_CLOSE); + close_file(req, base_fsp, ERROR_CLOSE); base_fsp = NULL; } return status; @@ -2856,7 +2863,7 @@ NTSTATUS create_file(connection_struct *conn, uint32_t create_options, uint32_t file_attributes, uint32_t oplock_request, - SMB_BIG_UINT allocation_size, + uint64_t allocation_size, struct security_descriptor *sd, struct ea_list *ea_list, @@ -2894,7 +2901,7 @@ NTSTATUS create_file(connection_struct *conn, * This filename is relative to a directory fid. */ char *parent_fname = NULL; - files_struct *dir_fsp = file_fsp(root_dir_fid); + files_struct *dir_fsp = file_fsp(req, root_dir_fid); if (dir_fsp == NULL) { status = NT_STATUS_INVALID_HANDLE; @@ -2907,7 +2914,8 @@ NTSTATUS create_file(connection_struct *conn, * Check to see if this is a mac fork of some kind. */ - if (is_ntfs_stream_name(fname)) { + if ((conn->fs_capabilities & FILE_NAMED_STREAMS) && + is_ntfs_stream_name(fname)) { status = NT_STATUS_OBJECT_PATH_NOT_FOUND; goto fail; } @@ -2994,7 +3002,7 @@ NTSTATUS create_file(connection_struct *conn, * also tries a QUERY_FILE_INFO on the file and then * close it */ - status = open_fake_file(conn, req->vuid, + status = open_fake_file(req, conn, req->vuid, fake_file_type, fname, access_mask, &fsp); if (!NT_STATUS_IS_OK(status)) { @@ -3086,7 +3094,7 @@ NTSTATUS create_file(connection_struct *conn, DEBUG(10, ("create_file: %s\n", nt_errstr(status))); if (fsp != NULL) { - close_file(fsp, ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); fsp = NULL; } return status; diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 1d3514429f..88e7b766be 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -545,7 +545,7 @@ static bool user_ok(const char *user, int snum) ret = True; if (lp_invalid_users(snum)) { - str_list_copy(talloc_tos(), &invalid, lp_invalid_users(snum)); + invalid = str_list_copy(talloc_tos(), lp_invalid_users(snum)); if (invalid && str_list_substitute(invalid, "%S", lp_servicename(snum))) { @@ -561,7 +561,7 @@ static bool user_ok(const char *user, int snum) TALLOC_FREE(invalid); if (ret && lp_valid_users(snum)) { - str_list_copy(talloc_tos(), &valid, lp_valid_users(snum)); + valid = str_list_copy(talloc_tos(), lp_valid_users(snum)); if ( valid && str_list_substitute(valid, "%S", lp_servicename(snum)) ) { diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 4fdcdcc557..25a1fe2e63 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -32,18 +32,6 @@ #define MAX_PIPE_NAME_LEN 24 -/* PIPE/// */ -#define PIPEDB_KEY_FORMAT "PIPE/%s/%u/%d" - -struct pipe_dbrec { - struct server_id pid; - int pnum; - uid_t uid; - - char name[MAX_PIPE_NAME_LEN]; - fstring user; -}; - /**************************************************************************** Reply to an open and X on a named pipe. This code is basically stolen from reply_open_and_X with some @@ -54,9 +42,10 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req) { const char *fname = NULL; char *pipe_name = NULL; - smb_np_struct *p; + files_struct *fsp; int size=0,fmode=0,mtime=0,rmode=0; TALLOC_CTX *ctx = talloc_tos(); + NTSTATUS status; /* XXXX we need to handle passed times, sattr and flags */ srvstr_pull_buf_talloc(ctx, req->inbuf, req->flags2, &pipe_name, @@ -101,9 +90,9 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req) /* can be opened and add it in after the open. */ DEBUG(3,("Known pipe %s opening.\n",fname)); - p = open_rpc_pipe_p(fname, conn, req->vuid); - if (!p) { - reply_doserror(req, ERRSRV, ERRnofids); + status = np_open(req, conn, fname, &fsp); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); return; } @@ -119,7 +108,7 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req) rmode = 1; } - SSVAL(req->outbuf,smb_vwv2, p->pnum); + SSVAL(req->outbuf,smb_vwv2, fsp->fnum); SSVAL(req->outbuf,smb_vwv3,fmode); srv_put_dos_date3((char *)req->outbuf,smb_vwv4,mtime); SIVAL(req->outbuf,smb_vwv6,size); @@ -136,27 +125,32 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req) void reply_pipe_write(struct smb_request *req) { - smb_np_struct *p = get_rpc_pipe_p(SVAL(req->inbuf,smb_vwv0)); + files_struct *fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); size_t numtowrite = SVAL(req->inbuf,smb_vwv1); - int nwritten; - char *data; + ssize_t nwritten; + uint8_t *data; - if (!p) { + if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); return; } - if (p->vuid != req->vuid) { + if (fsp->vuid != req->vuid) { reply_nterror(req, NT_STATUS_INVALID_HANDLE); return; } - data = smb_buf(req->inbuf) + 3; + data = (uint8_t *)smb_buf(req->inbuf) + 3; if (numtowrite == 0) { nwritten = 0; } else { - nwritten = write_to_pipe(p, data, numtowrite); + NTSTATUS status; + status = np_write(fsp, data, numtowrite, &nwritten); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); + return; + } } if ((nwritten == 0 && numtowrite != 0) || (nwritten < 0)) { @@ -168,7 +162,8 @@ void reply_pipe_write(struct smb_request *req) SSVAL(req->outbuf,smb_vwv0,nwritten); - DEBUG(3,("write-IPC pnum=%04x nwritten=%d\n", p->pnum, nwritten)); + DEBUG(3,("write-IPC pnum=%04x nwritten=%d\n", fsp->fnum, + (int)nwritten)); return; } @@ -182,31 +177,33 @@ void reply_pipe_write(struct smb_request *req) void reply_pipe_write_and_X(struct smb_request *req) { - smb_np_struct *p = get_rpc_pipe_p(SVAL(req->inbuf,smb_vwv2)); + files_struct *fsp = file_fsp(req, SVAL(req->inbuf, smb_vwv2)); size_t numtowrite = SVAL(req->inbuf,smb_vwv10); - int nwritten = -1; + ssize_t nwritten; int smb_doff = SVAL(req->inbuf, smb_vwv11); bool pipe_start_message_raw = ((SVAL(req->inbuf, smb_vwv7) & (PIPE_START_MESSAGE|PIPE_RAW_MODE)) == (PIPE_START_MESSAGE|PIPE_RAW_MODE)); - char *data; + uint8_t *data; - if (!p) { + if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); return; } - if (p->vuid != req->vuid) { + if (fsp->vuid != req->vuid) { reply_nterror(req, NT_STATUS_INVALID_HANDLE); return; } - data = smb_base(req->inbuf) + smb_doff; + data = (uint8_t *)smb_base(req->inbuf) + smb_doff; if (numtowrite == 0) { nwritten = 0; } else { + NTSTATUS status; + if(pipe_start_message_raw) { /* * For the start of a message in named pipe byte mode, @@ -225,7 +222,11 @@ void reply_pipe_write_and_X(struct smb_request *req) data += 2; numtowrite -= 2; } - nwritten = write_to_pipe(p, data, numtowrite); + status = np_write(fsp, data, numtowrite, &nwritten); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); + return; + } } if ((nwritten == 0 && numtowrite != 0) || (nwritten < 0)) { @@ -238,7 +239,8 @@ void reply_pipe_write_and_X(struct smb_request *req) nwritten = (pipe_start_message_raw ? nwritten + 2 : nwritten); SSVAL(req->outbuf,smb_vwv2,nwritten); - DEBUG(3,("writeX-IPC pnum=%04x nwritten=%d\n", p->pnum, nwritten)); + DEBUG(3,("writeX-IPC pnum=%04x nwritten=%d\n", fsp->fnum, + (int)nwritten)); chain_reply(req); } @@ -251,12 +253,13 @@ void reply_pipe_write_and_X(struct smb_request *req) void reply_pipe_read_and_X(struct smb_request *req) { - smb_np_struct *p = get_rpc_pipe_p(SVAL(req->inbuf,smb_vwv2)); + files_struct *fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); int smb_maxcnt = SVAL(req->inbuf,smb_vwv5); int smb_mincnt = SVAL(req->inbuf,smb_vwv6); - int nread = -1; - char *data; + ssize_t nread; + uint8_t *data; bool unused; + NTSTATUS status; /* we don't use the offset given to use for pipe reads. This is deliberate, instead we always return the next lump of @@ -265,18 +268,23 @@ void reply_pipe_read_and_X(struct smb_request *req) uint32 smb_offs = IVAL(req->inbuf,smb_vwv3); #endif - if (!p) { + if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); return; } + if (fsp->vuid != req->vuid) { + reply_nterror(req, NT_STATUS_INVALID_HANDLE); + return; + } + reply_outbuf(req, 12, smb_maxcnt); - data = smb_buf(req->outbuf); + data = (uint8_t *)smb_buf(req->outbuf); - nread = read_from_pipe(p, data, smb_maxcnt, &unused); + status = np_read(fsp, data, smb_maxcnt, &nread, &unused); - if (nread < 0) { + if (!NT_STATUS_IS_OK(status)) { reply_doserror(req, ERRDOS, ERRnoaccess); return; } @@ -288,33 +296,7 @@ void reply_pipe_read_and_X(struct smb_request *req) SSVAL(smb_buf(req->outbuf),-2,nread); DEBUG(3,("readX-IPC pnum=%04x min=%d max=%d nread=%d\n", - p->pnum, smb_mincnt, smb_maxcnt, nread)); + fsp->fnum, smb_mincnt, smb_maxcnt, (int)nread)); chain_reply(req); } - -/**************************************************************************** - Reply to a close. -****************************************************************************/ - -void reply_pipe_close(connection_struct *conn, struct smb_request *req) -{ - smb_np_struct *p = get_rpc_pipe_p(SVAL(req->inbuf,smb_vwv0)); - - if (!p) { - reply_doserror(req, ERRDOS, ERRbadfid); - return; - } - - DEBUG(5,("reply_pipe_close: pnum:%x\n", p->pnum)); - - if (!close_rpc_pipe_hnd(p)) { - reply_doserror(req, ERRDOS, ERRbadfid); - return; - } - - /* TODO: REMOVE PIPE FROM DB */ - - reply_outbuf(req, 0, 0); - return; -} diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 7479aea076..848d3e4a6d 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -890,13 +890,12 @@ static bool nt4_compatible_acls(void) not get. Deny entries are implicit on get with ace->perms = 0. ****************************************************************************/ -static SEC_ACCESS map_canon_ace_perms(int snum, +static uint32_t map_canon_ace_perms(int snum, enum security_ace_type *pacl_type, mode_t perms, bool directory_ace) { - SEC_ACCESS sa; - uint32 nt_mask = 0; + uint32_t nt_mask = 0; *pacl_type = SEC_ACE_TYPE_ACCESS_ALLOWED; @@ -935,8 +934,7 @@ static SEC_ACCESS map_canon_ace_perms(int snum, DEBUG(10,("map_canon_ace_perms: Mapped (UNIX) %x to (NT) %x\n", (unsigned int)perms, (unsigned int)nt_mask )); - init_sec_access(&sa,nt_mask); - return sa; + return nt_mask; } /**************************************************************************** @@ -988,7 +986,7 @@ static mode_t map_nt_perms( uint32 *mask, int type) Unpack a SEC_DESC into a UNIX owner and group. ****************************************************************************/ -NTSTATUS unpack_nt_owners(int snum, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, SEC_DESC *psd) +NTSTATUS unpack_nt_owners(int snum, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, const SEC_DESC *psd) { DOM_SID owner_sid; DOM_SID grp_sid; @@ -1329,11 +1327,13 @@ static void check_owning_objs(canon_ace *ace, DOM_SID *pfile_owner_sid, DOM_SID Unpack a SEC_DESC into two canonical ace lists. ****************************************************************************/ -static bool create_canon_ace_lists(files_struct *fsp, SMB_STRUCT_STAT *pst, - DOM_SID *pfile_owner_sid, - DOM_SID *pfile_grp_sid, - canon_ace **ppfile_ace, canon_ace **ppdir_ace, - SEC_ACL *dacl) +static bool create_canon_ace_lists(files_struct *fsp, + SMB_STRUCT_STAT *pst, + DOM_SID *pfile_owner_sid, + DOM_SID *pfile_grp_sid, + canon_ace **ppfile_ace, + canon_ace **ppdir_ace, + const SEC_ACL *dacl) { bool all_aces_are_inherit_only = (fsp->is_directory ? True : False); canon_ace *file_ace = NULL; @@ -2016,12 +2016,14 @@ static mode_t create_default_mode(files_struct *fsp, bool interitable_mode) succeeding. ****************************************************************************/ -static bool unpack_canon_ace(files_struct *fsp, - SMB_STRUCT_STAT *pst, - DOM_SID *pfile_owner_sid, - DOM_SID *pfile_grp_sid, - canon_ace **ppfile_ace, canon_ace **ppdir_ace, - uint32 security_info_sent, SEC_DESC *psd) +static bool unpack_canon_ace(files_struct *fsp, + SMB_STRUCT_STAT *pst, + DOM_SID *pfile_owner_sid, + DOM_SID *pfile_grp_sid, + canon_ace **ppfile_ace, + canon_ace **ppdir_ace, + uint32 security_info_sent, + const SEC_DESC *psd) { canon_ace *file_ace = NULL; canon_ace *dir_ace = NULL; @@ -2958,9 +2960,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn, */ for (ace = file_ace; ace != NULL; ace = ace->next) { - SEC_ACCESS acc; - - acc = map_canon_ace_perms(SNUM(conn), + uint32_t acc = map_canon_ace_perms(SNUM(conn), &nt_acl_type, ace->perms, S_ISDIR(sbuf->st_mode)); @@ -2975,19 +2975,14 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn, /* The User must have access to a profile share - even * if we can't map the SID. */ if (lp_profile_acls(SNUM(conn))) { - SEC_ACCESS acc; - - init_sec_access(&acc,FILE_GENERIC_ALL); init_sec_ace(&nt_ace_list[num_aces++], &global_sid_Builtin_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, - acc, 0); + FILE_GENERIC_ALL, 0); } for (ace = dir_ace; ace != NULL; ace = ace->next) { - SEC_ACCESS acc; - - acc = map_canon_ace_perms(SNUM(conn), + uint32_t acc = map_canon_ace_perms(SNUM(conn), &nt_acl_type, ace->perms, S_ISDIR(sbuf->st_mode)); @@ -3005,10 +3000,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn, /* The User must have access to a profile share - even * if we can't map the SID. */ if (lp_profile_acls(SNUM(conn))) { - SEC_ACCESS acc; - - init_sec_access(&acc,FILE_GENERIC_ALL); - init_sec_ace(&nt_ace_list[num_aces++], &global_sid_Builtin_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, acc, + init_sec_ace(&nt_ace_list[num_aces++], &global_sid_Builtin_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, FILE_GENERIC_ALL, SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT| SEC_ACE_FLAG_INHERIT_ONLY|0); } @@ -3199,7 +3191,7 @@ int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid) return -1; } - if (!NT_STATUS_IS_OK(open_file_fchmod(conn,fname,&st,&fsp))) { + if (!NT_STATUS_IS_OK(open_file_fchmod(NULL, conn, fname, &st, &fsp))) { return -1; } @@ -3214,7 +3206,7 @@ int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid) ret = SMB_VFS_FCHOWN(fsp, uid, (gid_t)-1); unbecome_root(); - close_file_fchmod(fsp); + close_file_fchmod(NULL, fsp); return ret; } @@ -3223,26 +3215,26 @@ int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid) Take care of parent ACL inheritance. ****************************************************************************/ -static NTSTATUS append_parent_acl(files_struct *fsp, - SMB_STRUCT_STAT *psbuf, - SEC_DESC *psd, +NTSTATUS append_parent_acl(files_struct *fsp, + const SEC_DESC *pcsd, SEC_DESC **pp_new_sd) { SEC_DESC *parent_sd = NULL; files_struct *parent_fsp = NULL; - TALLOC_CTX *mem_ctx = talloc_parent(psd); + TALLOC_CTX *mem_ctx = talloc_tos(); char *parent_name = NULL; SEC_ACE *new_ace = NULL; - unsigned int num_aces = psd->dacl->num_aces; + unsigned int num_aces = pcsd->dacl->num_aces; SMB_STRUCT_STAT sbuf; NTSTATUS status; int info; unsigned int i, j; - bool is_dacl_protected = (psd->type & SE_DESC_DACL_PROTECTED); + SEC_DESC *psd = dup_sec_desc(talloc_tos(), pcsd); + bool is_dacl_protected = (pcsd->type & SE_DESC_DACL_PROTECTED); ZERO_STRUCT(sbuf); - if (mem_ctx == NULL) { + if (psd == NULL) { return NT_STATUS_NO_MEMORY; } @@ -3272,7 +3264,7 @@ static NTSTATUS append_parent_acl(files_struct *fsp, status = SMB_VFS_GET_NT_ACL(parent_fsp->conn, parent_fsp->fsp_name, DACL_SECURITY_INFORMATION, &parent_sd ); - close_file(parent_fsp, NORMAL_CLOSE); + close_file(NULL, parent_fsp, NORMAL_CLOSE); if (!NT_STATUS_IS_OK(status)) { return status; @@ -3398,11 +3390,6 @@ static NTSTATUS append_parent_acl(files_struct *fsp, parent_name)); } - /* This sucks. psd should be const and we should - * be doing a deep-copy here. We're getting away - * with is as we know parent_sd is talloced off - * talloc_tos() as well as psd. JRA. */ - psd->dacl->aces = new_ace; psd->dacl->num_aces = i; psd->type &= ~(SE_DESC_DACL_AUTO_INHERITED| @@ -3418,7 +3405,7 @@ static NTSTATUS append_parent_acl(files_struct *fsp, This should be the only external function needed for the UNIX style set ACL. ****************************************************************************/ -NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) +NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd) { connection_struct *conn = fsp->conn; uid_t user = (uid_t)-1; @@ -3523,16 +3510,22 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd) create_file_sids(&sbuf, &file_owner_sid, &file_grp_sid); + /* See here: http://www.codeproject.com/KB/winsdk/accessctrl2.aspx + * for details. JRA. + */ + if ((security_info_sent & DACL_SECURITY_INFORMATION) && psd->dacl != NULL && (psd->type & (SE_DESC_DACL_AUTO_INHERITED| SE_DESC_DACL_AUTO_INHERIT_REQ))== (SE_DESC_DACL_AUTO_INHERITED| SE_DESC_DACL_AUTO_INHERIT_REQ) ) { - status = append_parent_acl(fsp, &sbuf, psd, &psd); + SEC_DESC *new_sd = NULL; + status = append_parent_acl(fsp, psd, &new_sd); if (!NT_STATUS_IS_OK(status)) { return status; } + psd = new_sd; } acl_perms = unpack_canon_ace( fsp, &sbuf, &file_owner_sid, &file_grp_sid, diff --git a/source3/smbd/process.c b/source3/smbd/process.c index b2d19e11e3..a8b93d8e1c 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -105,7 +105,11 @@ static bool valid_smb_header(const uint8_t *inbuf) if (is_encrypted_packet(inbuf)) { return true; } - return (strncmp(smb_base(inbuf),"\377SMB",4) == 0); + /* + * This used to be (strncmp(smb_base(inbuf),"\377SMB",4) == 0) + * but it just looks weird to call strncmp for this one. + */ + return (IVAL(smb_base(inbuf), 0) == 0x424D53FF); } /* Socket functions for smbd packet processing. */ @@ -376,6 +380,7 @@ void init_smb_request(struct smb_request *req, req->unread_bytes = unread_bytes; req->encrypted = encrypted; req->conn = conn_find(req->tid); + req->chain_fsp = NULL; /* Ensure we have at least wct words and 2 bytes of bcc. */ if (smb_size + req->wct*2 > req_size) { @@ -706,7 +711,7 @@ The timeout is in milliseconds ****************************************************************************/ static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer, - size_t *buffer_len, int timeout, + size_t *buffer_len, size_t *p_unread, bool *p_encrypted) { fd_set r_fds, w_fds; @@ -720,13 +725,8 @@ static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer, again: - if (timeout >= 0) { - to.tv_sec = timeout / 1000; - to.tv_usec = (timeout % 1000) * 1000; - } else { - to.tv_sec = SMBD_SELECT_TIMEOUT; - to.tv_usec = 0; - } + to.tv_sec = SMBD_SELECT_TIMEOUT; + to.tv_usec = 0; /* * Note that this call must be before processing any SMB @@ -747,7 +747,7 @@ static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer, pop_message = True; } else { struct timeval tv; - SMB_BIG_INT tdif; + int64_t tdif; GetTimeOfDay(&tv); tdif = usec_time_diff(&msg->end_time, &tv); @@ -869,7 +869,7 @@ static NTSTATUS receive_message_or_smb(TALLOC_CTX *mem_ctx, char **buffer, /* Did we timeout ? */ if (selrtn == 0) { - return NT_STATUS_IO_TIMEOUT; + goto again; } /* @@ -978,7 +978,7 @@ force write permissions on print services. */ static const struct smb_message_struct { const char *name; - void (*fn_new)(struct smb_request *req); + void (*fn)(struct smb_request *req); int flags; } smb_messages[256] = { @@ -1354,7 +1354,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in exit_server_cleanly("Non-SMB packet"); } - if (smb_messages[type].fn_new == NULL) { + if (smb_messages[type].fn == NULL) { DEBUG(0,("Unknown message type %d!\n",type)); smb_dump("Unknown", 1, (char *)req->inbuf, size); reply_unknown_new(req, type); @@ -1476,7 +1476,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in return conn; } - smb_messages[type].fn_new(req); + smb_messages[type].fn(req); return req->conn; } @@ -1491,8 +1491,6 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc struct smb_request *req; chain_size = 0; - file_chain_reset(); - reset_chain_p(); if (!(req = talloc(talloc_tos(), struct smb_request))) { smb_panic("could not allocate smb_request"); @@ -1540,25 +1538,6 @@ static void process_smb(char *inbuf, size_t nread, size_t unread_bytes, bool enc DO_PROFILE_INC(smb_count); - if (trans_num == 0) { - char addr[INET6_ADDRSTRLEN]; - - /* on the first packet, check the global hosts allow/ hosts - deny parameters before doing any parsing of the packet - passed to us by the client. This prevents attacks on our - parsing code from hosts not in the hosts allow list */ - - if (!check_access(smbd_server_fd(), lp_hostsallow(-1), - lp_hostsdeny(-1))) { - /* send a negative session response "not listening on calling name" */ - static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81}; - DEBUG( 1, ( "Connection denied from %s\n", - client_addr(get_client_fd(),addr,sizeof(addr)) ) ); - (void)srv_send_smb(smbd_server_fd(),(char *)buf,false); - exit_server_cleanly("connection denied"); - } - } - DEBUG( 6, ( "got message type 0x%x of len 0x%x\n", msg_type, smb_len(inbuf) ) ); DEBUG( 3, ( "Transaction %d of length %d (%u toread)\n", trans_num, @@ -1738,6 +1717,7 @@ void chain_reply(struct smb_request *req) smb_panic("could not allocate smb_request"); } init_smb_request(req2, (uint8 *)inbuf2,0, req->encrypted); + req2->chain_fsp = req->chain_fsp; /* process the request */ switch_message(smb_com2, req2, new_size); @@ -1836,23 +1816,6 @@ void chain_reply(struct smb_request *req) return; } -/**************************************************************************** - Setup the needed select timeout in milliseconds. -****************************************************************************/ - -static int setup_select_timeout(void) -{ - int select_timeout; - - select_timeout = SMBD_SELECT_TIMEOUT*1000; - - if (print_notify_messages_pending()) { - select_timeout = MIN(select_timeout, 1000); - } - - return select_timeout; -} - /**************************************************************************** Check if services need reloading. ****************************************************************************/ @@ -1907,113 +1870,40 @@ void check_reload(time_t t) } /**************************************************************************** - Process any timeout housekeeping. Return False if the caller should exit. + Process commands from the client ****************************************************************************/ -static void timeout_processing(int *select_timeout, - time_t *last_timeout_processing_time) +void smbd_process(void) { - time_t t; - - *last_timeout_processing_time = t = time(NULL); - - /* become root again if waiting */ - change_to_root_user(); - - /* check if we need to reload services */ - check_reload(t); - - if(global_machine_password_needs_changing && - /* for ADS we need to do a regular ADS password change, not a domain - password change */ - lp_security() == SEC_DOMAIN) { - - unsigned char trust_passwd_hash[16]; - time_t lct; - void *lock; - - /* - * We're in domain level security, and the code that - * read the machine password flagged that the machine - * password needs changing. - */ - - /* - * First, open the machine password file with an exclusive lock. - */ - - lock = secrets_get_trust_account_lock(NULL, lp_workgroup()); + unsigned int num_smbs = 0; + size_t unread_bytes = 0; - if (lock == NULL) { - DEBUG(0,("process: unable to lock the machine account password for \ -machine %s in domain %s.\n", global_myname(), lp_workgroup() )); - return; - } + char addr[INET6_ADDRSTRLEN]; - if(!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd_hash, &lct, NULL)) { - DEBUG(0,("process: unable to read the machine account password for \ -machine %s in domain %s.\n", global_myname(), lp_workgroup())); - TALLOC_FREE(lock); - return; - } + /* + * Before the first packet, check the global hosts allow/ hosts deny + * parameters before doing any parsing of packets passed to us by the + * client. This prevents attacks on our parsing code from hosts not in + * the hosts allow list. + */ + if (!check_access(smbd_server_fd(), lp_hostsallow(-1), + lp_hostsdeny(-1))) { /* - * Make sure someone else hasn't already done this. + * send a negative session response "not listening on calling + * name" */ - - if(t < lct + lp_machine_password_timeout()) { - global_machine_password_needs_changing = False; - TALLOC_FREE(lock); - return; - } - - /* always just contact the PDC here */ - - change_trust_account_password( lp_workgroup(), NULL); - global_machine_password_needs_changing = False; - TALLOC_FREE(lock); + unsigned char buf[5] = {0x83, 0, 0, 1, 0x81}; + DEBUG( 1, ("Connection denied from %s\n", + client_addr(get_client_fd(),addr,sizeof(addr)) ) ); + (void)srv_send_smb(smbd_server_fd(),(char *)buf,false); + exit_server_cleanly("connection denied"); } - /* update printer queue caches if necessary */ - - update_monitored_printq_cache(); - - /* - * Now we are root, check if the log files need pruning. - * Force a log file check. - */ - force_check_log_size(); - check_log_size(); - - /* Send any queued printer notify message to interested smbd's. */ - - print_notify_send_messages(smbd_messaging_context(), 0); - - /* - * Modify the select timeout depending upon - * what we have remaining in our queues. - */ - - *select_timeout = setup_select_timeout(); - - return; -} - -/**************************************************************************** - Process commands from the client -****************************************************************************/ - -void smbd_process(void) -{ - time_t last_timeout_processing_time = time(NULL); - unsigned int num_smbs = 0; - size_t unread_bytes = 0; - max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); while (True) { - int select_timeout = setup_select_timeout(); - int num_echos; + NTSTATUS status; char *inbuf = NULL; size_t inbuf_len = 0; bool encrypted = false; @@ -2021,82 +1911,24 @@ void smbd_process(void) errno = 0; - /* Did someone ask for immediate checks on things like blocking locks ? */ - if (select_timeout == 0) { - timeout_processing(&select_timeout, - &last_timeout_processing_time); - num_smbs = 0; /* Reset smb counter. */ - } - run_events(smbd_event_context(), 0, NULL, NULL); - while (True) { - NTSTATUS status; - - status = receive_message_or_smb( - talloc_tos(), &inbuf, &inbuf_len, - select_timeout, &unread_bytes, &encrypted); - - if (NT_STATUS_IS_OK(status)) { - break; - } - - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - timeout_processing( - &select_timeout, - &last_timeout_processing_time); - continue; - } + status = receive_message_or_smb( + talloc_tos(), &inbuf, &inbuf_len, + &unread_bytes, &encrypted); + if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("receive_message_or_smb failed: %s, " "exiting\n", nt_errstr(status))); return; - - num_smbs = 0; /* Reset smb counter. */ } - - /* - * Ensure we do timeout processing if the SMB we just got was - * only an echo request. This allows us to set the select - * timeout in 'receive_message_or_smb()' to any value we like - * without worrying that the client will send echo requests - * faster than the select timeout, thus starving out the - * essential processing (change notify, blocking locks) that - * the timeout code does. JRA. - */ - num_echos = smb_echo_count; - process_smb(inbuf, inbuf_len, unread_bytes, encrypted); TALLOC_FREE(inbuf); - if (smb_echo_count != num_echos) { - timeout_processing(&select_timeout, - &last_timeout_processing_time); - num_smbs = 0; /* Reset smb counter. */ - } - num_smbs++; - /* - * If we are getting smb requests in a constant stream - * with no echos, make sure we attempt timeout processing - * every select_timeout milliseconds - but only check for this - * every 200 smb requests. - */ - - if ((num_smbs % 200) == 0) { - time_t new_check_time = time(NULL); - if(new_check_time - last_timeout_processing_time >= (select_timeout/1000)) { - timeout_processing( - &select_timeout, - &last_timeout_processing_time); - num_smbs = 0; /* Reset smb counter. */ - last_timeout_processing_time = new_check_time; /* Reset time. */ - } - } - /* The timeout_processing function isn't run nearly often enough to implement 'max log size' without overrunning the size of the file by many megabytes. diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index f47e89bd22..3aa4652508 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -45,7 +45,7 @@ * Declare here, define at end: reduces likely "include" interaction problems. * David Lee */ -bool disk_quotas_vxfs(const char *name, char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); +bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize); #endif /* VXFS_QUOTA */ @@ -63,13 +63,13 @@ bool disk_quotas_vxfs(const char *name, char *path, SMB_BIG_UINT *bsize, SMB_BIG #include "samba_linux_quota.h" typedef struct _LINUX_SMB_DISK_QUOTA { - SMB_BIG_UINT bsize; - SMB_BIG_UINT hardlimit; /* In bsize units. */ - SMB_BIG_UINT softlimit; /* In bsize units. */ - SMB_BIG_UINT curblocks; /* In bsize units. */ - SMB_BIG_UINT ihardlimit; /* inode hard limit. */ - SMB_BIG_UINT isoftlimit; /* inode soft limit. */ - SMB_BIG_UINT curinodes; /* Current used inodes. */ + uint64_t bsize; + uint64_t hardlimit; /* In bsize units. */ + uint64_t softlimit; /* In bsize units. */ + uint64_t curblocks; /* In bsize units. */ + uint64_t ihardlimit; /* inode hard limit. */ + uint64_t isoftlimit; /* inode soft limit. */ + uint64_t curinodes; /* Current used inodes. */ } LINUX_SMB_DISK_QUOTA; @@ -95,13 +95,13 @@ static int get_smb_linux_xfs_quota(char *path, uid_t euser_id, gid_t egrp_id, LI if (ret) return ret; - dp->bsize = (SMB_BIG_UINT)512; - dp->softlimit = (SMB_BIG_UINT)D.d_blk_softlimit; - dp->hardlimit = (SMB_BIG_UINT)D.d_blk_hardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.d_ino_hardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.d_ino_softlimit; - dp->curinodes = (SMB_BIG_UINT)D.d_icount; - dp->curblocks = (SMB_BIG_UINT)D.d_bcount; + dp->bsize = (uint64_t)512; + dp->softlimit = (uint64_t)D.d_blk_softlimit; + dp->hardlimit = (uint64_t)D.d_blk_hardlimit; + dp->ihardlimit = (uint64_t)D.d_ino_hardlimit; + dp->isoftlimit = (uint64_t)D.d_ino_softlimit; + dp->curinodes = (uint64_t)D.d_icount; + dp->curblocks = (uint64_t)D.d_bcount; return ret; } @@ -134,13 +134,13 @@ static int get_smb_linux_v1_quota(char *path, uid_t euser_id, gid_t egrp_id, LIN if (ret && errno != EDQUOT) return ret; - dp->bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = (SMB_BIG_UINT)D.dqb_curblocks; + dp->bsize = (uint64_t)QUOTABLOCK_SIZE; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = (uint64_t)D.dqb_curblocks; return ret; } @@ -160,13 +160,13 @@ static int get_smb_linux_v2_quota(char *path, uid_t euser_id, gid_t egrp_id, LIN if (ret && errno != EDQUOT) return ret; - dp->bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = ((SMB_BIG_UINT)D.dqb_curspace) / dp->bsize; + dp->bsize = (uint64_t)QUOTABLOCK_SIZE; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = ((uint64_t)D.dqb_curspace) / dp->bsize; return ret; } @@ -190,13 +190,13 @@ static int get_smb_linux_gen_quota(char *path, uid_t euser_id, gid_t egrp_id, LI if (ret && errno != EDQUOT) return ret; - dp->bsize = (SMB_BIG_UINT)QUOTABLOCK_SIZE; - dp->softlimit = (SMB_BIG_UINT)D.dqb_bsoftlimit; - dp->hardlimit = (SMB_BIG_UINT)D.dqb_bhardlimit; - dp->ihardlimit = (SMB_BIG_UINT)D.dqb_ihardlimit; - dp->isoftlimit = (SMB_BIG_UINT)D.dqb_isoftlimit; - dp->curinodes = (SMB_BIG_UINT)D.dqb_curinodes; - dp->curblocks = ((SMB_BIG_UINT)D.dqb_curspace) / dp->bsize; + dp->bsize = (uint64_t)QUOTABLOCK_SIZE; + dp->softlimit = (uint64_t)D.dqb_bsoftlimit; + dp->hardlimit = (uint64_t)D.dqb_bhardlimit; + dp->ihardlimit = (uint64_t)D.dqb_ihardlimit; + dp->isoftlimit = (uint64_t)D.dqb_isoftlimit; + dp->curinodes = (uint64_t)D.dqb_curinodes; + dp->curblocks = ((uint64_t)D.dqb_curspace) / dp->bsize; return ret; } @@ -205,7 +205,7 @@ static int get_smb_linux_gen_quota(char *path, uid_t euser_id, gid_t egrp_id, LI Try to get the disk space from disk quotas (LINUX version). ****************************************************************************/ -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { int r; SMB_STRUCT_STAT S; @@ -306,7 +306,7 @@ bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB try to get the disk space from disk quotas (CRAY VERSION) ****************************************************************************/ -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { struct mntent *mnt; FILE *fd; @@ -454,7 +454,7 @@ static int my_xdr_getquota_rslt(XDR *xdrsp, struct getquota_rslt *gqr) } /* Restricted to SUNOS5 for the moment, I haven`t access to others to test. */ -static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +static bool nfs_quotas(char *nfspath, uid_t euser_id, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { uid_t uid = euser_id; struct dqblk D; @@ -468,7 +468,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B enum clnt_stat clnt_stat; bool ret = True; - *bsize = *dfree = *dsize = (SMB_BIG_UINT)0; + *bsize = *dfree = *dsize = (uint64_t)0; len=strcspn(mnttype, ":"); pathname=strstr(mnttype, ":"); @@ -544,7 +544,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B *bsize = gqr.getquota_rslt_u.gqr_rquota.rq_bsize; *dsize = D.dqb_bsoftlimit; - if (D.dqb_curblocks == D.dqb_curblocks == 1) + if (D.dqb_curblocks == 1) *bsize = 512; if (D.dqb_curblocks > D.dqb_bsoftlimit) { @@ -575,9 +575,9 @@ Quota code by Peter Urbanec (amiga@cse.unsw.edu.au). ****************************************************************************/ bool disk_quotas(const char *path, - SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, - SMB_BIG_UINT *dsize) + uint64_t *bsize, + uint64_t *dfree, + uint64_t *dsize) { uid_t euser_id; int ret; @@ -750,7 +750,7 @@ bool disk_quotas(const char *path, try to get the disk space from disk quotas - OSF1 version ****************************************************************************/ -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { int r, save_errno; struct dqblk D; @@ -816,7 +816,7 @@ try to get the disk space from disk quotas (IRIX 6.2 version) #include #include -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { uid_t euser_id; int r; @@ -1009,7 +1009,7 @@ static int my_xdr_getquota_rslt(XDR *xdrsp, struct getquota_rslt *gqr) } /* Works on FreeBSD, too. :-) */ -static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +static bool nfs_quotas(char *nfspath, uid_t euser_id, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { uid_t uid = euser_id; struct dqblk D; @@ -1023,7 +1023,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B enum clnt_stat clnt_stat; bool ret = True; - *bsize = *dfree = *dsize = (SMB_BIG_UINT)0; + *bsize = *dfree = *dsize = (uint64_t)0; len=strcspn(mnttype, ":"); pathname=strstr(mnttype, ":"); @@ -1104,7 +1104,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B *bsize = gqr.getquota_rslt_u.gqr_rquota.rq_bsize; *dsize = D.dqb_bsoftlimit; - if (D.dqb_curblocks == D.dqb_curblocks == 1) + if (D.dqb_curblocks == 1) *bsize = DEV_BSIZE; if (D.dqb_curblocks > D.dqb_bsoftlimit) { @@ -1134,7 +1134,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B try to get the disk space from disk quotas - default version ****************************************************************************/ -bool disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { int r; struct dqblk D; @@ -1353,7 +1353,7 @@ Hints for porting: #include #include -bool disk_quotas_vxfs(const char *name, char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { uid_t user_id, euser_id; int ret; @@ -1437,14 +1437,14 @@ bool disk_quotas_vxfs(const char *name, char *path, SMB_BIG_UINT *bsize, SMB_BIG #else /* WITH_QUOTAS */ -bool disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize) { (*bsize) = 512; /* This value should be ignored */ /* And just to be sure we set some values that hopefully */ /* will be larger that any possible real-world value */ - (*dfree) = (SMB_BIG_UINT)-1; - (*dsize) = (SMB_BIG_UINT)-1; + (*dfree) = (uint64_t)-1; + (*dsize) = (uint64_t)-1; /* As we have select not to use quotas, allways fail */ return false; @@ -1455,7 +1455,7 @@ bool disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BI /* wrapper to the new sys_quota interface this file should be removed later */ -bool disk_quotas(const char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize) { int r; SMB_DISK_QUOTA D; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 6933533672..25480c6e3b 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -29,7 +29,6 @@ /* look in server.c for some explanation of these variables */ extern enum protocol_types Protocol; extern int max_recv; -unsigned int smb_echo_count = 0; extern uint32 global_client_caps; extern bool global_encrypted_passwords_negotiated; @@ -340,8 +339,7 @@ bool check_fsp_open(connection_struct *conn, struct smb_request *req, } /**************************************************************************** - Check if we have a correct fsp pointing to a file. Replacement for the - CHECK_FSP macro. + Check if we have a correct fsp pointing to a file. ****************************************************************************/ bool check_fsp(connection_struct *conn, struct smb_request *req, @@ -426,22 +424,22 @@ void reply_special(char *inbuf) * header. */ char outbuf[smb_size]; - + static bool already_got_session = False; *name1 = *name2 = 0; - + memset(outbuf, '\0', sizeof(outbuf)); smb_setlen(outbuf,0); - + switch (msg_type) { case 0x81: /* session request */ - + if (already_got_session) { exit_server_cleanly("multiple session request not permitted"); } - + SCVAL(outbuf,0,0x82); SCVAL(outbuf,3,0); if (name_len(inbuf+4) > 50 || @@ -480,24 +478,24 @@ void reply_special(char *inbuf) already_got_session = True; break; - + case 0x89: /* session keepalive request (some old clients produce this?) */ SCVAL(outbuf,0,SMBkeepalive); SCVAL(outbuf,3,0); break; - + case 0x82: /* positive session response */ case 0x83: /* negative session response */ case 0x84: /* retarget session response */ DEBUG(0,("Unexpected session response\n")); break; - + case SMBkeepalive: /* session keepalive */ default: return; } - + DEBUG(5,("init msg_type=0x%x msg_flags=0x%x\n", msg_type, msg_flags)); @@ -749,7 +747,12 @@ void reply_tcon_and_X(struct smb_request *req) SSVAL(req->outbuf, smb_vwv2, SMB_SUPPORT_SEARCH_BITS| (lp_csc_policy(SNUM(conn)) << 2)); - init_dfsroot(conn, req->inbuf, req->outbuf); + if (lp_msdfs_root(SNUM(conn)) && lp_host_msdfs()) { + DEBUG(2,("Serving %s as a Dfs root\n", + lp_servicename(SNUM(conn)) )); + SSVAL(req->outbuf, smb_vwv2, + SMB_SHARE_IN_DFS | SVAL(req->outbuf, smb_vwv2)); + } } @@ -827,8 +830,8 @@ void reply_ioctl(struct smb_request *req) switch (ioctl_code) { case IOCTL_QUERY_JOB_INFO: { - files_struct *fsp = file_fsp(SVAL(req->inbuf, - smb_vwv0)); + files_struct *fsp = file_fsp( + req, SVAL(req->inbuf, smb_vwv0)); if (!fsp) { reply_doserror(req, ERRDOS, ERRbadfid); END_PROFILE(SMBioctl); @@ -1059,7 +1062,7 @@ void reply_getatr(struct smb_request *req) SSVAL(req->outbuf, smb_flg2, SVAL(req->outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME); } - + DEBUG(3,("reply_getatr: name=%s mode=%d size=%u\n", fname, mode, (unsigned int)size ) ); END_PROFILE(SMBgetatr); @@ -1166,9 +1169,9 @@ void reply_setatr(struct smb_request *req) } reply_outbuf(req, 0, 0); - + DEBUG( 3, ( "setatr name=%s mode=%d\n", fname, mode ) ); - + END_PROFILE(SMBsetatr); return; } @@ -1180,17 +1183,17 @@ void reply_setatr(struct smb_request *req) void reply_dskattr(struct smb_request *req) { connection_struct *conn = req->conn; - SMB_BIG_UINT dfree,dsize,bsize; + uint64_t dfree,dsize,bsize; START_PROFILE(SMBdskattr); - if (get_dfree_info(conn,".",True,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) { + if (get_dfree_info(conn,".",True,&bsize,&dfree,&dsize) == (uint64_t)-1) { reply_unixerror(req, ERRHRD, ERRgeneral); END_PROFILE(SMBdskattr); return; } reply_outbuf(req, 5, 0); - + if (Protocol <= PROTOCOL_LANMAN2) { double total_space, free_space; /* we need to scale this to a number that DOS6 can handle. We @@ -1202,9 +1205,9 @@ void reply_dskattr(struct smb_request *req) total_space = dsize * (double)bsize; free_space = dfree * (double)bsize; - dsize = (SMB_BIG_UINT)((total_space+63*512) / (64*512)); - dfree = (SMB_BIG_UINT)((free_space+63*512) / (64*512)); - + dsize = (uint64_t)((total_space+63*512) / (64*512)); + dfree = (uint64_t)((free_space+63*512) / (64*512)); + if (dsize > 0xFFFF) dsize = 0xFFFF; if (dfree > 0xFFFF) dfree = 0xFFFF; @@ -1689,7 +1692,7 @@ void reply_open(struct smb_request *req) if (fattr & aDIR) { DEBUG(3,("attempt to open a directory %s\n",fsp->fsp_name)); - close_file(fsp,ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); reply_doserror(req, ERRDOS,ERRnoaccess); END_PROFILE(SMBopen); return; @@ -1710,7 +1713,7 @@ void reply_open(struct smb_request *req) SCVAL(req->outbuf,smb_flg, CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED); } - + if(EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) { SCVAL(req->outbuf,smb_flg, CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED); @@ -1746,7 +1749,7 @@ void reply_open_and_X(struct smb_request *req) int smb_action = 0; files_struct *fsp; NTSTATUS status; - SMB_BIG_UINT allocation_size; + uint64_t allocation_size; ssize_t retval = -1; uint32 access_mask; uint32 share_mode; @@ -1769,7 +1772,7 @@ void reply_open_and_X(struct smb_request *req) core_oplock_request = CORE_OPLOCK_REQUEST(req->inbuf); oplock_request = ex_oplock_request | core_oplock_request; smb_ofun = SVAL(req->inbuf,smb_vwv8); - allocation_size = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv9); + allocation_size = (uint64_t)IVAL(req->inbuf,smb_vwv9); /* If it's an IPC, pass off the pipe handler. */ if (IS_IPC(conn)) { @@ -1832,14 +1835,14 @@ void reply_open_and_X(struct smb_request *req) if (((smb_action == FILE_WAS_CREATED) || (smb_action == FILE_WAS_OVERWRITTEN)) && allocation_size) { fsp->initial_allocation_size = smb_roundup(fsp->conn, allocation_size); if (vfs_allocate_file_space(fsp, fsp->initial_allocation_size) == -1) { - close_file(fsp,ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); reply_nterror(req, NT_STATUS_DISK_FULL); END_PROFILE(SMBopenX); return; } retval = vfs_set_filelen(fsp, (SMB_OFF_T)allocation_size); if (retval < 0) { - close_file(fsp,ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); reply_nterror(req, NT_STATUS_DISK_FULL); END_PROFILE(SMBopenX); return; @@ -1850,7 +1853,7 @@ void reply_open_and_X(struct smb_request *req) fattr = dos_mode(conn,fsp->fsp_name,&sbuf); mtime = sbuf.st_mtime; if (fattr & aDIR) { - close_file(fsp,ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); reply_doserror(req, ERRDOS, ERRnoaccess); END_PROFILE(SMBopenX); return; @@ -2198,7 +2201,7 @@ void reply_ctemp(struct smb_request *req) SCVAL(req->outbuf, smb_flg, CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED); } - + if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) { SCVAL(req->outbuf, smb_flg, CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED); @@ -2365,11 +2368,11 @@ static NTSTATUS do_unlink(connection_struct *conn, /* The set is across all open files on this dev/inode pair. */ if (!set_delete_on_close(fsp, True, &conn->server_info->utok)) { - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); return NT_STATUS_ACCESS_DENIED; } - return close_file(fsp,NORMAL_CLOSE); + return close_file(req, fsp, NORMAL_CLOSE); } /**************************************************************************** @@ -2810,7 +2813,7 @@ void reply_readbraw(struct smb_request *req) * return a zero length response here. */ - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); /* * We have to do a check_fsp by hand here, as @@ -2889,8 +2892,8 @@ void reply_readbraw(struct smb_request *req) maxcount = MIN(65535,maxcount); if (is_locked(fsp,(uint32)req->smbpid, - (SMB_BIG_UINT)maxcount, - (SMB_BIG_UINT)startpos, + (uint64_t)maxcount, + (uint64_t)startpos, READ_LOCK)) { reply_readbraw_error(); END_PROFILE(SMBreadbraw); @@ -2911,14 +2914,14 @@ void reply_readbraw(struct smb_request *req) if (nread < mincount) nread = 0; #endif - + DEBUG( 3, ( "reply_readbraw: fnum=%d start=%.0f max=%lu " "min=%lu nread=%lu\n", fsp->fnum, (double)startpos, (unsigned long)maxcount, (unsigned long)mincount, (unsigned long)nread ) ); - + send_file_readbraw(conn, fsp, startpos, nread, mincount); DEBUG(5,("reply_readbraw finished\n")); @@ -2952,7 +2955,7 @@ void reply_lockread(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBlockread); @@ -2975,7 +2978,7 @@ void reply_lockread(struct smb_request *req) reply_outbuf(req, 5, numtoread + 3); data = smb_buf(req->outbuf) + 3; - + /* * NB. Discovered by Menny Hamburger at Mainsoft. This is a core+ * protocol request that predates the read/write lock concept. @@ -2983,12 +2986,12 @@ void reply_lockread(struct smb_request *req) * for a write lock. JRA. * Note that the requested lock size is unaffected by max_recv. */ - + br_lck = do_lock(smbd_messaging_context(), fsp, req->smbpid, - (SMB_BIG_UINT)numtoread, - (SMB_BIG_UINT)startpos, + (uint64_t)numtoread, + (uint64_t)startpos, WRITE_LOCK, WINDOWS_LOCK, False, /* Non-blocking lock. */ @@ -3019,7 +3022,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n", END_PROFILE(SMBlockread); return; } - + srv_set_message((char *)req->outbuf, 5, nread+3, False); SSVAL(req->outbuf,smb_vwv0,nread); @@ -3027,7 +3030,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n", p = smb_buf(req->outbuf); SCVAL(p,0,0); /* pad byte. */ SSVAL(p,1,nread); - + DEBUG(3,("lockread fnum=%d num=%d nread=%d\n", fsp->fnum, (int)numtoread, (int)nread)); @@ -3060,7 +3063,7 @@ void reply_read(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBread); @@ -3091,9 +3094,9 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n", reply_outbuf(req, 5, numtoread+3); data = smb_buf(req->outbuf) + 3; - - if (is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtoread, - (SMB_BIG_UINT)startpos, READ_LOCK)) { + + if (is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtoread, + (uint64_t)startpos, READ_LOCK)) { reply_doserror(req, ERRDOS,ERRlock); END_PROFILE(SMBread); return; @@ -3114,7 +3117,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n", SSVAL(req->outbuf,smb_vwv5,nread+3); SCVAL(smb_buf(req->outbuf),0,1); SSVAL(smb_buf(req->outbuf),1,nread); - + DEBUG( 3, ( "read fnum=%d num=%d nread=%d\n", fsp->fnum, (int)numtoread, (int)nread ) ); @@ -3304,7 +3307,7 @@ void reply_read_and_X(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv2)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv2)); startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv3); smb_maxcnt = SVAL(req->inbuf,smb_vwv5); @@ -3379,8 +3382,8 @@ void reply_read_and_X(struct smb_request *req) } - if (is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)smb_maxcnt, - (SMB_BIG_UINT)startpos, READ_LOCK)) { + if (is_locked(fsp, (uint32)req->smbpid, (uint64_t)smb_maxcnt, + (uint64_t)startpos, READ_LOCK)) { END_PROFILE(SMBreadX); reply_doserror(req, ERRDOS, ERRlock); return; @@ -3452,7 +3455,7 @@ void reply_writebraw(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { error_to_writebrawerr(req); END_PROFILE(SMBwritebraw); @@ -3489,8 +3492,8 @@ void reply_writebraw(struct smb_request *req) return; } - if (is_locked(fsp,(uint32)req->smbpid,(SMB_BIG_UINT)tcount, - (SMB_BIG_UINT)startpos, WRITE_LOCK)) { + if (is_locked(fsp,(uint32)req->smbpid,(uint64_t)tcount, + (uint64_t)startpos, WRITE_LOCK)) { reply_doserror(req, ERRDOS, ERRlock); error_to_writebrawerr(req); END_PROFILE(SMBwritebraw); @@ -3656,8 +3659,8 @@ void reply_writeunlock(struct smb_request *req) END_PROFILE(SMBwriteunlock); return; } - - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBwriteunlock); @@ -3673,10 +3676,10 @@ void reply_writeunlock(struct smb_request *req) numtowrite = SVAL(req->inbuf,smb_vwv1); startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv2); data = smb_buf(req->inbuf) + 3; - + if (numtowrite - && is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos, WRITE_LOCK)) { + && is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtowrite, + (uint64_t)startpos, WRITE_LOCK)) { reply_doserror(req, ERRDOS, ERRlock); END_PROFILE(SMBwriteunlock); return; @@ -3690,7 +3693,7 @@ void reply_writeunlock(struct smb_request *req) } else { nwritten = write_file(req,fsp,data,startpos,numtowrite); } - + status = sync_file(conn, fsp, False /* write through */); if (!NT_STATUS_IS_OK(status)) { DEBUG(5,("reply_writeunlock: sync_file for %s returned %s\n", @@ -3710,8 +3713,8 @@ void reply_writeunlock(struct smb_request *req) status = do_unlock(smbd_messaging_context(), fsp, req->smbpid, - (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos, + (uint64_t)numtowrite, + (uint64_t)startpos, WINDOWS_LOCK); if (NT_STATUS_V(status)) { @@ -3722,12 +3725,12 @@ void reply_writeunlock(struct smb_request *req) } reply_outbuf(req, 1, 0); - + SSVAL(req->outbuf,smb_vwv0,nwritten); - + DEBUG(3,("writeunlock fnum=%d num=%d wrote=%d\n", fsp->fnum, (int)numtowrite, (int)nwritten)); - + END_PROFILE(SMBwriteunlock); return; } @@ -3764,7 +3767,7 @@ void reply_write(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBwrite); @@ -3780,9 +3783,9 @@ void reply_write(struct smb_request *req) numtowrite = SVAL(req->inbuf,smb_vwv1); startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv2); data = smb_buf(req->inbuf) + 3; - - if (is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos, WRITE_LOCK)) { + + if (is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtowrite, + (uint64_t)startpos, WRITE_LOCK)) { reply_doserror(req, ERRDOS, ERRlock); END_PROFILE(SMBwrite); return; @@ -3831,14 +3834,14 @@ void reply_write(struct smb_request *req) } reply_outbuf(req, 1, 0); - + SSVAL(req->outbuf,smb_vwv0,nwritten); if (nwritten < (ssize_t)numtowrite) { SCVAL(req->outbuf,smb_rcls,ERRHRD); SSVAL(req->outbuf,smb_err,ERRdiskfull); } - + DEBUG(3,("write fnum=%d num=%d wrote=%d\n", fsp->fnum, (int)numtowrite, (int)nwritten)); END_PROFILE(SMBwrite); @@ -3994,7 +3997,7 @@ void reply_write_and_X(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv2)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv2)); startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv3); write_through = BITSETW(req->inbuf+smb_vwv7,0); @@ -4037,8 +4040,8 @@ void reply_write_and_X(struct smb_request *req) } if (is_locked(fsp,(uint32)req->smbpid, - (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos, WRITE_LOCK)) { + (uint64_t)numtowrite, + (uint64_t)startpos, WRITE_LOCK)) { reply_doserror(req, ERRDOS, ERRlock); END_PROFILE(SMBwriteX); return; @@ -4059,7 +4062,7 @@ void reply_write_and_X(struct smb_request *req) END_PROFILE(SMBwriteX); return; } - + nwritten = write_file(req,fsp,data,startpos,numtowrite); } @@ -4115,7 +4118,7 @@ void reply_lseek(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { return; @@ -4175,7 +4178,7 @@ void reply_lseek(struct smb_request *req) reply_outbuf(req, 2, 0); SIVAL(req->outbuf,smb_vwv0,res); - + DEBUG(3,("lseek fnum=%d ofs=%.0f newpos = %.0f mode=%d\n", fsp->fnum, (double)startpos, (double)res, mode)); @@ -4201,12 +4204,12 @@ void reply_flush(struct smb_request *req) } fnum = SVAL(req->inbuf,smb_vwv0); - fsp = file_fsp(fnum); + fsp = file_fsp(req, fnum); if ((fnum != 0xFFFF) && !check_fsp(conn, req, fsp)) { return; } - + if (!fsp) { file_sync_all(conn); } else { @@ -4219,7 +4222,7 @@ void reply_flush(struct smb_request *req) return; } } - + reply_outbuf(req, 0, 0); DEBUG(3,("flush\n")); @@ -4263,17 +4266,10 @@ void reply_close(struct smb_request *req) return; } - /* If it's an IPC, pass off to the pipe handler. */ - if (IS_IPC(conn)) { - reply_pipe_close(conn, req); - END_PROFILE(SMBclose); - return; - } - - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); /* - * We can only use CHECK_FSP if we know it's not a directory. + * We can only use check_fsp if we know it's not a directory. */ if(!fsp || (fsp->conn != conn) || (fsp->vuid != req->vuid)) { @@ -4287,7 +4283,7 @@ void reply_close(struct smb_request *req) * Special case - close NT SMB directory handle. */ DEBUG(3,("close directory fnum=%d\n", fsp->fnum)); - status = close_file(fsp,NORMAL_CLOSE); + status = close_file(req, fsp, NORMAL_CLOSE); } else { time_t t; /* @@ -4297,7 +4293,7 @@ void reply_close(struct smb_request *req) DEBUG(3,("close fd=%d fnum=%d (numopen=%d)\n", fsp->fh->fd, fsp->fnum, conn->num_files_open)); - + /* * Take care of any time sent in the close. */ @@ -4310,8 +4306,8 @@ void reply_close(struct smb_request *req) * was detected on close - normally this is due to * a disk full error. If not then it was probably an I/O error. */ - - status = close_file(fsp,NORMAL_CLOSE); + + status = close_file(req, fsp, NORMAL_CLOSE); } if (!NT_STATUS_IS_OK(status)) { @@ -4348,7 +4344,7 @@ void reply_writeclose(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBwriteclose); @@ -4365,15 +4361,15 @@ void reply_writeclose(struct smb_request *req) mtime = convert_time_t_to_timespec(srv_make_unix_date3( req->inbuf+smb_vwv4)); data = smb_buf(req->inbuf) + 1; - + if (numtowrite - && is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos, WRITE_LOCK)) { + && is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtowrite, + (uint64_t)startpos, WRITE_LOCK)) { reply_doserror(req, ERRDOS,ERRlock); END_PROFILE(SMBwriteclose); return; } - + nwritten = write_file(req,fsp,data,startpos,numtowrite); set_close_write_time(fsp, mtime); @@ -4386,19 +4382,19 @@ void reply_writeclose(struct smb_request *req) if (numtowrite) { DEBUG(3,("reply_writeclose: zero length write doesn't close file %s\n", fsp->fsp_name )); - close_status = close_file(fsp,NORMAL_CLOSE); + close_status = close_file(req, fsp, NORMAL_CLOSE); } DEBUG(3,("writeclose fnum=%d num=%d wrote=%d (numopen=%d)\n", fsp->fnum, (int)numtowrite, (int)nwritten, conn->num_files_open)); - + if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) { reply_doserror(req, ERRHRD, ERRdiskfull); END_PROFILE(SMBwriteclose); return; } - + if(!NT_STATUS_IS_OK(close_status)) { reply_nterror(req, close_status); END_PROFILE(SMBwriteclose); @@ -4406,7 +4402,7 @@ void reply_writeclose(struct smb_request *req) } reply_outbuf(req, 1, 0); - + SSVAL(req->outbuf,smb_vwv0,nwritten); END_PROFILE(SMBwriteclose); return; @@ -4422,7 +4418,7 @@ void reply_writeclose(struct smb_request *req) void reply_lock(struct smb_request *req) { connection_struct *conn = req->conn; - SMB_BIG_UINT count,offset; + uint64_t count,offset; NTSTATUS status; files_struct *fsp; struct byte_range_lock *br_lck = NULL; @@ -4435,7 +4431,7 @@ void reply_lock(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBlock); @@ -4444,8 +4440,8 @@ void reply_lock(struct smb_request *req) release_level_2_oplocks_on_change(fsp); - count = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv1); - offset = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv3); + count = (uint64_t)IVAL(req->inbuf,smb_vwv1); + offset = (uint64_t)IVAL(req->inbuf,smb_vwv3); DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n", fsp->fh->fd, fsp->fnum, (double)offset, (double)count)); @@ -4482,7 +4478,7 @@ void reply_lock(struct smb_request *req) void reply_unlock(struct smb_request *req) { connection_struct *conn = req->conn; - SMB_BIG_UINT count,offset; + uint64_t count,offset; NTSTATUS status; files_struct *fsp; @@ -4494,16 +4490,16 @@ void reply_unlock(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBunlock); return; } - - count = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv1); - offset = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv3); - + + count = (uint64_t)IVAL(req->inbuf,smb_vwv1); + offset = (uint64_t)IVAL(req->inbuf,smb_vwv3); + status = do_unlock(smbd_messaging_context(), fsp, req->smbpid, @@ -4611,8 +4607,6 @@ void reply_echo(struct smb_request *req) TALLOC_FREE(req->outbuf); - smb_echo_count++; - END_PROFILE(SMBecho); return; } @@ -4626,7 +4620,7 @@ void reply_printopen(struct smb_request *req) connection_struct *conn = req->conn; files_struct *fsp; NTSTATUS status; - + START_PROFILE(SMBsplopen); if (req->wct < 2) { @@ -4642,7 +4636,7 @@ void reply_printopen(struct smb_request *req) } /* Open for exclusive use, write only. */ - status = print_fsp_open(conn, NULL, req->vuid, &fsp); + status = print_fsp_open(req, conn, NULL, req->vuid, &fsp); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); @@ -4652,7 +4646,7 @@ void reply_printopen(struct smb_request *req) reply_outbuf(req, 1, 0); SSVAL(req->outbuf,smb_vwv0,fsp->fnum); - + DEBUG(3,("openprint fd=%d fnum=%d\n", fsp->fh->fd, fsp->fnum)); @@ -4678,7 +4672,7 @@ void reply_printclose(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBsplclose); @@ -4690,11 +4684,11 @@ void reply_printclose(struct smb_request *req) END_PROFILE(SMBsplclose); return; } - + DEBUG(3,("printclose fd=%d fnum=%d\n", fsp->fh->fd,fsp->fnum)); - - status = close_file(fsp,NORMAL_CLOSE); + + status = close_file(req, fsp, NORMAL_CLOSE); if(!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); @@ -4744,7 +4738,7 @@ void reply_printqueue(struct smb_request *req) SSVAL(req->outbuf,smb_vwv1,0); SCVAL(smb_buf(req->outbuf),0,1); SSVAL(smb_buf(req->outbuf),1,0); - + DEBUG(3,("printqueue start_index=%d max_count=%d\n", start_index, max_count)); @@ -4760,7 +4754,7 @@ void reply_printqueue(struct smb_request *req) num_to_get = 0; else num_to_get = MIN(num_to_get,count-first); - + for (i=first;iinbuf,smb_vwv0)); + + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if (!check_fsp(conn, req, fsp)) { END_PROFILE(SMBsplwr); @@ -5217,7 +5211,7 @@ static bool resolve_wildcards(TALLOC_CTX *ctx, char *ext1 = NULL; char *ext2 = NULL; char *p,*p2, *pname1, *pname2; - + name2_copy = talloc_strdup(ctx, name2); if (!name2_copy) { return False; @@ -5229,7 +5223,7 @@ static bool resolve_wildcards(TALLOC_CTX *ctx, if (!pname1 || !pname2) { return False; } - + /* Truncate the copy of name2 at the last '/' */ *pname2 = '\0'; @@ -5583,10 +5577,10 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, DEBUG(3,("rename_internals_fsp: succeeded doing rename on %s -> %s\n", fsp->fsp_name,newname)); - rename_open_files(conn, lck, newname); - notify_rename(conn, fsp->is_directory, fsp->fsp_name, newname); + rename_open_files(conn, lck, newname); + /* * A rename acts as a new file create w.r.t. allowing an initial delete * on close, probably because in Windows there is a new handle to the @@ -5789,7 +5783,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, last_component_dest, attrs, replace_if_exists); - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); DEBUG(3, ("rename_internals: Error %s rename %s -> %s\n", nt_errstr(status), directory,newname)); @@ -5893,7 +5887,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, status = rename_internals_fsp(conn, fsp, destname, dname, attrs, replace_if_exists); - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("rename_internals_fsp returned %s for " @@ -6108,7 +6102,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, TALLOC_FREE(dest); if (!NT_STATUS_IS_OK(status)) { - close_file(fsp1,ERROR_CLOSE); + close_file(NULL, fsp1, ERROR_CLOSE); return status; } @@ -6127,7 +6121,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, ret = vfs_transfer_file(fsp1, fsp2, src_sbuf.st_size); } - close_file(fsp1,NORMAL_CLOSE); + close_file(NULL, fsp1, NORMAL_CLOSE); /* Ensure the modtime is set correctly on the destination file. */ set_close_write_time(fsp2, get_mtimespec(&src_sbuf)); @@ -6138,7 +6132,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, * Thus we don't look at the error return from the * close of fsp1. */ - status = close_file(fsp2,NORMAL_CLOSE); + status = close_file(NULL, fsp2, NORMAL_CLOSE); if (!NT_STATUS_IS_OK(status)) { return status; @@ -6502,17 +6496,17 @@ uint32 get_lock_pid( char *data, int data_offset, bool large_file_format) Get a lock count, dealing with large count requests. ****************************************************************************/ -SMB_BIG_UINT get_lock_count( char *data, int data_offset, bool large_file_format) +uint64_t get_lock_count( char *data, int data_offset, bool large_file_format) { - SMB_BIG_UINT count = 0; + uint64_t count = 0; if(!large_file_format) { - count = (SMB_BIG_UINT)IVAL(data,SMB_LKLEN_OFFSET(data_offset)); + count = (uint64_t)IVAL(data,SMB_LKLEN_OFFSET(data_offset)); } else { #if defined(HAVE_LONGLONG) - count = (((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) << 32) | - ((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset))); + count = (((uint64_t) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) << 32) | + ((uint64_t) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset))); #else /* HAVE_LONGLONG */ /* @@ -6529,7 +6523,7 @@ SMB_BIG_UINT get_lock_count( char *data, int data_offset, bool large_file_format SIVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset),0); } - count = (SMB_BIG_UINT)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)); + count = (uint64_t)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)); #endif /* HAVE_LONGLONG */ } @@ -6546,26 +6540,26 @@ static uint32 map_lock_offset(uint32 high, uint32 low) unsigned int i; uint32 mask = 0; uint32 highcopy = high; - + /* * Try and find out how many significant bits there are in high. */ - + for(i = 0; highcopy; i++) highcopy >>= 1; - + /* * We use 31 bits not 32 here as POSIX * lock offsets may not be negative. */ - + mask = (~0) << (31 - i); - + if(low & mask) return 0; /* Fail. */ - + high <<= (31 - i); - + return (high|low); } #endif /* !defined(HAVE_LONGLONG) */ @@ -6574,19 +6568,19 @@ static uint32 map_lock_offset(uint32 high, uint32 low) Get a lock offset, dealing with large offset requests. ****************************************************************************/ -SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err) +uint64_t get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err) { - SMB_BIG_UINT offset = 0; + uint64_t offset = 0; *err = False; if(!large_file_format) { - offset = (SMB_BIG_UINT)IVAL(data,SMB_LKOFF_OFFSET(data_offset)); + offset = (uint64_t)IVAL(data,SMB_LKOFF_OFFSET(data_offset)); } else { #if defined(HAVE_LONGLONG) - offset = (((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) << 32) | - ((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset))); + offset = (((uint64_t) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) << 32) | + ((uint64_t) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset))); #else /* HAVE_LONGLONG */ /* @@ -6595,7 +6589,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_forma * negotiated. For boxes without large unsigned ints mangle the * lock offset by mapping the top 32 bits onto the lower 32. */ - + if(IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0) { uint32 low = IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)); uint32 high = IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)); @@ -6603,7 +6597,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_forma if((new_low = map_lock_offset(high, low)) == 0) { *err = True; - return (SMB_BIG_UINT)-1; + return (uint64_t)-1; } DEBUG(3,("get_lock_offset: truncating lock offset (high)0x%x (low)0x%x to offset 0x%x.\n", @@ -6612,7 +6606,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_forma SIVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset),new_low); } - offset = (SMB_BIG_UINT)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)); + offset = (uint64_t)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)); #endif /* HAVE_LONGLONG */ } @@ -6631,7 +6625,7 @@ void reply_lockingX(struct smb_request *req) unsigned char oplocklevel; uint16 num_ulocks; uint16 num_locks; - SMB_BIG_UINT count = 0, offset = 0; + uint64_t count = 0, offset = 0; uint32 lock_pid; int32 lock_timeout; int i; @@ -6647,8 +6641,8 @@ void reply_lockingX(struct smb_request *req) END_PROFILE(SMBlockingX); return; } - - fsp = file_fsp(SVAL(req->inbuf,smb_vwv2)); + + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv2)); locktype = CVAL(req->inbuf,smb_vwv3); oplocklevel = CVAL(req->inbuf,smb_vwv3+1); num_ulocks = SVAL(req->inbuf,smb_vwv6); @@ -6660,7 +6654,7 @@ void reply_lockingX(struct smb_request *req) END_PROFILE(SMBlockingX); return; } - + data = smb_buf(req->inbuf); if (locktype & LOCKING_ANDX_CHANGE_LOCKTYPE) { @@ -6671,7 +6665,7 @@ void reply_lockingX(struct smb_request *req) END_PROFILE(SMBlockingX); return; } - + /* Check if this is an oplock break on a file we have granted an oplock on. */ @@ -6688,7 +6682,7 @@ void reply_lockingX(struct smb_request *req) * Make sure we have granted an exclusive or batch oplock on * this file. */ - + if (fsp->oplock_type == 0) { /* The Samba4 nbench simulator doesn't understand @@ -6720,7 +6714,7 @@ void reply_lockingX(struct smb_request *req) } else { result = downgrade_oplock(fsp); } - + if (!result) { DEBUG(0, ("reply_lockingX: error in removing " "oplock on file %s\n", fsp->fsp_name)); @@ -6749,7 +6743,7 @@ void reply_lockingX(struct smb_request *req) * We do this check *after* we have checked this is not a oplock break * response message. JRA. */ - + release_level_2_oplocks_on_change(fsp); if (smb_buflen(req->inbuf) < @@ -6758,14 +6752,14 @@ void reply_lockingX(struct smb_request *req) END_PROFILE(SMBlockingX); return; } - + /* Data now points at the beginning of the list of smb_unlkrng structs */ for(i = 0; i < (int)num_ulocks; i++) { lock_pid = get_lock_pid( data, i, large_file_format); count = get_lock_count( data, i, large_file_format); offset = get_lock_offset( data, i, large_file_format, &err); - + /* * There is no error code marked "stupid client bug".... :-). */ @@ -6778,7 +6772,7 @@ void reply_lockingX(struct smb_request *req) DEBUG(10,("reply_lockingX: unlock start=%.0f, len=%.0f for " "pid %u, file %s\n", (double)offset, (double)count, (unsigned int)lock_pid, fsp->fsp_name )); - + status = do_unlock(smbd_messaging_context(), fsp, lock_pid, @@ -6798,20 +6792,20 @@ void reply_lockingX(struct smb_request *req) if (!lp_blocking_locks(SNUM(conn))) { lock_timeout = 0; } - + /* Now do any requested locks */ data += ((large_file_format ? 20 : 10)*num_ulocks); - + /* Data now points at the beginning of the list of smb_lkrng structs */ - + for(i = 0; i < (int)num_locks; i++) { enum brl_type lock_type = ((locktype & LOCKING_ANDX_SHARED_LOCK) ? READ_LOCK:WRITE_LOCK); lock_pid = get_lock_pid( data, i, large_file_format); count = get_lock_count( data, i, large_file_format); offset = get_lock_offset( data, i, large_file_format, &err); - + /* * There is no error code marked "stupid client bug".... :-). */ @@ -6820,12 +6814,12 @@ void reply_lockingX(struct smb_request *req) reply_doserror(req, ERRDOS, ERRnoaccess); return; } - + DEBUG(10,("reply_lockingX: lock start=%.0f, len=%.0f for pid " "%u, file %s timeout = %d\n", (double)offset, (double)count, (unsigned int)lock_pid, fsp->fsp_name, (int)lock_timeout )); - + if (locktype & LOCKING_ANDX_CANCEL_LOCK) { if (lp_blocking_locks(SNUM(conn))) { @@ -6924,7 +6918,7 @@ void reply_lockingX(struct smb_request *req) return; } } - + /* If any of the above locks failed, then we must unlock all of the previous locks (X/Open spec). */ @@ -6941,7 +6935,7 @@ void reply_lockingX(struct smb_request *req) count = get_lock_count( data, i, large_file_format); offset = get_lock_offset( data, i, large_file_format, &err); - + /* * There is no error code marked "stupid client * bug".... :-). @@ -6951,7 +6945,7 @@ void reply_lockingX(struct smb_request *req) reply_doserror(req, ERRDOS, ERRnoaccess); return; } - + do_unlock(smbd_messaging_context(), fsp, lock_pid, @@ -6965,10 +6959,10 @@ void reply_lockingX(struct smb_request *req) } reply_outbuf(req, 2, 0); - + DEBUG(3, ("lockingX fnum=%d type=%d num_locks=%d num_ulocks=%d\n", fsp->fnum, (unsigned int)locktype, num_locks, num_ulocks)); - + END_PROFILE(SMBlockingX); chain_reply(req); } @@ -7024,7 +7018,7 @@ void reply_setattrE(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if(!fsp || (fsp->conn != conn)) { reply_doserror(req, ERRDOS, ERRbadfid); @@ -7042,7 +7036,7 @@ void reply_setattrE(struct smb_request *req) srv_make_unix_date2(req->inbuf+smb_vwv3)); /* atime. */ ts[1] = convert_time_t_to_timespec( srv_make_unix_date2(req->inbuf+smb_vwv5)); /* mtime. */ - + reply_outbuf(req, 0, 0); /* @@ -7074,7 +7068,7 @@ void reply_setattrE(struct smb_request *req) END_PROFILE(SMBsetattrE); return; } - + DEBUG( 3, ( "reply_setattrE fnum=%d actime=%u modtime=%u\n", fsp->fnum, (unsigned int)ts[0].tv_sec, @@ -7135,7 +7129,7 @@ void reply_getattrE(struct smb_request *req) return; } - fsp = file_fsp(SVAL(req->inbuf,smb_vwv0)); + fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0)); if(!fsp || (fsp->conn != conn)) { reply_doserror(req, ERRDOS, ERRbadfid); @@ -7149,9 +7143,9 @@ void reply_getattrE(struct smb_request *req) END_PROFILE(SMBgetattrE); return; } - + mode = dos_mode(conn,fsp->fsp_name,&sbuf); - + /* * Convert the times into dos times. Set create * date to be last modify date as UNIX doesn't save @@ -7176,9 +7170,9 @@ void reply_getattrE(struct smb_request *req) SIVAL(req->outbuf, smb_vwv8, allocation_size); } SSVAL(req->outbuf,smb_vwv10, mode); - + DEBUG( 3, ( "reply_getattrE fnum=%d\n", fsp->fnum)); - + END_PROFILE(SMBgetattrE); return; } diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c index e9dc46aa3c..3822ee191e 100644 --- a/source3/smbd/seal.c +++ b/source3/smbd/seal.c @@ -426,9 +426,14 @@ static NTSTATUS srv_enc_spnego_gss_negotiate(unsigned char **ppdata, size_t *p_d data_blob_free(&auth_reply); SAFE_FREE(*ppdata); - *ppdata = response.data; + *ppdata = (unsigned char *)memdup(response.data, response.length); + if ((*ppdata) == NULL && response.length > 0) { + status = NT_STATUS_NO_MEMORY; + } *p_data_size = response.length; + data_blob_free(&response); + return status; } #endif @@ -463,8 +468,13 @@ static NTSTATUS srv_enc_ntlm_negotiate(unsigned char **ppdata, size_t *p_data_si } SAFE_FREE(*ppdata); - *ppdata = response.data; + *ppdata = (unsigned char *)memdup(response.data, response.length); + if ((*ppdata) == NULL && response.length > 0) { + status = NT_STATUS_NO_MEMORY; + } *p_data_size = response.length; + data_blob_free(&response); + return status; } @@ -585,8 +595,11 @@ static NTSTATUS srv_enc_spnego_ntlm_auth(connection_struct *conn, } SAFE_FREE(*ppdata); - *ppdata = response.data; + *ppdata = (unsigned char *)memdup(response.data, response.length); + if ((*ppdata) == NULL && response.length > 0) + return NT_STATUS_NO_MEMORY; *p_data_size = response.length; + data_blob_free(&response); return status; } @@ -636,8 +649,11 @@ static NTSTATUS srv_enc_raw_ntlm_auth(connection_struct *conn, /* Return the raw blob. */ SAFE_FREE(*ppdata); - *ppdata = response.data; + *ppdata = (unsigned char *)memdup(response.data, response.length); + if ((*ppdata) == NULL && response.length > 0) + return NT_STATUS_NO_MEMORY; *p_data_size = response.length; + data_blob_free(&response); return status; } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 53116f3d98..4e81263ee4 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -840,7 +840,7 @@ bool reload_services(bool test) if (lp_loaded()) { char *fname = lp_configfile(); - if (file_exist(fname, NULL) && + if (file_exist(fname) && !strcsequal(fname, get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; @@ -888,7 +888,7 @@ bool reload_services(bool test) enum server_exit_reason { SERVER_EXIT_NORMAL, SERVER_EXIT_ABNORMAL }; static void exit_server_common(enum server_exit_reason how, - const char *const reason) NORETURN_ATTRIBUTE; + const char *const reason) _NORETURN_; static void exit_server_common(enum server_exit_reason how, const char *const reason) @@ -1067,6 +1067,30 @@ static bool deadtime_fn(const struct timeval *now, void *private_data) return True; } +/* + * Do the recurring log file and smb.conf reload checks. + */ + +static bool housekeeping_fn(const struct timeval *now, void *private_data) +{ + change_to_root_user(); + + /* update printer queue caches if necessary */ + update_monitored_printq_cache(); + + /* check if we need to reload services */ + check_reload(time(NULL)); + + /* Change machine password if neccessary. */ + attempt_machine_password_change(); + + /* + * Force a log file check. + */ + force_check_log_size(); + check_log_size(); + return true; +} /**************************************************************************** main program. @@ -1295,7 +1319,7 @@ extern void build_options(bool screen); setpgid( (pid_t)0, (pid_t)0); #endif - if (!directory_exist(lp_lockdir(), NULL)) + if (!directory_exist(lp_lockdir())) mkdir(lp_lockdir(), 0755); if (is_daemon) @@ -1426,6 +1450,13 @@ extern void build_options(bool screen); exit(1); } + if (!(event_add_idle(smbd_event_context(), NULL, + timeval_set(SMBD_SELECT_TIMEOUT, 0), + "housekeeping", housekeeping_fn, NULL))) { + DEBUG(0, ("Could not add housekeeping event\n")); + exit(1); + } + #ifdef CLUSTER_SUPPORT if (lp_clustering()) { diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 0b851f1e48..05197021a3 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -1296,10 +1296,9 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password, void close_cnum(connection_struct *conn, uint16 vuid) { - if (IS_IPC(conn)) { - pipe_close_conn(conn); - } else { - file_close_conn(conn); + file_close_conn(conn); + + if (!IS_IPC(conn)) { dptr_closecnum(conn); } diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 3b431a19be..8163eb30af 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -113,7 +113,10 @@ bool session_claim(user_struct *vuser) break; } - sess_pid = ((struct sessionid *)rec->value.dptr)->pid; + memcpy(&sess_pid, + ((char *)rec->value.dptr) + + offsetof(struct sessionid, pid), + sizeof(sess_pid)); if (!process_exists(sess_pid)) { DEBUG(5, ("%s has died -- re-using session\n", diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index 0e9a2c2ebe..ee33e13a48 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -118,7 +118,7 @@ static int darwin_statvfs(const char *path, vfs_statvfs_struct *statbuf) statbuf->UserBlocksAvail = sbuf.f_bavail; statbuf->TotalFileNodes = sbuf.f_files; statbuf->FreeFileNodes = sbuf.f_ffree; - statbuf->FsIdentifier = *(SMB_BIG_UINT *)(&sbuf.f_fsid); /* Ick. */ + statbuf->FsIdentifier = *(uint64_t *)(&sbuf.f_fsid); /* Ick. */ statbuf->FsCapabilities = darwin_fs_capabilities(sbuf.f_mntonname); return 0; diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 2e2da5cc71..1da45a8b58 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -47,9 +47,9 @@ static char *store_file_unix_basic_info2(connection_struct *conn, Only do this for Windows clients. ********************************************************************/ -SMB_BIG_UINT smb_roundup(connection_struct *conn, SMB_BIG_UINT val) +uint64_t smb_roundup(connection_struct *conn, uint64_t val) { - SMB_BIG_UINT rval = lp_allocation_roundup_size(SNUM(conn)); + uint64_t rval = lp_allocation_roundup_size(SNUM(conn)); /* Only roundup for Windows clients. */ enum remote_arch_types ra_type = get_remote_arch(); @@ -64,18 +64,18 @@ SMB_BIG_UINT smb_roundup(connection_struct *conn, SMB_BIG_UINT val) account sparse files. ********************************************************************/ -SMB_BIG_UINT get_allocation_size(connection_struct *conn, files_struct *fsp, const SMB_STRUCT_STAT *sbuf) +uint64_t get_allocation_size(connection_struct *conn, files_struct *fsp, const SMB_STRUCT_STAT *sbuf) { - SMB_BIG_UINT ret; + uint64_t ret; if(S_ISDIR(sbuf->st_mode)) { return 0; } #if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE) - ret = (SMB_BIG_UINT)STAT_ST_BLOCKSIZE * (SMB_BIG_UINT)sbuf->st_blocks; + ret = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_blocks; #else - ret = (SMB_BIG_UINT)get_file_size(*sbuf); + ret = (uint64_t)get_file_size(*sbuf); #endif if (fsp && fsp->initial_allocation_size) @@ -1031,7 +1031,7 @@ static void call_trans2open(connection_struct *conn, mtime = sbuf.st_mtime; inode = sbuf.st_ino; if (fattr & aDIR) { - close_file(fsp,ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); reply_doserror(req, ERRDOS,ERRnoaccess); return; } @@ -1264,7 +1264,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx, long prev_dirpos=0; uint32 mode=0; SMB_OFF_T file_size = 0; - SMB_BIG_UINT allocation_size = 0; + uint64_t allocation_size = 0; uint32 len; struct timespec mdate_ts, adate_ts, create_date_ts; time_t mdate = (time_t)0, adate = (time_t)0, create_date = (time_t)0; @@ -1892,7 +1892,7 @@ static void call_trans2findfirst(connection_struct *conn, bool requires_resume_key; int info_level; char *directory = NULL; - const char *mask = NULL; + char *mask = NULL; char *p; int last_entry_off=0; int dptr_num = -1; @@ -1980,7 +1980,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n", return; } - ntstatus = unix_convert(ctx, conn, directory, True, &directory, NULL, &sbuf); + ntstatus = unix_convert(ctx, conn, directory, True, &directory, &mask, &sbuf); if (!NT_STATUS_IS_OK(ntstatus)) { reply_nterror(req, ntstatus); return; @@ -1996,10 +1996,12 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n", if(p == NULL) { /* Windows and OS/2 systems treat search on the root '\' as if it were '\*' */ if((directory[0] == '.') && (directory[1] == '\0')) { - mask = "*"; + mask = talloc_strdup(ctx,"*"); + if (!mask) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } mask_contains_wcard = True; - } else { - mask = directory; } directory = talloc_strdup(talloc_tos(), "./"); if (!directory) { @@ -2007,7 +2009,6 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n", return; } } else { - mask = p+1; *p = 0; } @@ -2612,22 +2613,22 @@ static void call_trans2qfsinfo(connection_struct *conn, switch (info_level) { case SMB_INFO_ALLOCATION: { - SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; + uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; data_len = 18; - if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) { + if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (uint64_t)-1) { reply_unixerror(req, ERRHRD, ERRgeneral); return; } block_size = lp_block_size(snum); if (bsize < block_size) { - SMB_BIG_UINT factor = block_size/bsize; + uint64_t factor = block_size/bsize; bsize = block_size; dsize /= factor; dfree /= factor; } if (bsize > block_size) { - SMB_BIG_UINT factor = bsize/block_size; + uint64_t factor = bsize/block_size; bsize = block_size; dsize *= factor; dfree *= factor; @@ -2732,21 +2733,21 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_dev, (unsi case SMB_QUERY_FS_SIZE_INFO: case SMB_FS_SIZE_INFORMATION: { - SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; + uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; data_len = 24; - if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) { + if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (uint64_t)-1) { reply_unixerror(req, ERRHRD, ERRgeneral); return; } block_size = lp_block_size(snum); if (bsize < block_size) { - SMB_BIG_UINT factor = block_size/bsize; + uint64_t factor = block_size/bsize; bsize = block_size; dsize /= factor; dfree /= factor; } if (bsize > block_size) { - SMB_BIG_UINT factor = bsize/block_size; + uint64_t factor = bsize/block_size; bsize = block_size; dsize *= factor; dfree *= factor; @@ -2765,21 +2766,21 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned case SMB_FS_FULL_SIZE_INFORMATION: { - SMB_BIG_UINT dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; + uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; data_len = 32; - if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) { + if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (uint64_t)-1) { reply_unixerror(req, ERRHRD, ERRgeneral); return; } block_size = lp_block_size(snum); if (bsize < block_size) { - SMB_BIG_UINT factor = block_size/bsize; + uint64_t factor = block_size/bsize; bsize = block_size; dsize /= factor; dfree /= factor; } if (bsize > block_size) { - SMB_BIG_UINT factor = bsize/block_size; + uint64_t factor = bsize/block_size; bsize = block_size; dsize *= factor; dfree *= factor; @@ -2810,8 +2811,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned * what we have to send --metze: * * Unknown1: 24 NULL bytes - * Soft Quota Treshold: 8 bytes seems like SMB_BIG_UINT or so - * Hard Quota Limit: 8 bytes seems like SMB_BIG_UINT or so + * Soft Quota Treshold: 8 bytes seems like uint64_t or so + * Hard Quota Limit: 8 bytes seems like uint64_t or so * Quota Flags: 2 byte : * Unknown3: 6 NULL bytes * @@ -2859,9 +2860,9 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned DEBUG(10,("SMB_FS_QUOTA_INFORMATION: for service [%s]\n",lp_servicename(SNUM(conn)))); /* Unknown1 24 NULL bytes*/ - SBIG_UINT(pdata,0,(SMB_BIG_UINT)0); - SBIG_UINT(pdata,8,(SMB_BIG_UINT)0); - SBIG_UINT(pdata,16,(SMB_BIG_UINT)0); + SBIG_UINT(pdata,0,(uint64_t)0); + SBIG_UINT(pdata,8,(uint64_t)0); + SBIG_UINT(pdata,16,(uint64_t)0); /* Default Soft Quota 8 bytes */ SBIG_UINT(pdata,24,quotas.softlim); @@ -2934,7 +2935,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned /* We have POSIX ACLs, pathname, encryption, * large read/write, and locking capability. */ - SBIG_UINT(pdata,4,((SMB_BIG_UINT)( + SBIG_UINT(pdata,4,((uint64_t)( CIFS_UNIX_POSIX_ACLS_CAP| CIFS_UNIX_POSIX_PATHNAMES_CAP| CIFS_UNIX_FCNTL_LOCKS_CAP| @@ -3036,9 +3037,9 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned SIVAL(pdata, 0, flags); SIVAL(pdata, 4, SMB_WHOAMI_MASK); SBIG_UINT(pdata, 8, - (SMB_BIG_UINT)conn->server_info->utok.uid); + (uint64_t)conn->server_info->utok.uid); SBIG_UINT(pdata, 16, - (SMB_BIG_UINT)conn->server_info->utok.gid); + (uint64_t)conn->server_info->utok.gid); if (data_len >= max_data_bytes) { @@ -3077,7 +3078,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned /* GID list */ for (i = 0; i < conn->server_info->utok.ngroups; ++i) { SBIG_UINT(pdata, data_len, - (SMB_BIG_UINT)conn->server_info->utok.groups[i]); + (uint64_t)conn->server_info->utok.groups[i]); data_len += 8; } @@ -3297,7 +3298,7 @@ cap_low = 0x%x, cap_high = 0x%x\n", * but we didn't use the last 6 bytes for now * --metze */ - fsp = file_fsp(SVAL(params,0)); + fsp = file_fsp(req, SVAL(params,0)); if (!check_fsp_ntquota_handle(conn, req, fsp)) { @@ -3318,10 +3319,10 @@ cap_low = 0x%x, cap_high = 0x%x\n", /* unknown_1 24 NULL bytes in pdata*/ - /* the soft quotas 8 bytes (SMB_BIG_UINT)*/ - quotas.softlim = (SMB_BIG_UINT)IVAL(pdata,24); + /* the soft quotas 8 bytes (uint64_t)*/ + quotas.softlim = (uint64_t)IVAL(pdata,24); #ifdef LARGE_SMB_OFF_T - quotas.softlim |= (((SMB_BIG_UINT)IVAL(pdata,28)) << 32); + quotas.softlim |= (((uint64_t)IVAL(pdata,28)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(pdata,28) != 0)&& ((quotas.softlim != 0xFFFFFFFF)|| @@ -3334,10 +3335,10 @@ cap_low = 0x%x, cap_high = 0x%x\n", } #endif /* LARGE_SMB_OFF_T */ - /* the hard quotas 8 bytes (SMB_BIG_UINT)*/ - quotas.hardlim = (SMB_BIG_UINT)IVAL(pdata,32); + /* the hard quotas 8 bytes (uint64_t)*/ + quotas.hardlim = (uint64_t)IVAL(pdata,32); #ifdef LARGE_SMB_OFF_T - quotas.hardlim |= (((SMB_BIG_UINT)IVAL(pdata,36)) << 32); + quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32); #else /* LARGE_SMB_OFF_T */ if ((IVAL(pdata,36) != 0)&& ((quotas.hardlim != 0xFFFFFFFF)|| @@ -3753,7 +3754,7 @@ static void call_trans2qpipeinfo(connection_struct *conn, unsigned int data_size = 0; unsigned int param_size = 2; uint16 info_level; - smb_np_struct *p_pipe = NULL; + files_struct *fsp; if (!params) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -3765,8 +3766,8 @@ static void call_trans2qpipeinfo(connection_struct *conn, return; } - p_pipe = get_rpc_pipe_p(SVAL(params,0)); - if (p_pipe == NULL) { + fsp = file_fsp(req, SVAL(params,0)); + if (!fsp_is_np(fsp)) { reply_nterror(req, NT_STATUS_INVALID_HANDLE); return; } @@ -3827,7 +3828,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, int mode=0; int nlink; SMB_OFF_T file_size=0; - SMB_BIG_UINT allocation_size=0; + uint64_t allocation_size=0; unsigned int data_size = 0; unsigned int param_size = 2; SMB_STRUCT_STAT sbuf; @@ -3872,7 +3873,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, return; } - fsp = file_fsp(SVAL(params,0)); + fsp = file_fsp(req, SVAL(params,0)); info_level = SVAL(params,2); DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QFILEINFO: level = %d\n", info_level)); @@ -4681,8 +4682,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd case SMB_QUERY_POSIX_LOCK: { NTSTATUS status = NT_STATUS_INVALID_LEVEL; - SMB_BIG_UINT count; - SMB_BIG_UINT offset; + uint64_t count; + uint64_t offset; uint32 lock_pid; enum brl_type lock_type; @@ -4710,13 +4711,13 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd lock_pid = IVAL(pdata, POSIX_LOCK_PID_OFFSET); #if defined(HAVE_LONGLONG) - offset = (((SMB_BIG_UINT) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) | - ((SMB_BIG_UINT) IVAL(pdata,POSIX_LOCK_START_OFFSET)); - count = (((SMB_BIG_UINT) IVAL(pdata,(POSIX_LOCK_LEN_OFFSET+4))) << 32) | - ((SMB_BIG_UINT) IVAL(pdata,POSIX_LOCK_LEN_OFFSET)); + offset = (((uint64_t) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) | + ((uint64_t) IVAL(pdata,POSIX_LOCK_START_OFFSET)); + count = (((uint64_t) IVAL(pdata,(POSIX_LOCK_LEN_OFFSET+4))) << 32) | + ((uint64_t) IVAL(pdata,POSIX_LOCK_LEN_OFFSET)); #else /* HAVE_LONGLONG */ - offset = (SMB_BIG_UINT)IVAL(pdata,POSIX_LOCK_START_OFFSET); - count = (SMB_BIG_UINT)IVAL(pdata,POSIX_LOCK_LEN_OFFSET); + offset = (uint64_t)IVAL(pdata,POSIX_LOCK_START_OFFSET); + count = (uint64_t)IVAL(pdata,POSIX_LOCK_LEN_OFFSET); #endif /* HAVE_LONGLONG */ status = query_lock(fsp, @@ -5015,12 +5016,12 @@ static NTSTATUS smb_set_file_size(connection_struct *conn, if (vfs_set_filelen(new_fsp, size) == -1) { status = map_nt_error_from_unix(errno); - close_file(new_fsp,NORMAL_CLOSE); + close_file(req, new_fsp,NORMAL_CLOSE); return status; } trigger_write_time_update_immediate(new_fsp); - close_file(new_fsp,NORMAL_CLOSE); + close_file(req, new_fsp,NORMAL_CLOSE); return NT_STATUS_OK; } @@ -5122,7 +5123,7 @@ static NTSTATUS smb_file_position_information(connection_struct *conn, int total_data, files_struct *fsp) { - SMB_BIG_UINT position_information; + uint64_t position_information; if (total_data < 8) { return NT_STATUS_INVALID_PARAMETER; @@ -5133,9 +5134,9 @@ static NTSTATUS smb_file_position_information(connection_struct *conn, return NT_STATUS_OK; } - position_information = (SMB_BIG_UINT)IVAL(pdata,0); + position_information = (uint64_t)IVAL(pdata,0); #ifdef LARGE_SMB_OFF_T - position_information |= (((SMB_BIG_UINT)IVAL(pdata,4)) << 32); + position_information |= (((uint64_t)IVAL(pdata,4)) << 32); #else /* LARGE_SMB_OFF_T */ if (IVAL(pdata,4) != 0) { /* more than 32 bits? */ @@ -5474,8 +5475,8 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, int total_data, files_struct *fsp) { - SMB_BIG_UINT count; - SMB_BIG_UINT offset; + uint64_t count; + uint64_t offset; uint32 lock_pid; bool blocking_lock = False; enum brl_type lock_type; @@ -5522,13 +5523,13 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, lock_pid = IVAL(pdata, POSIX_LOCK_PID_OFFSET); #if defined(HAVE_LONGLONG) - offset = (((SMB_BIG_UINT) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) | - ((SMB_BIG_UINT) IVAL(pdata,POSIX_LOCK_START_OFFSET)); - count = (((SMB_BIG_UINT) IVAL(pdata,(POSIX_LOCK_LEN_OFFSET+4))) << 32) | - ((SMB_BIG_UINT) IVAL(pdata,POSIX_LOCK_LEN_OFFSET)); + offset = (((uint64_t) IVAL(pdata,(POSIX_LOCK_START_OFFSET+4))) << 32) | + ((uint64_t) IVAL(pdata,POSIX_LOCK_START_OFFSET)); + count = (((uint64_t) IVAL(pdata,(POSIX_LOCK_LEN_OFFSET+4))) << 32) | + ((uint64_t) IVAL(pdata,POSIX_LOCK_LEN_OFFSET)); #else /* HAVE_LONGLONG */ - offset = (SMB_BIG_UINT)IVAL(pdata,POSIX_LOCK_START_OFFSET); - count = (SMB_BIG_UINT)IVAL(pdata,POSIX_LOCK_LEN_OFFSET); + offset = (uint64_t)IVAL(pdata,POSIX_LOCK_START_OFFSET); + count = (uint64_t)IVAL(pdata,POSIX_LOCK_LEN_OFFSET); #endif /* HAVE_LONGLONG */ DEBUG(10,("smb_set_posix_lock: file %s, lock_type = %u," @@ -5701,7 +5702,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf) { - SMB_BIG_UINT allocation_size = 0; + uint64_t allocation_size = 0; NTSTATUS status = NT_STATUS_OK; files_struct *new_fsp = NULL; @@ -5713,9 +5714,9 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn, return NT_STATUS_INVALID_PARAMETER; } - allocation_size = (SMB_BIG_UINT)IVAL(pdata,0); + allocation_size = (uint64_t)IVAL(pdata,0); #ifdef LARGE_SMB_OFF_T - allocation_size |= (((SMB_BIG_UINT)IVAL(pdata,4)) << 32); + allocation_size |= (((uint64_t)IVAL(pdata,4)) << 32); #else /* LARGE_SMB_OFF_T */ if (IVAL(pdata,4) != 0) { /* more than 32 bits? */ @@ -5770,7 +5771,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn, if (allocation_size != get_file_size(*psbuf)) { if (vfs_allocate_file_space(new_fsp, allocation_size) == -1) { status = map_nt_error_from_unix(errno); - close_file(new_fsp,NORMAL_CLOSE); + close_file(req, new_fsp, NORMAL_CLOSE); return status; } } @@ -5782,7 +5783,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn, */ trigger_write_time_update_immediate(new_fsp); - close_file(new_fsp,NORMAL_CLOSE); + close_file(req, new_fsp, NORMAL_CLOSE); return NT_STATUS_OK; } @@ -6195,7 +6196,7 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn, &fsp); if (NT_STATUS_IS_OK(status)) { - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); } info_level_return = SVAL(pdata,16); @@ -6388,7 +6389,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn, /* Realloc the data size */ *ppdata = (char *)SMB_REALLOC(*ppdata,*pdata_return_size); if (*ppdata == NULL) { - close_file(fsp,ERROR_CLOSE); + close_file(req, fsp, ERROR_CLOSE); *pdata_return_size = 0; return NT_STATUS_NO_MEMORY; } @@ -6506,7 +6507,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn, if (lck == NULL) { DEBUG(0, ("smb_posix_unlink: Could not get share mode " "lock for file %s\n", fsp->fsp_name)); - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); return NT_STATUS_INVALID_PARAMETER; } @@ -6522,7 +6523,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn, continue; } /* Fail with sharing violation. */ - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); TALLOC_FREE(lck); return NT_STATUS_SHARING_VIOLATION; } @@ -6539,12 +6540,12 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn, psbuf); if (!NT_STATUS_IS_OK(status)) { - close_file(fsp, NORMAL_CLOSE); + close_file(req, fsp, NORMAL_CLOSE); TALLOC_FREE(lck); return status; } TALLOC_FREE(lck); - return close_file(fsp, NORMAL_CLOSE); + return close_file(req, fsp, NORMAL_CLOSE); } /**************************************************************************** @@ -6581,7 +6582,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn, return; } - fsp = file_fsp(SVAL(params,0)); + fsp = file_fsp(req, SVAL(params,0)); /* Basic check for non-null fsp. */ if (!check_fsp_open(conn, req, fsp)) { return; @@ -7064,10 +7065,11 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req, reply_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } - } else if (IVAL(pdata,0) != 4) { - reply_nterror(req, NT_STATUS_INVALID_PARAMETER); - return; } + /* If total_data == 4 Windows doesn't care what values + * are placed in that field, it just ignores them. + * The System i QNTC IBM SMB client puts bad values here, + * so ignore them. */ status = create_directory(conn, req, directory); @@ -7249,7 +7251,7 @@ static void call_trans2ioctl(connection_struct *conn, unsigned int max_data_bytes) { char *pdata = *ppdata; - files_struct *fsp = file_fsp(SVAL(req->inbuf,smb_vwv15)); + files_struct *fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv15)); /* check for an invalid fid before proceeding */ diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 1e137dd908..011f31dd24 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -501,13 +501,13 @@ ssize_t vfs_pwrite_data(struct smb_request *req, Returns 0 on success, -1 on failure. ****************************************************************************/ -int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len) +int vfs_allocate_file_space(files_struct *fsp, uint64_t len) { int ret; SMB_STRUCT_STAT st; connection_struct *conn = fsp->conn; - SMB_BIG_UINT space_avail; - SMB_BIG_UINT bsize,dfree,dsize; + uint64_t space_avail; + uint64_t bsize,dfree,dsize; release_level_2_oplocks_on_change(fsp); @@ -527,10 +527,10 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len) if (ret == -1) return ret; - if (len == (SMB_BIG_UINT)st.st_size) + if (len == (uint64_t)st.st_size) return 0; - if (len < (SMB_BIG_UINT)st.st_size) { + if (len < (uint64_t)st.st_size) { /* Shrink - use ftruncate. */ DEBUG(10,("vfs_allocate_file_space: file %s, shrink. Current size %.0f\n", @@ -551,7 +551,7 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len) len -= st.st_size; len /= 1024; /* Len is now number of 1k blocks needed. */ space_avail = get_dfree_info(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize); - if (space_avail == (SMB_BIG_UINT)-1) { + if (space_avail == (uint64_t)-1) { return -1; } diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 28400887ef..d984dd661c 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -105,7 +105,7 @@ static NTSTATUS cmd_disconnect(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a static NTSTATUS cmd_disk_free(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - SMB_BIG_UINT diskfree, bsize, dfree, dsize; + uint64_t diskfree, bsize, dfree, dsize; if (argc != 2) { printf("Usage: disk_free \n"); return NT_STATUS_OK; @@ -272,7 +272,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c flagstr++; } if ((flags & O_CREAT) && argc == 4) { - if (sscanf(argv[3], "%o", &mode) == 0) { + if (sscanf(argv[3], "%ho", (unsigned short *)&mode) == 0) { printf("open: error=-1 (invalid mode!)\n"); return NT_STATUS_UNSUCCESSFUL; } @@ -989,7 +989,7 @@ static NTSTATUS cmd_mknod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, return NT_STATUS_OK; } - if (sscanf(argv[2], "%o", &mode) == 0) { + if (sscanf(argv[2], "%ho", (unsigned short *)&mode) == 0) { printf("open: error=-1 (invalid mode!)\n"); return NT_STATUS_UNSUCCESSFUL; } diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c index 2ba5ab8f06..b58cb3deec 100644 --- a/source3/torture/locktest.c +++ b/source3/torture/locktest.c @@ -71,7 +71,7 @@ struct record { enum lock_op lock_op; enum brl_type lock_type; char conn, f; - SMB_BIG_UINT start, len; + uint64_t start, len; char needed; }; @@ -303,8 +303,8 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], { unsigned conn = rec->conn; unsigned f = rec->f; - SMB_BIG_UINT start = rec->start; - SMB_BIG_UINT len = rec->len; + uint64_t start = rec->start; + uint64_t len = rec->len; enum brl_type op = rec->lock_type; int server; bool ret[NSERVERS]; diff --git a/source3/torture/torture.c b/source3/torture/torture.c index d8942e42b9..904fb5c262 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -294,15 +294,6 @@ static bool torture_open_connection_share(struct cli_state **c, return True; } -void torture_open_connection_free_unclist(char **unc_list) -{ - if (unc_list!=NULL) - { - SAFE_FREE(unc_list[0]); - SAFE_FREE(unc_list); - } -} - bool torture_open_connection(struct cli_state **c, int conn_index) { char **unc_list = NULL; @@ -311,7 +302,7 @@ bool torture_open_connection(struct cli_state **c, int conn_index) if (use_multishare_conn==True) { char *h, *s; - unc_list = file_lines_load(multishare_conn_fname, &num_unc_names, 0); + unc_list = file_lines_load(multishare_conn_fname, &num_unc_names, 0, NULL); if (!unc_list || num_unc_names <= 0) { printf("Failed to load unc names list from '%s'\n", multishare_conn_fname); exit(1); @@ -321,14 +312,14 @@ bool torture_open_connection(struct cli_state **c, int conn_index) NULL, &h, &s)) { printf("Failed to parse UNC name %s\n", unc_list[conn_index % num_unc_names]); - torture_open_connection_free_unclist(unc_list); + TALLOC_FREE(unc_list); exit(1); } result = torture_open_connection_share(c, h, s); /* h, s were copied earlier */ - torture_open_connection_free_unclist(unc_list); + TALLOC_FREE(unc_list); return result; } @@ -5075,7 +5066,7 @@ static bool run_local_gencache(int dummy) return False; } - blob = data_blob_string_const("bar"); + blob = data_blob_string_const_null("bar"); tm = time(NULL); if (!gencache_set_data_blob("foo", &blob, tm)) { @@ -5649,7 +5640,7 @@ static void usage(void) *p = 0; fstrcpy(share, p+1); - fstrcpy(myname, get_myname(talloc_tos())); + fstrcpy(myname, talloc_get_myname(talloc_tos())); if (!*myname) { fprintf(stderr, "Failed to get my hostname.\n"); return 1; diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c index 56e27eec1d..bb4dc35d2b 100644 --- a/source3/torture/vfstest.c +++ b/source3/torture/vfstest.c @@ -433,7 +433,7 @@ bool reload_services(bool test) if (lp_loaded()) { const char *fname = lp_configfile(); - if (file_exist(fname, NULL) && + if (file_exist(fname) && !strcsequal(fname, get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 7dbe518c3d..4b1aa54731 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -22,6 +22,7 @@ #include "includes.h" #include "utils/net.h" +#include "librpc/gen_ndr/ndr_krb5pac.h" #ifdef HAVE_ADS @@ -43,7 +44,7 @@ static const char *assume_own_realm(struct net_context *c) static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads) { char addr[INET6_ADDRSTRLEN]; - struct nbt_cldap_netlogon_5 reply; + struct NETLOGON_SAM_LOGON_RESPONSE_EX reply; print_sockaddr(addr, sizeof(addr), &ads->ldap.ss); if ( !ads_cldap_netlogon_5(talloc_tos(), addr, ads->server.realm, &reply ) ) { @@ -55,19 +56,19 @@ static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads) addr); d_printf("Response Type: "); - switch (reply.type) { - case SAMLOGON_AD_UNK_R: - d_printf("SAMLOGON\n"); + switch (reply.command) { + case LOGON_SAM_LOGON_USER_UNKNOWN_EX: + d_printf("LOGON_SAM_LOGON_USER_UNKNOWN_EX\n"); break; - case SAMLOGON_AD_R: - d_printf("SAMLOGON_USER\n"); + case LOGON_SAM_LOGON_RESPONSE_EX: + d_printf("LOGON_SAM_LOGON_RESPONSE_EX\n"); break; default: - d_printf("0x%x\n", reply.type); + d_printf("0x%x\n", reply.command); break; } - d_printf("GUID: %s\n", smb_uuid_string(talloc_tos(), reply.domain_uuid)); + d_printf("GUID: %s\n", GUID_string(talloc_tos(), &reply.domain_uuid)); d_printf("Flags:\n" "\tIs a PDC: %s\n" @@ -182,7 +183,8 @@ static int net_ads_info(struct net_context *c, int argc, const char **argv) d_printf("Realm: %s\n", ads->config.realm); d_printf("Bind Path: %s\n", ads->config.bind_path); d_printf("LDAP port: %d\n", ads->ldap.port); - d_printf("Server time: %s\n", http_timestring(ads->config.current_time)); + d_printf("Server time: %s\n", + http_timestring(talloc_tos(), ads->config.current_time)); d_printf("KDC server: %s\n", ads->auth.kdc_server ); d_printf("Server time offset: %d\n", ads->auth.time_offset ); @@ -359,7 +361,7 @@ static int net_ads_workgroup(struct net_context *c, int argc, const char **argv) { ADS_STRUCT *ads; char addr[INET6_ADDRSTRLEN]; - struct nbt_cldap_netlogon_5 reply; + struct NETLOGON_SAM_LOGON_RESPONSE_EX reply; if (c->display_usage) { d_printf("Usage:\n" @@ -479,7 +481,7 @@ static int ads_user_add(struct net_context *c, int argc, const char **argv) asprintf(&upn, "%s@%s", argv[0], ads->config.realm); status = ads_krb5_set_password(ads->auth.kdc_server, upn, argv[1], ads->auth.time_offset); - safe_free(upn); + SAFE_FREE(upn); if (ADS_ERR_OK(status)) { d_printf("User %s added\n", argv[0]); rc = 0; @@ -533,7 +535,7 @@ static int ads_user_info(struct net_context *c, int argc, const char **argv) asprintf(&searchstring, "(sAMAccountName=%s)", escaped_user); rc = ads_search(ads, &res, searchstring, attrs); - safe_free(searchstring); + SAFE_FREE(searchstring); if (!ADS_ERR_OK(rc)) { d_fprintf(stderr, "ads_search: %s\n", ads_errstr(rc)); diff --git a/source3/utils/net_dns.c b/source3/utils/net_dns.c index 14d45e2b0f..4e617a1968 100644 --- a/source3/utils/net_dns.c +++ b/source3/utils/net_dns.c @@ -145,14 +145,14 @@ error: int get_my_ip_address( struct sockaddr_storage **pp_ss ) { - struct iface_struct nics[MAX_INTERFACES]; int i, n; struct sockaddr_storage *list = NULL; int count = 0; - /* find the first non-loopback address from our list of interfaces */ + /* Honor the configured list of interfaces to register */ - n = get_interfaces(nics, MAX_INTERFACES); + load_interfaces(); + n = iface_count(); if (n <= 0) { return -1; @@ -163,19 +163,17 @@ int get_my_ip_address( struct sockaddr_storage **pp_ss ) } for ( i=0; iinfo2.domain_name.string); + d_printf("Domain Name: %s\n", info->general.domain_name.string); d_printf("Domain SID: %s\n", sid_str); d_printf("Sequence number: %llu\n", - (unsigned long long)info->info2.sequence_num); - d_printf("Num users: %u\n", info->info2.num_users); - d_printf("Num domain groups: %u\n", info->info2.num_groups); - d_printf("Num local groups: %u\n", info->info2.num_aliases); + (unsigned long long)info->general.sequence_num); + d_printf("Num users: %u\n", info->general.num_users); + d_printf("Num domain groups: %u\n", info->general.num_groups); + d_printf("Num local groups: %u\n", info->general.num_aliases); } done: @@ -2876,7 +2874,7 @@ static void display_share_info_1(struct net_context *c, if (c->opt_long_list_entries) { d_printf("%-12s %-8.8s %-50s\n", r->shi1_netname, - share_type[r->shi1_type & ~(STYPE_TEMPORARY|STYPE_HIDDEN)], + net_share_type_str(r->shi1_type & ~(STYPE_TEMPORARY|STYPE_HIDDEN)), r->shi1_remark); } else { d_printf("%s\n", r->shi1_netname); @@ -5014,8 +5012,7 @@ NTSTATUS rpc_init_shutdown_internals(struct net_context *c, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; const char *msg = "This machine will be shutdown shortly"; uint32 timeout = 20; - struct initshutdown_String msg_string; - struct initshutdown_String_sub s; + struct lsa_StringLarge msg_string; if (c->opt_comment) { msg = c->opt_comment; @@ -5024,8 +5021,7 @@ NTSTATUS rpc_init_shutdown_internals(struct net_context *c, timeout = c->opt_timeout; } - s.name = msg; - msg_string.name = &s; + msg_string.string = msg; /* create an entry */ result = rpccli_initshutdown_Init(pipe_hnd, mem_ctx, NULL, @@ -5069,16 +5065,14 @@ NTSTATUS rpc_reg_shutdown_internals(struct net_context *c, { const char *msg = "This machine will be shutdown shortly"; uint32 timeout = 20; - struct initshutdown_String msg_string; - struct initshutdown_String_sub s; + struct lsa_StringLarge msg_string; NTSTATUS result; WERROR werr; if (c->opt_comment) { msg = c->opt_comment; } - s.name = msg; - msg_string.name = &s; + msg_string.string = msg; if (c->opt_timeout) { timeout = c->opt_timeout; diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index 5bc38f979f..2fe464a000 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -330,12 +330,8 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) /* Create a random machine account password */ - { - char *str; - str = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); - clear_trust_password = SMB_STRDUP(str); - E_md4hash(clear_trust_password, md4_trust_password); - } + clear_trust_password = generate_random_str(talloc_tos(), DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH); + E_md4hash(clear_trust_password, md4_trust_password); /* Set password on machine account */ @@ -468,7 +464,7 @@ done: cli_shutdown(cli); - SAFE_FREE(clear_trust_password); + TALLOC_FREE(clear_trust_password); return retval; } diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index f4b305d4ab..ddd18a7b9f 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -2482,7 +2482,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, TALLOC_FREE( reg_ctr ); } - safe_free(keylist); + SAFE_FREE(keylist); /* close printer handles here */ if (got_hnd_src) { diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 124af00b57..4a39043768 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -272,7 +272,7 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx, uint32 value_length; char n; - struct winreg_ValNameBuf name_buf; + struct winreg_StringBuf name_buf; WERROR err; n = '\0'; @@ -1186,7 +1186,7 @@ static NTSTATUS rpc_registry_getsd_internal(struct net_context *c, blob.data = sd->data; blob.length = sd->size; - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &sec_desc, + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &sec_desc, (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index d1349a903d..133173116c 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -264,8 +264,9 @@ static NTSTATUS rpc_service_status_internal(struct net_context *c, WERROR result = WERR_GENERAL_FAILURE; NTSTATUS status; SERVICE_STATUS service_status; - SERVICE_CONFIG config; - fstring ascii_string; + struct QUERY_SERVICE_CONFIG config; + uint32_t buf_size = sizeof(config); + uint32_t ret_size = 0; if (argc != 1 ) { d_printf("Usage: net rpc service status \n"); @@ -314,8 +315,23 @@ static NTSTATUS rpc_service_status_internal(struct net_context *c, /* get the config */ - result = rpccli_svcctl_query_config(pipe_hnd, mem_ctx, &hService, &config ); - if ( !W_ERROR_IS_OK(result) ) { + status = rpccli_svcctl_QueryServiceConfigW(pipe_hnd, mem_ctx, + &hService, + &config, + buf_size, + &ret_size, + &result); + if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) { + buf_size = ret_size; + status = rpccli_svcctl_QueryServiceConfigW(pipe_hnd, mem_ctx, + &hService, + &config, + buf_size, + &ret_size, + &result); + } + + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Query config request failed. [%s]\n", dos_errstr(result)); goto done; } @@ -329,29 +345,24 @@ static NTSTATUS rpc_service_status_internal(struct net_context *c, d_printf("\tError Control = 0x%x\n", config.error_control); d_printf("\tTag ID = 0x%x\n", config.tag_id); - if ( config.executablepath ) { - rpcstr_pull( ascii_string, config.executablepath->buffer, sizeof(ascii_string), -1, STR_TERMINATE ); - d_printf("\tExecutable Path = %s\n", ascii_string); + if (config.executablepath) { + d_printf("\tExecutable Path = %s\n", config.executablepath); } - if ( config.loadordergroup ) { - rpcstr_pull( ascii_string, config.loadordergroup->buffer, sizeof(ascii_string), -1, STR_TERMINATE ); - d_printf("\tLoad Order Group = %s\n", ascii_string); + if (config.loadordergroup) { + d_printf("\tLoad Order Group = %s\n", config.loadordergroup); } - if ( config.dependencies ) { - rpcstr_pull( ascii_string, config.dependencies->buffer, sizeof(ascii_string), -1, STR_TERMINATE ); - d_printf("\tDependencies = %s\n", ascii_string); + if (config.dependencies) { + d_printf("\tDependencies = %s\n", config.dependencies); } - if ( config.startname ) { - rpcstr_pull( ascii_string, config.startname->buffer, sizeof(ascii_string), -1, STR_TERMINATE ); - d_printf("\tStart Name = %s\n", ascii_string); + if (config.startname) { + d_printf("\tStart Name = %s\n", config.startname); } - if ( config.displayname ) { - rpcstr_pull( ascii_string, config.displayname->buffer, sizeof(ascii_string), -1, STR_TERMINATE ); - d_printf("\tDisplay Name = %s\n", ascii_string); + if (config.displayname) { + d_printf("\tDisplay Name = %s\n", config.displayname); } done: diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c index 8f263c636c..ce8e82182e 100644 --- a/source3/utils/net_usershare.c +++ b/source3/utils/net_usershare.c @@ -371,7 +371,7 @@ static int info_fn(struct file_list *fl, void *priv) return -1; } - lines = fd_lines_load(fd, &numlines, 10240); + lines = fd_lines_load(fd, &numlines, 10240, NULL); close(fd); if (lines == NULL) { @@ -385,7 +385,7 @@ static int info_fn(struct file_list *fl, void *priv) &psd, &guest_ok); - file_lines_free(lines); + TALLOC_FREE(lines); if (us_err != USERSHARE_OK) { d_fprintf(stderr, "info_fn: file %s is not a well formed usershare file.\n", diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index 88850d29df..fbb3c24b03 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -2,6 +2,7 @@ * Unix SMB/CIFS implementation. * Helper routines for net * Copyright (C) Volker Lendecke 2006 + * Copyright (C) Kai Blin 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 @@ -595,3 +596,14 @@ void net_display_usage_from_functable(struct functable *table) d_printf("%s\n", table[i].usage); } } + +const char *net_share_type_str(int num_type) +{ + switch(num_type) { + case 0: return "Disk"; + case 1: return "Print"; + case 2: return "Dev"; + case 3: return "IPC"; + default: return "Unknown"; + } +} diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index c04b628b1b..45da3f1e88 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -219,7 +219,7 @@ static bool query_one(const char *lookup, unsigned int lookup_type) } } - safe_free(ip_list); + free(ip_list); return (ip_list != NULL); } diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index 4586086d73..0a76761cb2 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -1813,7 +1813,7 @@ static void manage_ntlm_server_1_request(struct ntlm_auth_state *state, if (ntlm_server_1_lm_session_key && (memcmp(zeros, lm_key, sizeof(lm_key)) != 0)) { - hex_lm_key = hex_encode(NULL, + hex_lm_key = hex_encode_talloc(NULL, (const unsigned char *)lm_key, sizeof(lm_key)); x_fprintf(x_stdout, "LANMAN-Session-Key: %s\n", hex_lm_key); @@ -1823,7 +1823,7 @@ static void manage_ntlm_server_1_request(struct ntlm_auth_state *state, if (ntlm_server_1_user_session_key && (memcmp(zeros, user_session_key, sizeof(user_session_key)) != 0)) { - hex_user_session_key = hex_encode(NULL, + hex_user_session_key = hex_encode_talloc(NULL, (const unsigned char *)user_session_key, sizeof(user_session_key)); x_fprintf(x_stdout, "User-Session-Key: %s\n", hex_user_session_key); @@ -2262,7 +2262,7 @@ static bool check_auth_crap(void) if (request_lm_key && (memcmp(zeros, lm_key, sizeof(lm_key)) != 0)) { - hex_lm_key = hex_encode(NULL, (const unsigned char *)lm_key, + hex_lm_key = hex_encode_talloc(NULL, (const unsigned char *)lm_key, sizeof(lm_key)); x_fprintf(x_stdout, "LM_KEY: %s\n", hex_lm_key); TALLOC_FREE(hex_lm_key); @@ -2270,7 +2270,7 @@ static bool check_auth_crap(void) if (request_user_session_key && (memcmp(zeros, user_session_key, sizeof(user_session_key)) != 0)) { - hex_user_session_key = hex_encode(NULL, (const unsigned char *)user_session_key, + hex_user_session_key = hex_encode_talloc(NULL, (const unsigned char *)user_session_key, sizeof(user_session_key)); x_fprintf(x_stdout, "NT_KEY: %s\n", hex_user_session_key); TALLOC_FREE(hex_user_session_key); diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index e1d6709073..6a7189e636 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -235,7 +235,7 @@ static int print_sam_info (struct samu *sam_pwent, bool verbosity, bool smbpwdst uid_t uid; time_t tmp; - /* TODO: chaeck if entry is a user or a workstation */ + /* TODO: check if entry is a user or a workstation */ if (!sam_pwent) return -1; if (verbosity) { @@ -260,25 +260,32 @@ static int print_sam_info (struct samu *sam_pwent, bool verbosity, bool smbpwdst printf ("Munged dial: %s\n", pdb_get_munged_dial(sam_pwent)); tmp = pdb_get_logon_time(sam_pwent); - printf ("Logon time: %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Logon time: %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); tmp = pdb_get_logoff_time(sam_pwent); - printf ("Logoff time: %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Logoff time: %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); tmp = pdb_get_kickoff_time(sam_pwent); - printf ("Kickoff time: %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Kickoff time: %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); tmp = pdb_get_pass_last_set_time(sam_pwent); - printf ("Password last set: %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Password last set: %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); tmp = pdb_get_pass_can_change_time(sam_pwent); - printf ("Password can change: %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Password can change: %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); tmp = pdb_get_pass_must_change_time(sam_pwent); - printf ("Password must change: %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Password must change: %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); tmp = pdb_get_bad_password_time(sam_pwent); - printf ("Last bad password : %s\n", tmp ? http_timestring(tmp) : "0"); + printf ("Last bad password : %s\n", + tmp ? http_timestring(talloc_tos(), tmp) : "0"); printf ("Bad password count : %d\n", pdb_get_bad_password_count(sam_pwent)); diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index 9409690c8b..3ad949a6d3 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -153,7 +153,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) unsigned int aflags = 0; unsigned int amask = 0; DOM_SID sid; - SEC_ACCESS mask; + uint32_t mask; const struct perm_value *v; char *str = SMB_STRDUP(orig_str); TALLOC_CTX *frame = talloc_stackframe(); @@ -401,7 +401,7 @@ static void sort_acl(SEC_ACL *the_acl) static int change_share_sec(TALLOC_CTX *mem_ctx, const char *sharename, char *the_acl, enum acl_mode mode) { - SEC_DESC *sd; + SEC_DESC *sd = NULL; SEC_DESC *old = NULL; size_t sd_size = 0; uint32 i, j; diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index d488ce2187..10b55014c2 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -23,13 +23,13 @@ #include "includes.h" -static int test_args = False; +static int test_args; #define CREATE_ACCESS_READ READ_CONTROL_ACCESS /* numeric is set when the user wants numeric SIDs and ACEs rather than going via LSA calls to resolve them */ -static int numeric = False; +static int numeric; enum acl_mode {SMB_ACL_SET, SMB_ACL_DELETE, SMB_ACL_MODIFY, SMB_ACL_ADD }; enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP}; @@ -179,9 +179,12 @@ static void SidToString(struct cli_state *cli, fstring str, const DOM_SID *sid) return; } - slprintf(str, sizeof(fstring) - 1, "%s%s%s", - domain, lp_winbind_separator(), name); - + if (*domain) { + slprintf(str, sizeof(fstring) - 1, "%s%s%s", + domain, lp_winbind_separator(), name); + } else { + fstrcpy(str, name); + } } /* convert a string to a SID, either numeric or username/group */ @@ -196,6 +199,65 @@ static bool StringToSid(struct cli_state *cli, DOM_SID *sid, const char *str) return NT_STATUS_IS_OK(cli_lsa_lookup_name(cli, str, &type, sid)); } +static void print_ace_flags(FILE *f, uint8_t flags) +{ + char *str = talloc_strdup(NULL, ""); + + if (!str) { + goto out; + } + + if (flags & SEC_ACE_FLAG_OBJECT_INHERIT) { + str = talloc_asprintf(str, "%s%s", + str, "OI|"); + if (!str) { + goto out; + } + } + if (flags & SEC_ACE_FLAG_CONTAINER_INHERIT) { + str = talloc_asprintf(str, "%s%s", + str, "CI|"); + if (!str) { + goto out; + } + } + if (flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) { + str = talloc_asprintf(str, "%s%s", + str, "NP|"); + if (!str) { + goto out; + } + } + if (flags & SEC_ACE_FLAG_INHERIT_ONLY) { + str = talloc_asprintf(str, "%s%s", + str, "IO|"); + if (!str) { + goto out; + } + } + if (flags & SEC_ACE_FLAG_INHERITED_ACE) { + str = talloc_asprintf(str, "%s%s", + str, "I|"); + if (!str) { + goto out; + } + } + /* Ignore define SEC_ACE_FLAG_SUCCESSFUL_ACCESS ( 0x40 ) + and SEC_ACE_FLAG_FAILED_ACCESS ( 0x80 ) as they're + audit ace flags. */ + + if (str[strlen(str)-1] == '|') { + str[strlen(str)-1] = '\0'; + fprintf(f, "/%s/", str); + } else { + fprintf(f, "/0x%x/", flags); + } + TALLOC_FREE(str); + return; + + out: + fprintf(f, "/0x%x/", flags); +} /* print an ACE on a FILE, using either numeric or ascii representation */ static void print_ace(struct cli_state *cli, FILE *f, SEC_ACE *ace) @@ -210,7 +272,7 @@ static void print_ace(struct cli_state *cli, FILE *f, SEC_ACE *ace) fprintf(f, "%s:", sidstr); if (numeric) { - fprintf(f, "%d/%d/0x%08x", + fprintf(f, "%d/0x%x/0x%08x", ace->type, ace->flags, ace->access_mask); return; } @@ -225,9 +287,7 @@ static void print_ace(struct cli_state *cli, FILE *f, SEC_ACE *ace) fprintf(f, "%d", ace->type); } - /* Not sure what flags can be set in a file ACL */ - - fprintf(f, "/%d/", ace->flags); + print_ace_flags(f, ace->flags); /* Standard permissions */ @@ -263,6 +323,37 @@ static void print_ace(struct cli_state *cli, FILE *f, SEC_ACE *ace) } } +static bool parse_ace_flags(const char *str, unsigned int *pflags) +{ + const char *p = str; + *pflags = 0; + + while (*p) { + if (strnequal(p, "OI", 2)) { + *pflags |= SEC_ACE_FLAG_OBJECT_INHERIT; + p += 2; + } else if (strnequal(p, "CI", 2)) { + *pflags |= SEC_ACE_FLAG_CONTAINER_INHERIT; + p += 2; + } else if (strnequal(p, "NP", 2)) { + *pflags |= SEC_ACE_FLAG_NO_PROPAGATE_INHERIT; + p += 2; + } else if (strnequal(p, "IO", 2)) { + *pflags |= SEC_ACE_FLAG_INHERIT_ONLY; + p += 2; + } else if (*p == 'I') { + *pflags |= SEC_ACE_FLAG_INHERITED_ACE; + p += 1; + } else if (*p) { + return false; + } + + if (*p != '|' && *p != '\0') { + return false; + } + } + return true; +} /* parse an ACE in the same format as print_ace() */ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, @@ -275,7 +366,7 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, unsigned int aflags = 0; unsigned int amask = 0; DOM_SID sid; - SEC_ACCESS mask; + uint32_t mask; const struct perm_value *v; char *str = SMB_STRDUP(orig_str); TALLOC_CTX *frame = talloc_stackframe(); @@ -335,15 +426,40 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, /* Only numeric form accepted for flags at present */ - if (!(next_token_talloc(frame, &cp, &tok, "/") && - sscanf(tok, "%i", &aflags))) { - printf("ACE '%s': bad integer flags entry at '%s'\n", + if (!next_token_talloc(frame, &cp, &tok, "/")) { + printf("ACE '%s': bad flags entry at '%s'\n", orig_str, tok); SAFE_FREE(str); TALLOC_FREE(frame); return False; } + if (tok[0] < '0' || tok[0] > '9') { + if (!parse_ace_flags(tok, &aflags)) { + printf("ACE '%s': bad named flags entry at '%s'\n", + orig_str, tok); + SAFE_FREE(str); + TALLOC_FREE(frame); + return False; + } + } else if (strnequal(tok, "0x", 2)) { + if (!sscanf(tok, "%x", &aflags)) { + printf("ACE '%s': bad hex flags entry at '%s'\n", + orig_str, tok); + SAFE_FREE(str); + TALLOC_FREE(frame); + return False; + } + } else { + if (!sscanf(tok, "%i", &aflags)) { + printf("ACE '%s': bad integer flags entry at '%s'\n", + orig_str, tok); + SAFE_FREE(str); + TALLOC_FREE(frame); + return False; + } + } + if (!next_token_talloc(frame, &cp, &tok, "/")) { printf("ACE '%s': missing / at '%s'\n", orig_str, tok); @@ -506,6 +622,7 @@ static void sec_desc_print(struct cli_state *cli, FILE *f, SEC_DESC *sd) uint32 i; fprintf(f, "REVISION:%d\n", sd->revision); + fprintf(f, "CONTROL:0x%x\n", sd->type); /* Print owner and group sid */ @@ -626,29 +743,42 @@ static int owner_set(struct cli_state *cli, enum chown_mode change_mode, } -/* The MSDN is contradictory over the ordering of ACE entries in an ACL. - However NT4 gives a "The information may have been modified by a - computer running Windows NT 5.0" if denied ACEs do not appear before - allowed ACEs. */ +/* The MSDN is contradictory over the ordering of ACE entries in an + ACL. However NT4 gives a "The information may have been modified + by a computer running Windows NT 5.0" if denied ACEs do not appear + before allowed ACEs. At + http://technet.microsoft.com/en-us/library/cc781716.aspx the + canonical order is specified as "Explicit Deny, Explicit Allow, + Inherited ACEs unchanged" */ static int ace_compare(SEC_ACE *ace1, SEC_ACE *ace2) { - if (sec_ace_equal(ace1, ace2)) + if (sec_ace_equal(ace1, ace2)) return 0; - if (ace1->type != ace2->type) + if ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) && + !(ace2->flags & SEC_ACE_FLAG_INHERITED_ACE)) + return 1; + if (!(ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) && + (ace2->flags & SEC_ACE_FLAG_INHERITED_ACE)) + return -1; + if ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) && + (ace2->flags & SEC_ACE_FLAG_INHERITED_ACE)) + return ace1 - ace2; + + if (ace1->type != ace2->type) return ace2->type - ace1->type; - if (sid_compare(&ace1->trustee, &ace2->trustee)) + if (sid_compare(&ace1->trustee, &ace2->trustee)) return sid_compare(&ace1->trustee, &ace2->trustee); - if (ace1->flags != ace2->flags) + if (ace1->flags != ace2->flags) return ace1->flags - ace2->flags; - if (ace1->access_mask != ace2->access_mask) + if (ace1->access_mask != ace2->access_mask) return ace1->access_mask - ace2->access_mask; - if (ace1->size != ace2->size) + if (ace1->size != ace2->size) return ace1->size - ace2->size; return memcmp(ace1, ace2, sizeof(SEC_ACE)); @@ -677,6 +807,7 @@ static void sort_acl(SEC_ACL *the_acl) /***************************************************** set the ACLs on a file given an ascii description *******************************************************/ + static int cacl_set(struct cli_state *cli, char *filename, char *the_acl, enum acl_mode mode) { @@ -730,7 +861,7 @@ static int cacl_set(struct cli_state *cli, char *filename, } if (!found) { - printf("ACL for ACE:"); + printf("ACL for ACE:"); print_ace(cli, stdout, &sd->dacl->aces[i]); printf(" not found\n"); } @@ -762,7 +893,7 @@ static int cacl_set(struct cli_state *cli, char *filename, old->owner_sid = sd->owner_sid; } - if (sd->group_sid) { + if (sd->group_sid) { old->group_sid = sd->group_sid; } @@ -895,8 +1026,8 @@ static struct cli_state *connect_one(const char *server, const char *share) { "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" }, { "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" }, { "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" }, - { "numeric", 0, POPT_ARG_NONE, &numeric, True, "Don't resolve sids or masks to names" }, - { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"}, + { "numeric", 0, POPT_ARG_NONE, &numeric, 1, "Don't resolve sids or masks to names" }, + { "test-args", 't', POPT_ARG_NONE, &test_args, 1, "Test arguments"}, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index 11f8776a0e..b769c2bce0 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -180,11 +180,7 @@ static int parse_quota_set(TALLOC_CTX *ctx, switch (todo) { case PARSE_LIM: -#if defined(HAVE_LONGLONG) - if (sscanf(p,"%llu/%llu",&pqt->softlim,&pqt->hardlim)!=2) { -#else - if (sscanf(p,"%lu/%lu",&pqt->softlim,&pqt->hardlim)!=2) { -#endif + if (sscanf(p,"%"PRIu64"/%"PRIu64,&pqt->softlim,&pqt->hardlim)!=2) { return -1; } diff --git a/source3/utils/status_profile.c b/source3/utils/status_profile.c index 48814fedea..a51537d3da 100644 --- a/source3/utils/status_profile.c +++ b/source3/utils/status_profile.c @@ -423,12 +423,12 @@ bool status_profile_dump(bool verbose) static int print_count_samples( const struct profile_stats * const current, const struct profile_stats * const last, - SMB_BIG_UINT delta_usec) + uint64_t delta_usec) { int i; int count = 0; unsigned step; - SMB_BIG_UINT spent; + uint64_t spent; int delta_sec; const char * name; char buf[40]; @@ -467,13 +467,13 @@ static int print_count_samples( } static struct profile_stats sample_data[2]; -static SMB_BIG_UINT sample_time[2]; +static uint64_t sample_time[2]; bool status_profile_rates(bool verbose) { - SMB_BIG_UINT remain_usec; - SMB_BIG_UINT next_usec; - SMB_BIG_UINT delta_usec; + uint64_t remain_usec; + uint64_t next_usec; + uint64_t delta_usec; int last = 0; int current = 1; diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 527db2d805..da129cf7c0 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -56,7 +56,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); ret = 1; } - if (!directory_exist(lp_lockdir(), &st)) { + if (!directory_exist_stat(lp_lockdir(), &st)) { fprintf(stderr, "ERROR: lock directory %s does not exist\n", lp_lockdir()); ret = 1; @@ -66,7 +66,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); ret = 1; } - if (!directory_exist(lp_piddir(), &st)) { + if (!directory_exist_stat(lp_piddir(), &st)) { fprintf(stderr, "ERROR: pid directory %s does not exist\n", lp_piddir()); ret = 1; @@ -329,9 +329,12 @@ rameter is ignored when using CUPS libraries.\n", cname = poptGetArg(pc); caddr = poptGetArg(pc); + poptFreeContext(pc); + if ( cname && ! caddr ) { printf ( "ERROR: You must specify both a machine name and an IP address.\n" ); - return(1); + ret = 1; + goto done; } if (new_local_machine) { @@ -346,7 +349,8 @@ rameter is ignored when using CUPS libraries.\n", if (!lp_load_with_registry_shares(config_file,False,True,False,True)) { fprintf(stderr,"Error loading services.\n"); - return(1); + ret = 1; + goto done; } fprintf(stderr,"Loaded services file OK.\n"); @@ -393,13 +397,15 @@ rameter is ignored when using CUPS libraries.\n", (s=lp_servicenumber(section_name)) == -1) { fprintf(stderr,"Unknown section %s\n", section_name); - return(1); + ret = 1; + goto done; } if (parameter_name) { if (!dump_a_parameter( s, parameter_name, stdout, isGlobal)) { fprintf(stderr,"Parameter %s unknown for section %s\n", parameter_name, section_name); - return(1); + ret = 1; + goto done; } } else { if (isGlobal == True) @@ -407,7 +413,7 @@ rameter is ignored when using CUPS libraries.\n", else lp_dump_one(stdout, show_defaults, s); } - return(ret); + goto done; } lp_dump(stdout, show_defaults, lp_numservices()); @@ -428,7 +434,10 @@ rameter is ignored when using CUPS libraries.\n", } } } + +done: + gfree_loadparm(); TALLOC_FREE(frame); - return(ret); + return ret; } diff --git a/source3/web/cgi.c b/source3/web/cgi.c index 070e80cf91..ce36bd9310 100644 --- a/source3/web/cgi.c +++ b/source3/web/cgi.c @@ -451,7 +451,7 @@ static void cgi_download(char *file) if (S_ISDIR(st.st_mode)) { snprintf(buf, sizeof(buf), "%s/index.html", file); - if (!file_exist(buf, &st) || !S_ISREG(st.st_mode)) + if (!file_exist_stat(buf, &st) || !S_ISREG(st.st_mode)) { cgi_setup_error("404 File Not Found","", "The requested file was not found"); @@ -488,7 +488,8 @@ static void cgi_download(char *file) printf("Content-Type: text/html\r\n"); } } - printf("Expires: %s\r\n", http_timestring(time(NULL)+EXPIRY_TIME)); + printf("Expires: %s\r\n", + http_timestring(talloc_tos(), time(NULL)+EXPIRY_TIME)); lang = lang_tdb_current(); if (lang) { @@ -604,7 +605,7 @@ void cgi_setup(const char *rootdir, int auth_required) } printf("HTTP/1.0 200 OK\r\nConnection: close\r\n"); - printf("Date: %s\r\n", http_timestring(time(NULL))); + printf("Date: %s\r\n", http_timestring(talloc_tos(), time(NULL))); baseurl = ""; pathinfo = url+1; } diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index ce24c7cddd..e684a075c2 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -43,9 +43,10 @@ static void initPid2Machine (void) { /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { - PIDMAP *p; + PIDMAP *p, *next; - for (p = pidmap; p != NULL; ) { + for (p = pidmap; p != NULL; p = next) { + next = p->next; DLIST_REMOVE(pidmap, p); SAFE_FREE(p->machine); SAFE_FREE(p); diff --git a/source3/web/swat.c b/source3/web/swat.c index 1502c5bc2f..27c4b54e2f 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -384,7 +384,8 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte break; case P_LIST: - if (!str_list_compare(*(char ***)ptr, (char **)(parm->def.lvalue))) continue; + if (!str_list_equal(*(const char ***)ptr, + (const char **)(parm->def.lvalue))) continue; break; case P_STRING: @@ -595,7 +596,7 @@ static void ViewModeBoxes(int mode) ****************************************************************************/ static void welcome_page(void) { - if (file_exist("help/welcome.html", NULL)) { + if (file_exist("help/welcome.html")) { include_html("help/welcome.html"); } else { include_html("help/welcome-no-samba-doc.html"); @@ -1439,7 +1440,7 @@ const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid) cgi_load_variables(); - if (!file_exist(get_dyn_CONFIGFILE(), NULL)) { + if (!file_exist(get_dyn_CONFIGFILE())) { have_read_access = True; have_write_access = True; } else { diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c index 9fefb1bba7..60a2d8642a 100644 --- a/source3/winbindd/idmap_ad.c +++ b/source3/winbindd/idmap_ad.c @@ -517,6 +517,8 @@ again: bidx = idx; for (i = 0; (i < IDMAP_AD_MAX_IDS) && ids[idx]; i++, idx++) { + ids[idx]->status = ID_UNKNOWN; + sidstr = sid_binstring(ids[idx]->sid); filter = talloc_asprintf_append_buffer(filter, "(objectSid=%s)", sidstr); @@ -732,6 +734,16 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e, uint32 *gid ) { ADS_STRUCT *ads_internal = NULL; + const char *attrs[] = {NULL, /* attr_homedir */ + NULL, /* attr_shell */ + NULL, /* attr_gecos */ + NULL, /* attr_gidnumber */ + NULL }; + char *filter = NULL; + LDAPMessage *msg_internal = NULL; + ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *sidstr = NULL; /* Only do query if we are online */ if (idmap_is_offline()) { @@ -743,24 +755,224 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e, ads_internal = ad_idmap_cached_connection(); - if ( !ads_internal || !ad_schema ) + if ( !ads_internal || !ad_schema ) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - if ( !homedir || !shell || !gecos ) + } + + if (!sid || !homedir || !shell || !gecos) { return NT_STATUS_INVALID_PARAMETER; + } + + /* See if we can use the ADS connection struct swe were given */ - *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr ); - *shell = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr ); - *gecos = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr ); - - if ( gid ) { - if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) ) - *gid = (uint32)-1; + if (ads) { + *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr ); + *shell = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr ); + *gecos = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr ); + + if (gid) { + if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) ) + *gid = (uint32)-1; + } + + nt_status = NT_STATUS_OK; + goto done; } - - return NT_STATUS_OK; + + /* Have to do our own query */ + + attrs[0] = ad_schema->posix_homedir_attr; + attrs[1] = ad_schema->posix_shell_attr; + attrs[2] = ad_schema->posix_gecos_attr; + attrs[3] = ad_schema->posix_gidnumber_attr; + + sidstr = sid_binstring(sid); + filter = talloc_asprintf(ctx, "(objectSid=%s)", sidstr); + SAFE_FREE(sidstr); + + if (!filter) { + nt_status = NT_STATUS_NO_MEMORY; + goto done; + } + + ads_status = ads_search_retry(ads_internal, &msg_internal, filter, attrs); + if (!ADS_ERR_OK(ads_status)) { + nt_status = ads_ntstatus(ads_status); + goto done; + } + + *homedir = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_homedir_attr); + *shell = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_shell_attr); + *gecos = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_gecos_attr); + + if (gid) { + if (!ads_pull_uint32(ads_internal, msg_internal, ad_schema->posix_gidnumber_attr, gid)) + *gid = (uint32)-1; + } + + nt_status = NT_STATUS_OK; + +done: + if (msg_internal) { + ads_msgfree(ads_internal, msg_internal); + } + + return nt_status; } +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_ad_map_to_alias(TALLOC_CTX *mem_ctx, + const char *domain, + const char *name, + char **alias) +{ + ADS_STRUCT *ads_internal = NULL; + const char *attrs[] = {NULL, /* attr_uid */ + NULL }; + char *filter = NULL; + LDAPMessage *msg = NULL; + ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + + /* Check incoming parameters */ + + if ( !domain || !name || !*alias) { + nt_status = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + /* Only do query if we are online */ + + if (idmap_is_offline()) { + nt_status = NT_STATUS_FILE_IS_OFFLINE; + goto done; + } + + ads_internal = ad_idmap_cached_connection(); + + if (!ads_internal || !ad_schema) { + nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND; + goto done; + } + + attrs[0] = ad_schema->posix_uid_attr; + + filter = talloc_asprintf(mem_ctx, + "(sAMAccountName=%s)", + name); + if (!filter) { + nt_status = NT_STATUS_NO_MEMORY; + goto done; + } + + ads_status = ads_search_retry(ads_internal, &msg, filter, attrs); + if (!ADS_ERR_OK(ads_status)) { + nt_status = ads_ntstatus(ads_status); + goto done; + } + + *alias = ads_pull_string(ads_internal, mem_ctx, msg, ad_schema->posix_uid_attr ); + + if (!*alias) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + nt_status = NT_STATUS_OK; + +done: + if (filter) { + talloc_destroy(filter); + } + if (msg) { + ads_msgfree(ads_internal, msg); + } + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_ad_map_from_alias( TALLOC_CTX *mem_ctx, + const char *domain, + const char *alias, + char **name ) +{ + ADS_STRUCT *ads_internal = NULL; + const char *attrs[] = {"sAMAccountName", + NULL }; + char *filter = NULL; + LDAPMessage *msg = NULL; + ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *username; + + /* Check incoming parameters */ + + if ( !alias || !name) { + nt_status = NT_STATUS_INVALID_PARAMETER; + goto done; + } + + /* Only do query if we are online */ + + if (idmap_is_offline()) { + nt_status = NT_STATUS_FILE_IS_OFFLINE; + goto done; + } + + ads_internal = ad_idmap_cached_connection(); + + if (!ads_internal || !ad_schema) { + nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND; + goto done; + } + + filter = talloc_asprintf(mem_ctx, + "(%s=%s)", + ad_schema->posix_uid_attr, + alias); + if (!filter) { + nt_status = NT_STATUS_NO_MEMORY; + goto done; + } + + ads_status = ads_search_retry(ads_internal, &msg, filter, attrs); + if (!ADS_ERR_OK(ads_status)) { + nt_status = ads_ntstatus(ads_status); + goto done; + } + + username = ads_pull_string(ads_internal, mem_ctx, msg, + "sAMAccountName"); + if (!username) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + *name = talloc_asprintf(mem_ctx, "%s\\%s", + lp_workgroup(), + username); + if (!*name) { + nt_status = NT_STATUS_NO_MEMORY; + goto done; + } + + nt_status = NT_STATUS_OK; + +done: + if (filter) { + talloc_destroy(filter); + } + if (msg) { + ads_msgfree(ads_internal, msg); + } + + return nt_status; +} + + /************************************************************************ ***********************************************************************/ @@ -786,21 +998,27 @@ static struct idmap_methods ad_methods = { function which sets the intended schema model to use */ static struct nss_info_methods nss_rfc2307_methods = { - .init = nss_rfc2307_init, - .get_nss_info = nss_ad_get_info, - .close_fn = nss_ad_close + .init = nss_rfc2307_init, + .get_nss_info = nss_ad_get_info, + .map_to_alias = nss_ad_map_to_alias, + .map_from_alias = nss_ad_map_from_alias, + .close_fn = nss_ad_close }; static struct nss_info_methods nss_sfu_methods = { - .init = nss_sfu_init, - .get_nss_info = nss_ad_get_info, - .close_fn = nss_ad_close + .init = nss_sfu_init, + .get_nss_info = nss_ad_get_info, + .map_to_alias = nss_ad_map_to_alias, + .map_from_alias = nss_ad_map_from_alias, + .close_fn = nss_ad_close }; static struct nss_info_methods nss_sfu20_methods = { - .init = nss_sfu20_init, - .get_nss_info = nss_ad_get_info, - .close_fn = nss_ad_close + .init = nss_sfu20_init, + .get_nss_info = nss_ad_get_info, + .map_to_alias = nss_ad_map_to_alias, + .map_from_alias = nss_ad_map_from_alias, + .close_fn = nss_ad_close }; diff --git a/source3/winbindd/idmap_adex/cell_util.c b/source3/winbindd/idmap_adex/cell_util.c new file mode 100644 index 0000000000..f5c08a0454 --- /dev/null +++ b/source3/winbindd/idmap_adex/cell_util.c @@ -0,0 +1,292 @@ +/* + * idmap_adex: Support for AD Forests + * + * Copyright (C) Gerald (Jerry) Carter 2006-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 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" +#include "idmap_adex.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +/********************************************************************** +**********************************************************************/ + + char *find_attr_string(char **list, size_t num_lines, const char *substr) +{ + int i; + int cmplen = strlen(substr); + + for (i = 0; i < num_lines; i++) { + /* make sure to avoid substring matches like uid + and uidNumber */ + if ((StrnCaseCmp(list[i], substr, cmplen) == 0) && + (list[i][cmplen] == '=')) { + /* Don't return an empty string */ + if (list[i][cmplen + 1] != '\0') + return &(list[i][cmplen + 1]); + + return NULL; + } + } + + return NULL; +} + +/********************************************************************** +**********************************************************************/ + + bool is_object_class(char **list, size_t num_lines, const char *substr) +{ + int i; + + for (i = 0; i < num_lines; i++) { + if (strequal(list[i], substr)) { + return true; + } + } + + return false; +} + +/********************************************************************** + Find out about the cell (e.g. use2307Attrs, etc...) +**********************************************************************/ + + NTSTATUS cell_lookup_settings(struct likewise_cell * cell) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + + /* Parameter check */ + + if (!cell) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Only supporting Forest-wide, schema based searches */ + + cell_set_flags(cell, LWCELL_FLAG_USE_RFC2307_ATTRS); + cell_set_flags(cell, LWCELL_FLAG_SEARCH_FOREST); + + cell->provider = &ccp_unified; + + nt_status = NT_STATUS_OK; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(1,("LWI: Failed to obtain cell settings (%s)\n", + nt_errstr(nt_status))); + } + + return nt_status; +} + + +static NTSTATUS cell_lookup_forest(struct likewise_cell *c) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct gc_info *gc = NULL; + + if (!c) { + return NT_STATUS_INVALID_PARAMETER; + } + + if ((gc = TALLOC_ZERO_P(NULL, struct gc_info)) == NULL) { + nt_status = NT_STATUS_NO_MEMORY; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Query the rootDSE for the forest root naming conect first. + Check that the a GC server for the forest has not already + been added */ + + nt_status = gc_find_forest_root(gc, cell_dns_domain(c)); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + c->forest_name = talloc_strdup(c, gc->forest_name); + BAIL_ON_PTR_ERROR(c->forest_name, nt_status); + +done: + if (gc) { + talloc_free(gc); + } + + return nt_status; +} + +/********************************************************************** +**********************************************************************/ + + NTSTATUS cell_locate_membership(ADS_STRUCT * ads) +{ + ADS_STATUS status; + char *domain_dn = ads_build_dn(lp_realm()); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + DOM_SID sid; + struct likewise_cell *cell = NULL; + + /* In the Likewise plugin, I had to support the concept of cells + based on the machine's membership in an OU. However, now I'll + just assume our membership in the forest cell */ + + DEBUG(2, ("locate_cell_membership: Located membership " + "in cell \"%s\"\n", domain_dn)); + + if ((cell = cell_new()) == NULL) { + nt_status = NT_STATUS_NO_MEMORY; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + status = ads_domain_sid(ads, &sid); + if (!ADS_ERR_OK(status)) { + DEBUG(3,("locate_cell_membership: Failed to find " + "domain SID for %s\n", domain_dn)); + } + + /* save the SID and search base for our domain */ + + cell_set_dns_domain(cell, lp_realm()); + cell_set_connection(cell, ads); + cell_set_dn(cell, domain_dn); + cell_set_domain_sid(cell, &sid); + + /* Now save our forest root */ + + cell_lookup_forest(cell); + + /* Add the cell to the list */ + + if (!cell_list_add(cell)) { + nt_status = NT_STATUS_INSUFFICIENT_RESOURCES; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Done! */ + nt_status = NT_STATUS_OK; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(0,("LWI: Failed to locate cell membership (%s)\n", + nt_errstr(nt_status))); + } + + SAFE_FREE(domain_dn); + + return nt_status; +} + +/********************************************************************* + ********************************************************************/ + + int min_id_value(void) +{ + int id_val; + + id_val = lp_parm_int(-1, "lwidentity", "min_id_value", MIN_ID_VALUE); + + /* Still don't let it go below 50 */ + + return MAX(50, id_val); +} + +/******************************************************************** + *******************************************************************/ + + char *cell_dn_to_dns(const char *dn) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *domain = NULL; + char *dns_name = NULL; + const char *tmp_dn; + char *buffer = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!dn || !*dn) { + goto done; + } + + tmp_dn = talloc_strdup(frame, dn); + BAIL_ON_PTR_ERROR(tmp_dn, nt_status); + + while (next_token_talloc(frame, &tmp_dn, &buffer, ",")) { + + /* skip everything up the where DC=... begins */ + if (StrnCaseCmp(buffer, "DC=", 3) != 0) + continue; + + if (!domain) { + domain = talloc_strdup(frame, &buffer[3]); + } else { + domain = talloc_asprintf_append(domain, ".%s", + &buffer[3]); + } + BAIL_ON_PTR_ERROR(domain, nt_status); + } + + dns_name = SMB_STRDUP(domain); + BAIL_ON_PTR_ERROR(dns_name, nt_status); + + nt_status = NT_STATUS_OK; + +done: + PRINT_NTSTATUS_ERROR(nt_status, "cell_dn_to_dns", 1); + + talloc_destroy(frame); + + return dns_name; +} + +/********************************************************************* + ********************************************************************/ + + NTSTATUS get_sid_type(ADS_STRUCT *ads, + LDAPMessage *msg, + enum lsa_SidType *type) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + uint32_t atype; + + if (!ads_pull_uint32(ads, msg, "sAMAccountType", &atype)) { + nt_status = NT_STATUS_INVALID_USER_BUFFER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + switch (atype &0xF0000000) { + case ATYPE_SECURITY_GLOBAL_GROUP: + *type = SID_NAME_DOM_GRP; + break; + case ATYPE_SECURITY_LOCAL_GROUP: + *type = SID_NAME_ALIAS; + break; + case ATYPE_NORMAL_ACCOUNT: + case ATYPE_WORKSTATION_TRUST: + case ATYPE_INTERDOMAIN_TRUST: + *type = SID_NAME_USER; + break; + default: + *type = SID_NAME_USE_NONE; + nt_status = NT_STATUS_INVALID_ACCOUNT_NAME; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = NT_STATUS_OK; + +done: + return nt_status; +} diff --git a/source3/winbindd/idmap_adex/domain_util.c b/source3/winbindd/idmap_adex/domain_util.c new file mode 100644 index 0000000000..6851503cc8 --- /dev/null +++ b/source3/winbindd/idmap_adex/domain_util.c @@ -0,0 +1,286 @@ +/* + * idmap_adex: Domain search interface + * + * Copyright (C) Gerald (Jerry) Carter 2007-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 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" +#include "idmap_adex.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +struct dc_info { + struct dc_info *prev, *next; + char *dns_name; + struct likewise_cell *domain_cell; +}; + +static struct dc_info *_dc_server_list = NULL; + + +/********************************************************************** + *********************************************************************/ + +static struct dc_info *dc_list_head(void) +{ + return _dc_server_list; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS dc_add_domain(const char *domain) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct dc_info *dc = NULL; + + if (!domain) { + return NT_STATUS_INVALID_PARAMETER; + } + + DEBUG(10,("dc_add_domain: Attempting to add domain %s\n", domain)); + + /* Check for duplicates */ + + dc = dc_list_head(); + while (dc) { + if (strequal (dc->dns_name, domain)) + break; + dc = dc->next; + } + + if (dc) { + DEBUG(10,("dc_add_domain: %s already in list\n", domain)); + return NT_STATUS_OK; + } + + dc = TALLOC_ZERO_P(NULL, struct dc_info); + BAIL_ON_PTR_ERROR(dc, nt_status); + + dc->dns_name = talloc_strdup(dc, domain); + BAIL_ON_PTR_ERROR(dc->dns_name, nt_status); + + DLIST_ADD_END(_dc_server_list, dc, struct dc_info*); + + nt_status = NT_STATUS_OK; + + DEBUG(5,("dc_add_domain: Successfully added %s\n", domain)); + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + talloc_destroy(dc); + DEBUG(0,("LWI: Failed to add new DC connection for %s (%s)\n", + domain, nt_errstr(nt_status))); + } + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static void dc_server_list_destroy(void) +{ + struct dc_info *dc = dc_list_head(); + + while (dc) { + struct dc_info *p = dc->next; + + cell_destroy(dc->domain_cell); + talloc_destroy(dc); + + dc = p; + } + + return; +} + + +/********************************************************************** + *********************************************************************/ + + NTSTATUS domain_init_list(void) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct winbindd_tdc_domain *domains = NULL; + size_t num_domains = 0; + int i; + + if (_dc_server_list != NULL) { + dc_server_list_destroy(); + } + + /* Add our domain */ + + nt_status = dc_add_domain(lp_realm()); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (!wcache_tdc_fetch_list(&domains, &num_domains)) { + nt_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Add all domains with an incoming trust path */ + + for (i=0; idomain_cell, search_base, + scope, expr, attrs, msg); + nt_status = ads_ntstatus(status); + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static struct dc_info *dc_find_domain(const char *dns_domain) +{ + struct dc_info *dc = dc_list_head(); + + if (!dc) + return NULL; + + while (dc) { + if (strequal(dc->dns_name, dns_domain)) { + return dc; + } + + dc = dc->next; + } + + return NULL; +} + +/********************************************************************** + *********************************************************************/ + + NTSTATUS dc_search_domains(struct likewise_cell **cell, + LDAPMessage **msg, + const char *dn, + const DOM_SID *sid) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + TALLOC_CTX *frame = talloc_stackframe(); + char *dns_domain; + const char *attrs[] = { "*", NULL }; + struct dc_info *dc = NULL; + const char *base = NULL; + + if (!dn || !*dn) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + dns_domain = cell_dn_to_dns(dn); + BAIL_ON_PTR_ERROR(dns_domain, nt_status); + + if ((dc = dc_find_domain(dns_domain)) == NULL) { + nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Reparse the cell settings for the domain if necessary */ + + if (!dc->domain_cell) { + char *base_dn; + + base_dn = ads_build_dn(dc->dns_name); + BAIL_ON_PTR_ERROR(base_dn, nt_status); + + nt_status = cell_connect_dn(&dc->domain_cell, base_dn); + SAFE_FREE(base_dn); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = cell_lookup_settings(dc->domain_cell); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* By definition this is already part of a larger + forest-wide search scope */ + + cell_set_flags(dc->domain_cell, LWCELL_FLAG_SEARCH_FOREST); + } + + /* Check whether we are operating in non-schema or RFC2307 + mode */ + + if (cell_flags(dc->domain_cell) & LWCELL_FLAG_USE_RFC2307_ATTRS) { + nt_status = dc_do_search(dc, dn, LDAP_SCOPE_BASE, + "(objectclass=*)", attrs, msg); + } else { + const char *sid_str = NULL; + char *filter = NULL; + + sid_str = sid_string_talloc(frame, sid); + BAIL_ON_PTR_ERROR(sid_str, nt_status); + + filter = talloc_asprintf(frame, "(keywords=backLink=%s)", + sid_str); + BAIL_ON_PTR_ERROR(filter, nt_status); + + base = cell_search_base(dc->domain_cell); + BAIL_ON_PTR_ERROR(base, nt_status); + + nt_status = dc_do_search(dc, base, LDAP_SCOPE_SUBTREE, + filter, attrs, msg); + } + BAIL_ON_NTSTATUS_ERROR(nt_status); + + *cell = dc->domain_cell; + +done: + talloc_destroy(CONST_DISCARD(char*, base)); + talloc_destroy(frame); + + return nt_status; +} diff --git a/source3/winbindd/idmap_adex/gc_util.c b/source3/winbindd/idmap_adex/gc_util.c new file mode 100644 index 0000000000..6dc02336d5 --- /dev/null +++ b/source3/winbindd/idmap_adex/gc_util.c @@ -0,0 +1,848 @@ +/* + * idmap_adex: Global Catalog search interface + * + * Copyright (C) Gerald (Jerry) Carter 2007-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 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" +#include "idmap_adex.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +static struct gc_info *_gc_server_list = NULL; + + +/********************************************************************** + *********************************************************************/ + +static struct gc_info *gc_list_head(void) +{ + return _gc_server_list; +} + +/********************************************************************** + Checks if either of the domains is a subdomain of the other + *********************************************************************/ + +static bool is_subdomain(const char* a, const char *b) +{ + char *s; + TALLOC_CTX *frame = talloc_stackframe(); + char *x, *y; + bool ret = false; + + /* Trivial cases */ + + if (!a && !b) + return true; + + if (!a || !b) + return false; + + /* Normalize the case */ + + x = talloc_strdup(frame, a); + y = talloc_strdup(frame, b); + if (!x || !y) { + ret = false; + goto done; + } + + strupper_m(x); + strupper_m(y); + + /* Exact match */ + + if (strcmp(x, y) == 0) { + ret = true; + goto done; + } + + /* Check for trailing substrings */ + + s = strstr_m(x, y); + if (s && (strlen(s) == strlen(y))) { + ret = true; + goto done; + } + + s = strstr_m(y, x); + if (s && (strlen(s) == strlen(x))) { + ret = true; + goto done; + } + +done: + talloc_destroy(frame); + + return ret; +} + +/********************************************************************** + *********************************************************************/ + + NTSTATUS gc_find_forest_root(struct gc_info *gc, const char *domain) +{ + ADS_STRUCT *ads = NULL; + ADS_STATUS ads_status; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!gc || !domain) { + return NT_STATUS_INVALID_PARAMETER; + } + + ZERO_STRUCT(cldap_reply); + + ads = ads_init(domain, NULL, NULL); + BAIL_ON_PTR_ERROR(ads, nt_status); + + ads->auth.flags = ADS_AUTH_NO_BIND; + ads_status = ads_connect(ads); + if (!ADS_ERR_OK(ads_status)) { + DEBUG(4, ("find_forest_root: ads_connect(%s) failed! (%s)\n", + domain, ads_errstr(ads_status))); + } + nt_status = ads_ntstatus(ads_status); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (!ads_cldap_netlogon_5(frame, + ads->config.ldap_server_name, + ads->config.realm, + &cldap_reply)) + { + DEBUG(4,("find_forest_root: Failed to get a CLDAP reply from %s!\n", + ads->server.ldap_server)); + nt_status = NT_STATUS_IO_TIMEOUT; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + gc->forest_name = talloc_strdup(gc, cldap_reply.forest); + BAIL_ON_PTR_ERROR(gc->forest_name, nt_status); + +done: + if (ads) { + ads_destroy(&ads); + } + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS gc_add_forest(const char *domain) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct gc_info *gc = NULL; + struct gc_info *find_gc = NULL; + char *dn; + ADS_STRUCT *ads = NULL; + struct likewise_cell *primary_cell = NULL; + + primary_cell = cell_list_head(); + if (!primary_cell) { + nt_status = NT_STATUS_INVALID_SERVER_STATE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Check for duplicates based on domain name first as this + requires no connection */ + + find_gc = gc_list_head(); + while (find_gc) { + if (strequal (find_gc->forest_name, domain)) + break; + find_gc = find_gc->next; + } + + if (find_gc) { + DEBUG(10,("gc_add_forest: %s already in list\n", find_gc->forest_name)); + return NT_STATUS_OK; + } + + if ((gc = TALLOC_ZERO_P(NULL, struct gc_info)) == NULL) { + nt_status = NT_STATUS_NO_MEMORY; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Query the rootDSE for the forest root naming conect first. + Check that the a GC server for the forest has not already + been added */ + + nt_status = gc_find_forest_root(gc, domain); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + find_gc = gc_list_head(); + while (find_gc) { + if (strequal (find_gc->forest_name, gc->forest_name)) + break; + find_gc = find_gc->next; + } + + if (find_gc) { + DEBUG(10,("gc_add_forest: Forest %s already in list\n", + find_gc->forest_name)); + return NT_STATUS_OK; + } + + /* Not found, so add it here. Make sure we connect to + a DC in _this_ domain and not the forest root. */ + + dn = ads_build_dn(gc->forest_name); + BAIL_ON_PTR_ERROR(dn, nt_status); + + gc->search_base = talloc_strdup(gc, dn); + SAFE_FREE(dn); + BAIL_ON_PTR_ERROR(gc->search_base, nt_status); + +#if 0 + /* Can't use cell_connect_dn() here as there is no way to + specifiy the LWCELL_FLAG_GC_CELL flag setting for cell_connect() */ + + nt_status = cell_connect_dn(&gc->forest_cell, gc->search_base); + BAIL_ON_NTSTATUS_ERROR(nt_status); +#else + + gc->forest_cell = cell_new(); + BAIL_ON_PTR_ERROR(gc->forest_cell, nt_status); + + /* Set the DNS domain, dn, etc ... and add it to the list */ + + cell_set_dns_domain(gc->forest_cell, gc->forest_name); + cell_set_dn(gc->forest_cell, gc->search_base); + cell_set_flags(gc->forest_cell, LWCELL_FLAG_GC_CELL); +#endif + + /* It is possible to belong to a non-forest cell and a + non-provisioned forest (at our domain levele). In that + case, we should just inherit the flags from our primary + cell since the GC searches will match our own schema + model. */ + + if (strequal(primary_cell->forest_name, gc->forest_name) + || is_subdomain(primary_cell->dns_domain, gc->forest_name)) + { + cell_set_flags(gc->forest_cell, cell_flags(primary_cell)); + } else { + /* outside of our domain */ + + nt_status = cell_connect(gc->forest_cell); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = cell_lookup_settings(gc->forest_cell); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Drop the connection now that we have the settings */ + + ads = cell_connection(gc->forest_cell); + ads_destroy(&ads); + cell_set_connection(gc->forest_cell, NULL); + } + + DLIST_ADD_END(_gc_server_list, gc, struct gc_info*); + + DEBUG(10,("gc_add_forest: Added %s to Global Catalog list of servers\n", + gc->forest_name)); + + nt_status = NT_STATUS_OK; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + talloc_destroy(gc); + DEBUG(3,("LWI: Failed to add new GC connection for %s (%s)\n", + domain, nt_errstr(nt_status))); + } + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static void gc_server_list_destroy(void) +{ + struct gc_info *gc = gc_list_head(); + + while (gc) { + struct gc_info *p = gc->next; + + cell_destroy(gc->forest_cell); + talloc_destroy(gc); + + gc = p; + } + + _gc_server_list = NULL; + + return; +} + +/********************************************************************** + Setup the initial list of forests and initial the forest cell + settings for each. FIXME!!! + *********************************************************************/ + + NTSTATUS gc_init_list(void) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct winbindd_tdc_domain *domains = NULL; + size_t num_domains = 0; + int i; + + if (_gc_server_list != NULL) { + gc_server_list_destroy(); + } + + if (!wcache_tdc_fetch_list(&domains, &num_domains)) { + nt_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Find our forest first. Have to try all domains here starting + with our own. gc_add_forest() filters duplicates */ + + nt_status = gc_add_forest(lp_realm()); + WARN_ON_NTSTATUS_ERROR(nt_status); + + for (i=0; iforest_cell, "", + LDAP_SCOPE_SUBTREE, filter, attrs, &m); + nt_status = ads_ntstatus(ads_status); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + *msg = m; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(2,("LWI: Forest wide search %s failed (%s)\n", + filter, nt_errstr(nt_status))); + } + + return nt_status; +} + +/********************************************************************** + Search all forests via GC and return the results in an array of + ADS_STRUCT/LDAPMessage pairs. + *********************************************************************/ + + NTSTATUS gc_search_all_forests(const char *filter, + ADS_STRUCT ***ads_list, + LDAPMessage ***msg_list, + int *num_resp, uint32_t flags) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct gc_info *gc = NULL; + uint32_t test_flags = ADEX_GC_SEARCH_CHECK_UNIQUE; + + *ads_list = NULL; + *msg_list = NULL; + *num_resp = 0; + + if ((gc = gc_search_start()) == NULL) { + nt_status = NT_STATUS_INVALID_DOMAIN_STATE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + while (gc) { + LDAPMessage *m = NULL; + + nt_status = gc_search_forest(gc, &m, filter); + if (!NT_STATUS_IS_OK(nt_status)) { + gc = gc->next; + continue; + } + + nt_status = add_ads_result_to_array(cell_connection(gc->forest_cell), + m, ads_list, msg_list, + num_resp); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* If there can only be one match, then we are done */ + + if ((*num_resp > 0) && ((flags & test_flags) == test_flags)) { + break; + } + + gc = gc->next; + } + + if (*num_resp == 0) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = NT_STATUS_OK; + +done: + return nt_status; +} + +/********************************************************************** + Search all forests via GC and return the results in an array of + ADS_STRUCT/LDAPMessage pairs. + *********************************************************************/ + + NTSTATUS gc_search_all_forests_unique(const char *filter, + ADS_STRUCT **ads, + LDAPMessage **msg) +{ + ADS_STRUCT **ads_list = NULL; + LDAPMessage **msg_list = NULL; + int num_resp; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + + nt_status = gc_search_all_forests(filter, &ads_list, + &msg_list, &num_resp, + ADEX_GC_SEARCH_CHECK_UNIQUE); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = check_result_unique(ads_list[0], msg_list[0]); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + *ads = ads_list[0]; + *msg = msg_list[0]; + +done: + /* Be care that we don't free the msg result being returned */ + + if (!NT_STATUS_IS_OK(nt_status)) { + free_result_array(ads_list, msg_list, num_resp); + } else { + talloc_destroy(ads_list); + talloc_destroy(msg_list); + } + + return nt_status; +} + +/********************************************************************* + ********************************************************************/ + + NTSTATUS gc_name_to_sid(const char *domain, + const char *name, + DOM_SID *sid, + enum lsa_SidType *sid_type) +{ + TALLOC_CTX *frame = talloc_stackframe(); + char *p, *name_user; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *name_filter; + ADS_STRUCT *ads = NULL; + LDAPMessage *msg = NULL; + LDAPMessage *e = NULL; + char *dn = NULL; + char *dns_domain = NULL; + ADS_STRUCT **ads_list = NULL; + LDAPMessage **msg_list = NULL; + int num_resp = 0; + int i; + + /* Strip the "DOMAIN\" prefix if necessary and search for + a matching sAMAccountName in the forest */ + + if ((p = strchr_m( name, '\\' )) == NULL) + name_user = talloc_strdup( frame, name ); + else + name_user = talloc_strdup( frame, p+1 ); + BAIL_ON_PTR_ERROR(name_user, nt_status); + + name_filter = talloc_asprintf(frame, "(sAMAccountName=%s)", name_user); + BAIL_ON_PTR_ERROR(name_filter, nt_status); + + nt_status = gc_search_all_forests(name_filter, &ads_list, + &msg_list, &num_resp, 0); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Assume failure until we know otherwise*/ + + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* Match the domain name from the DN */ + + for (i=0; idomain_name)) { + if (!ads_pull_sid(ads, e, "objectSid", sid)) { + nt_status = NT_STATUS_INVALID_SID; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + talloc_destroy(domain_rec); + + nt_status = get_sid_type(ads, msg, sid_type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* We're done! */ + nt_status = NT_STATUS_OK; + break; + } + + /* once more around thew merry-go-round */ + + talloc_destroy(domain_rec); + e = ads_next_entry(ads, e); + } + } + +done: + free_result_array(ads_list, msg_list, num_resp); + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + Pull an attribute string value + *******************************************************************/ + +static NTSTATUS get_object_account_name(ADS_STRUCT *ads, + LDAPMessage *msg, + char **name) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *sam_name = NULL; + struct winbindd_tdc_domain *domain_rec = NULL; + char *dns_domain = NULL; + char *dn = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + int len; + + /* Check parameters */ + + if (!ads || !msg || !name) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* get the name and domain */ + + dn = ads_get_dn(ads, msg); + BAIL_ON_PTR_ERROR(dn, nt_status); + + DEBUG(10,("get_object_account_name: dn = \"%s\"\n", dn)); + + dns_domain = cell_dn_to_dns(dn); + SAFE_FREE(dn); + BAIL_ON_PTR_ERROR(dns_domain, nt_status); + + domain_rec = wcache_tdc_fetch_domain(frame, dns_domain); + SAFE_FREE(dns_domain); + + if (!domain_rec) { + nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + sam_name = ads_pull_string(ads, frame, msg, "sAMAccountName"); + BAIL_ON_PTR_ERROR(sam_name, nt_status); + + len = asprintf(name, "%s\\%s", domain_rec->domain_name, sam_name); + if (len == -1) { + *name = NULL; + BAIL_ON_PTR_ERROR((*name), nt_status); + } + + nt_status = NT_STATUS_OK; + +done: + talloc_destroy(frame); + + return nt_status; +} + +/********************************************************************* + ********************************************************************/ + + NTSTATUS gc_sid_to_name(const DOM_SID *sid, + char **name, + enum lsa_SidType *sid_type) +{ + TALLOC_CTX *frame = talloc_stackframe(); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *filter; + ADS_STRUCT *ads = NULL; + LDAPMessage *msg = NULL; + char *sid_string; + + *name = NULL; + + sid_string = sid_binstring(sid); + BAIL_ON_PTR_ERROR(sid_string, nt_status); + + filter = talloc_asprintf(frame, "(objectSid=%s)", sid_string); + SAFE_FREE(sid_string); + BAIL_ON_PTR_ERROR(filter, nt_status); + + nt_status = gc_search_all_forests_unique(filter, &ads, &msg); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = get_object_account_name(ads, msg, name); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = get_sid_type(ads, msg, sid_type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + ads_msgfree(ads, msg); + talloc_destroy(frame); + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + + NTSTATUS add_ads_result_to_array(ADS_STRUCT *ads, + LDAPMessage *msg, + ADS_STRUCT ***ads_list, + LDAPMessage ***msg_list, + int *size) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + ADS_STRUCT **ads_tmp = NULL; + LDAPMessage **msg_tmp = NULL; + int count = *size; + + if (!ads || !msg) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + +#if 0 + /* Don't add a response with no entries */ + + if (ads_count_replies(ads, msg) == 0) { + return NT_STATUS_OK; + } +#endif + + if (count == 0) { + ads_tmp = TALLOC_ARRAY(NULL, ADS_STRUCT*, 1); + BAIL_ON_PTR_ERROR(ads_tmp, nt_status); + + msg_tmp = TALLOC_ARRAY(NULL, LDAPMessage*, 1); + BAIL_ON_PTR_ERROR(msg_tmp, nt_status); + } else { + ads_tmp = TALLOC_REALLOC_ARRAY(*ads_list, *ads_list, ADS_STRUCT*, + count+1); + BAIL_ON_PTR_ERROR(ads_tmp, nt_status); + + msg_tmp = TALLOC_REALLOC_ARRAY(*msg_list, *msg_list, LDAPMessage*, + count+1); + BAIL_ON_PTR_ERROR(msg_tmp, nt_status); + } + + ads_tmp[count] = ads; + msg_tmp[count] = msg; + count++; + + *ads_list = ads_tmp; + *msg_list = msg_tmp; + *size = count; + + nt_status = NT_STATUS_OK; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + talloc_destroy(ads_tmp); + talloc_destroy(msg_tmp); + } + + return nt_status; +} + +/********************************************************************** + Frees search results. Do not free the ads_list as these are + references back to the GC search structures. + *********************************************************************/ + + void free_result_array(ADS_STRUCT **ads_list, + LDAPMessage **msg_list, + int num_resp) +{ + int i; + + for (i=0; i 1) { + nt_status = NT_STATUS_DUPLICATE_NAME; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = NT_STATUS_OK; + +done: + return nt_status; +} diff --git a/source3/winbindd/idmap_adex/idmap_adex.c b/source3/winbindd/idmap_adex/idmap_adex.c new file mode 100644 index 0000000000..7596b1cbd8 --- /dev/null +++ b/source3/winbindd/idmap_adex/idmap_adex.c @@ -0,0 +1,460 @@ +/* + * idmap_adex: Support for D Forests + * + * Copyright (C) Gerald (Jerry) Carter 2006-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 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" +#include "idmap_adex.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +#define WINBIND_CCACHE_NAME "MEMORY:winbind_ccache" + +NTSTATUS init_module(void); + +/* + * IdMap backend + */ + +/******************************************************************** + Basic init function responsible for determining our current mode + (standalone or using Centeris Cells). This must return success or + it will be dropped from the idmap backend list. + *******************************************************************/ + +static NTSTATUS _idmap_adex_init(struct idmap_domain *dom, + const char *params) +{ + ADS_STRUCT *ads = NULL; + ADS_STATUS status; + static NTSTATUS init_status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; + DOM_SID domain_sid; + fstring dcname; + struct sockaddr_storage ip; + struct likewise_cell *lwcell; + + if (NT_STATUS_IS_OK(init_status)) + return NT_STATUS_OK; + + /* Silently fail if we are not a member server in security = ads */ + + if ((lp_server_role() != ROLE_DOMAIN_MEMBER) || + (lp_security() != SEC_ADS)) { + init_status = NT_STATUS_INVALID_SERVER_STATE; + BAIL_ON_NTSTATUS_ERROR(init_status); + } + + /* fetch our domain SID first */ + + if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { + init_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + BAIL_ON_NTSTATUS_ERROR(init_status); + } + + /* reuse the same ticket cache as winbindd */ + + setenv("KRB5CCNAME", WINBIND_CCACHE_NAME, 1); + + /* Establish a connection to a DC */ + + if ((ads = ads_init(lp_realm(), lp_workgroup(), NULL)) == NULL) { + init_status = NT_STATUS_NO_MEMORY; + BAIL_ON_NTSTATUS_ERROR(init_status); + } + + ads->auth.password = + secrets_fetch_machine_password(lp_workgroup(), NULL, NULL); + ads->auth.realm = SMB_STRDUP(lp_realm()); + + /* get the DC name here to setup the server affinity cache and + local krb5.conf */ + + get_dc_name(lp_workgroup(), lp_realm(), dcname, &ip); + + status = ads_connect(ads); + if (!ADS_ERR_OK(status)) { + DEBUG(0, ("_idmap_adex_init: ads_connect() failed! (%s)\n", + ads_errstr(status))); + } + init_status = ads_ntstatus(status); + BAIL_ON_NTSTATUS_ERROR(init_status); + + + /* Find out cell membership */ + + init_status = cell_locate_membership(ads); + if (!NT_STATUS_IS_OK(init_status)) { + DEBUG(0,("LWI: Fail to locate cell membership (%s).", + nt_errstr(init_status))); + goto done; + } + + /* Fill in the cell information */ + + lwcell = cell_list_head(); + + init_status = cell_lookup_settings(lwcell); + BAIL_ON_NTSTATUS_ERROR(init_status); + + /* Miscellaneous setup. E.g. set up the list of GC + servers and domain list for our forest (does not actually + connect). */ + + init_status = gc_init_list(); + BAIL_ON_NTSTATUS_ERROR(init_status); + + init_status = domain_init_list(); + BAIL_ON_NTSTATUS_ERROR(init_status); + +done: + if (!NT_STATUS_IS_OK(init_status)) { + DEBUG(1,("Likewise initialization failed (%s)\n", + nt_errstr(init_status))); + } + + /* cleanup */ + + if (!NT_STATUS_IS_OK(init_status)) { + cell_list_destroy(); + + /* init_status stores the failure reason but we need to + return success or else idmap_init() will drop us from the + backend list */ + return NT_STATUS_OK; + } + + init_status = NT_STATUS_OK; + + return init_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _idmap_adex_get_sid_from_id(struct + idmap_domain + *dom, struct + id_map + **ids) +{ + int i; + bool one_mapped = false; + bool all_mapped = true; + NTSTATUS nt_status; + struct likewise_cell *cell; + + nt_status = _idmap_adex_init(dom, NULL); + if (!NT_STATUS_IS_OK(nt_status)) + return nt_status; + + if ((cell = cell_list_head()) == NULL) { + return NT_STATUS_INVALID_SERVER_STATE; + } + + /* have to work through these one by one */ + for (i = 0; ids[i]; i++) { + NTSTATUS status; + status = cell->provider->get_sid_from_id(ids[i]->sid, + ids[i]->xid.id, + ids[i]->xid.type); + /* Fail if we cannot find any DC */ + if (NT_STATUS_EQUAL + (status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) { + return status; + } + + if (!NT_STATUS_IS_OK(status)) { + ids[i]->status = ID_UNMAPPED; + all_mapped = false; + continue; + } + + ids[i]->status = ID_MAPPED; + one_mapped = true; + } + + return NT_STATUS_OK; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _idmap_adex_get_id_from_sid(struct + idmap_domain + *dom, struct + id_map + **ids) +{ + int i; + bool one_mapped = false; + bool all_mapped = true; + NTSTATUS nt_status; + struct likewise_cell *cell; + + nt_status = _idmap_adex_init(dom, NULL); + if (!NT_STATUS_IS_OK(nt_status)) + return nt_status; + + if ((cell = cell_list_head()) == NULL) { + return NT_STATUS_INVALID_SERVER_STATE; + } + + /* have to work through these one by one */ + for (i = 0; ids[i]; i++) { + NTSTATUS status; + status = cell->provider->get_id_from_sid(&ids[i]->xid.id, + &ids[i]->xid. + type, ids[i]->sid); + /* Fail if we cannot find any DC */ + if (NT_STATUS_EQUAL + (status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) { + return status; + } + + if (!NT_STATUS_IS_OK(status)) { + ids[i]->status = ID_UNMAPPED; + all_mapped = false; + continue; + } + + ids[i]->status = ID_MAPPED; + one_mapped = true; + } + + return NT_STATUS_OK; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _idmap_adex_set_mapping(struct + idmap_domain + *dom, const struct + id_map *map) +{ + DEBUG(0, ("_idmap_adex_set_mapping: not implemented\n")); + return NT_STATUS_NOT_IMPLEMENTED; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _idmap_adex_remove_mapping(struct + idmap_domain + *dom, const + struct + id_map + *map) +{ + DEBUG(0, ("_idmap_adex_remove_mapping: not implemented\n")); + return NT_STATUS_NOT_IMPLEMENTED; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _idmap_adex_dump(struct idmap_domain + *dom, struct id_map **maps, int *num_map) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _idmap_adex_close(struct idmap_domain + *dom) +{ + /* FIXME! need to do cleanup here */ + + return NT_STATUS_OK; +} + +/* + * IdMap NSS plugin + */ + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _nss_adex_init(struct nss_domain_entry + *e) +{ + return _idmap_adex_init(NULL, NULL); +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _nss_adex_get_info(struct + nss_domain_entry *e, + const DOM_SID * sid, + TALLOC_CTX * ctx, + ADS_STRUCT * ads, + LDAPMessage * msg, + char **homedir, + char **shell, char **gecos, gid_t * p_gid) +{ + NTSTATUS nt_status; + struct likewise_cell *cell; + + nt_status = _idmap_adex_init(NULL, NULL); + if (!NT_STATUS_IS_OK(nt_status)) + return nt_status; + + if ((cell = cell_list_head()) == NULL) { + return NT_STATUS_INVALID_SERVER_STATE; + } + + return cell->provider->get_nss_info(sid, ctx, homedir, + shell, gecos, p_gid); +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _nss_adex_map_to_alias(TALLOC_CTX * mem_ctx, const char + *domain, const char + *name, char **alias) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct likewise_cell *cell = NULL; + + nt_status = _idmap_adex_init(NULL, NULL); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if ((cell = cell_list_head()) == NULL) { + nt_status = NT_STATUS_INVALID_SERVER_STATE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = cell->provider->map_to_alias(mem_ctx, domain, + name, alias); + + /* go ahead and allow the cache mgr to mark this in + negative cache */ + + if (!NT_STATUS_IS_OK(nt_status)) + nt_status = NT_STATUS_NONE_MAPPED; + +done: + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _nss_adex_map_from_alias(TALLOC_CTX * mem_ctx, const char + *domain, const char + *alias, char **name) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct likewise_cell *cell = NULL; + + nt_status = _idmap_adex_init(NULL, NULL); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if ((cell = cell_list_head()) == NULL) { + nt_status = NT_STATUS_INVALID_SERVER_STATE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + + nt_status = cell->provider->map_from_alias(mem_ctx, domain, + alias, name); + + /* go ahead and allow the cache mgr to mark this in + negative cache */ + + if (!NT_STATUS_IS_OK(nt_status)) + nt_status = NT_STATUS_NONE_MAPPED; + +done: + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _nss_adex_close(void) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/********************************************************************** + *********************************************************************/ + +static struct idmap_methods adex_idmap_methods = { + + .init = _idmap_adex_init, + .unixids_to_sids = _idmap_adex_get_sid_from_id, + .sids_to_unixids = _idmap_adex_get_id_from_sid, + .set_mapping = _idmap_adex_set_mapping, + .remove_mapping = _idmap_adex_remove_mapping, + .dump_data = _idmap_adex_dump, + .close_fn = _idmap_adex_close +}; +static struct nss_info_methods adex_nss_methods = { + .init = _nss_adex_init, + .get_nss_info = _nss_adex_get_info, + .map_to_alias = _nss_adex_map_to_alias, + .map_from_alias = _nss_adex_map_from_alias, + .close_fn = _nss_adex_close +}; + +/********************************************************************** + Register with the idmap and idmap_nss subsystems. We have to protect + against the idmap and nss_info interfaces being in a half-registered + state. + **********************************************************************/ +NTSTATUS idmap_adex_init(void) +{ + static NTSTATUS idmap_status = NT_STATUS_UNSUCCESSFUL; + static NTSTATUS nss_status = NT_STATUS_UNSUCCESSFUL; + if (!NT_STATUS_IS_OK(idmap_status)) { + idmap_status = + smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, + "adex", &adex_idmap_methods); + if (!NT_STATUS_IS_OK(idmap_status)) { + DEBUG(0, + ("idmap_centeris_init: Failed to register the adex" + "idmap plugin.\n")); + return idmap_status; + } + } + + if (!NT_STATUS_IS_OK(nss_status)) { + nss_status = + smb_register_idmap_nss(SMB_NSS_INFO_INTERFACE_VERSION, + "adex", &adex_nss_methods); + if (!NT_STATUS_IS_OK(nss_status)) { + DEBUG(0, + ("idmap_adex_init: Failed to register the adex" + "nss plugin.\n")); + return nss_status; + } + } + + return NT_STATUS_OK; +} + +static NTSTATUS nss_info_adex_init(void) +{ + return idmap_adex_init(); +} diff --git a/source3/winbindd/idmap_adex/idmap_adex.h b/source3/winbindd/idmap_adex/idmap_adex.h new file mode 100644 index 0000000000..e068d5c340 --- /dev/null +++ b/source3/winbindd/idmap_adex/idmap_adex.h @@ -0,0 +1,257 @@ +/* + * idmap_centeris: Support for Local IDs and Centeris Cell Structure + * + * Copyright (C) Gerald (Jerry) Carter 2006-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 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. + */ + +#ifndef _IDMAP_ADEX_H +#define _IDMAP_ADEX_H + +#include "winbindd/winbindd.h" + +#define ADEX_CELL_RDN "$LikewiseIdentityCell" + +#define ADEX_OC_USER "centerisLikewiseUser" +#define ADEX_OC_GROUP "centerisLikewiseGroup" + +#define AD_USER "User" +#define AD_GROUP "Group" + +#define ADEX_OC_POSIX_USER "posixAccount" +#define ADEX_OC_POSIX_GROUP "posixGroup" + +#define ADEX_ATTR_UIDNUM "uidNumber" +#define ADEX_ATTR_GIDNUM "gidNUmber" +#define ADEX_ATTR_HOMEDIR "unixHomeDirectory" +#define ADEX_ATTR_USERPW "unixUserPassword" +#define ADEX_ATTR_GROUPALIAS "groupAlias" /* Not part of RFC2307 */ +#define ADEX_ATTR_SHELL "loginShell" +#define ADEX_ATTR_GECOS "gecos" +#define ADEX_ATTR_UID "uid" +#define ADEX_ATTR_DISPLAYNAME "displayName" + +#define MIN_ID_VALUE 100 + +#define BAIL_ON_NTSTATUS_ERROR(x) \ + do { \ + if (!NT_STATUS_IS_OK(x)) { \ + DEBUG(10,("Failed! (%s)\n", nt_errstr(x))); \ + goto done; \ + } \ + } \ + while (0); \ + +#define WARN_ON_NTSTATUS_ERROR(x) \ + do { \ + if (!NT_STATUS_IS_OK(x)) { \ + DEBUG(10,("Failure ignored! (%s)\n", nt_errstr(x))); \ + } \ + } \ + while (0); \ + +#define BAIL_ON_ADS_ERROR(x) \ + do { \ + if (!ADS_ERR_OK(x)) { \ + goto done; \ + } \ + } \ + while (0); + +#define BAIL_ON_PTR_ERROR(p, x) \ + do { \ + if ((p) == NULL ) { \ + DEBUG(10,("NULL pointer!\n")); \ + x = NT_STATUS_NO_MEMORY; \ + goto done; \ + } \ + } while (0); + +#define PRINT_NTSTATUS_ERROR(x, hdr, level) \ + do { \ + if (!NT_STATUS_IS_OK(x)) { \ + DEBUG(level,("LWI ("hdr"): %s\n", nt_errstr(x))); \ + } \ + } while(0); +/* + * Cell Provider API + */ + +struct cell_provider_api { + NTSTATUS(*get_sid_from_id) (DOM_SID * sid, + uint32_t id, enum id_type type); + NTSTATUS(*get_id_from_sid) (uint32_t * id, + enum id_type * type, const DOM_SID * sid); + NTSTATUS(*get_nss_info) (const DOM_SID * sid, + TALLOC_CTX * ctx, + char **homedir, + char **shell, char **gecos, gid_t * p_gid); + NTSTATUS(*map_to_alias) (TALLOC_CTX * mem_ctx, + const char *domain, + const char *name, char **alias); + NTSTATUS(*map_from_alias) (TALLOC_CTX * mem_ctx, + const char *domain, + const char *alias, char **name); +}; + +/* registered providers */ + +extern struct cell_provider_api ccp_unified; +extern struct cell_provider_api ccp_local; + +#define LWCELL_FLAG_USE_RFC2307_ATTRS 0x00000001 +#define LWCELL_FLAG_SEARCH_FOREST 0x00000002 +#define LWCELL_FLAG_GC_CELL 0x00000004 +#define LWCELL_FLAG_LOCAL_MODE 0x00000008 + +struct likewise_cell { + struct likewise_cell *prev, *next; + ADS_STRUCT *conn; + struct likewise_cell *gc_search_cell; + DOM_SID domain_sid; + char *dns_domain; + char *forest_name; + char *dn; + struct GUID *links; /* only held by owning cell */ + size_t num_links; + uint32_t flags; + struct cell_provider_api *provider; +}; + +/* Search flags used for Global Catalog API */ + +#define ADEX_GC_SEARCH_CHECK_UNIQUE 0x00000001 + +struct gc_info { + struct gc_info *prev, *next; + char *forest_name; + char *search_base; + struct likewise_cell *forest_cell; +}; + +/* Available functions outside of idmap_lwidentity.c */ + +/* cell_util.c */ + +char *find_attr_string(char **list, size_t num_lines, const char *substr); +bool is_object_class(char **list, size_t num_lines, const char *substr); +int min_id_value(void); +char *cell_dn_to_dns(const char *dn); +NTSTATUS get_sid_type(ADS_STRUCT *ads, + LDAPMessage *msg, + enum lsa_SidType *type); + +NTSTATUS cell_locate_membership(ADS_STRUCT * ads); +NTSTATUS cell_lookup_settings(struct likewise_cell * cell); +NTSTATUS cell_follow_links(struct likewise_cell *cell); +NTSTATUS cell_set_local_provider(void); + +/* likewise_cell.c */ + +struct likewise_cell *cell_new(void); +struct likewise_cell *cell_list_head(void); + +bool cell_list_add(struct likewise_cell *cell); +bool cell_list_remove(struct likewise_cell * cell); + +void cell_list_destroy(void); +void cell_destroy(struct likewise_cell *c); +void cell_set_forest_searches(struct likewise_cell *c, + bool search); +void cell_set_dns_domain(struct likewise_cell *c, + const char *dns_domain); +void cell_set_connection(struct likewise_cell *c, + ADS_STRUCT *ads); +void cell_set_dn(struct likewise_cell *c, + const char *dn); +void cell_set_domain_sid(struct likewise_cell *c, + DOM_SID *sid); +void cell_set_flags(struct likewise_cell *c, uint32_t flags); +void cell_clear_flags(struct likewise_cell *c, uint32_t flags); + +const char* cell_search_base(struct likewise_cell *c); +const char *cell_dns_domain(struct likewise_cell *c); +ADS_STRUCT *cell_connection(struct likewise_cell *c); +bool cell_search_forest(struct likewise_cell *c); +ADS_STATUS cell_do_search(struct likewise_cell *c, + const char *search_base, + int scope, + const char *expr, + const char **attrs, + LDAPMessage ** msg); +uint32_t cell_flags(struct likewise_cell *c); + +NTSTATUS cell_connect_dn(struct likewise_cell **c, + const char *dn); +NTSTATUS cell_connect(struct likewise_cell *c); + + +/* gc_util.c */ + +NTSTATUS gc_init_list(void); + +NTSTATUS gc_find_forest_root(struct gc_info *gc, + const char *domain); + +struct gc_info *gc_search_start(void); + +NTSTATUS gc_search_forest(struct gc_info *gc, + LDAPMessage **msg, + const char *filter); + +NTSTATUS gc_search_all_forests(const char *filter, + ADS_STRUCT ***ads_list, + LDAPMessage ***msg_list, + int *num_resp, uint32_t flags); + +NTSTATUS gc_search_all_forests_unique(const char *filter, + ADS_STRUCT **ads, + LDAPMessage **msg); + +NTSTATUS gc_name_to_sid(const char *domain, + const char *name, + DOM_SID *sid, + enum lsa_SidType *sid_type); + +NTSTATUS gc_sid_to_name(const DOM_SID *sid, + char **name, + enum lsa_SidType *sid_type); + +NTSTATUS add_ads_result_to_array(ADS_STRUCT *ads, + LDAPMessage *msg, + ADS_STRUCT ***ads_list, + LDAPMessage ***msg_list, + int *size); + +void free_result_array(ADS_STRUCT **ads_list, + LDAPMessage **msg_list, + int num_resp); + +NTSTATUS check_result_unique(ADS_STRUCT *ads, + LDAPMessage *msg); + + +/* domain_util.c */ + +NTSTATUS domain_init_list(void); + +NTSTATUS dc_search_domains(struct likewise_cell **cell, + LDAPMessage **msg, + const char *dn, + const DOM_SID *user_sid); + + +#endif /* _IDMAP_ADEX_H */ diff --git a/source3/winbindd/idmap_adex/likewise_cell.c b/source3/winbindd/idmap_adex/likewise_cell.c new file mode 100644 index 0000000000..7723b3e015 --- /dev/null +++ b/source3/winbindd/idmap_adex/likewise_cell.c @@ -0,0 +1,443 @@ +/* + * idmap_adex: Support for AD Forests + * + * Copyright (C) Gerald (Jerry) Carter 2006-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 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" +#include "idmap_adex.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +static struct likewise_cell *_lw_cell_list = NULL; + +/********************************************************************** + Return the current HEAD of the list + *********************************************************************/ + + struct likewise_cell *cell_list_head(void) +{ + return _lw_cell_list; +} + + +/********************************************************************** + *********************************************************************/ + + void cell_destroy(struct likewise_cell *c) +{ + if (!c) + return; + + if (c->conn) + ads_destroy(&c->conn); + + talloc_destroy(c); +} + +/********************************************************************** + Free all cell entries and reset the list head to NULL + *********************************************************************/ + + void cell_list_destroy(void) +{ + struct likewise_cell *p = _lw_cell_list; + + while (p) { + struct likewise_cell *q = p->next; + + cell_destroy(p); + + p = q; + } + + _lw_cell_list = NULL; + + return; +} + +/********************************************************************** + Add a new cell structure to the list + *********************************************************************/ + + struct likewise_cell* cell_new(void) +{ + struct likewise_cell *c; + + /* Each cell struct is a TALLOC_CTX* */ + + c = TALLOC_ZERO_P(NULL, struct likewise_cell); + if (!c) { + DEBUG(0,("cell_new: memory allocation failure!\n")); + return NULL; + } + + return c; +} + +/********************************************************************** + Add a new cell structure to the list + *********************************************************************/ + + bool cell_list_add(struct likewise_cell * cell) +{ + if (!cell) { + return false; + } + + /* Always add to the end */ + + DLIST_ADD_END(_lw_cell_list, cell, struct likewise_cell *); + + return true; +} + +/********************************************************************** + Add a new cell structure to the list + *********************************************************************/ + + bool cell_list_remove(struct likewise_cell * cell) +{ + if (!cell) { + return false; + } + + /* Remove and drop the cell structure */ + + DLIST_REMOVE(_lw_cell_list, cell); + talloc_destroy(cell); + + return true; +} + +/********************************************************************** + Set the containing DNS domain for a cell + *********************************************************************/ + + void cell_set_dns_domain(struct likewise_cell *c, const char *dns_domain) +{ + c->dns_domain = talloc_strdup(c, dns_domain); +} + +/********************************************************************** + Set ADS connection for a cell + *********************************************************************/ + + void cell_set_connection(struct likewise_cell *c, ADS_STRUCT *ads) +{ + c->conn = ads; +} + +/********************************************************************** + *********************************************************************/ + + void cell_set_flags(struct likewise_cell *c, uint32_t flags) +{ + c->flags |= flags; +} + +/********************************************************************** + *********************************************************************/ + + void cell_clear_flags(struct likewise_cell *c, uint32_t flags) +{ + c->flags &= ~flags; +} + +/********************************************************************** + Set the Cell's DN + *********************************************************************/ + + void cell_set_dn(struct likewise_cell *c, const char *dn) +{ + if ( c->dn) { + talloc_free(c->dn); + c->dn = NULL; + } + + c->dn = talloc_strdup(c, dn); +} + +/********************************************************************** + *********************************************************************/ + + void cell_set_domain_sid(struct likewise_cell *c, DOM_SID *sid) +{ + sid_copy(&c->domain_sid, sid); +} + +/* + * Query Routines + */ + +/********************************************************************** + *********************************************************************/ + + const char* cell_search_base(struct likewise_cell *c) +{ + if (!c) + return NULL; + + return talloc_asprintf(c, "cn=%s,%s", ADEX_CELL_RDN, c->dn); +} + +/********************************************************************** + *********************************************************************/ + + bool cell_search_forest(struct likewise_cell *c) +{ + uint32_t test_flags = LWCELL_FLAG_SEARCH_FOREST; + + return ((c->flags & test_flags) == test_flags); +} + +/********************************************************************** + *********************************************************************/ + + uint32_t cell_flags(struct likewise_cell *c) +{ + if (!c) + return 0; + + return c->flags; +} + +/********************************************************************** + *********************************************************************/ + + const char *cell_dns_domain(struct likewise_cell *c) +{ + if (!c) + return NULL; + + return c->dns_domain; +} + +/********************************************************************** + *********************************************************************/ + + ADS_STRUCT *cell_connection(struct likewise_cell *c) +{ + if (!c) + return NULL; + + return c->conn; +} + +/* + * Connection functions + */ + +/******************************************************************** + *******************************************************************/ + + NTSTATUS cell_connect(struct likewise_cell *c) +{ + ADS_STRUCT *ads = NULL; + ADS_STATUS ads_status; + fstring dc_name; + struct sockaddr_storage dcip; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + + /* have to at least have the AD domain name */ + + if (!c->dns_domain) { + nt_status = NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* clear out any old information */ + + if (c->conn) { + ads_destroy(&c->conn); + c->conn = NULL; + } + + /* now setup the new connection */ + + ads = ads_init(c->dns_domain, NULL, NULL); + BAIL_ON_PTR_ERROR(ads, nt_status); + + ads->auth.password = + secrets_fetch_machine_password(lp_workgroup(), NULL, NULL); + ads->auth.realm = SMB_STRDUP(lp_realm()); + + /* Make the connection. We should already have an initial + TGT using the machine creds */ + + if (cell_flags(c) & LWCELL_FLAG_GC_CELL) { + ads_status = ads_connect_gc(ads); + } else { + /* Set up server affinity for normal cells and the client + site name cache */ + + if (!get_dc_name("", c->dns_domain, dc_name, &dcip)) { + nt_status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + ads_status = ads_connect(ads); + } + + + c->conn = ads; + + nt_status = ads_ntstatus(ads_status); + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + ads_destroy(&ads); + c->conn = NULL; + } + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + + NTSTATUS cell_connect_dn(struct likewise_cell **c, const char *dn) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct likewise_cell *new_cell = NULL; + char *dns_domain = NULL; + + if (*c || !dn) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + if ((new_cell = cell_new()) == NULL) { + nt_status = NT_STATUS_NO_MEMORY; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Set the DNS domain, dn, etc ... and add it to the list */ + + dns_domain = cell_dn_to_dns(dn); + cell_set_dns_domain(new_cell, dns_domain); + SAFE_FREE(dns_domain); + + cell_set_dn(new_cell, dn); + + nt_status = cell_connect(new_cell); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + *c = new_cell; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(1,("LWI: Failled to connect to cell \"%s\" (%s)\n", + dn ? dn : "NULL", nt_errstr(nt_status))); + talloc_destroy(new_cell); + } + + return nt_status; +} + + +/******************************************************************** + *******************************************************************/ + +#define MAX_SEARCH_COUNT 2 + + ADS_STATUS cell_do_search(struct likewise_cell *c, + const char *search_base, + int scope, + const char *expr, + const char **attrs, + LDAPMessage ** msg) +{ + int search_count = 0; + ADS_STATUS status; + NTSTATUS nt_status; + + /* check for a NULL connection */ + + if (!c->conn) { + nt_status = cell_connect(c); + if (!NT_STATUS_IS_OK(nt_status)) { + status = ADS_ERROR_NT(nt_status); + return status; + } + } + + DEBUG(10, ("cell_do_search: Base = %s, Filter = %s, Scope = %d, GC = %s\n", + search_base, expr, scope, + c->conn->server.gc ? "yes" : "no")); + + /* we try multiple times in case the ADS_STRUCT is bad + and we need to reconnect */ + + while (search_count < MAX_SEARCH_COUNT) { + *msg = NULL; + status = ads_do_search(c->conn, search_base, + scope, expr, attrs, msg); + if (ADS_ERR_OK(status)) { + if (DEBUGLEVEL >= 10) { + LDAPMessage *e = NULL; + + int n = ads_count_replies(c->conn, *msg); + + DEBUG(10,("cell_do_search: Located %d entries\n", n)); + + for (e=ads_first_entry(c->conn, *msg); + e!=NULL; + e = ads_next_entry(c->conn, e)) + { + char *dn = ads_get_dn(c->conn, e); + + DEBUGADD(10,(" dn: %s\n", dn ? dn : "")); + SAFE_FREE(dn); + } + } + + return status; + } + + + DEBUG(5, ("cell_do_search: search[%d] failed (%s)\n", + search_count, ads_errstr(status))); + + search_count++; + + /* Houston, we have a problem */ + + if (status.error_type == ENUM_ADS_ERROR_LDAP) { + switch (status.err.rc) { + case LDAP_TIMELIMIT_EXCEEDED: + case LDAP_TIMEOUT: + case -1: /* we get this error if we cannot contact + the LDAP server */ + nt_status = cell_connect(c); + if (!NT_STATUS_IS_OK(nt_status)) { + status = ADS_ERROR_NT(nt_status); + return status; + } + break; + default: + /* we're all done here */ + return status; + } + } + } + + DEBUG(5, ("cell_do_search: exceeded maximum search count!\n")); + + return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); +} diff --git a/source3/winbindd/idmap_adex/provider_unified.c b/source3/winbindd/idmap_adex/provider_unified.c new file mode 100644 index 0000000000..f18534797e --- /dev/null +++ b/source3/winbindd/idmap_adex/provider_unified.c @@ -0,0 +1,1180 @@ +/* + * idmap_adex + * + * Provider for RFC2307 and SFU AD Forests + * + * Copyright (C) Gerald (Jerry) Carter 2006-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 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" +#include "idmap_adex.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +/* Information needed by the LDAP search filters */ + +enum filterType { SidFilter, IdFilter, AliasFilter }; + +struct lwcell_filter +{ + enum filterType ftype; + bool use2307; + union { + DOM_SID sid; + struct { + uint32_t id; + enum id_type type; + } id; + fstring alias; + } filter; +}; + +/******************************************************************** + *******************************************************************/ + +static char* build_id_filter(uint32_t id, + enum id_type type, + uint32_t search_flags) +{ + char *filter = NULL; + char *oc_filter, *attr_filter; + NTSTATUS nt_status; + TALLOC_CTX *frame = talloc_stackframe(); + bool use2307 = ((search_flags & LWCELL_FLAG_USE_RFC2307_ATTRS) + == LWCELL_FLAG_USE_RFC2307_ATTRS); + bool use_gc = ((search_flags & LWCELL_FLAG_SEARCH_FOREST) + == LWCELL_FLAG_SEARCH_FOREST); + const char *oc; + + /* Construct search filter for objectclass and attributes */ + + switch (type) { + case ID_TYPE_UID: + oc = ADEX_OC_USER; + if (use2307) { + oc = ADEX_OC_POSIX_USER; + if (use_gc) { + oc = AD_USER; + } + } + oc_filter = talloc_asprintf(frame, "objectclass=%s", oc); + attr_filter = talloc_asprintf(frame, "%s=%u", + ADEX_ATTR_UIDNUM, id); + break; + + case ID_TYPE_GID: + oc = ADEX_OC_GROUP; + if (use2307) { + oc = ADEX_OC_POSIX_GROUP; + if (use_gc) { + oc = AD_GROUP; + } + } + oc_filter = talloc_asprintf(frame, "objectclass=%s", oc); + attr_filter = talloc_asprintf(frame, "%s=%u", + ADEX_ATTR_GIDNUM, id); + break; + default: + return NULL; + } + + BAIL_ON_PTR_ERROR(oc_filter, nt_status); + BAIL_ON_PTR_ERROR(attr_filter, nt_status); + + /* Use "keywords=%s" for non-schema cells */ + + if (use2307) { + filter = talloc_asprintf(frame, "(&(%s)(%s))", + oc_filter, attr_filter); + } else { + filter = talloc_asprintf(frame, "(&(keywords=%s)(keywords=%s))", + oc_filter, attr_filter); + } + + talloc_destroy(oc_filter); + talloc_destroy(attr_filter); + +done: + /* Don't destroy the stackframe CTX since we are returning + memory from it */ + + return filter; +} + +/******************************************************************** + *******************************************************************/ + +static char* build_alias_filter(const char *alias, uint32_t search_flags) +{ + char *filter = NULL; + char *user_attr_filter, *group_attr_filter; + NTSTATUS nt_status; + TALLOC_CTX *frame = talloc_stackframe(); + bool use2307 = ((search_flags & LWCELL_FLAG_USE_RFC2307_ATTRS) + == LWCELL_FLAG_USE_RFC2307_ATTRS); + bool search_forest = ((search_flags & LWCELL_FLAG_SEARCH_FOREST) + == LWCELL_FLAG_SEARCH_FOREST); + + /* Construct search filter for objectclass and attributes */ + + user_attr_filter = talloc_asprintf(frame, "%s=%s", + ADEX_ATTR_UID, alias); + group_attr_filter = talloc_asprintf(frame, "%s=%s", + ADEX_ATTR_DISPLAYNAME, alias); + BAIL_ON_PTR_ERROR(user_attr_filter, nt_status); + BAIL_ON_PTR_ERROR(group_attr_filter, nt_status); + + /* Use "keywords=%s" for non-schema cells */ + + if (use2307) { + filter = talloc_asprintf(frame, + "(|(&(%s)(objectclass=%s))(&(%s)(objectclass=%s)))", + user_attr_filter, + search_forest ? AD_USER : ADEX_OC_POSIX_USER, + group_attr_filter, + search_forest ? AD_GROUP : ADEX_OC_POSIX_GROUP); + } else { + filter = talloc_asprintf(frame, + "(|(keywords=%s)(keywords=%s))", + user_attr_filter, + group_attr_filter); + } + + talloc_destroy(user_attr_filter); + talloc_destroy(group_attr_filter); + +done: + /* Don't destroy the stackframe CTX since we are returning + memory from it */ + + return filter; +} + + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS search_cell(struct likewise_cell *c, + LDAPMessage **msg, + const struct lwcell_filter *fdata) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + TALLOC_CTX* frame = talloc_stackframe(); + char *filter = NULL; + const char *base = NULL; + ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); + const char *attrs[] = { "*", NULL }; + int count; + char *sid_str; + + /* get the filter and other search parameters */ + + switch (fdata->ftype) { + case SidFilter: + sid_str = sid_string_talloc(frame, &fdata->filter.sid); + BAIL_ON_PTR_ERROR(sid_str, nt_status); + + filter = talloc_asprintf(frame, "(keywords=backLink=%s)", + sid_str); + break; + case IdFilter: + filter = build_id_filter(fdata->filter.id.id, + fdata->filter.id.type, + cell_flags(c)); + break; + case AliasFilter: + filter = build_alias_filter(fdata->filter.alias, + cell_flags(c)); + break; + default: + nt_status = NT_STATUS_INVALID_PARAMETER; + break; + } + BAIL_ON_PTR_ERROR(filter, nt_status); + + base = cell_search_base(c); + BAIL_ON_PTR_ERROR(base, nt_status); + + ads_status = cell_do_search(c, base, LDAP_SCOPE_SUBTREE, + filter, attrs, msg); + + nt_status = ads_ntstatus(ads_status); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Now check that we got only one reply */ + + count = ads_count_replies(c->conn, *msg); + if (count < 1) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + if ( count > 1) { + nt_status = NT_STATUS_DUPLICATE_NAME; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + +done: + PRINT_NTSTATUS_ERROR(nt_status, "search_cell", 4); + + talloc_destroy(CONST_DISCARD(char*, base)); + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS search_domain(struct likewise_cell **cell, + LDAPMessage **msg, + const char *dn, + const DOM_SID *sid) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + TALLOC_CTX* frame = talloc_stackframe(); + int count; + + nt_status = dc_search_domains(cell, msg, dn, sid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Now check that we got only one reply */ + + count = ads_count_replies(cell_connection(*cell), *msg); + if (count < 1) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + if ( count > 1) { + nt_status = NT_STATUS_DUPLICATE_NAME; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + +done: + PRINT_NTSTATUS_ERROR(nt_status, "search_domain", 4); + talloc_destroy(frame); + + return nt_status; +} + + +/******************************************************************** + Check that a DN is within the forest scope. + *******************************************************************/ + +static bool check_forest_scope(const char *dn) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + TALLOC_CTX *frame = talloc_stackframe(); + char *p = NULL; + char *q = NULL; + char *dns_domain = NULL; + struct winbindd_tdc_domain *domain; + + /* If the DN does *not* contain "$LikewiseIdentityCell", + assume this is a schema mode forest and it is in the + forest scope by definition. */ + + if ((p = strstr_m(dn, ADEX_CELL_RDN)) == NULL) { + nt_status = NT_STATUS_OK; + goto done; + } + + /* If this is a non-schema forest, then make sure that the DN + is in the form "...,cn=$LikewiseIdentityCell,DC=..." */ + + if ((q = strchr_m(p, ',')) == NULL) { + nt_status = NT_STATUS_OBJECT_NAME_INVALID; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + q++; + if (StrnCaseCmp(q, "dc=", 3) != 0) { + nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + + dns_domain = cell_dn_to_dns(q); + BAIL_ON_PTR_ERROR(dns_domain, nt_status); + + domain = wcache_tdc_fetch_domain(frame, dns_domain); + if (!domain) { + nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = NT_STATUS_OK; + +done: + talloc_destroy(frame); + SAFE_FREE(dns_domain); + + return NT_STATUS_IS_OK(nt_status); +} + + + +/******************************************************************** + Check that only one result was returned within the forest cell + scope. + *******************************************************************/ + +static NTSTATUS check_result_unique_scoped(ADS_STRUCT **ads_list, + LDAPMessage **msg_list, + int num_resp, + char **dn, + DOM_SID *user_sid) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + int i; + ADS_STRUCT *ads = NULL; + LDAPMessage *msg = NULL; + int count = 0; + char *entry_dn = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (!dn || !user_sid) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + *dn = NULL; + + if (!ads_list || !msg_list || (num_resp == 0)) { + nt_status = NT_STATUS_NO_SUCH_FILE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Loop over all msgs */ + + for (i=0; i 1) { + nt_status = NT_STATUS_DUPLICATE_NAME; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + ads = ads_list[i]; + msg = e; + *dn = SMB_STRDUP(entry_dn); + BAIL_ON_PTR_ERROR((*dn), nt_status); + } + + e = ads_next_entry(ads_list[i], e); + SAFE_FREE(entry_dn); + } + } + + if (!ads || !msg) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* If we made is through the loop, then grab the user_sid and + run home to base */ + + /* + Try and get the SID from either objectSid or keywords. + We cannot use pull_sid() here since we want to try + both methods and not only one or the other (and we + have no full likewise_cell struct. + + Fail if both are unavailable + */ + + if (!ads_pull_sid(ads, msg, "objectSid", user_sid)) { + char **keywords; + char *s; + size_t num_lines = 0; + + keywords = ads_pull_strings(ads, frame, msg, "keywords", + &num_lines); + BAIL_ON_PTR_ERROR(keywords, nt_status); + + s = find_attr_string(keywords, num_lines, "backLink"); + if (!s) { + nt_status = NT_STATUS_INTERNAL_DB_CORRUPTION; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + if (!string_to_sid(user_sid, s)) { + nt_status = NT_STATUS_INVALID_SID; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + } + + nt_status = NT_STATUS_OK; + +done: + if (!NT_STATUS_IS_OK(nt_status)) { + SAFE_FREE(*dn); + } + + talloc_destroy(frame); + SAFE_FREE(entry_dn); + + return nt_status; +} + +/******************************************************************** + Search all forests. Each forest can have it's own forest-cell + settings so we have to generate the filter for each search. + We don't use gc_search_all_forests() since we may have a different + schema model in each forest and need to construct the search + filter for each GC search. + *******************************************************************/ + +static NTSTATUS search_forest(struct likewise_cell *forest_cell, + LDAPMessage **msg, + const struct lwcell_filter *fdata) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + TALLOC_CTX *frame = talloc_stackframe(); + char *filter = NULL; + char *dn = NULL; + struct gc_info *gc = NULL; + ADS_STRUCT **ads_list = NULL; + LDAPMessage **msg_list = NULL; + int num_resp = 0; + LDAPMessage *m; + DOM_SID user_sid; + struct likewise_cell *domain_cell = NULL; + + if ((gc = gc_search_start()) == NULL) { + nt_status = NT_STATUS_INVALID_DOMAIN_STATE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + while (gc) { + char *sid_binstr = NULL; + uint32_t flags = LWCELL_FLAG_SEARCH_FOREST; + + m = NULL; + + flags |= cell_flags(gc->forest_cell); + + switch (fdata->ftype) { + case SidFilter: + sid_binstr = sid_binstring(&fdata->filter.sid); + BAIL_ON_PTR_ERROR(sid_binstr, nt_status); + + filter = talloc_asprintf(frame, "(objectSid=%s)", sid_binstr); + SAFE_FREE(sid_binstr); + break; + case IdFilter: + filter = build_id_filter(fdata->filter.id.id, + fdata->filter.id.type, flags); + break; + case AliasFilter: + filter = build_alias_filter(fdata->filter.alias, flags); + break; + } + + /* First find the sparse object in GC */ + nt_status = gc_search_forest(gc, &m, filter); + if (!NT_STATUS_IS_OK(nt_status)) { + gc = gc->next; + continue; + } + + nt_status = add_ads_result_to_array(cell_connection(gc->forest_cell), + m, &ads_list, &msg_list, + &num_resp); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + gc = gc->next; + } + + /* Uniqueness check across forests */ + + nt_status = check_result_unique_scoped(ads_list, msg_list, num_resp, + &dn, &user_sid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = search_domain(&domain_cell, &m, dn, &user_sid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Save the connection and results in the return parameters */ + + forest_cell->gc_search_cell = domain_cell; + *msg = m; + +done: + PRINT_NTSTATUS_ERROR(nt_status, "search_forest", 4); + + SAFE_FREE(dn); + + free_result_array(ads_list, msg_list, num_resp); + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS search_cell_list(struct likewise_cell **c, + LDAPMessage **m, + const struct lwcell_filter *fdata) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct likewise_cell *cell = NULL; + LDAPMessage *msg = NULL; + struct likewise_cell *result_cell = NULL; + + if ((cell = cell_list_head()) == NULL) { + nt_status = NT_STATUS_INVALID_SERVER_STATE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + while (cell) { + /* Clear any previous GC search results */ + + cell->gc_search_cell = NULL; + + if (cell_search_forest(cell)) { + nt_status = search_forest(cell, &msg, fdata); + } else { + nt_status = search_cell(cell, &msg, fdata); + } + + /* Always point to the search result cell. + In forests this might be for another domain + which means the schema model may be different */ + + result_cell = cell->gc_search_cell ? + cell->gc_search_cell : cell; + + /* Check if we are done */ + + if (NT_STATUS_IS_OK(nt_status)) { + break; + } + + /* No luck. Free memory and hit the next cell. + Forest searches always set the gc_search_cell + so give preference to that connection if possible. */ + + ads_msgfree(cell_connection(result_cell), msg); + msg = NULL; + + cell = cell->next; + } + + /* This might be assigning NULL but that is ok as long as we + give back the proper error code */ + + *c = result_cell; + *m = msg; + +done: + PRINT_NTSTATUS_ERROR(nt_status, "search_cell_list", 3); + + return nt_status; +} + +/******************************************************************** + Pull the SID from an object which is always stored in the keywords + attribute as "backLink=S-1-5-21-..." + *******************************************************************/ + +static NTSTATUS pull_sid(struct likewise_cell *c, + LDAPMessage *msg, + DOM_SID *sid) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + TALLOC_CTX *frame = talloc_stackframe(); + ADS_STRUCT *ads = NULL; + + ads = cell_connection(c); + + /* + We have two ways of getting the sid: + (a) from the objectSID in case of a GC search, + (b) from backLink in the case of a cell search. + Pull the keywords attributes and grab the backLink. + */ + + if (!ads_pull_sid(ads, msg, "objectSid", sid)) { + char **keywords; + char *s; + size_t num_lines = 0; + + keywords = ads_pull_strings(ads, frame, msg, + "keywords", &num_lines); + BAIL_ON_PTR_ERROR(keywords, nt_status); + + s = find_attr_string(keywords, num_lines, "backLink"); + if (!s) { + nt_status = NT_STATUS_INTERNAL_DB_CORRUPTION; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + if (!string_to_sid(sid, s)) { + nt_status = NT_STATUS_INVALID_SID; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + } + + nt_status = NT_STATUS_OK; + +done: + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS get_object_type(struct likewise_cell *c, + LDAPMessage *msg, + enum id_type *type) +{ + TALLOC_CTX *ctx = talloc_stackframe(); + char **oc_list = NULL; + NTSTATUS nt_status = NT_STATUS_OK; + size_t list_size = 0; + char *s = NULL; + ADS_STRUCT *ads = NULL; + + ads = cell_connection(c); + + /* Deal with RFC 2307 support first */ + + if (cell_flags(c) & LWCELL_FLAG_USE_RFC2307_ATTRS) { + oc_list = ads_pull_strings(ads, ctx, msg, + "objectClass", &list_size); + if (!oc_list) { + nt_status = NT_STATUS_INTERNAL_DB_CORRUPTION; + goto done; + } + + /* Check for posix classes and AD classes */ + + if (is_object_class(oc_list, list_size, ADEX_OC_POSIX_USER) + || is_object_class(oc_list, list_size, AD_USER)) { + *type = ID_TYPE_UID; + } else if (is_object_class(oc_list, list_size, ADEX_OC_POSIX_GROUP) + || is_object_class(oc_list, list_size, AD_GROUP)) { + *type = ID_TYPE_GID; + } else { + *type = ID_TYPE_NOT_SPECIFIED; + nt_status = NT_STATUS_INVALID_PARAMETER; + } + } else { + /* Default to non-schema mode */ + + oc_list = ads_pull_strings(ads, ctx, msg, + "keywords", &list_size); + if (!oc_list) { + nt_status = NT_STATUS_INTERNAL_DB_CORRUPTION; + goto done; + } + + s = find_attr_string(oc_list, list_size, "objectClass"); + if (!s) { + nt_status = NT_STATUS_INTERNAL_DB_CORRUPTION; + goto done; + } + + if (strequal(s, ADEX_OC_USER)) { + *type = ID_TYPE_UID; + } else if (strequal(s, ADEX_OC_GROUP)) { + *type = ID_TYPE_GID; + } else { + *type = ID_TYPE_NOT_SPECIFIED; + nt_status = NT_STATUS_INVALID_PARAMETER; + } + } + + nt_status = NT_STATUS_OK; + +done: + talloc_destroy(ctx); + + return nt_status; +} + +/******************************************************************** + Pull an attribute uint32_t value + *******************************************************************/ + +static NTSTATUS get_object_uint32(struct likewise_cell *c, + LDAPMessage *msg, + const char *attrib, + uint32_t *x) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char **keywords = NULL; + size_t list_size = 0; + TALLOC_CTX *frame = talloc_stackframe(); + ADS_STRUCT *ads = NULL; + + ads = cell_connection(c); + + /* Deal with RFC2307 schema */ + + if (cell_flags(c) & LWCELL_FLAG_USE_RFC2307_ATTRS) { + if (!ads_pull_uint32(ads, msg, attrib, x)) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + } else { + /* Non-schema mode */ + char *s = NULL; + uint32_t num; + + keywords = ads_pull_strings(ads, frame, msg, "keywords", + &list_size); + BAIL_ON_PTR_ERROR(keywords, nt_status); + + s = find_attr_string(keywords, list_size, attrib); + if (!s) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + num = strtoll(s, NULL, 10); + if (errno == ERANGE) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + *x = num; + } + + nt_status = NT_STATUS_OK; + +done: + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS get_object_id(struct likewise_cell *c, + LDAPMessage *msg, + enum id_type type, + uint32_t *id) +{ + NTSTATUS nt_status = NT_STATUS_OK; + const char *id_attr; + + /* Figure out which attribute we need to pull */ + + switch (type) { + case ID_TYPE_UID: + id_attr = ADEX_ATTR_UIDNUM; + break; + case ID_TYPE_GID: + id_attr = ADEX_ATTR_GIDNUM; + break; + default: + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + break; + } + + nt_status = get_object_uint32(c, msg, id_attr, id); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + return nt_status; +} + +/******************************************************************** + Pull the uid/gid and type from an object. This differs depending on + the cell flags. + *******************************************************************/ + +static NTSTATUS pull_id(struct likewise_cell *c, + LDAPMessage *msg, + uint32_t *id, + enum id_type *type) +{ + NTSTATUS nt_status; + + nt_status = get_object_type(c, msg, type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = get_object_id(c, msg, *type, id); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + return nt_status; +} + +/******************************************************************** + Pull an attribute string value + *******************************************************************/ + +static NTSTATUS get_object_string(struct likewise_cell *c, + LDAPMessage *msg, + TALLOC_CTX *ctx, + const char *attrib, + char **string) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char **keywords = NULL; + size_t list_size = 0; + TALLOC_CTX *frame = talloc_stackframe(); + ADS_STRUCT *ads = NULL; + + *string = NULL; + + ads = cell_connection(c); + + /* Deal with RFC2307 schema */ + + if (cell_flags(c) & LWCELL_FLAG_USE_RFC2307_ATTRS) { + *string = ads_pull_string(ads, ctx, msg, attrib); + } else { + /* Non-schema mode */ + + char *s = NULL; + + keywords = ads_pull_strings(ads, frame, msg, + "keywords", &list_size); + if (!keywords) { + nt_status = NT_STATUS_NO_MEMORY; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + s = find_attr_string(keywords, list_size, attrib); + if (s) { + *string = talloc_strdup(ctx, s); + } + } + + if (!*string) { + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = NT_STATUS_OK; + +done: + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + Pull the struct passwd fields for a user + *******************************************************************/ + +static NTSTATUS pull_nss_info(struct likewise_cell *c, + LDAPMessage *msg, + TALLOC_CTX *ctx, + char **homedir, + char **shell, + char **gecos, + gid_t *p_gid) +{ + NTSTATUS nt_status; + + nt_status = get_object_string(c, msg, ctx, ADEX_ATTR_HOMEDIR, homedir); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = get_object_string(c, msg, ctx, ADEX_ATTR_SHELL, shell); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = get_object_string(c, msg, ctx, ADEX_ATTR_GECOS, gecos); + /* Gecos is often not set so ignore failures */ + + nt_status = get_object_uint32(c, msg, ADEX_ATTR_GIDNUM, p_gid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + return nt_status; +} + +/******************************************************************** + Pull the struct passwd fields for a user + *******************************************************************/ + +static NTSTATUS pull_alias(struct likewise_cell *c, + LDAPMessage *msg, + TALLOC_CTX *ctx, + char **alias) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + enum id_type type; + const char *attr = NULL; + + /* Figure out if this is a user or a group */ + + nt_status = get_object_type(c, msg, &type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + switch (type) { + case ID_TYPE_UID: + attr = ADEX_ATTR_UID; + break; + case ID_TYPE_GID: + /* What is the group attr for RFC2307 Forests? */ + attr = ADEX_ATTR_DISPLAYNAME; + break; + default: + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + break; + } + + nt_status = get_object_string(c, msg, ctx, attr, alias); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS _ccp_get_sid_from_id(DOM_SID * sid, + uint32_t id, enum id_type type) +{ + struct likewise_cell *cell = NULL; + LDAPMessage *msg = NULL; + NTSTATUS nt_status; + struct lwcell_filter filter; + + filter.ftype = IdFilter; + filter.filter.id.id = id; + filter.filter.id.type = type; + + nt_status = search_cell_list(&cell, &msg, &filter); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = pull_sid(cell, msg, sid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + ads_msgfree(cell->conn, msg); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS _ccp_get_id_from_sid(uint32_t * id, + enum id_type *type, + const DOM_SID * sid) +{ + struct likewise_cell *cell = NULL; + LDAPMessage *msg = NULL; + NTSTATUS nt_status; + struct lwcell_filter filter; + + filter.ftype = SidFilter; + sid_copy(&filter.filter.sid, sid); + + nt_status = search_cell_list(&cell, &msg, &filter); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = pull_id(cell, msg, id, type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (*id < min_id_value()) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + +done: + ads_msgfree(cell->conn, msg); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +static NTSTATUS _ccp_nss_get_info(const DOM_SID * sid, + TALLOC_CTX * ctx, + char **homedir, + char **shell, + char **gecos, gid_t * p_gid) +{ + struct likewise_cell *cell = NULL; + LDAPMessage *msg = NULL; + NTSTATUS nt_status; + struct lwcell_filter filter; + enum id_type type; + + filter.ftype = SidFilter; + sid_copy(&filter.filter.sid, sid); + + nt_status = search_cell_list(&cell, &msg, &filter); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = get_object_type(cell, msg, &type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (type != ID_TYPE_UID) { + nt_status = NT_STATUS_NO_SUCH_USER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + nt_status = pull_nss_info(cell, msg, ctx, homedir, shell, gecos, + (uint32_t*) p_gid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + ads_msgfree(cell->conn, msg); + + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS _ccp_map_to_alias(TALLOC_CTX *ctx, + const char *domain, + const char *name, char **alias) +{ + TALLOC_CTX *frame = talloc_stackframe(); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + DOM_SID sid; + struct likewise_cell *cell = NULL; + LDAPMessage *msg = NULL; + struct lwcell_filter filter; + enum lsa_SidType sid_type; + + /* Convert the name to a SID */ + + nt_status = gc_name_to_sid(domain, name, &sid, &sid_type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Find the user/group */ + + filter.ftype = SidFilter; + sid_copy(&filter.filter.sid, &sid); + + nt_status = search_cell_list(&cell, &msg, &filter); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Pull the alias and return */ + + nt_status = pull_alias(cell, msg, ctx, alias); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + PRINT_NTSTATUS_ERROR(nt_status, "map_to_alias", 3); + + talloc_destroy(frame); + ads_msgfree(cell_connection(cell), msg); + + return nt_status; +} + +/********************************************************************** + Map from an alias name to the canonical, qualified name. + Ensure that the alias is only pull from the closest in which + the user or gorup is enabled in + *********************************************************************/ + +static NTSTATUS _ccp_map_from_alias(TALLOC_CTX *mem_ctx, + const char *domain, + const char *alias, char **name) +{ + TALLOC_CTX *frame = talloc_stackframe(); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + DOM_SID sid; + struct likewise_cell *cell_alias = NULL; + LDAPMessage *msg_alias = NULL; + struct likewise_cell *cell_sid = NULL; + LDAPMessage *msg_sid = NULL; + struct lwcell_filter filter; + char *canonical_name = NULL; + enum lsa_SidType type; + + /* Find the user/group */ + + filter.ftype = AliasFilter; + fstrcpy(filter.filter.alias, alias); + + nt_status = search_cell_list(&cell_alias, &msg_alias, &filter); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + nt_status = pull_sid(cell_alias, msg_alias, &sid); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + /* Now search again for the SID according to the cell list. + Verify that the cell of both search results is the same + so that we only match an alias from the closest cell + in which a user/group has been instantied. */ + + filter.ftype = SidFilter; + sid_copy(&filter.filter.sid, &sid); + + nt_status = search_cell_list(&cell_sid, &msg_sid, &filter); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (cell_alias != cell_sid) { + nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Finally do the GC sid/name conversion */ + + nt_status = gc_sid_to_name(&sid, &canonical_name, &type); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + *name = talloc_strdup(mem_ctx, canonical_name); + BAIL_ON_PTR_ERROR((*name), nt_status); + + nt_status = NT_STATUS_OK; + +done: + PRINT_NTSTATUS_ERROR(nt_status, "map_from_alias", 3); + + ads_msgfree(cell_connection(cell_alias), msg_alias); + ads_msgfree(cell_connection(cell_sid), msg_sid); + + SAFE_FREE(canonical_name); + + talloc_destroy(frame); + + return nt_status; +} + +/******************************************************************** + *******************************************************************/ + +struct cell_provider_api ccp_unified = { + .get_sid_from_id = _ccp_get_sid_from_id, + .get_id_from_sid = _ccp_get_id_from_sid, + .get_nss_info = _ccp_nss_get_info, + .map_to_alias = _ccp_map_to_alias, + .map_from_alias = _ccp_map_from_alias +}; diff --git a/source3/winbindd/idmap_hash/idmap_hash.c b/source3/winbindd/idmap_hash/idmap_hash.c new file mode 100644 index 0000000000..a050f99bc8 --- /dev/null +++ b/source3/winbindd/idmap_hash/idmap_hash.c @@ -0,0 +1,393 @@ +/* + * idmap_hash.c + * + * Copyright (C) Gerald Carter 2007 - 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 . + * + */ + +#include "includes.h" +#include "winbindd/winbindd.h" +#include "idmap_hash.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_IDMAP + +struct sid_hash_table { + DOM_SID *sid; +}; + +struct sid_hash_table *hashed_domains = NULL; + +/********************************************************************* + Hash a domain SID (S-1-5-12-aaa-bbb-ccc) to a 12bit number + ********************************************************************/ + +static uint32_t hash_domain_sid(const DOM_SID *sid) +{ + uint32_t hash; + + if (sid->num_auths != 4) + return 0; + + /* XOR the last three subauths */ + + hash = ((sid->sub_auths[1] ^ sid->sub_auths[2]) ^ sid->sub_auths[3]); + + /* Take all 32-bits into account when generating the 12-bit + hash value */ + hash = (((hash & 0xFFF00000) >> 20) + + ((hash & 0x000FFF00) >> 8) + + (hash & 0x000000FF)) & 0x0000FFF; + + /* return a 12-bit hash value */ + + return hash; +} + +/********************************************************************* + Hash a Relative ID to a 20 bit number + ********************************************************************/ + +static uint32_t hash_rid(uint32_t rid) +{ + /* 20 bits for the rid which allows us to support + the first 100K users/groups in a domain */ + + return (rid & 0x0007FFFF); +} + +/********************************************************************* + ********************************************************************/ + +static uint32_t combine_hashes(uint32_t h_domain, + uint32_t h_rid) +{ + uint32_t return_id = 0; + + /* shift the hash_domain 19 bits to the left and OR with the + hash_rid */ + + return_id = ((h_domain<<19) | h_rid); + + return return_id; +} + +/********************************************************************* + ********************************************************************/ + +static void separate_hashes(uint32_t id, + uint32_t *h_domain, + uint32_t *h_rid) +{ + *h_rid = id & 0x0007FFFF; + *h_domain = (id & 0x7FF80000) >> 19; + + return; +} + + +/********************************************************************* + ********************************************************************/ + +static NTSTATUS be_init(struct idmap_domain *dom, + const char *params) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + struct winbindd_tdc_domain *dom_list = NULL; + size_t num_domains = 0; + int i; + + /* If the domain SID hash talbe has been initialized, assume + that we completed this function previously */ + + if ( hashed_domains ) { + nt_status = NT_STATUS_OK; + goto done; + } + + if (!wcache_tdc_fetch_list(&dom_list, &num_domains)) { + nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* Create the hash table of domain SIDs */ + + hashed_domains = TALLOC_ZERO_ARRAY(NULL, struct sid_hash_table, 4096); + BAIL_ON_PTR_NT_ERROR(hashed_domains, nt_status); + + /* create the hash table of domain SIDs */ + + for (i=0; i %d\n", + dom_list[i].domain_name, + sid_string_dbg(&dom_list[i].sid), + hash)); + + hashed_domains[hash].sid = talloc(hashed_domains, DOM_SID); + sid_copy(hashed_domains[hash].sid, &dom_list[i].sid); + } + +done: + return nt_status; +} + +/********************************************************************* + ********************************************************************/ + +static NTSTATUS unixids_to_sids(struct idmap_domain *dom, + struct id_map **ids) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + int i; + + nt_status = be_init(dom, NULL); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (!ids) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + for (i=0; ids[i]; i++) { + uint32_t h_domain, h_rid; + + ids[i]->status = ID_UNMAPPED; + + separate_hashes(ids[i]->xid.id, &h_domain, &h_rid); + + /* Make sure the caller allocated memor for us */ + + if (!ids[i]->sid) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + /* If the domain hash doesn't find a SID in the table, + skip it */ + + if (!hashed_domains[h_domain].sid) + continue; + + sid_copy(ids[i]->sid, hashed_domains[h_domain].sid); + sid_append_rid(ids[i]->sid, h_rid); + ids[i]->status = ID_MAPPED; + } + +done: + return nt_status; +} + +/********************************************************************* + ********************************************************************/ + +static NTSTATUS sids_to_unixids(struct idmap_domain *dom, + struct id_map **ids) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + int i; + + nt_status = be_init(dom, NULL); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (!ids) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + for (i=0; ids[i]; i++) { + DOM_SID sid; + uint32_t rid; + uint32_t h_domain, h_rid; + + ids[i]->status = ID_UNMAPPED; + + sid_copy(&sid, ids[i]->sid); + sid_split_rid(&sid, &rid); + + h_domain = hash_domain_sid(&sid); + h_rid = hash_rid(rid); + + /* Check that both hashes are non-zero*/ + + if (h_domain && h_rid) { + ids[i]->xid.id = combine_hashes(h_domain, h_rid); + ids[i]->status = ID_MAPPED; + } + } + +done: + return nt_status; +} + +/********************************************************************* + ********************************************************************/ + +static NTSTATUS be_close(struct idmap_domain *dom) +{ + if (hashed_domains) + talloc_free(hashed_domains); + + return NT_STATUS_OK; +} + +/********************************************************************* + ********************************************************************/ + +static NTSTATUS nss_hash_init(struct nss_domain_entry *e ) +{ + return be_init(NULL, NULL); +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_hash_get_info(struct nss_domain_entry *e, + const DOM_SID *sid, + TALLOC_CTX *ctx, + ADS_STRUCT *ads, + LDAPMessage *msg, + char **homedir, + char **shell, + char **gecos, + gid_t *p_gid ) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + + nt_status = nss_hash_init(e); + BAIL_ON_NTSTATUS_ERROR(nt_status); + + if (!homedir || !shell || !gecos) { + nt_status = NT_STATUS_INVALID_PARAMETER; + BAIL_ON_NTSTATUS_ERROR(nt_status); + } + + *homedir = talloc_strdup(ctx, lp_template_homedir()); + BAIL_ON_PTR_NT_ERROR(*homedir, nt_status); + + *shell = talloc_strdup(ctx, lp_template_shell()); + BAIL_ON_PTR_NT_ERROR(*shell, nt_status); + + *gecos = NULL; + + /* Initialize the gid so that the upper layer fills + in the proper Windows primary group */ + + if (*p_gid) { + *p_gid = (gid_t)-1; + } + +done: + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_hash_map_to_alias(TALLOC_CTX *mem_ctx, + const char *domain, + const char *name, + char **alias) +{ + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + const char *value; + + value = talloc_asprintf(mem_ctx, "%s\\%s", domain, name); + BAIL_ON_PTR_NT_ERROR(value, nt_status); + + nt_status = mapfile_lookup_key(mem_ctx, value, alias); + BAIL_ON_NTSTATUS_ERROR(nt_status); + +done: + return nt_status; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_hash_map_from_alias(TALLOC_CTX *mem_ctx, + const char *domain, + const char *alias, + char **name) +{ + return mapfile_lookup_value(mem_ctx, alias, name); +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_hash_close(void) +{ + return NT_STATUS_OK; +} + +/********************************************************************* + Dispatch Tables for IDMap and NssInfo Methods +********************************************************************/ + +static struct idmap_methods hash_idmap_methods = { + .init = be_init, + .unixids_to_sids = unixids_to_sids, + .sids_to_unixids = sids_to_unixids, + .close_fn = be_close +}; + +static struct nss_info_methods hash_nss_methods = { + .init = nss_hash_init, + .get_nss_info = nss_hash_get_info, + .map_to_alias = nss_hash_map_to_alias, + .map_from_alias = nss_hash_map_from_alias, + .close_fn = nss_hash_close +}; + +/********************************************************************** + Register with the idmap and idmap_nss subsystems. We have to protect + against the idmap and nss_info interfaces being in a half-registered + state. + **********************************************************************/ + +NTSTATUS idmap_hash_init(void) +{ + static NTSTATUS idmap_status = NT_STATUS_UNSUCCESSFUL; + static NTSTATUS nss_status = NT_STATUS_UNSUCCESSFUL; + + if ( !NT_STATUS_IS_OK(idmap_status) ) { + idmap_status = smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, + "hash", &hash_idmap_methods); + + if ( !NT_STATUS_IS_OK(idmap_status) ) { + DEBUG(0,("Failed to register hash idmap plugin.\n")); + return idmap_status; + } + } + + if ( !NT_STATUS_IS_OK(nss_status) ) { + nss_status = smb_register_idmap_nss(SMB_NSS_INFO_INTERFACE_VERSION, + "hash", &hash_nss_methods); + if ( !NT_STATUS_IS_OK(nss_status) ) { + DEBUG(0,("Failed to register hash idmap nss plugin.\n")); + return nss_status; + } + } + + return NT_STATUS_OK; +} diff --git a/source3/winbindd/idmap_hash/idmap_hash.h b/source3/winbindd/idmap_hash/idmap_hash.h new file mode 100644 index 0000000000..621520e950 --- /dev/null +++ b/source3/winbindd/idmap_hash/idmap_hash.h @@ -0,0 +1,60 @@ +/* + * lwopen.h + * + * Copyright (C) Gerald Carter + * + * 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 . + * + */ + +#ifndef _LWOPEN_H +#define _LWOPEN_H + +#define BAIL_ON_NTSTATUS_ERROR(x) \ + do { \ + if (!NT_STATUS_IS_OK(x)) { \ + DEBUG(10,("Failed! (%s)\n", nt_errstr(x))); \ + goto done; \ + } \ + } \ + while (0); \ + +#define BAIL_ON_PTR_NT_ERROR(p, x) \ + do { \ + if ((p) == NULL ) { \ + DEBUG(10,("NULL pointer!\n")); \ + x = NT_STATUS_NO_MEMORY; \ + goto done; \ + } else { \ + x = NT_STATUS_OK; \ + } \ + } while (0); + +#define PRINT_NTSTATUS_ERROR(x, hdr, level) \ + do { \ + if (!NT_STATUS_IS_OK(x)) { \ + DEBUG(level,("Likewise Open ("hdr"): %s\n", nt_errstr(x))); \ + } \ + } while(0); + + +NTSTATUS mapfile_lookup_key(TALLOC_CTX *ctx, + const char *value, + char **key); + +NTSTATUS mapfile_lookup_value(TALLOC_CTX *ctx, + const char *key, + char **value); + +#endif /* _LWOPEN_H */ diff --git a/source3/winbindd/idmap_hash/mapfile.c b/source3/winbindd/idmap_hash/mapfile.c new file mode 100644 index 0000000000..5ab1142ffe --- /dev/null +++ b/source3/winbindd/idmap_hash/mapfile.c @@ -0,0 +1,175 @@ +/* + * mapfile.c + * + * Copyright (C) Gerald Carter + * + * 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 . + * + */ + +#include "includes.h" +#include "winbindd/winbindd.h" +#include "idmap_hash.h" +#include + +XFILE *lw_map_file = NULL; + +/********************************************************************* + ********************************************************************/ + +static bool mapfile_open(void) +{ + const char *mapfile_name = NULL; + + /* If we have an open handle, just reset it */ + + if (lw_map_file) { + return (x_tseek(lw_map_file, 0, SEEK_SET) == 0); + } + + mapfile_name = lp_parm_const_string(-1, "idmap_hash", "name_map", NULL); + if (!mapfile_name) { + return false; + } + + lw_map_file = x_fopen(mapfile_name, O_RDONLY, 0); + if (!lw_map_file) { + DEBUG(0,("can't open idmap_hash:name_map (%s). Error %s\n", + mapfile_name, strerror(errno) )); + return false; + } + + return true; +} + +/********************************************************************* + ********************************************************************/ + +static bool mapfile_read_line(fstring key, fstring value) +{ + char buffer[1024]; + char *p; + int len; + + if (!lw_map_file) + return false; + + if ((p = x_fgets(buffer, sizeof(buffer)-1, lw_map_file)) == NULL) { + return false; + } + + /* Strip newlines and carriage returns */ + + len = strlen_m(buffer) - 1; + while ((buffer[len] == '\n') || (buffer[len] == '\r')) { + buffer[len--] = '\0'; + } + + + if ((p = strchr_m(buffer, '=')) == NULL ) { + DEBUG(0,("idmap_hash: Bad line in name_map (%s)\n", buffer)); + return false; + } + + *p = '\0'; + p++; + + fstrcpy(key, buffer); + fstrcpy(value, p); + + /* Eat whitespace */ + + if (!trim_char(key, ' ', ' ')) + return false; + + if (!trim_char(value, ' ', ' ')) + return false; + + return true; +} + +/********************************************************************* + ********************************************************************/ + +static bool mapfile_close(void) +{ + int ret = 0; + if (lw_map_file) { + ret = x_fclose(lw_map_file); + lw_map_file = NULL; + } + + return (ret == 0); +} + + +/********************************************************************* + ********************************************************************/ + +NTSTATUS mapfile_lookup_key(TALLOC_CTX *ctx, const char *value, char **key) +{ + fstring r_key, r_value; + NTSTATUS ret = NT_STATUS_NOT_FOUND; + + if (!mapfile_open()) + return NT_STATUS_OBJECT_PATH_NOT_FOUND; + + while (mapfile_read_line(r_key, r_value)) + { + if (strequal(r_value, value)) { + ret = NT_STATUS_OK; + + /* We're done once finishing this block */ + *key = talloc_strdup(ctx, r_key); + if (!*key) { + ret = NT_STATUS_NO_MEMORY; + } + break; + } + } + + mapfile_close(); + + return ret; +} + +/********************************************************************* + ********************************************************************/ + +NTSTATUS mapfile_lookup_value(TALLOC_CTX *ctx, const char *key, char **value) +{ + fstring r_key, r_value; + NTSTATUS ret = NT_STATUS_NOT_FOUND; + + if (!mapfile_open()) + return NT_STATUS_OBJECT_PATH_NOT_FOUND; + + while (mapfile_read_line(r_key, r_value)) + { + if (strequal(r_key, key)) { + ret = NT_STATUS_OK; + + /* We're done once finishing this block */ + *value = talloc_strdup(ctx, r_value); + if (!*key) { + ret = NT_STATUS_NO_MEMORY; + } + break; + } + } + + mapfile_close(); + + return ret; +} diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c index 9e66eed0c8..f9d3a9fbff 100644 --- a/source3/winbindd/idmap_tdb.c +++ b/source3/winbindd/idmap_tdb.c @@ -228,7 +228,7 @@ static NTSTATUS idmap_tdb_open_db(TALLOC_CTX *memctx, TDB_CONTEXT **tdbctx) goto done; } - if (!file_exist(tdbfile, &stbuf)) { + if (!file_exist_stat(tdbfile, &stbuf)) { tdb_is_new = True; } diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c index 3066db6f3b..8bde963c60 100644 --- a/source3/winbindd/idmap_tdb2.c +++ b/source3/winbindd/idmap_tdb2.c @@ -94,12 +94,11 @@ static NTSTATUS idmap_tdb2_open_db(void) */ static NTSTATUS idmap_tdb2_alloc_load(void) { - const char *range; uid_t low_uid = 0; uid_t high_uid = 0; gid_t low_gid = 0; gid_t high_gid = 0; - uint32 low_id, high_id; + uint32 low_id; /* see if a idmap script is configured */ idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap", @@ -187,6 +186,10 @@ static NTSTATUS idmap_tdb2_allocate_id(struct unixid *xid) uint32_t high_hwm; uint32_t hwm; int res; + NTSTATUS status; + + status = idmap_tdb2_open_db(); + NT_STATUS_NOT_OK_RETURN(status); /* Get current high water mark */ switch (xid->type) { @@ -264,6 +267,10 @@ static NTSTATUS idmap_tdb2_get_hwm(struct unixid *xid) const char *hwmtype; uint32_t hwm; uint32_t high_hwm; + NTSTATUS status; + + status = idmap_tdb2_open_db(); + NT_STATUS_NOT_OK_RETURN(status); /* Get current high water mark */ switch (xid->type) { @@ -451,6 +458,10 @@ static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_tdb2_context *ctx, struct id_m NTSTATUS ret; TDB_DATA data; char *keystr; + NTSTATUS status; + + status = idmap_tdb2_open_db(); + NT_STATUS_NOT_OK_RETURN(status); if (!ctx || !map) { return NT_STATUS_INVALID_PARAMETER; @@ -546,6 +557,10 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m TDB_DATA data; char *keystr; unsigned long rec_id = 0; + NTSTATUS status; + + status = idmap_tdb2_open_db(); + NT_STATUS_NOT_OK_RETURN(status); if ((keystr = sid_string_talloc(ctx, map->sid)) == NULL) { DEBUG(0, ("Out of memory!\n")); diff --git a/source3/winbindd/idmap_util.c b/source3/winbindd/idmap_util.c index b10a1a4ba9..9f876618be 100644 --- a/source3/winbindd/idmap_util.c +++ b/source3/winbindd/idmap_util.c @@ -121,7 +121,7 @@ backend: return NT_STATUS_NONE_MAPPED; } - idmap_cache_set_sid2uid(sid, gid); + idmap_cache_set_sid2gid(sid, gid); return NT_STATUS_OK; } diff --git a/source3/winbindd/nss_info.c b/source3/winbindd/nss_info.c index daa3dd037d..0e8cb60257 100644 --- a/source3/winbindd/nss_info.c +++ b/source3/winbindd/nss_info.c @@ -278,6 +278,47 @@ static struct nss_domain_entry *find_nss_domain( const char *domain ) homedir, shell, gecos, p_gid ); } +/******************************************************************** + *******************************************************************/ + + NTSTATUS nss_map_to_alias( TALLOC_CTX *mem_ctx, const char *domain, + const char *name, char **alias ) +{ + struct nss_domain_entry *p; + struct nss_info_methods *m; + + if ( (p = find_nss_domain( domain )) == NULL ) { + DEBUG(4,("nss_map_to_alias: Failed to find nss domain pointer for %s\n", + domain )); + return NT_STATUS_NOT_FOUND; + } + + m = p->backend->methods; + + return m->map_to_alias( mem_ctx, domain, name, alias ); +} + + +/******************************************************************** + *******************************************************************/ + + NTSTATUS nss_map_from_alias( TALLOC_CTX *mem_ctx, const char *domain, + const char *alias, char **name ) +{ + struct nss_domain_entry *p; + struct nss_info_methods *m; + + if ( (p = find_nss_domain( domain )) == NULL ) { + DEBUG(4,("nss_map_from_alias: Failed to find nss domain pointer for %s\n", + domain )); + return NT_STATUS_NOT_FOUND; + } + + m = p->backend->methods; + + return m->map_from_alias( mem_ctx, domain, alias, name ); +} + /******************************************************************** *******************************************************************/ diff --git a/source3/winbindd/nss_info_template.c b/source3/winbindd/nss_info_template.c index aaf02e4abe..d8f903ddd0 100644 --- a/source3/winbindd/nss_info_template.c +++ b/source3/winbindd/nss_info_template.c @@ -45,6 +45,8 @@ static NTSTATUS nss_template_get_info( struct nss_domain_entry *e, if ( !homedir || !shell || !gecos ) return NT_STATUS_INVALID_PARAMETER; + /* protect against home directories using whitespace in the + username */ *homedir = talloc_strdup( ctx, lp_template_homedir() ); *shell = talloc_strdup( ctx, lp_template_shell() ); *gecos = NULL; @@ -56,6 +58,28 @@ static NTSTATUS nss_template_get_info( struct nss_domain_entry *e, return NT_STATUS_OK; } +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_template_map_to_alias( TALLOC_CTX *mem_ctx, + const char *domain, + const char *name, + char **alias ) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + +/********************************************************************** + *********************************************************************/ + +static NTSTATUS nss_template_map_from_alias( TALLOC_CTX *mem_ctx, + const char *domain, + const char *alias, + char **name ) +{ + return NT_STATUS_NOT_IMPLEMENTED; +} + /************************************************************************ ***********************************************************************/ @@ -69,9 +93,11 @@ static NTSTATUS nss_template_close( void ) ***********************************************************************/ static struct nss_info_methods nss_template_methods = { - .init = nss_template_init, - .get_nss_info = nss_template_get_info, - .close_fn = nss_template_close + .init = nss_template_init, + .get_nss_info = nss_template_get_info, + .map_to_alias = nss_template_map_to_alias, + .map_from_alias = nss_template_map_from_alias, + .close_fn = nss_template_close }; NTSTATUS nss_info_template_init( void ) diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 44b5415726..5d4f21a820 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -66,7 +66,7 @@ static bool reload_services_file(const char *logfile) if (lp_loaded()) { const char *fname = lp_configfile(); - if (file_exist(fname,NULL) && !strcsequal(fname,get_dyn_CONFIGFILE())) { + if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); } } @@ -1120,7 +1120,7 @@ int main(int argc, char **argv, char **envp) exit(1); } - if (!directory_exist(lp_lockdir(), NULL)) { + if (!directory_exist(lp_lockdir())) { mkdir(lp_lockdir(), 0755); } diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c index 894e7866b3..1febddf110 100644 --- a/source3/winbindd/winbindd_ads.c +++ b/source3/winbindd/winbindd_ads.c @@ -1023,10 +1023,11 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, DEBUG(10,("ads: lookup_groupmem: got sid %s from " "cache\n", sid_string_dbg(&sid))); sid_copy(&(*sid_mem)[*num_names], &sid); - (*names)[*num_names] = talloc_asprintf(*names, "%s%c%s", - domain_name, - *lp_winbind_separator(), - name ); + (*names)[*num_names] = fill_domain_username_talloc( + *names, + domain_name, + name, + true); (*name_types)[*num_names] = name_type; (*num_names)++; @@ -1071,11 +1072,12 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, { sid_copy(&(*sid_mem)[*num_names], &sid_mem_nocache[i]); - (*names)[*num_names] = talloc_asprintf( *names, - "%s%c%s", - domains_nocache[i], - *lp_winbind_separator(), - names_nocache[i] ); + (*names)[*num_names] = + fill_domain_username_talloc( + *names, + domains_nocache[i], + names_nocache[i], + true); (*name_types)[*num_names] = name_types_nocache[i]; (*num_names)++; } diff --git a/source3/winbindd/winbindd_async.c b/source3/winbindd/winbindd_async.c index 1481aed8e1..7500bcbe5b 100644 --- a/source3/winbindd/winbindd_async.c +++ b/source3/winbindd/winbindd_async.c @@ -366,7 +366,7 @@ static void lookupname_recv(TALLOC_CTX *mem_ctx, bool success, /******************************************************************** The lookup name call first contacts a DC in its own domain - and fallbacks to contact a DC in the forest in our domain doesn't + and fallbacks to contact a DC if the forest in our domain doesn't know the name. ********************************************************************/ diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 2fbb01b623..360e915bc4 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -934,6 +934,8 @@ static void wcache_save_lockout_policy(struct winbindd_domain *domain, centry_free(centry); } + + static void wcache_save_password_policy(struct winbindd_domain *domain, NTSTATUS status, struct samr_DomInfo1 *policy) @@ -957,6 +959,209 @@ static void wcache_save_password_policy(struct winbindd_domain *domain, centry_free(centry); } +/*************************************************************************** + ***************************************************************************/ + +static void wcache_save_username_alias(struct winbindd_domain *domain, + NTSTATUS status, + const char *name, const char *alias) +{ + struct cache_entry *centry; + fstring uname; + + if ( (centry = centry_start(domain, status)) == NULL ) + return; + + centry_put_string( centry, alias ); + + fstrcpy(uname, name); + strupper_m(uname); + centry_end(centry, "NSS/NA/%s", uname); + + DEBUG(10,("wcache_save_username_alias: %s -> %s\n", name, alias )); + + centry_free(centry); +} + +static void wcache_save_alias_username(struct winbindd_domain *domain, + NTSTATUS status, + const char *alias, const char *name) +{ + struct cache_entry *centry; + fstring uname; + + if ( (centry = centry_start(domain, status)) == NULL ) + return; + + centry_put_string( centry, name ); + + fstrcpy(uname, alias); + strupper_m(uname); + centry_end(centry, "NSS/AN/%s", uname); + + DEBUG(10,("wcache_save_alias_username: %s -> %s\n", alias, name )); + + centry_free(centry); +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS resolve_username_to_alias( TALLOC_CTX *mem_ctx, + struct winbindd_domain *domain, + const char *name, char **alias ) +{ + struct winbind_cache *cache = get_cache(domain); + struct cache_entry *centry = NULL; + NTSTATUS status; + char *upper_name; + + if ( domain->internal ) + return NT_STATUS_NOT_SUPPORTED; + + if (!cache->tdb) + goto do_query; + + if ( (upper_name = SMB_STRDUP(name)) == NULL ) + return NT_STATUS_NO_MEMORY; + strupper_m(upper_name); + + centry = wcache_fetch(cache, domain, "NSS/NA/%s", upper_name); + + SAFE_FREE( upper_name ); + + if (!centry) + goto do_query; + + status = centry->status; + + if (!NT_STATUS_IS_OK(status)) { + centry_free(centry); + return status; + } + + *alias = centry_string( centry, mem_ctx ); + + centry_free(centry); + + DEBUG(10,("resolve_username_to_alias: [Cached] - mapped %s to %s\n", + name, *alias ? *alias : "(none)")); + + return (*alias) ? NT_STATUS_OK : NT_STATUS_OBJECT_NAME_NOT_FOUND; + +do_query: + + /* If its not in cache and we are offline, then fail */ + + if ( get_global_winbindd_state_offline() || !domain->online ) { + DEBUG(8,("resolve_username_to_alias: rejecting query " + "in offline mode\n")); + return NT_STATUS_NOT_FOUND; + } + + status = nss_map_to_alias( mem_ctx, domain->name, name, alias ); + + if ( NT_STATUS_IS_OK( status ) ) { + wcache_save_username_alias(domain, status, name, *alias); + } + + if ( NT_STATUS_EQUAL( status, NT_STATUS_NONE_MAPPED ) ) { + wcache_save_username_alias(domain, status, name, "(NULL)"); + } + + DEBUG(5,("resolve_username_to_alias: backend query returned %s\n", + nt_errstr(status))); + + if ( NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND) ) { + set_domain_offline( domain ); + } + + return status; +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS resolve_alias_to_username( TALLOC_CTX *mem_ctx, + struct winbindd_domain *domain, + const char *alias, char **name ) +{ + struct winbind_cache *cache = get_cache(domain); + struct cache_entry *centry = NULL; + NTSTATUS status; + char *upper_name; + + if ( domain->internal ) + return NT_STATUS_NOT_SUPPORTED; + + if (!cache->tdb) + goto do_query; + + if ( (upper_name = SMB_STRDUP(alias)) == NULL ) + return NT_STATUS_NO_MEMORY; + strupper_m(upper_name); + + centry = wcache_fetch(cache, domain, "NSS/AN/%s", upper_name); + + SAFE_FREE( upper_name ); + + if (!centry) + goto do_query; + + status = centry->status; + + if (!NT_STATUS_IS_OK(status)) { + centry_free(centry); + return status; + } + + *name = centry_string( centry, mem_ctx ); + + centry_free(centry); + + DEBUG(10,("resolve_alias_to_username: [Cached] - mapped %s to %s\n", + alias, *name ? *name : "(none)")); + + return (*name) ? NT_STATUS_OK : NT_STATUS_OBJECT_NAME_NOT_FOUND; + +do_query: + + /* If its not in cache and we are offline, then fail */ + + if ( get_global_winbindd_state_offline() || !domain->online ) { + DEBUG(8,("resolve_alias_to_username: rejecting query " + "in offline mode\n")); + return NT_STATUS_NOT_FOUND; + } + + /* an alias cannot contain a domain prefix or '@' */ + + if (strchr(alias, '\\') || strchr(alias, '@')) { + DEBUG(10,("resolve_alias_to_username: skipping fully " + "qualified name %s\n", alias)); + return NT_STATUS_OBJECT_NAME_INVALID; + } + + status = nss_map_from_alias( mem_ctx, domain->name, alias, name ); + + if ( NT_STATUS_IS_OK( status ) ) { + wcache_save_alias_username( domain, status, alias, *name ); + } + + if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) { + wcache_save_alias_username(domain, status, alias, "(NULL)"); + } + + DEBUG(5,("resolve_alias_to_username: backend query returned %s\n", + nt_errstr(status))); + + if ( NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND) ) { + set_domain_offline( domain ); + } + + return status; +} + NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const DOM_SID *sid) { struct winbind_cache *cache = get_cache(domain); @@ -3257,6 +3462,48 @@ static int validate_pwinfo(TALLOC_CTX *mem_ctx, const char *keystr, return 0; } +static int validate_nss_an(TALLOC_CTX *mem_ctx, const char *keystr, + TDB_DATA dbuf, + struct tdb_validation_status *state) +{ + struct cache_entry *centry = create_centry_validate(keystr, dbuf, state); + + if (!centry) { + return 1; + } + + (void)centry_string( centry, mem_ctx ); + + centry_free(centry); + + if (!(state->success)) { + return 1; + } + DEBUG(10,("validate_pwinfo: %s ok\n", keystr)); + return 0; +} + +static int validate_nss_na(TALLOC_CTX *mem_ctx, const char *keystr, + TDB_DATA dbuf, + struct tdb_validation_status *state) +{ + struct cache_entry *centry = create_centry_validate(keystr, dbuf, state); + + if (!centry) { + return 1; + } + + (void)centry_string( centry, mem_ctx ); + + centry_free(centry); + + if (!(state->success)) { + return 1; + } + DEBUG(10,("validate_pwinfo: %s ok\n", keystr)); + return 0; +} + static int validate_trustdoms(TALLOC_CTX *mem_ctx, const char *keystr, TDB_DATA dbuf, struct tdb_validation_status *state) { @@ -3358,6 +3605,8 @@ struct key_val_struct { {"NSS/PWINFO/", validate_pwinfo}, {"TRUSTDOMS/", validate_trustdoms}, {"TRUSTDOMCACHE/", validate_trustdomcache}, + {"NSS/NA/", validate_nss_na}, + {"NSS/AN/", validate_nss_an}, {"WINBINDD_OFFLINE", validate_offline}, {WINBINDD_CACHE_VERSION_KEYSTR, validate_cache_version}, {NULL, NULL} diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index ce851649ba..db43101a34 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1080,7 +1080,7 @@ static bool dcip_to_name(TALLOC_CTX *mem_ctx, fstring name ) { struct ip_service ip_list; - uint32_t nt_version = NETLOGON_VERSION_1; + uint32_t nt_version = NETLOGON_NT_VERSION_1; ip_list.ss = *pss; ip_list.port = 0; diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 63ce0e8d7f..994c94b5be 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -120,6 +120,10 @@ void async_request(TALLOC_CTX *mem_ctx, struct winbindd_child *child, SMB_ASSERT(continuation != NULL); + DEBUG(10, ("Sending request to child pid %d (domain=%s)\n", + (int)child->pid, + (child->domain != NULL) ? child->domain->name : "''")); + state = TALLOC_P(mem_ctx, struct winbindd_async_request); if (state == NULL) { @@ -196,10 +200,12 @@ static void async_request_fail(struct winbindd_async_request *state) TALLOC_FREE(state->reply_timeout_event); - SMB_ASSERT(state->child_pid != (pid_t)0); + /* If child exists and is not already reaped, + send kill signal to child. */ - /* If not already reaped, send kill signal to child. */ - if (state->child->pid == state->child_pid) { + if ((state->child->pid != (pid_t)0) && + (state->child->pid != (pid_t)-1) && + (state->child->pid == state->child_pid)) { kill(state->child_pid, SIGTERM); /* @@ -294,13 +300,27 @@ static void schedule_async_request(struct winbindd_child *child) return; /* Busy */ } + /* + * This may be a reschedule, so we might + * have an existing timeout event pending on + * the first entry in the child->requests list + * (we only send one request at a time). + * Ensure we free it before we reschedule. + * Bug #5814, from hargagan . + * JRA. + */ + + TALLOC_FREE(request->reply_timeout_event); + if ((child->pid == 0) && (!fork_domain_child(child))) { - /* Cancel all outstanding requests */ + /* fork_domain_child failed. + Cancel all outstanding requests */ while (request != NULL) { /* request might be free'd in the continuation */ struct winbindd_async_request *next = request->next; - request->continuation(request->private_data, False); + + async_request_fail(request); request = next; } return; @@ -487,6 +507,17 @@ void winbind_child_died(pid_t pid) child->event.flags = 0; child->pid = 0; + if (child->requests) { + /* + * schedule_async_request() will also + * clear this event but the call is + * idempotent so it doesn't hurt to + * cover all possible future code + * paths. JRA. + */ + TALLOC_FREE(child->requests->reply_timeout_event); + } + schedule_async_request(child); } @@ -874,7 +905,7 @@ static bool calculate_next_machine_pwd_change(const char *domain, if (time(NULL) < (pass_last_set_time + timeout)) { next_change = pass_last_set_time + timeout; DEBUG(10,("machine password still valid until: %s\n", - http_timestring(next_change))); + http_timestring(talloc_tos(), next_change))); *t = timeval_set(next_change, 0); return true; } diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c index 4d5026d158..f2b6fbefb5 100644 --- a/source3/winbindd/winbindd_group.c +++ b/source3/winbindd/winbindd_group.c @@ -35,7 +35,11 @@ static void add_member(const char *domain, const char *user, { fstring name; - fill_domain_username(name, domain, user, True); + if (domain != NULL) { + fill_domain_username(name, domain, user, True); + } else { + fstrcpy(name, user); + } safe_strcat(name, ",", sizeof(name)-1); string_append(pp_members, name); *p_num_members += 1; @@ -136,7 +140,7 @@ static void add_expanded_sid(const DOM_SID *sid, continue; } - add_member(domain->name, names[i], pp_members, p_num_members); + add_member(NULL, names[i], pp_members, p_num_members); } done: @@ -179,12 +183,32 @@ static bool fill_passdb_alias_grmem(struct winbindd_domain *domain, /* Fill a grent structure from various other information */ -static bool fill_grent(struct winbindd_gr *gr, const char *dom_name, - const char *gr_name, gid_t unix_gid) +static bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr, + const char *dom_name, + char *gr_name, gid_t unix_gid) { fstring full_group_name; + char *mapped_name = NULL; + struct winbindd_domain *domain = find_domain_from_name_noinit(dom_name); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + + nt_status = normalize_name_map(mem_ctx, domain, gr_name, + &mapped_name); - fill_domain_username( full_group_name, dom_name, gr_name, True ); + /* Basic whitespace replacement */ + if (NT_STATUS_IS_OK(nt_status)) { + fill_domain_username(full_group_name, dom_name, + mapped_name, true); + } + /* Mapped to an aliase */ + else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) { + fstrcpy(full_group_name, mapped_name); + } + /* no change */ + else { + fill_domain_username( full_group_name, dom_name, + gr_name, True ); + } gr->gr_gid = unix_gid; @@ -280,7 +304,10 @@ static bool fill_grent_mem_domusers( TALLOC_CTX *mem_ctx, char *domainname = NULL; char *username = NULL; fstring name; + char *mapped_name = NULL; enum lsa_SidType type; + struct winbindd_domain *target_domain = NULL; + NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL; DEBUG(10,("fill_grent_mem_domain_users: " "sid %s in 'Domain Users' in domain %s\n", @@ -300,7 +327,24 @@ static bool fill_grent_mem_domusers( TALLOC_CTX *mem_ctx, nt_errstr(status))); return False; } - fill_domain_username(name, domain->name, username, True); + + target_domain = find_domain_from_name_noinit(domainname); + name_map_status = normalize_name_map(mem_ctx, target_domain, + username, &mapped_name); + + /* Basic whitespace replacement */ + if (NT_STATUS_IS_OK(name_map_status)) { + fill_domain_username(name, domainname, mapped_name, true); + } + /* Mapped to an alias */ + else if (NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED)) { + fstrcpy(name, mapped_name); + } + /* no mapping done...use original name */ + else { + fill_domain_username(name, domainname, username, true); + } + len = strlen(name); buf_len = len + 1; if (!(buf = (char *)SMB_MALLOC(buf_len))) { @@ -552,6 +596,7 @@ static bool fill_grent_mem(struct winbindd_domain *domain, uint32 n_members = 0; char **members = NULL; NTSTATUS nt_status; + int j; nt_status = expand_groups( mem_ctx, domain, glist, n_glist, @@ -562,13 +607,45 @@ static bool fill_grent_mem(struct winbindd_domain *domain, goto done; } - /* Add new group members to list */ + /* Add new group members to list. Pass through the + alias mapping function */ - nt_status = add_names_to_list( mem_ctx, &names, &num_names, - members, n_members ); - if ( !NT_STATUS_IS_OK(nt_status) ) { - result = False; - goto done; + for (j=0; jrequest.data.groupname[sizeof(state->request.data.groupname)-1]='\0'; @@ -686,11 +764,20 @@ void winbindd_getgrnam(struct winbindd_cli_state *state) DEBUG(3, ("[%5lu]: getgrnam %s\n", (unsigned long)state->pid, state->request.data.groupname)); - /* Parse domain and groupname */ + nt_status = normalize_name_unmap(state->mem_ctx, + state->request.data.groupname, + &tmp); + /* If we didn't map anything in the above call, just reset the + tmp pointer to the original string */ + if (!NT_STATUS_IS_OK(nt_status) && + !NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) + { + tmp = state->request.data.groupname; + } - memset(name_group, 0, sizeof(fstring)); + /* Parse domain and groupname */ - tmp = state->request.data.groupname; + memset(name_group, 0, sizeof(name_group)); name_domain[0] = '\0'; name_group[0] = '\0'; @@ -723,7 +810,7 @@ void winbindd_getgrnam(struct winbindd_cli_state *state) /* Get rid and name type from name */ - ws_name_replace( name_group, WB_REPLACE_CHAR ); + fstrcpy( name_group, tmp ); winbindd_lookupname_async( state->mem_ctx, domain->name, name_group, getgrnam_recv, WINBINDD_GETGRNAM, state ); @@ -771,7 +858,8 @@ static void getgrsid_sid2gid_recv(void *private_data, bool success, gid_t gid) return; } - if (!fill_grent(&s->state->response.data.gr, dom_name, group_name, gid) || + if (!fill_grent(s->state->mem_ctx, &s->state->response.data.gr, + dom_name, group_name, gid) || !fill_grent_mem(domain, s->state, &s->group_sid, s->group_type, &num_gr_mem, &gr_mem, &gr_mem_len)) { @@ -796,6 +884,9 @@ static void getgrsid_lookupsid_recv( void *private_data, bool success, enum lsa_SidType name_type ) { struct getgrsid_state *s = (struct getgrsid_state *)private_data; + char *mapped_name = NULL; + fstring raw_name; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; if (!success) { DEBUG(5,("getgrsid_lookupsid_recv: lookupsid failed!\n")); @@ -814,15 +905,39 @@ static void getgrsid_lookupsid_recv( void *private_data, bool success, dom_name, name, name_type)); request_error(s->state); return; -} + } - if ( (s->group_name = talloc_asprintf( s->state->mem_ctx, - "%s%c%s", - dom_name, - *lp_winbind_separator(), - name)) == NULL ) -{ - DEBUG(1, ("getgrsid_lookupsid_recv: talloc_asprintf() Failed!\n")); + /* normalize the name and ensure that we have the DOM\name + coming out of here */ + + fstrcpy(raw_name, name); + + nt_status = normalize_name_unmap(s->state->mem_ctx, raw_name, + &mapped_name); + + /* basiuc whitespace reversal */ + if (NT_STATUS_IS_OK(nt_status)) { + s->group_name = talloc_asprintf(s->state->mem_ctx, + "%s%c%s", + dom_name, + *lp_winbind_separator(), + mapped_name); + } + /* mapped from alias */ + else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) { + s->group_name = mapped_name; + } + /* no mapping at all. use original string */ + else { + s->group_name = talloc_asprintf(s->state->mem_ctx, + "%s%c%s", + dom_name, + *lp_winbind_separator(), + raw_name); + } + + if (s->group_name == NULL) { + DEBUG(1, ("getgrsid_lookupsid_recv: group_name is NULL!\n")); request_error(s->state); return; } @@ -831,10 +946,10 @@ static void getgrsid_lookupsid_recv( void *private_data, bool success, winbindd_sid2gid_async(s->state->mem_ctx, &s->group_sid, getgrsid_sid2gid_recv, s); - } +} static void winbindd_getgrsid( struct winbindd_cli_state *state, const DOM_SID group_sid ) - { +{ struct getgrsid_state *s; if ( (s = TALLOC_ZERO_P(state->mem_ctx, struct getgrsid_state)) == NULL ) { @@ -1261,7 +1376,7 @@ void winbindd_getgrent(struct winbindd_cli_state *state) fill_domain_username(domain_group_name, ent->domain_name, name_list[ent->sam_entry_index].acct_name, True); - result = fill_grent(&group_list[group_list_ndx], + result = fill_grent(state->mem_ctx, &group_list[group_list_ndx], ent->domain_name, name_list[ent->sam_entry_index].acct_name, group_gid); @@ -1413,6 +1528,8 @@ static void getgroups_sid2gid_recv(void *private_data, bool success, gid_t gid); void winbindd_getgroups(struct winbindd_cli_state *state) { struct getgroups_state *s; + char *real_name = NULL; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; /* Ensure null termination */ state->request.data.username @@ -1432,13 +1549,22 @@ void winbindd_getgroups(struct winbindd_cli_state *state) s->state = state; - ws_name_return( state->request.data.username, WB_REPLACE_CHAR ); + nt_status = normalize_name_unmap(state->mem_ctx, + state->request.data.username, + &real_name); + + /* Reset the real_name pointer if we didn't do anything + productive in the above call */ + if (!NT_STATUS_IS_OK(nt_status) && + !NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) + { + real_name = state->request.data.username; + } - if (!parse_domain_user_talloc(state->mem_ctx, - state->request.data.username, + if (!parse_domain_user_talloc(state->mem_ctx, real_name, &s->domname, &s->username)) { DEBUG(5, ("Could not parse domain user: %s\n", - state->request.data.username)); + real_name)); /* error out if we do not have nested group support */ diff --git a/source3/winbindd/winbindd_locator.c b/source3/winbindd/winbindd_locator.c index b2a8bd7e30..b60d235f70 100644 --- a/source3/winbindd/winbindd_locator.c +++ b/source3/winbindd/winbindd_locator.c @@ -45,11 +45,15 @@ struct winbindd_child *locator_child(void) void winbindd_dsgetdcname(struct winbindd_cli_state *state) { - state->request.domain_name - [sizeof(state->request.domain_name)-1] = '\0'; + state->request.data.dsgetdcname.domain_name + [sizeof(state->request.data.dsgetdcname.domain_name)-1] = '\0'; + state->request.data.dsgetdcname.site_name + [sizeof(state->request.data.dsgetdcname.site_name)-1] = '\0'; + state->request.data.dsgetdcname.domain_guid + [sizeof(state->request.data.dsgetdcname.domain_guid)-1] = '\0'; DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid, - state->request.domain_name)); + state->request.data.dsgetdcname.domain_name)); sendto_child(state, locator_child()); } @@ -94,44 +98,59 @@ static uint32_t get_dsgetdc_flags(uint32_t wbc_flags) return ds_flags; } - static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain, struct winbindd_cli_state *state) { NTSTATUS result; struct netr_DsRGetDCNameInfo *info = NULL; - const char *dc = NULL; uint32_t ds_flags = 0; + struct GUID guid, *guid_ptr = NULL; + const char *guid_str = NULL; - state->request.domain_name - [sizeof(state->request.domain_name)-1] = '\0'; + state->request.data.dsgetdcname.domain_name + [sizeof(state->request.data.dsgetdcname.domain_name)-1] = '\0'; + state->request.data.dsgetdcname.site_name + [sizeof(state->request.data.dsgetdcname.site_name)-1] = '\0'; + state->request.data.dsgetdcname.domain_guid + [sizeof(state->request.data.dsgetdcname.domain_guid)-1] = '\0'; DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid, - state->request.domain_name)); + state->request.data.dsgetdcname.domain_name)); ds_flags = get_dsgetdc_flags(state->request.flags); - result = dsgetdcname(state->mem_ctx, winbind_messaging_context(), - state->request.domain_name, - NULL, NULL, ds_flags, &info); - - if (!NT_STATUS_IS_OK(result)) { - return WINBINDD_ERROR; + result = GUID_from_string(state->request.data.dsgetdcname.domain_guid, + &guid); + if (NT_STATUS_IS_OK(result) && !GUID_all_zero(&guid)) { + guid_ptr = &guid; } - if (info->dc_address) { - dc = strip_hostname(info->dc_address); - } + result = dsgetdcname(state->mem_ctx, + winbind_messaging_context(), + state->request.data.dsgetdcname.domain_name, + guid_ptr, + state->request.data.dsgetdcname.site_name, + ds_flags, + &info); - if ((!dc || !is_ipaddress_v4(dc)) && info->dc_unc) { - dc = strip_hostname(info->dc_unc); + if (!NT_STATUS_IS_OK(result)) { + return WINBINDD_ERROR; } - if (!dc || !*dc) { + guid_str = GUID_string(state->mem_ctx, &info->domain_guid); + if (!guid_str) { return WINBINDD_ERROR; } - fstrcpy(state->response.data.dc_name, dc); + fstrcpy(state->response.data.dsgetdcname.dc_unc, info->dc_unc); + fstrcpy(state->response.data.dsgetdcname.dc_address, info->dc_address); + state->response.data.dsgetdcname.dc_address_type = info->dc_address_type; + fstrcpy(state->response.data.dsgetdcname.domain_guid, guid_str); + fstrcpy(state->response.data.dsgetdcname.domain_name, info->domain_name); + fstrcpy(state->response.data.dsgetdcname.forest_name, info->forest_name); + state->response.data.dsgetdcname.dc_flags = info->dc_flags; + fstrcpy(state->response.data.dsgetdcname.dc_site_name, info->dc_site_name); + fstrcpy(state->response.data.dsgetdcname.client_site_name, info->client_site_name); return WINBINDD_OK; } diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index d4a2e3ed79..9ff3899661 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -127,7 +127,7 @@ static NTSTATUS append_info3_as_ndr(TALLOC_CTX *mem_ctx, DATA_BLOB blob; enum ndr_err_code ndr_err; - ndr_err = ndr_push_struct_blob(&blob, mem_ctx, info3, + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, info3, (ndr_push_flags_fn_t)ndr_push_netr_SamInfo3); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0,("append_info3_as_ndr: failed to append\n")); @@ -811,7 +811,9 @@ void winbindd_pam_auth(struct winbindd_cli_state *state) { struct winbindd_domain *domain; fstring name_domain, name_user; + char *mapped_user = NULL; NTSTATUS result; + NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL; /* Ensure null termination */ state->request.data.auth.user @@ -831,10 +833,20 @@ void winbindd_pam_auth(struct winbindd_cli_state *state) /* Parse domain and username */ - ws_name_return( state->request.data.auth.user, WB_REPLACE_CHAR ); + name_map_status = normalize_name_unmap(state->mem_ctx, + state->request.data.auth.user, + &mapped_user); - if (!canonicalize_username(state->request.data.auth.user, - name_domain, name_user)) { + /* If the name normalization didnt' actually do anything, + just use the original name */ + + if (!NT_STATUS_IS_OK(name_map_status) && + !NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED)) + { + mapped_user = state->request.data.auth.user; + } + + if (!canonicalize_username(mapped_user, name_domain, name_user)) { result = NT_STATUS_NO_SUCH_USER; goto done; } @@ -1447,7 +1459,10 @@ enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain, NTSTATUS result = NT_STATUS_LOGON_FAILURE; NTSTATUS krb5_result = NT_STATUS_OK; fstring name_domain, name_user; + char *mapped_user; + fstring domain_user; struct netr_SamInfo3 *info3 = NULL; + NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL; /* Ensure null termination */ state->request.data.auth.user[sizeof(state->request.data.auth.user)-1]='\0'; @@ -1465,9 +1480,26 @@ enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain, /* Parse domain and username */ - ws_name_return( state->request.data.auth.user, WB_REPLACE_CHAR ); + name_map_status = normalize_name_unmap(state->mem_ctx, + state->request.data.auth.user, + &mapped_user); - parse_domain_user(state->request.data.auth.user, name_domain, name_user); + /* If the name normalization didnt' actually do anything, + just use the original name */ + + if (!NT_STATUS_IS_OK(name_map_status) && + !NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED)) + { + mapped_user = state->request.data.auth.user; + } + + parse_domain_user(mapped_user, name_domain, name_user); + + if ( mapped_user != state->request.data.auth.user ) { + fstr_sprintf( domain_user, "%s\\%s", name_domain, name_user ); + safe_strcpy( state->request.data.auth.user, domain_user, + sizeof(state->request.data.auth.user)-1 ); + } if (domain->online == false) { result = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; @@ -1970,14 +2002,30 @@ done: void winbindd_pam_chauthtok(struct winbindd_cli_state *state) { fstring domain, user; + char *mapped_user; struct winbindd_domain *contact_domain; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; DEBUG(3, ("[%5lu]: pam chauthtok %s\n", (unsigned long)state->pid, state->request.data.chauthtok.user)); /* Setup crap */ - ws_name_return( state->request.data.auth.user, WB_REPLACE_CHAR ); + nt_status = normalize_name_unmap(state->mem_ctx, + state->request.data.chauthtok.user, + &mapped_user); + + /* Update the chauthtok name if we did any mapping */ + + if (NT_STATUS_IS_OK(nt_status) || + NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) + { + fstrcpy(state->request.data.chauthtok.user, mapped_user); + } + + /* Must pass in state->...chauthtok.user because + canonicalize_username() assumes an fstring(). Since + we have already copied it (if necessary), this is ok. */ if (!canonicalize_username(state->request.data.chauthtok.user, domain, user)) { set_auth_errors(&state->response, NT_STATUS_NO_SUCH_USER); diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index e0fc073a0a..95ccf30cfe 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -48,8 +48,6 @@ int count_all_current_connections(void); bool claim_connection(connection_struct *conn, const char *name, uint32 msg_flags); bool register_message_flags(bool doreg, uint32 msg_flags); -bool store_pipe_opendb( smb_np_struct *p ); -bool delete_pipe_opendb( smb_np_struct *p ); /* The following definitions come from winbindd/winbindd.c */ @@ -569,6 +567,10 @@ bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser, void parse_add_domuser(void *buf, char *domuser, int *len); bool canonicalize_username(fstring username_inout, fstring domain, fstring user); void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume); +char *fill_domain_username_talloc(TALLOC_CTX *ctx, + const char *domain, + const char *user, + bool can_assume); const char *get_winbind_pipe_dir(void) ; char *get_winbind_priv_pipe_dir(void) ; int open_winbindd_socket(void); @@ -583,8 +585,22 @@ NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, uint32 *p_num_groups, DOM_SID **user_sids); -void ws_name_replace( char *name, char replace ); -void ws_name_return( char *name, char replace ); + +NTSTATUS normalize_name_map(TALLOC_CTX *mem_ctx, + struct winbindd_domain *domain, + char *name, + char **normalized); +NTSTATUS normalize_name_unmap(TALLOC_CTX *mem_ctx, + char *name, + char **normalized); + +NTSTATUS resolve_username_to_alias(TALLOC_CTX *mem_ctx, + struct winbindd_domain *domain, + const char *name, char **alias); +NTSTATUS resolve_alias_to_username(TALLOC_CTX *mem_ctx, + struct winbindd_domain *domain, + const char *alias, char **name); + bool winbindd_can_contact_domain(struct winbindd_domain *domain); bool winbindd_internal_child(struct winbindd_child *child); void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain); diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index bb79d7ec12..d966e50159 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -279,6 +279,8 @@ NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain, char *full_name = NULL; struct rpc_pipe_client *cli; POLICY_HND lsa_policy; + NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL; + char *mapped_name = NULL; if (name == NULL || *name=='\0') { full_name = talloc_asprintf(mem_ctx, "%s", domain_name); @@ -294,9 +296,19 @@ NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain, DEBUG(3,("rpc: name_to_sid name=%s\n", full_name)); - ws_name_return( full_name, WB_REPLACE_CHAR ); + name_map_status = normalize_name_unmap(mem_ctx, full_name, + &mapped_name); - DEBUG(3,("name_to_sid [rpc] %s for domain %s\n", full_name?full_name:"", domain_name )); + /* Reset the full_name pointer if we mapped anytthing */ + + if (NT_STATUS_IS_OK(name_map_status) || + NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED)) + { + full_name = mapped_name; + } + + DEBUG(3,("name_to_sid [rpc] %s for domain %s\n", + full_name?full_name:"", domain_name )); result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy); if (!NT_STATUS_IS_OK(result)) @@ -332,6 +344,8 @@ NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain, NTSTATUS result; struct rpc_pipe_client *cli; POLICY_HND lsa_policy; + NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL; + char *mapped_name = NULL; DEBUG(3,("sid_to_name [rpc] %s for domain %s\n", sid_string_dbg(sid), domain->name )); @@ -356,9 +370,17 @@ NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain, *domain_name = domains[0]; *name = names[0]; - ws_name_replace( *name, WB_REPLACE_CHAR ); - DEBUG(5,("Mapped sid to [%s]\\[%s]\n", domains[0], *name)); + + name_map_status = normalize_name_map(mem_ctx, domain, *name, + &mapped_name); + if (NT_STATUS_IS_OK(name_map_status) || + NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED)) + { + *name = mapped_name; + DEBUG(5,("returning mapped name -- %s\n", *name)); + } + return NT_STATUS_OK; } @@ -411,8 +433,20 @@ NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain, ret_names = *names; for (i=0; iname, + tmp_names.names[r].string, + true); (*name_types)[i+r] = tmp_types.ids[r]; } @@ -981,7 +1018,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq) &info); if (NT_STATUS_IS_OK(result)) { - *seq = info->info2.sequence_num; + *seq = info->general.sequence_num; got_seq_num = True; } diff --git a/source3/winbindd/winbindd_user.c b/source3/winbindd/winbindd_user.c index 3b6dfdda1c..e5d0a22a73 100644 --- a/source3/winbindd/winbindd_user.c +++ b/source3/winbindd/winbindd_user.c @@ -67,12 +67,15 @@ static bool fillup_pw_field(const char *lp_template, } /* Fill a pwent structure with information we have obtained */ -static bool winbindd_fill_pwent(char *dom_name, char *user_name, +static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name, DOM_SID *user_sid, DOM_SID *group_sid, char *full_name, char *homedir, char *shell, struct winbindd_pw *pw) { fstring output_username; + char *mapped_name = NULL; + struct winbindd_domain *domain = NULL; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; if (!pw || !dom_name || !user_name) return False; @@ -99,7 +102,28 @@ static bool winbindd_fill_pwent(char *dom_name, char *user_name, /* Username */ - fill_domain_username(output_username, dom_name, user_name, True); + domain = find_domain_from_name_noinit(dom_name); + if (domain) { + nt_status = normalize_name_map(ctx, domain, user_name, + &mapped_name); + } else { + DEBUG(5,("winbindd_fill_pwent: Failed to find domain for %s. " + "Disabling name alias support\n", dom_name)); + nt_status = NT_STATUS_NO_SUCH_DOMAIN; + } + + /* Basic removal of whitespace */ + if (NT_STATUS_IS_OK(nt_status)) { + fill_domain_username(output_username, dom_name, mapped_name, True); + } + /* Complete name replacement */ + else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) { + fstrcpy(output_username, mapped_name); + } + /* No change at all */ + else { + fill_domain_username(output_username, dom_name, user_name, True); + } safe_strcpy(pw->pw_name, output_username, sizeof(pw->pw_name) - 1); @@ -179,6 +203,7 @@ struct getpwsid_state { uid_t uid; DOM_SID group_sid; gid_t gid; + bool username_mapped; }; static void getpwsid_queryuser_recv(void *private_data, bool success, @@ -231,6 +256,8 @@ static void getpwsid_queryuser_recv(void *private_data, bool success, fstring username; struct getpwsid_state *s = talloc_get_type_abort(private_data, struct getpwsid_state); + char *mapped_name; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; if (!success) { DEBUG(5, ("Could not query domain %s SID %s\n", @@ -272,7 +299,23 @@ static void getpwsid_queryuser_recv(void *private_data, bool success, strlower_m( username ); s->username = talloc_strdup(s->state->mem_ctx, username); - ws_name_replace( s->username, WB_REPLACE_CHAR ); + nt_status = normalize_name_map(s->state->mem_ctx, s->domain, + s->username, &mapped_name); + + /* Basic removal of whitespace */ + if (NT_STATUS_IS_OK(nt_status)) { + s->username = mapped_name; + s->username_mapped = false; + } + /* Complete name replacement */ + else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) { + s->username = mapped_name; + s->username_mapped = true; + } + /* No change at all */ + else { + s->username_mapped = false; + } s->fullname = talloc_strdup(s->state->mem_ctx, full_name); s->homedir = talloc_strdup(s->state->mem_ctx, homedir); @@ -330,8 +373,16 @@ static void getpwsid_sid2gid_recv(void *private_data, bool success, gid_t gid) pw = &s->state->response.data.pw; pw->pw_uid = s->uid; pw->pw_gid = s->gid; + + /* allow username to be overridden by the alias mapping */ + + if ( s->username_mapped ) { + fstrcpy( output_username, s->username ); + } else { fill_domain_username(output_username, s->domain->name, s->username, True); + } + safe_strcpy(pw->pw_name, output_username, sizeof(pw->pw_name) - 1); safe_strcpy(pw->pw_gecos, s->fullname, sizeof(pw->pw_gecos) - 1); @@ -370,8 +421,10 @@ void winbindd_getpwnam(struct winbindd_cli_state *state) { struct winbindd_domain *domain; fstring domname, username; + char *mapped_user = NULL; char *domuser; size_t dusize; + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; domuser = state->request.data.username; dusize = sizeof(state->request.data.username); @@ -383,9 +436,19 @@ void winbindd_getpwnam(struct winbindd_cli_state *state) (unsigned long)state->pid, domuser)); - ws_name_return(domuser, WB_REPLACE_CHAR); + nt_status = normalize_name_unmap(state->mem_ctx, domuser, + &mapped_user); + + /* If we could not convert from an aliased name or a + normalized name, then just use the original name */ + + if (!NT_STATUS_IS_OK(nt_status) && + !NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_RENAMED)) + { + mapped_user = domuser; + } - if (!parse_domain_user(domuser, domname, username)) { + if (!parse_domain_user(mapped_user, domname, username)) { DEBUG(5, ("Could not parse domain user: %s\n", domuser)); request_error(state); return; @@ -743,6 +806,7 @@ void winbindd_getpwent(struct winbindd_cli_state *state) /* Lookup user info */ result = winbindd_fill_pwent( + state->mem_ctx, ent->domain_name, name_list[ent->sam_entry_index].name, &name_list[ent->sam_entry_index].user_sid, diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index 132c96f1ee..fdfc8ed9d1 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -111,7 +111,16 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const const char *alternative_name = NULL; char *idmap_config_option; const char *param; + const char **ignored_domains, **dom; + ignored_domains = lp_parm_string_list(-1, "winbind", "ignore domains", NULL); + for (dom=ignored_domains; dom && *dom; dom++) { + if (gen_fnmatch(*dom, domain_name) == 0) { + DEBUG(2,("Ignoring domain '%s'\n", domain_name)); + return NULL; + } + } + /* ignore alt_name if we are not in an AD domain */ if ( (lp_security() == SEC_ADS) && alt_name && *alt_name) { @@ -436,6 +445,10 @@ static void rescan_forest_root_trusts( void ) &dom_list[i].sid ); } + if (d == NULL) { + continue; + } + DEBUG(10,("rescan_forest_root_trusts: Following trust path " "for domain tree root %s (%s)\n", d->name, d->alt_name )); @@ -500,6 +513,10 @@ static void rescan_forest_trusts( void ) &cache_methods, &dom_list[i].sid ); } + + if (d == NULL) { + continue; + } DEBUG(10,("Following trust path for domain %s (%s)\n", d->name, d->alt_name )); @@ -1058,13 +1075,12 @@ void free_getent_state(struct getent_state *state) temp = state; while(temp != NULL) { - struct getent_state *next; + struct getent_state *next = temp->next; /* Free sam entries then list entry */ SAFE_FREE(state->sam_entries); DLIST_REMOVE(state, state); - next = temp->next; SAFE_FREE(temp); temp = next; @@ -1160,7 +1176,7 @@ void parse_add_domuser(void *buf, char *domuser, int *len) } } - safe_strcpy(buf, user, *len); + safe_strcpy((char *)buf, user, *len); } /* Ensure an incoming username from NSS is fully qualified. Replace the @@ -1213,6 +1229,33 @@ void fill_domain_username(fstring name, const char *domain, const char *user, bo } } +/** + * talloc version of fill_domain_username() + * return NULL on talloc failure. + */ +char *fill_domain_username_talloc(TALLOC_CTX *mem_ctx, + const char *domain, + const char *user, + bool can_assume) +{ + char *tmp_user, *name; + + tmp_user = talloc_strdup(mem_ctx, user); + strlower_m(tmp_user); + + if (can_assume && assume_domain(domain)) { + name = tmp_user; + } else { + name = talloc_asprintf(mem_ctx, "%s%c%s", + domain, + *lp_winbind_separator(), + tmp_user); + TALLOC_FREE(tmp_user); + } + + return name; +} + /* * Winbindd socket accessor functions */ @@ -1378,34 +1421,107 @@ NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain, We use this to remove spaces from user and group names ********************************************************************/ -void ws_name_replace( char *name, char replace ) +NTSTATUS normalize_name_map(TALLOC_CTX *mem_ctx, + struct winbindd_domain *domain, + char *name, + char **normalized) { - char replace_char[2] = { 0x0, 0x0 }; - - if ( !lp_winbind_normalize_names() || (replace == '\0') ) - return; + NTSTATUS nt_status; - replace_char[0] = replace; - all_string_sub( name, " ", replace_char, 0 ); + if (!name || !normalized) { + return NT_STATUS_INVALID_PARAMETER; + } - return; + if (!lp_winbind_normalize_names()) { + return NT_STATUS_PROCEDURE_NOT_FOUND; + } + + /* Alias support and whitespace replacement are mutually + exclusive */ + + nt_status = resolve_username_to_alias(mem_ctx, domain, + name, normalized ); + if (NT_STATUS_IS_OK(nt_status)) { + /* special return code to let the caller know we + mapped to an alias */ + return NT_STATUS_FILE_RENAMED; + } + + /* check for an unreachable domain */ + + if (NT_STATUS_EQUAL(nt_status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) { + DEBUG(5,("normalize_name_map: Setting domain %s offline\n", + domain->name)); + set_domain_offline(domain); + return nt_status; + } + + /* deal with whitespace */ + + *normalized = talloc_strdup(mem_ctx, name); + if (!(*normalized)) { + return NT_STATUS_NO_MEMORY; + } + + all_string_sub( *normalized, " ", "_", 0 ); + + return NT_STATUS_OK; } /********************************************************************* - We use this to do the inverse of ws_name_replace() + We use this to do the inverse of normalize_name_map() ********************************************************************/ -void ws_name_return( char *name, char replace ) +NTSTATUS normalize_name_unmap(TALLOC_CTX *mem_ctx, + char *name, + char **normalized) { - char replace_char[2] = { 0x0, 0x0 }; - - if ( !lp_winbind_normalize_names() || (replace == '\0') ) - return; + NTSTATUS nt_status; + struct winbindd_domain *domain = find_our_domain(); + + if (!name || !normalized) { + return NT_STATUS_INVALID_PARAMETER; + } - replace_char[0] = replace; - all_string_sub( name, replace_char, " ", 0 ); + if (!lp_winbind_normalize_names()) { + return NT_STATUS_PROCEDURE_NOT_FOUND; + } - return; + /* Alias support and whitespace replacement are mutally + exclusive */ + + /* When mapping from an alias to a username, we don't know the + domain. But we only need a domain structure to cache + a successful lookup , so just our own domain structure for + the seqnum. */ + + nt_status = resolve_alias_to_username(mem_ctx, domain, + name, normalized); + if (NT_STATUS_IS_OK(nt_status)) { + /* Special return code to let the caller know we mapped + from an alias */ + return NT_STATUS_FILE_RENAMED; + } + + /* check for an unreachable domain */ + + if (NT_STATUS_EQUAL(nt_status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) { + DEBUG(5,("normalize_name_unmap: Setting domain %s offline\n", + domain->name)); + set_domain_offline(domain); + return nt_status; + } + + /* deal with whitespace */ + + *normalized = talloc_strdup(mem_ctx, name); + if (!(*normalized)) { + return NT_STATUS_NO_MEMORY; + } + + all_string_sub(*normalized, "_", " ", 0); + + return NT_STATUS_OK; } /********************************************************************* diff --git a/BUGS4.txt b/source4/BUGS similarity index 100% rename from BUGS4.txt rename to source4/BUGS diff --git a/source4/Makefile b/source4/Makefile index 66b092192e..26cab668c8 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -8,14 +8,13 @@ default: all include mkconfig.mk -pidldir := $(srcdir)/pidl +pidldir := $(srcdir)/../pidl -BASEDIR = $(prefix) -TORTUREDIR = $(libdir)/torture -SWATDIR = $(datadir)/swat -JSDIR = $(datadir)/js -SETUPDIR = $(datadir)/setup -NCALRPCDIR = $(localstatedir)/ncalrpc +basedir = $(prefix) +torturedir = $(libdir)/torture +swatdir = $(datadir)/swat +setupdir = $(datadir)/setup +ncalrpcdir = $(localstatedir)/ncalrpc BNLD = $(LD) BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS) @@ -49,7 +48,7 @@ endif include $(srcdir)/build/make/rules.mk include $(srcdir)/build/make/python.mk -zlibsrcdir := lib/zlib +zlibsrcdir := ../lib/zlib dynconfigsrcdir := dynconfig heimdalsrcdir := heimdal dsdbsrcdir := dsdb @@ -62,7 +61,7 @@ libsrcdir := lib libsocketsrcdir := lib/socket libcharsetsrcdir := lib/charset ldb_sambasrcdir := lib/ldb-samba -tdbsrcdir := lib/tdb +tdbsrcdir := ../lib/tdb ldbsrcdir := lib/ldb libtlssrcdir := lib/tls libregistrysrcdir := lib/registry @@ -70,18 +69,18 @@ smbreadlinesrcdir := lib/smbreadline libmessagingsrcdir := lib/messaging libeventssrcdir := lib/events libcmdlinesrcdir := lib/cmdline -poptsrcdir := lib/popt -socketwrappersrcdir := lib/socket_wrapper -nsswrappersrcdir := lib/nss_wrapper +poptsrcdir := ../lib/popt +socketwrappersrcdir := ../lib/socket_wrapper +nsswrappersrcdir := ../lib/nss_wrapper appwebsrcdir := lib/appweb libstreamsrcdir := lib/stream -libutilsrcdir := lib/util +libutilsrcdir := ../lib/util libtdrsrcdir := lib/tdr libdbwrapsrcdir := lib/dbwrap -libcryptosrcdir := lib/crypto +libcryptosrcdir := ../lib/crypto libtorturesrcdir := lib/torture smb_serversrcdir := smb_server -libcompressionsrcdir := lib/compression +libcompressionsrcdir := ../lib/compression libgencachesrcdir := lib paramsrcdir := param rpc_serversrcdir := rpc_server @@ -98,13 +97,25 @@ ntvfssrcdir := ntvfs ntptrsrcdir := ntptr librpcsrcdir := librpc libclisrcdir := libcli -ejsscriptsrcdir := scripting/ejs +libclinbtsrcdir := ../libcli/nbt pyscriptsrcdir := $(srcdir)/scripting/python kdcsrcdir := kdc ntp_signdsrcdir := ntp_signd +wmisrcdir := lib/wmi +tallocsrcdir := ../lib/talloc +comsrcdir := $(srcdir)/lib/com include data.mk +$(foreach SCRIPT,$(wildcard scripting/bin/*),$(eval $(call binary_install_template,$(SCRIPT)))) + +$(DESTDIR)$(bindir)/%: scripting/bin/% installdirs + @mkdir -p $(@D) + @echo Installing $(@F) as $@ + @if test -f $@; then echo -n ""; rm -f $@.old; mv $@ $@.old; fi + @cp $< $@ + @chmod $(INSTALLPERMS) $@ + pythonmods:: $(PYTHON_PYS) $(PYTHON_SO) DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \ @@ -130,7 +141,10 @@ else include $(srcdir)/static_deps.mk endif -DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \ +clean:: + @find ../lib ../libcli -name '*.o' -o -name '*.ho' | xargs rm -f + +DEFAULT_HEADERS = $(srcdir)/../lib/util/dlinklist.h \ $(srcdir)/version.h libraries:: $(STATIC_LIBS) $(SHARED_LIBS) @@ -150,7 +164,7 @@ testsuite:: bin/smbclient bin/cifsdd bin/smbtorture bin/nmblookup showlayout:: @echo 'Samba will be installed into:' - @echo ' basedir: $(BASEDIR)' + @echo ' basedir: $(basedir)' @echo ' bindir: $(bindir)' @echo ' sbindir: $(sbindir)' @echo ' libdir: $(libdir)' @@ -161,11 +175,10 @@ showlayout:: @echo ' piddir: $(piddir)' @echo ' lockdir: $(lockdir)' @echo ' logfilebase: $(logfilebase)' - @echo ' setupdir: $(SETUPDIR)' - @echo ' jsdir: $(JSDIR)' - @echo ' swatdir: $(SWATDIR)' + @echo ' setupdir: $(setupdir)' + @echo ' swatdir: $(swatdir)' @echo ' mandir: $(mandir)' - @echo ' torturedir: $(TORTUREDIR)' + @echo ' torturedir: $(torturedir)' @echo ' datadir: $(datadir)' @echo ' winbindd_socket_dir: $(winbindd_socket_dir)' @echo ' ntp_signd_socket_dir: $(ntp_signd_socket_dir)' @@ -177,7 +190,7 @@ showflags:: # The permissions to give the executables INSTALLPERMS = 0755 -install:: showlayout everything installbin installsbin installdat installswat installmisc \ +install:: showlayout everything installbin installsbin installdat installmisc \ installlib installheader installpc installplugins # DESTDIR is used here to prevent packagers wasting their time @@ -190,10 +203,10 @@ install:: showlayout everything installbin installsbin installdat installswat in installdirs:: @$(SHELL) $(srcdir)/script/installdirs.sh \ - $(DESTDIR)$(BASEDIR) \ + $(DESTDIR)$(basedir) \ $(DESTDIR)$(bindir) \ $(DESTDIR)$(sbindir) \ - $(DESTDIR)$(TORTUREDIR) \ + $(DESTDIR)$(torturedir) \ $(DESTDIR)$(libdir) \ $(DESTDIR)$(modulesdir) \ $(DESTDIR)$(mandir) \ @@ -207,7 +220,7 @@ installdirs:: $(DESTDIR)$(logfilebase) \ $(DESTDIR)$(privatedir)/tls \ $(DESTDIR)$(includedir) \ - $(DESTDIR)$(PKGCONFIGDIR) \ + $(DESTDIR)$(pkgconfigdir) \ $(DESTDIR)$(sysconfdir) installbin:: installdirs @@ -224,24 +237,21 @@ installheader:: headers installdirs installdat:: installdirs @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(datadir) $(srcdir) -installswat:: installdirs -#SWAT has been disabled until further notice -# @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) - installman:: manpages installdirs @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(mandir) $(MANPAGES) installmisc:: installdirs - @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(bindir) + @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(setupdir) installpc:: installdirs - @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES) + @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(pkgconfigdir) $(PC_FILES) -uninstall:: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \ - uninstallplugins +uninstall:: uninstallbin uninstallsbin uninstalldat uninstallmisc uninstalllib uninstallheader \ + uninstallman uninstallpc uninstallplugins uninstallmisc:: - #FIXME + @echo "Removing MISC files" + @rm -rf $(DESTDIR)$(setupdir)/* $(DESTDIR)$(bindir)/%: bin/% installdirs @mkdir -p $(@D) @@ -257,20 +267,30 @@ $(DESTDIR)$(sbindir)/%: bin/% installdirs @cp $< $@ @chmod $(INSTALLPERMS) $@ +uninstalldat:: + @echo "Removing DAT files" + @rm -fr $(DESTDIR)$(datadir)/* + uninstallbin:: uninstalllib:: + @echo "Removing libraries" @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(libdir) $(SHARED_LIBS) - #@$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(libdir) $(STATIC_LIBS) uninstallheader:: - @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(includedir) $(PUBLIC_HEADERS) + @echo "Removing headers" + @rm -fr $(DESTDIR)$(includedir)/* uninstallman:: + @echo "Removing manpages" @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(mandir) $(MANPAGES) uninstallplugins:: +uninstallpc:: + @echo "Removing package configurations" + @cd $(DESTDIR)$(pkgconfigdir); rm -f $(notdir $(PC_FILES)) + config.status: @echo "config.status does not exist. Please run ./configure." @/bin/false @@ -281,8 +301,8 @@ data.mk: config.status $(MK_FILES) testcov-html:: include $(pidldir)/config.mk -selftestdir := $(srcdir)/selftest -include $(selftestdir)/config.mk +selftestdir := $(srcdir)/../selftest +include $(srcdir)/selftest/config.mk showflags:: @echo ' pwd = '`/bin/pwd` diff --git a/NEWS4 b/source4/NEWS similarity index 100% rename from NEWS4 rename to source4/NEWS diff --git a/TODO4 b/source4/TODO similarity index 98% rename from TODO4 rename to source4/TODO index 14df8a507a..5efebed1b3 100644 --- a/TODO4 +++ b/source4/TODO @@ -1,7 +1,7 @@ -source/build/smb_build/TODO -source/lib/registry/TODO -source/lib/tdr/TODO -source/pidl/TODO +build/smb_build/TODO +lib/registry/TODO +lib/tdr/TODO +pidl/TODO - seperate adminlog mechanism (as opposed to the current DEBUG log, which is not really aimed at administrators but more at developers) diff --git a/source4/aclocal.m4 b/source4/aclocal.m4 index 57a66439a1..240a994f9d 100644 --- a/source4/aclocal.m4 +++ b/source4/aclocal.m4 @@ -53,7 +53,7 @@ AC_DEFUN(LIB_REMOVE_USR_LIB,[ $1=[$]ac_new_flags ]) -m4_include(lib/replace/libreplace.m4) +m4_include(../lib/replace/libreplace.m4) m4_include(build/m4/ax_cflags_gcc_option.m4) m4_include(build/m4/ax_cflags_irix_option.m4) m4_include(build/m4/public.m4) diff --git a/source4/auth/auth.py b/source4/auth/auth.py index 226175a75b..1e5d68804b 100644 --- a/source4/auth/auth.py +++ b/source4/auth/auth.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/auth/auth_sam_reply.c b/source4/auth/auth_sam_reply.c index ea6f0a1f60..839553632e 100644 --- a/source4/auth/auth_sam_reply.c +++ b/source4/auth/auth_sam_reply.c @@ -24,6 +24,7 @@ #include "auth/auth.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_netlogon.h" +#include "auth/auth_sam_reply.h" NTSTATUS auth_convert_server_info_sambaseinfo(TALLOC_CTX *mem_ctx, struct auth_serversupplied_info *server_info, diff --git a/source4/auth/auth_wrap.c b/source4/auth/auth_wrap.c index dea76ef87d..c514821c72 100644 --- a/source4/auth/auth_wrap.c +++ b/source4/auth/auth_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2523,7 +2529,7 @@ static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0}; #define SWIG_name "_auth" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2548,13 +2554,13 @@ SWIGINTERN PyObject *_wrap_system_session(PyObject *SWIGUNUSEDPARM(self), PyObje PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; struct loadparm_context *arg2 = (struct loadparm_context *) 0 ; - struct auth_session_info *result = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "lp_ctx", NULL }; + struct auth_session_info *result = 0 ; arg2 = loadparm_init(NULL); arg1 = NULL; @@ -2578,13 +2584,13 @@ SWIGINTERN PyObject *_wrap_system_session_anon(PyObject *SWIGUNUSEDPARM(self), P PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; struct loadparm_context *arg2 = (struct loadparm_context *) 0 ; - struct auth_session_info *result = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "lp_ctx", NULL }; + struct auth_session_info *result = 0 ; arg2 = loadparm_init(NULL); arg1 = NULL; diff --git a/source4/auth/credentials/credentials.c b/source4/auth/credentials/credentials.c index adabe49cb4..5fb180d7b1 100644 --- a/source4/auth/credentials/credentials.c +++ b/source4/auth/credentials/credentials.c @@ -25,6 +25,7 @@ #include "librpc/gen_ndr/samr.h" /* for struct samrPassword */ #include "auth/credentials/credentials.h" #include "auth/credentials/credentials_krb5.h" +#include "auth/credentials/credentials_proto.h" #include "libcli/auth/libcli_auth.h" #include "lib/events/events.h" #include "param/param.h" diff --git a/source4/auth/credentials/credentials.h b/source4/auth/credentials/credentials.h index 79c50ae5af..52b10c633c 100644 --- a/source4/auth/credentials/credentials.h +++ b/source4/auth/credentials/credentials.h @@ -22,7 +22,7 @@ #ifndef __CREDENTIALS_H__ #define __CREDENTIALS_H__ -#include "util/data_blob.h" +#include "../lib/util/data_blob.h" #include "librpc/gen_ndr/misc.h" struct ccache_container; diff --git a/source4/auth/credentials/credentials.py b/source4/auth/credentials/credentials.py index 2cd56c3599..fe21dd2ba2 100644 --- a/source4/auth/credentials/credentials.py +++ b/source4/auth/credentials/credentials.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/auth/credentials/credentials_files.c b/source4/auth/credentials/credentials_files.c index 6c3bb2531e..17c555d25b 100644 --- a/source4/auth/credentials/credentials_files.c +++ b/source4/auth/credentials/credentials_files.c @@ -27,9 +27,10 @@ #include "librpc/gen_ndr/samr.h" /* for struct samrPassword */ #include "param/secrets.h" #include "system/filesys.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "auth/credentials/credentials.h" #include "auth/credentials/credentials_krb5.h" +#include "auth/credentials/credentials_proto.h" #include "param/param.h" #include "lib/events/events.h" @@ -118,7 +119,7 @@ _PUBLIC_ bool cli_credentials_parse_file(struct cli_credentials *cred, const cha char **lines; int i, numlines; - lines = file_lines_load(file, &numlines, NULL); + lines = file_lines_load(file, &numlines, 0, NULL); if (lines == NULL) { diff --git a/source4/auth/credentials/credentials_ntlm.c b/source4/auth/credentials/credentials_ntlm.c index 22e273c35a..ef41971462 100644 --- a/source4/auth/credentials/credentials_ntlm.c +++ b/source4/auth/credentials/credentials_ntlm.c @@ -23,7 +23,7 @@ #include "includes.h" #include "librpc/gen_ndr/samr.h" /* for struct samrPassword */ -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "auth/credentials/credentials.h" diff --git a/source4/auth/credentials/credentials_wrap.c b/source4/auth/credentials/credentials_wrap.c index 81ba426e45..260451d0fc 100644 --- a/source4/auth/credentials/credentials_wrap.c +++ b/source4/auth/credentials/credentials_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2524,7 +2530,7 @@ static swig_module_info swig_module = {swig_types, 17, 0, 0, 0, 0}; #define SWIG_name "_credentials" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2839,13 +2845,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_get_username(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_username",kwnames,&obj0)) SWIG_fail; @@ -2869,7 +2875,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel cli_credentials *arg1 = (cli_credentials *) 0 ; char *arg2 = (char *) 0 ; enum credentials_obtained arg3 = (enum credentials_obtained) CRED_SPECIFIED ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2883,6 +2888,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel char * kwnames[] = { (char *) "self",(char *) "value",(char *) "obtained", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_username",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -2920,13 +2926,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_get_password(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_password",kwnames,&obj0)) SWIG_fail; @@ -2950,7 +2956,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel cli_credentials *arg1 = (cli_credentials *) 0 ; char *arg2 = (char *) 0 ; enum credentials_obtained arg3 = (enum credentials_obtained) CRED_SPECIFIED ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2964,6 +2969,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel char * kwnames[] = { (char *) "self",(char *) "val",(char *) "obtained", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_password",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -3001,13 +3007,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_get_domain(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_domain",kwnames,&obj0)) SWIG_fail; @@ -3031,7 +3037,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self) cli_credentials *arg1 = (cli_credentials *) 0 ; char *arg2 = (char *) 0 ; enum credentials_obtained arg3 = (enum credentials_obtained) CRED_SPECIFIED ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3045,6 +3050,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self) char * kwnames[] = { (char *) "self",(char *) "val",(char *) "obtained", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_domain",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -3082,13 +3088,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_get_realm(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_realm",kwnames,&obj0)) SWIG_fail; @@ -3112,7 +3118,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self), cli_credentials *arg1 = (cli_credentials *) 0 ; char *arg2 = (char *) 0 ; enum credentials_obtained arg3 = (enum credentials_obtained) CRED_SPECIFIED ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3126,6 +3131,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "val",(char *) "obtained", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_realm",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -3253,13 +3259,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_get_bind_dn(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_bind_dn",kwnames,&obj0)) SWIG_fail; @@ -3282,7 +3288,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_bind_dn(PyObject *SWIGUNUSEDPARM(self PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3293,6 +3298,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_bind_dn(PyObject *SWIGUNUSEDPARM(self char * kwnames[] = { (char *) "self",(char *) "bind_dn", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Credentials_set_bind_dn",kwnames,&obj0,&obj1)) SWIG_fail; @@ -3350,13 +3356,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_get_workstation(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_workstation",kwnames,&obj0)) SWIG_fail; @@ -3380,7 +3386,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_workstation(PyObject *SWIGUNUSEDPARM( cli_credentials *arg1 = (cli_credentials *) 0 ; char *arg2 = (char *) 0 ; enum credentials_obtained arg3 = (enum credentials_obtained) CRED_SPECIFIED ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3394,6 +3399,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_workstation(PyObject *SWIGUNUSEDPARM( char * kwnames[] = { (char *) "self",(char *) "workstation",(char *) "obtained", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_workstation",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -3432,7 +3438,6 @@ SWIGINTERN PyObject *_wrap_Credentials_set_machine_account(PyObject *SWIGUNUSEDP PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; struct loadparm_context *arg2 = (struct loadparm_context *) 0 ; - NTSTATUS result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3442,6 +3447,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_machine_account(PyObject *SWIGUNUSEDP char * kwnames[] = { (char *) "self",(char *) "lp_ctx", NULL }; + NTSTATUS result; arg1 = NULL; arg2 = loadparm_init(NULL); @@ -3510,13 +3516,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_is_anonymous(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_is_anonymous",kwnames,&obj0)) SWIG_fail; @@ -3539,13 +3545,13 @@ SWIGINTERN PyObject *_wrap_Credentials_get_nt_hash(PyObject *SWIGUNUSEDPARM(self PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; - struct samr_Password *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + struct samr_Password *result = 0 ; arg1 = NULL; arg2 = NULL; @@ -3568,13 +3574,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_authentication_requested(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_authentication_requested",kwnames,&obj0)) SWIG_fail; @@ -3596,13 +3602,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_wrong_password(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_wrong_password",kwnames,&obj0)) SWIG_fail; @@ -3624,13 +3630,13 @@ fail: SWIGINTERN PyObject *_wrap_Credentials_set_cmdline_callbacks(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; cli_credentials *arg1 = (cli_credentials *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + bool result; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_set_cmdline_callbacks",kwnames,&obj0)) SWIG_fail; @@ -3669,7 +3675,6 @@ SWIGINTERN PyObject *_wrap_delete_Credentials(PyObject *SWIGUNUSEDPARM(self), Py arg1 = (cli_credentials *)(argp1); } delete_cli_credentials(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c index 06a7b8a382..54d53965cc 100644 --- a/source4/auth/gensec/cyrus_sasl.c +++ b/source4/auth/gensec/cyrus_sasl.c @@ -110,7 +110,7 @@ static int gensec_sasl_get_password(sasl_conn_t *conn, void *context, int id, static int gensec_sasl_dispose(struct gensec_sasl_state *gensec_sasl_state) { sasl_dispose(&gensec_sasl_state->conn); - return 0; + return SASL_OK; } static NTSTATUS gensec_sasl_client_start(struct gensec_security *gensec_security) @@ -319,43 +319,43 @@ static const struct gensec_security_ops gensec_sasl_security_ops = { .priority = GENSEC_SASL }; -int gensec_sasl_log(void *context, +static int gensec_sasl_log(void *context, int sasl_log_level, const char *message) { - int debug_level; + int dl; switch (sasl_log_level) { case SASL_LOG_NONE: - debug_level = 0; + dl = 0; break; case SASL_LOG_ERR: - debug_level = 1; + dl = 1; break; case SASL_LOG_FAIL: - debug_level = 2; + dl = 2; break; case SASL_LOG_WARN: - debug_level = 3; + dl = 3; break; case SASL_LOG_NOTE: - debug_level = 5; + dl = 5; break; case SASL_LOG_DEBUG: - debug_level = 10; + dl = 10; break; case SASL_LOG_TRACE: - debug_level = 11; + dl = 11; break; #if DEBUG_PASSWORD case SASL_LOG_PASS: - debug_level = 100; + dl = 100; break; #endif default: - debug_level = 0; + dl = 0; break; } - DEBUG(debug_level, ("gensec_sasl: %s\n", message)); + DEBUG(dl, ("gensec_sasl: %s\n", message)); return SASL_OK; } diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c index 0edb34d740..5d57383d2a 100644 --- a/source4/auth/gensec/gensec.c +++ b/source4/auth/gensec/gensec.c @@ -490,6 +490,7 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, NT_STATUS_HAVE_NO_MEMORY(*gensec_security); (*gensec_security)->ops = NULL; + (*gensec_security)->private_data = NULL; ZERO_STRUCT((*gensec_security)->target); ZERO_STRUCT((*gensec_security)->peer_addr); @@ -525,6 +526,7 @@ _PUBLIC_ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx, (*gensec_security)->private_data = NULL; (*gensec_security)->subcontext = true; + (*gensec_security)->want_features = parent->want_features; (*gensec_security)->event_ctx = parent->event_ctx; (*gensec_security)->msg_ctx = parent->msg_ctx; (*gensec_security)->lp_ctx = parent->lp_ctx; @@ -1015,7 +1017,11 @@ _PUBLIC_ NTSTATUS gensec_update_recv(struct gensec_update_request *req, TALLOC_C _PUBLIC_ void gensec_want_feature(struct gensec_security *gensec_security, uint32_t feature) { - gensec_security->want_features |= feature; + if (!gensec_security->ops || !gensec_security->ops->want_feature) { + gensec_security->want_features |= feature; + return; + } + gensec_security->ops->want_feature(gensec_security, feature); } /** diff --git a/source4/auth/gensec/gensec.h b/source4/auth/gensec/gensec.h index 2830297ffe..0b31882ddd 100644 --- a/source4/auth/gensec/gensec.h +++ b/source4/auth/gensec/gensec.h @@ -133,6 +133,8 @@ struct gensec_security_ops { NTSTATUS (*session_key)(struct gensec_security *gensec_security, DATA_BLOB *session_key); NTSTATUS (*session_info)(struct gensec_security *gensec_security, struct auth_session_info **session_info); + void (*want_feature)(struct gensec_security *gensec_security, + uint32_t feature); bool (*have_feature)(struct gensec_security *gensec_security, uint32_t feature); bool enabled; @@ -174,6 +176,7 @@ struct gensec_security; struct socket_context; NTSTATUS gensec_socket_init(struct gensec_security *gensec_security, + TALLOC_CTX *mem_ctx, struct socket_context *current_socket, struct event_context *ev, void (*recv_handler)(void *, uint16_t), diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c index 1334e799ae..e307dbb5cb 100644 --- a/source4/auth/gensec/gensec_gssapi.c +++ b/source4/auth/gensec/gensec_gssapi.c @@ -1181,6 +1181,10 @@ static NTSTATUS gensec_gssapi_session_key(struct gensec_security *gensec_securit OM_uint32 maj_stat, min_stat; krb5_keyblock *subkey; + if (gensec_gssapi_state->sasl_state != STAGE_DONE) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + if (gensec_gssapi_state->session_key.data) { *session_key = gensec_gssapi_state->session_key; return NT_STATUS_OK; @@ -1200,10 +1204,7 @@ static NTSTATUS gensec_gssapi_session_key(struct gensec_security *gensec_securit *session_key = data_blob_talloc(gensec_gssapi_state, KRB5_KEY_DATA(subkey), KRB5_KEY_LENGTH(subkey)); krb5_free_keyblock(gensec_gssapi_state->smb_krb5_context->krb5_context, subkey); - if (gensec_gssapi_state->sasl_state == STAGE_DONE) { - /* only cache in the done stage */ - gensec_gssapi_state->session_key = *session_key; - } + gensec_gssapi_state->session_key = *session_key; dump_data_pw("KRB5 Session Key:\n", session_key->data, session_key->length); return NT_STATUS_OK; @@ -1360,7 +1361,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi return NT_STATUS_OK; } -size_t gensec_gssapi_sig_size(struct gensec_security *gensec_security, size_t data_size) +static size_t gensec_gssapi_sig_size(struct gensec_security *gensec_security, size_t data_size) { struct gensec_gssapi_state *gensec_gssapi_state = talloc_get_type(gensec_security->private_data, struct gensec_gssapi_state); diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c index 47df2ccfcc..1f54043038 100644 --- a/source4/auth/gensec/gensec_krb5.c +++ b/source4/auth/gensec/gensec_krb5.c @@ -515,6 +515,10 @@ static NTSTATUS gensec_krb5_session_key(struct gensec_security *gensec_security, krb5_keyblock *skey; krb5_error_code err = -1; + if (gensec_krb5_state->state_position != GENSEC_KRB5_DONE) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + if (gensec_krb5_state->session_key.data) { *session_key = gensec_krb5_state->session_key; return NT_STATUS_OK; diff --git a/source4/auth/gensec/schannel_sign.c b/source4/auth/gensec/schannel_sign.c index 1e57beba08..9862a029a4 100644 --- a/source4/auth/gensec/schannel_sign.c +++ b/source4/auth/gensec/schannel_sign.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "auth/auth.h" #include "auth/gensec/schannel.h" #include "auth/credentials/credentials.h" diff --git a/source4/auth/gensec/schannel_state.c b/source4/auth/gensec/schannel_state.c index f0710c5581..c73313f9c8 100644 --- a/source4/auth/gensec/schannel_state.c +++ b/source4/auth/gensec/schannel_state.c @@ -25,10 +25,11 @@ #include "lib/ldb/include/ldb_errors.h" #include "dsdb/samdb/samdb.h" #include "ldb_wrap.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "libcli/auth/libcli_auth.h" #include "auth/auth.h" #include "param/param.h" +#include "auth/gensec/schannel_state.h" /** connect to the schannel ldb @@ -44,7 +45,7 @@ struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct event_contex "computerName: CASE_INSENSITIVE\n" \ "flatname: CASE_INSENSITIVE\n"; - path = smbd_tmp_path(mem_ctx, lp_ctx, "schannel.ldb"); + path = private_path(mem_ctx, lp_ctx, "schannel.ldb"); if (!path) { return NULL; } @@ -195,7 +196,7 @@ NTSTATUS schannel_fetch_session_key_ldb(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - ret = ldb_search_exp_fmt(ldb, mem_ctx, &res, + ret = ldb_search(ldb, mem_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(computerName=%s)(flatname=%s))", computer_name, domain); if (ret != LDB_SUCCESS) { diff --git a/source4/auth/gensec/socket.c b/source4/auth/gensec/socket.c index 27449bf610..319730e2ca 100644 --- a/source4/auth/gensec/socket.c +++ b/source4/auth/gensec/socket.c @@ -408,8 +408,10 @@ static NTSTATUS gensec_socket_send(struct socket_context *sock, } /* Turn a normal socket into a potentially GENSEC wrapped socket */ +/* CAREFUL: this function will steal 'current_socket' */ NTSTATUS gensec_socket_init(struct gensec_security *gensec_security, + TALLOC_CTX *mem_ctx, struct socket_context *current_socket, struct event_context *ev, void (*recv_handler)(void *, uint16_t), @@ -420,7 +422,7 @@ NTSTATUS gensec_socket_init(struct gensec_security *gensec_security, struct socket_context *new_sock; NTSTATUS nt_status; - nt_status = socket_create_with_ops(current_socket, &gensec_socket_ops, &new_sock, + nt_status = socket_create_with_ops(mem_ctx, &gensec_socket_ops, &new_sock, SOCKET_TYPE_STREAM, current_socket->flags | SOCKET_FLAG_ENCRYPT); if (!NT_STATUS_IS_OK(nt_status)) { *new_socket = NULL; @@ -432,22 +434,19 @@ NTSTATUS gensec_socket_init(struct gensec_security *gensec_security, gensec_socket = talloc(new_sock, struct gensec_socket); if (gensec_socket == NULL) { *new_socket = NULL; + talloc_free(new_sock); return NT_STATUS_NO_MEMORY; } new_sock->private_data = gensec_socket; gensec_socket->socket = current_socket; - if (talloc_reference(gensec_socket, current_socket) == NULL) { - *new_socket = NULL; - return NT_STATUS_NO_MEMORY; - } - /* Nothing to do here, if we are not actually wrapping on this socket */ if (!gensec_have_feature(gensec_security, GENSEC_FEATURE_SEAL) && !gensec_have_feature(gensec_security, GENSEC_FEATURE_SIGN)) { gensec_socket->wrap = false; + talloc_steal(gensec_socket, current_socket); *new_socket = new_sock; return NT_STATUS_OK; } @@ -469,6 +468,7 @@ NTSTATUS gensec_socket_init(struct gensec_security *gensec_security, gensec_socket->packet = packet_init(gensec_socket); if (gensec_socket->packet == NULL) { *new_socket = NULL; + talloc_free(new_sock); return NT_STATUS_NO_MEMORY; } @@ -481,6 +481,7 @@ NTSTATUS gensec_socket_init(struct gensec_security *gensec_security, /* TODO: full-request that knows about maximum packet size */ + talloc_steal(gensec_socket, current_socket); *new_socket = new_sock; return NT_STATUS_OK; } diff --git a/source4/auth/gensec/spnego.c b/source4/auth/gensec/spnego.c index 1855e0583d..bf991616bd 100644 --- a/source4/auth/gensec/spnego.c +++ b/source4/auth/gensec/spnego.c @@ -1094,6 +1094,20 @@ static NTSTATUS gensec_spnego_update(struct gensec_security *gensec_security, TA return NT_STATUS_INVALID_PARAMETER; } +static void gensec_spnego_want_feature(struct gensec_security *gensec_security, + uint32_t feature) +{ + struct spnego_state *spnego_state = (struct spnego_state *)gensec_security->private_data; + + if (!spnego_state || !spnego_state->sub_sec_security) { + gensec_security->want_features |= feature; + return; + } + + gensec_want_feature(spnego_state->sub_sec_security, + feature); +} + static bool gensec_spnego_have_feature(struct gensec_security *gensec_security, uint32_t feature) { @@ -1133,6 +1147,7 @@ static const struct gensec_security_ops gensec_spnego_security_ops = { .unwrap_packets = gensec_spnego_unwrap_packets, .session_key = gensec_spnego_session_key, .session_info = gensec_spnego_session_info, + .want_feature = gensec_spnego_want_feature, .have_feature = gensec_spnego_have_feature, .enabled = true, .priority = GENSEC_SPNEGO diff --git a/source4/auth/gensec/spnego_parse.c b/source4/auth/gensec/spnego_parse.c index 5ea8cf7100..a79f15b8ee 100644 --- a/source4/auth/gensec/spnego_parse.c +++ b/source4/auth/gensec/spnego_parse.c @@ -23,7 +23,7 @@ #include "includes.h" #include "auth/gensec/spnego.h" #include "auth/gensec/gensec.h" -#include "lib/util/asn1.h" +#include "../lib/util/asn1.h" static bool read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx, struct spnego_negTokenInit *token) diff --git a/source4/auth/kerberos/gssapi_parse.c b/source4/auth/kerberos/gssapi_parse.c index 77e907d3fa..489ebcaa83 100644 --- a/source4/auth/kerberos/gssapi_parse.c +++ b/source4/auth/kerberos/gssapi_parse.c @@ -22,8 +22,10 @@ */ #include "includes.h" -#include "lib/util/asn1.h" +#include "../lib/util/asn1.h" #include "auth/gensec/gensec.h" +#include "system/kerberos.h" +#include "auth/kerberos/kerberos.h" /* generate a krb5 GSS-API wrapper packet given a ticket diff --git a/source4/auth/kerberos/kerberos.c b/source4/auth/kerberos/kerberos.c index 2579ab20cc..1889dcab4d 100644 --- a/source4/auth/kerberos/kerberos.c +++ b/source4/auth/kerberos/kerberos.c @@ -23,6 +23,7 @@ #include "includes.h" #include "system/kerberos.h" +#include "auth/kerberos/kerberos.h" #ifdef HAVE_KRB5 @@ -33,7 +34,7 @@ This version is built to use a keyblock, rather than needing the original password. */ - int kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc, + krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc, krb5_principal principal, krb5_keyblock *keyblock, time_t *expire_time, time_t *kdc_time) { @@ -77,7 +78,7 @@ simulate a kinit, putting the tgt in the given credentials cache. Orignally by remus@snapserver.com */ - int kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc, + krb5_error_code kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc, krb5_principal principal, const char *password, time_t *expire_time, time_t *kdc_time) { diff --git a/source4/auth/kerberos/kerberos_heimdal.c b/source4/auth/kerberos/kerberos_heimdal.c index f669d0f2f4..44cb39c518 100644 --- a/source4/auth/kerberos/kerberos_heimdal.c +++ b/source4/auth/kerberos/kerberos_heimdal.c @@ -36,6 +36,7 @@ #include "includes.h" #include "system/kerberos.h" +#include "auth/kerberos/kerberos.h" /* Taken from accept_sec_context.c,v 1.65 */ krb5_error_code smb_rd_req_return_stuff(krb5_context context, diff --git a/source4/auth/kerberos/kerberos_util.c b/source4/auth/kerberos/kerberos_util.c index 9002715065..0567565d33 100644 --- a/source4/auth/kerberos/kerberos_util.c +++ b/source4/auth/kerberos/kerberos_util.c @@ -32,7 +32,7 @@ struct principal_container { krb5_principal principal; }; -static int free_principal(struct principal_container *pc) +static krb5_error_code free_principal(struct principal_container *pc) { /* current heimdal - 0.6.3, which we need anyway, fixes segfaults here */ krb5_free_principal(pc->smb_krb5_context->krb5_context, pc->principal); @@ -241,19 +241,17 @@ static krb5_error_code salt_principal_from_credentials(TALLOC_CTX *parent_ctx, return 0; } -static int free_keytab(struct keytab_container *ktc) +static krb5_error_code free_keytab(struct keytab_container *ktc) { - krb5_kt_close(ktc->smb_krb5_context->krb5_context, ktc->keytab); - - return 0; + return krb5_kt_close(ktc->smb_krb5_context->krb5_context, ktc->keytab); } -int smb_krb5_open_keytab(TALLOC_CTX *mem_ctx, +krb5_error_code smb_krb5_open_keytab(TALLOC_CTX *mem_ctx, struct smb_krb5_context *smb_krb5_context, const char *keytab_name, struct keytab_container **ktc) { krb5_keytab keytab; - int ret; + krb5_error_code ret; ret = krb5_kt_resolve(smb_krb5_context->krb5_context, keytab_name, &keytab); if (ret) { DEBUG(1,("failed to open krb5 keytab: %s\n", @@ -339,7 +337,7 @@ static krb5_error_code keytab_add_keys(TALLOC_CTX *parent_ctx, return 0; } -static int create_keytab(TALLOC_CTX *parent_ctx, +static krb5_error_code create_keytab(TALLOC_CTX *parent_ctx, struct cli_credentials *machine_account, struct smb_krb5_context *smb_krb5_context, const char **enctype_strings, @@ -603,7 +601,7 @@ static krb5_error_code remove_old_entries(TALLOC_CTX *parent_ctx, return ret; } -int smb_krb5_update_keytab(TALLOC_CTX *parent_ctx, +krb5_error_code smb_krb5_update_keytab(TALLOC_CTX *parent_ctx, struct cli_credentials *machine_account, struct smb_krb5_context *smb_krb5_context, const char **enctype_strings, @@ -635,7 +633,7 @@ int smb_krb5_update_keytab(TALLOC_CTX *parent_ctx, return ret; } -int smb_krb5_create_memory_keytab(TALLOC_CTX *parent_ctx, +krb5_error_code smb_krb5_create_memory_keytab(TALLOC_CTX *parent_ctx, struct cli_credentials *machine_account, struct smb_krb5_context *smb_krb5_context, const char **enctype_strings, diff --git a/source4/auth/kerberos/krb5_init_context.c b/source4/auth/kerberos/krb5_init_context.c index 82e42a4560..90b542c4c4 100644 --- a/source4/auth/kerberos/krb5_init_context.c +++ b/source4/auth/kerberos/krb5_init_context.c @@ -49,13 +49,13 @@ struct smb_krb5_socket { krb5_krbhst_info *hi; }; -static int smb_krb5_context_destroy_1(struct smb_krb5_context *ctx) +static krb5_error_code smb_krb5_context_destroy_1(struct smb_krb5_context *ctx) { krb5_free_context(ctx->krb5_context); return 0; } -static int smb_krb5_context_destroy_2(struct smb_krb5_context *ctx) +static krb5_error_code smb_krb5_context_destroy_2(struct smb_krb5_context *ctx) { /* Otherwise krb5_free_context will try and close what we have already free()ed */ krb5_set_warn_dest(ctx->krb5_context, NULL); diff --git a/source4/auth/ntlm/auth.c b/source4/auth/ntlm/auth.c index 0f1ef3ccdb..bf6dc846e7 100644 --- a/source4/auth/ntlm/auth.c +++ b/source4/auth/ntlm/auth.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "auth/auth.h" #include "auth/ntlm/auth_proto.h" #include "lib/events/events.h" diff --git a/source4/auth/ntlm/auth_sam.c b/source4/auth/ntlm/auth_sam.c index 1b8233b8a4..78429106f6 100644 --- a/source4/auth/ntlm/auth_sam.c +++ b/source4/auth/ntlm/auth_sam.c @@ -23,7 +23,7 @@ #include "librpc/gen_ndr/ndr_netlogon.h" #include "system/time.h" #include "lib/ldb/include/ldb.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "auth/auth.h" #include "auth/ntlm/ntlm_check.h" #include "auth/ntlm/auth_proto.h" @@ -248,7 +248,7 @@ static NTSTATUS authsam_authenticate(struct auth_context *auth_context, } } - nt_status = samdb_result_passwords(mem_ctx, msgs[0], &lm_pwd, &nt_pwd); + nt_status = samdb_result_passwords(mem_ctx, auth_context->lp_ctx, msgs[0], &lm_pwd, &nt_pwd); NT_STATUS_NOT_OK_RETURN(nt_status); nt_status = authsam_password_ok(auth_context, mem_ctx, diff --git a/source4/auth/ntlm/auth_server.c b/source4/auth/ntlm/auth_server.c index bb8773e75e..fde9835cf2 100644 --- a/source4/auth/ntlm/auth_server.c +++ b/source4/auth/ntlm/auth_server.c @@ -80,6 +80,7 @@ static NTSTATUS server_get_challenge(struct auth_method_context *ctx, TALLOC_CTX io.in.workgroup = ""; /* only used with SPNEGO, disabled above */ io.in.options = smb_options; + lp_smbcli_session_options(ctx->auth_ctx->lp_ctx, &io.in.session_options); status = smb_composite_connect(&io, mem_ctx, lp_resolve_context(ctx->auth_ctx->lp_ctx), ctx->auth_ctx->event_ctx); @@ -111,7 +112,6 @@ static NTSTATUS server_check_password(struct auth_method_context *ctx, NTSTATUS nt_status; struct auth_serversupplied_info *server_info; struct cli_credentials *creds; - const char *user; struct smb_composite_sesssetup session_setup; struct smbcli_session *session = talloc_get_type(ctx->private_data, struct smbcli_session); diff --git a/source4/auth/ntlm/auth_util.c b/source4/auth/ntlm/auth_util.c index 1d86b858cf..64ceb437ad 100644 --- a/source4/auth/ntlm/auth_util.c +++ b/source4/auth/ntlm/auth_util.c @@ -23,6 +23,7 @@ #include "includes.h" #include "auth/auth.h" +#include "auth/auth_proto.h" #include "libcli/security/security.h" #include "libcli/auth/libcli_auth.h" #include "dsdb/samdb/samdb.h" diff --git a/source4/auth/ntlm/ntlm_check.c b/source4/auth/ntlm/ntlm_check.c index 0dbbce0edc..62dec84f1d 100644 --- a/source4/auth/ntlm/ntlm_check.c +++ b/source4/auth/ntlm/ntlm_check.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "librpc/gen_ndr/netlogon.h" #include "libcli/auth/libcli_auth.h" #include "param/param.h" diff --git a/source4/auth/ntlm/pam_errors.c b/source4/auth/ntlm/pam_errors.c index 9774ad8727..29fa4a8133 100644 --- a/source4/auth/ntlm/pam_errors.c +++ b/source4/auth/ntlm/pam_errors.c @@ -18,6 +18,7 @@ */ #include "includes.h" +#include "auth/ntlm/pam_errors.h" #ifdef WITH_HAVE_SECURITY_PAM_APPL_H #include diff --git a/source4/auth/ntlm/pam_errors.h b/source4/auth/ntlm/pam_errors.h index 959e1f3517..2dfe085b77 100644 --- a/source4/auth/ntlm/pam_errors.h +++ b/source4/auth/ntlm/pam_errors.h @@ -20,19 +20,6 @@ #ifndef __AUTH_NTLM_PAM_ERRORS_H__ #define __AUTH_NTLM_PAM_ERRORS_H__ -/* The following definitions come from auth/pam_errors.c */ - - -/***************************************************************************** -convert a PAM error to a NT status32 code - *****************************************************************************/ -NTSTATUS pam_to_nt_status(int pam_error); - -/***************************************************************************** -convert an NT status32 code to a PAM error - *****************************************************************************/ -int nt_status_to_pam(NTSTATUS nt_status); - /***************************************************************************** convert a PAM error to a NT status32 code *****************************************************************************/ diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c index 0b7f0da9af..cea18c45a7 100644 --- a/source4/auth/ntlmssp/ntlmssp.c +++ b/source4/auth/ntlmssp/ntlmssp.c @@ -235,6 +235,10 @@ NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security, { struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; + if (gensec_ntlmssp_state->expected_state != NTLMSSP_DONE) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + if (!gensec_ntlmssp_state->session_key.data) { return NT_STATUS_NO_USER_SESSION_KEY; } diff --git a/source4/auth/ntlmssp/ntlmssp_client.c b/source4/auth/ntlmssp/ntlmssp_client.c index 891761860c..eb990dee9c 100644 --- a/source4/auth/ntlmssp/ntlmssp_client.c +++ b/source4/auth/ntlmssp/ntlmssp_client.c @@ -24,7 +24,7 @@ #include "includes.h" #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c index e1c1e7cbb3..9256872036 100644 --- a/source4/auth/ntlmssp/ntlmssp_parse.c +++ b/source4/auth/ntlmssp/ntlmssp_parse.c @@ -20,8 +20,8 @@ */ #include "includes.h" -#include "pstring.h" #include "param/param.h" +#include "auth/ntlmssp/msrpc_parse.h" /* this is a tiny msrpc packet generator. I am only using this to diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c index 838596ee98..ad1ee8e871 100644 --- a/source4/auth/ntlmssp/ntlmssp_server.c +++ b/source4/auth/ntlmssp/ntlmssp_server.c @@ -24,8 +24,7 @@ #include "includes.h" #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" -#include "lib/crypto/crypto.h" -#include "system/filesys.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" @@ -125,8 +124,6 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security, { struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; DATA_BLOB struct_blob; - char dnsname[MAXHOSTNAMELEN], dnsdomname[MAXHOSTNAMELEN]; - const char *p; uint32_t neg_flags = 0; uint32_t ntlmssp_command, chal_flags; const uint8_t *cryptkey; @@ -183,25 +180,24 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security, gensec_ntlmssp_state->chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8); gensec_ntlmssp_state->internal_chal = data_blob_talloc(gensec_ntlmssp_state, cryptkey, 8); - dnsname[0] = '\0'; - if (gethostname(dnsname, sizeof(dnsname)) == -1) { - DEBUG(0,("gethostname failed\n")); - return NT_STATUS_UNSUCCESSFUL; - } - - /* This should be a 'netbios domain -> DNS domain' mapping */ - p = strchr(dnsname, '.'); - if (p != NULL) { - safe_strcpy(dnsdomname, p+1, sizeof(dnsdomname)); - strlower_m(dnsdomname); - } else { - dnsdomname[0] = '\0'; - } - /* This creates the 'blob' of names that appears at the end of the packet */ - if (chal_flags & NTLMSSP_CHAL_TARGET_INFO) - { + if (chal_flags & NTLMSSP_CHAL_TARGET_INFO) { + char dnsdomname[MAXHOSTNAMELEN], dnsname[MAXHOSTNAMELEN]; const char *target_name_dns = ""; + + /* Find out the DNS domain name */ + dnsdomname[0] = '\0'; + safe_strcpy(dnsdomname, lp_realm(gensec_security->lp_ctx), sizeof(dnsdomname) - 1); + strlower_m(dnsdomname); + + /* Find out the DNS host name */ + safe_strcpy(dnsname, gensec_ntlmssp_state->server_name, sizeof(dnsname) - 1); + if (dnsdomname[0] != '\0') { + safe_strcat(dnsname, ".", sizeof(dnsname) - 1); + safe_strcat(dnsname, dnsdomname, sizeof(dnsname) - 1); + } + strlower_m(dnsname); + if (chal_flags |= NTLMSSP_TARGET_TYPE_DOMAIN) { target_name_dns = dnsdomname; } else if (chal_flags |= NTLMSSP_TARGET_TYPE_SERVER) { @@ -221,7 +217,7 @@ NTSTATUS ntlmssp_server_negotiate(struct gensec_security *gensec_security, } { - /* Marshel the packet in the right format, be it unicode or ASCII */ + /* Marshal the packet in the right format, be it unicode or ASCII */ const char *gen_string; if (gensec_ntlmssp_state->unicode) { gen_string = "CdUdbddB"; diff --git a/source4/auth/ntlmssp/ntlmssp_sign.c b/source4/auth/ntlmssp/ntlmssp_sign.c index 063b16f539..49ed48df98 100644 --- a/source4/auth/ntlmssp/ntlmssp_sign.c +++ b/source4/auth/ntlmssp/ntlmssp_sign.c @@ -23,7 +23,7 @@ #include "auth/auth.h" #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" #include "param/param.h" diff --git a/source4/auth/sam.c b/source4/auth/sam.c index a2090afcdc..4255a6432a 100644 --- a/source4/auth/sam.c +++ b/source4/auth/sam.c @@ -23,12 +23,13 @@ #include "system/time.h" #include "auth/auth.h" #include -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "libcli/ldap/ldap.h" #include "librpc/gen_ndr/ndr_netlogon.h" #include "param/param.h" +#include "auth/auth_sam.h" const char *user_attrs[] = { /* required for the krb5 kdc */ @@ -207,7 +208,7 @@ _PUBLIC_ NTSTATUS authsam_account_ok(TALLOC_CTX *mem_ctx, if (logon_workstation && workstation_list && *workstation_list) { bool invalid_ws = true; int i; - const char **workstations = str_list_make(mem_ctx, workstation_list, ","); + const char **workstations = (const char **)str_list_make(mem_ctx, workstation_list, ","); for (i = 0; workstations && workstations[i]; i++) { DEBUG(10,("sam_account_ok: checking for workstation match '%s' and '%s'\n", diff --git a/source4/autogen.sh b/source4/autogen.sh index b721a45a99..9984712caf 100755 --- a/source4/autogen.sh +++ b/source4/autogen.sh @@ -2,6 +2,18 @@ # Run this script to build samba from git. +while true; do + case $1 in + (--version-file) + VERSION_FILE=$2 + shift 2 + ;; + (*) + break + ;; + esac +done + ## insert all possible names (only works with ## autoconf 2.x) TESTAUTOHEADER="autoheader autoheader-2.53 autoheader2.50 autoheader259 autoheader253" @@ -48,12 +60,12 @@ if test "$AUTOCONFFOUND" = "0" -o "$AUTOHEADERFOUND" = "0"; then fi echo "$0: running script/mkversion.sh" -./script/mkversion.sh || exit 1 +./script/mkversion.sh $VERSION_FILE || exit 1 rm -rf autom4te*.cache rm -f configure include/config_tmp.h* -IPATHS="-I. -Ilib/replace" +IPATHS="-I. -I../lib/replace" echo "$0: running $AUTOHEADER $IPATHS" $AUTOHEADER $IPATHS || exit 1 diff --git a/source4/scripting/python/ac_pkg_swig.m4 b/source4/build/m4/ac_pkg_swig.m4 similarity index 100% rename from source4/scripting/python/ac_pkg_swig.m4 rename to source4/build/m4/ac_pkg_swig.m4 diff --git a/source4/build/m4/check_make.m4 b/source4/build/m4/check_make.m4 index f497684453..343913f884 100644 --- a/source4/build/m4/check_make.m4 +++ b/source4/build/m4/check_make.m4 @@ -6,34 +6,28 @@ dnl Released under the GNU GPL dnl ------------------------------------------------------- dnl +AC_DEFUN([AC_SAMBA_GNU_MAKE], +[ AC_PATH_PROGS(MAKE,gmake make) AC_CACHE_CHECK([whether we have GNU make], samba_cv_gnu_make, [ if ! $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null then - AC_MSG_ERROR([Unable to find GNU make]) + samba_cv_gnu_make=no +else + samba_cv_gnu_make=yes +fi +]) +if test x$samba_cv_gnu_make = xyes; then + $1 +else + $2 fi ]) +AC_DEFUN([AC_SAMBA_GNU_MAKE_VERSION], +[ AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[ samba_cv_gnu_make_version=`$ac_cv_path_MAKE --version | head -1 | cut -d " " -f 3 2>/dev/null` ]) - GNU_MAKE_VERSION=$samba_cv_gnu_make_version - AC_SUBST(GNU_MAKE_VERSION) - - -new_make=no -AC_MSG_CHECKING([for GNU make >= 3.81]) -if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then - new_make=yes -fi -AC_MSG_RESULT($new_make) -automatic_dependencies=no -AX_CFLAGS_GCC_OPTION([-M -MT conftest.d -MF conftest.o], [], [ automatic_dependencies=$new_make ], []) -AC_MSG_CHECKING([Whether to use automatic dependencies]) -AC_ARG_ENABLE(automatic-dependencies, -[ --enable-automatic-dependencies Enable automatic dependencies], -[ automatic_dependencies=$enableval ], -[ automatic_dependencies=no ]) -AC_MSG_RESULT($automatic_dependencies) -AC_SUBST(automatic_dependencies) +]) diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4 index c45a803633..f7266e6e44 100644 --- a/source4/build/m4/check_path.m4 +++ b/source4/build/m4/check_path.m4 @@ -23,8 +23,13 @@ winbindd_socket_dir="${localstatedir}/run/winbindd" winbindd_privileged_socket_dir="${localstatedir}/lib/winbindd_privileged" ntp_signd_socket_dir="${localstatedir}/run/ntp_signd" -AC_ARG_WITH(fhs, -[AS_HELP_STRING([--with-fhs],[Use FHS-compliant paths (default=no)])], +AC_ARG_ENABLE(fhs, +[AS_HELP_STRING([--enable-fhs],[Use FHS-compliant paths (default=no)])], +[fhs=$enableval], +[fhs=no] +) + +if test x$fhs = xyes; then lockdir="${localstatedir}/lib/samba" piddir="${localstatedir}/run/samba" logfilebase="${localstatedir}/log/samba" @@ -36,7 +41,12 @@ AC_ARG_WITH(fhs, ntp_signd_socket_dir="${localstatedir}/run/samba/ntp_signd" winbindd_socket_dir="${localstatedir}/run/samba/winbindd" winbindd_privileged_socket_dir="${localstatedir}/lib/samba/winbindd_privileged" -) +else + # Check to prevent installing directly under /usr without the FHS + AS_IF([test $prefix == /usr || test $prefix == /usr/local],[ + AC_MSG_ERROR([Don't install directly under "/usr" or "/usr/local" without using the FHS option (--enable-fhs). This could lead to file loss!]) + ]) +fi ################################################# # set private directory location diff --git a/source4/build/m4/check_perl.m4 b/source4/build/m4/check_perl.m4 index 82ca242499..aaec9cf950 100644 --- a/source4/build/m4/check_perl.m4 +++ b/source4/build/m4/check_perl.m4 @@ -5,6 +5,8 @@ dnl Released under the GNU GPL dnl ------------------------------------------------------- dnl +AC_DEFUN([AC_SAMBA_PERL], +[ case "$host_os" in *irix*) # On IRIX, we prefer Freeware or Nekoware Perl, because the @@ -18,11 +20,13 @@ esac if test x"$PERL" = x""; then AC_MSG_WARN([No version of perl was found!]) - AC_MSG_ERROR([Please install perl from http://www.perl.com/]) + $2 +else + if test x"$debug" = x"yes";then + PERL="$PERL -W" + fi + export PERL + $1 fi -if test x"$debug" = x"yes";then - PERL="$PERL -W" -fi -export PERL +]) -AC_PATH_PROG(YAPP, yapp, false) diff --git a/source4/build/m4/check_python.m4 b/source4/build/m4/check_python.m4 new file mode 100644 index 0000000000..96f93a3d75 --- /dev/null +++ b/source4/build/m4/check_python.m4 @@ -0,0 +1,89 @@ +dnl Autoconf macros for finding a Python development environment +dnl +dnl Copyright (C) 2007-2008 Jelmer Vernooij +dnl Published under the GNU GPL, v3 or later +dnl +AC_ARG_VAR([PYTHON_VERSION],[The installed Python + version to use, for example '2.3'. This string + will be appended to the Python interpreter + canonical name.]) + +AC_DEFUN([TRY_LINK_PYTHON], +[ + if test $working_python = no; then + ac_save_LIBS="$LIBS" + ac_save_CFLAGS="$CFLAGS" + LIBS="$LIBS $1" + CFLAGS="$CFLAGS $2" + + AC_TRY_LINK([ + /* we have our own configure tests */ + #include + ],[ + Py_InitModule(NULL, NULL); + ],[ + PYTHON_LDFLAGS="$1" + PYTHON_CFLAGS="$2" + working_python=yes + ]) + LIBS="$ac_save_LIBS" + CFLAGS="$ac_save_CFLAGS" + fi +]) + +dnl Try to find a Python implementation including header files +dnl AC_SAMBA_PYTHON_DEVEL(RUN-IF-FOUND, RUN-IF-NOT-FOUND) +dnl +dnl Will set the following variables: +dnl $PYTHON +dnl $PYTHON_CONFIG (if found) +dnl $PYTHON_CFLAGS +dnl $PYTHON_LDFLAGS +AC_DEFUN([AC_SAMBA_PYTHON_DEVEL], +[ + AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) + if test -z "$PYTHON"; then + working_python=no + AC_MSG_WARN([No python found]) + fi + + dnl assume no working python + working_python=no + + if test -z "$PYTHON_VERSION"; then + AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) + else + AC_PATH_PROG([PYTHON_CONFIG], [python[$PYTHON_VERSION]-config]) + fi + + if test -z "$PYTHON_CONFIG"; then + AC_MSG_WARN([No python-config found]) + else + TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`]) + TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --cflags`]) + if test x$working_python = xno; then + # It seems the library path isn't included on some systems + base=`$PYTHON_CONFIG --prefix` + TRY_LINK_PYTHON([`echo -n -L${base}/lib " "; $PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`]) + TRY_LINK_PYTHON([`echo -n -L${base}/lib " "; $PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --cflags`]) + fi + fi + + if test x$PYTHON != x + then + DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=1), sysconfig.get_config_var('CFLAGS'))"` + DISTUTILS_LDFLAGS=`$PYTHON -c "from distutils import sysconfig; print '%s %s -lpython%s -L%s' % (sysconfig.get_config_var('LIBS'), sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('LIBPL'))"` + TRY_LINK_PYTHON($DISTUTILS_LDFLAGS, $DISTUTILS_CFLAGS) + fi + + AC_MSG_CHECKING(working python module support) + if test $working_python = yes; then + AC_MSG_RESULT([yes]) + $1 + else + AC_MSG_RESULT([no]) + $2 + fi +]) + + diff --git a/source4/build/m4/env.m4 b/source4/build/m4/env.m4 index 6c040b9bab..4cde95d5e7 100644 --- a/source4/build/m4/env.m4 +++ b/source4/build/m4/env.m4 @@ -1,6 +1,7 @@ dnl SMB Build Environment Checks dnl ------------------------------------------------------- dnl Copyright (C) Stefan (metze) Metzmacher 2004 +dnl Copyright (C) Jelmer Vernooij 2005,2008 dnl Released under the GNU GPL dnl ------------------------------------------------------- dnl @@ -40,7 +41,54 @@ fi m4_include(build/m4/check_path.m4) m4_include(build/m4/check_perl.m4) + +AC_SAMBA_PERL([], [AC_MSG_ERROR([Please install perl from http://www.perl.com/])]) + +AC_PATH_PROG(YAPP, yapp, false) + m4_include(build/m4/check_cc.m4) m4_include(build/m4/check_ld.m4) m4_include(build/m4/check_make.m4) + +AC_SAMBA_GNU_MAKE([AC_MSG_RESULT(found)], [AC_MSG_ERROR([Unable to find GNU make])]) +AC_SAMBA_GNU_MAKE_VERSION() +GNU_MAKE_VERSION=$samba_cv_gnu_make_version +AC_SUBST(GNU_MAKE_VERSION) + +new_make=no +AC_MSG_CHECKING([for GNU make >= 3.81]) +if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then + new_make=yes +fi +AC_MSG_RESULT($new_make) +automatic_dependencies=no +AX_CFLAGS_GCC_OPTION([-M -MT conftest.d -MF conftest.o], [], [ automatic_dependencies=$new_make ], []) +AC_MSG_CHECKING([Whether to use automatic dependencies]) +AC_ARG_ENABLE(automatic-dependencies, +[ --enable-automatic-dependencies Enable automatic dependencies], +[ automatic_dependencies=$enableval ], +[ automatic_dependencies=no ]) +AC_MSG_RESULT($automatic_dependencies) +AC_SUBST(automatic_dependencies) + m4_include(build/m4/check_doc.m4) + +m4_include(build/m4/check_python.m4) + +m4_include(build/m4/ac_pkg_swig.m4) + +AC_PROG_SWIG(1.3.36) + +AC_SAMBA_PYTHON_DEVEL([ +SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS]) +SMB_ENABLE(EXT_LIB_PYTHON,YES) +SMB_ENABLE(LIBPYTHON,YES) +],[ +AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.]) +]) + +AC_MSG_CHECKING(python library directory) +pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1, 0, '\\${prefix}')"` +AC_MSG_RESULT($pythondir) + +AC_SUBST(pythondir) diff --git a/source4/build/smb_build/summary.pm b/source4/build/smb_build/summary.pm index 4ea1ad525e..f6c1c50550 100644 --- a/source4/build/smb_build/summary.pm +++ b/source4/build/smb_build/summary.pm @@ -46,7 +46,7 @@ sub show($$) print "Summary:\n\n"; showitem($output, "SSL in SWAT and LDAP", ["GNUTLS"]); - showitem($output, "threads in smbd (see --with-pthread)", ["PTHREAD"]); + showitem($output, "threads in server (see --with-pthread)", ["PTHREAD"]); showitem($output, "intelligent command line editing", ["READLINE"]); showitem($output, "changing process titles (see --with-setproctitle)", ["SETPROCTITLE"]); showitem($output, "using extended attributes", ["XATTR"]); diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c index 310fb564e0..240f2b1dc2 100644 --- a/source4/cldap_server/cldap_server.c +++ b/source4/cldap_server/cldap_server.c @@ -127,6 +127,7 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l int num_interfaces; TALLOC_CTX *tmp_ctx = talloc_new(cldapd); NTSTATUS status; + int i; num_interfaces = iface_count(ifaces); @@ -135,14 +136,14 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l if (!lp_bind_interfaces_only(lp_ctx)) { status = cldapd_add_socket(cldapd, lp_ctx, "0.0.0.0"); NT_STATUS_NOT_OK_RETURN(status); - } else { - int i; - - for (i=0; icount == 1) { - talloc_steal(mem_ctx, dom_res); dom_dn = ldb_msg_find_attr_as_dn(sam_ctx, mem_ctx, ref_res->msgs[0], "ncName"); if (!dom_dn) { return NT_STATUS_NO_SUCH_DOMAIN; } - ret = ldb_search(sam_ctx, dom_dn, - LDB_SCOPE_BASE, "objectClass=domain", - dom_attrs, &dom_res); + ret = ldb_search(sam_ctx, mem_ctx, &dom_res, + dom_dn, LDB_SCOPE_BASE, dom_attrs, + "objectClass=domain"); if (ret != LDB_SUCCESS) { DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } - talloc_steal(mem_ctx, dom_res); if (dom_res->count != 1) { DEBUG(2,("Error finding domain '%s'/'%s' in sam\n", domain, ldb_dn_get_linearized(dom_dn))); return NT_STATUS_NO_SUCH_DOMAIN; @@ -123,11 +121,11 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, struct ldb_dn *dom_dn; /* try and find the domain */ - ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res, - partitions_basedn, LDB_SCOPE_ONELEVEL, - ref_attrs, - "(&(objectClass=crossRef)(ncName=*)(nETBIOSName=%s))", - ldb_binary_encode_string(mem_ctx, netbios_domain)); + ret = ldb_search(sam_ctx, mem_ctx, &ref_res, + partitions_basedn, LDB_SCOPE_ONELEVEL, + ref_attrs, + "(&(objectClass=crossRef)(ncName=*)(nETBIOSName=%s))", + ldb_binary_encode_string(mem_ctx, netbios_domain)); if (ret != LDB_SUCCESS) { DEBUG(2,("Unable to find referece to '%s' in sam: %s\n", @@ -135,19 +133,17 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } else if (ref_res->count == 1) { - talloc_steal(mem_ctx, dom_res); dom_dn = ldb_msg_find_attr_as_dn(sam_ctx, mem_ctx, ref_res->msgs[0], "ncName"); if (!dom_dn) { return NT_STATUS_NO_SUCH_DOMAIN; } - ret = ldb_search(sam_ctx, dom_dn, - LDB_SCOPE_BASE, "objectClass=domain", - dom_attrs, &dom_res); + ret = ldb_search(sam_ctx, mem_ctx, &dom_res, + dom_dn, LDB_SCOPE_BASE, dom_attrs, + "objectClass=domain"); if (ret != LDB_SUCCESS) { DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(sam_ctx))); return NT_STATUS_NO_SUCH_DOMAIN; } - talloc_steal(mem_ctx, dom_res); if (dom_res->count != 1) { DEBUG(2,("Error finding domain '%s'/'%s' in sam\n", domain, ldb_dn_get_linearized(dom_dn))); return NT_STATUS_NO_SUCH_DOMAIN; @@ -179,7 +175,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return NT_STATUS_INVALID_PARAMETER; } - ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &dom_res, + ret = ldb_search(sam_ctx, mem_ctx, &dom_res, NULL, LDB_SCOPE_SUBTREE, dom_attrs, "(&(objectCategory=DomainDNS)(objectGUID=%s))", @@ -196,7 +192,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, return NT_STATUS_INVALID_PARAMETER; } - ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &dom_res, + ret = ldb_search(sam_ctx, mem_ctx, &dom_res, NULL, LDB_SCOPE_SUBTREE, dom_attrs, "(&(objectCategory=DomainDNS)(objectSID=%s))", @@ -210,7 +206,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, return NT_STATUS_NO_SUCH_DOMAIN; } else if (dom_res->count == 1) { /* try and find the domain */ - ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res, + ret = ldb_search(sam_ctx, mem_ctx, &ref_res, partitions_basedn, LDB_SCOPE_ONELEVEL, ref_attrs, "(&(objectClass=crossRef)(ncName=%s))", @@ -260,7 +256,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, acct_control = acct_control & (ACB_TEMPDUP | ACB_NORMAL | ACB_DOMTRUST | ACB_WSTRUST | ACB_SVRTRUST); /* We must exclude disabled accounts, but otherwise do the bitwise match the client asked for */ - ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &user_res, + ret = ldb_search(sam_ctx, mem_ctx, &user_res, dom_res->msgs[0]->dn, LDB_SCOPE_SUBTREE, none_attrs, "(&(objectClass=user)(samAccountName=%s)" @@ -286,8 +282,8 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, server_type = NBT_SERVER_DS | NBT_SERVER_TIMESERV | NBT_SERVER_CLOSEST | NBT_SERVER_WRITABLE | - NBT_SERVER_GOOD_TIMESERV | NBT_SERVER_DS_DNS_CONTR | - NBT_SERVER_DS_DNS_DOMAIN; + NBT_SERVER_GOOD_TIMESERV | DS_DNS_CONTROLLER | + DS_DNS_DOMAIN; if (samdb_is_pdc(sam_ctx)) { server_type |= NBT_SERVER_PDC; @@ -305,8 +301,8 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, server_type |= NBT_SERVER_KDC; } - if (!ldb_dn_compare_base(ldb_get_root_basedn(sam_ctx), ldb_get_default_basedn(sam_ctx))) { - server_type |= NBT_SERVER_DS_DNS_FOREST; + if (ldb_dn_compare(ldb_get_root_basedn(sam_ctx), ldb_get_default_basedn(sam_ctx)) == 0) { + server_type |= DS_DNS_FOREST; } pdc_name = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name(lp_ctx)); @@ -335,68 +331,68 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, /* could check if the user exists */ if (user_known) { - netlogon->nt5_ex.command = LOGON_SAM_LOGON_RESPONSE_EX; + netlogon->data.nt5_ex.command = LOGON_SAM_LOGON_RESPONSE_EX; } else { - netlogon->nt5_ex.command = LOGON_SAM_LOGON_USER_UNKNOWN_EX; + netlogon->data.nt5_ex.command = LOGON_SAM_LOGON_USER_UNKNOWN_EX; } - netlogon->nt5_ex.server_type = server_type; - netlogon->nt5_ex.domain_uuid = domain_uuid; - netlogon->nt5_ex.forest = realm; - netlogon->nt5_ex.dns_domain = dns_domain; - netlogon->nt5_ex.pdc_dns_name = pdc_dns_name; - netlogon->nt5_ex.domain = flatname; - netlogon->nt5_ex.pdc_name = lp_netbios_name(lp_ctx); - netlogon->nt5_ex.user_name = user; - netlogon->nt5_ex.server_site = server_site; - netlogon->nt5_ex.client_site = client_site; + netlogon->data.nt5_ex.server_type = server_type; + netlogon->data.nt5_ex.domain_uuid = domain_uuid; + netlogon->data.nt5_ex.forest = realm; + netlogon->data.nt5_ex.dns_domain = dns_domain; + netlogon->data.nt5_ex.pdc_dns_name = pdc_dns_name; + netlogon->data.nt5_ex.domain = flatname; + netlogon->data.nt5_ex.pdc_name = lp_netbios_name(lp_ctx); + netlogon->data.nt5_ex.user_name = user; + netlogon->data.nt5_ex.server_site = server_site; + netlogon->data.nt5_ex.client_site = client_site; if (version & NETLOGON_NT_VERSION_5EX_WITH_IP) { /* Clearly this needs to be fixed up for IPv6 */ extra_flags = NETLOGON_NT_VERSION_5EX_WITH_IP; - netlogon->nt5_ex.sockaddr.sa_family = 2; - netlogon->nt5_ex.sockaddr.pdc_ip = pdc_ip; - netlogon->nt5_ex.sockaddr.remaining = data_blob_talloc_zero(mem_ctx, 8); + netlogon->data.nt5_ex.sockaddr.sockaddr_family = 2; + netlogon->data.nt5_ex.sockaddr.pdc_ip = pdc_ip; + netlogon->data.nt5_ex.sockaddr.remaining = data_blob_talloc_zero(mem_ctx, 8); } - netlogon->nt5_ex.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5EX|extra_flags; - netlogon->nt5_ex.lmnt_token = 0xFFFF; - netlogon->nt5_ex.lm20_token = 0xFFFF; + netlogon->data.nt5_ex.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5EX|extra_flags; + netlogon->data.nt5_ex.lmnt_token = 0xFFFF; + netlogon->data.nt5_ex.lm20_token = 0xFFFF; } else if (version & NETLOGON_NT_VERSION_5) { netlogon->ntver = NETLOGON_NT_VERSION_5; /* could check if the user exists */ if (user_known) { - netlogon->nt5.command = LOGON_SAM_LOGON_RESPONSE; + netlogon->data.nt5.command = LOGON_SAM_LOGON_RESPONSE; } else { - netlogon->nt5.command = LOGON_SAM_LOGON_USER_UNKNOWN; + netlogon->data.nt5.command = LOGON_SAM_LOGON_USER_UNKNOWN; } - netlogon->nt5.pdc_name = pdc_name; - netlogon->nt5.user_name = user; - netlogon->nt5.domain_name = flatname; - netlogon->nt5.domain_uuid = domain_uuid; - netlogon->nt5.forest = realm; - netlogon->nt5.dns_domain = dns_domain; - netlogon->nt5.pdc_dns_name = pdc_dns_name; - netlogon->nt5.pdc_ip = pdc_ip; - netlogon->nt5.server_type = server_type; - netlogon->nt5.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5; - netlogon->nt5.lmnt_token = 0xFFFF; - netlogon->nt5.lm20_token = 0xFFFF; + netlogon->data.nt5.pdc_name = pdc_name; + netlogon->data.nt5.user_name = user; + netlogon->data.nt5.domain_name = flatname; + netlogon->data.nt5.domain_uuid = domain_uuid; + netlogon->data.nt5.forest = realm; + netlogon->data.nt5.dns_domain = dns_domain; + netlogon->data.nt5.pdc_dns_name = pdc_dns_name; + netlogon->data.nt5.pdc_ip = pdc_ip; + netlogon->data.nt5.server_type = server_type; + netlogon->data.nt5.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5; + netlogon->data.nt5.lmnt_token = 0xFFFF; + netlogon->data.nt5.lm20_token = 0xFFFF; } else /* (version & NETLOGON_NT_VERSION_1) and all other cases */ { netlogon->ntver = NETLOGON_NT_VERSION_1; /* could check if the user exists */ if (user_known) { - netlogon->nt4.command = LOGON_SAM_LOGON_RESPONSE; + netlogon->data.nt4.command = LOGON_SAM_LOGON_RESPONSE; } else { - netlogon->nt4.command = LOGON_SAM_LOGON_USER_UNKNOWN; + netlogon->data.nt4.command = LOGON_SAM_LOGON_USER_UNKNOWN; } - netlogon->nt4.server = pdc_name; - netlogon->nt4.user_name = user; - netlogon->nt4.domain = flatname; - netlogon->nt4.nt_version = NETLOGON_NT_VERSION_1; - netlogon->nt4.lmnt_token = 0xFFFF; - netlogon->nt4.lm20_token = 0xFFFF; + netlogon->data.nt4.server = pdc_name; + netlogon->data.nt4.user_name = user; + netlogon->data.nt4.domain = flatname; + netlogon->data.nt4.nt_version = NETLOGON_NT_VERSION_1; + netlogon->data.nt4.lmnt_token = 0xFFFF; + netlogon->data.nt4.lm20_token = 0xFFFF; } return NT_STATUS_OK; diff --git a/source4/cldap_server/rootdse.c b/source4/cldap_server/rootdse.c index 4ff71c0863..65786e6708 100644 --- a/source4/cldap_server/rootdse.c +++ b/source4/cldap_server/rootdse.c @@ -66,22 +66,19 @@ static void cldapd_rootdse_fill(struct cldapd_server *cldapd, attrs[i] = NULL; } - lreq = talloc(mem_ctx, struct ldb_request); - if (lreq == NULL) goto nomem; - res = talloc_zero(mem_ctx, struct ldb_result); if (res == NULL) goto nomem; - lreq->operation = LDB_SEARCH; - lreq->op.search.base = basedn; - lreq->op.search.scope = scope; - lreq->op.search.tree = search->tree; - lreq->op.search.attrs = attrs; - - lreq->controls = NULL; + ldb_ret = ldb_build_search_req_ex(&lreq, cldapd->samctx, mem_ctx, + basedn, scope, + search->tree, attrs, + NULL, + res, ldb_search_default_callback, + NULL); - lreq->context = res; - lreq->callback = ldb_search_default_callback; + if (ldb_ret != LDB_SUCCESS) { + goto reply; + } /* Copy the timeout from the incoming call */ ldb_set_timeout(cldapd->samctx, lreq, search->timelimit); diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c index 141b165ad4..5f07826d06 100644 --- a/source4/client/cifsdd.c +++ b/source4/client/cifsdd.c @@ -357,7 +357,8 @@ static void print_transfer_stats(void) static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, struct event_context *ev, const char * which, const char **ports, - struct smbcli_options *smb_options) + struct smbcli_options *smb_options, + struct smbcli_session_options *smb_session_options) { int options = 0; const char * path = NULL; @@ -379,13 +380,13 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, path = check_arg_pathname("if"); handle = dd_open_path(resolve_ctx, ev, path, ports, check_arg_numeric("ibs"), options, - smb_options); + smb_options, smb_session_options); } else if (strcmp(which, "of") == 0) { options |= DD_WRITE; path = check_arg_pathname("of"); handle = dd_open_path(resolve_ctx, ev, path, ports, check_arg_numeric("obs"), options, - smb_options); + smb_options, smb_session_options); } else { SMB_ASSERT(0); return(NULL); @@ -412,12 +413,14 @@ static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx) struct dd_iohandle * ofile; struct smbcli_options options; + struct smbcli_session_options session_options; ibs = check_arg_numeric("ibs"); obs = check_arg_numeric("obs"); count = check_arg_numeric("count"); lp_smbcli_options(lp_ctx, &options); + lp_smbcli_session_options(lp_ctx, &session_options); /* Allocate IO buffer. We need more than the max IO size because we * could accumulate a remainder if ibs and obs don't match. @@ -436,12 +439,14 @@ static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx) (unsigned long long)iomax, options.max_xmit)); if (!(ifile = open_file(lp_resolve_context(lp_ctx), ev, "if", - lp_smb_ports(lp_ctx), &options))) { + lp_smb_ports(lp_ctx), &options, + &session_options))) { return(FILESYS_EXIT_CODE); } if (!(ofile = open_file(lp_resolve_context(lp_ctx), ev, "of", - lp_smb_ports(lp_ctx), &options))) { + lp_smb_ports(lp_ctx), &options, + &session_options))) { return(FILESYS_EXIT_CODE); } diff --git a/source4/client/cifsdd.h b/source4/client/cifsdd.h index 21a4ad4882..3195e4334f 100644 --- a/source4/client/cifsdd.h +++ b/source4/client/cifsdd.h @@ -89,6 +89,7 @@ struct dd_iohandle #define DD_OPLOCK 0x00000008 struct smbcli_options; +struct smbcli_session_options; struct event_context; struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, @@ -96,7 +97,8 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, const char * path, const char **ports, uint64_t io_size, int options, - struct smbcli_options *smb_options); + struct smbcli_options *smb_options, + struct smbcli_session_options *smb_session_options); bool dd_fill_block(struct dd_iohandle * h, uint8_t * buf, uint64_t * buf_size, uint64_t need_size, uint64_t block_size); bool dd_flush_block(struct dd_iohandle * h, uint8_t * buf, diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c index 4297c30012..25194a621a 100644 --- a/source4/client/cifsddio.c +++ b/source4/client/cifsddio.c @@ -225,7 +225,8 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct const char * host, const char **ports, const char * share, - struct smbcli_options *options) + struct smbcli_options *options, + struct smbcli_session_options *session_options) { NTSTATUS ret; struct smbcli_state * cli = NULL; @@ -236,7 +237,8 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct ret = smbcli_full_connection(NULL, &cli, host, ports, share, NULL /* devtype */, cmdline_credentials, resolve_ctx, - ev, options); + ev, options, + session_options); if (!NT_STATUS_IS_OK(ret)) { fprintf(stderr, "%s: connecting to //%s/%s: %s\n", @@ -302,7 +304,8 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx const char * path, uint64_t io_size, int options, - struct smbcli_options *smb_options) + struct smbcli_options *smb_options, + struct smbcli_session_options *smb_session_options) { struct cifs_handle * smbh; @@ -323,7 +326,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx smbh->h.io_seek = smb_seek_func; if ((smbh->cli = init_smb_session(resolve_ctx, ev, host, ports, share, - smb_options)) == NULL) { + smb_options, smb_session_options)) == NULL) { return(NULL); } @@ -344,7 +347,8 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, const char **ports, uint64_t io_size, int options, - struct smbcli_options *smb_options) + struct smbcli_options *smb_options, + struct smbcli_session_options *smb_session_options) { if (file_exist(path)) { return(open_fd_handle(path, io_size, options)); @@ -361,7 +365,8 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, return(open_cifs_handle(resolve_ctx, ev, host, ports, share, remain, - io_size, options, smb_options)); + io_size, options, smb_options, + smb_session_options)); } return(open_fd_handle(path, io_size, options)); diff --git a/source4/client/client.c b/source4/client/client.c index e05e195372..3213c8931f 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -41,7 +41,7 @@ #include "libcli/util/clilsa.h" #include "system/dir.h" #include "system/filesys.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "system/readline.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" @@ -2754,7 +2754,7 @@ process a -c command string ****************************************************************************/ static int process_command_string(struct smbclient_context *ctx, const char *cmd) { - const char **lines; + char **lines; int i, rc = 0; lines = str_list_make(NULL, cmd, ";"); @@ -3032,7 +3032,8 @@ static bool do_connect(struct smbclient_context *ctx, const char *specified_server, const char **ports, const char *specified_share, struct cli_credentials *cred, - struct smbcli_options *options) + struct smbcli_options *options, + struct smbcli_session_options *session_options) { NTSTATUS status; char *server, *share; @@ -3051,7 +3052,7 @@ static bool do_connect(struct smbclient_context *ctx, status = smbcli_full_connection(ctx, &ctx->cli, server, ports, share, NULL, cred, resolve_ctx, - ev_ctx, options); + ev_ctx, options, session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to \\\\%s\\%s failed - %s\n", server, share, nt_errstr(status)); @@ -3138,6 +3139,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, struct smbclient_context *ctx; const char *cmdstr = NULL; struct smbcli_options smb_options; + struct smbcli_session_options smb_session_options; struct poptOption long_options[] = { POPT_AUTOHELP @@ -3227,6 +3229,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, poptFreeContext(pc); lp_smbcli_options(cmdline_lp_ctx, &smb_options); + lp_smbcli_session_options(cmdline_lp_ctx, &smb_session_options); ev_ctx = s4_event_context_init(talloc_autofree_context()); @@ -3255,7 +3258,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, - cmdline_credentials, &smb_options)) + cmdline_credentials, &smb_options, &smb_session_options)) return 1; if (base_directory) diff --git a/source4/client/smbmount.c b/source4/client/smbmount.c index 9ab6c375f2..37c9eaadc4 100644 --- a/source4/client/smbmount.c +++ b/source4/client/smbmount.c @@ -111,7 +111,8 @@ static void usr1_handler(int x) /***************************************************** return a connection to a server *******************************************************/ -static struct smbcli_state *do_connection(const char *the_service, bool unicode, int maxprotocol) +static struct smbcli_state *do_connection(const char *the_service, bool unicode, int maxprotocol, + struct smbcli_session_options session_options) { struct smbcli_state *c; struct nmb_name called, calling; @@ -210,11 +211,12 @@ static struct smbcli_state *do_connection(const char *the_service, bool unicode, if (!smbcli_session_setup(c, username, password, strlen(password), password, strlen(password), - workgroup)) { + workgroup, session_options)) { /* if a password was not supplied then try again with a null username */ if (password[0] || !username[0] || - !smbcli_session_setup(c, "", "", 0, "", 0, workgroup)) { + !smbcli_session_setup(c, "", "", 0, "", 0, workgroup, + session_options)) { DEBUG(0,("%d: session setup failed: %s\n", sys_getpid(), smbcli_errstr(c))); talloc_free(c); @@ -329,6 +331,9 @@ static void send_fs_socket(struct loadparm_context *lp_ctx, int fd, closed = 0, res = 1; pid_t parentpid = getppid(); struct smb_conn_opt conn_options; + struct smbcli_session_options session_options; + + lp_smbcli_session_options(lp_ctx, &session_options); memset(&conn_options, 0, sizeof(conn_options)); @@ -409,7 +414,8 @@ static void send_fs_socket(struct loadparm_context *lp_ctx, DEBUG(2,("mount.smbfs[%d]: got signal, getting new socket\n", sys_getpid())); c = do_connection(the_service, lp_unicode(lp_ctx), - lp_cli_maxprotocol(lp_ctx)); + lp_cli_maxprotocol(lp_ctx), + session_options); } } @@ -430,14 +436,17 @@ static void init_mount(struct loadparm_context *lp_ctx) struct smbcli_state *c; char *args[20]; int i, status; + struct smbcli_session_options session_options; if (realpath(mpoint, mount_point) == NULL) { fprintf(stderr, "Could not resolve mount point %s\n", mpoint); return; } + lp_smbcli_session_options(lp_ctx, &session_options); - c = do_connection(service, lp_unicode(lp_ctx), lp_cli_maxprotocol(lp_ctx)); + c = do_connection(service, lp_unicode(lp_ctx), lp_cli_maxprotocol(lp_ctx), + session_options); if (!c) { fprintf(stderr,"SMB connection failed\n"); exit(1); diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index cc61974cbd..c09d10900b 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -23,6 +23,7 @@ #include "cluster/cluster.h" #include "cluster/cluster_private.h" #include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" static struct cluster_ops *ops; diff --git a/source4/cluster/ctdb/brlock_ctdb.c b/source4/cluster/ctdb/brlock_ctdb.c index 1b22c6c727..01d60901a6 100644 --- a/source4/cluster/ctdb/brlock_ctdb.c +++ b/source4/cluster/ctdb/brlock_ctdb.c @@ -21,7 +21,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "messaging/messaging.h" #include "lib/messaging/irpc.h" #include "libcli/libcli.h" diff --git a/source4/cluster/ctdb/client/ctdb_client.c b/source4/cluster/ctdb/client/ctdb_client.c index 2af0d418a8..a83dd7aebe 100644 --- a/source4/cluster/ctdb/client/ctdb_client.c +++ b/source4/cluster/ctdb/client/ctdb_client.c @@ -20,13 +20,13 @@ #include "includes.h" #include "tdb_wrap.h" -#include "lib/tdb/include/tdb.h" -#include "lib/util/dlinklist.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* allocate a packet for use in client<->daemon communication diff --git a/source4/cluster/ctdb/common/ctdb_io.c b/source4/cluster/ctdb/common/ctdb_io.c index ca9c635878..9116bd69f7 100644 --- a/source4/cluster/ctdb/common/ctdb_io.c +++ b/source4/cluster/ctdb/common/ctdb_io.c @@ -21,9 +21,9 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" diff --git a/source4/cluster/ctdb/common/ctdb_ltdb.c b/source4/cluster/ctdb/common/ctdb_ltdb.c index 92adc4a12a..e9ee55f6a7 100644 --- a/source4/cluster/ctdb/common/ctdb_ltdb.c +++ b/source4/cluster/ctdb/common/ctdb_ltdb.c @@ -19,12 +19,12 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" #include "tdb_wrap.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* find an attached ctdb_db handle given a name diff --git a/source4/cluster/ctdb/common/ctdb_message.c b/source4/cluster/ctdb/common/ctdb_message.c index 1aea28fd35..323e90c9e0 100644 --- a/source4/cluster/ctdb/common/ctdb_message.c +++ b/source4/cluster/ctdb/common/ctdb_message.c @@ -22,11 +22,11 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* this dispatches the messages to the registered ctdb message handler diff --git a/source4/cluster/ctdb/common/ctdb_util.c b/source4/cluster/ctdb/common/ctdb_util.c index f11388331d..67eb32221a 100644 --- a/source4/cluster/ctdb/common/ctdb_util.c +++ b/source4/cluster/ctdb/common/ctdb_util.c @@ -19,7 +19,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" diff --git a/source4/cluster/ctdb/ctdb_cluster.c b/source4/cluster/ctdb/ctdb_cluster.c index ce295c4474..d0ceef4ad1 100644 --- a/source4/cluster/ctdb/ctdb_cluster.c +++ b/source4/cluster/ctdb/ctdb_cluster.c @@ -24,12 +24,13 @@ #include "cluster/cluster.h" #include "system/filesys.h" #include "cluster/cluster_private.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "include/ctdb.h" #include "tdb_wrap.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" -#include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" +#include "cluster/ctdb/ctdb_cluster.h" /* a linked list of messaging handlers, allowing incoming messages to be directed to the right messaging context */ diff --git a/source4/cluster/ctdb/example/cluster_start.sh b/source4/cluster/ctdb/example/cluster_start.sh index 575d031c95..825eadb483 100755 --- a/source4/cluster/ctdb/example/cluster_start.sh +++ b/source4/cluster/ctdb/example/cluster_start.sh @@ -1,12 +1,12 @@ #!/bin/sh -killall smbd +killall samba sleep 1 -killall -9 smbd +killall -9 samba killall -9 valgrind type=$1 -xterm -e $type bin/smbd -s /home/tridge/samba/samba4.svn/prefix/etc/smb.conf.node1 -M single -i & -xterm -e $type bin/smbd -s /home/tridge/samba/samba4.svn/prefix/etc/smb.conf.node2 -M single -i & +xterm -e $type bin/samba -s /home/tridge/samba/samba4.svn/prefix/etc/smb.conf.node1 -M single -i & +xterm -e $type bin/samba -s /home/tridge/samba/samba4.svn/prefix/etc/smb.conf.node2 -M single -i & diff --git a/source4/cluster/ctdb/opendb_ctdb.c b/source4/cluster/ctdb/opendb_ctdb.c index b1faf9e0e6..3313798bee 100644 --- a/source4/cluster/ctdb/opendb_ctdb.c +++ b/source4/cluster/ctdb/opendb_ctdb.c @@ -40,7 +40,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "messaging/messaging.h" #include "tdb_wrap.h" #include "lib/messaging/irpc.h" diff --git a/source4/cluster/ctdb/server/ctdb_call.c b/source4/cluster/ctdb/server/ctdb_call.c index bbe07717ed..0d09241d52 100644 --- a/source4/cluster/ctdb/server/ctdb_call.c +++ b/source4/cluster/ctdb/server/ctdb_call.c @@ -22,7 +22,7 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/util/dlinklist.h" #include "system/network.h" #include "system/filesys.h" diff --git a/source4/cluster/ctdb/server/ctdb_control.c b/source4/cluster/ctdb/server/ctdb_control.c index 4b826b5187..ba94b9dd24 100644 --- a/source4/cluster/ctdb/server/ctdb_control.c +++ b/source4/cluster/ctdb/server/ctdb_control.c @@ -18,7 +18,7 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "system/wait.h" diff --git a/source4/cluster/ctdb/server/ctdb_daemon.c b/source4/cluster/ctdb/server/ctdb_daemon.c index f96cd86916..46e81ab3c3 100644 --- a/source4/cluster/ctdb/server/ctdb_daemon.c +++ b/source4/cluster/ctdb/server/ctdb_daemon.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/events/events.h" #include "lib/util/dlinklist.h" #include "system/network.h" diff --git a/source4/cluster/ctdb/server/ctdb_freeze.c b/source4/cluster/ctdb/server/ctdb_freeze.c index 2294266890..391c6b86d0 100644 --- a/source4/cluster/ctdb/server/ctdb_freeze.c +++ b/source4/cluster/ctdb/server/ctdb_freeze.c @@ -18,7 +18,7 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "system/wait.h" diff --git a/source4/cluster/ctdb/server/ctdb_lockwait.c b/source4/cluster/ctdb/server/ctdb_lockwait.c index 2fc3e7a3ed..1112ab2054 100644 --- a/source4/cluster/ctdb/server/ctdb_lockwait.c +++ b/source4/cluster/ctdb/server/ctdb_lockwait.c @@ -21,7 +21,7 @@ #include "lib/events/events.h" #include "system/filesys.h" #include "system/wait.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "../include/ctdb_private.h" diff --git a/source4/cluster/ctdb/server/ctdb_ltdb_server.c b/source4/cluster/ctdb/server/ctdb_ltdb_server.c index 68ed546b27..cabdeb124c 100644 --- a/source4/cluster/ctdb/server/ctdb_ltdb_server.c +++ b/source4/cluster/ctdb/server/ctdb_ltdb_server.c @@ -19,7 +19,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" diff --git a/source4/cluster/ctdb/server/ctdb_recover.c b/source4/cluster/ctdb/server/ctdb_recover.c index 6065016e1f..1e70d1de7a 100644 --- a/source4/cluster/ctdb/server/ctdb_recover.c +++ b/source4/cluster/ctdb/server/ctdb_recover.c @@ -19,7 +19,7 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "system/wait.h" diff --git a/source4/cluster/ctdb/server/ctdb_server.c b/source4/cluster/ctdb/server/ctdb_server.c index 1480127327..0cfbdc0f2f 100644 --- a/source4/cluster/ctdb/server/ctdb_server.c +++ b/source4/cluster/ctdb/server/ctdb_server.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/events/events.h" #include "lib/util/dlinklist.h" #include "system/network.h" diff --git a/source4/cluster/ctdb/server/ctdb_takeover.c b/source4/cluster/ctdb/server/ctdb_takeover.c index 42a23808dd..53a5a1dc3c 100644 --- a/source4/cluster/ctdb/server/ctdb_takeover.c +++ b/source4/cluster/ctdb/server/ctdb_takeover.c @@ -19,7 +19,7 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/util/dlinklist.h" #include "system/network.h" #include "system/filesys.h" diff --git a/source4/cluster/ctdb/server/ctdb_traverse.c b/source4/cluster/ctdb/server/ctdb_traverse.c index 233de62e2b..d735594e73 100644 --- a/source4/cluster/ctdb/server/ctdb_traverse.c +++ b/source4/cluster/ctdb/server/ctdb_traverse.c @@ -21,7 +21,7 @@ #include "lib/events/events.h" #include "system/filesys.h" #include "system/wait.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "../include/ctdb_private.h" typedef void (*ctdb_traverse_fn_t)(void *private_data, TDB_DATA key, TDB_DATA data); diff --git a/source4/cluster/ctdb/takeover/ctdb_takeover.c b/source4/cluster/ctdb/takeover/ctdb_takeover.c index 862382d90a..ae68725271 100644 --- a/source4/cluster/ctdb/takeover/ctdb_takeover.c +++ b/source4/cluster/ctdb/takeover/ctdb_takeover.c @@ -19,7 +19,7 @@ */ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "system/wait.h" diff --git a/source4/cluster/ctdb/tcp/tcp_connect.c b/source4/cluster/ctdb/tcp/tcp_connect.c index 2f828e5717..3c167532ba 100644 --- a/source4/cluster/ctdb/tcp/tcp_connect.c +++ b/source4/cluster/ctdb/tcp/tcp_connect.c @@ -19,7 +19,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" diff --git a/source4/cluster/ctdb/tcp/tcp_init.c b/source4/cluster/ctdb/tcp/tcp_init.c index f5d4e4c1d6..b8296d5244 100644 --- a/source4/cluster/ctdb/tcp/tcp_init.c +++ b/source4/cluster/ctdb/tcp/tcp_init.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/events/events.h" #include "system/network.h" #include "system/filesys.h" diff --git a/source4/cluster/ctdb/tcp/tcp_io.c b/source4/cluster/ctdb/tcp/tcp_io.c index c10afb3425..d3afdc165a 100644 --- a/source4/cluster/ctdb/tcp/tcp_io.c +++ b/source4/cluster/ctdb/tcp/tcp_io.c @@ -20,7 +20,7 @@ #include "includes.h" #include "lib/events/events.h" #include "lib/util/dlinklist.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "system/network.h" #include "system/filesys.h" #include "../include/ctdb_private.h" diff --git a/source4/cluster/local.c b/source4/cluster/local.c index 96636927f1..5b872a3e2e 100644 --- a/source4/cluster/local.c +++ b/source4/cluster/local.c @@ -22,11 +22,11 @@ #include "includes.h" #include "cluster/cluster.h" #include "cluster/cluster_private.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "tdb_wrap.h" #include "system/filesys.h" #include "param/param.h" -#include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" /* server a server_id for the local node diff --git a/source4/configure.ac b/source4/configure.ac index d03092c6b6..9d387fcb4c 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -11,27 +11,32 @@ AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h]) # Configuration rules. m4_include(build/m4/env.m4) -m4_include(lib/replace/samba.m4) +m4_include(../lib/replace/samba.m4) m4_include(lib/smbreadline/readline.m4) m4_include(heimdal_build/config.m4) -m4_include(lib/util/fault.m4) -m4_include(lib/util/signal.m4) -m4_include(lib/util/util.m4) -m4_include(lib/util/fsusage.m4) -m4_include(lib/util/xattr.m4) -m4_include(lib/util/capability.m4) -m4_include(lib/util/time.m4) -m4_include(lib/popt/samba.m4) +m4_include(../lib/util/fault.m4) +m4_include(../lib/util/signal.m4) +m4_include(../lib/util/util.m4) +m4_include(../lib/util/fsusage.m4) +m4_include(../lib/util/xattr.m4) +m4_include(../lib/util/capability.m4) +m4_include(../lib/util/time.m4) +m4_include(../lib/popt/samba.m4) m4_include(lib/charset/config.m4) m4_include(lib/socket/config.m4) -m4_include(lib/zlib.m4) +m4_include(../lib/zlib/zlib.m4) +AC_ZLIB([ +SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}]) +],[ +SMB_INCLUDE_MK(lib/zlib.mk) +]) m4_include(nsswitch/nsstest.m4) -m4_include(pidl/config.m4) +m4_include(../pidl/config.m4) AC_CONFIG_FILES(lib/registry/registry.pc) AC_CONFIG_FILES(lib/events/events.pc) AC_CONFIG_FILES(librpc/dcerpc.pc) -AC_CONFIG_FILES(librpc/ndr.pc) +AC_CONFIG_FILES(../librpc/ndr.pc) AC_CONFIG_FILES(lib/torture/torture.pc) AC_CONFIG_FILES(auth/gensec/gensec.pc) AC_CONFIG_FILES(param/samba-hostconfig.pc) @@ -41,20 +46,20 @@ AC_CONFIG_FILES(librpc/dcerpc_atsvc.pc) SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0, [], [ - m4_include(lib/talloc/libtalloc.m4) - SMB_INCLUDE_MK(lib/talloc/config.mk) + m4_include(../lib/talloc/libtalloc.m4) + SMB_INCLUDE_MK(../lib/talloc/config.mk) ] ) -SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0, +SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.3, [], [ - m4_include(lib/tdb/libtdb.m4) - SMB_INCLUDE_MK(lib/tdb/config.mk) + m4_include(../lib/tdb/libtdb.m4) + SMB_INCLUDE_MK(../lib/tdb/config.mk) ] ) -SMB_INCLUDE_MK(lib/tdb/python.mk) +SMB_INCLUDE_MK(../lib/tdb/python.mk) SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1, [ @@ -94,17 +99,15 @@ m4_include(lib/tls/config.m4) m4_include(lib/events/libevents.m4) dnl m4_include(auth/kerberos/config.m4) -m4_include(scripting/python/config.m4) m4_include(auth/gensec/config.m4) m4_include(smbd/process_model.m4) m4_include(ntvfs/posix/config.m4) m4_include(ntvfs/unixuid/config.m4) -m4_include(lib/socket_wrapper/config.m4) -m4_include(lib/nss_wrapper/config.m4) +m4_include(../lib/socket_wrapper/config.m4) +m4_include(../lib/nss_wrapper/config.m4) m4_include(auth/config.m4) m4_include(kdc/config.m4) m4_include(ntvfs/sysdep/config.m4) -m4_include(lib/appweb/config.m4) m4_include(nsswitch/config.m4) ################################################# @@ -159,7 +162,7 @@ then builddir_headers="-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib "; fi -CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS" +CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/../lib/replace -I\$(srcdir)/../lib/talloc -I\$(srcdir)/.. -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS" SMB_WRITE_PERLVARS(build/smb_build/config.pm) diff --git a/source4/dsdb/common/flag_mapping.c b/source4/dsdb/common/flag_mapping.c index 4a2a079e45..dceb41be67 100644 --- a/source4/dsdb/common/flag_mapping.c +++ b/source4/dsdb/common/flag_mapping.c @@ -22,6 +22,8 @@ #include "includes.h" #include "librpc/gen_ndr/samr.h" #include "dsdb/common/flags.h" +#include "lib/ldb/include/ldb.h" +#include "dsdb/common/proto.h" /* translated the ACB_CTRL Flags to UserFlags (userAccountControl) diff --git a/source4/dsdb/common/sidmap.c b/source4/dsdb/common/sidmap.c index 20bba7a0d9..31b56ea52f 100644 --- a/source4/dsdb/common/sidmap.c +++ b/source4/dsdb/common/sidmap.c @@ -26,7 +26,7 @@ #include "auth/auth.h" #include "libcli/ldap/ldap_ndr.h" #include "lib/ldb/include/ldb.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "libcli/security/security.h" #include "param/param.h" diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index fa8276e7b4..6a6f370943 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -25,7 +25,8 @@ #include "events.h" #include "ldb.h" #include "ldb_errors.h" -#include "lib/util/util_ldb.h" +#include "../lib/util/util_ldb.h" +#include "../lib/crypto/crypto.h" #include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_security.h" @@ -571,7 +572,7 @@ uint_t samdb_result_hashes(TALLOC_CTX *mem_ctx, struct ldb_message *msg, return count; } -NTSTATUS samdb_result_passwords(TALLOC_CTX *mem_ctx, struct ldb_message *msg, +NTSTATUS samdb_result_passwords(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct ldb_message *msg, struct samr_Password **lm_pwd, struct samr_Password **nt_pwd) { struct samr_Password *lmPwdHash, *ntPwdHash; @@ -587,14 +588,21 @@ NTSTATUS samdb_result_passwords(TALLOC_CTX *mem_ctx, struct ldb_message *msg, } } if (lm_pwd) { - int num_lm; - num_lm = samdb_result_hashes(mem_ctx, msg, "dBCSPwd", &lmPwdHash); - if (num_lm == 0) { - *lm_pwd = NULL; - } else if (num_lm > 1) { - return NT_STATUS_INTERNAL_DB_CORRUPTION; + /* Ensure that if we have turned off LM + * authentication, that we never use the LM hash, even + * if we store it */ + if (lp_lanman_auth(lp_ctx)) { + int num_lm; + num_lm = samdb_result_hashes(mem_ctx, msg, "dBCSPwd", &lmPwdHash); + if (num_lm == 0) { + *lm_pwd = NULL; + } else if (num_lm > 1) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } else { + *lm_pwd = &lmPwdHash[0]; + } } else { - *lm_pwd = &lmPwdHash[0]; + *lm_pwd = NULL; } } return NT_STATUS_OK; @@ -1024,7 +1032,7 @@ const struct dom_sid *samdb_domain_sid(struct ldb_context *ldb) goto failed; } - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, attrs, "objectSid=*"); + ret = ldb_search(ldb, tmp_ctx, &res, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, attrs, "objectSid=*"); if (ret != LDB_SUCCESS) { goto failed; @@ -1137,13 +1145,12 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb) } - ret = ldb_search(ldb, ldb_dn_new(tmp_ctx, ldb, ""), LDB_SCOPE_BASE, NULL, root_attrs, &root_res); + ret = ldb_search(ldb, tmp_ctx, &root_res, ldb_dn_new(tmp_ctx, ldb, ""), LDB_SCOPE_BASE, root_attrs, NULL); if (ret) { DEBUG(1,("Searching for dsServiceName in rootDSE failed: %s\n", ldb_errstring(ldb))); goto failed; } - talloc_steal(tmp_ctx, root_res); if (root_res->count != 1) { goto failed; @@ -1189,11 +1196,10 @@ const struct GUID *samdb_ntds_invocation_id(struct ldb_context *ldb) goto failed; } - ret = ldb_search(ldb, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(ldb, tmp_ctx, &res, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, attrs, NULL); if (ret) { goto failed; } - talloc_steal(tmp_ctx, res); if (res->count != 1) { goto failed; @@ -1283,11 +1289,10 @@ const struct GUID *samdb_ntds_objectGUID(struct ldb_context *ldb) goto failed; } - ret = ldb_search(ldb, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(ldb, tmp_ctx, &res, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, attrs, NULL); if (ret) { goto failed; } - talloc_steal(tmp_ctx, res); if (res->count != 1) { goto failed; @@ -1397,14 +1402,13 @@ bool samdb_is_pdc(struct ldb_context *ldb) return false; } - ret = ldb_search(ldb, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res); + ret = ldb_search(ldb, tmp_ctx, &dom_res, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, dom_attrs, NULL); if (ret) { DEBUG(1,("Searching for fSMORoleOwner in %s failed: %s\n", ldb_dn_get_linearized(ldb_get_default_basedn(ldb)), ldb_errstring(ldb))); goto failed; } - talloc_steal(tmp_ctx, dom_res); if (dom_res->count != 1) { goto failed; } @@ -1444,17 +1448,17 @@ bool samdb_is_gc(struct ldb_context *ldb) } /* Query cn=ntds settings,.... */ - ret = ldb_search(ldb, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(ldb, tmp_ctx, &res, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, attrs, NULL); if (ret) { + talloc_free(tmp_ctx); return false; } if (res->count != 1) { - talloc_free(res); + talloc_free(tmp_ctx); return false; } options = ldb_msg_find_attr_as_int(res->msgs[0], "options", 0); - talloc_free(res); talloc_free(tmp_ctx); /* if options attribute has the 0x00000001 flag set, then enable the global catlog */ @@ -1478,10 +1482,9 @@ int samdb_search_for_parent_domain(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, if (local_ctx == NULL) return LDB_ERR_OPERATIONS_ERROR; while ((sdn = ldb_dn_get_parent(local_ctx, sdn))) { - ret = ldb_search(ldb, sdn, LDB_SCOPE_BASE, - "(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain))", attrs, &res); + ret = ldb_search(ldb, local_ctx, &res, sdn, LDB_SCOPE_BASE, attrs, + "(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain))"); if (ret == LDB_SUCCESS) { - talloc_steal(local_ctx, res); if (res->count == 1) { break; } @@ -1536,7 +1539,7 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, struct ldb_dn *user_dn, struct ldb_dn *domain_dn, struct ldb_message *mod, - const char *new_pass, + const DATA_BLOB *new_password, struct samr_Password *lmNewHash, struct samr_Password *ntNewHash, bool user_change, @@ -1637,40 +1640,47 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, *_dominfo = dominfo; } - if (restrictions && new_pass) { - + if (restrictions && new_password) { + char *new_pass; + /* check the various password restrictions */ - if (restrictions && minPwdLength > strlen_m(new_pass)) { + if (restrictions && minPwdLength > utf16_len_n(new_password->data, new_password->length) / 2) { if (reject_reason) { *reject_reason = SAMR_REJECT_TOO_SHORT; } return NT_STATUS_PASSWORD_RESTRICTION; } + + /* Create the NT hash */ + mdfour(local_ntNewHash.hash, new_password->data, new_password->length); - /* possibly check password complexity */ - if (restrictions && pwdProperties & DOMAIN_PASSWORD_COMPLEX && - !samdb_password_complexity_ok(new_pass)) { - if (reject_reason) { - *reject_reason = SAMR_REJECT_COMPLEXITY; + ntNewHash = &local_ntNewHash; + + /* Only check complexity if we can convert it at all. Assuming unconvertable passwords are 'strong' */ + if (convert_string_talloc(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ctx, "loadparm")), + CH_UTF16, CH_UNIX, + new_password->data, new_password->length, + (void **)&new_pass) != -1) { + + + /* possibly check password complexity */ + if (restrictions && pwdProperties & DOMAIN_PASSWORD_COMPLEX && + !samdb_password_complexity_ok(new_pass)) { + if (reject_reason) { + *reject_reason = SAMR_REJECT_COMPLEXITY; + } + return NT_STATUS_PASSWORD_RESTRICTION; } - return NT_STATUS_PASSWORD_RESTRICTION; - } - - /* compute the new nt and lm hashes */ - if (E_deshash(new_pass, local_lmNewHash.hash)) { - lmNewHash = &local_lmNewHash; - } - if (!E_md4hash(new_pass, local_ntNewHash.hash)) { - /* If we can't convert this password to UCS2, then we should not accept it */ - if (reject_reason) { - *reject_reason = SAMR_REJECT_OTHER; + + /* compute the new lm hashes (for checking history - case insenitivly!) */ + if (E_deshash(new_pass, local_lmNewHash.hash)) { + lmNewHash = &local_lmNewHash; } - return NT_STATUS_PASSWORD_RESTRICTION; + } - ntNewHash = &local_ntNewHash; } - if (user_change) { + if (restrictions && user_change) { /* are all password changes disallowed? */ if (pwdProperties & DOMAIN_REFUSE_PASSWORD_CHANGE) { if (reject_reason) { @@ -1736,16 +1746,15 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, #define CHECK_RET(x) do { if (x != 0) return NT_STATUS_NO_MEMORY; } while(0) /* the password is acceptable. Start forming the new fields */ - if (new_pass) { - /* if we know the cleartext, then only set it. + if (new_password) { + /* if we know the cleartext UTF16 password, then set it. * Modules in ldb will set all the appropriate * hashes */ - CHECK_RET(samdb_msg_add_string(ctx, mem_ctx, mod, - "userPassword", new_pass)); + CHECK_RET(ldb_msg_add_value(mod, "clearTextPassword", new_password, NULL)); } else { /* We don't have the cleartext, so delete the old one * and set what we have of the hashes */ - CHECK_RET(samdb_msg_add_delete(ctx, mem_ctx, mod, "userPassword")); + CHECK_RET(samdb_msg_add_delete(ctx, mem_ctx, mod, "clearTextPassword")); if (lmNewHash) { CHECK_RET(samdb_msg_add_hash(ctx, mem_ctx, mod, "dBCSPwd", lmNewHash)); @@ -1774,7 +1783,7 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, */ NTSTATUS samdb_set_password_sid(struct ldb_context *ctx, TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid, - const char *new_pass, + const DATA_BLOB *new_pass, struct samr_Password *lmNewHash, struct samr_Password *ntNewHash, bool user_change, @@ -1917,7 +1926,7 @@ struct ldb_dn *samdb_dns_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_c return NULL; } - split_realm = str_list_make(tmp_ctx, dns_domain, "."); + split_realm = (const char **)str_list_make(tmp_ctx, dns_domain, "."); if (!split_realm) { talloc_free(tmp_ctx); return NULL; @@ -1955,7 +1964,7 @@ struct ldb_dn *samdb_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result *res_domain_ref; char *escaped_domain = ldb_binary_encode_string(mem_ctx, domain_name); /* find the domain's DN */ - int ret_domain = ldb_search_exp_fmt(ldb, mem_ctx, + int ret_domain = ldb_search(ldb, mem_ctx, &res_domain_ref, samdb_partitions_dn(ldb, mem_ctx), LDB_SCOPE_ONELEVEL, @@ -1967,7 +1976,7 @@ struct ldb_dn *samdb_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, } if (res_domain_ref->count == 0) { - ret_domain = ldb_search_exp_fmt(ldb, mem_ctx, + ret_domain = ldb_search(ldb, mem_ctx, &res_domain_ref, samdb_dns_domain_to_dn(ldb, mem_ctx, domain_name), LDB_SCOPE_BASE, diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk index 63e8a77ce4..8bc8b6e000 100644 --- a/source4/dsdb/config.mk +++ b/source4/dsdb/config.mk @@ -46,7 +46,7 @@ $(eval $(call proto_header_template,$(dsdbsrcdir)/schema/proto.h,$(SAMDB_SCHEMA_ # Start SUBSYSTEM DREPL_SRV [MODULE::DREPL_SRV] INIT_FUNCTION = server_service_drepl_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = \ SAMDB \ process_model diff --git a/source4/dsdb/repl/drepl_out_helpers.c b/source4/dsdb/repl/drepl_out_helpers.c index 80b398ef5c..c292c6db74 100644 --- a/source4/dsdb/repl/drepl_out_helpers.c +++ b/source4/dsdb/repl/drepl_out_helpers.c @@ -27,7 +27,7 @@ #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" @@ -246,40 +246,42 @@ static void dreplsrv_op_pull_source_get_changes_send(struct dreplsrv_op_pull_sou r = talloc(st, struct drsuapi_DsGetNCChanges); if (composite_nomem(r, c)) return; - r->in.level = talloc(r, int32_t); - if (composite_nomem(r->in.level, c)) return; - r->out.level = talloc(r, int32_t); - if (composite_nomem(r->out.level, c)) return; + r->out.level_out = talloc(r, int32_t); + if (composite_nomem(r->out.level_out, c)) return; + r->in.req = talloc(r, union drsuapi_DsGetNCChangesRequest); + if (composite_nomem(r->in.req, c)) return; + r->out.ctr = talloc(r, union drsuapi_DsGetNCChangesCtr); + if (composite_nomem(r->out.ctr, c)) return; r->in.bind_handle = &drsuapi->bind_handle; if (drsuapi->remote_info28.supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) { - *r->in.level = 8; - r->in.req.req8.destination_dsa_guid = service->ntds_guid; - r->in.req.req8.source_dsa_invocation_id = rf1->source_dsa_invocation_id; - r->in.req.req8.naming_context = &partition->nc; - r->in.req.req8.highwatermark = rf1->highwatermark; - r->in.req.req8.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ - r->in.req.req8.replica_flags = rf1->replica_flags; - r->in.req.req8.max_object_count = 133; - r->in.req.req8.max_ndr_size = 1336811; - r->in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req8.fsmo_info = 0; - r->in.req.req8.partial_attribute_set = NULL; - r->in.req.req8.partial_attribute_set_ex = NULL; - r->in.req.req8.mapping_ctr.num_mappings = 0; - r->in.req.req8.mapping_ctr.mappings = NULL; + r->in.level = 8; + r->in.req->req8.destination_dsa_guid = service->ntds_guid; + r->in.req->req8.source_dsa_invocation_id= rf1->source_dsa_invocation_id; + r->in.req->req8.naming_context = &partition->nc; + r->in.req->req8.highwatermark = rf1->highwatermark; + r->in.req->req8.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ + r->in.req->req8.replica_flags = rf1->replica_flags; + r->in.req->req8.max_object_count = 133; + r->in.req->req8.max_ndr_size = 1336811; + r->in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req8.fsmo_info = 0; + r->in.req->req8.partial_attribute_set = NULL; + r->in.req->req8.partial_attribute_set_ex= NULL; + r->in.req->req8.mapping_ctr.num_mappings= 0; + r->in.req->req8.mapping_ctr.mappings = NULL; } else { - *r->in.level = 5; - r->in.req.req5.destination_dsa_guid = service->ntds_guid; - r->in.req.req5.source_dsa_invocation_id = rf1->source_dsa_invocation_id; - r->in.req.req5.naming_context = &partition->nc; - r->in.req.req5.highwatermark = rf1->highwatermark; - r->in.req.req5.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ - r->in.req.req5.replica_flags = rf1->replica_flags; - r->in.req.req5.max_object_count = 133; - r->in.req.req5.max_ndr_size = 1336770; - r->in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req5.fsmo_info = 0; + r->in.level = 5; + r->in.req->req5.destination_dsa_guid = service->ntds_guid; + r->in.req->req5.source_dsa_invocation_id= rf1->source_dsa_invocation_id; + r->in.req->req5.naming_context = &partition->nc; + r->in.req->req5.highwatermark = rf1->highwatermark; + r->in.req->req5.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ + r->in.req->req5.replica_flags = rf1->replica_flags; + r->in.req->req5.max_object_count = 133; + r->in.req->req5.max_ndr_size = 1336770; + r->in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req5.fsmo_info = 0; } req = dcerpc_drsuapi_DsGetNCChanges_send(drsuapi->pipe, r, r); @@ -311,28 +313,28 @@ static void dreplsrv_op_pull_source_get_changes_recv(struct rpc_request *req) return; } - if (*r->out.level == 1) { + if (*r->out.level_out == 1) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr1; - } else if (*r->out.level == 2 && - r->out.ctr.ctr2.mszip1.ts) { + ctr1 = &r->out.ctr->ctr1; + } else if (*r->out.level_out == 2 && + r->out.ctr->ctr2.mszip1.ts) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr2.mszip1.ts->ctr1; - } else if (*r->out.level == 6) { + ctr1 = &r->out.ctr->ctr2.mszip1.ts->ctr1; + } else if (*r->out.level_out == 6) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && - r->out.ctr.ctr7.ctr.mszip6.ts) { + ctr6 = &r->out.ctr->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && + r->out.ctr->ctr7.ctr.mszip6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.mszip6.ts->ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && - r->out.ctr.ctr7.ctr.xpress6.ts) { + ctr6 = &r->out.ctr->ctr7.ctr.mszip6.ts->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && + r->out.ctr->ctr7.ctr.xpress6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.xpress6.ts->ctr6; + ctr6 = &r->out.ctr->ctr7.ctr.xpress6.ts->ctr6; } else { composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP)); return; diff --git a/source4/dsdb/repl/drepl_out_pull.c b/source4/dsdb/repl/drepl_out_pull.c index f33959243e..c66c5bbd19 100644 --- a/source4/dsdb/repl/drepl_out_pull.c +++ b/source4/dsdb/repl/drepl_out_pull.c @@ -27,7 +27,7 @@ #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c index 8a1c5aa31a..f36b735d32 100644 --- a/source4/dsdb/repl/drepl_partitions.c +++ b/source4/dsdb/repl/drepl_partitions.c @@ -27,7 +27,7 @@ #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" @@ -48,8 +48,8 @@ WERROR dreplsrv_load_partitions(struct dreplsrv_service *s) basedn = ldb_dn_new(s, s->samdb, NULL); W_ERROR_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->samdb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->samdb, s, &r, basedn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return WERR_FOOBAR; @@ -57,7 +57,6 @@ WERROR dreplsrv_load_partitions(struct dreplsrv_service *s) talloc_free(r); return WERR_FOOBAR; } - talloc_steal(s, r); el = ldb_msg_find_element(r->msgs[0], "namingContexts"); if (!el) { @@ -201,15 +200,14 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s, DEBUG(2, ("dreplsrv_refresh_partition(%s)\n", ldb_dn_get_linearized(p->dn))); - ret = ldb_search(s->samdb, p->dn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->samdb, mem_ctx, &r, p->dn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); if (ret != LDB_SUCCESS) { return WERR_FOOBAR; } else if (r->count != 1) { talloc_free(r); return WERR_FOOBAR; } - talloc_steal(mem_ctx, r); ZERO_STRUCT(p->nc); p->nc.dn = ldb_dn_alloc_linearized(p, p->dn); diff --git a/source4/dsdb/repl/drepl_periodic.c b/source4/dsdb/repl/drepl_periodic.c index 8745e210a1..7205c8b0f1 100644 --- a/source4/dsdb/repl/drepl_periodic.c +++ b/source4/dsdb/repl/drepl_periodic.c @@ -27,7 +27,7 @@ #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c index 3611258ca5..98d1c1b06c 100644 --- a/source4/dsdb/repl/drepl_service.c +++ b/source4/dsdb/repl/drepl_service.c @@ -27,7 +27,7 @@ #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c index 552d83f411..9853a75347 100644 --- a/source4/dsdb/repl/replicated_objects.c +++ b/source4/dsdb/repl/replicated_objects.c @@ -22,11 +22,11 @@ #include "includes.h" #include "dsdb/samdb/samdb.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "param/param.h" diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c index 369b06c305..916dc943be 100644 --- a/source4/dsdb/samdb/cracknames.c +++ b/source4/dsdb/samdb/cracknames.c @@ -33,7 +33,7 @@ #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_misc.h" #include "auth/auth.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "dsdb/samdb/samdb.h" #include "param/param.h" @@ -107,8 +107,8 @@ static enum drsuapi_DsNameStatus LDB_lookup_spn_alias(krb5_context context, stru return DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR; } - ret = ldb_search(ldb_ctx, service_dn, LDB_SCOPE_BASE, "(objectClass=nTDSService)", - directory_attrs, &res); + ret = ldb_search(ldb_ctx, tmp_ctx, &res, service_dn, LDB_SCOPE_BASE, + directory_attrs, "(objectClass=nTDSService)"); if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) { DEBUG(1, ("ldb_search: dn: %s not found: %s", service_dn_str, ldb_errstring(ldb_ctx))); @@ -121,7 +121,6 @@ static enum drsuapi_DsNameStatus LDB_lookup_spn_alias(krb5_context context, stru DEBUG(1, ("ldb_search: dn: %s not found", service_dn_str)); return DRSUAPI_DS_NAME_STATUS_NOT_FOUND; } - talloc_steal(tmp_ctx, res); spnmappings = ldb_msg_find_element(res->msgs[0], "sPNMappings"); if (!spnmappings || spnmappings->num_values == 0) { @@ -292,7 +291,7 @@ static WERROR DsCrackNameUPN(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, realm = krb5_princ_realm(smb_krb5_context->krb5_context, principal); - ldb_ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &domain_res, + ldb_ret = ldb_search(sam_ctx, mem_ctx, &domain_res, samdb_partitions_dn(sam_ctx, mem_ctx), LDB_SCOPE_ONELEVEL, domain_attrs, @@ -357,15 +356,7 @@ WERROR DsCrackNameOneName(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, const char *result_filter = NULL; struct ldb_dn *name_dn = NULL; - struct smb_krb5_context *smb_krb5_context; - ret = smb_krb5_init_context(mem_ctx, - ldb_get_event_context(sam_ctx), - (struct loadparm_context *)ldb_get_opaque(sam_ctx, "loadparm"), - &smb_krb5_context); - - if (ret) { - return WERR_NOMEM; - } + struct smb_krb5_context *smb_krb5_context = NULL; info1->status = DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR; info1->dns_domain_name = NULL; @@ -381,6 +372,30 @@ WERROR DsCrackNameOneName(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, /* here we need to set the domain_filter and/or the result_filter */ switch (format_offered) { + case DRSUAPI_DS_NAME_FORMAT_UNKNOWN: + { + int i; + enum drsuapi_DsNameFormat formats[] = { + DRSUAPI_DS_NAME_FORMAT_FQDN_1779, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, + DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, DRSUAPI_DS_NAME_FORMAT_CANONICAL, + DRSUAPI_DS_NAME_FORMAT_GUID, DRSUAPI_DS_NAME_FORMAT_DISPLAY, + DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL, + DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, + DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX + }; + WERROR werr; + for (i=0; i < ARRAY_SIZE(formats); i++) { + werr = DsCrackNameOneName(sam_ctx, mem_ctx, format_flags, formats[i], format_desired, name, info1); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + if (info1->status != DRSUAPI_DS_NAME_STATUS_NOT_FOUND) { + return werr; + } + } + return werr; + } + case DRSUAPI_DS_NAME_FORMAT_CANONICAL: case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX: { @@ -535,6 +550,16 @@ WERROR DsCrackNameOneName(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: { krb5_principal principal; char *unparsed_name; + + ret = smb_krb5_init_context(mem_ctx, + ldb_get_event_context(sam_ctx), + (struct loadparm_context *)ldb_get_opaque(sam_ctx, "loadparm"), + &smb_krb5_context); + + if (ret) { + return WERR_NOMEM; + } + ret = krb5_parse_name(smb_krb5_context->krb5_context, name, &principal); if (ret) { info1->status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND; @@ -561,6 +586,16 @@ WERROR DsCrackNameOneName(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, krb5_principal principal; char *unparsed_name_short; char *service; + + ret = smb_krb5_init_context(mem_ctx, + ldb_get_event_context(sam_ctx), + (struct loadparm_context *)ldb_get_opaque(sam_ctx, "loadparm"), + &smb_krb5_context); + + if (ret) { + return WERR_NOMEM; + } + ret = krb5_parse_name(smb_krb5_context->krb5_context, name, &principal); if (ret == 0 && principal->name.name_string.len < 2) { info1->status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND; @@ -737,7 +772,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ if (domain_filter) { /* if we have a domain_filter look it up and set the result_basedn and the dns_domain_name */ - ldb_ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &domain_res, + ldb_ret = ldb_search(sam_ctx, mem_ctx, &domain_res, partitions_basedn, LDB_SCOPE_ONELEVEL, domain_attrs, @@ -774,7 +809,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ if (domain_res) { result_basedn = samdb_result_dn(sam_ctx, mem_ctx, domain_res->msgs[0], "ncName", NULL); - ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &res, + ret = ldb_search(sam_ctx, mem_ctx, &res, result_basedn, LDB_SCOPE_SUBTREE, result_attrs, "%s", result_filter); if (ret != LDB_SUCCESS) { @@ -798,7 +833,8 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ result_attrs, NULL, res, - ldb_search_default_callback); + ldb_search_default_callback, + NULL); if (ret == LDB_SUCCESS) { struct ldb_search_options_control *search_options; search_options = talloc(req, struct ldb_search_options_control); @@ -813,8 +849,6 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ return WERR_OK; } - ldb_set_timeout(sam_ctx, req, 0); /* use default timeout */ - ret = ldb_request(sam_ctx, req); if (ret == LDB_SUCCESS) { @@ -936,7 +970,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ if (samdb_find_attribute(sam_ctx, result, "objectClass", "domain")) { - ldb_ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &domain_res, + ldb_ret = ldb_search(sam_ctx, mem_ctx, &domain_res, partitions_basedn, LDB_SCOPE_ONELEVEL, domain_attrs, @@ -976,7 +1010,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ return WERR_OK; } dom_sid->num_auths--; - ldb_ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &domain_res, + ldb_ret = ldb_search(sam_ctx, mem_ctx, &domain_res, NULL, LDB_SCOPE_BASE, attrs, @@ -1000,7 +1034,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ return WERR_OK; } - ldb_ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &domain_res2, + ldb_ret = ldb_search(sam_ctx, mem_ctx, &domain_res2, partitions_basedn, LDB_SCOPE_ONELEVEL, domain_attrs, @@ -1267,7 +1301,7 @@ NTSTATUS crack_auto_name_to_nt4_name(TALLOC_CTX *mem_ctx, const char **nt4_domain, const char **nt4_account) { - uint32_t format_offered = DRSUAPI_DS_NAME_FORMAT_UKNOWN; + uint32_t format_offered = DRSUAPI_DS_NAME_FORMAT_UNKNOWN; /* Handle anonymous bind */ if (!name || !*name) { @@ -1284,6 +1318,8 @@ NTSTATUS crack_auto_name_to_nt4_name(TALLOC_CTX *mem_ctx, format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; } else if (strchr_m(name, '/')) { format_offered = DRSUAPI_DS_NAME_FORMAT_CANONICAL; + } else { + return NT_STATUS_NO_SUCH_USER; } return crack_name_to_nt4_name(mem_ctx, ev_ctx, lp_ctx, format_offered, name, nt4_domain, nt4_account); diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index 4e2c527fe9..da23030ed3 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -1,7 +1,8 @@ /* ldb database library - Copyright (C) Amdrew Bartlett 2007 + Copyright (C) Andrew Bartlett 2007 + Copyright (C) Simo Sorce 2008 Copyright (C) Andrew Tridgell 2004 This program is free software; you can redistribute it and/or modify @@ -35,7 +36,7 @@ /** * Make a and 'and' or 'or' tree from the two supplied elements */ -struct ldb_parse_tree *make_parse_list(struct ldb_module *module, +static struct ldb_parse_tree *make_parse_list(struct ldb_module *module, TALLOC_CTX *mem_ctx, enum ldb_parse_op op, struct ldb_parse_tree *first_arm, struct ldb_parse_tree *second_arm) { @@ -62,7 +63,7 @@ struct ldb_parse_tree *make_parse_list(struct ldb_module *module, /** * Make an equality or prefix match tree, from the attribute, operation and matching value supplied */ -struct ldb_parse_tree *make_match_tree(struct ldb_module *module, +static struct ldb_parse_tree *make_match_tree(struct ldb_module *module, TALLOC_CTX *mem_ctx, enum ldb_parse_op op, const char *attr, const DATA_BLOB *match) { @@ -99,6 +100,7 @@ struct ldb_parse_tree *make_match_tree(struct ldb_module *module, struct anr_context { bool found_anr; struct ldb_module *module; + struct ldb_request *req; }; /** @@ -106,39 +108,35 @@ struct anr_context { * parse tree with an 'or' of all the anr attributes in the schema. */ -typedef struct ldb_parse_tree *(*anr_parse_tree_callback_t)(TALLOC_CTX *mem_ctx, - const struct ldb_val *match, - void *context); - - /** - * Callback function to do the heavy lifting for the for the parse tree walker + * Callback function to do the heavy lifting for the parse tree walker */ -struct ldb_parse_tree *anr_replace_callback(TALLOC_CTX *mem_ctx, - const struct ldb_val *match, - void *context) +static int anr_replace_value(struct anr_context *ac, + TALLOC_CTX *mem_ctx, + const struct ldb_val *match, + struct ldb_parse_tree **ntree) { struct ldb_parse_tree *tree = NULL; - struct anr_context *anr_context = talloc_get_type(context, struct anr_context); - struct ldb_module *module = anr_context->module; + struct ldb_module *module = ac->module; struct ldb_parse_tree *match_tree; - uint8_t *p; - enum ldb_parse_op op; struct dsdb_attribute *cur; const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + uint8_t *p; + enum ldb_parse_op op; + if (!schema) { ldb_asprintf_errstring(module->ldb, "no schema with which to construct anr filter"); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } - anr_context->found_anr = true; + ac->found_anr = true; if (match->length > 1 && match->data[0] == '=') { - DATA_BLOB *match2 = talloc(tree, DATA_BLOB); + DATA_BLOB *match2 = talloc(mem_ctx, DATA_BLOB); *match2 = data_blob_const(match->data+1, match->length - 1); if (match2 == NULL){ ldb_oom(module->ldb); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } match = match2; op = LDB_OP_EQUALITY; @@ -154,7 +152,7 @@ struct ldb_parse_tree *anr_replace_callback(TALLOC_CTX *mem_ctx, tree = make_parse_list(module, mem_ctx, LDB_OP_OR, tree, match_tree); if (tree == NULL) { ldb_oom(module->ldb); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } } else { tree = match_tree; @@ -173,7 +171,7 @@ struct ldb_parse_tree *anr_replace_callback(TALLOC_CTX *mem_ctx, DATA_BLOB *second_match = talloc(tree, DATA_BLOB); if (!first_match || !second_match) { ldb_oom(module->ldb); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } *first_match = data_blob_const(match->data, p-match->data); *second_match = data_blob_const(p+1, match->length - (p-match->data) - 1); @@ -183,26 +181,26 @@ struct ldb_parse_tree *anr_replace_callback(TALLOC_CTX *mem_ctx, match_tree_1 = make_match_tree(module, mem_ctx, op, "givenName", first_match); match_tree_2 = make_match_tree(module, mem_ctx, op, "sn", second_match); - first_split_filter = make_parse_list(module, context, LDB_OP_AND, match_tree_1, match_tree_2); + first_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (first_split_filter == NULL){ ldb_oom(module->ldb); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } match_tree_1 = make_match_tree(module, mem_ctx, op, "sn", first_match); match_tree_2 = make_match_tree(module, mem_ctx, op, "givenName", second_match); - second_split_filter = make_parse_list(module, context, LDB_OP_AND, match_tree_1, match_tree_2); + second_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (second_split_filter == NULL){ ldb_oom(module->ldb); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } split_filters = make_parse_list(module, mem_ctx, LDB_OP_OR, first_split_filter, second_split_filter); if (split_filters == NULL) { ldb_oom(module->ldb); - return NULL; + return LDB_ERR_OPERATIONS_ERROR; } if (tree) { @@ -212,38 +210,46 @@ struct ldb_parse_tree *anr_replace_callback(TALLOC_CTX *mem_ctx, tree = split_filters; } } - return tree; + *ntree = tree; + return LDB_SUCCESS; } /* replace any occurances of an attribute with a new, generated attribute tree */ -struct ldb_parse_tree *anr_replace_subtrees(struct ldb_parse_tree *tree, - const char *attr, - anr_parse_tree_callback_t callback, - void *context) +static int anr_replace_subtrees(struct anr_context *ac, + struct ldb_parse_tree *tree, + const char *attr, + struct ldb_parse_tree **ntree) { + int ret; int i; - struct ldb_parse_tree *tmp; switch (tree->operation) { case LDB_OP_AND: case LDB_OP_OR: for (i=0;iu.list.num_elements;i++) { - tmp = anr_replace_subtrees(tree->u.list.elements[i], - attr, callback, context); - if (tmp) tree->u.list.elements[i] = tmp; + ret = anr_replace_subtrees(ac, tree->u.list.elements[i], + attr, &tree->u.list.elements[i]); + if (ret != LDB_SUCCESS) { + return ret; + } + *ntree = tree; } break; case LDB_OP_NOT: - tmp = anr_replace_subtrees(tree->u.isnot.child, attr, callback, context); - if (tmp) tree->u.isnot.child = tmp; + ret = anr_replace_subtrees(ac, tree->u.isnot.child, attr, &tree->u.isnot.child); + if (ret != LDB_SUCCESS) { + return ret; + } + *ntree = tree; break; case LDB_OP_EQUALITY: if (ldb_attr_cmp(tree->u.equality.attr, attr) == 0) { - tmp = callback(tree, &tree->u.equality.value, - context); - if (tmp) tree = tmp; + ret = anr_replace_value(ac, tree, &tree->u.equality.value, ntree); + if (ret != LDB_SUCCESS) { + return ret; + } } break; case LDB_OP_SUBSTRING: @@ -252,53 +258,97 @@ struct ldb_parse_tree *anr_replace_subtrees(struct ldb_parse_tree *tree, tree->u.substring.end_with_wildcard == 1 && tree->u.substring.chunks[0] != NULL && tree->u.substring.chunks[1] == NULL) { - tmp = callback(tree, tree->u.substring.chunks[0], context); - if (tmp) tree = tmp; + ret = anr_replace_value(ac, tree, tree->u.substring.chunks[0], ntree); + if (ret != LDB_SUCCESS) { + return ret; + } } } break; + default: + break; + } + + return LDB_SUCCESS; +} + +static int anr_search_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct anr_context *ac; + + ac = talloc_get_type(req->context, struct anr_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + return ldb_module_send_entry(ac->req, ares->message); + + case LDB_REPLY_REFERRAL: + return ldb_module_send_referral(ac->req, ares->referral); + + case LDB_REPLY_DONE: + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + } - return tree; + return LDB_SUCCESS; } /* search */ static int anr_search(struct ldb_module *module, struct ldb_request *req) { struct ldb_parse_tree *anr_tree; - struct anr_context *context = talloc(req, struct anr_context); - if (!context) { + struct ldb_request *down_req; + struct anr_context *ac; + int ret; + + ac = talloc(req, struct anr_context); + if (!ac) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - context->module = module; - context->found_anr = false; + ac->module = module; + ac->req = req; + ac->found_anr = false; #if 0 printf("oldanr : %s\n", ldb_filter_from_tree (0, req->op.search.tree)); #endif - /* Yes, this is a problem with req->op.search.tree being const... */ - anr_tree = anr_replace_subtrees(req->op.search.tree, "anr", anr_replace_callback, context); - if (!anr_tree) { - talloc_free(context); + ret = anr_replace_subtrees(ac, req->op.search.tree, "anr", &anr_tree); + if (ret != LDB_SUCCESS) { return LDB_ERR_OPERATIONS_ERROR; } - if (context->found_anr) { - /* The above function modifies the tree if it finds "anr", so no - * point just setting this on the down_req */ -#if 0 - printf("newtree: %s\n", ldb_filter_from_tree (0, anr_tree)); -#endif - req->op.search.tree = talloc_steal(req, anr_tree); - } else { - if (anr_tree != req->op.search.tree) { - talloc_free(anr_tree); - } - talloc_free(context); + if (!ac->found_anr) { + talloc_free(ac); + return ldb_next_request(module, req); } - return ldb_next_request(module, req); + + ret = ldb_build_search_req_ex(&down_req, + module->ldb, ac, + req->op.search.base, + req->op.search.scope, + anr_tree, + req->op.search.attrs, + req->controls, + ac, anr_search_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + talloc_steal(down_req, anr_tree); + + return ldb_next_request(module, down_req); } _PUBLIC_ const struct ldb_module_ops ldb_anr_module_ops = { diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c index 84bf5e4843..a0602d9281 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2005 + Copyright (C) Simo Sorce 2005-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -95,7 +95,7 @@ static bool add_attrs(void *mem_ctx, char ***attrs, const char *attr) return true; } -static bool inject_extended_dn(struct ldb_message *msg, +static int inject_extended_dn(struct ldb_message *msg, struct ldb_context *ldb, int type, bool remove_guid, @@ -113,8 +113,9 @@ static bool inject_extended_dn(struct ldb_message *msg, guid_blob = ldb_msg_find_ldb_val(msg, "objectGUID"); sid_blob = ldb_msg_find_ldb_val(msg, "objectSID"); - if (!guid_blob) - return false; + if (!guid_blob) { + return LDB_ERR_OPERATIONS_ERROR; + } switch (type) { case 0: @@ -123,7 +124,7 @@ static bool inject_extended_dn(struct ldb_message *msg, const char *lower_guid_hex = strlower_talloc(msg, data_blob_hex_string(msg, guid_blob)); const char *lower_sid_hex = strlower_talloc(msg, data_blob_hex_string(msg, sid_blob)); if (!lower_guid_hex || !lower_sid_hex) { - return false; + return LDB_ERR_OPERATIONS_ERROR; } new_dn = talloc_asprintf(msg, ";;%s", lower_guid_hex, @@ -132,7 +133,7 @@ static bool inject_extended_dn(struct ldb_message *msg, } else { const char *lower_guid_hex = strlower_talloc(msg, data_blob_hex_string(msg, guid_blob)); if (!lower_guid_hex) { - return false; + return LDB_ERR_OPERATIONS_ERROR; } new_dn = talloc_asprintf(msg, ";%s", lower_guid_hex, @@ -151,8 +152,8 @@ static bool inject_extended_dn(struct ldb_message *msg, if (sid) { object_sid = dom_sid_string(msg, sid); if (!object_sid) - return false; - + return LDB_ERR_OPERATIONS_ERROR; + } /* Normal, sane format */ @@ -167,11 +168,11 @@ static bool inject_extended_dn(struct ldb_message *msg, } break; default: - return false; + return LDB_ERR_OPERATIONS_ERROR; } if (!new_dn) { - return false; + return LDB_ERR_OPERATIONS_ERROR; } if (remove_guid) { @@ -184,50 +185,186 @@ static bool inject_extended_dn(struct ldb_message *msg, msg->dn = ldb_dn_new(msg, ldb, new_dn); if (! ldb_dn_validate(msg->dn)) - return false; + return LDB_ERR_OPERATIONS_ERROR; val = ldb_msg_find_ldb_val(msg, "distinguishedName"); if (val) { ldb_msg_remove_attr(msg, "distinguishedName"); if (ldb_msg_add_steal_string(msg, "distinguishedName", new_dn)) - return false; + return LDB_ERR_OPERATIONS_ERROR; } - return true; + return LDB_SUCCESS; } /* search */ struct extended_context { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); - - const char * const *attrs; + struct ldb_request *req; + struct ldb_control *control; + struct ldb_dn *basedn; + char *wellknown_object; + bool inject; bool remove_guid; bool remove_sid; int extended_type; + const char * const *cast_attrs; }; -static int extended_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) { struct extended_context *ac; + int ret; - ac = talloc_get_type(context, struct extended_context); + ac = talloc_get_type(req->context, struct extended_context); - if (ares->type == LDB_REPLY_ENTRY) { - /* for each record returned post-process to add any derived - attributes that have been asked for */ - if (!inject_extended_dn(ares->message, ldb, ac->extended_type, ac->remove_guid, ac->remove_sid)) { - goto error; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + if (ac->inject) { + /* for each record returned post-process to add any derived + attributes that have been asked for */ + ret = inject_extended_dn(ares->message, ac->module->ldb, + ac->extended_type, ac->remove_guid, + ac->remove_sid); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } + + return ldb_module_send_entry(ac->req, ares->message); + + case LDB_REPLY_REFERRAL: + return ldb_module_send_referral(ac->req, ares->referral); + + case LDB_REPLY_DONE: + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + + } + return LDB_SUCCESS; +} + +static int extended_base_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct extended_context *ac; + struct ldb_request *down_req; + struct ldb_control **saved_controls; + struct ldb_message_element *el; + int ret; + size_t i; + size_t wkn_len = 0; + char *valstr = NULL; + const char *found = NULL; + + ac = talloc_get_type(req->context, struct extended_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - return ac->up_callback(ldb, ac->up_context, ares); + switch (ares->type) { + case LDB_REPLY_ENTRY: + if (!ac->wellknown_object) { + ac->basedn = ares->message->dn; + break; + } + + wkn_len = strlen(ac->wellknown_object); -error: - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + el = ldb_msg_find_element(ares->message, "wellKnownObjects"); + if (!el) { + ac->basedn = NULL; + break; + } + + for (i=0; i < el->num_values; i++) { + valstr = talloc_strndup(ac, + (const char *)el->values[i].data, + el->values[i].length); + if (!valstr) { + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + if (strncasecmp(valstr, ac->wellknown_object, wkn_len) != 0) { + talloc_free(valstr); + continue; + } + + found = &valstr[wkn_len]; + break; + } + + if (!found) { + break; + } + + ac->basedn = ldb_dn_new(ac, ac->module->ldb, found); + talloc_free(valstr); + if (!ac->basedn) { + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + break; + + case LDB_REPLY_REFERRAL: + break; + + case LDB_REPLY_DONE: + + if (!ac->basedn) { + const char *str = talloc_asprintf(req, "Base-DN '%s' not found", + ldb_dn_get_linearized(ac->req->op.search.base)); + ldb_set_errstring(ac->module->ldb, str); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_NO_SUCH_OBJECT); + } + + ret = ldb_build_search_req_ex(&down_req, + ac->module->ldb, ac, + ac->basedn, + ac->req->op.search.scope, + ac->req->op.search.tree, + ac->cast_attrs, + ac->req->controls, + ac, extended_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); + } + + if (ac->control) { + /* save it locally and remove it from the list */ + /* we do not need to replace them later as we + * are keeping the original req intact */ + if (!save_controls(ac->control, down_req, &saved_controls)) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + } + + /* perform the search */ + return ldb_next_request(ac->module, down_req); + } + return LDB_SUCCESS; } static int extended_search(struct ldb_module *module, struct ldb_request *req) @@ -239,126 +376,286 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req) struct ldb_request *down_req; char **new_attrs; int ret; + struct ldb_dn *base_dn = NULL; + enum ldb_scope base_dn_scope = LDB_SCOPE_BASE; + const char *base_dn_filter = NULL; + const char * const *base_dn_attrs = NULL; + char *wellknown_object = NULL; + static const char *dnattr[] = { + "distinguishedName", + NULL + }; + static const char *wkattr[] = { + "wellKnownObjects", + NULL + }; + + if (ldb_dn_is_special(req->op.search.base)) { + char *dn; + + dn = ldb_dn_alloc_linearized(req, req->op.search.base); + if (!dn) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + + if (strncasecmp(dn, "'); + if (!p) { + return LDB_ERR_INVALID_DN_SYNTAX; + } + p[0] = '\0'; + + if (strncasecmp(str, "S-", 2) == 0) { + valstr = str; + } else { + DATA_BLOB binary; + binary = strhex_to_data_blob(NULL, str); + if (!binary.data) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + valstr = ldb_binary_encode(req, binary); + data_blob_free(&binary); + if (!valstr) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + } + + /* TODO: do a search over all partitions */ + base_dn = ldb_get_default_basedn(module->ldb); + base_dn_filter = talloc_asprintf(req, "(objectSid=%s)", valstr); + if (!base_dn_filter) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + base_dn_scope = LDB_SCOPE_SUBTREE; + base_dn_attrs = dnattr; + } else if (strncasecmp(dn, "'); + if (!p) { + return LDB_ERR_INVALID_DN_SYNTAX; + } + p[0] = '\0'; + + if (strchr(str, '-')) { + valstr = str; + } else { + DATA_BLOB binary; + binary = strhex_to_data_blob(NULL, str); + if (!binary.data) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + valstr = ldb_binary_encode(req, binary); + data_blob_free(&binary); + if (!valstr) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + } + + /* TODO: do a search over all partitions */ + base_dn = ldb_get_default_basedn(module->ldb); + base_dn_filter = talloc_asprintf(req, "(objectGUID=%s)", valstr); + if (!base_dn_filter) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + base_dn_scope = LDB_SCOPE_SUBTREE; + base_dn_attrs = dnattr; + } else if (strncasecmp(dn, "ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + + tail_str = p; + p = strchr(tail_str, '>'); + if (!p) { + return LDB_ERR_INVALID_DN_SYNTAX; + } + p[0] = '\0'; + + base_dn = ldb_dn_new(req, module->ldb, tail_str); + if (!base_dn) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + base_dn_filter = talloc_strdup(req, "(objectClass=*)"); + if (!base_dn_filter) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + base_dn_scope = LDB_SCOPE_BASE; + base_dn_attrs = wkattr; + } + talloc_free(dn); + } /* check if there's an extended dn control */ control = ldb_request_get_control(req, LDB_CONTROL_EXTENDED_DN_OID); - if (control == NULL) { + if (control == NULL && base_dn_filter == NULL) { /* not found go on */ return ldb_next_request(module, req); } - if (control->data) { + if (control && control->data) { extended_ctrl = talloc_get_type(control->data, struct ldb_extended_dn_control); if (!extended_ctrl) { return LDB_ERR_PROTOCOL_ERROR; } } - ac = talloc(req, struct extended_context); + ac = talloc_zero(req, struct extended_context); if (ac == NULL) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } ac->module = module; - ac->up_context = req->context; - ac->up_callback = req->callback; - ac->attrs = req->op.search.attrs; + ac->req = req; + ac->control = control; + ac->basedn = NULL; + ac->wellknown_object = wellknown_object; + ac->inject = false; ac->remove_guid = false; ac->remove_sid = false; - if (extended_ctrl) { - ac->extended_type = extended_ctrl->type; - } else { - ac->extended_type = 0; - } - - down_req = talloc_zero(req, struct ldb_request); - if (down_req == NULL) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - down_req->operation = req->operation; - down_req->op.search.base = req->op.search.base; - down_req->op.search.scope = req->op.search.scope; - down_req->op.search.tree = req->op.search.tree; - /* check if attrs only is specified, in that case check wether we need to modify them */ - if (req->op.search.attrs) { - if (! is_attr_in_list(req->op.search.attrs, "objectGUID")) { - ac->remove_guid = true; + if (control) { + ac->inject = true; + if (extended_ctrl) { + ac->extended_type = extended_ctrl->type; + } else { + ac->extended_type = 0; } - if (! is_attr_in_list(req->op.search.attrs, "objectSID")) { - ac->remove_sid = true; - } - if (ac->remove_guid || ac->remove_sid) { - new_attrs = copy_attrs(down_req, req->op.search.attrs); - if (new_attrs == NULL) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + + /* check if attrs only is specified, in that case check wether we need to modify them */ + if (req->op.search.attrs) { + if (! is_attr_in_list(req->op.search.attrs, "objectGUID")) { + ac->remove_guid = true; } - - if (ac->remove_guid) { - if (!add_attrs(down_req, &new_attrs, "objectGUID")) - return LDB_ERR_OPERATIONS_ERROR; + if (! is_attr_in_list(req->op.search.attrs, "objectSID")) { + ac->remove_sid = true; } - if (ac->remove_sid) { - if (!add_attrs(down_req, &new_attrs, "objectSID")) + if (ac->remove_guid || ac->remove_sid) { + new_attrs = copy_attrs(ac, req->op.search.attrs); + if (new_attrs == NULL) { + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; - } + } - down_req->op.search.attrs = (const char * const *)new_attrs; + if (ac->remove_guid) { + if (!add_attrs(ac, &new_attrs, "objectGUID")) + return LDB_ERR_OPERATIONS_ERROR; + } + if (ac->remove_sid) { + if (!add_attrs(ac, &new_attrs, "objectSID")) + return LDB_ERR_OPERATIONS_ERROR; + } + ac->cast_attrs = (const char * const *)new_attrs; + } else { + ac->cast_attrs = req->op.search.attrs; + } } } - down_req->controls = req->controls; + if (base_dn) { + ret = ldb_build_search_req(&down_req, + module->ldb, ac, + base_dn, + base_dn_scope, + base_dn_filter, + base_dn_attrs, + NULL, + ac, extended_base_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - /* save it locally and remove it from the list */ - /* we do not need to replace them later as we - * are keeping the original req intact */ - if (!save_controls(control, down_req, &saved_controls)) { - return LDB_ERR_OPERATIONS_ERROR; + /* perform the search */ + return ldb_next_request(module, down_req); } - down_req->context = ac; - down_req->callback = extended_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* perform the search */ - ret = ldb_next_request(module, down_req); + ret = ldb_build_search_req_ex(&down_req, + module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + ac->cast_attrs, + req->controls, + ac, extended_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + if (ac->control) { + /* save it locally and remove it from the list */ + /* we do not need to replace them later as we + * are keeping the original req intact */ + if (!save_controls(control, down_req, &saved_controls)) { + return LDB_ERR_OPERATIONS_ERROR; + } } - return ret; + /* perform the search */ + return ldb_next_request(module, down_req); } static int extended_init(struct ldb_module *module) { - struct ldb_request *req; int ret; - req = talloc(module, struct ldb_request); - if (req == NULL) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - req->operation = LDB_REQ_REGISTER_CONTROL; - req->op.reg_control.oid = LDB_CONTROL_EXTENDED_DN_OID; - req->controls = NULL; - - ret = ldb_request(module->ldb, req); + ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n"); - talloc_free(req); + ldb_debug(module->ldb, LDB_DEBUG_ERROR, + "extended_dn: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } - talloc_free(req); return ldb_next_init(module); } diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c index fd5aa5e18a..492ef1c92b 100644 --- a/source4/dsdb/samdb/ldb_modules/instancetype.c +++ b/source4/dsdb/samdb/ldb_modules/instancetype.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2004-2006 + Copyright (C) Simo Sorce 2004-2008 Copyright (C) Andrew Bartlett 2005 Copyright (C) Andrew Tridgell 2005 Copyright (C) Stefan Metzmacher 2007 @@ -41,11 +41,43 @@ #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" +struct it_context { + struct ldb_module *module; + struct ldb_request *req; +}; + +static int it_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct it_context *ac; + + ac = talloc_get_type(req->context, struct it_context); + + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); +} + /* add_record: add instancetype attribute */ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *down_req; struct ldb_message *msg; + struct it_context *ac; uint32_t instance_type; int ret; const struct ldb_control *partition_ctrl; @@ -70,18 +102,16 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) struct dsdb_control_current_partition); SMB_ASSERT(partition && partition->version == DSDB_CONTROL_CURRENT_PARTITION_VERSION); - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { - ldb_oom(module->ldb); + ac = talloc(req, struct it_context); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - - *down_req = *req; + ac->module = module; + ac->req = req; /* we have to copy the message as the caller might have it as a const */ - down_req->op.add.message = msg = ldb_msg_copy_shallow(down_req, req->op.add.message); + msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -99,23 +129,21 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_add_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, it_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; + /* go on with the call chain */ + return ldb_next_request(module, down_req); } _PUBLIC_ const struct ldb_module_ops ldb_instancetype_module_ops = { diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index bc998a835a..6acbf45afd 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -2,7 +2,7 @@ ldb database library Copyright (C) Andrew Bartlett 2005 - Copyright (C) Simo Sorce 2006 + Copyright (C) Simo Sorce 2006-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 @@ -74,15 +74,14 @@ static const char *user_name(TALLOC_CTX *mem_ctx, struct ldb_module *module) struct kludge_acl_context { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); + struct ldb_request *req; enum security_user_level user_type; bool allowedAttributes; bool allowedAttributesEffective; bool allowedChildClasses; bool allowedChildClassesEffective; - const char **attrs; + const char * const *attrs; }; /* read all objectClasses */ @@ -142,7 +141,7 @@ static int kludge_acl_allowedAttributes(struct ldb_context *ldb, struct ldb_mess ldb_msg_add_string(msg, attrName, attr_list[i]); } talloc_free(mem_ctx); - return 0; + return LDB_SUCCESS; } /* read all objectClasses */ @@ -191,6 +190,7 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * (comparison_fn_t)data_blob_cmp); for (i=1 ; i < allowedClasses->num_values; i++) { + struct ldb_val *val1 = &allowedClasses->values[i-1]; struct ldb_val *val2 = &allowedClasses->values[i]; if (data_blob_cmp(val1, val2) == 0) { @@ -201,86 +201,117 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * } } - return 0; + return LDB_SUCCESS; } /* find all attributes allowed by all these objectClasses */ -static int kludge_acl_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) { struct kludge_acl_context *ac; struct kludge_private_data *data; int i, ret; - ac = talloc_get_type(context, struct kludge_acl_context); + ac = talloc_get_type(req->context, struct kludge_acl_context); data = talloc_get_type(ac->module->private_data, struct kludge_private_data); - if (ares->type != LDB_REPLY_ENTRY) { - return ac->up_callback(ldb, ac->up_context, ares); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - if (ac->allowedAttributes) { - ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributes"); - if (ret != LDB_SUCCESS) { - return ret; - + switch (ares->type) { + case LDB_REPLY_ENTRY: + if (ac->allowedAttributes) { + ret = kludge_acl_allowedAttributes(ac->module->ldb, + ares->message, + "allowedAttributes"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } - } - if (ac->allowedChildClasses) { - ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClasses"); - if (ret != LDB_SUCCESS) { - return ret; + if (ac->allowedChildClasses) { + ret = kludge_acl_childClasses(ac->module->ldb, + ares->message, + "allowedChildClasses"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } - } - if (data && data->password_attrs) /* if we are not initialized just get through */ - { - switch (ac->user_type) { - case SECURITY_SYSTEM: - if (ac->allowedAttributesEffective) { - ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributesEffective"); - if (ret != LDB_SUCCESS) { - return ret; + if (data && data->password_attrs) /* if we are not initialized just get through */ + { + switch (ac->user_type) { + case SECURITY_SYSTEM: + if (ac->allowedAttributesEffective) { + ret = kludge_acl_allowedAttributes(ac->module->ldb, ares->message, + "allowedAttributesEffective"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } - } - if (ac->allowedChildClassesEffective) { - ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClassesEffective"); - if (ret != LDB_SUCCESS) { - return ret; + if (ac->allowedChildClassesEffective) { + ret = kludge_acl_childClasses(ac->module->ldb, ares->message, + "allowedChildClassesEffective"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } - } - break; - case SECURITY_ADMINISTRATOR: - if (ac->allowedAttributesEffective) { - ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributesEffective"); - if (ret != LDB_SUCCESS) { - return ret; + break; + + case SECURITY_ADMINISTRATOR: + if (ac->allowedAttributesEffective) { + ret = kludge_acl_allowedAttributes(ac->module->ldb, ares->message, + "allowedAttributesEffective"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } - } - if (ac->allowedChildClassesEffective) { - ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClassesEffective"); - if (ret != LDB_SUCCESS) { - return ret; + if (ac->allowedChildClassesEffective) { + ret = kludge_acl_childClasses(ac->module->ldb, ares->message, + "allowedChildClassesEffective"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + } + /* fall through */ + default: + /* remove password attributes */ + for (i = 0; data->password_attrs[i]; i++) { + ldb_msg_remove_attr(ares->message, data->password_attrs[i]); } } - /* fall though */ - default: - /* remove password attributes */ - for (i = 0; data->password_attrs[i]; i++) { - ldb_msg_remove_attr(ares->message, data->password_attrs[i]); + } + + if (ac->allowedAttributes || + ac->allowedAttributesEffective || + ac->allowedChildClasses || + ac->allowedChildClassesEffective) { + + if (!ldb_attr_in_list(ac->attrs, "objectClass") && + !ldb_attr_in_list(ac->attrs, "*")) { + + ldb_msg_remove_attr(ares->message, + "objectClass"); } } - } - if ((ac->allowedAttributes || ac->allowedAttributesEffective - || ac->allowedChildClasses || ac->allowedChildClassesEffective) && - (!ldb_attr_in_list(ac->attrs, "objectClass") && - !ldb_attr_in_list(ac->attrs, "*"))) { - ldb_msg_remove_attr(ares->message, "objectClass"); - } + return ldb_module_send_entry(ac->req, ares->message); + + case LDB_REPLY_REFERRAL: + return ldb_module_send_referral(ac->req, ares->referral); - return ac->up_callback(ldb, ac->up_context, ares); + case LDB_REPLY_DONE: + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + + } + return LDB_SUCCESS; } static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) @@ -288,9 +319,10 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) struct kludge_acl_context *ac; struct ldb_request *down_req; struct kludge_private_data *data; + const char * const *attrs; int ret, i; - - req->handle = NULL; + struct ldb_control *sd_control; + struct ldb_control **sd_saved_controls; ac = talloc(req, struct kludge_acl_context); if (ac == NULL) { @@ -301,23 +333,10 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) data = talloc_get_type(module->private_data, struct kludge_private_data); ac->module = module; - ac->up_context = req->context; - ac->up_callback = req->callback; + ac->req = req; ac->user_type = what_is_user(module); ac->attrs = req->op.search.attrs; - down_req = talloc_zero(req, struct ldb_request); - if (down_req == NULL) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - down_req->operation = req->operation; - down_req->op.search.base = req->op.search.base; - down_req->op.search.scope = req->op.search.scope; - down_req->op.search.tree = req->op.search.tree; - down_req->op.search.attrs = req->op.search.attrs; - ac->allowedAttributes = ldb_attr_in_list(req->op.search.attrs, "allowedAttributes"); ac->allowedAttributesEffective = ldb_attr_in_list(req->op.search.attrs, "allowedAttributesEffective"); @@ -327,12 +346,11 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) ac->allowedChildClassesEffective = ldb_attr_in_list(req->op.search.attrs, "allowedChildClassesEffective"); if (ac->allowedAttributes || ac->allowedAttributesEffective || ac->allowedChildClasses || ac->allowedChildClassesEffective) { - down_req->op.search.attrs - = ldb_attr_list_copy_add(down_req, down_req->op.search.attrs, "objectClass"); + attrs = ldb_attr_list_copy_add(ac, req->op.search.attrs, "objectClass"); + } else { + attrs = req->op.search.attrs; } - /* FIXME: I hink we should copy the tree and keep the original - * unmodified. SSS */ /* replace any attributes in the parse tree that are private, so we don't allow a search for 'userPassword=penguin', just as we would not allow that attribute to be returned */ @@ -340,30 +358,45 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) case SECURITY_SYSTEM: break; default: + /* FIXME: We should copy the tree and keep the original unmodified. */ /* remove password attributes */ - for (i = 0; data && data->password_attrs && data->password_attrs[i]; i++) { - ldb_parse_tree_attr_replace(down_req->op.search.tree, + + if (!data || !data->password_attrs) { + break; + } + for (i = 0; data->password_attrs[i]; i++) { + ldb_parse_tree_attr_replace(req->op.search.tree, data->password_attrs[i], "kludgeACLredactedattribute"); } } - down_req->controls = req->controls; - - down_req->context = ac; - down_req->callback = kludge_acl_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* perform the search */ - ret = ldb_next_request(module, down_req); + ret = ldb_build_search_req_ex(&down_req, + module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + attrs, + req->controls, + ac, kludge_acl_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + /* check if there's an SD_FLAGS control */ + sd_control = ldb_request_get_control(down_req, LDB_CONTROL_SD_FLAGS_OID); + if (sd_control) { + /* save it locally and remove it from the list */ + /* we do not need to replace them later as we + * are keeping the original req intact */ + if (!save_controls(sd_control, down_req, &sd_saved_controls)) { + return LDB_ERR_OPERATIONS_ERROR; + } } - return ret; + /* perform the search */ + return ldb_next_request(module, down_req); } /* ANY change type */ @@ -409,14 +442,12 @@ static int kludge_acl_init(struct ldb_module *module) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, ldb_dn_new(mem_ctx, module->ldb, "@KLUDGEACL"), - LDB_SCOPE_BASE, - NULL, attrs, - &res); + ret = ldb_search(module->ldb, mem_ctx, &res, + ldb_dn_new(mem_ctx, module->ldb, "@KLUDGEACL"), + LDB_SCOPE_BASE, attrs, NULL); if (ret != LDB_SUCCESS) { goto done; } - talloc_steal(mem_ctx, res); if (res->count == 0) { goto done; } @@ -444,6 +475,13 @@ static int kludge_acl_init(struct ldb_module *module) } data->password_attrs[i] = NULL; + ret = ldb_mod_register_control(module, LDB_CONTROL_SD_FLAGS_OID); + if (ret != LDB_SUCCESS) { + ldb_debug(module->ldb, LDB_DEBUG_ERROR, + "partition: Unable to register control with rootdse!\n"); + return LDB_ERR_OPERATIONS_ERROR; + } + done: talloc_free(mem_ctx); return ldb_next_init(module); diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index e64472432d..14fd107d81 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -2,6 +2,7 @@ ldb database library Copyright (C) Andrew Bartlett 2007 + Copyright (C) Simo Sorce 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 @@ -33,234 +34,176 @@ #include "ldb/include/ldb_private.h" #include "dsdb/samdb/samdb.h" -struct linked_attributes_context { - enum la_step {LA_SEARCH, LA_DO_OPS, LA_DO_ORIG} step; - struct ldb_module *module; - struct ldb_handle *handle; - struct ldb_request *orig_req; - - struct ldb_request *search_req; - struct ldb_request **down_req; - struct ldb_request *orig_down_req; - - int num_requests; - int finished_requests; - - const char **linked_attrs; +struct la_op_store { + struct la_op_store *next; + enum la_op {LA_OP_ADD, LA_OP_DEL} op; + struct ldb_dn *dn; + char *name; + char *value; }; struct replace_context { - struct linked_attributes_context *ac; + struct la_context *ac; + unsigned int num_elements; struct ldb_message_element *el; }; -static int linked_attributes_rename_del_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); - -static struct linked_attributes_context *linked_attributes_init_handle(struct ldb_request *req, - struct ldb_module *module) -{ - struct linked_attributes_context *ac; - struct ldb_handle *h; +struct la_context { + const struct dsdb_schema *schema; + struct ldb_module *module; + struct ldb_request *req; - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } + struct replace_context *rc; + struct la_op_store *ops; + struct la_op_store *cur; +}; - h->module = module; +static struct la_context *linked_attributes_init(struct ldb_module *module, + struct ldb_request *req) +{ + struct la_context *ac; - ac = talloc_zero(h, struct linked_attributes_context); + ac = talloc_zero(req, struct la_context); if (ac == NULL) { ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); return NULL; } - h->private_data = ac; - + ac->schema = dsdb_get_schema(module->ldb); ac->module = module; - ac->handle = h; - ac->orig_req = req; - - ac->orig_down_req = talloc(ac, struct ldb_request); - if (!ac->orig_down_req) { - ldb_oom(ac->module->ldb); - return NULL; - } - - *ac->orig_down_req = *req; - - req->handle = h; + ac->req = req; return ac; } /* Common routine to handle reading the attributes and creating a * series of modify requests */ - -static int setup_modifies(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, - struct linked_attributes_context *ac, - const struct ldb_message *msg, - struct ldb_dn *olddn, struct ldb_dn *newdn) +static int la_store_op(struct la_context *ac, + enum la_op op, char *dn, + const char *name, const char *value) { - int i, j, ret = LDB_SUCCESS; - const struct dsdb_schema *schema = dsdb_get_schema(ldb); - /* Look up each of the returned attributes */ - /* Find their schema */ - /* And it is an actual entry: now create a series of modify requests */ - for (i=0; i < msg->num_elements; i++) { - int otherid; - const struct dsdb_attribute *target_attr; - const struct ldb_message_element *el = &msg->elements[i]; - const struct dsdb_attribute *schema_attr - = dsdb_attribute_by_lDAPDisplayName(schema, el->name); - if (!schema_attr) { - ldb_asprintf_errstring(ldb, - "attribute %s is not a valid attribute in schema", el->name); - return LDB_ERR_OBJECT_CLASS_VIOLATION; - } - /* We have a valid attribute, but if it's not linked they maybe we just got an extra return on our search... */ - if (schema_attr->linkID == 0) { - continue; - } - - /* Depending on which direction this link is in, we need to find it's partner */ - if ((schema_attr->linkID & 1) == 1) { - otherid = schema_attr->linkID - 1; - } else { - otherid = schema_attr->linkID + 1; - } - - /* Now find the target attribute */ - target_attr = dsdb_attribute_by_linkID(schema, otherid); - if (!target_attr) { - ldb_asprintf_errstring(ldb, - "attribute %s does not have valid link target", el->name); - return LDB_ERR_OBJECT_CLASS_VIOLATION; - } - - /* For each value being moded, we need to setup the modify */ - for (j=0; j < el->num_values; j++) { - struct ldb_message_element *ret_el; - struct ldb_request *new_req; - struct ldb_message *new_msg; - - /* Create a spot in the list for the requests */ - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } + struct la_op_store *os, *tmp; + struct ldb_dn *op_dn; - /* Create the modify request */ - new_msg = ldb_msg_new(ac->down_req); - if (!new_msg) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - new_msg->dn = ldb_dn_from_ldb_val(new_msg, ldb, &el->values[j]); - if (!new_msg->dn) { - ldb_asprintf_errstring(ldb, - "attribute %s value %s was not a valid DN", msg->elements[i].name, - el->values[j].data); - return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; - } - - if (olddn) { - ret = ldb_msg_add_empty(new_msg, target_attr->lDAPDisplayName, - LDB_FLAG_MOD_DELETE, &ret_el); - if (ret != LDB_SUCCESS) { - return ret; - } - ret_el->values = talloc_array(new_msg, struct ldb_val, 1); - if (!ret_el->values) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ret_el->values[0] = data_blob_string_const(ldb_dn_get_linearized(olddn)); - ret_el->num_values = 1; - } - - if (newdn) { - ret = ldb_msg_add_empty(new_msg, target_attr->lDAPDisplayName, - LDB_FLAG_MOD_ADD, &ret_el); - if (ret != LDB_SUCCESS) { - return ret; - } - ret_el->values = talloc_array(new_msg, struct ldb_val, 1); - if (!ret_el->values) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + op_dn = ldb_dn_new(ac, ac->module->ldb, dn); + if (!op_dn) { + return LDB_ERR_OPERATIONS_ERROR; + } + + /* optimize out del - add operations that would end up + * with no changes */ + if (ac->ops && op == LA_OP_DEL) { + /* do a linear search to find out if there is + * an equivalent add */ + os = ac->ops; + while (os->next) { + + tmp = os->next; + if (tmp->op == LA_OP_ADD) { + + if ((strcmp(name, tmp->name) == 0) && + (strcmp(value, tmp->value) == 0) && + (ldb_dn_compare(op_dn, tmp->dn) == 0)) { + + break; } - ret_el->values[0] = data_blob_string_const(ldb_dn_get_linearized(newdn)); - ret_el->num_values = 1; } + os = os->next; + } + if (os->next) { + /* pair found, remove it and return */ + os->next = tmp->next; + talloc_free(tmp); + talloc_free(op_dn); + return LDB_SUCCESS; + } + } - ret = ldb_build_mod_req(&new_req, ldb, ac->down_req, - new_msg, - NULL, - NULL, - NULL); - if (ret != LDB_SUCCESS) { - return ret; - } - - talloc_steal(new_req, new_msg); - - ldb_set_timeout_from_prev_req(ldb, ac->orig_req, new_req); - - ac->down_req[ac->num_requests] = new_req; - ac->num_requests++; - - - /* Run the new request */ - ret = ldb_next_request(ac->module, new_req); - if (ret != LDB_SUCCESS) { - return ret; - } + os = talloc_zero(ac, struct la_op_store); + if (!os) { + return LDB_ERR_OPERATIONS_ERROR; + } + + os->op = op; + + os->dn = talloc_steal(os, op_dn); + if (!os->dn) { + return LDB_ERR_OPERATIONS_ERROR; + } + + os->name = talloc_strdup(os, name); + if (!os->name) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if ((op != LA_OP_DEL) && (value == NULL)) { + return LDB_ERR_OPERATIONS_ERROR; + } + if (value) { + os->value = talloc_strdup(os, value); + if (!os->value) { + return LDB_ERR_OPERATIONS_ERROR; } } - return ret; + + if (ac->ops) { + ac->cur->next = os; + } else { + ac->ops = os; + } + ac->cur = os; + + return LDB_SUCCESS; } +static int la_op_search_callback(struct ldb_request *req, + struct ldb_reply *ares); +static int la_do_mod_request(struct la_context *ac); +static int la_mod_callback(struct ldb_request *req, + struct ldb_reply *ares); +static int la_down_req(struct la_context *ac); +static int la_down_callback(struct ldb_request *req, + struct ldb_reply *ares); + + + /* add */ static int linked_attributes_add(struct ldb_module *module, struct ldb_request *req) { - int i; - struct linked_attributes_context *ac; - - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); - if (!schema) { - /* without schema, this doesn't make any sense */ - return ldb_next_request(module, req); - } + const struct dsdb_attribute *target_attr; + struct la_context *ac; + const char *attr_name; + const char *attr_val; + int ret; + int i, j; if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } - - ac = linked_attributes_init_handle(req, module); + ac = linked_attributes_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - - ac->step = LA_DO_OPS; - + + if (!ac->schema) { + /* without schema, this doesn't make any sense */ + talloc_free(ac); + return ldb_next_request(module, req); + } + /* Need to ensure we only have forward links being specified */ for (i=0; i < req->op.add.message->num_elements; i++) { const struct ldb_message_element *el = &req->op.add.message->elements[i]; const struct dsdb_attribute *schema_attr - = dsdb_attribute_by_lDAPDisplayName(schema, el->name); + = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { ldb_asprintf_errstring(module->ldb, - "attribute %s is not a valid attribute in schema", req->op.add.message->elements[i].name); + "attribute %s is not a valid attribute in schema", el->name); return LDB_ERR_OBJECT_CLASS_VIOLATION; } - /* We have a valid attribute, not find out if it is linked */ + /* We have a valid attribute, now find out if it is linked */ if (schema_attr->linkID == 0) { continue; } @@ -268,160 +211,155 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * if ((schema_attr->linkID & 1) == 1) { /* Odd is for the target. Illigal to modify */ ldb_asprintf_errstring(module->ldb, - "attribute %s must not be modified directly, it is a linked attribute", req->op.add.message->elements[i].name); + "attribute %s must not be modified directly, it is a linked attribute", el->name); return LDB_ERR_UNWILLING_TO_PERFORM; } /* Even link IDs are for the originating attribute */ - } - - /* Now call the common routine to setup the modifies across all the attributes */ - return setup_modifies(module->ldb, ac, ac, req->op.add.message, NULL, req->op.add.message->dn); -} + target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1); + if (!target_attr) { + /* + * windows 2003 has a broken schema where + * the definition of msDS-IsDomainFor + * is missing (which is supposed to be + * the backlink of the msDS-HasDomainNCs + * attribute + */ + continue; + } -struct merge { - struct ldb_dn *dn; - bool add; - bool ignore; -}; + attr_name = target_attr->lDAPDisplayName; + attr_val = ldb_dn_get_linearized(ac->req->op.add.message->dn); -static int merge_cmp(struct merge *merge1, struct merge *merge2) { - int ret; - ret = ldb_dn_compare(merge1->dn, merge2->dn); - if (ret == 0) { - if (merge1->add == merge2->add) { - return 0; - } - if (merge1->add == true) { - return 1; + for (j = 0; j < el->num_values; j++) { + ret = la_store_op(ac, LA_OP_ADD, + (char *)el->values[j].data, + attr_name, attr_val); + if (ret != LDB_SUCCESS) { + return ret; + } } - return -1; } - return ret; + + /* if no linked attributes are present continue */ + if (ac->ops == NULL) { + talloc_free(ac); + return ldb_next_request(module, req); + } + + /* start with the first one */ + return la_do_mod_request(ac); } -static int linked_attributes_mod_replace_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct replace_context *ac2 = talloc_get_type(context, struct replace_context); - struct linked_attributes_context *ac = ac2->ac; - - /* OK, we have one search result here: */ + const struct dsdb_attribute *schema_attr; + const struct dsdb_attribute *target_attr; + struct ldb_message_element *search_el; + struct replace_context *rc; + struct la_context *ac; + const char *attr_name; + const char *dn; + int i, j; + int ret = LDB_SUCCESS; - /* Only entries are interesting, and we only want the olddn */ - if (ares->type == LDB_REPLY_ENTRY - && ldb_dn_compare(ares->message->dn, ac->orig_req->op.mod.message->dn) == 0) { - /* only bother at all if there were some linked attributes found */ - struct ldb_message_element *search_el - = ldb_msg_find_element(ares->message, - ac2->el->name); - - /* See if this element already exists */ - if (search_el) { + ac = talloc_get_type(req->context, struct la_context); + rc = ac->rc; + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - struct merge *merged_list = NULL; + /* Only entries are interesting, and we only want the olddn */ + switch (ares->type) { + case LDB_REPLY_ENTRY: + + if (ldb_dn_compare(ares->message->dn, ac->req->op.mod.message->dn) != 0) { + /* Guh? We only asked for this DN */ + ldb_oom(ac->module->ldb); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - int ret, size = 0, i; - struct ldb_message *msg = ldb_msg_new(ac); - if (!msg) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } + dn = ldb_dn_get_linearized(ac->req->op.add.message->dn); - /* Add all the existing elements, marking as 'proposed for delete' by setting .add = false */ - for (i=0; i < search_el->num_values; i++) { - merged_list = talloc_realloc(ares, merged_list, struct merge, size + 1); - merged_list[size].dn = ldb_dn_from_ldb_val(merged_list, ldb, &search_el->values[i]); - merged_list[size].add = false; - merged_list[size].ignore = false; - size++; - } + for (i = 0; i < rc->num_elements; i++) { - /* Add all the new replacement elements, marking as 'proposed for add' by setting .add = true */ - for (i=0; i < ac2->el->num_values; i++) { - merged_list = talloc_realloc(ares, merged_list, struct merge, size + 1); - merged_list[size].dn = ldb_dn_from_ldb_val(merged_list, ldb, &ac2->el->values[i]); - merged_list[size].add = true; - merged_list[size].ignore = false; - size++; + schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, rc->el[i].name); + if (!schema_attr) { + ldb_asprintf_errstring(ac->module->ldb, + "attribute %s is not a valid attribute in schema", + rc->el[i].name); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OBJECT_CLASS_VIOLATION); } - /* Sort the list, so we can pick out an add and delete for the same DN, and eliminate them */ - qsort(merged_list, size, - sizeof(*merged_list), - (comparison_fn_t)merge_cmp); - - /* Now things are sorted, it is trivial to mark pairs of DNs as 'ignore' */ - for (i=0; i + 1 < size; i++) { - if (ldb_dn_compare(merged_list[i].dn, - merged_list[i+1].dn) == 0 - /* Fortunetly the sort also sorts 'add == false' first */ - && merged_list[i].add == false - && merged_list[i+1].add == true) { - - /* Mark as ignore, so we include neither in the actual operations */ - merged_list[i].ignore = true; - merged_list[i+1].ignore = true; - } - } + search_el = ldb_msg_find_element(ares->message, + rc->el[i].name); - /* Arrange to delete anything the search found that we don't re-add */ - for (i=0; i < size; i++) { - if (merged_list[i].ignore == false - && merged_list[i].add == false) { - ldb_msg_add_steal_string(msg, search_el->name, - ldb_dn_get_linearized(merged_list[i].dn)); - } + /* See if this element already exists */ + /* otherwise just ignore as + * the add has already been scheduled */ + if ( ! search_el) { + continue; } - /* The DN to set on the linked attributes is the original DN of the modify message */ - msg->dn = ac->orig_req->op.mod.message->dn; - - ret = setup_modifies(ac->module->ldb, ac2, ac, msg, ares->message->dn, NULL); - if (ret != LDB_SUCCESS) { - return ret; + target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1); + if (!target_attr) { + /* + * windows 2003 has a broken schema where + * the definition of msDS-IsDomainFor + * is missing (which is supposed to be + * the backlink of the msDS-HasDomainNCs + * attribute + */ + continue; } + attr_name = target_attr->lDAPDisplayName; - /* Now add links for all the actually new elements */ - for (i=0; i < size; i++) { - if (merged_list[i].ignore == false && merged_list[i].add == true) { - ldb_msg_add_steal_string(msg, search_el->name, - ldb_dn_get_linearized(merged_list[i].dn)); + /* make sure we manage each value */ + for (j = 0; j < search_el->num_values; j++) { + ret = la_store_op(ac, LA_OP_DEL, + (char *)search_el->values[j].data, + attr_name, dn); + if (ret != LDB_SUCCESS) { + talloc_free(ares); + return ldb_module_done(ac->req, + NULL, NULL, ret); } } + } - ret = setup_modifies(ac->module->ldb, ac2, ac, msg, NULL, ares->message->dn); - if (ret != LDB_SUCCESS) { - return ret; - } - - talloc_free(merged_list); + break; - } else { - /* Looks like it doesn't exist, process like an 'add' */ - struct ldb_message *msg = ldb_msg_new(ac); - if (!msg) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - msg->num_elements = 1; - msg->elements = ac2->el; - msg->dn = ac->orig_req->op.mod.message->dn; + case LDB_REPLY_REFERRAL: + /* ignore */ + break; - return setup_modifies(ac->module->ldb, ac2, ac, msg, NULL, ac->orig_req->op.mod.message->dn); - } - talloc_free(ares); - return LDB_SUCCESS; - } else if (ares->type == LDB_REPLY_ENTRY) { - /* Guh? We only asked for this DN */ - return LDB_ERR_OPERATIONS_ERROR; + case LDB_REPLY_DONE: - } else { talloc_free(ares); + + /* All mods set up, start with the first one */ + ret = la_do_mod_request(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } return LDB_SUCCESS; } - - + + talloc_free(ares); + return ret; } + + /* modify */ static int linked_attributes_modify(struct ldb_module *module, struct ldb_request *req) { @@ -431,523 +369,556 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques /* Apply the modify to the linked entry */ int i, j; - struct linked_attributes_context *ac; - - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); - if (!schema) { - /* without schema, this doesn't make any sense */ - return ldb_next_request(module, req); - } + struct la_context *ac; + struct ldb_request *search_req; + int ret; if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } - - ac = linked_attributes_init_handle(req, module); + ac = linked_attributes_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - - /* prepare the first operation */ - ac->step = LA_DO_OPS; + + if (!ac->schema) { + /* without schema, this doesn't make any sense */ + return ldb_next_request(module, req); + } + + ac->rc = NULL; for (i=0; i < req->op.mod.message->num_elements; i++) { - int ret; - struct ldb_request *new_req; + bool store_el = false; + const char *attr_name; + const char *attr_val; const struct dsdb_attribute *target_attr; const struct ldb_message_element *el = &req->op.mod.message->elements[i]; const struct dsdb_attribute *schema_attr - = dsdb_attribute_by_lDAPDisplayName(schema, el->name); + = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { ldb_asprintf_errstring(module->ldb, - "attribute %s is not a valid attribute in schema", req->op.mod.message->elements[i].name); + "attribute %s is not a valid attribute in schema", el->name); return LDB_ERR_OBJECT_CLASS_VIOLATION; } - /* We have a valid attribute, not find out if it is linked */ + /* We have a valid attribute, now find out if it is linked */ if (schema_attr->linkID == 0) { continue; } if ((schema_attr->linkID & 1) == 1) { - /* Odd is for the target. Illigal to modify */ + /* Odd is for the target. Illegal to modify */ ldb_asprintf_errstring(module->ldb, - "attribute %s must not be modified directly, it is a linked attribute", req->op.mod.message->elements[i].name); + "attribute %s must not be modified directly, it is a linked attribute", el->name); return LDB_ERR_UNWILLING_TO_PERFORM; } /* Even link IDs are for the originating attribute */ /* Now find the target attribute */ - target_attr = dsdb_attribute_by_linkID(schema, schema_attr->linkID + 1); + target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1); if (!target_attr) { - ldb_asprintf_errstring(module->ldb, - "attribute %s does not have valid link target", req->op.mod.message->elements[i].name); - return LDB_ERR_OBJECT_CLASS_VIOLATION; + /* + * windows 2003 has a broken schema where + * the definition of msDS-IsDomainFor + * is missing (which is supposed to be + * the backlink of the msDS-HasDomainNCs + * attribute + */ + continue; } - /* Replace with new set of values */ - if (((el->flags & LDB_FLAG_MOD_MASK) == LDB_FLAG_MOD_REPLACE) - && el->num_values > 0) { - struct replace_context *ac2 = talloc(ac, struct replace_context); - const char **attrs = talloc_array(ac, const char *, 2); - if (!attrs || !ac2) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - attrs[0] = el->name; - attrs[1] = NULL; - - ac2->ac = ac; - ac2->el = el; - - /* We need to setup a search, compare with the list, and then setup add/del as required */ - - /* The callback does all the hard work here */ - ret = ldb_build_search_req(&new_req, module->ldb, req, - req->op.mod.message->dn, - LDB_SCOPE_BASE, - "(objectClass=*)", - attrs, - NULL, - ac2, - linked_attributes_mod_replace_search_callback); - - if (ret != LDB_SUCCESS) { - return ret; - } - - talloc_steal(new_req, attrs); - - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); - - if (ret != LDB_SUCCESS) { - return ret; - } + attr_name = target_attr->lDAPDisplayName; + attr_val = ldb_dn_get_linearized(ac->req->op.mod.message->dn); - /* Create a spot in the list for the requests */ - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } + switch (el->flags & LDB_FLAG_MOD_MASK) { + case LDB_FLAG_MOD_REPLACE: + /* treat as just a normal add the delete part is handled by the callback */ + store_el = true; - ac->down_req[ac->num_requests] = talloc_steal(ac->down_req, new_req); - ac->num_requests++; + /* break intentionally missing */ - ret = ldb_next_request(module, new_req); - - if (ret != LDB_SUCCESS) { - return ret; - } - - continue; + case LDB_FLAG_MOD_ADD: - /* Delete all values case */ - } else if (((el->flags & LDB_FLAG_MOD_MASK) & (LDB_FLAG_MOD_DELETE|LDB_FLAG_MOD_REPLACE)) - && el->num_values == 0) { - const char **attrs = talloc_array(ac, const char *, 2); - if (!attrs) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + /* For each value being added, we need to setup the adds */ + for (j = 0; j < el->num_values; j++) { + ret = la_store_op(ac, LA_OP_ADD, + (char *)el->values[j].data, + attr_name, attr_val); + if (ret != LDB_SUCCESS) { + return ret; + } } - attrs[0] = el->name; - attrs[1] = NULL; - - /* We need to setup a search, and then setup del as required */ - - /* The callback does all the hard work here, acting identically to if we had delted the whole entry */ - ret = ldb_build_search_req(&new_req, module->ldb, req, - req->op.mod.message->dn, - LDB_SCOPE_BASE, - "(objectClass=*)", - attrs, - NULL, - ac, - linked_attributes_rename_del_search_callback); + break; - if (ret != LDB_SUCCESS) { - return ret; - } - - talloc_steal(new_req, attrs); - - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); - - if (ret != LDB_SUCCESS) { - return ret; - } + case LDB_FLAG_MOD_DELETE: - /* Create a spot in the list for the requests */ - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + if (el->num_values) { + /* For each value being deleted, we need to setup the delete */ + for (j = 0; j < el->num_values; j++) { + ret = la_store_op(ac, LA_OP_DEL, + (char *)el->values[j].data, + attr_name, attr_val); + if (ret != LDB_SUCCESS) { + return ret; + } + } + } else { + store_el = true; } - ac->down_req[ac->num_requests] = talloc_steal(ac->down_req, new_req); - ac->num_requests++; - - ret = ldb_next_request(module, new_req); - - if (ret != LDB_SUCCESS) { - return ret; - } - - continue; + break; } - /* Prepare the modify (mod element) on the targets, for a normal modify request */ - - /* For each value being moded, we need to setup the modify */ - for (j=0; j < el->num_values; j++) { - /* Create the modify request */ - struct ldb_message *new_msg = ldb_msg_new(ac); - if (!new_msg) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - new_msg->dn = ldb_dn_from_ldb_val(new_msg, module->ldb, &el->values[j]); - if (!new_msg->dn) { - ldb_asprintf_errstring(module->ldb, - "attribute %s value %s was not a valid DN", req->op.mod.message->elements[i].name, - el->values[j].data); - return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; - } + if (store_el) { + struct ldb_message_element *search_el; - ret = ldb_msg_add_empty(new_msg, target_attr->lDAPDisplayName, - el->flags & LDB_FLAG_MOD_MASK, NULL); - if (ret != LDB_SUCCESS) { - return ret; - } - - ret = ldb_msg_add_string(new_msg, target_attr->lDAPDisplayName, - ldb_dn_get_linearized(ac->orig_req->op.add.message->dn)); - if (ret != LDB_SUCCESS) { - return ret; + if (!ac->rc) { + ac->rc = talloc_zero(ac, struct replace_context); + if (!ac->rc) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } } - ret = ldb_build_mod_req(&new_req, module->ldb, ac, - new_msg, - NULL, - NULL, - NULL); - if (ret != LDB_SUCCESS) { - return ret; - } - - talloc_steal(new_req, new_msg); - - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); - - if (ret != LDB_SUCCESS) { - return ret; - } - - /* Now add it to the list */ - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ac->module->ldb); + search_el = talloc_realloc(ac->rc, ac->rc->el, + struct ldb_message_element, + ac->rc->num_elements +1); + if (!search_el) { + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ac->down_req[ac->num_requests] = talloc_steal(ac->down_req, new_req); - ac->num_requests++; + ac->rc->el = search_el; - /* Run the new request */ - ret = ldb_next_request(module, new_req); - if (ret != LDB_SUCCESS) { - return ret; - } + ac->rc->el[ac->rc->num_elements] = *el; + ac->rc->num_elements++; } } - return LDB_SUCCESS; -} -static int linked_attributes_rename_del_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) -{ - struct linked_attributes_context *ac = talloc_get_type(context, struct linked_attributes_context); - struct ldb_dn *olddn, *newdn; - - switch (ac->orig_req->operation) { - case LDB_DELETE: - { - olddn = ac->orig_req->op.del.dn; - newdn = NULL; - break; - } - /* This isn't the general modify case, just the modify when we are asked to delete all values */ - case LDB_MODIFY: - { - olddn = ac->orig_req->op.mod.message->dn; - newdn = NULL; - break; - } - case LDB_RENAME: - { - olddn = ac->orig_req->op.rename.olddn; - newdn = ac->orig_req->op.rename.newdn; - break; - } - default: - return LDB_ERR_OPERATIONS_ERROR; - } - + /* both replace and delete without values are handled in the callback + * after the search on the entry to be modified is performed */ + if (ac->rc) { + const char **attrs; + + attrs = talloc_array(ac->rc, const char *, ac->rc->num_elements +1); + if (!attrs) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + for (i = 0; i < ac->rc->num_elements; i++) { + attrs[i] = ac->rc->el[i].name; + } + attrs[i] = NULL; - /* OK, we have one search result here: */ + /* The callback does all the hard work here */ + ret = ldb_build_search_req(&search_req, module->ldb, ac, + req->op.mod.message->dn, + LDB_SCOPE_BASE, + "(objectClass=*)", attrs, + NULL, + ac, la_mod_search_callback, + req); - /* Only entries are interesting, and we only want the olddn */ - if (ares->type == LDB_REPLY_ENTRY - && ldb_dn_compare(ares->message->dn, olddn) == 0) { - /* only bother at all if there were some linked attributes found */ - if (ares->message->num_elements > 0) { - return setup_modifies(ldb, ac, ac, - ares->message, olddn, newdn); + if (ret == LDB_SUCCESS) { + talloc_steal(search_req, attrs); + + ret = ldb_next_request(module, search_req); } - talloc_free(ares); - return LDB_SUCCESS; - } else if (ares->type == LDB_REPLY_ENTRY) { - /* Guh? We only asked for this DN */ - return LDB_ERR_OPERATIONS_ERROR; } else { - talloc_free(ares); - return LDB_SUCCESS; + if (ac->ops) { + /* start the mod requests chain */ + ret = la_do_mod_request(ac); + } else { + /* nothing to do for this module, proceed */ + talloc_free(ac); + ret = ldb_next_request(module, req); + } } - - + + return ret; } -/* rename */ -static int linked_attributes_rename(struct ldb_module *module, struct ldb_request *req) + +/* delete, rename */ +static int linked_attributes_op(struct ldb_module *module, struct ldb_request *req) { - /* Look up list of linked attributes */ + struct ldb_request *search_req; + struct ldb_dn *base_dn; + struct la_context *ac; const char **attrs; WERROR werr; int ret; - struct linked_attributes_context *ac; - struct ldb_request *new_req; - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); - if (!schema) { - /* without schema, this doesn't make any sense */ - return ldb_next_request(module, req); - } /* This gets complex: We need to: - - Do a search for the entry + - Do a search for the entry - Wait for these result to appear - - In the callback for the result, issue a modify request based on the linked attributes found + - In the callback for the result, issue a modify + request based on the linked attributes found - Wait for each modify result - - Regain our sainity + - Regain our sainity */ - ac = linked_attributes_init_handle(req, module); + switch (req->operation) { + case LDB_RENAME: + base_dn = req->op.rename.olddn; + break; + case LDB_DELETE: + base_dn = req->op.del.dn; + break; + default: + return LDB_ERR_OPERATIONS_ERROR; + } + + ac = linked_attributes_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - - werr = dsdb_linked_attribute_lDAPDisplayName_list(schema, ac, &attrs); + + if (!ac->schema) { + /* without schema, this doesn't make any sense */ + return ldb_next_request(module, req); + } + + werr = dsdb_linked_attribute_lDAPDisplayName_list(ac->schema, ac, &attrs); if (!W_ERROR_IS_OK(werr)) { return LDB_ERR_OPERATIONS_ERROR; } - - ret = ldb_build_search_req(&new_req, module->ldb, req, - req->op.rename.olddn, - LDB_SCOPE_BASE, - "(objectClass=*)", - attrs, - NULL, - ac, - linked_attributes_rename_del_search_callback); + + ret = ldb_build_search_req(&search_req, module->ldb, req, + base_dn, LDB_SCOPE_BASE, + "(objectClass=*)", attrs, + NULL, + ac, la_op_search_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - talloc_steal(new_req, attrs); + talloc_steal(search_req, attrs); - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); + return ldb_next_request(module, search_req); +} - if (ret != LDB_SUCCESS) { - return ret; +static int la_op_search_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct la_context *ac; + const struct dsdb_attribute *schema_attr; + const struct dsdb_attribute *target_attr; + const struct ldb_message_element *el; + const char *attr_name; + const char *deldn; + const char *adddn; + int i, j; + int ret; + + ac = talloc_get_type(req->context, struct la_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + /* Only entries are interesting, and we only want the olddn */ + switch (ares->type) { + case LDB_REPLY_ENTRY: + ret = ldb_dn_compare(ares->message->dn, req->op.search.base); + if (ret != 0) { + /* Guh? We only asked for this DN */ + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->message->num_elements == 0) { + /* only bother at all if there were some + * linked attributes found */ + talloc_free(ares); + return LDB_SUCCESS; + } + + switch (ac->req->operation) { + case LDB_DELETE: + deldn = ldb_dn_get_linearized(ac->req->op.del.dn); + adddn = NULL; + break; + case LDB_RENAME: + deldn = ldb_dn_get_linearized(ac->req->op.rename.olddn); + adddn = ldb_dn_get_linearized(ac->req->op.rename.newdn); + break; + default: + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + for (i = 0; i < ares->message->num_elements; i++) { + el = &ares->message->elements[i]; + + schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); + if (!schema_attr) { + ldb_asprintf_errstring(ac->module->ldb, + "attribute %s is not a valid attribute" + " in schema", el->name); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OBJECT_CLASS_VIOLATION); + } + + /* Valid attribute, now find out if it is linked */ + if (schema_attr->linkID == 0) { + /* Not a linked attribute, skip */ + continue; + } + + if ((schema_attr->linkID & 1) == 0) { + /* Odd is for the target. */ + target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1); + if (!target_attr) { + continue; + } + attr_name = target_attr->lDAPDisplayName; + } else { + target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID - 1); + if (!target_attr) { + continue; + } + attr_name = target_attr->lDAPDisplayName; + } + for (j = 0; j < el->num_values; j++) { + ret = la_store_op(ac, LA_OP_DEL, + (char *)el->values[j].data, + attr_name, deldn); + if (ret != LDB_SUCCESS) { + talloc_free(ares); + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + if (!adddn) continue; + ret = la_store_op(ac, LA_OP_ADD, + (char *)el->values[j].data, + attr_name, adddn); + if (ret != LDB_SUCCESS) { + talloc_free(ares); + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + } + } + + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + break; + + case LDB_REPLY_DONE: + + talloc_free(ares); + + if (ac->ops) { + /* start the mod requests chain */ + ret = la_do_mod_request(ac); + } else { + ret = la_down_req(ac); + } + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + return LDB_SUCCESS; } - ac->search_req = new_req; - ac->step = LA_SEARCH; - return ldb_next_request(module, new_req); + talloc_free(ares); + return LDB_SUCCESS; } -/* delete */ -static int linked_attributes_delete(struct ldb_module *module, struct ldb_request *req) +/* do a linked attributes modify request */ +static int la_do_mod_request(struct la_context *ac) { - /* Look up list of linked attributes */ - const char **attrs; - WERROR werr; + struct ldb_message_element *ret_el; + struct ldb_request *mod_req; + struct ldb_message *new_msg; + struct ldb_context *ldb; int ret; - struct ldb_request *new_req; - struct linked_attributes_context *ac; - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); - if (!schema) { - /* without schema, this doesn't make any sense */ - return ldb_next_request(module, req); - } - /* This gets complex: We need to: - - Do a search for the entry - - Wait for these result to appear - - In the callback for the result, issue a modify request based on the linked attributes found - - Wait for each modify result - - Regain our sainity - */ + ldb = ac->module->ldb; - ac = linked_attributes_init_handle(req, module); - if (!ac) { + /* Create the modify request */ + new_msg = ldb_msg_new(ac); + if (!new_msg) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - - werr = dsdb_linked_attribute_lDAPDisplayName_list(schema, ac, &attrs); - if (!W_ERROR_IS_OK(werr)) { + new_msg->dn = ldb_dn_copy(new_msg, ac->ops->dn); + if (!new_msg->dn) { return LDB_ERR_OPERATIONS_ERROR; - }; - - ret = ldb_build_search_req(&new_req, module->ldb, req, - req->op.del.dn, - LDB_SCOPE_BASE, - "(objectClass=*)", - attrs, - NULL, - ac, - linked_attributes_rename_del_search_callback); + } + if (ac->ops->op == LA_OP_ADD) { + ret = ldb_msg_add_empty(new_msg, ac->ops->name, + LDB_FLAG_MOD_ADD, &ret_el); + } else { + ret = ldb_msg_add_empty(new_msg, ac->ops->name, + LDB_FLAG_MOD_DELETE, &ret_el); + } if (ret != LDB_SUCCESS) { return ret; } - - talloc_steal(new_req, attrs); - - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); - + ret_el->values = talloc_array(new_msg, struct ldb_val, 1); + if (!ret_el->values) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + ret_el->values[0] = data_blob_string_const(ac->ops->value); + ret_el->num_values = 1; + + /* use ac->ops as the mem_ctx so that the request will be freed + * in the callback as soon as completed */ + ret = ldb_build_mod_req(&mod_req, ldb, ac->ops, + new_msg, + NULL, + ac, la_mod_callback, + ac->req); if (ret != LDB_SUCCESS) { return ret; } + talloc_steal(mod_req, new_msg); - ac->search_req = new_req; - ac->step = LA_SEARCH; - return ldb_next_request(module, new_req); + /* Run the new request */ + return ldb_next_request(ac->module, mod_req); } +static int la_mod_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct la_context *ac; + struct la_op_store *os; + int ret; -static int linked_attributes_wait_none(struct ldb_handle *handle) { - struct linked_attributes_context *ac; - int i, ret = LDB_ERR_OPERATIONS_ERROR; - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } + ac = talloc_get_type(req->context, struct la_context); - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct linked_attributes_context); - - switch (ac->step) { - case LA_SEARCH: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS) { - handle->status = ac->search_req->handle->status; - goto done; - } - - if (ac->search_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - ac->step = LA_DO_OPS; - return LDB_SUCCESS; + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, + "invalid ldb_reply_type in callback"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - case LA_DO_OPS: - for (i=0; i < ac->num_requests; i++) { - ret = ldb_wait(ac->down_req[i]->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req[i]->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req[i]->handle->status; - goto done; - } - - if (ac->down_req[i]->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - } + talloc_free(ares); - /* Now run the original request */ - ac->step = LA_DO_ORIG; - return ldb_next_request(ac->module, ac->orig_down_req); + if (ac->ops) { + os = ac->ops; + ac->ops = os->next; - case LA_DO_ORIG: - ret = ldb_wait(ac->orig_down_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->orig_down_req->handle->status != LDB_SUCCESS) { - handle->status = ac->orig_down_req->handle->status; - goto done; - } - - if (ac->orig_down_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - ret = LDB_SUCCESS; + /* this frees the request too + * DO NOT access 'req' after this point */ + talloc_free(os); } -done: - handle->state = LDB_ASYNC_DONE; - return ret; + /* as last op run the original request */ + if (ac->ops) { + ret = la_do_mod_request(ac); + } else { + ret = la_down_req(ac); + } + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + return LDB_SUCCESS; } -static int linked_attributes_wait_all(struct ldb_handle *handle) { - +static int la_down_req(struct la_context *ac) +{ + struct ldb_request *down_req; int ret; - while (handle->state != LDB_ASYNC_DONE) { - ret = linked_attributes_wait_none(handle); - if (ret != LDB_SUCCESS) { - return ret; - } + switch (ac->req->operation) { + case LDB_ADD: + ret = ldb_build_add_req(&down_req, ac->module->ldb, ac, + ac->req->op.add.message, + ac->req->controls, + ac, la_down_callback, + ac->req); + break; + case LDB_MODIFY: + ret = ldb_build_mod_req(&down_req, ac->module->ldb, ac, + ac->req->op.mod.message, + ac->req->controls, + ac, la_down_callback, + ac->req); + break; + case LDB_DELETE: + ret = ldb_build_del_req(&down_req, ac->module->ldb, ac, + ac->req->op.del.dn, + ac->req->controls, + ac, la_down_callback, + ac->req); + break; + case LDB_RENAME: + ret = ldb_build_rename_req(&down_req, ac->module->ldb, ac, + ac->req->op.rename.olddn, + ac->req->op.rename.newdn, + ac->req->controls, + ac, la_down_callback, + ac->req); + break; + default: + ret = LDB_ERR_OPERATIONS_ERROR; + } + if (ret != LDB_SUCCESS) { + return ret; } - return handle->status; + return ldb_next_request(ac->module, down_req); } -static int linked_attributes_wait(struct ldb_handle *handle, enum ldb_wait_type type) +static int la_down_callback(struct ldb_request *req, struct ldb_reply *ares) { - if (type == LDB_WAIT_ALL) { - return linked_attributes_wait_all(handle); - } else { - return linked_attributes_wait_none(handle); + struct la_context *ac; + + ac = talloc_get_type(req->context, struct la_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, + "invalid ldb_reply_type in callback"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } _PUBLIC_ const struct ldb_module_ops ldb_linked_attributes_module_ops = { .name = "linked_attributes", .add = linked_attributes_add, .modify = linked_attributes_modify, - .del = linked_attributes_delete, - .rename = linked_attributes_rename, - .wait = linked_attributes_wait, + .del = linked_attributes_op, + .rename = linked_attributes_op, }; diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c index a411c01513..622e444166 100644 --- a/source4/dsdb/samdb/ldb_modules/local_password.c +++ b/source4/dsdb/samdb/ldb_modules/local_password.c @@ -1,7 +1,7 @@ /* ldb database module - Copyright (C) Simo Sorce 2004-2006 + Copyright (C) Simo Sorce 2004-2008 Copyright (C) Andrew Bartlett 2005-2006 Copyright (C) Andrew Tridgell 2004 @@ -44,7 +44,7 @@ This allows the password database to be syncronised in a multi-master fashion, seperate to the more difficult concerns of the main database. (With passwords, the last writer always wins) - + Each incoming add/modify is split into a remote, and a local request, done in that order. We maintain a list of attributes that are kept locally: @@ -62,73 +62,89 @@ static const char * const password_attrs[] = { /* And we merge them back into search requests when asked to do so */ -struct lpdb_context { +struct lpdb_reply { + struct lpdb_reply *next; + struct ldb_reply *remote; + struct ldb_dn *local_dn; +}; - enum lpdb_type {LPDB_ADD, LPDB_MOD, LPDB_SEARCH} type; - enum lpdb_step {LPDB_ADD_REMOTE, LPDB_MOD_REMOTE, LPDB_MOD_SEARCH_SELF, LPDB_LOCAL, LPDB_SEARCH_REMOTE} step; +struct lpdb_context { struct ldb_module *module; - struct ldb_request *orig_req; - struct ldb_request *remote_req; - struct ldb_request *search_req; - struct ldb_request *local_req; + struct ldb_request *req; struct ldb_message *local_message; + struct lpdb_reply *list; + struct lpdb_reply *current; + struct ldb_reply *remote_done; + struct ldb_reply *remote; + bool added_objectGUID; bool added_objectClass; - struct ldb_reply *search_res; -}; - -struct lpdb_local_search_context { - struct lpdb_context *ac; - struct ldb_reply *remote_res; - struct ldb_reply *local_res; }; -static struct ldb_handle *lpdb_init_handle(struct ldb_request *req, struct ldb_module *module, enum lpdb_type type) +static struct lpdb_context *lpdb_init_context(struct ldb_module *module, + struct ldb_request *req) { struct lpdb_context *ac; - struct ldb_handle *h; - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { + ac = talloc_zero(req, struct lpdb_context); + if (ac == NULL) { ldb_set_errstring(module->ldb, "Out of Memory"); return NULL; } - h->module = module; + ac->module = module; + ac->req = req; - ac = talloc_zero(h, struct lpdb_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; - } + return ac; +} - h->private_data = (void *)ac; +static int lpdb_local_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct lpdb_context *ac; - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; + ac = talloc_get_type(req->context, struct lpdb_context); - ac->type = type; - ac->module = module; - ac->orig_req = req; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - return h; + talloc_free(ares); + return ldb_module_done(ac->req, + ac->remote_done->controls, + ac->remote_done->response, + ac->remote_done->error); } -/* Add a record, splitting password attributes from the user's main - * record */ +/***************************************************************************** + * ADD + ****************************************************************************/ + +static int lpdb_add_callback(struct ldb_request *req, + struct ldb_reply *ares); static int local_password_add(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; - struct lpdb_context *ac; struct ldb_message *remote_message; - struct ldb_message *local_message; + struct ldb_request *remote_req; + struct lpdb_context *ac; struct GUID objectGUID; + int ret; int i; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_add\n"); @@ -163,22 +179,12 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req } /* From here, we assume we have password attributes to split off */ - h = lpdb_init_handle(req, module, LPDB_ADD); - if (!h) { + ac = lpdb_init_context(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct lpdb_context); - ac->orig_req = req; - - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->remote_req) = *(ac->orig_req); - - remote_message = ldb_msg_copy_shallow(ac->remote_req, ac->orig_req->op.add.message); + remote_message = ldb_msg_copy_shallow(remote_req, req->op.add.message); if (remote_message == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -188,81 +194,113 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req ldb_msg_remove_attr(remote_message, password_attrs[i]); } - ac->remote_req->op.add.message = remote_message; - - ac->remote_req->context = NULL; - ac->remote_req->callback = NULL; - - ac->local_req = talloc(ac, struct ldb_request); - if (ac->local_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } + /* Find the objectGUID to use as the key */ + objectGUID = samdb_result_guid(ac->req->op.add.message, "objectGUID"); - *(ac->local_req) = *(ac->orig_req); - local_message = ldb_msg_copy_shallow(ac->local_req, ac->orig_req->op.add.message); - if (local_message == NULL) { + ac->local_message = ldb_msg_copy_shallow(ac, req->op.add.message); + if (ac->local_message == NULL) { return LDB_ERR_OPERATIONS_ERROR; } /* Remove anything seen in the remote message from the local * message (leaving only password attributes) */ - for (i=0;iremote_req->op.add.message->num_elements;i++) { - ldb_msg_remove_attr(local_message, ac->remote_req->op.add.message->elements[i].name); + for (i=0; i < remote_message->num_elements; i++) { + ldb_msg_remove_attr(ac->local_message, remote_message->elements[i].name); } /* We must have an objectGUID already, or we don't know where * to add the password. This may be changed to an 'add and * search', to allow the directory to create the objectGUID */ - if (ldb_msg_find_ldb_val(ac->orig_req->op.add.message, "objectGUID") == NULL) { - ldb_set_errstring(module->ldb, - "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"); + if (ldb_msg_find_ldb_val(req->op.add.message, "objectGUID") == NULL) { + ldb_set_errstring(module->ldb, + "no objectGUID found in search: " + "local_password module must be " + "onfigured below objectGUID module!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } - /* Find the objectGUID to use as the key */ - objectGUID = samdb_result_guid(ac->orig_req->op.add.message, "objectGUID"); - - local_message->dn = ldb_dn_new(local_message, module->ldb, LOCAL_BASE); - ldb_dn_add_child_fmt(local_message->dn, PASSWORD_GUID_ATTR "=%s", GUID_string(local_message, &objectGUID)); - - ac->local_req->op.add.message = local_message; - - ac->local_req->context = NULL; - ac->local_req->callback = NULL; - - ac->step = LPDB_ADD_REMOTE; + ac->local_message->dn = ldb_dn_new(ac->local_message, + module->ldb, LOCAL_BASE); + if ((ac->local_message->dn == NULL) || + ( ! ldb_dn_add_child_fmt(ac->local_message->dn, + PASSWORD_GUID_ATTR "=%s", + GUID_string(ac->local_message, + &objectGUID)))) { + return LDB_ERR_OPERATIONS_ERROR; + } - /* Return our own handle do deal with this call */ - req->handle = h; + ret = ldb_build_add_req(&remote_req, module->ldb, ac, + remote_message, + req->controls, + ac, lpdb_add_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; + } - return ldb_next_request(module, ac->remote_req); + return ldb_next_request(module, remote_req); } -/* After adding the remote entry, add the local one */ -static int local_password_add_local(struct ldb_handle *h) { - +/* Add a record, splitting password attributes from the user's main + * record */ +static int lpdb_add_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct ldb_request *local_req; struct lpdb_context *ac; - ac = talloc_get_type(h->private_data, struct lpdb_context); + int ret; + + ac = talloc_get_type(req->context, struct lpdb_context); - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ac->step = LPDB_LOCAL; + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); + ac->remote_done = talloc_steal(ac, ares); - /* perform the local add */ - return ldb_next_request(ac->module, ac->local_req); + ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ac->local_message, + NULL, + ac, lpdb_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + ret = ldb_next_request(ac->module, local_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + return LDB_SUCCESS; } -static int local_password_mod_search_self(struct ldb_handle *h); +/***************************************************************************** + * MODIFY + ****************************************************************************/ + +static int lpdb_modify_callabck(struct ldb_request *req, + struct ldb_reply *ares); +static int lpdb_mod_search_callback(struct ldb_request *req, + struct ldb_reply *ares); static int local_password_modify(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; struct lpdb_context *ac; struct ldb_message *remote_message; - struct ldb_message *local_message; + struct ldb_request *remote_req; + int ret; int i; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_modify\n"); @@ -289,243 +327,565 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * } /* From here, we assume we have password attributes to split off */ - h = lpdb_init_handle(req, module, LPDB_MOD); - if (!h) { + ac = lpdb_init_context(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct lpdb_context); - ac->orig_req = req; - - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->remote_req) = *(ac->orig_req); - remote_message = ldb_msg_copy_shallow(ac->remote_req, ac->orig_req->op.mod.message); + remote_message = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); if (remote_message == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - + /* Remove any password attributes from the remote message */ for (i=0; i < ARRAY_SIZE(password_attrs); i++) { ldb_msg_remove_attr(remote_message, password_attrs[i]); } - ac->remote_req->op.mod.message = remote_message; - - ac->remote_req->context = NULL; - ac->remote_req->callback = NULL; - - ac->local_req = talloc(ac, struct ldb_request); - if (ac->local_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->local_req) = *(ac->orig_req); - local_message = ldb_msg_copy_shallow(ac->local_req, ac->orig_req->op.mod.message); - if (local_message == NULL) { + ac->local_message = ldb_msg_copy_shallow(ac, ac->req->op.mod.message); + if (ac->local_message == NULL) { return LDB_ERR_OPERATIONS_ERROR; } /* Remove anything seen in the remote message from the local * message (leaving only password attributes) */ - for (i=0;iremote_req->op.mod.message->num_elements;i++) { - ldb_msg_remove_attr(local_message, ac->remote_req->op.mod.message->elements[i].name); + for (i=0; i < remote_message->num_elements;i++) { + ldb_msg_remove_attr(ac->local_message, remote_message->elements[i].name); } - ac->local_req->op.mod.message = local_message; - ac->local_message = local_message; + ret = ldb_build_mod_req(&remote_req, module->ldb, ac, + remote_message, + req->controls, + ac, lpdb_modify_callabck, + req); + if (ret != LDB_SUCCESS) { + return ret; + } - ac->local_req->context = NULL; - ac->local_req->callback = NULL; + return ldb_next_request(module, remote_req); +} - ac->step = LPDB_MOD_REMOTE; +/* On a modify, we don't have the objectGUID handy, so we need to + * search our DN for it */ +static int lpdb_modify_callabck(struct ldb_request *req, + struct ldb_reply *ares) +{ + static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; + struct ldb_request *search_req; + struct lpdb_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct lpdb_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ac->remote_done = talloc_steal(ac, ares); - /* Return our own handle do deal with this call */ - req->handle = h; + /* prepare the search operation */ + ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ac->req->op.mod.message->dn, LDB_SCOPE_BASE, + "(objectclass=*)", attrs, + NULL, + ac, lpdb_mod_search_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - return ldb_next_request(module, ac->remote_req); + ret = ldb_next_request(ac->module, search_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + return LDB_SUCCESS; } -/* Called when we search for our oen entry. Stores the one entry we +/* Called when we search for our own entry. Stores the one entry we * expect (as it is a base search) on the context pointer */ -static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int lpdb_mod_search_callback(struct ldb_request *req, + struct ldb_reply *ares) { + struct ldb_request *local_req; struct lpdb_context *ac; + struct ldb_dn *local_dn; + struct GUID objectGUID; + int ret = LDB_SUCCESS; - ac = talloc_get_type(context, struct lpdb_context); + ac = talloc_get_type(req->context, struct lpdb_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - /* we are interested only in the single reply (base search) we receive here */ - if (ares->type == LDB_REPLY_ENTRY) { - if (ac->search_res != NULL) { - ldb_set_errstring(ldb, "Too many results"); + switch (ares->type) { + case LDB_REPLY_ENTRY: + if (ac->remote != NULL) { + ldb_set_errstring(ac->module->ldb, "Too many results"); talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ac->search_res = talloc_steal(ac, ares); - } else { + ac->remote = talloc_steal(ac, ares); + break; + + case LDB_REPLY_REFERRAL: + + /* ignore */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: + /* After we find out the objectGUID for the entry, modify the local + * password database as required */ + talloc_free(ares); + + /* if it is not an entry of type person this is an error */ + /* TODO: remove this when sambaPassword will be in schema */ + if (ac->remote == NULL) { + ldb_asprintf_errstring(ac->module->ldb, + "entry just modified (%s) not found!", + ldb_dn_get_linearized(req->op.search.base)); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (!ldb_msg_check_string_attribute(ac->remote->message, + "objectClass", "person")) { + /* Not relevent to us */ + return ldb_module_done(ac->req, + ac->remote_done->controls, + ac->remote_done->response, + ac->remote_done->error); + } + + if (ldb_msg_find_ldb_val(ac->remote->message, + "objectGUID") == NULL) { + ldb_set_errstring(ac->module->ldb, + "no objectGUID found in search: " + "local_password module must be " + "configured below objectGUID " + "module!\n"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OBJECT_CLASS_VIOLATION); + } + + objectGUID = samdb_result_guid(ac->remote->message, + "objectGUID"); + + local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + if ((local_dn == NULL) || + ( ! ldb_dn_add_child_fmt(local_dn, + PASSWORD_GUID_ATTR "=%s", + GUID_string(ac, &objectGUID)))) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + ac->local_message->dn = local_dn; + + ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac, + ac->local_message, + NULL, + ac, lpdb_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + /* perform the local update */ + ret = ldb_next_request(ac->module, local_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } return LDB_SUCCESS; } -/* On a modify, we don't have the objectGUID handy, so we need to - * search our DN for it */ -static int local_password_mod_search_self(struct ldb_handle *h) { +/***************************************************************************** + * DELETE + ****************************************************************************/ +static int lpdb_delete_callabck(struct ldb_request *req, + struct ldb_reply *ares); +static int lpdb_del_search_callback(struct ldb_request *req, + struct ldb_reply *ares); + +static int local_password_delete(struct ldb_module *module, + struct ldb_request *req) +{ + struct ldb_request *remote_req; struct lpdb_context *ac; - static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; + int ret; - ac = talloc_get_type(h->private_data, struct lpdb_context); + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_delete\n"); - /* prepare the search operation */ - ac->search_req = talloc_zero(ac, struct ldb_request); - if (ac->search_req == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, "Out of Memory!\n"); - return LDB_ERR_OPERATIONS_ERROR; + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.mod.message->dn)) { + return ldb_next_request(module, req); + } + + /* If the caller is manipulating the local passwords directly, + * let them pass */ + if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + req->op.del.dn) == 0) { + return ldb_next_request(module, req); } - ac->search_req->operation = LDB_SEARCH; - ac->search_req->op.search.base = ac->orig_req->op.mod.message->dn; - ac->search_req->op.search.scope = LDB_SCOPE_BASE; - ac->search_req->op.search.tree = ldb_parse_tree(ac->orig_req, NULL); - if (ac->search_req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, "Invalid search filter"); + /* From here, we assume we have password attributes to split off */ + ac = lpdb_init_context(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ac->search_req->op.search.attrs = attrs; - ac->search_req->controls = NULL; - ac->search_req->context = ac; - ac->search_req->callback = get_self_callback; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->search_req); - ac->step = LPDB_MOD_SEARCH_SELF; + ret = ldb_build_del_req(&remote_req, module->ldb, ac, + req->op.del.dn, + req->controls, + ac, lpdb_delete_callabck, + req); + if (ret != LDB_SUCCESS) { + return ret; + } - return ldb_next_request(ac->module, ac->search_req); + return ldb_next_request(module, remote_req); } -/* After we find out the objectGUID for the entry, modify the local - * password database as required */ -static int local_password_mod_local(struct ldb_handle *h) { +/* On a modify, we don't have the objectGUID handy, so we need to + * search our DN for it */ +static int lpdb_delete_callabck(struct ldb_request *req, + struct ldb_reply *ares) +{ + static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; + struct ldb_request *search_req; + struct lpdb_context *ac; + int ret; + ac = talloc_get_type(req->context, struct lpdb_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ac->remote_done = talloc_steal(ac, ares); + + /* prepare the search operation */ + ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ac->req->op.del.dn, LDB_SCOPE_BASE, + "(objectclass=*)", attrs, + NULL, + ac, lpdb_del_search_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ret = ldb_next_request(ac->module, search_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + return LDB_SUCCESS; +} + +/* Called when we search for our own entry. Stores the one entry we + * expect (as it is a base search) on the context pointer */ +static int lpdb_del_search_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct ldb_request *local_req; struct lpdb_context *ac; + struct ldb_dn *local_dn; struct GUID objectGUID; - ac = talloc_get_type(h->private_data, struct lpdb_context); - - /* if it is not an entry of type person this is an error */ - /* TODO: remove this when these things are checked in the schema */ - if (!ac->search_res) { - ldb_asprintf_errstring(ac->module->ldb, - "entry just modified (%s) not found!", - ldb_dn_get_linearized(ac->remote_req->op.mod.message->dn)); - return LDB_ERR_OPERATIONS_ERROR; - } - if (!ldb_msg_check_string_attribute(ac->search_res->message, "objectClass", "person")) { - /* Not relevent to us */ - return LDB_SUCCESS; + int ret = LDB_SUCCESS; + + ac = talloc_get_type(req->context, struct lpdb_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - - if (ldb_msg_find_ldb_val(ac->search_res->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, - "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"); - return LDB_ERR_OBJECT_CLASS_VIOLATION; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - - objectGUID = samdb_result_guid(ac->search_res->message, "objectGUID"); - ac->local_message->dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); - ldb_dn_add_child_fmt(ac->local_message->dn, PASSWORD_GUID_ATTR "=%s", GUID_string(ac, &objectGUID)); + switch (ares->type) { + case LDB_REPLY_ENTRY: + if (ac->remote != NULL) { + ldb_set_errstring(ac->module->ldb, "Too many results"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ac->remote = talloc_steal(ac, ares); + break; + + case LDB_REPLY_REFERRAL: - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; + /* ignore */ + talloc_free(ares); + break; - ac->step = LPDB_LOCAL; + case LDB_REPLY_DONE: + /* After we find out the objectGUID for the entry, modify the local + * password database as required */ - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); + talloc_free(ares); + + /* if it is not an entry of type person this is NOT an error */ + /* TODO: remove this when sambaPassword will be in schema */ + if (ac->remote == NULL) { + return ldb_module_done(ac->req, + ac->remote_done->controls, + ac->remote_done->response, + ac->remote_done->error); + } + if (!ldb_msg_check_string_attribute(ac->remote->message, + "objectClass", "person")) { + /* Not relevent to us */ + return ldb_module_done(ac->req, + ac->remote_done->controls, + ac->remote_done->response, + ac->remote_done->error); + } + + if (ldb_msg_find_ldb_val(ac->remote->message, + "objectGUID") == NULL) { + ldb_set_errstring(ac->module->ldb, + "no objectGUID found in search: " + "local_password module must be " + "configured below objectGUID " + "module!\n"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OBJECT_CLASS_VIOLATION); + } + + objectGUID = samdb_result_guid(ac->remote->message, + "objectGUID"); + + local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + if ((local_dn == NULL) || + ( ! ldb_dn_add_child_fmt(local_dn, + PASSWORD_GUID_ATTR "=%s", + GUID_string(ac, &objectGUID)))) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ret = ldb_build_del_req(&local_req, ac->module->ldb, ac, + local_dn, + NULL, + ac, lpdb_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } - /* perform the local update */ - return ldb_next_request(ac->module, ac->local_req); + /* perform the local update */ + ret = ldb_next_request(ac->module, local_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + } + + return LDB_SUCCESS; } -static int lpdb_local_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +/***************************************************************************** + * SEARCH + ****************************************************************************/ + +static int lpdb_local_search_callback(struct ldb_request *req, + struct ldb_reply *ares); + +static int lpdb_local_search(struct lpdb_context *ac) +{ + struct ldb_request *local_req; + int ret; + + ret = ldb_build_search_req(&local_req, ac->module->ldb, ac, + ac->current->local_dn, + LDB_SCOPE_BASE, + "(objectclass=*)", + ac->req->op.search.attrs, + NULL, + ac, lpdb_local_search_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + + return ldb_next_request(ac->module, local_req); +} + +static int lpdb_local_search_callback(struct ldb_request *req, + struct ldb_reply *ares) { - struct lpdb_local_search_context *local_context; + struct lpdb_context *ac; + struct ldb_reply *merge; + struct lpdb_reply *lr; + int ret; + int i; + + ac = talloc_get_type(req->context, struct lpdb_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - local_context = talloc_get_type(context, struct lpdb_local_search_context); + lr = ac->current; - /* we are interested only in the single reply (base search) we receive here */ + /* we are interested only in a single reply (base search) */ switch (ares->type) { case LDB_REPLY_ENTRY: - { - int i; - if (local_context->local_res != NULL) { - ldb_set_errstring(ldb, "Too many results to base search for password entry!"); + + if (lr->remote == NULL) { + ldb_set_errstring(ac->module->ldb, + "Too many results for password entry search!"); talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - - local_context->local_res = ares; - /* Make sure never to return the internal key attribute to the caller */ + merge = lr->remote; + lr->remote = NULL; + + /* steal the local results on the remote results to be + * returned all together */ + talloc_steal(merge, ares->message->elements); + + /* Make sure never to return the internal key attribute */ ldb_msg_remove_attr(ares->message, PASSWORD_GUID_ATTR); - talloc_steal(local_context->remote_res->message->elements, ares->message->elements); for (i=0; i < ares->message->num_elements; i++) { struct ldb_message_element *el; - el = ldb_msg_find_element(local_context->remote_res->message, + el = ldb_msg_find_element(merge->message, ares->message->elements[i].name); if (!el) { - if (ldb_msg_add_empty(local_context->remote_res->message, - ares->message->elements[i].name, 0, &el) != LDB_SUCCESS) { + ret = ldb_msg_add_empty(merge->message, + ares->message->elements[i].name, + 0, &el); + if (ret != LDB_SUCCESS) { talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_done(ac->req, + NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } *el = ares->message->elements[i]; } } - return local_context->ac->orig_req->callback(ldb, - local_context->ac->orig_req->context, - local_context->remote_res); - } - case LDB_REPLY_DONE: - { - /* Fire off the callback if there was no local entry, so we get the rest returned */ - if (local_context->local_res == NULL) { - return local_context->ac->orig_req->callback(ldb, - local_context->ac->orig_req->context, - local_context->remote_res); - } - return LDB_SUCCESS; + + /* free the rest */ + talloc_free(ares); + + return ldb_module_send_entry(ac->req, merge->message); + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); break; - } - default: - { + + case LDB_REPLY_DONE: + talloc_free(ares); - ldb_set_errstring(ldb, "Unexpected result type in base search for password entry!"); - return LDB_ERR_OPERATIONS_ERROR; - } + + /* if this entry was not returned yet, return it now */ + if (lr->remote) { + ret = ldb_module_send_entry(ac->req, ac->remote->message); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + lr->remote = NULL; + } + + if (lr->next->remote->type == LDB_REPLY_DONE) { + /* this was the last one */ + return ldb_module_done(ac->req, + lr->next->remote->controls, + lr->next->remote->response, + lr->next->remote->error); + } else { + /* next one */ + ac->current = lr->next; + talloc_free(lr); + + ret = lpdb_local_search(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + } } + + return LDB_SUCCESS; } /* For each entry returned in a remote search, do a local base search, * based on the objectGUID we asked for as an additional attribute */ -static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int lpdb_remote_search_callback(struct ldb_request *req, + struct ldb_reply *ares) { struct lpdb_context *ac; + struct ldb_dn *local_dn; + struct GUID objectGUID; + struct lpdb_reply *lr; + int ret; - ac = talloc_get_type(context, struct lpdb_context); + ac = talloc_get_type(req->context, struct lpdb_context); - if (ares->type == LDB_REPLY_ENTRY) { - struct ldb_request *req; - struct lpdb_local_search_context *local_context; - struct GUID objectGUID; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + switch (ares->type) { + case LDB_REPLY_ENTRY: /* No point searching further if it's not a 'person' entry */ if (!ldb_msg_check_string_attribute(ares->message, "objectClass", "person")) { @@ -538,13 +898,14 @@ static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, s ldb_msg_remove_attr(ares->message, "objectClass"); } - return ac->orig_req->callback(ldb, ac->orig_req->context, ares); + return ldb_module_send_entry(ac->req, ares->message); } if (ldb_msg_find_ldb_val(ares->message, "objectGUID") == NULL) { ldb_set_errstring(ac->module->ldb, "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } objectGUID = samdb_result_guid(ares->message, "objectGUID"); @@ -557,44 +918,63 @@ static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, s ldb_msg_remove_attr(ares->message, "objectClass"); } - req = talloc_zero(ac, struct ldb_request); - if (!req) { - return LDB_ERR_OPERATIONS_ERROR; + local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + if ((local_dn == NULL) || + (! ldb_dn_add_child_fmt(local_dn, + PASSWORD_GUID_ATTR "=%s", + GUID_string(ac, &objectGUID)))) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + lr = talloc_zero(ac, struct lpdb_reply); + if (lr == NULL) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } + lr->local_dn = talloc_steal(lr, local_dn); + lr->remote = talloc_steal(lr, ares); - local_context = talloc(ac, struct lpdb_local_search_context); - if (!local_context) { - return LDB_ERR_OPERATIONS_ERROR; + if (ac->list) { + ac->current->next = lr; + } else { + ac->list = lr; } - local_context->ac = ac; - local_context->remote_res = ares; - local_context->local_res = NULL; + ac->current= lr; + + break; - req->op.search.base = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); - if ( ! ldb_dn_add_child_fmt(req->op.search.base, PASSWORD_GUID_ATTR "=%s", GUID_string(ac, &objectGUID))) { - return LDB_ERR_OPERATIONS_ERROR; + case LDB_REPLY_REFERRAL: + + return ldb_module_send_referral(ac->req, ares->referral); + + case LDB_REPLY_DONE: + + if (ac->list == NULL) { + /* found nothing */ + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - req->operation = LDB_SEARCH; - req->op.search.scope = LDB_SCOPE_BASE; - req->op.search.tree = ldb_parse_tree(req, NULL); - if (req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, "Out of Memory"); - return LDB_ERR_OPERATIONS_ERROR; + + lr = talloc_zero(ac, struct lpdb_reply); + if (lr == NULL) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - req->op.search.attrs = ac->orig_req->op.search.attrs; - req->controls = NULL; - req->context = ac; - req->callback = get_self_callback; + lr->remote = talloc_steal(lr, ares); - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, req); - - req->context = local_context; - req->callback = lpdb_local_search_callback; + ac->current->next = lr; - return ldb_next_request(ac->module, req); - } else { - return ac->orig_req->callback(ldb, ac->orig_req->context, ares); + /* rewind current and start local searches */ + ac->current= ac->list; + + ret = lpdb_local_search(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } } + + return LDB_SUCCESS; } /* Search for passwords and other attributes. The passwords are @@ -603,7 +983,7 @@ static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, s static int local_password_search(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; + struct ldb_request *remote_req; struct lpdb_context *ac; int i; int ret; @@ -615,6 +995,8 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * return ldb_next_request(module, req); } + search_attrs = NULL; + /* If the caller is searching for the local passwords directly, let them pass */ if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), req->op.search.base) == 0) { @@ -634,32 +1016,15 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * } } - h = lpdb_init_handle(req, module, LPDB_SEARCH); - if (!h) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ac = talloc_get_type(h->private_data, struct lpdb_context); - - ac->orig_req = req; - - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { + ac = lpdb_init_context(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } /* Remote search is for all attributes: if the remote LDAP server has these attributes, then it overrides the local database */ - *(ac->remote_req) = *(ac->orig_req); - - /* Return our own handle do deal with this call */ - ac->remote_req->handle = h; - - ac->remote_req->context = ac; - ac->remote_req->callback = lpdb_remote_search_callback; - if (req->op.search.attrs && !ldb_attr_in_list(req->op.search.attrs, "*")) { if (!ldb_attr_in_list(req->op.search.attrs, "objectGUID")) { - search_attrs = ldb_attr_list_copy_add(req, req->op.search.attrs, "objectGUID"); + search_attrs = ldb_attr_list_copy_add(ac, req->op.search.attrs, "objectGUID"); ac->added_objectGUID = true; if (!search_attrs) { return LDB_ERR_OPERATIONS_ERROR; @@ -668,7 +1033,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = req->op.search.attrs; } if (!ldb_attr_in_list(search_attrs, "objectClass")) { - search_attrs = ldb_attr_list_copy_add(req, search_attrs, "objectClass"); + search_attrs = ldb_attr_list_copy_add(ac, search_attrs, "objectClass"); ac->added_objectClass = true; if (!search_attrs) { return LDB_ERR_OPERATIONS_ERROR; @@ -678,175 +1043,26 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = req->op.search.attrs; } - ac->remote_req->op.search.attrs = search_attrs; - - ldb_set_timeout_from_prev_req(module->ldb, ac->orig_req, ac->remote_req); - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = LPDB_SEARCH_REMOTE; - - /* perform the search */ - ret = ldb_next_request(module, ac->remote_req); - - if (ret == LDB_SUCCESS) { - req->handle = ac->remote_req->handle; - } - - return ret; -} - -static int lpdb_wait(struct ldb_handle *handle) { - struct lpdb_context *ac; - int ret; - - if (!handle || !handle->private_data) { + ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + search_attrs, + req->controls, + ac, lpdb_remote_search_callback, + req); + if (ret != LDB_SUCCESS) { return LDB_ERR_OPERATIONS_ERROR; } - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct lpdb_context); - - switch (ac->step) { - case LPDB_ADD_REMOTE: - ret = ldb_wait(ac->remote_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->remote_req->handle->status != LDB_SUCCESS) { - handle->status = ac->remote_req->handle->status; - goto done; - } - - if (ac->remote_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* original request done, go on */ - return local_password_add_local(handle); - - case LPDB_MOD_REMOTE: - ret = ldb_wait(ac->remote_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->remote_req->handle->status != LDB_SUCCESS) { - handle->status = ac->remote_req->handle->status; - goto done; - } - - if (ac->remote_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* original request done, go on */ - return local_password_mod_search_self(handle); - - case LPDB_MOD_SEARCH_SELF: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS) { - handle->status = ac->search_req->handle->status; - goto done; - } - - if (ac->search_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* original request done, go on */ - return local_password_mod_local(handle); - - case LPDB_LOCAL: - ret = ldb_wait(ac->local_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->local_req->handle->status != LDB_SUCCESS) { - handle->status = ac->local_req->handle->status; - goto done; - } - - if (ac->local_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - case LPDB_SEARCH_REMOTE: - ret = ldb_wait(ac->remote_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->remote_req->handle->status != LDB_SUCCESS) { - handle->status = ac->remote_req->handle->status; - goto done; - } - - if (ac->remote_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - default: - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; - } - - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - -static int lpdb_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = lpdb_wait(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; -} - -static int local_password_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return lpdb_wait_all(handle); - } else { - return lpdb_wait(handle); - } + /* perform the search */ + return ldb_next_request(module, remote_req); } _PUBLIC_ const struct ldb_module_ops ldb_local_password_module_ops = { .name = "local_password", .add = local_password_add, .modify = local_password_modify, - .search = local_password_search, - .wait = local_password_wait + .del = local_password_delete, + .search = local_password_search }; diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c index 084540f68d..d90c2547a6 100644 --- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c @@ -29,7 +29,7 @@ #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" static int naming_fsmo_init(struct ldb_module *module) { @@ -64,10 +64,9 @@ static int naming_fsmo_init(struct ldb_module *module) } module->private_data = naming_fsmo; - ret = ldb_search(module->ldb, naming_dn, - LDB_SCOPE_BASE, - NULL, naming_attrs, - &naming_res); + ret = ldb_search(module->ldb, mem_ctx, &naming_res, + naming_dn, LDB_SCOPE_BASE, + naming_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { ldb_debug(module->ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)\n"); @@ -81,7 +80,6 @@ static int naming_fsmo_init(struct ldb_module *module) talloc_free(mem_ctx); return ret; } - talloc_steal(mem_ctx, naming_res); if (naming_res->count == 0) { ldb_debug(module->ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no cross-ref container present: (skip loading of naming contexts details)\n"); diff --git a/source4/dsdb/samdb/ldb_modules/normalise.c b/source4/dsdb/samdb/ldb_modules/normalise.c index 3306fd3c33..70513bd644 100644 --- a/source4/dsdb/samdb/ldb_modules/normalise.c +++ b/source4/dsdb/samdb/ldb_modules/normalise.c @@ -45,6 +45,14 @@ CN=Admins,CN=Users,DC=samba,DC=example,DC=com */ + +struct norm_context { + struct ldb_module *module; + struct ldb_request *req; + + const struct dsdb_schema *schema; +}; + static int fix_dn(struct ldb_dn *dn) { int i, ret; @@ -69,93 +77,117 @@ static int fix_dn(struct ldb_dn *dn) return LDB_SUCCESS; } -static int normalise_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int normalize_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - const struct dsdb_schema *schema = dsdb_get_schema(ldb); - struct ldb_request *orig_req = talloc_get_type(context, struct ldb_request); - TALLOC_CTX *mem_ctx; + struct ldb_message *msg; + struct norm_context *ac; int i, j, ret; - /* Only entries are interesting, and we handle the case of the parent seperatly */ - if (ares->type != LDB_REPLY_ENTRY) { - return orig_req->callback(ldb, orig_req->context, ares); - } + ac = talloc_get_type(req->context, struct norm_context); - if (!schema) { - return orig_req->callback(ldb, orig_req->context, ares); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - - mem_ctx = talloc_new(ares); - if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - /* OK, we have one of *many* search results passing by here, - * but we should get them one at a time */ + /* Only entries are interesting, and we handle the case of the parent seperatly */ - ret = fix_dn(ares->message->dn); - if (ret != LDB_SUCCESS) { - talloc_free(mem_ctx); - return ret; - } + switch (ares->type) { + case LDB_REPLY_ENTRY: - for (i = 0; i < ares->message->num_elements; i++) { - const struct dsdb_attribute *attribute = dsdb_attribute_by_lDAPDisplayName(schema, ares->message->elements[i].name); - if (!attribute) { - continue; - } - /* Look to see if this attributeSyntax is a DN */ - if (!((strcmp(attribute->attributeSyntax_oid, "2.5.5.1") == 0) || - (strcmp(attribute->attributeSyntax_oid, "2.5.5.7") == 0))) { - continue; + /* OK, we have one of *many* search results passing by here, + * but we should get them one at a time */ + msg = ares->message; + + ret = fix_dn(msg->dn); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); } - for (j = 0; j < ares->message->elements[i].num_values; j++) { - const char *dn_str; - struct ldb_dn *dn = ldb_dn_from_ldb_val(mem_ctx, ldb, &ares->message->elements[i].values[j]); - if (!dn) { - talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + + for (i = 0; i < msg->num_elements; i++) { + const struct dsdb_attribute *attribute = dsdb_attribute_by_lDAPDisplayName(ac->schema, msg->elements[i].name); + if (!attribute) { + continue; } - ret = fix_dn(dn); - if (ret != LDB_SUCCESS) { - talloc_free(mem_ctx); - return ret; + /* Look to see if this attributeSyntax is a DN */ + if (!((strcmp(attribute->attributeSyntax_oid, "2.5.5.1") == 0) || + (strcmp(attribute->attributeSyntax_oid, "2.5.5.7") == 0))) { + continue; + } + for (j = 0; j < msg->elements[i].num_values; j++) { + const char *dn_str; + struct ldb_dn *dn = ldb_dn_new(ac, ac->module->ldb, (const char *)msg->elements[i].values[j].data); + if (!dn) { + return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); + } + ret = fix_dn(dn); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + dn_str = talloc_steal(msg->elements[i].values, ldb_dn_get_linearized(dn)); + msg->elements[i].values[j] = data_blob_string_const(dn_str); + talloc_free(dn); } - dn_str = talloc_steal(ares->message->elements[i].values, ldb_dn_get_linearized(dn)); - ares->message->elements[i].values[j] = data_blob_string_const(dn_str); - talloc_free(dn); } + + return ldb_module_send_entry(ac->req, msg); + + case LDB_REPLY_REFERRAL: + + return ldb_module_send_referral(ac->req, ares->referral); + + case LDB_REPLY_DONE: + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - talloc_free(mem_ctx); - return orig_req->callback(ldb, orig_req->context, ares); + + return LDB_SUCCESS; } /* search */ static int normalise_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_request *down_req; + struct norm_context *ac; int ret; - struct ldb_request *down_req = talloc(req, struct ldb_request); - if (!down_req) { - ldb_oom(module->ldb); + + ac = talloc(req, struct norm_context); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - - *down_req = *req; - down_req->context = req; - down_req->callback = normalise_search_callback; - ret = ldb_next_request(module, down_req); + ac->module = module; + ac->req = req; - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + /* if schema not yet present just skip over */ + ac->schema = dsdb_get_schema(ac->module->ldb); + if (ac->schema == NULL) { + talloc_free(ac); + return ldb_next_request(module, req); } - return ret; + + ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + req->op.search.attrs, + req->controls, + ac, normalize_search_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + + return ldb_next_request(module, down_req); } + _PUBLIC_ const struct ldb_module_ops ldb_normalise_module_ops = { .name = "normalise", .search = normalise_search, diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index b048a8d8e1..7d00851792 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2006 + Copyright (C) Simo Sorce 2006-2008 Copyright (C) Andrew Bartlett 2005-2007 This program is free software; you can redistribute it and/or modify @@ -38,7 +38,7 @@ #include "ldb/include/ldb_errors.h" #include "ldb/include/ldb_private.h" #include "dsdb/samdb/samdb.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_security.h" #include "libcli/security/security.h" @@ -47,21 +47,12 @@ struct oc_context { - enum oc_step {OC_DO_REQ, OC_SEARCH_SELF, OC_DO_MOD, - OC_SEARCH_ADD_PARENT, OC_DO_ADD, - OC_SEARCH_RENAME_PARENT, OC_DO_RENAME} step; - struct ldb_module *module; - struct ldb_request *orig_req; - - struct ldb_request *down_req; + struct ldb_request *req; - struct ldb_request *search_req; struct ldb_reply *search_res; - struct ldb_request *add_req; - struct ldb_request *mod_req; - struct ldb_request *rename_req; + int (*step_fn)(struct oc_context *); }; struct class_list { @@ -69,46 +60,31 @@ struct class_list { const struct dsdb_class *objectclass; }; -static int objectclass_do_add(struct ldb_handle *h); - -static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_module *module) +static struct oc_context *oc_init_context(struct ldb_module *module, + struct ldb_request *req) { struct oc_context *ac; - struct ldb_handle *h; - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - - ac = talloc_zero(h, struct oc_context); + ac = talloc_zero(req, struct oc_context); if (ac == NULL) { ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); return NULL; } - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - ac->module = module; - ac->orig_req = req; + ac->req = req; - return h; + return ac; } +static int objectclass_do_add(struct oc_context *ac); + /* Sort objectClasses into correct order, and validate that all * objectClasses specified actually exist in the schema */ static int objectclass_sort(struct ldb_module *module, const struct dsdb_schema *schema, - struct ldb_message *msg, /* so that when we create new elements, we put it on the right parent */ TALLOC_CTX *mem_ctx, struct ldb_message_element *objectclass_element, struct class_list **sorted_out) @@ -117,6 +93,7 @@ static int objectclass_sort(struct ldb_module *module, int layer; struct class_list *sorted = NULL, *parent_class = NULL, *subclass = NULL, *unsorted = NULL, *current, *poss_subclass, *poss_parent, *new_parent; + /* DESIGN: * * We work on 4 different 'bins' (implemented here as linked lists): @@ -150,8 +127,7 @@ static int objectclass_sort(struct ldb_module *module, for (i=0; i < objectclass_element->num_values; i++) { current = talloc(mem_ctx, struct class_list); if (!current) { - ldb_set_errstring(module->ldb, "objectclass: out of memory allocating objectclass list"); - talloc_free(mem_ctx); + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } current->objectclass = dsdb_class_by_lDAPDisplayName(schema, (const char *)objectclass_element->values[i].data); @@ -258,7 +234,7 @@ static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, struct auth_session_info *session_info = ldb_get_opaque(module->ldb, "sessionInfo"); struct security_descriptor *sd; - struct dom_sid *domain_sid = samdb_domain_sid(module->ldb); + const struct dom_sid *domain_sid = samdb_domain_sid(module->ldb); if (!objectclass->defaultSecurityDescriptor || !domain_sid) { return NULL; @@ -292,28 +268,77 @@ static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, } -static int get_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int get_search_callback(struct ldb_request *req, struct ldb_reply *ares) { struct oc_context *ac; + int ret; - ac = talloc_get_type(context, struct oc_context); + ac = talloc_get_type(req->context, struct oc_context); - /* we are interested only in the single reply (base search) we receive here */ - if (ares->type == LDB_REPLY_ENTRY) { + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS && + ares->error != LDB_ERR_NO_SUCH_OBJECT) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: if (ac->search_res != NULL) { - ldb_set_errstring(ldb, "Too many results"); + ldb_set_errstring(ac->module->ldb, "Too many results"); talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ac->search_res = talloc_move(ac, &ares); - } else { + ac->search_res = talloc_steal(ac, ares); + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: talloc_free(ares); + ret = ac->step_fn(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + break; } return LDB_SUCCESS; } +static int oc_op_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct oc_context *ac; + + ac = talloc_get_type(req->context, struct oc_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); +} + /* Fix up the DN to be in the standard form, taking particular care to match the parent DN This should mean that if the parent is: @@ -357,22 +382,27 @@ static int fix_attributes(struct ldb_context *ldb, const struct dsdb_schema *sch int i; for (i=0; i < msg->num_elements; i++) { const struct dsdb_attribute *attribute = dsdb_attribute_by_lDAPDisplayName(schema, msg->elements[i].name); + /* Add in a very special case for 'clearTextPassword', + * which is used for internal processing only, and is + * not presented in the schema */ if (!attribute) { - ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", msg->elements[i].name); - return LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE; + if (strcasecmp(msg->elements[i].name, "clearTextPassword") != 0) { + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", msg->elements[i].name); + return LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE; + } + } else { + msg->elements[i].name = attribute->lDAPDisplayName; } - msg->elements[i].name = attribute->lDAPDisplayName; } return LDB_SUCCESS; } +static int objectclass_do_add(struct oc_context *ac); + static int objectclass_add(struct ldb_module *module, struct ldb_request *req) { - - static const char * const attrs[] = { NULL }; - - struct ldb_handle *h; + struct ldb_request *search_req; struct oc_context *ac; struct ldb_dn *parent_dn; int ret; @@ -384,61 +414,56 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - /* Need to object to this, but cn=rootdse doesn't hae an objectClass... */ + /* Need to object to this, but cn=rootdse doesn't have an objectClass... */ if (ldb_msg_find_element(req->op.add.message, "objectClass") == NULL) { return ldb_next_request(module, req); } - h = oc_init_handle(req, module); - if (!h) { + ac = oc_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct oc_context); - - /* return or own handle to deal with this call */ - req->handle = h; /* If there isn't a parent, just go on to the add processing */ - if (ldb_dn_get_comp_num(ac->orig_req->op.add.message->dn) == 1) { - return objectclass_do_add(h); + if (ldb_dn_get_comp_num(ac->req->op.add.message->dn) == 1) { + return objectclass_do_add(ac); } - parent_dn = ldb_dn_get_parent(ac, ac->orig_req->op.add.message->dn); + /* get copy of parent DN */ + parent_dn = ldb_dn_get_parent(ac, ac->req->op.add.message->dn); if (parent_dn == NULL) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&ac->search_req, module->ldb, + ret = ldb_build_search_req(&search_req, module->ldb, ac, parent_dn, LDB_SCOPE_BASE, - "(objectClass=*)", - attrs, NULL, - ac, get_search_callback); + "(objectClass=*)", NULL, + NULL, + ac, get_search_callback, + req); if (ret != LDB_SUCCESS) { return ret; } + talloc_steal(search_req, parent_dn); - talloc_steal(ac->search_req, parent_dn); - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->search_req); - - ac->step = OC_SEARCH_ADD_PARENT; + ac->step_fn = objectclass_do_add; - return ldb_next_request(ac->module, ac->search_req); + return ldb_next_request(ac->module, search_req); } -static int objectclass_do_add(struct ldb_handle *h) +static int objectclass_do_add(struct oc_context *ac) { const struct dsdb_schema *schema; - struct oc_context *ac; + struct ldb_request *add_req; + char *value; struct ldb_message_element *objectclass_element; struct ldb_message *msg; TALLOC_CTX *mem_ctx; struct class_list *sorted, *current; int ret; - - ac = talloc_get_type(h->private_data, struct oc_context); + schema = dsdb_get_schema(ac->module->ldb); mem_ctx = talloc_new(ac); @@ -446,41 +471,34 @@ static int objectclass_do_add(struct ldb_handle *h) return LDB_ERR_OPERATIONS_ERROR; } - ac->add_req = talloc(ac, struct ldb_request); - if (ac->add_req == NULL) { - talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; - } - - *ac->add_req = *ac->orig_req; + msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message); - ac->add_req->op.add.message = msg = ldb_msg_copy_shallow(ac->add_req, ac->orig_req->op.add.message); - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->add_req); - /* Check we have a valid parent */ if (ac->search_res == NULL) { - if (ldb_dn_compare(ldb_get_root_basedn(ac->module->ldb), ac->orig_req->op.add.message->dn) == 0) { + if (ldb_dn_compare(ldb_get_root_basedn(ac->module->ldb), + msg->dn) == 0) { /* Allow the tree to be started */ /* but don't keep any error string, it's meaningless */ ldb_set_errstring(ac->module->ldb, NULL); } else { ldb_asprintf_errstring(ac->module->ldb, "objectclass: Cannot add %s, parent does not exist!", - ldb_dn_get_linearized(ac->orig_req->op.add.message->dn)); + ldb_dn_get_linearized(msg->dn)); + talloc_free(mem_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; } } else { /* Fix up the DN to be in the standard form, taking particular care to match the parent DN */ ret = fix_dn(msg, - ac->orig_req->op.add.message->dn, + ac->req->op.add.message->dn, ac->search_res->message->dn, &msg->dn); if (ret != LDB_SUCCESS) { ldb_asprintf_errstring(ac->module->ldb, "Could not munge DN %s into normal form", - ldb_dn_get_linearized(ac->orig_req->op.add.message->dn)); + ldb_dn_get_linearized(ac->req->op.add.message->dn)); + talloc_free(mem_ctx); return ret; } @@ -505,7 +523,7 @@ static int objectclass_do_add(struct ldb_handle *h) talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } - ret = objectclass_sort(ac->module, schema, msg, mem_ctx, objectclass_element, &sorted); + ret = objectclass_sort(ac->module, schema, mem_ctx, objectclass_element, &sorted); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; @@ -524,7 +542,13 @@ static int objectclass_do_add(struct ldb_handle *h) /* Move from the linked list back into an ldb msg */ for (current = sorted; current; current = current->next) { - ret = ldb_msg_add_string(msg, "objectClass", current->objectclass->lDAPDisplayName); + value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); + if (value == NULL) { + ldb_oom(ac->module->ldb); + talloc_free(mem_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted " @@ -537,8 +561,13 @@ static int objectclass_do_add(struct ldb_handle *h) struct ldb_message_element *el; int32_t systemFlags = 0; if (!ldb_msg_find_element(msg, "objectCategory")) { - ldb_msg_add_string(msg, "objectCategory", - current->objectclass->defaultObjectCategory); + value = talloc_strdup(msg, current->objectclass->defaultObjectCategory); + if (value == NULL) { + ldb_oom(ac->module->ldb); + talloc_free(mem_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + ldb_msg_add_string(msg, "objectCategory", value); } if (!ldb_msg_find_element(msg, "showInAdvancedViewOnly") && (current->objectclass->defaultHidingValue == true)) { ldb_msg_add_string(msg, "showInAdvancedViewOnly", @@ -597,20 +626,33 @@ static int objectclass_do_add(struct ldb_handle *h) return ret; } - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = OC_DO_ADD; + ret = ldb_build_add_req(&add_req, ac->module->ldb, ac, + msg, + ac->req->controls, + ac, oc_op_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; + } /* perform the add */ - return ldb_next_request(ac->module, ac->add_req); + return ldb_next_request(ac->module, add_req); } +static int oc_modify_callback(struct ldb_request *req, + struct ldb_reply *ares); +static int objectclass_do_mod(struct oc_context *ac); + static int objectclass_modify(struct ldb_module *module, struct ldb_request *req) { struct ldb_message_element *objectclass_element; struct ldb_message *msg; const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + struct class_list *sorted, *current; + struct ldb_request *down_req; + struct oc_context *ac; + TALLOC_CTX *mem_ctx; + char *value; int ret; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_modify\n"); @@ -626,23 +668,19 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req } objectclass_element = ldb_msg_find_element(req->op.mod.message, "objectClass"); + ac = oc_init_context(module, req); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + /* If no part of this touches the objectClass, then we don't * need to make any changes. */ /* If the only operation is the deletion of the objectClass * then go on with just fixing the attribute case */ if (!objectclass_element) { - struct ldb_request *down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { - ldb_set_errstring(module->ldb, "Out of memory!"); - return LDB_ERR_OPERATIONS_ERROR; - } - - *down_req = *req; /* copy the request */ - - down_req->op.mod.message = msg = ldb_msg_copy_shallow(down_req, req->op.mod.message); - - if (down_req->op.mod.message == NULL) { + msg = ldb_msg_copy_shallow(ac, req->op.mod.message); + if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -651,15 +689,17 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req return ret; } - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, oc_op_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; + + /* go on with the call chain */ + return ldb_next_request(module, down_req); } switch (objectclass_element->flags & LDB_FLAG_MOD_MASK) { @@ -668,41 +708,28 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED; } break; + case LDB_FLAG_MOD_REPLACE: - { - struct ldb_request *down_req; - struct class_list *sorted, *current; - TALLOC_CTX *mem_ctx; - mem_ctx = talloc_new(req); + mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - /* prepare the first operation */ - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { - ldb_set_errstring(module->ldb, "Out of memory!"); - talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; - } - - *down_req = *req; /* copy the request */ - - down_req->op.mod.message = msg = ldb_msg_copy_shallow(down_req, req->op.mod.message); - - if (down_req->op.mod.message == NULL) { + msg = ldb_msg_copy_shallow(ac, req->op.mod.message); + if (msg == NULL) { talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } - + ret = fix_attributes(module->ldb, schema, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; } - ret = objectclass_sort(module, schema, msg, mem_ctx, objectclass_element, &sorted); + ret = objectclass_sort(module, schema, mem_ctx, objectclass_element, &sorted); if (ret != LDB_SUCCESS) { + talloc_free(mem_ctx); return ret; } @@ -719,9 +746,21 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req /* Move from the linked list back into an ldb msg */ for (current = sorted; current; current = current->next) { - ret = ldb_msg_add_string(msg, "objectClass", current->objectclass->lDAPDisplayName); + /* copy the value as this string is on the schema + * context and we can't rely on it not changing + * before the operation is over */ + value = talloc_strdup(msg, + current->objectclass->lDAPDisplayName); + if (value == NULL) { + ldb_oom(module->ldb); + talloc_free(mem_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); + ldb_set_errstring(module->ldb, + "objectclass: could not re-add sorted " + "objectclass to modify msg"); talloc_free(mem_ctx); return ret; } @@ -731,130 +770,121 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req ret = ldb_msg_sanity_check(module->ldb, msg); if (ret != LDB_SUCCESS) { - talloc_free(mem_ctx); return ret; } - - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, oc_op_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; - } + + /* go on with the call chain */ + return ldb_next_request(module, down_req); } /* This isn't the default branch of the switch, but a 'in any * other case'. When a delete isn't for all objectClasses for * example */ - { - struct ldb_handle *h; - struct oc_context *ac; - - h = oc_init_handle(req, module); - if (!h) { - return LDB_ERR_OPERATIONS_ERROR; - } - ac = talloc_get_type(h->private_data, struct oc_context); - - /* return or own handle to deal with this call */ - req->handle = h; - - /* prepare the first operation */ - ac->down_req = talloc(ac, struct ldb_request); - if (ac->down_req == NULL) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->down_req) = *req; /* copy the request */ - - ac->down_req->op.mod.message = msg = ldb_msg_copy_shallow(ac->down_req, req->op.mod.message); - - if (ac->down_req->op.mod.message == NULL) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - ret = fix_attributes(ac->module->ldb, schema, msg); - if (ret != LDB_SUCCESS) { - ldb_oom(ac->module->ldb); - return ret; - } - ac->down_req->context = NULL; - ac->down_req->callback = NULL; - ldb_set_timeout_from_prev_req(module->ldb, req, ac->down_req); - - ac->step = OC_DO_REQ; + msg = ldb_msg_copy_shallow(ac, req->op.mod.message); + if (msg == NULL) { + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } - return ldb_next_request(module, ac->down_req); + ret = fix_attributes(module->ldb, schema, msg); + if (ret != LDB_SUCCESS) { + ldb_oom(ac->module->ldb); + return ret; } + + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, oc_modify_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; + } + + return ldb_next_request(module, down_req); } -static int objectclass_search_self(struct ldb_handle *h) +static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { - int ret; - struct oc_context *ac; static const char * const attrs[] = { "objectClass", NULL }; + struct ldb_request *search_req; + struct oc_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct oc_context); - ac = talloc_get_type(h->private_data, struct oc_context); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ret = ldb_build_search_req(&ac->search_req, ac->module->ldb, - ac, ac->orig_req->op.mod.message->dn, LDB_SCOPE_BASE, + if (ares->type != LDB_REPLY_DONE) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, - ac, get_search_callback); - + ac, get_search_callback, + ac->req); if (ret != LDB_SUCCESS) { - return ret; + return ldb_module_done(ac->req, NULL, NULL, ret); } - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->search_req); + ac->step_fn = objectclass_do_mod; - ac->step = OC_SEARCH_SELF; - - return ldb_next_request(ac->module, ac->search_req); + ret = ldb_next_request(ac->module, search_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + return LDB_SUCCESS; } -static int objectclass_do_mod(struct ldb_handle *h) { +static int objectclass_do_mod(struct oc_context *ac) +{ const struct dsdb_schema *schema; - struct oc_context *ac; + struct ldb_request *mod_req; + char *value; struct ldb_message_element *objectclass_element; struct ldb_message *msg; TALLOC_CTX *mem_ctx; struct class_list *sorted, *current; int ret; - - ac = talloc_get_type(h->private_data, struct oc_context); - schema = dsdb_get_schema(ac->module->ldb); - mem_ctx = talloc_new(ac); - if (mem_ctx == NULL) { + if (ac->search_res == NULL) { return LDB_ERR_OPERATIONS_ERROR; } + schema = dsdb_get_schema(ac->module->ldb); - ac->mod_req = talloc(ac, struct ldb_request); - if (ac->mod_req == NULL) { - talloc_free(mem_ctx); + mem_ctx = talloc_new(ac); + if (mem_ctx == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac->mod_req->operation = LDB_MODIFY; - ac->mod_req->controls = NULL; - ac->mod_req->context = ac; - ac->mod_req->callback = NULL; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->mod_req); - /* use a new message structure */ - ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req); + msg = ldb_msg_new(ac); if (msg == NULL) { - ldb_set_errstring(ac->module->ldb, "objectclass: could not create new modify msg"); + ldb_set_errstring(ac->module->ldb, + "objectclass: could not create new modify msg"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -869,9 +899,9 @@ static int objectclass_do_mod(struct ldb_handle *h) { } /* modify dn */ - msg->dn = ac->orig_req->op.mod.message->dn; + msg->dn = ac->req->op.mod.message->dn; - ret = objectclass_sort(ac->module, schema, msg, mem_ctx, objectclass_element, &sorted); + ret = objectclass_sort(ac->module, schema, mem_ctx, objectclass_element, &sorted); if (ret != LDB_SUCCESS) { return ret; } @@ -889,7 +919,12 @@ static int objectclass_do_mod(struct ldb_handle *h) { /* Move from the linked list back into an ldb msg */ for (current = sorted; current; current = current->next) { - ret = ldb_msg_add_string(msg, "objectClass", current->objectclass->lDAPDisplayName); + value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); + if (value == NULL) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); talloc_free(mem_ctx); @@ -903,33 +938,38 @@ static int objectclass_do_mod(struct ldb_handle *h) { return ret; } - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = OC_DO_MOD; + ret = ldb_build_mod_req(&mod_req, ac->module->ldb, ac, + msg, + ac->req->controls, + ac, oc_op_callback, + ac->req); + if (ret != LDB_SUCCESS) { + talloc_free(mem_ctx); + return ret; + } talloc_free(mem_ctx); - /* perform the search */ - return ldb_next_request(ac->module, ac->mod_req); + /* perform the modify */ + return ldb_next_request(ac->module, mod_req); } +static int objectclass_do_rename(struct oc_context *ac); + static int objectclass_rename(struct ldb_module *module, struct ldb_request *req) { - static const char * const attrs[] = { NULL }; - struct ldb_handle *h; + struct ldb_request *search_req; struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_rename\n"); if (ldb_dn_is_special(req->op.rename.newdn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } - + /* Firstly ensure we are not trying to rename it to be a child of itself */ if ((ldb_dn_compare_base(req->op.rename.olddn, req->op.rename.newdn) == 0) && (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) != 0)) { @@ -938,65 +978,50 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req return LDB_ERR_UNWILLING_TO_PERFORM; } - h = oc_init_handle(req, module); - if (!h) { + ac = oc_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct oc_context); - - /* return or own handle to deal with this call */ - req->handle = h; - parent_dn = ldb_dn_get_parent(ac, ac->orig_req->op.rename.newdn); + parent_dn = ldb_dn_get_parent(ac, req->op.rename.newdn); if (parent_dn == NULL) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&ac->search_req, module->ldb, + ret = ldb_build_search_req(&search_req, module->ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, - ac, get_search_callback); + ac, get_search_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - talloc_steal(ac->search_req, parent_dn); - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->search_req); - ac->step = OC_SEARCH_RENAME_PARENT; + ac->step_fn = objectclass_do_rename; - return ldb_next_request(ac->module, ac->search_req); + return ldb_next_request(ac->module, search_req); } -static int objectclass_do_rename(struct ldb_handle *h) +static int objectclass_do_rename(struct oc_context *ac) { - struct oc_context *ac; + struct ldb_request *rename_req; + struct ldb_dn *fixed_dn; int ret; - - ac = talloc_get_type(h->private_data, struct oc_context); - ac->rename_req = talloc(ac, struct ldb_request); - if (ac->rename_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *ac->rename_req = *ac->orig_req; - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->rename_req); - /* Check we have a valid parent */ if (ac->search_res == NULL) { ldb_asprintf_errstring(ac->module->ldb, "objectclass: Cannot rename %s, parent does not exist!", - ldb_dn_get_linearized(ac->orig_req->op.rename.newdn)); + ldb_dn_get_linearized(ac->req->op.rename.newdn)); return LDB_ERR_UNWILLING_TO_PERFORM; } - /* Fix up the DN to be in the standard form, taking particular care to match the parent DN */ - ret = fix_dn(ac->rename_req, - ac->orig_req->op.rename.newdn, - ac->search_res->message->dn, - &ac->rename_req->op.rename.newdn); - + /* Fix up the DN to be in the standard form, + * taking particular care to match the parent DN */ + ret = fix_dn(ac, + ac->req->op.rename.newdn, + ac->search_res->message->dn, + &fixed_dn); if (ret != LDB_SUCCESS) { return ret; } @@ -1005,197 +1030,17 @@ static int objectclass_do_rename(struct ldb_handle *h) * by reading the allowedChildClasses and * allowedChildClasssesEffective attributes */ - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = OC_DO_RENAME; - - /* perform the rename */ - return ldb_next_request(ac->module, ac->rename_req); -} - -static int oc_wait(struct ldb_handle *handle) { - struct oc_context *ac; - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct oc_context); - - switch (ac->step) { - case OC_DO_REQ: - ret = ldb_wait(ac->down_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req->handle->status; - goto done; - } - - if (ac->down_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* mods done, go on */ - return objectclass_search_self(handle); - - case OC_SEARCH_SELF: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS) { - handle->status = ac->search_req->handle->status; - goto done; - } - - if (ac->search_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* self search done, go on */ - return objectclass_do_mod(handle); - - case OC_DO_MOD: - ret = ldb_wait(ac->mod_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->mod_req->handle->status != LDB_SUCCESS) { - handle->status = ac->mod_req->handle->status; - goto done; - } - - if (ac->mod_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - case OC_SEARCH_ADD_PARENT: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS - && ac->search_req->handle->status != LDB_ERR_NO_SUCH_OBJECT) { - handle->status = ac->search_req->handle->status; - goto done; - } - - if (ac->search_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* parent search done, go on */ - return objectclass_do_add(handle); - - case OC_DO_ADD: - ret = ldb_wait(ac->add_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->add_req->handle->status != LDB_SUCCESS) { - handle->status = ac->add_req->handle->status; - goto done; - } - - if (ac->add_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - case OC_SEARCH_RENAME_PARENT: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS && ac->search_req->handle->status != LDB_ERR_NO_SUCH_OBJECT) { - handle->status = ac->search_req->handle->status; - goto done; - } - - if (ac->search_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* parent search done, go on */ - return objectclass_do_rename(handle); - - case OC_DO_RENAME: - ret = ldb_wait(ac->rename_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->rename_req->handle->status != LDB_SUCCESS) { - handle->status = ac->rename_req->handle->status; - goto done; - } - - if (ac->rename_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - default: - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; - } - - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - -static int oc_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = oc_wait(handle); - if (ret != LDB_SUCCESS) { - return ret; - } + ret = ldb_build_rename_req(&rename_req, ac->module->ldb, ac, + ac->req->op.rename.olddn, fixed_dn, + ac->req->controls, + ac, oc_op_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; } - return handle->status; -} - -static int objectclass_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return oc_wait_all(handle); - } else { - return oc_wait(handle); - } + /* perform the rename */ + return ldb_next_request(ac->module, rename_req); } _PUBLIC_ const struct ldb_module_ops ldb_objectclass_module_ops = { @@ -1203,5 +1048,4 @@ _PUBLIC_ const struct ldb_module_ops ldb_objectclass_module_ops = { .add = objectclass_add, .modify = objectclass_modify, .rename = objectclass_rename, - .wait = objectclass_wait }; diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index f62839389d..3d725686e7 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -1,9 +1,9 @@ /* ldb database library - Copyright (C) Simo Sorce 2004-2006 Copyright (C) Andrew Bartlett 2005 Copyright (C) Andrew Tridgell 2005 + Copyright (C) Simo Sorce 2004-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -103,6 +103,36 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ return 0; } +struct og_context { + struct ldb_module *module; + struct ldb_request *req; +}; + +static int og_op_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct og_context *ac; + + ac = talloc_get_type(req->context, struct og_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); +} + /* add_record: add objectGUID attribute */ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) { @@ -115,6 +145,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) enum ndr_err_code ndr_err; int ret; time_t t = time(NULL); + struct og_context *ac; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); @@ -127,15 +158,15 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { + ac = talloc(req, struct og_context); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - - *down_req = *req; + ac->module = module; + ac->req = req; /* we have to copy the message as the caller might have it as a const */ - down_req->op.add.message = msg = ldb_msg_copy_shallow(down_req, req->op.add.message); + msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; @@ -149,44 +180,41 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) &guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_value(msg, "objectGUID", &v, NULL); if (ret) { - talloc_free(down_req); return ret; } if (add_time_element(msg, "whenCreated", t) != 0 || add_time_element(msg, "whenChanged", t) != 0) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } /* Get a sequence number from the backend */ + /* FIXME: ldb_sequence_number is a semi-async call, + * make sure this function is split and a callback is used */ ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 || add_uint64_element(msg, "uSNChanged", seq_num) != 0) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } } - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_add_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, og_op_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - return ret; + /* go on with the call chain */ + return ldb_next_request(module, down_req); } /* modify_record: update timestamps */ @@ -197,6 +225,7 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) int ret; time_t t = time(NULL); uint64_t seq_num; + struct og_context *ac; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); @@ -205,22 +234,20 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { + ac = talloc(req, struct og_context); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - - *down_req = *req; + ac->module = module; + ac->req = req; /* we have to copy the message as the caller might have it as a const */ - down_req->op.mod.message = msg = ldb_msg_copy_shallow(down_req, req->op.mod.message); + msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } if (add_time_element(msg, "whenChanged", t) != 0) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } @@ -228,23 +255,21 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } } - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, og_op_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - return ret; + /* go on with the call chain */ + return ldb_next_request(module, down_req); } _PUBLIC_ const struct ldb_module_ops ldb_objectguid_module_ops = { diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index 9cae6ab7b5..2a321e29c5 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -1,4 +1,3 @@ - /* Partitions ldb module @@ -43,61 +42,95 @@ struct partition_private_data { struct ldb_dn **replicate; }; +struct part_request { + struct ldb_module *module; + struct ldb_request *req; +}; + struct partition_context { struct ldb_module *module; - struct ldb_request *orig_req; + struct ldb_request *req; + bool got_success; - struct ldb_request **down_req; + struct part_request *part_req; int num_requests; int finished_requests; }; -static struct partition_context *partition_init_handle(struct ldb_request *req, struct ldb_module *module) +static struct partition_context *partition_init_ctx(struct ldb_module *module, struct ldb_request *req) { struct partition_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - ac = talloc_zero(h, struct partition_context); + ac = talloc_zero(req, struct partition_context); if (ac == NULL) { ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); return NULL; } - h->private_data = ac; - ac->module = module; - ac->orig_req = req; - - req->handle = h; + ac->req = req; return ac; } -static struct ldb_module *make_module_for_next_request(TALLOC_CTX *mem_ctx, - struct ldb_context *ldb, - struct ldb_module *module) +#define PARTITION_FIND_OP(module, op) do { \ + struct ldb_context *ldbctx = module->ldb; \ + while (module && module->ops->op == NULL) module = module->next; \ + if (module == NULL) { \ + ldb_asprintf_errstring(ldbctx, \ + "Unable to find backend operation for " #op ); \ + return LDB_ERR_OPERATIONS_ERROR; \ + } \ +} while (0) + +/* + * helper functions to call the next module in chain + * */ + +static int partition_request(struct ldb_module *module, struct ldb_request *request) { - struct ldb_module *current; - static const struct ldb_module_ops ops; /* zero */ - current = talloc_zero(mem_ctx, struct ldb_module); - if (current == NULL) { - return module; + int ret; + switch (request->operation) { + case LDB_SEARCH: + PARTITION_FIND_OP(module, search); + ret = module->ops->search(module, request); + break; + case LDB_ADD: + PARTITION_FIND_OP(module, add); + ret = module->ops->add(module, request); + break; + case LDB_MODIFY: + PARTITION_FIND_OP(module, modify); + ret = module->ops->modify(module, request); + break; + case LDB_DELETE: + PARTITION_FIND_OP(module, del); + ret = module->ops->del(module, request); + break; + case LDB_RENAME: + PARTITION_FIND_OP(module, rename); + ret = module->ops->rename(module, request); + break; + case LDB_EXTENDED: + PARTITION_FIND_OP(module, extended); + ret = module->ops->extended(module, request); + break; + default: + PARTITION_FIND_OP(module, request); + ret = module->ops->request(module, request); + break; } - - current->ldb = ldb; - current->ops = &ops; - current->prev = NULL; - current->next = module; - return current; + if (ret == LDB_SUCCESS) { + return ret; + } + if (!ldb_errstring(module->ldb)) { + /* Set a default error string, to place the blame somewhere */ + ldb_asprintf_errstring(module->ldb, + "error in module %s: %s (%d)", + module->ops->name, + ldb_strerror(ret), ret); + } + return ret; } static struct dsdb_control_current_partition *find_partition(struct partition_private_data *data, @@ -120,127 +153,206 @@ static struct dsdb_control_current_partition *find_partition(struct partition_pr /** * fire the caller's callback for every entry, but only send 'done' once. */ -static int partition_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int partition_req_callback(struct ldb_request *req, + struct ldb_reply *ares) { struct partition_context *ac; + struct ldb_module *module; + struct ldb_request *nreq; + int ret; - ac = talloc_get_type(context, struct partition_context); + ac = talloc_get_type(req->context, struct partition_context); - if (ares->type == LDB_REPLY_ENTRY) { - return ac->orig_req->callback(ldb, ac->orig_req->context, ares); - } else { - ac->finished_requests++; - if (ac->finished_requests == ac->num_requests) { - return ac->orig_req->callback(ldb, ac->orig_req->context, ares); - } else { - talloc_free(ares); - return LDB_SUCCESS; - } + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } -} -/** - * only fire the 'last' callback, and only for START-TLS for now - */ -static int partition_other_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) -{ - struct partition_context *ac; + if (ares->error != LDB_SUCCESS && !ac->got_success) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ac = talloc_get_type(context, struct partition_context); + switch (ares->type) { + case LDB_REPLY_REFERRAL: + /* ignore referrals for now */ + break; - if (!ac->orig_req->callback) { - talloc_free(ares); - return LDB_SUCCESS; - } + case LDB_REPLY_ENTRY: + if (ac->req->operation != LDB_SEARCH) { + ldb_set_errstring(ac->module->ldb, + "partition_req_callback:" + " Unsupported reply type for this request"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + return ldb_module_send_entry(ac->req, ares->message); + + case LDB_REPLY_DONE: + if (ares->error == LDB_SUCCESS) { + ac->got_success = true; + } + if (ac->req->operation == LDB_EXTENDED) { + /* FIXME: check for ares->response, replmd does not fill it ! */ + if (ares->response) { + if (strcmp(ares->response->oid, LDB_EXTENDED_START_TLS_OID) != 0) { + ldb_set_errstring(ac->module->ldb, + "partition_req_callback:" + " Unknown extended reply, " + "only supports START_TLS"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + } + } - if (!ares - || (ares->type == LDB_REPLY_EXTENDED - && strcmp(ares->response->oid, LDB_EXTENDED_START_TLS_OID))) { ac->finished_requests++; if (ac->finished_requests == ac->num_requests) { - return ac->orig_req->callback(ldb, ac->orig_req->context, ares); + /* this was the last one, call callback */ + return ldb_module_done(ac->req, ares->controls, + ares->response, + ac->got_success?LDB_SUCCESS:ares->error); + } + + /* not the last, now call the next one */ + module = ac->part_req[ac->finished_requests].module; + nreq = ac->part_req[ac->finished_requests].req; + + ret = partition_request(module, nreq); + if (ret != LDB_SUCCESS) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, ret); } - talloc_free(ares); - return LDB_SUCCESS; + + break; } - ldb_set_errstring(ldb, "partition_other_callback: Unknown reply type, only supports START_TLS"); + talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_SUCCESS; } - -static int partition_send_request(struct partition_context *ac, +static int partition_prep_request(struct partition_context *ac, struct dsdb_control_current_partition *partition) { int ret; - struct ldb_module *backend; struct ldb_request *req; - if (partition) { - backend = make_module_for_next_request(ac, ac->module->ldb, partition->module); - } else { - backend = ac->module; - } - - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { + ac->part_req = talloc_realloc(ac, ac->part_req, + struct part_request, + ac->num_requests + 1); + if (ac->part_req == NULL) { ldb_oom(ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - req = ac->down_req[ac->num_requests] = talloc(ac, struct ldb_request); - if (req == NULL) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + + switch (ac->req->operation) { + case LDB_SEARCH: + ret = ldb_build_search_req_ex(&req, ac->module->ldb, + ac->part_req, + ac->req->op.search.base, + ac->req->op.search.scope, + ac->req->op.search.tree, + ac->req->op.search.attrs, + ac->req->controls, + ac, partition_req_callback, + ac->req); + break; + case LDB_ADD: + ret = ldb_build_add_req(&req, ac->module->ldb, ac->part_req, + ac->req->op.add.message, + ac->req->controls, + ac, partition_req_callback, + ac->req); + break; + case LDB_MODIFY: + ret = ldb_build_mod_req(&req, ac->module->ldb, ac->part_req, + ac->req->op.mod.message, + ac->req->controls, + ac, partition_req_callback, + ac->req); + break; + case LDB_DELETE: + ret = ldb_build_del_req(&req, ac->module->ldb, ac->part_req, + ac->req->op.del.dn, + ac->req->controls, + ac, partition_req_callback, + ac->req); + break; + case LDB_RENAME: + ret = ldb_build_rename_req(&req, ac->module->ldb, ac->part_req, + ac->req->op.rename.olddn, + ac->req->op.rename.newdn, + ac->req->controls, + ac, partition_req_callback, + ac->req); + break; + case LDB_EXTENDED: + ret = ldb_build_extended_req(&req, ac->module->ldb, + ac->part_req, + ac->req->op.extended.oid, + ac->req->op.extended.data, + ac->req->controls, + ac, partition_req_callback, + ac->req); + break; + default: + ldb_set_errstring(ac->module->ldb, + "Unsupported request type!"); + ret = LDB_ERR_UNWILLING_TO_PERFORM; } - - *req = *ac->orig_req; /* copy the request */ - if (req->controls) { - req->controls - = talloc_memdup(req, - ac->orig_req->controls, talloc_get_size(ac->orig_req->controls)); + if (ret != LDB_SUCCESS) { + return ret; + } + + ac->part_req[ac->num_requests].req = req; + + if (ac->req->controls) { + req->controls = talloc_memdup(req, ac->req->controls, + talloc_get_size(ac->req->controls)); if (req->controls == NULL) { ldb_oom(ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } } - if (req->operation == LDB_SEARCH) { - /* If the search is for 'more' than this partition, - * then change the basedn, so a remote LDAP server - * doesn't object */ - if (partition) { - if (ldb_dn_compare_base(partition->dn, req->op.search.base) != 0) { - req->op.search.base = partition->dn; - } - } else { - req->op.search.base = NULL; - } - req->callback = partition_search_callback; - req->context = ac; - } else { - req->callback = partition_other_callback; - req->context = ac; - } - if (partition) { - ret = ldb_request_add_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID, false, partition); + ac->part_req[ac->num_requests].module = partition->module; + + ret = ldb_request_add_control(req, + DSDB_CONTROL_CURRENT_PARTITION_OID, + false, partition); if (ret != LDB_SUCCESS) { return ret; } - } - /* Spray off search requests the backend */ - ret = ldb_next_request(backend, req); - if (ret != LDB_SUCCESS) { - return ret; + if (req->operation == LDB_SEARCH) { + /* If the search is for 'more' than this partition, + * then change the basedn, so a remote LDAP server + * doesn't object */ + if (ldb_dn_compare_base(partition->dn, + req->op.search.base) != 0) { + req->op.search.base = partition->dn; + } + } + + } else { + /* make sure you put the NEXT module here, or + * partition_request() will simply loop forever on itself */ + ac->part_req[ac->num_requests].module = ac->module->next; } ac->num_requests++; + return LDB_SUCCESS; } +static int partition_call_first(struct partition_context *ac) +{ + return partition_request(ac->part_req[0].module, ac->part_req[0].req); +} + /** * Send a request down to all the partitions */ @@ -251,17 +363,19 @@ static int partition_send_all(struct ldb_module *module, int i; struct partition_private_data *data = talloc_get_type(module->private_data, struct partition_private_data); - int ret = partition_send_request(ac, NULL); + int ret = partition_prep_request(ac, NULL); if (ret != LDB_SUCCESS) { return ret; } for (i=0; data && data->partitions && data->partitions[i]; i++) { - ret = partition_send_request(ac, data->partitions[i]); + ret = partition_prep_request(ac, data->partitions[i]); if (ret != LDB_SUCCESS) { return ret; } } - return LDB_SUCCESS; + + /* fire the first one */ + return partition_call_first(ac); } /** @@ -270,21 +384,23 @@ static int partition_send_all(struct ldb_module *module, */ static int partition_replicate(struct ldb_module *module, struct ldb_request *req, struct ldb_dn *dn) { + struct partition_context *ac; unsigned i; int ret; struct dsdb_control_current_partition *partition; - struct ldb_module *backend; struct partition_private_data *data = talloc_get_type(module->private_data, struct partition_private_data); + if (!data || !data->partitions) { + return ldb_next_request(module, req); + } if (req->operation != LDB_SEARCH) { /* Is this a special DN, we need to replicate to every backend? */ for (i=0; data->replicate && data->replicate[i]; i++) { if (ldb_dn_compare(data->replicate[i], dn) == 0) { - struct partition_context *ac; - ac = partition_init_handle(req, module); + ac = partition_init_ctx(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } @@ -310,18 +426,19 @@ static int partition_replicate(struct ldb_module *module, struct ldb_request *re return ldb_next_request(module, req); } - backend = make_module_for_next_request(req, module->ldb, partition->module); - if (!backend) { + ac = partition_init_ctx(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_request_add_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID, false, partition); + /* we need to add a control but we never touch the original request */ + ret = partition_prep_request(ac, partition); if (ret != LDB_SUCCESS) { return ret; } - /* issue request */ - return ldb_next_request(backend, req); + /* fire the first one */ + return partition_call_first(ac); } /* search */ @@ -336,6 +453,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) /* (later) consider if we should be searching multiple * partitions (for 'invisible' partition behaviour */ + struct ldb_control *search_control = ldb_request_get_control(req, LDB_CONTROL_SEARCH_OPTIONS_OID); struct ldb_control *domain_scope_control = ldb_request_get_control(req, LDB_CONTROL_DOMAIN_SCOPE_OID); @@ -350,6 +468,14 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } + /* + * for now pass down the LDB_CONTROL_SEARCH_OPTIONS_OID control + * down as uncritical to make windows 2008 dcpromo happy. + */ + if (search_control) { + search_control->critical = 0; + } + /* TODO: Generate referrals (look for a partition under this DN) if we don't have the above control specified */ @@ -366,7 +492,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } } - ac = partition_init_handle(req, module); + ac = partition_init_ctx(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } @@ -376,13 +502,41 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) return partition_send_all(module, ac, req); } for (i=0; data && data->partitions && data->partitions[i]; i++) { - /* Find all partitions under the search base */ - if (ldb_dn_compare_base(req->op.search.base, data->partitions[i]->dn) == 0) { - ret = partition_send_request(ac, data->partitions[i]); + bool match = false, stop = false; + /* Find all partitions under the search base + + we match if: + + 1) the DN we are looking for exactly matches the partition + or + 2) the DN we are looking for is a parent of the partition and it isn't + a scope base search + or + 3) the DN we are looking for is a child of the partition + */ + if (ldb_dn_compare(data->partitions[i]->dn, req->op.search.base) == 0) { + match = true; + if (req->op.search.scope == LDB_SCOPE_BASE) { + stop = true; + } + } + if (!match && + (ldb_dn_compare_base(req->op.search.base, data->partitions[i]->dn) == 0 && + req->op.search.scope != LDB_SCOPE_BASE)) { + match = true; + } + if (!match && + ldb_dn_compare_base(data->partitions[i]->dn, req->op.search.base) == 0) { + match = true; + stop = true; /* note that this relies on partition ordering */ + } + if (match) { + ret = partition_prep_request(ac, data->partitions[i]); if (ret != LDB_SUCCESS) { return ret; } } + if (stop) break; } /* Perhaps we didn't match any partitions. Try the main partition, only */ @@ -390,8 +544,10 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req) talloc_free(ac); return ldb_next_request(module, req); } - - return LDB_SUCCESS; + + /* fire the first one */ + return partition_call_first(ac); + } else { /* Handle this like all other requests */ if (search_control && (search_options->search_options & ~LDB_SEARCH_OPTION_PHANTOM_ROOT) == 0) { @@ -429,14 +585,13 @@ static int partition_delete(struct ldb_module *module, struct ldb_request *req) /* rename */ static int partition_rename(struct ldb_module *module, struct ldb_request *req) { - int i, matched = -1; /* Find backend */ struct dsdb_control_current_partition *backend, *backend2; struct partition_private_data *data = talloc_get_type(module->private_data, struct partition_private_data); - /* Skip the lot if 'data' isn't here yet (initialistion) */ + /* Skip the lot if 'data' isn't here yet (initialization) */ if (!data) { return LDB_ERR_OPERATIONS_ERROR; } @@ -459,22 +614,6 @@ static int partition_rename(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_AFFECTS_MULTIPLE_DSAS; } - for (i=0; data && data->partitions && data->partitions[i]; i++) { - if (ldb_dn_compare_base(req->op.rename.olddn, data->partitions[i]->dn) == 0) { - matched = i; - } - } - - if (matched > 0) { - ldb_asprintf_errstring(module->ldb, - "Cannot rename from %s to %s, subtree rename would cross partition %s: %s", - ldb_dn_get_linearized(req->op.rename.olddn), - ldb_dn_get_linearized(req->op.rename.newdn), - ldb_dn_get_linearized(data->partitions[matched]->dn), - ldb_strerror(LDB_ERR_AFFECTS_MULTIPLE_DSAS)); - return LDB_ERR_AFFECTS_MULTIPLE_DSAS; - } - return partition_replicate(module, req, req->op.rename.olddn); } @@ -486,24 +625,26 @@ static int partition_start_trans(struct ldb_module *module) struct partition_private_data); /* Look at base DN */ /* Figure out which partition it is under */ - /* Skip the lot if 'data' isn't here yet (initialistion) */ + /* Skip the lot if 'data' isn't here yet (initialization) */ ret = ldb_next_start_trans(module); if (ret != LDB_SUCCESS) { return ret; } for (i=0; data && data->partitions && data->partitions[i]; i++) { - struct ldb_module *next = make_module_for_next_request(module, module->ldb, data->partitions[i]->module); + struct ldb_module *next = data->partitions[i]->module; + PARTITION_FIND_OP(next, start_transaction); - ret = ldb_next_start_trans(next); - talloc_free(next); + ret = next->ops->start_transaction(next); if (ret != LDB_SUCCESS) { /* Back it out, if it fails on one */ for (i--; i >= 0; i--) { - next = make_module_for_next_request(module, module->ldb, data->partitions[i]->module); - ldb_next_del_trans(next); - talloc_free(next); + next = data->partitions[i]->module; + PARTITION_FIND_OP(next, del_transaction); + + next->ops->del_transaction(next); } + ldb_next_del_trans(module); return ret; } } @@ -513,7 +654,7 @@ static int partition_start_trans(struct ldb_module *module) /* end a transaction */ static int partition_end_trans(struct ldb_module *module) { - int i, ret, ret2 = LDB_SUCCESS; + int i, ret; struct partition_private_data *data = talloc_get_type(module->private_data, struct partition_private_data); ret = ldb_next_end_trans(module); @@ -525,24 +666,24 @@ static int partition_end_trans(struct ldb_module *module) /* Figure out which partition it is under */ /* Skip the lot if 'data' isn't here yet (initialistion) */ for (i=0; data && data->partitions && data->partitions[i]; i++) { - struct ldb_module *next = make_module_for_next_request(module, module->ldb, data->partitions[i]->module); - - ret = ldb_next_end_trans(next); - talloc_free(next); + struct ldb_module *next = data->partitions[i]->module; + PARTITION_FIND_OP(next, end_transaction); + + ret = next->ops->end_transaction(next); if (ret != LDB_SUCCESS) { - ret2 = ret; - } - } + /* Back it out, if it fails on one */ + for (i--; i >= 0; i--) { + next = data->partitions[i]->module; + PARTITION_FIND_OP(next, del_transaction); - if (ret != LDB_SUCCESS) { - /* Back it out, if it fails on one */ - for (i=0; data && data->partitions && data->partitions[i]; i++) { - struct ldb_module *next = make_module_for_next_request(module, module->ldb, data->partitions[i]->module); - ldb_next_del_trans(next); - talloc_free(next); + next->ops->del_transaction(next); + } + ldb_next_del_trans(module); + return ret; } } - return ret; + + return LDB_SUCCESS; } /* delete a transaction */ @@ -560,10 +701,10 @@ static int partition_del_trans(struct ldb_module *module) /* Figure out which partition it is under */ /* Skip the lot if 'data' isn't here yet (initialistion) */ for (i=0; data && data->partitions && data->partitions[i]; i++) { - struct ldb_module *next = make_module_for_next_request(module, module->ldb, data->partitions[i]->module); - - ret = ldb_next_del_trans(next); - talloc_free(next); + struct ldb_module *next = data->partitions[i]->module; + PARTITION_FIND_OP(next, del_transaction); + + ret = next->ops->del_transaction(next); if (ret != LDB_SUCCESS) { ret2 = ret; } @@ -571,6 +712,8 @@ static int partition_del_trans(struct ldb_module *module) return ret2; } + +/* FIXME: This function is still semi-async */ static int partition_sequence_number(struct ldb_module *module, struct ldb_request *req) { int i, ret; @@ -579,105 +722,241 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque uint64_t timestamp = 0; struct partition_private_data *data = talloc_get_type(module->private_data, struct partition_private_data); + struct ldb_seqnum_request *seq; + struct ldb_seqnum_result *seqr; + struct ldb_request *treq; + struct ldb_seqnum_request *tseq; + struct ldb_seqnum_result *tseqr; + struct ldb_extended *ext; + struct ldb_result *res; + + seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request); - switch (req->op.seq_num.type) { + switch (seq->type) { case LDB_SEQ_NEXT: case LDB_SEQ_HIGHEST_SEQ: - ret = ldb_next_request(module, req); + res = talloc_zero(req, struct ldb_result); + if (res == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + tseq = talloc_zero(res, struct ldb_seqnum_request); + if (tseq == NULL) { + talloc_free(res); + return LDB_ERR_OPERATIONS_ERROR; + } + tseq->type = seq->type; + + ret = ldb_build_extended_req(&treq, module->ldb, res, + LDB_EXTENDED_SEQUENCE_NUMBER, + tseq, + NULL, + res, + ldb_extended_default_callback, + NULL); + ret = ldb_next_request(module, treq); + if (ret == LDB_SUCCESS) { + ret = ldb_wait(treq->handle, LDB_WAIT_ALL); + } if (ret != LDB_SUCCESS) { + talloc_free(res); return ret; } - if (req->op.seq_num.flags & LDB_SEQ_TIMESTAMP_SEQUENCE) { - timestamp_sequence = req->op.seq_num.seq_num; + seqr = talloc_get_type(res->extended->data, + struct ldb_seqnum_result); + if (seqr->flags & LDB_SEQ_TIMESTAMP_SEQUENCE) { + timestamp_sequence = seqr->seq_num; } else { - seq_number = seq_number + req->op.seq_num.seq_num; + seq_number += seqr->seq_num; } + talloc_free(res); - /* Look at base DN */ - /* Figure out which partition it is under */ /* Skip the lot if 'data' isn't here yet (initialistion) */ for (i=0; data && data->partitions && data->partitions[i]; i++) { - struct ldb_module *next = make_module_for_next_request(req, module->ldb, data->partitions[i]->module); - - ret = ldb_request_add_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID, false, data->partitions[i]); + + res = talloc_zero(req, struct ldb_result); + if (res == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + tseq = talloc_zero(res, struct ldb_seqnum_request); + if (tseq == NULL) { + talloc_free(res); + return LDB_ERR_OPERATIONS_ERROR; + } + tseq->type = seq->type; + + ret = ldb_build_extended_req(&treq, module->ldb, res, + LDB_EXTENDED_SEQUENCE_NUMBER, + tseq, + NULL, + res, + ldb_extended_default_callback, + NULL); + if (ret != LDB_SUCCESS) { + talloc_free(res); + return ret; + } + + ret = ldb_request_add_control(treq, + DSDB_CONTROL_CURRENT_PARTITION_OID, + false, data->partitions[i]); if (ret != LDB_SUCCESS) { + talloc_free(res); return ret; } - ret = ldb_next_request(next, req); - talloc_free(next); + ret = partition_request(data->partitions[i]->module, treq); + if (ret != LDB_SUCCESS) { + talloc_free(res); + return ret; + } + ret = ldb_wait(treq->handle, LDB_WAIT_ALL); if (ret != LDB_SUCCESS) { + talloc_free(res); return ret; } - if (req->op.seq_num.flags & LDB_SEQ_TIMESTAMP_SEQUENCE) { - timestamp_sequence = MAX(timestamp_sequence, req->op.seq_num.seq_num); + tseqr = talloc_get_type(res->extended->data, + struct ldb_seqnum_result); + if (tseqr->flags & LDB_SEQ_TIMESTAMP_SEQUENCE) { + timestamp_sequence = MAX(timestamp_sequence, + tseqr->seq_num); } else { - seq_number = seq_number + req->op.seq_num.seq_num; + seq_number += tseqr->seq_num; } + talloc_free(res); } - /* fall though */ + /* fall through */ case LDB_SEQ_HIGHEST_TIMESTAMP: - { - struct ldb_request *date_req = talloc(req, struct ldb_request); - if (!date_req) { + + res = talloc_zero(req, struct ldb_result); + if (res == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - *date_req = *req; - date_req->op.seq_num.flags = LDB_SEQ_HIGHEST_TIMESTAMP; - ret = ldb_next_request(module, date_req); + tseq = talloc_zero(res, struct ldb_seqnum_request); + if (tseq == NULL) { + talloc_free(res); + return LDB_ERR_OPERATIONS_ERROR; + } + tseq->type = LDB_SEQ_HIGHEST_TIMESTAMP; + + ret = ldb_build_extended_req(&treq, module->ldb, res, + LDB_EXTENDED_SEQUENCE_NUMBER, + tseq, + NULL, + res, + ldb_extended_default_callback, + NULL); if (ret != LDB_SUCCESS) { + talloc_free(res); return ret; } - timestamp = date_req->op.seq_num.seq_num; - - /* Look at base DN */ - /* Figure out which partition it is under */ + + ret = ldb_next_request(module, treq); + if (ret != LDB_SUCCESS) { + talloc_free(res); + return ret; + } + ret = ldb_wait(treq->handle, LDB_WAIT_ALL); + if (ret != LDB_SUCCESS) { + talloc_free(res); + return ret; + } + + tseqr = talloc_get_type(res->extended->data, + struct ldb_seqnum_result); + timestamp = tseqr->seq_num; + + talloc_free(res); + /* Skip the lot if 'data' isn't here yet (initialistion) */ for (i=0; data && data->partitions && data->partitions[i]; i++) { - struct ldb_module *next = make_module_for_next_request(req, module->ldb, data->partitions[i]->module); - - ret = ldb_next_request(next, date_req); - talloc_free(next); + + res = talloc_zero(req, struct ldb_result); + if (res == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + tseq = talloc_zero(res, struct ldb_seqnum_request); + if (tseq == NULL) { + talloc_free(res); + return LDB_ERR_OPERATIONS_ERROR; + } + tseq->type = LDB_SEQ_HIGHEST_TIMESTAMP; + + ret = ldb_build_extended_req(&treq, module->ldb, res, + LDB_EXTENDED_SEQUENCE_NUMBER, + tseq, + NULL, + res, + ldb_extended_default_callback, + NULL); + if (ret != LDB_SUCCESS) { + talloc_free(res); + return ret; + } + + ret = partition_request(data->partitions[i]->module, treq); if (ret != LDB_SUCCESS) { + talloc_free(res); return ret; } - timestamp = MAX(timestamp, date_req->op.seq_num.seq_num); + ret = ldb_wait(treq->handle, LDB_WAIT_ALL); + if (ret != LDB_SUCCESS) { + talloc_free(res); + return ret; + } + + tseqr = talloc_get_type(res->extended->data, + struct ldb_seqnum_result); + timestamp = MAX(timestamp, tseqr->seq_num); + + talloc_free(res); } + break; } + + ext = talloc_zero(req, struct ldb_extended); + if (!ext) { + return LDB_ERR_OPERATIONS_ERROR; + } + seqr = talloc_zero(ext, struct ldb_seqnum_result); + if (seqr == NULL) { + talloc_free(ext); + return LDB_ERR_OPERATIONS_ERROR; } + ext->oid = LDB_EXTENDED_SEQUENCE_NUMBER; + ext->data = seqr; - switch (req->op.seq_num.flags) { + switch (seq->type) { case LDB_SEQ_NEXT: case LDB_SEQ_HIGHEST_SEQ: - - req->op.seq_num.flags = 0; /* Has someone above set a timebase sequence? */ if (timestamp_sequence) { - req->op.seq_num.seq_num = (((unsigned long long)timestamp << 24) | (seq_number & 0xFFFFFF)); + seqr->seq_num = (((unsigned long long)timestamp << 24) | (seq_number & 0xFFFFFF)); } else { - req->op.seq_num.seq_num = seq_number; + seqr->seq_num = seq_number; } - if (timestamp_sequence > req->op.seq_num.seq_num) { - req->op.seq_num.seq_num = timestamp_sequence; - req->op.seq_num.flags |= LDB_SEQ_TIMESTAMP_SEQUENCE; + if (timestamp_sequence > seqr->seq_num) { + seqr->seq_num = timestamp_sequence; + seqr->flags |= LDB_SEQ_TIMESTAMP_SEQUENCE; } - req->op.seq_num.flags |= LDB_SEQ_GLOBAL_SEQUENCE; + seqr->flags |= LDB_SEQ_GLOBAL_SEQUENCE; break; case LDB_SEQ_HIGHEST_TIMESTAMP: - req->op.seq_num.seq_num = timestamp; + seqr->seq_num = timestamp; break; } - switch (req->op.seq_num.flags) { - case LDB_SEQ_NEXT: - req->op.seq_num.seq_num++; + if (seq->type == LDB_SEQ_NEXT) { + seqr->seq_num++; } - return LDB_SUCCESS; + + /* send request done */ + return ldb_module_done(req, NULL, ext, LDB_SUCCESS); } static int partition_extended_replicated_objects(struct ldb_module *module, struct ldb_request *req) @@ -705,7 +984,6 @@ static int partition_extended_schema_update_now(struct ldb_module *module, struc struct partition_private_data *data; struct ldb_dn *schema_dn; struct partition_context *ac; - struct ldb_module *backend; int ret; schema_dn = talloc_get_type(req->op.extended.data, struct ldb_dn); @@ -724,30 +1002,37 @@ static int partition_extended_schema_update_now(struct ldb_module *module, struc return ldb_next_request(module, req); } - ac = partition_init_handle(req, module); + ac = partition_init_ctx(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - backend = make_module_for_next_request(req, module->ldb, partition->module); - if (!backend) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ret = ldb_request_add_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID, false, partition); + /* we need to add a control but we never touch the original request */ + ret = partition_prep_request(ac, partition); if (ret != LDB_SUCCESS) { return ret; } - return ldb_next_request(backend, req); + /* fire the first one */ + return partition_call_first(ac); } /* extended */ static int partition_extended(struct ldb_module *module, struct ldb_request *req) { + struct partition_private_data *data; struct partition_context *ac; + data = talloc_get_type(module->private_data, struct partition_private_data); + if (!data || !data->partitions) { + return ldb_next_request(module, req); + } + + if (strcmp(req->op.extended.oid, LDB_EXTENDED_SEQUENCE_NUMBER) == 0) { + return partition_sequence_number(module, req); + } + if (strcmp(req->op.extended.oid, DSDB_EXTENDED_REPLICATED_OBJECTS_OID) == 0) { return partition_extended_replicated_objects(module, req); } @@ -762,27 +1047,23 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req * we need to send it to all partitions */ - ac = partition_init_handle(req, module); + ac = partition_init_ctx(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - + return partition_send_all(module, ac, req); } -static int sort_compare(void *void1, - void *void2, void *opaque) +static int partition_sort_compare(const void *v1, const void *v2) { - struct dsdb_control_current_partition **pp1 = - (struct dsdb_control_current_partition **)void1; - struct dsdb_control_current_partition **pp2 = - (struct dsdb_control_current_partition **)void2; - struct dsdb_control_current_partition *partition1 = talloc_get_type(*pp1, - struct dsdb_control_current_partition); - struct dsdb_control_current_partition *partition2 = talloc_get_type(*pp2, - struct dsdb_control_current_partition); - - return ldb_dn_compare(partition1->dn, partition2->dn); + struct dsdb_control_current_partition *p1; + struct dsdb_control_current_partition *p2; + + p1 = *((struct dsdb_control_current_partition **)v1); + p2 = *((struct dsdb_control_current_partition **)v2); + + return ldb_dn_compare(p1->dn, p2->dn); } static int partition_init(struct ldb_module *module) @@ -807,15 +1088,13 @@ static int partition_init(struct ldb_module *module) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, ldb_dn_new(mem_ctx, module->ldb, "@PARTITION"), - LDB_SCOPE_BASE, - NULL, attrs, - &res); + ret = ldb_search(module->ldb, mem_ctx, &res, + ldb_dn_new(mem_ctx, module->ldb, "@PARTITION"), + LDB_SCOPE_BASE, attrs, NULL); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; } - talloc_steal(mem_ctx, res); if (res->count == 0) { talloc_free(mem_ctx); return ldb_next_init(module); @@ -890,8 +1169,8 @@ static int partition_init(struct ldb_module *module) data->partitions[i] = NULL; /* sort these into order, most to least specific */ - ldb_qsort(data->partitions, partition_attributes->num_values, sizeof(*data->partitions), - module->ldb, sort_compare); + qsort(data->partitions, partition_attributes->num_values, + sizeof(*data->partitions), partition_sort_compare); for (i=0; data->partitions[i]; i++) { struct ldb_request *req; @@ -904,8 +1183,19 @@ static int partition_init(struct ldb_module *module) req->operation = LDB_REQ_REGISTER_PARTITION; req->op.reg_partition.dn = data->partitions[i]->dn; + req->callback = ldb_op_default_callback; + + ldb_set_timeout(module->ldb, req, 0); + + req->handle = ldb_handle_new(req, module->ldb); + if (req->handle == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } ret = ldb_request(module->ldb, req); + if (ret == LDB_SUCCESS) { + ret = ldb_wait(req->handle, LDB_WAIT_ALL); + } if (ret != LDB_SUCCESS) { ldb_debug(module->ldb, LDB_DEBUG_ERROR, "partition: Unable to register partition with rootdse!\n"); talloc_free(mem_ctx); @@ -923,7 +1213,7 @@ static int partition_init(struct ldb_module *module) talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } - + for (i=0; i < replicate_attributes->num_values; i++) { data->replicate[i] = ldb_dn_from_ldb_val(data->replicate, module->ldb, &replicate_attributes->values[i]); if (!ldb_dn_validate(data->replicate[i])) { @@ -1014,74 +1304,22 @@ static int partition_init(struct ldb_module *module) } } - talloc_free(mem_ctx); - return ldb_next_init(module); -} - -static int partition_wait_none(struct ldb_handle *handle) { - struct partition_context *ac; - int ret; - int i; - - if (!handle || !handle->private_data) { + ret = ldb_mod_register_control(module, LDB_CONTROL_DOMAIN_SCOPE_OID); + if (ret != LDB_SUCCESS) { + ldb_debug(module->ldb, LDB_DEBUG_ERROR, + "partition: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct partition_context); - - for (i=0; i < ac->num_requests; i++) { - ret = ldb_wait(ac->down_req[i]->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req[i]->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req[i]->handle->status; - goto done; - } - - if (ac->down_req[i]->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - } - - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - - -static int partition_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = partition_wait_none(handle); - if (ret != LDB_SUCCESS) { - return ret; - } + ret = ldb_mod_register_control(module, LDB_CONTROL_SEARCH_OPTIONS_OID); + if (ret != LDB_SUCCESS) { + ldb_debug(module->ldb, LDB_DEBUG_ERROR, + "partition: Unable to register control with rootdse!\n"); + return LDB_ERR_OPERATIONS_ERROR; } - return handle->status; -} - -static int partition_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return partition_wait_all(handle); - } else { - return partition_wait_none(handle); - } + talloc_free(mem_ctx); + return ldb_next_init(module); } _PUBLIC_ const struct ldb_module_ops ldb_partition_module_ops = { @@ -1093,9 +1331,7 @@ _PUBLIC_ const struct ldb_module_ops ldb_partition_module_ops = { .del = partition_delete, .rename = partition_rename, .extended = partition_extended, - .sequence_number = partition_sequence_number, .start_transaction = partition_start_trans, .end_transaction = partition_end_trans, .del_transaction = partition_del_trans, - .wait = partition_wait }; diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 69783aefa8..5ed7f1fbad 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -1,7 +1,7 @@ /* ldb database module - Copyright (C) Simo Sorce 2004-2006 + Copyright (C) Simo Sorce 2004-2008 Copyright (C) Andrew Bartlett 2005-2006 Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2007 @@ -48,7 +48,7 @@ #include "dsdb/samdb/ldb_modules/password_modules.h" #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "param/param.h" /* If we have decided there is reason to work on this request, then @@ -73,23 +73,16 @@ struct ph_context { - enum ph_type {PH_ADD, PH_MOD} type; - enum ph_step {PH_ADD_SEARCH_DOM, PH_ADD_DO_ADD, PH_MOD_DO_REQ, PH_MOD_SEARCH_SELF, PH_MOD_SEARCH_DOM, PH_MOD_DO_MOD} step; - struct ldb_module *module; - struct ldb_request *orig_req; + struct ldb_request *req; struct ldb_request *dom_req; struct ldb_reply *dom_res; - struct ldb_request *down_req; - - struct ldb_request *search_req; struct ldb_reply *search_res; - struct ldb_request *mod_req; - struct dom_sid *domain_sid; + struct domain_data *domain; }; struct domain_data { @@ -116,7 +109,8 @@ struct setup_password_fields_io { /* new credentials */ struct { - const char *cleartext; + const struct ldb_val *cleartext_utf8; + const struct ldb_val *cleartext_utf16; struct samr_Password *nt_hash; struct samr_Password *lm_hash; } n; @@ -151,6 +145,9 @@ struct setup_password_fields_io { } g; }; +/* Get the NT hash, and fill it in as an entry in the password history, + and specify it into io->g.nt_hash */ + static int setup_nt_fields(struct setup_password_fields_io *io) { uint32_t i; @@ -188,6 +185,9 @@ static int setup_nt_fields(struct setup_password_fields_io *io) return LDB_SUCCESS; } +/* Get the LANMAN hash, and fill it in as an entry in the password history, + and specify it into io->g.lm_hash */ + static int setup_lm_fields(struct setup_password_fields_io *io) { uint32_t i; @@ -227,6 +227,10 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) Principal *salt_principal; krb5_salt salt; krb5_keyblock key; + krb5_data cleartext_data; + + cleartext_data.data = io->n.cleartext_utf8->data; + cleartext_data.length = io->n.cleartext_utf8->length; /* Many, many thanks to lukeh@padl.com for this * algorithm, described in his Nov 10 2004 mail to @@ -321,11 +325,11 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) * create ENCTYPE_AES256_CTS_HMAC_SHA1_96 key out of * the salt and the cleartext password */ - krb5_ret = krb5_string_to_key_salt(io->smb_krb5_context->krb5_context, - ENCTYPE_AES256_CTS_HMAC_SHA1_96, - io->n.cleartext, - salt, - &key); + krb5_ret = krb5_string_to_key_data_salt(io->smb_krb5_context->krb5_context, + ENCTYPE_AES256_CTS_HMAC_SHA1_96, + cleartext_data, + salt, + &key); if (krb5_ret) { ldb_asprintf_errstring(io->ac->module->ldb, "setup_kerberos_keys: " @@ -346,11 +350,11 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) * create ENCTYPE_AES128_CTS_HMAC_SHA1_96 key out of * the salt and the cleartext password */ - krb5_ret = krb5_string_to_key_salt(io->smb_krb5_context->krb5_context, - ENCTYPE_AES128_CTS_HMAC_SHA1_96, - io->n.cleartext, - salt, - &key); + krb5_ret = krb5_string_to_key_data_salt(io->smb_krb5_context->krb5_context, + ENCTYPE_AES128_CTS_HMAC_SHA1_96, + cleartext_data, + salt, + &key); if (krb5_ret) { ldb_asprintf_errstring(io->ac->module->ldb, "setup_kerberos_keys: " @@ -371,11 +375,11 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) * create ENCTYPE_DES_CBC_MD5 key out of * the salt and the cleartext password */ - krb5_ret = krb5_string_to_key_salt(io->smb_krb5_context->krb5_context, - ENCTYPE_DES_CBC_MD5, - io->n.cleartext, - salt, - &key); + krb5_ret = krb5_string_to_key_data_salt(io->smb_krb5_context->krb5_context, + ENCTYPE_DES_CBC_MD5, + cleartext_data, + salt, + &key); if (krb5_ret) { ldb_asprintf_errstring(io->ac->module->ldb, "setup_kerberos_keys: " @@ -396,11 +400,11 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) * create ENCTYPE_DES_CBC_CRC key out of * the salt and the cleartext password */ - krb5_ret = krb5_string_to_key_salt(io->smb_krb5_context->krb5_context, - ENCTYPE_DES_CBC_CRC, - io->n.cleartext, - salt, - &key); + krb5_ret = krb5_string_to_key_data_salt(io->smb_krb5_context->krb5_context, + ENCTYPE_DES_CBC_CRC, + cleartext_data, + salt, + &key); if (krb5_ret) { ldb_asprintf_errstring(io->ac->module->ldb, "setup_kerberos_keys: " @@ -478,12 +482,11 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, if (old_scp) { DATA_BLOB blob; - blob = strhex_to_data_blob(old_scp->data); + blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - talloc_steal(io->ac, blob.data); /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), &_old_pkb, @@ -592,12 +595,11 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, if (old_scp) { DATA_BLOB blob; - blob = strhex_to_data_blob(old_scp->data); + blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - talloc_steal(io->ac, blob.data); /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ ndr_err = ndr_pull_struct_blob(&blob, io->ac, @@ -655,7 +657,6 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, DATA_BLOB dns_domain; DATA_BLOB dns_domain_l; DATA_BLOB dns_domain_u; - DATA_BLOB cleartext; DATA_BLOB digest; DATA_BLOB delim; DATA_BLOB backslash; @@ -936,8 +937,6 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, dns_domain_l = data_blob_string_const(io->domain->dns_domain); dns_domain_u = data_blob_string_const(io->domain->realm); - cleartext = data_blob_string_const(io->n.cleartext); - digest = data_blob_string_const("Digest"); delim = data_blob_string_const(":"); @@ -963,7 +962,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, MD5Update(&md5, wdigest[i].realm->data, wdigest[i].realm->length); } MD5Update(&md5, delim.data, delim.length); - MD5Update(&md5, cleartext.data, cleartext.length); + MD5Update(&md5, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length); MD5Final(pdb->hashes[i].hash, &md5); } @@ -1018,7 +1017,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) ZERO_STRUCT(zero16); ZERO_STRUCT(names); - if (!io->n.cleartext) { + if (!io->n.cleartext_utf8) { /* * when we don't have a cleartext password * we can't setup a supplementalCredential value @@ -1200,7 +1199,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) if (pc) { *nc = "CLEARTEXT"; - pcb.cleartext = io->n.cleartext; + pcb.cleartext = *io->n.cleartext_utf16; ndr_err = ndr_push_struct_blob(&pcb_blob, io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), @@ -1292,58 +1291,97 @@ static int setup_password_fields(struct setup_password_fields_io *io) { bool ok; int ret; - + ssize_t converted_pw_len; + /* * refuse the change if someone want to change the cleartext * and supply his own hashes at the same time... */ - if (io->n.cleartext && (io->n.nt_hash || io->n.lm_hash)) { + if ((io->n.cleartext_utf8 || io->n.cleartext_utf16) && (io->n.nt_hash || io->n.lm_hash)) { ldb_asprintf_errstring(io->ac->module->ldb, "setup_password_fields: " "it's only allowed to set the cleartext password or the password hashes"); return LDB_ERR_UNWILLING_TO_PERFORM; } - - if (io->n.cleartext) { - struct samr_Password *hash; - - hash = talloc(io->ac, struct samr_Password); - if (!hash) { + + if (io->n.cleartext_utf8 && io->n.cleartext_utf16) { + ldb_asprintf_errstring(io->ac->module->ldb, + "setup_password_fields: " + "it's only allowed to set the cleartext password as userPassword or clearTextPasssword, not both at once"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } + + if (io->n.cleartext_utf8) { + char **cleartext_utf16_str; + struct ldb_val *cleartext_utf16_blob; + io->n.cleartext_utf16 = cleartext_utf16_blob = talloc(io->ac, struct ldb_val); + if (!io->n.cleartext_utf16) { ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - - /* compute the new nt hash */ - ok = E_md4hash(io->n.cleartext, hash->hash); - if (ok) { - io->n.nt_hash = hash; - } else { + converted_pw_len = convert_string_talloc(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + CH_UTF8, CH_UTF16, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, + (void **)&cleartext_utf16_str); + if (converted_pw_len == -1) { ldb_asprintf_errstring(io->ac->module->ldb, "setup_password_fields: " - "failed to generate nthash from cleartext password"); + "failed to generate UTF16 password from cleartext UTF8 password"); return LDB_ERR_OPERATIONS_ERROR; } + *cleartext_utf16_blob = data_blob_const(cleartext_utf16_str, converted_pw_len); + } else if (io->n.cleartext_utf16) { + char *cleartext_utf8_str; + struct ldb_val *cleartext_utf8_blob; + io->n.cleartext_utf8 = cleartext_utf8_blob = talloc(io->ac, struct ldb_val); + if (!io->n.cleartext_utf8) { + ldb_oom(io->ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + converted_pw_len = convert_string_talloc(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + CH_UTF16, CH_UTF8, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length, + (void **)&cleartext_utf8_str); + if (converted_pw_len == -1) { + /* We can't bail out entirely, as these unconvertable passwords are frustratingly valid */ + io->n.cleartext_utf8 = NULL; + talloc_free(cleartext_utf8_blob); + } + *cleartext_utf8_blob = data_blob_const(cleartext_utf8_str, converted_pw_len); } - - if (io->n.cleartext) { - struct samr_Password *hash; - - hash = talloc(io->ac, struct samr_Password); - if (!hash) { + if (io->n.cleartext_utf16) { + struct samr_Password *nt_hash; + nt_hash = talloc(io->ac, struct samr_Password); + if (!nt_hash) { ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } + io->n.nt_hash = nt_hash; - /* compute the new lm hash */ - ok = E_deshash(io->n.cleartext, hash->hash); - if (ok) { - io->n.lm_hash = hash; - } else { - talloc_free(hash->hash); - } + /* compute the new nt hash */ + mdfour(nt_hash->hash, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length); } - if (io->n.cleartext) { + if (io->n.cleartext_utf8) { + struct samr_Password *lm_hash; + char *cleartext_unix; + converted_pw_len = convert_string_talloc(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + CH_UTF8, CH_UNIX, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, + (void **)&cleartext_unix); + if (converted_pw_len != -1) { + lm_hash = talloc(io->ac, struct samr_Password); + if (!lm_hash) { + ldb_oom(io->ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + + /* compute the new lm hash. */ + ok = E_deshash((char *)cleartext_unix, lm_hash->hash); + if (ok) { + io->n.lm_hash = lm_hash; + } else { + talloc_free(lm_hash->hash); + } + } + ret = setup_kerberos_keys(io); if (ret != 0) { return ret; @@ -1378,170 +1416,196 @@ static int setup_password_fields(struct setup_password_fields_io *io) return LDB_SUCCESS; } -static struct ldb_handle *ph_init_handle(struct ldb_request *req, struct ldb_module *module, enum ph_type type) +static struct ph_context *ph_init_context(struct ldb_module *module, + struct ldb_request *req) { struct ph_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - h->module = module; - - ac = talloc_zero(h, struct ph_context); + ac = talloc_zero(req, struct ph_context); if (ac == NULL) { ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); return NULL; } - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->type = type; ac->module = module; - ac->orig_req = req; + ac->req = req; - return h; + return ac; } -static int get_domain_data_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int ph_op_callback(struct ldb_request *req, struct ldb_reply *ares) { struct ph_context *ac; - ac = talloc_get_type(context, struct ph_context); - - /* we are interested only in the single reply (base search) we receive here */ - if (ares->type == LDB_REPLY_ENTRY) { - if (ac->dom_res != NULL) { - ldb_set_errstring(ldb, "Too many results"); - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - ac->dom_res = talloc_steal(ac, ares); - } else { - talloc_free(ares); - } - - return LDB_SUCCESS; -} - -static int build_domain_data_request(struct ph_context *ac) -{ - /* attrs[] is returned from this function in - ac->dom_req->op.search.attrs, so it must be static, as - otherwise the compiler can put it on the stack */ - static const char * const attrs[] = { "pwdProperties", "pwdHistoryLength", NULL }; - char *filter; + ac = talloc_get_type(req->context, struct ph_context); - ac->dom_req = talloc_zero(ac, struct ldb_request); - if (ac->dom_req == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, "Out of Memory!\n"); - return LDB_ERR_OPERATIONS_ERROR; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ac->dom_req->operation = LDB_SEARCH; - ac->dom_req->op.search.base = ldb_get_default_basedn(ac->module->ldb); - ac->dom_req->op.search.scope = LDB_SCOPE_SUBTREE; - - filter = talloc_asprintf(ac->dom_req, - "(&(objectSid=%s)(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain)))", - ldap_encode_ndr_dom_sid(ac->dom_req, ac->domain_sid)); - if (filter == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, "Out of Memory!\n"); - talloc_free(ac->dom_req); - return LDB_ERR_OPERATIONS_ERROR; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - ac->dom_req->op.search.tree = ldb_parse_tree(ac->dom_req, filter); - if (ac->dom_req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, "Invalid search filter"); - talloc_free(ac->dom_req); - return LDB_ERR_OPERATIONS_ERROR; + if (ares->type != LDB_REPLY_DONE) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ac->dom_req->op.search.attrs = attrs; - ac->dom_req->controls = NULL; - ac->dom_req->context = ac; - ac->dom_req->callback = get_domain_data_callback; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->dom_req); - return LDB_SUCCESS; + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } -static struct domain_data *get_domain_data(struct ldb_module *module, void *ctx, struct ldb_reply *res) +static int password_hash_add_do_add(struct ph_context *ac); +static int ph_modify_callback(struct ldb_request *req, struct ldb_reply *ares); +static int password_hash_mod_search_self(struct ph_context *ac); +static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares); +static int password_hash_mod_do_mod(struct ph_context *ac); + +static int get_domain_data_callback(struct ldb_request *req, + struct ldb_reply *ares) { struct domain_data *data; - const char *tmp; struct ph_context *ac; + int ret; + char *tmp; char *p; - ac = talloc_get_type(ctx, struct ph_context); + ac = talloc_get_type(req->context, struct ph_context); - data = talloc_zero(ac, struct domain_data); - if (data == NULL) { - return NULL; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - - if (res == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Could not find this user's domain: %s!\n", dom_sid_string(data, ac->domain_sid)); - talloc_free(data); - return NULL; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - data->pwdProperties= samdb_result_uint(res->message, "pwdProperties", 0); - data->store_cleartext = data->pwdProperties & DOMAIN_PASSWORD_STORE_CLEARTEXT; - data->pwdHistoryLength = samdb_result_uint(res->message, "pwdHistoryLength", 0); + switch (ares->type) { + case LDB_REPLY_ENTRY: + if (ac->domain != NULL) { + ldb_set_errstring(ac->module->ldb, "Too many results"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + data = talloc_zero(ac, struct domain_data); + if (data == NULL) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - /* For a domain DN, this puts things in dotted notation */ - /* For builtin domains, this will give details for the host, - * but that doesn't really matter, as it's just used for salt - * and kerberos principals, which don't exist here */ + data->pwdProperties = samdb_result_uint(ares->message, "pwdProperties", 0); + data->store_cleartext = data->pwdProperties & DOMAIN_PASSWORD_STORE_CLEARTEXT; + data->pwdHistoryLength = samdb_result_uint(ares->message, "pwdHistoryLength", 0); - tmp = ldb_dn_canonical_string(ctx, res->message->dn); - if (!tmp) { - return NULL; - } - - /* But it puts a trailing (or just before 'builtin') / on things, so kill that */ - p = strchr(tmp, '/'); - if (p) { - p[0] = '\0'; - } + /* For a domain DN, this puts things in dotted notation */ + /* For builtin domains, this will give details for the host, + * but that doesn't really matter, as it's just used for salt + * and kerberos principals, which don't exist here */ + + tmp = ldb_dn_canonical_string(data, ares->message->dn); + if (!tmp) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + /* But it puts a trailing (or just before 'builtin') / on things, so kill that */ + p = strchr(tmp, '/'); + if (p) { + p[0] = '\0'; + } - if (tmp != NULL) { data->dns_domain = strlower_talloc(data, tmp); if (data->dns_domain == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Out of memory!\n"); - return NULL; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } data->realm = strupper_talloc(data, tmp); if (data->realm == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Out of memory!\n"); - return NULL; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } + /* FIXME: NetbIOS name is *always* the first domain component ?? -SSS */ p = strchr(tmp, '.'); if (p) { p[0] = '\0'; } data->netbios_domain = strupper_talloc(data, tmp); if (data->netbios_domain == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Out of memory!\n"); - return NULL; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + talloc_free(tmp); + ac->domain = data; + break; + + case LDB_REPLY_DONE: + + /* call the next step */ + switch (ac->req->operation) { + case LDB_ADD: + ret = password_hash_add_do_add(ac); + break; + + case LDB_MODIFY: + ret = password_hash_mod_do_mod(ac); + break; + + default: + ret = LDB_ERR_OPERATIONS_ERROR; + break; + } + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); } + + case LDB_REPLY_REFERRAL: + /* ignore */ + break; } - return data; + talloc_free(ares); + return LDB_SUCCESS; +} + +static int build_domain_data_request(struct ph_context *ac) +{ + /* attrs[] is returned from this function in + ac->dom_req->op.search.attrs, so it must be static, as + otherwise the compiler can put it on the stack */ + static const char * const attrs[] = { "pwdProperties", "pwdHistoryLength", NULL }; + char *filter; + + filter = talloc_asprintf(ac, + "(&(objectSid=%s)(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain)))", + ldap_encode_ndr_dom_sid(ac, ac->domain_sid)); + if (filter == NULL) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + + return ldb_build_search_req(&ac->dom_req, ac->module->ldb, ac, + ldb_get_default_basedn(ac->module->ldb), + LDB_SCOPE_SUBTREE, + filter, attrs, + NULL, + ac, get_domain_data_callback, + ac->req); } static int password_hash_add(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; struct ph_context *ac; struct ldb_message_element *sambaAttr; + struct ldb_message_element *clearTextPasswordAttr; struct ldb_message_element *ntAttr; struct ldb_message_element *lmAttr; int ret; @@ -1558,7 +1622,7 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - /* nobody must touch this fields */ + /* nobody must touch these fields */ if (ldb_msg_find_element(req->op.add.message, "ntPwdHistory")) { return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -1573,6 +1637,7 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) * or LM hashes, then we don't need to make any changes. */ sambaAttr = ldb_msg_find_element(req->op.mod.message, "userPassword"); + clearTextPasswordAttr = ldb_msg_find_element(req->op.mod.message, "clearTextPassword"); ntAttr = ldb_msg_find_element(req->op.mod.message, "unicodePwd"); lmAttr = ldb_msg_find_element(req->op.mod.message, "dBCSPwd"); @@ -1593,6 +1658,10 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) ldb_set_errstring(module->ldb, "mupltiple values for userPassword not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } + if (clearTextPasswordAttr && clearTextPasswordAttr->num_values > 1) { + ldb_set_errstring(module->ldb, "mupltiple values for clearTextPassword not allowed!\n"); + return LDB_ERR_CONSTRAINT_VIOLATION; + } if (ntAttr && (ntAttr->num_values > 1)) { ldb_set_errstring(module->ldb, "mupltiple values for unicodePwd not allowed!\n"); @@ -1608,6 +1677,11 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_CONSTRAINT_VIOLATION; } + if (clearTextPasswordAttr && clearTextPasswordAttr->num_values == 0) { + ldb_set_errstring(module->ldb, "clearTextPassword must have a value!\n"); + return LDB_ERR_CONSTRAINT_VIOLATION; + } + if (ntAttr && (ntAttr->num_values == 0)) { ldb_set_errstring(module->ldb, "unicodePwd must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; @@ -1617,16 +1691,16 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_CONSTRAINT_VIOLATION; } - h = ph_init_handle(req, module, PH_ADD); - if (!h) { + ac = ph_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct ph_context); /* get user domain data */ ac->domain_sid = samdb_result_sid_prefix(ac, req->op.add.message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "can't handle entry with missing objectSid!\n"); + ldb_debug(module->ldb, LDB_DEBUG_ERROR, + "can't handle entry with missing objectSid!\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -1635,51 +1709,33 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) return ret; } - ac->step = PH_ADD_SEARCH_DOM; - - req->handle = h; - return ldb_next_request(module, ac->dom_req); } -static int password_hash_add_do_add(struct ldb_handle *h) { +static int password_hash_add_do_add(struct ph_context *ac) { - struct ph_context *ac; - struct domain_data *domain; + struct ldb_request *down_req; struct smb_krb5_context *smb_krb5_context; struct ldb_message *msg; struct setup_password_fields_io io; int ret; - ac = talloc_get_type(h->private_data, struct ph_context); - - domain = get_domain_data(ac->module, ac, ac->dom_res); - if (domain == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ac->down_req = talloc(ac, struct ldb_request); - if (ac->down_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->down_req) = *(ac->orig_req); - ac->down_req->op.add.message = msg = ldb_msg_copy_shallow(ac->down_req, ac->orig_req->op.add.message); - if (ac->down_req->op.add.message == NULL) { + msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message); + if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } /* Some operations below require kerberos contexts */ - if (smb_krb5_init_context(ac->down_req, - ldb_get_opaque(h->module->ldb, "EventContext"), - (struct loadparm_context *)ldb_get_opaque(h->module->ldb, "loadparm"), + if (smb_krb5_init_context(ac, + ldb_get_event_context(ac->module->ldb), + (struct loadparm_context *)ldb_get_opaque(ac->module->ldb, "loadparm"), &smb_krb5_context) != 0) { return LDB_ERR_OPERATIONS_ERROR; } ZERO_STRUCT(io); io.ac = ac; - io.domain = domain; + io.domain = ac->domain; io.smb_krb5_context = smb_krb5_context; io.u.user_account_control = samdb_result_uint(msg, "userAccountControl", 0); @@ -1687,12 +1743,14 @@ static int password_hash_add_do_add(struct ldb_handle *h) { io.u.user_principal_name = samdb_result_string(msg, "userPrincipalName", NULL); io.u.is_computer = ldb_msg_check_string_attribute(msg, "objectClass", "computer"); - io.n.cleartext = samdb_result_string(msg, "userPassword", NULL); + io.n.cleartext_utf8 = ldb_msg_find_ldb_val(msg, "userPassword"); + io.n.cleartext_utf16 = ldb_msg_find_ldb_val(msg, "clearTextPassword"); io.n.nt_hash = samdb_result_hash(io.ac, msg, "unicodePwd"); io.n.lm_hash = samdb_result_hash(io.ac, msg, "dBCSPwd"); /* remove attributes */ - if (io.n.cleartext) ldb_msg_remove_attr(msg, "userPassword"); + if (io.n.cleartext_utf8) ldb_msg_remove_attr(msg, "userPassword"); + if (io.n.cleartext_utf16) ldb_msg_remove_attr(msg, "clearTextPassword"); if (io.n.nt_hash) ldb_msg_remove_attr(msg, "unicodePwd"); if (io.n.lm_hash) ldb_msg_remove_attr(msg, "dBCSPwd"); ldb_msg_remove_attr(msg, "pwdLastSet"); @@ -1756,27 +1814,28 @@ static int password_hash_add_do_add(struct ldb_handle *h) { return ret; } - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = PH_ADD_DO_ADD; - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->down_req); + ret = ldb_build_add_req(&down_req, ac->module->ldb, ac, + msg, + ac->req->controls, + ac, ph_op_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; + } - /* perform the operation */ - return ldb_next_request(ac->module, ac->down_req); + return ldb_next_request(ac->module, down_req); } -static int password_hash_mod_search_self(struct ldb_handle *h); - static int password_hash_modify(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; struct ph_context *ac; struct ldb_message_element *sambaAttr; + struct ldb_message_element *clearTextAttr; struct ldb_message_element *ntAttr; struct ldb_message_element *lmAttr; struct ldb_message *msg; + struct ldb_request *down_req; + int ret; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "password_hash_modify\n"); @@ -1802,13 +1861,16 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r } sambaAttr = ldb_msg_find_element(req->op.mod.message, "userPassword"); + clearTextAttr = ldb_msg_find_element(req->op.mod.message, "clearTextPassword"); ntAttr = ldb_msg_find_element(req->op.mod.message, "unicodePwd"); lmAttr = ldb_msg_find_element(req->op.mod.message, "dBCSPwd"); - /* If no part of this touches the userPassword OR unicodePwd and/or dBCSPwd, then we don't - * need to make any changes. For password changes/set there should - * be a 'delete' or a 'modify' on this attribute. */ - if ((!sambaAttr) && (!ntAttr) && (!lmAttr)) { + /* If no part of this touches the userPassword OR + * clearTextPassword OR unicodePwd and/or dBCSPwd, then we + * don't need to make any changes. For password changes/set + * there should be a 'delete' or a 'modify' on this + * attribute. */ + if ((!sambaAttr) && (!clearTextAttr) && (!ntAttr) && (!lmAttr)) { return ldb_next_request(module, req); } @@ -1817,6 +1879,9 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r if (sambaAttr && (sambaAttr->num_values > 1)) { return LDB_ERR_CONSTRAINT_VIOLATION; } + if (clearTextAttr && (clearTextAttr->num_values > 1)) { + return LDB_ERR_CONSTRAINT_VIOLATION; + } if (ntAttr && (ntAttr->num_values > 1)) { return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -1824,83 +1889,144 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r return LDB_ERR_CONSTRAINT_VIOLATION; } - h = ph_init_handle(req, module, PH_MOD); - if (!h) { + ac = ph_init_context(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct ph_context); - /* return or own handle to deal with this call */ - req->handle = h; - - /* prepare the first operation */ - ac->down_req = talloc_zero(ac, struct ldb_request); - if (ac->down_req == NULL) { - ldb_set_errstring(module->ldb, "Out of memory!"); + /* use a new message structure so that we can modify it */ + msg = ldb_msg_copy_shallow(ac, req->op.mod.message); + if (msg == NULL) { + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - *(ac->down_req) = *req; /* copy the request */ - - /* use a new message structure so that we can modify it */ - ac->down_req->op.mod.message = msg = ldb_msg_copy_shallow(ac->down_req, req->op.mod.message); - - /* - remove any imodification to the password from the first commit + /* - remove any modification to the password from the first commit * we will make the real modification later */ if (sambaAttr) ldb_msg_remove_attr(msg, "userPassword"); + if (clearTextAttr) ldb_msg_remove_attr(msg, "clearTextPassword"); if (ntAttr) ldb_msg_remove_attr(msg, "unicodePwd"); if (lmAttr) ldb_msg_remove_attr(msg, "dBCSPwd"); - /* if there was nothing else to be modify skip to next step */ + /* if there was nothing else to be modified skip to next step */ if (msg->num_elements == 0) { - talloc_free(ac->down_req); - ac->down_req = NULL; - return password_hash_mod_search_self(h); + return password_hash_mod_search_self(ac); } - - ac->down_req->context = NULL; - ac->down_req->callback = NULL; - ac->step = PH_MOD_DO_REQ; + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, ph_modify_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; + } + + return ldb_next_request(module, down_req); +} + +static int ph_modify_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct ph_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct ph_context); - ldb_set_timeout_from_prev_req(module->ldb, req, ac->down_req); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - return ldb_next_request(module, ac->down_req); + if (ares->type != LDB_REPLY_DONE) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + ret = password_hash_mod_search_self(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + talloc_free(ares); + return LDB_SUCCESS; } -static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { struct ph_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct ph_context); - ac = talloc_get_type(context, struct ph_context); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + /* we are interested only in the single reply (base search) */ + switch (ares->type) { + case LDB_REPLY_ENTRY: - /* we are interested only in the single reply (base search) we receive here */ - if (ares->type == LDB_REPLY_ENTRY) { if (ac->search_res != NULL) { - ldb_set_errstring(ldb, "Too many results"); + ldb_set_errstring(ac->module->ldb, "Too many results"); talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } /* if it is not an entry of type person this is an error */ - /* TODO: remove this when userPassword will be in schema */ + /* TODO: remove this when sambaPassword will be in schema */ if (!ldb_msg_check_string_attribute(ares->message, "objectClass", "person")) { - ldb_set_errstring(ldb, "Object class violation"); + ldb_set_errstring(ac->module->ldb, "Object class violation"); talloc_free(ares); - return LDB_ERR_OBJECT_CLASS_VIOLATION; + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OBJECT_CLASS_VIOLATION); } ac->search_res = talloc_steal(ac, ares); - } else { - talloc_free(ares); + return LDB_SUCCESS; + + case LDB_REPLY_DONE: + + /* get object domain sid */ + ac->domain_sid = samdb_result_sid_prefix(ac, + ac->search_res->message, + "objectSid"); + if (ac->domain_sid == NULL) { + ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, + "can't handle entry without objectSid!\n"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + /* get user domain data */ + ret = build_domain_data_request(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL,ret); + } + + return ldb_next_request(ac->module, ac->dom_req); + + case LDB_REPLY_REFERRAL: + /*ignore anything else for now */ + break; } + talloc_free(ares); return LDB_SUCCESS; } -static int password_hash_mod_search_self(struct ldb_handle *h) { +static int password_hash_mod_search_self(struct ph_context *ac) { - struct ph_context *ac; static const char * const attrs[] = { "userAccountControl", "lmPwdHistory", "ntPwdHistory", "objectSid", "msDS-KeyVersionNumber", @@ -1909,64 +2035,28 @@ static int password_hash_mod_search_self(struct ldb_handle *h) { "dBCSPwd", "unicodePwd", "supplementalCredentials", NULL }; - - ac = talloc_get_type(h->private_data, struct ph_context); - - /* prepare the search operation */ - ac->search_req = talloc_zero(ac, struct ldb_request); - if (ac->search_req == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, "Out of Memory!\n"); - return LDB_ERR_OPERATIONS_ERROR; - } - - ac->search_req->operation = LDB_SEARCH; - ac->search_req->op.search.base = ac->orig_req->op.mod.message->dn; - ac->search_req->op.search.scope = LDB_SCOPE_BASE; - ac->search_req->op.search.tree = ldb_parse_tree(ac->search_req, NULL); - if (ac->search_req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, "Invalid search filter"); - return LDB_ERR_OPERATIONS_ERROR; - } - ac->search_req->op.search.attrs = attrs; - ac->search_req->controls = NULL; - ac->search_req->context = ac; - ac->search_req->callback = get_self_callback; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->search_req); - - ac->step = PH_MOD_SEARCH_SELF; - - return ldb_next_request(ac->module, ac->search_req); -} - -static int password_hash_mod_search_dom(struct ldb_handle *h) { - - struct ph_context *ac; + struct ldb_request *search_req; int ret; - ac = talloc_get_type(h->private_data, struct ph_context); + ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ac->req->op.mod.message->dn, + LDB_SCOPE_BASE, + "(objectclass=*)", + attrs, + NULL, + ac, ph_mod_search_callback, + ac->req); - /* get object domain sid */ - ac->domain_sid = samdb_result_sid_prefix(ac, ac->search_res->message, "objectSid"); - if (ac->domain_sid == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, "can't handle entry with missing objectSid!\n"); - return LDB_ERR_OPERATIONS_ERROR; - } - - /* get user domain data */ - ret = build_domain_data_request(ac); if (ret != LDB_SUCCESS) { return ret; } - ac->step = PH_MOD_SEARCH_DOM; - - return ldb_next_request(ac->module, ac->dom_req); + return ldb_next_request(ac->module, search_req); } -static int password_hash_mod_do_mod(struct ldb_handle *h) { +static int password_hash_mod_do_mod(struct ph_context *ac) { - struct ph_context *ac; - struct domain_data *domain; + struct ldb_request *mod_req; struct smb_krb5_context *smb_krb5_context; struct ldb_message *msg; struct ldb_message *orig_msg; @@ -1974,43 +2064,29 @@ static int password_hash_mod_do_mod(struct ldb_handle *h) { struct setup_password_fields_io io; int ret; - ac = talloc_get_type(h->private_data, struct ph_context); - - domain = get_domain_data(ac->module, ac, ac->dom_res); - if (domain == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ac->mod_req = talloc(ac, struct ldb_request); - if (ac->mod_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->mod_req) = *(ac->orig_req); - /* use a new message structure so that we can modify it */ - ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req); + msg = ldb_msg_new(ac); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } /* modify dn */ - msg->dn = ac->orig_req->op.mod.message->dn; + msg->dn = ac->req->op.mod.message->dn; /* Some operations below require kerberos contexts */ - if (smb_krb5_init_context(ac->mod_req, - ldb_get_opaque(h->module->ldb, "EventContext"), - (struct loadparm_context *)ldb_get_opaque(h->module->ldb, "loadparm"), + if (smb_krb5_init_context(ac, + ldb_get_event_context(ac->module->ldb), + (struct loadparm_context *)ldb_get_opaque(ac->module->ldb, "loadparm"), &smb_krb5_context) != 0) { return LDB_ERR_OPERATIONS_ERROR; } - orig_msg = discard_const(ac->orig_req->op.mod.message); + orig_msg = discard_const(ac->req->op.mod.message); searched_msg = ac->search_res->message; ZERO_STRUCT(io); io.ac = ac; - io.domain = domain; + io.domain = ac->domain; io.smb_krb5_context = smb_krb5_context; io.u.user_account_control = samdb_result_uint(searched_msg, "userAccountControl", 0); @@ -2018,7 +2094,8 @@ static int password_hash_mod_do_mod(struct ldb_handle *h) { io.u.user_principal_name = samdb_result_string(searched_msg, "userPrincipalName", NULL); io.u.is_computer = ldb_msg_check_string_attribute(searched_msg, "objectClass", "computer"); - io.n.cleartext = samdb_result_string(orig_msg, "userPassword", NULL); + io.n.cleartext_utf8 = ldb_msg_find_ldb_val(orig_msg, "userPassword"); + io.n.cleartext_utf16 = ldb_msg_find_ldb_val(orig_msg, "clearTextPassword"); io.n.nt_hash = samdb_result_hash(io.ac, orig_msg, "unicodePwd"); io.n.lm_hash = samdb_result_hash(io.ac, orig_msg, "dBCSPwd"); @@ -2093,189 +2170,20 @@ static int password_hash_mod_do_mod(struct ldb_handle *h) { return ret; } - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = PH_MOD_DO_MOD; - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->mod_req); - - /* perform the search */ - return ldb_next_request(ac->module, ac->mod_req); -} - -static int ph_wait(struct ldb_handle *handle) { - struct ph_context *ac; - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct ph_context); - - switch (ac->step) { - case PH_ADD_SEARCH_DOM: - ret = ldb_wait(ac->dom_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->dom_req->handle->status != LDB_SUCCESS) { - handle->status = ac->dom_req->handle->status; - goto done; - } - - if (ac->dom_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* domain search done, go on */ - return password_hash_add_do_add(handle); - - case PH_ADD_DO_ADD: - ret = ldb_wait(ac->down_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req->handle->status; - goto done; - } - - if (ac->down_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - case PH_MOD_DO_REQ: - ret = ldb_wait(ac->down_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req->handle->status; - goto done; - } - - if (ac->down_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* non-password mods done, go on */ - return password_hash_mod_search_self(handle); - - case PH_MOD_SEARCH_SELF: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS) { - handle->status = ac->search_req->handle->status; - goto done; - } - - if (ac->search_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - if (ac->search_res == NULL) { - return LDB_ERR_NO_SUCH_OBJECT; - } - - /* self search done, go on */ - return password_hash_mod_search_dom(handle); - - case PH_MOD_SEARCH_DOM: - ret = ldb_wait(ac->dom_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->dom_req->handle->status != LDB_SUCCESS) { - handle->status = ac->dom_req->handle->status; - goto done; - } - - if (ac->dom_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* domain search done, go on */ - return password_hash_mod_do_mod(handle); - - case PH_MOD_DO_MOD: - ret = ldb_wait(ac->mod_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->mod_req->handle->status != LDB_SUCCESS) { - handle->status = ac->mod_req->handle->status; - goto done; - } - - if (ac->mod_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - - default: - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; - } - - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - -static int ph_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = ph_wait(handle); - if (ret != LDB_SUCCESS) { - return ret; - } + ret = ldb_build_mod_req(&mod_req, ac->module->ldb, ac, + msg, + ac->req->controls, + ac, ph_op_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; } - return handle->status; -} - -static int password_hash_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return ph_wait_all(handle); - } else { - return ph_wait(handle); - } + return ldb_next_request(ac->module, mod_req); } _PUBLIC_ const struct ldb_module_ops ldb_password_hash_module_ops = { .name = "password_hash", .add = password_hash_add, .modify = password_hash_modify, - .wait = password_hash_wait }; diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c index 09d56d77c9..198b667358 100644 --- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c @@ -28,7 +28,7 @@ #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" static int pdc_fsmo_init(struct ldb_module *module) { @@ -63,10 +63,9 @@ static int pdc_fsmo_init(struct ldb_module *module) } module->private_data = pdc_fsmo; - ret = ldb_search(module->ldb, pdc_dn, - LDB_SCOPE_BASE, - NULL, pdc_attrs, - &pdc_res); + ret = ldb_search(module->ldb, mem_ctx, &pdc_res, + pdc_dn, LDB_SCOPE_BASE, + pdc_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { ldb_debug(module->ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n"); @@ -79,7 +78,6 @@ static int pdc_fsmo_init(struct ldb_module *module) talloc_free(mem_ctx); return ret; } - talloc_steal(mem_ctx, pdc_res); if (pdc_res->count == 0) { ldb_debug(module->ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n"); diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 0d065425ca..2ff42297b7 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -50,6 +50,14 @@ struct proxy_data { const char **newstr; }; +struct proxy_ctx { + struct ldb_module *module; + struct ldb_request *req; + +#ifdef DEBUG_PROXY + int count; +#endif +}; /* load the @PROXYINFO record @@ -62,18 +70,17 @@ static int load_proxy_info(struct ldb_module *module) int ret; const char *olddn, *newdn, *url, *username, *password, *oldstr, *newstr; struct cli_credentials *creds; - /* see if we have already loaded it */ if (proxy->upstream != NULL) { - return 0; + return LDB_SUCCESS; } dn = ldb_dn_new(proxy, module->ldb, "@PROXYINFO"); if (dn == NULL) { goto failed; } - ret = ldb_search(module->ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(module->ldb, proxy, &res, dn, LDB_SCOPE_BASE, NULL, NULL); talloc_free(dn); if (ret != LDB_SUCCESS || res->count != 1) { ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Can't find @PROXYINFO\n"); @@ -105,7 +112,7 @@ static int load_proxy_info(struct ldb_module *module) goto failed; } - proxy->upstream = ldb_init(proxy); + proxy->upstream = ldb_init(proxy, ldb_get_event_context(ldb)); if (proxy->upstream == NULL) { ldb_oom(module->ldb); goto failed; @@ -145,7 +152,7 @@ static int load_proxy_info(struct ldb_module *module) talloc_free(res); - return 0; + return LDB_SUCCESS; failed: talloc_free(res); @@ -153,7 +160,7 @@ failed: talloc_free(proxy->newdn); talloc_free(proxy->upstream); proxy->upstream = NULL; - return -1; + return LDB_ERR_OPERATIONS_ERROR; } @@ -180,10 +187,10 @@ static void proxy_convert_blob(TALLOC_CTX *mem_ctx, struct ldb_val *v, /* convert a returned value */ -static void proxy_convert_value(struct ldb_module *module, struct ldb_message *msg, struct ldb_val *v) +static void proxy_convert_value(struct proxy_data *proxy, struct ldb_message *msg, struct ldb_val *v) { - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); int i; + for (i=0;proxy->oldstr[i];i++) { char *p = strcasestr((char *)v->data, proxy->oldstr[i]); if (p == NULL) continue; @@ -195,20 +202,21 @@ static void proxy_convert_value(struct ldb_module *module, struct ldb_message *m /* convert a returned value */ -static struct ldb_parse_tree *proxy_convert_tree(struct ldb_module *module, +static struct ldb_parse_tree *proxy_convert_tree(TALLOC_CTX *mem_ctx, + struct proxy_data *proxy, struct ldb_parse_tree *tree) { - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); int i; - char *expression = ldb_filter_from_tree(module, tree); + char *expression = ldb_filter_from_tree(mem_ctx, tree); + for (i=0;proxy->newstr[i];i++) { struct ldb_val v; char *p = strcasestr(expression, proxy->newstr[i]); if (p == NULL) continue; v.data = (uint8_t *)expression; v.length = strlen(expression)+1; - proxy_convert_blob(module, &v, proxy->newstr[i], proxy->oldstr[i]); - return ldb_parse_tree(module, (const char *)v.data); + proxy_convert_blob(mem_ctx, &v, proxy->newstr[i], proxy->oldstr[i]); + return ldb_parse_tree(mem_ctx, (const char *)v.data); } return tree; } @@ -218,13 +226,14 @@ static struct ldb_parse_tree *proxy_convert_tree(struct ldb_module *module, /* convert a returned record */ -static void proxy_convert_record(struct ldb_module *module, struct ldb_message *msg) +static void proxy_convert_record(struct ldb_context *ldb, + struct proxy_data *proxy, + struct ldb_message *msg) { - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); int attr, v; - + /* fix the message DN */ - if (ldb_dn_compare_base(module->ldb, proxy->olddn, msg->dn) == 0) { + if (ldb_dn_compare_base(proxy->olddn, msg->dn) == 0) { ldb_dn_remove_base_components(msg->dn, ldb_dn_get_comp_num(proxy->olddn)); ldb_dn_add_base(msg->dn, proxy->newdn); } @@ -232,21 +241,71 @@ static void proxy_convert_record(struct ldb_module *module, struct ldb_message * /* fix any attributes */ for (attr=0;attrnum_elements;attr++) { for (v=0;velements[attr].num_values;v++) { - proxy_convert_value(module, msg, &msg->elements[attr].values[v]); + proxy_convert_value(proxy, msg, &msg->elements[attr].values[v]); } } /* fix any DN components */ for (attr=0;attrnum_elements;attr++) { for (v=0;velements[attr].num_values;v++) { - proxy_convert_value(module, msg, &msg->elements[attr].values[v]); + proxy_convert_value(proxy, msg, &msg->elements[attr].values[v]); } } } +static int proxy_search_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct proxy_data *proxy; + struct proxy_ctx *ac; + int ret; + + ac = talloc_get_type(req->context, struct proxy_ctx); + proxy = talloc_get_type(ac->module->private_data, struct proxy_data); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + /* Only entries are interesting, and we only want the olddn */ + switch (ares->type) { + case LDB_REPLY_ENTRY: + +#ifdef DEBUG_PROXY + ac->count++; +#endif + proxy_convert_record(ac->module->ldb, proxy, ares->message); + ret = ldb_module_send_entry(ac->req, ares->message); + break; + + case LDB_REPLY_REFERRAL: + + /* ignore remote referrals */ + break; + + case LDB_REPLY_DONE: + +#ifdef DEBUG_PROXY + printf("# record %d\n", ac->count+1); +#endif + + return ldb_module_done(ac->req, NULL, NULL, LDB_SUCCESS); + } + + talloc_free(ares); + return ret; +} + /* search */ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *req) { + struct proxy_ctx *ac; + struct ldb_parse_tree *newtree; struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); struct ldb_request *newreq; struct ldb_dn *base; @@ -258,56 +317,59 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re goto passthru; } - if (load_proxy_info(module) != 0) { - return -1; + if (load_proxy_info(module) != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } /* see if the dn is within olddn */ - if (ldb_dn_compare_base(module->ldb, proxy->newdn, req->op.search.base) != 0) { + if (ldb_dn_compare_base(proxy->newdn, req->op.search.base) != 0) { goto passthru; } - newreq = talloc(module, struct ldb_request); - if (newreq == NULL) { - return -1; + ac = talloc(req, struct proxy_ctx); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; } - newreq->op.search.tree = proxy_convert_tree(module, req->op.search.tree); + ac->module = module; + ac->req = req; +#ifdef DEBUG_PROXY + ac->count = 0; +#endif + + newtree = proxy_convert_tree(ac, proxy, req->op.search.tree); /* convert the basedn of this search */ - base = ldb_dn_copy(proxy, req->op.search.base); + base = ldb_dn_copy(ac, req->op.search.base); if (base == NULL) { - talloc_free(newreq); goto failed; } ldb_dn_remove_base_components(base, ldb_dn_get_comp_num(proxy->newdn)); ldb_dn_add_base(base, proxy->olddn); ldb_debug(module->ldb, LDB_DEBUG_FATAL, "proxying: '%s' with dn '%s' \n", - ldb_filter_from_tree(proxy, newreq->op.search.tree), ldb_dn_get_linearized(newreq->op.search.base)); + ldb_filter_from_tree(ac, newreq->op.search.tree), ldb_dn_get_linearized(newreq->op.search.base)); for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { ldb_debug(module->ldb, LDB_DEBUG_FATAL, "attr: '%s'\n", req->op.search.attrs[i]); } - newreq->op.search.base = base; - newreq->op.search.scope = req->op.search.scope; - newreq->op.search.attrs = req->op.search.attrs; - newreq->op.search.res = req->op.search.res; - newreq->controls = req->controls; + ret = ldb_build_search_req_ex(&newreq, module->ldb, ac, + base, req->op.search.scope, + newtree, req->op.search.attrs, + req->controls, + ac, proxy_search_callback, + req); + + /* FIXME: warning, need a real event system hooked up for this to work properly, + * for now this makes the module *not* ASYNC */ ret = ldb_request(proxy->upstream, newreq); if (ret != LDB_SUCCESS) { ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); - talloc_free(newreq); - return -1; } - - for (i = 0; i < newreq->op.search.res->count; i++) { - printf("# record %d\n", i+1); - - proxy_convert_record(module, newreq->op.search.res->msgs[i]); + ret = ldb_wait(newreq->handle, LDB_WAIT_ALL); + if (ret != LDB_SUCCESS) { + ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); } - - talloc_free(newreq); return ret; failed: diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c index c6ebea1044..b8e43a7e88 100644 --- a/source4/dsdb/samdb/ldb_modules/ranged_results.c +++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c @@ -32,57 +32,89 @@ #include "ldb_includes.h" struct rr_context { - struct ldb_request *orig_req; - struct ldb_request *down_req; + struct ldb_module *module; + struct ldb_request *req; }; -static int rr_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static struct rr_context *rr_init_context(struct ldb_module *module, + struct ldb_request *req) { - struct rr_context *rr_context = talloc_get_type(context, struct rr_context); - struct ldb_request *orig_req = rr_context->orig_req; + struct rr_context *ac; + + ac = talloc_zero(req, struct rr_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return NULL; + } + + ac->module = module; + ac->req = req; + + return ac; +} + +static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct rr_context *ac; int i, j; - - if (ares->type != LDB_REPLY_ENTRY) { - return rr_context->orig_req->callback(ldb, rr_context->orig_req->context, ares); + + ac = talloc_get_type(req->context, struct rr_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type == LDB_REPLY_REFERRAL) { + return ldb_module_send_referral(ac->req, ares->referral); } + if (ares->type == LDB_REPLY_DONE) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + /* LDB_REPLY_ENTRY */ + /* Find those that are range requests from the attribute list */ - for (i = 0; orig_req->op.search.attrs[i]; i++) { + for (i = 0; ac->req->op.search.attrs[i]; i++) { char *p, *new_attr; const char *end_str; unsigned int start, end, orig_num_values; struct ldb_message_element *el; struct ldb_val *orig_values; - p = strchr(orig_req->op.search.attrs[i], ';'); + p = strchr(ac->req->op.search.attrs[i], ';'); if (!p) { continue; } if (strncasecmp(p, ";range=", strlen(";range=")) != 0) { continue; } - if (sscanf(p, ";range=%u-%u", &start, &end) == 2) { - } else if (sscanf(p, ";range=%u-*", &start) == 1) { - end = (unsigned int)-1; - } else { - continue; + if (sscanf(p, ";range=%u-%u", &start, &end) != 2) { + if (sscanf(p, ";range=%u-*", &start) == 1) { + end = (unsigned int)-1; + } else { + continue; + } } - new_attr = talloc_strndup(orig_req, - orig_req->op.search.attrs[i], - (unsigned int)(p-orig_req->op.search.attrs[i])); + new_attr = talloc_strndup(ac->req, + ac->req->op.search.attrs[i], + (size_t)(p - ac->req->op.search.attrs[i])); if (!new_attr) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } el = ldb_msg_find_element(ares->message, new_attr); talloc_free(new_attr); if (!el) { continue; } - if (start > end) { - ldb_asprintf_errstring(ldb, "range request error: start must not be greater than end"); - return LDB_ERR_UNWILLING_TO_PERFORM; - } if (end >= (el->num_values - 1)) { /* Need to leave the requested attribute in * there (so add an empty one to match) */ @@ -91,11 +123,12 @@ static int rr_search_callback(struct ldb_context *ldb, void *context, struct ldb } else { end_str = talloc_asprintf(el, "%u", end); if (!end_str) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } } - /* If start is greater then where we noe find the end to be */ + /* If start is greater then where we are find the end to be */ if (start > end) { el->num_values = 0; el->values = NULL; @@ -104,16 +137,19 @@ static int rr_search_callback(struct ldb_context *ldb, void *context, struct ldb orig_num_values = el->num_values; if ((start + end < start) || (start + end < end)) { - ldb_asprintf_errstring(ldb, "range request error: start or end would overflow!"); - return LDB_ERR_UNWILLING_TO_PERFORM; + ldb_asprintf_errstring(ac->module->ldb, + "range request error: start or end would overflow!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_UNWILLING_TO_PERFORM); } el->num_values = 0; el->values = talloc_array(el, struct ldb_val, (end - start) + 1); if (!el->values) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } for (j=start; j <= end; j++) { el->values[el->num_values] = orig_values[j]; @@ -122,13 +158,13 @@ static int rr_search_callback(struct ldb_context *ldb, void *context, struct ldb } el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str); if (!el->name) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } } - return rr_context->orig_req->callback(ldb, rr_context->orig_req->context, ares); - + return ldb_module_send_entry(ac->req, ares->message); } /* search */ @@ -137,8 +173,10 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) int i; unsigned int start, end; const char **new_attrs = NULL; - struct rr_context *context; bool found_rr = false; + struct ldb_request *down_req; + struct rr_context *ac; + int ret; /* Strip the range request from the attribute */ for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { @@ -146,19 +184,21 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) new_attrs = talloc_realloc(req, new_attrs, const char *, i+2); new_attrs[i] = req->op.search.attrs[i]; new_attrs[i+1] = NULL; - p = strchr(req->op.search.attrs[i], ';'); + p = strchr(new_attrs[i], ';'); if (!p) { continue; } if (strncasecmp(p, ";range=", strlen(";range=")) != 0) { continue; } - if (sscanf(p, ";range=%u-%u", &start, &end) == 2) { - } else if (sscanf(p, ";range=%u-*", &start) == 1) { - end = (unsigned int)-1; - } else { - ldb_asprintf_errstring(module->ldb, "range request error: range requst malformed"); - return LDB_ERR_UNWILLING_TO_PERFORM; + end = (unsigned int)-1; + if (sscanf(p, ";range=%u-*", &start) != 1) { + if (sscanf(p, ";range=%u-%u", &start, &end) != 2) { + ldb_asprintf_errstring(module->ldb, + "range request error: " + "range request malformed"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } } if (start > end) { ldb_asprintf_errstring(module->ldb, "range request error: start must not be greater than end"); @@ -166,9 +206,8 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) } found_rr = true; - new_attrs[i] = talloc_strndup(new_attrs, - req->op.search.attrs[i], - (unsigned int)(p-req->op.search.attrs[i])); + new_attrs[i] = talloc_strndup(new_attrs, new_attrs[i], + (size_t)(p - new_attrs[i])); if (!new_attrs[i]) { ldb_oom(module->ldb); @@ -177,27 +216,27 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) } if (found_rr) { - int ret; - context = talloc(req, struct rr_context); - context->orig_req = req; - context->down_req = talloc(context, struct ldb_request); - *context->down_req = *req; - - context->down_req->op.search.attrs = new_attrs; - - context->down_req->callback = rr_search_callback; - context->down_req->context = context; - - ret = ldb_next_request(module, context->down_req); - - /* We don't need to implement our own 'wait' function, so pass the handle along */ - if (ret == LDB_SUCCESS) { - req->handle = context->down_req->handle; + ac = rr_init_context(module, req); + if (!ac) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + new_attrs, + req->controls, + ac, rr_search_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; + return ldb_next_request(module, down_req); } /* No change, just run the original request as if we were never here */ + talloc_free(new_attrs); return ldb_next_request(module, req); } diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index dd5faf837a..f30748c85c 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2004-2006 + Copyright (C) Simo Sorce 2004-2008 Copyright (C) Andrew Bartlett 2005 Copyright (C) Andrew Tridgell 2005 Copyright (C) Stefan Metzmacher 2007 @@ -51,68 +51,34 @@ struct replmd_replicated_request { struct ldb_module *module; - struct ldb_handle *handle; - struct ldb_request *orig_req; + struct ldb_request *req; const struct dsdb_schema *schema; struct dsdb_extended_replicated_objects *objs; + /* the controls we pass down */ + struct ldb_control **controls; + uint32_t index_current; - struct { - TALLOC_CTX *mem_ctx; - struct ldb_request *search_req; - struct ldb_message *search_msg; - int search_ret; - struct ldb_request *change_req; - int change_ret; - } sub; + struct ldb_message *search_msg; }; -static struct replmd_replicated_request *replmd_replicated_init_handle(struct ldb_module *module, - struct ldb_request *req, - struct dsdb_extended_replicated_objects *objs) +static struct replmd_replicated_request *replmd_ctx_init(struct ldb_module *module, + struct ldb_request *req) { - struct replmd_replicated_request *ar; - struct ldb_handle *h; - const struct dsdb_schema *schema; - - schema = dsdb_get_schema(module->ldb); - if (!schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, - "replmd_replicated_init_handle: no loaded schema found\n"); - return NULL; - } + struct replmd_replicated_request *ac; - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - h->state = LDB_ASYNC_PENDING; - h->status = LDB_SUCCESS; - - ar = talloc_zero(h, struct replmd_replicated_request); - if (ar == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); + ac = talloc_zero(req, struct replmd_replicated_request); + if (ac == NULL) { + ldb_oom(module->ldb); return NULL; } - h->private_data = ar; - - ar->module = module; - ar->handle = h; - ar->orig_req = req; - ar->schema = schema; - ar->objs = objs; - - req->handle = h; - - return ar; + ac->module = module; + ac->req = req; + return ac; } /* @@ -124,16 +90,16 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t) char *s; if (ldb_msg_find_element(msg, attr) != NULL) { - return 0; + return LDB_SUCCESS; } s = ldb_timestring(msg, t); if (s == NULL) { - return -1; + return LDB_ERR_OPERATIONS_ERROR; } - if (ldb_msg_add_string(msg, attr, s) != 0) { - return -1; + if (ldb_msg_add_string(msg, attr, s) != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } el = ldb_msg_find_element(msg, attr); @@ -141,7 +107,7 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t) is ignored */ el->flags = LDB_FLAG_MOD_REPLACE; - return 0; + return LDB_SUCCESS; } /* @@ -152,11 +118,11 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ struct ldb_message_element *el; if (ldb_msg_find_element(msg, attr) != NULL) { - return 0; + return LDB_SUCCESS; } - if (ldb_msg_add_fmt(msg, attr, "%llu", (unsigned long long)v) != 0) { - return -1; + if (ldb_msg_add_fmt(msg, attr, "%llu", (unsigned long long)v) != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } el = ldb_msg_find_element(msg, attr); @@ -164,7 +130,7 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ is ignored */ el->flags = LDB_FLAG_MOD_REPLACE; - return 0; + return LDB_SUCCESS; } static int replmd_replPropertyMetaData1_attid_sort(const struct replPropertyMetaData1 *m1, @@ -236,34 +202,37 @@ static void replmd_ldb_message_sort(struct ldb_message *msg, discard_const_p(void, schema), (ldb_qsort_cmp_fn_t)replmd_ldb_message_element_attid_sort); } -static int replmd_prepare_originating(struct ldb_module *module, struct ldb_request *req, - struct ldb_dn *dn, const char *fn_name, - int (*fn)(struct ldb_module *, - struct ldb_request *, - const struct dsdb_schema *)) +static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) { - const struct dsdb_schema *schema; - - /* do not manipulate our control entries */ - if (ldb_dn_is_special(dn)) { - return ldb_next_request(module, req); + struct replmd_replicated_request *ac; + + ac = talloc_get_type(req->context, struct replmd_replicated_request); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - schema = dsdb_get_schema(module->ldb); - if (!schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, - "%s: no dsdb_schema loaded", - fn_name); - return LDB_ERR_CONSTRAINT_VIOLATION; + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, + "invalid ldb_reply_type in callback"); + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - return fn(module, req, schema); + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); } -static int replmd_add_originating(struct ldb_module *module, - struct ldb_request *req, - const struct dsdb_schema *schema) +static int replmd_add(struct ldb_module *module, struct ldb_request *req) { + struct replmd_replicated_request *ac; + const struct dsdb_schema *schema; enum ndr_err_code ndr_err; struct ldb_request *down_req; struct ldb_message *msg; @@ -280,11 +249,30 @@ static int replmd_add_originating(struct ldb_module *module, int ret; uint32_t i, ni=0; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add_originating\n"); + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.add.message->dn)) { + return ldb_next_request(module, req); + } + + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add\n"); + + schema = dsdb_get_schema(module->ldb); + if (!schema) { + ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + "replmd_modify: no dsdb_schema loaded"); + return LDB_ERR_CONSTRAINT_VIOLATION; + } + + ac = replmd_ctx_init(module, req); + if (!ac) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->schema = schema; - if (ldb_msg_find_element(req->op.add.message, "objectGUID")) { + if (ldb_msg_find_element(req->op.add.message, "objectGUID") != NULL) { ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, - "replmd_add_originating: it's not allowed to add an object with objectGUID\n"); + "replmd_add: it's not allowed to add an object with objectGUID\n"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -301,22 +289,13 @@ static int replmd_add_originating(struct ldb_module *module, our_invocation_id = samdb_ntds_invocation_id(module->ldb); if (!our_invocation_id) { ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, - "replmd_add_originating: unable to find invocationId\n"); - return LDB_ERR_OPERATIONS_ERROR; - } - - /* create a copy of the request */ - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { - ldb_oom(module->ldb); + "replmd_add: unable to find invocationId\n"); return LDB_ERR_OPERATIONS_ERROR; } - *down_req = *req; /* we have to copy the message as the caller might have it as a const */ - down_req->op.add.message = msg = ldb_msg_copy_shallow(down_req, req->op.add.message); + msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -325,7 +304,6 @@ static int replmd_add_originating(struct ldb_module *module, unix_to_nt_time(&now, t); time_str = ldb_timestring(msg, t); if (!time_str) { - talloc_free(down_req); return LDB_ERR_OPERATIONS_ERROR; } @@ -343,7 +321,6 @@ static int replmd_add_originating(struct ldb_module *module, */ ret = ldb_msg_add_string(msg, "whenCreated", time_str); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -356,7 +333,6 @@ static int replmd_add_originating(struct ldb_module *module, struct replPropertyMetaData1, nmd.ctr.ctr1.count); if (!nmd.ctr.ctr1.array) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -371,9 +347,8 @@ static int replmd_add_originating(struct ldb_module *module, sa = dsdb_attribute_by_lDAPDisplayName(schema, e->name); if (!sa) { ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, - "replmd_add_originating: attribute '%s' not defined in schema\n", + "replmd_add: attribute '%s' not defined in schema\n", e->name); - talloc_free(down_req); return LDB_ERR_NO_SUCH_ATTRIBUTE; } @@ -419,7 +394,6 @@ static int replmd_add_originating(struct ldb_module *module, &nmd, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -429,31 +403,26 @@ static int replmd_add_originating(struct ldb_module *module, */ ret = ldb_msg_add_value(msg, "objectGUID", &guid_value, NULL); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "whenChanged", time_str); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = samdb_msg_add_uint64(module->ldb, msg, msg, "uSNCreated", seq_num); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = samdb_msg_add_uint64(module->ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_value(msg, "replPropertyMetaData", &nmd_value, NULL); if (ret != LDB_SUCCESS) { - talloc_free(down_req); ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -463,49 +432,54 @@ static int replmd_add_originating(struct ldb_module *module, */ replmd_ldb_message_sort(msg, schema); - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_add_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, replmd_op_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; -} - -static int replmd_add(struct ldb_module *module, struct ldb_request *req) -{ - return replmd_prepare_originating(module, req, req->op.add.message->dn, - "replmd_add", replmd_add_originating); + /* go on with the call chain */ + return ldb_next_request(module, down_req); } -static int replmd_modify_originating(struct ldb_module *module, - struct ldb_request *req, - const struct dsdb_schema *schema) +static int replmd_modify(struct ldb_module *module, struct ldb_request *req) { + struct replmd_replicated_request *ac; + const struct dsdb_schema *schema; struct ldb_request *down_req; struct ldb_message *msg; int ret; time_t t = time(NULL); uint64_t seq_num; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify_originating\n"); + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.mod.message->dn)) { + return ldb_next_request(module, req); + } + + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); + + schema = dsdb_get_schema(module->ldb); + if (!schema) { + ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + "replmd_modify: no dsdb_schema loaded"); + return LDB_ERR_CONSTRAINT_VIOLATION; + } - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { + ac = replmd_ctx_init(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - *down_req = *req; + ac->schema = schema; /* we have to copy the message as the caller might have it as a const */ - down_req->op.mod.message = msg = ldb_msg_copy_shallow(down_req, req->op.mod.message); + msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - talloc_free(down_req); + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } @@ -521,16 +495,16 @@ static int replmd_modify_originating(struct ldb_module *module, * - calculate the new replPropertyMetaData attribute */ - if (add_time_element(msg, "whenChanged", t) != 0) { - talloc_free(down_req); + if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) { + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } /* Get a sequence number from the backend */ ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { - if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) { - talloc_free(down_req); + if (add_uint64_element(msg, "uSNChanged", seq_num) != LDB_SUCCESS) { + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } } @@ -540,96 +514,71 @@ static int replmd_modify_originating(struct ldb_module *module, * - replace the old object with the newly constructed one */ - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; - } - - return ret; -} - -static int replmd_modify(struct ldb_module *module, struct ldb_request *req) -{ - return replmd_prepare_originating(module, req, req->op.mod.message->dn, - "replmd_modify", replmd_modify_originating); -} - -static int replmd_replicated_request_reply_helper(struct replmd_replicated_request *ar, int ret) -{ - struct ldb_reply *ares = NULL; - - ar->handle->status = ret; - ar->handle->state = LDB_ASYNC_DONE; - - if (!ar->orig_req->callback) { - return LDB_SUCCESS; - } - - /* we're done and need to report the success to the caller */ - ares = talloc_zero(ar, struct ldb_reply); - if (!ares) { - ar->handle->status = LDB_ERR_OPERATIONS_ERROR; - ar->handle->state = LDB_ASYNC_DONE; - return LDB_ERR_OPERATIONS_ERROR; + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + msg, + req->controls, + ac, replmd_op_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } + talloc_steal(down_req, msg); - ares->type = LDB_REPLY_EXTENDED; - ares->response = NULL; - - return ar->orig_req->callback(ar->module->ldb, ar->orig_req->context, ares); -} - -static int replmd_replicated_request_done(struct replmd_replicated_request *ar) -{ - return replmd_replicated_request_reply_helper(ar, LDB_SUCCESS); + /* go on with the call chain */ + return ldb_next_request(module, down_req); } static int replmd_replicated_request_error(struct replmd_replicated_request *ar, int ret) { - return replmd_replicated_request_reply_helper(ar, ret); + return ret; } static int replmd_replicated_request_werror(struct replmd_replicated_request *ar, WERROR status) { int ret = LDB_ERR_OTHER; /* TODO: do some error mapping */ - return replmd_replicated_request_reply_helper(ar, ret); + return ret; } static int replmd_replicated_apply_next(struct replmd_replicated_request *ar); -static int replmd_replicated_apply_add_callback(struct ldb_context *ldb, - void *private_data, +static int replmd_replicated_apply_add_callback(struct ldb_request *req, struct ldb_reply *ares) { -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - struct replmd_replicated_request *ar = talloc_get_type(private_data, + struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); + int ret; + - ar->sub.change_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.change_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.change_ret); + if (!ares) { + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ar->req, ares->controls, + ares->response, ares->error); } - talloc_free(ar->sub.mem_ctx); - ZERO_STRUCT(ar->sub); + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + talloc_free(ares); ar->index_current++; - return replmd_replicated_apply_next(ar); -#else + ret = replmd_replicated_apply_next(ar); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ar->req, NULL, NULL, ret); + } + return LDB_SUCCESS; -#endif } static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) { + struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; struct replPropertyMetaDataBlob *md; @@ -696,39 +645,17 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) replmd_ldb_message_sort(msg, ar->schema); - ret = ldb_build_add_req(&ar->sub.change_req, + ret = ldb_build_add_req(&change_req, ar->module->ldb, - ar->sub.mem_ctx, + ar, msg, - NULL, + ar->controls, ar, - replmd_replicated_apply_add_callback); + replmd_replicated_apply_add_callback, + ar->req); if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - return ldb_next_request(ar->module, ar->sub.change_req); -#else - ret = ldb_next_request(ar->module, ar->sub.change_req); - if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(ar->module->ldb, "Failed to add replicated object %s: %s", ldb_dn_get_linearized(ar->sub.change_req->op.add.message->dn), - ldb_errstring(ar->module->ldb)); - return replmd_replicated_request_error(ar, ret); - } - - ar->sub.change_ret = ldb_wait(ar->sub.change_req->handle, LDB_WAIT_ALL); - if (ar->sub.change_ret != LDB_SUCCESS) { - ldb_asprintf_errstring(ar->module->ldb, "Failed while waiting on add replicated object %s: %s", ldb_dn_get_linearized(ar->sub.change_req->op.add.message->dn), - ldb_errstring(ar->module->ldb)); - return replmd_replicated_request_error(ar, ar->sub.change_ret); - } - - talloc_free(ar->sub.mem_ctx); - ZERO_STRUCT(ar->sub); - - ar->index_current++; - - return LDB_SUCCESS; -#endif + return ldb_next_request(ar->module, change_req); } static int replmd_replPropertyMetaData1_conflict_compare(struct replPropertyMetaData1 *m1, @@ -752,35 +679,42 @@ static int replmd_replPropertyMetaData1_conflict_compare(struct replPropertyMeta return m1->originating_usn - m2->originating_usn; } -static int replmd_replicated_apply_merge_callback(struct ldb_context *ldb, - void *private_data, +static int replmd_replicated_apply_merge_callback(struct ldb_request *req, struct ldb_reply *ares) { -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - struct replmd_replicated_request *ar = talloc_get_type(private_data, + struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); + int ret; - ret = ldb_next_request(ar->module, ar->sub.change_req); - if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - - ar->sub.change_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.change_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.change_ret); + if (!ares) { + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ar->req, ares->controls, + ares->response, ares->error); } - talloc_free(ar->sub.mem_ctx); - ZERO_STRUCT(ar->sub); + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + talloc_free(ares); ar->index_current++; + ret = replmd_replicated_apply_next(ar); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ar->req, NULL, NULL, ret); + } + return LDB_SUCCESS; -#else - return LDB_SUCCESS; -#endif } static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) { + struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; struct replPropertyMetaDataBlob *rmd; @@ -801,11 +735,11 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) /* * TODO: add rename conflict handling */ - if (ldb_dn_compare(msg->dn, ar->sub.search_msg->dn) != 0) { + if (ldb_dn_compare(msg->dn, ar->search_msg->dn) != 0) { ldb_debug_set(ar->module->ldb, LDB_DEBUG_FATAL, "replmd_replicated_apply_merge[%u]: rename not supported", ar->index_current); ldb_debug(ar->module->ldb, LDB_DEBUG_FATAL, "%s => %s\n", - ldb_dn_get_linearized(ar->sub.search_msg->dn), + ldb_dn_get_linearized(ar->search_msg->dn), ldb_dn_get_linearized(msg->dn)); return replmd_replicated_request_werror(ar, WERR_NOT_SUPPORTED); } @@ -816,9 +750,9 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) } /* find existing meta data */ - omd_value = ldb_msg_find_ldb_val(ar->sub.search_msg, "replPropertyMetaData"); + omd_value = ldb_msg_find_ldb_val(ar->search_msg, "replPropertyMetaData"); if (omd_value) { - ndr_err = ndr_pull_struct_blob(omd_value, ar->sub.mem_ctx, + ndr_err = ndr_pull_struct_blob(omd_value, ar, lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), &omd, (ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -834,7 +768,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) ZERO_STRUCT(nmd); nmd.version = 1; nmd.ctr.ctr1.count = omd.ctr.ctr1.count + rmd->ctr.ctr1.count; - nmd.ctr.ctr1.array = talloc_array(ar->sub.mem_ctx, + nmd.ctr.ctr1.array = talloc_array(ar, struct replPropertyMetaData1, nmd.ctr.ctr1.count); if (!nmd.ctr.ctr1.array) return replmd_replicated_request_werror(ar, WERR_NOMEM); @@ -917,14 +851,16 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) if (msg->num_elements == 0) { ldb_debug(ar->module->ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: skip replace\n", ar->index_current); - goto next_object; + + ar->index_current++; + return replmd_replicated_apply_next(ar); } ldb_debug(ar->module->ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: replace %u attributes\n", ar->index_current, msg->num_elements); /* - * when we now that we'll modify the record, add the whenChanged, uSNChanged + * when we know that we'll modify the record, add the whenChanged, uSNChanged * and replPopertyMetaData attributes */ ret = ldb_msg_add_string(msg, "whenChanged", ar->objs->objects[ar->index_current].when_changed); @@ -947,150 +883,123 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) msg->elements[i].flags = LDB_FLAG_MOD_REPLACE; } - ret = ldb_build_mod_req(&ar->sub.change_req, + ret = ldb_build_mod_req(&change_req, ar->module->ldb, - ar->sub.mem_ctx, + ar, msg, - NULL, + ar->controls, ar, - replmd_replicated_apply_merge_callback); - if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - return ldb_next_request(ar->module, ar->sub.change_req); -#else - ret = ldb_next_request(ar->module, ar->sub.change_req); + replmd_replicated_apply_merge_callback, + ar->req); if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - ar->sub.change_ret = ldb_wait(ar->sub.change_req->handle, LDB_WAIT_ALL); - if (ar->sub.change_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.change_ret); - } - -next_object: - talloc_free(ar->sub.mem_ctx); - ZERO_STRUCT(ar->sub); - - ar->index_current++; - - return LDB_SUCCESS; -#endif + return ldb_next_request(ar->module, change_req); } -static int replmd_replicated_apply_search_callback(struct ldb_context *ldb, - void *private_data, +static int replmd_replicated_apply_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct replmd_replicated_request *ar = talloc_get_type(private_data, + struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); - bool is_done = false; + int ret; + + if (!ares) { + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS && + ares->error != LDB_ERR_NO_SUCH_OBJECT) { + return ldb_module_done(ar->req, ares->controls, + ares->response, ares->error); + } switch (ares->type) { case LDB_REPLY_ENTRY: - ar->sub.search_msg = talloc_steal(ar->sub.mem_ctx, ares->message); + ar->search_msg = talloc_steal(ar, ares->message); break; + case LDB_REPLY_REFERRAL: /* we ignore referrals */ break; - case LDB_REPLY_EXTENDED: - case LDB_REPLY_DONE: - is_done = true; - } - talloc_free(ares); - -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - if (is_done) { - ar->sub.search_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.search_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.search_ret); + case LDB_REPLY_DONE: + if (ar->search_msg != NULL) { + ret = replmd_replicated_apply_merge(ar); + } else { + ret = replmd_replicated_apply_add(ar); } - if (ar->sub.search_msg) { - return replmd_replicated_apply_merge(ar); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ar->req, NULL, NULL, ret); } - return replmd_replicated_apply_add(ar); } -#endif + + talloc_free(ares); return LDB_SUCCESS; } -static int replmd_replicated_apply_search(struct replmd_replicated_request *ar) +static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *ar); + +static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) { int ret; char *tmp_str; char *filter; + struct ldb_request *search_req; + + if (ar->index_current >= ar->objs->num_objects) { + /* done with it, go to the last op */ + return replmd_replicated_uptodate_vector(ar); + } + + ar->search_msg = NULL; - tmp_str = ldb_binary_encode(ar->sub.mem_ctx, ar->objs->objects[ar->index_current].guid_value); + tmp_str = ldb_binary_encode(ar, ar->objs->objects[ar->index_current].guid_value); if (!tmp_str) return replmd_replicated_request_werror(ar, WERR_NOMEM); - filter = talloc_asprintf(ar->sub.mem_ctx, "(objectGUID=%s)", tmp_str); + filter = talloc_asprintf(ar, "(objectGUID=%s)", tmp_str); if (!filter) return replmd_replicated_request_werror(ar, WERR_NOMEM); talloc_free(tmp_str); - ret = ldb_build_search_req(&ar->sub.search_req, + ret = ldb_build_search_req(&search_req, ar->module->ldb, - ar->sub.mem_ctx, + ar, ar->objs->partition_dn, LDB_SCOPE_SUBTREE, filter, NULL, NULL, ar, - replmd_replicated_apply_search_callback); - if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - return ldb_next_request(ar->module, ar->sub.search_req); -#else - ret = ldb_next_request(ar->module, ar->sub.search_req); + replmd_replicated_apply_search_callback, + ar->req); if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - ar->sub.search_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.search_ret != LDB_SUCCESS && ar->sub.search_ret != LDB_ERR_NO_SUCH_OBJECT) { - return replmd_replicated_request_error(ar, ar->sub.search_ret); - } - if (ar->sub.search_msg) { - return replmd_replicated_apply_merge(ar); - } - - return replmd_replicated_apply_add(ar); -#endif -} - -static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) -{ -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - if (ar->index_current >= ar->objs->num_objects) { - return replmd_replicated_uptodate_vector(ar); - } -#endif - - ar->sub.mem_ctx = talloc_new(ar); - if (!ar->sub.mem_ctx) return replmd_replicated_request_werror(ar, WERR_NOMEM); - - return replmd_replicated_apply_search(ar); + return ldb_next_request(ar->module, search_req); } -static int replmd_replicated_uptodate_modify_callback(struct ldb_context *ldb, - void *private_data, +static int replmd_replicated_uptodate_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - struct replmd_replicated_request *ar = talloc_get_type(private_data, + struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); - ar->sub.change_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.change_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.change_ret); + if (!ares) { + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ar->req, ares->controls, + ares->response, ares->error); } - talloc_free(ar->sub.mem_ctx); - ZERO_STRUCT(ar->sub); + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - return replmd_replicated_request_done(ar); -#else - return LDB_SUCCESS; -#endif + talloc_free(ares); + + return ldb_module_done(ar->req, NULL, NULL, LDB_SUCCESS); } static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplicaCursor2 *c1, @@ -1101,6 +1010,7 @@ static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplic static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *ar) { + struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; struct replUpToDateVectorBlob ouv; @@ -1142,9 +1052,9 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a /* * first create the new replUpToDateVector */ - ouv_value = ldb_msg_find_ldb_val(ar->sub.search_msg, "replUpToDateVector"); + ouv_value = ldb_msg_find_ldb_val(ar->search_msg, "replUpToDateVector"); if (ouv_value) { - ndr_err = ndr_pull_struct_blob(ouv_value, ar->sub.mem_ctx, + ndr_err = ndr_pull_struct_blob(ouv_value, ar, lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), &ouv, (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -1165,7 +1075,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a */ nuv.ctr.ctr2.count = 1 + ouv.ctr.ctr2.count; if (ruv) nuv.ctr.ctr2.count += ruv->count; - nuv.ctr.ctr2.cursors = talloc_array(ar->sub.mem_ctx, + nuv.ctr.ctr2.cursors = talloc_array(ar, struct drsuapi_DsReplicaCursor2, nuv.ctr.ctr2.count); if (!nuv.ctr.ctr2.cursors) return replmd_replicated_request_werror(ar, WERR_NOMEM); @@ -1266,9 +1176,9 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a /* * create the change ldb_message */ - msg = ldb_msg_new(ar->sub.mem_ctx); + msg = ldb_msg_new(ar); if (!msg) return replmd_replicated_request_werror(ar, WERR_NOMEM); - msg->dn = ar->sub.search_msg->dn; + msg->dn = ar->search_msg->dn; ndr_err = ndr_push_struct_blob(&nuv_value, msg, lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), @@ -1301,12 +1211,12 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a * first see if we already have a repsFrom value for the current source dsa * if so we'll later replace this value */ - orf_el = ldb_msg_find_element(ar->sub.search_msg, "repsFrom"); + orf_el = ldb_msg_find_element(ar->search_msg, "repsFrom"); if (orf_el) { for (i=0; i < orf_el->num_values; i++) { struct repsFromToBlob *trf; - trf = talloc(ar->sub.mem_ctx, struct repsFromToBlob); + trf = talloc(ar, struct repsFromToBlob); if (!trf) return replmd_replicated_request_werror(ar, WERR_NOMEM); ndr_err = ndr_pull_struct_blob(&orf_el->values[i], trf, lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), trf, @@ -1375,72 +1285,62 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a nrf_el->flags = LDB_FLAG_MOD_REPLACE; /* prepare the ldb_modify() request */ - ret = ldb_build_mod_req(&ar->sub.change_req, + ret = ldb_build_mod_req(&change_req, ar->module->ldb, - ar->sub.mem_ctx, + ar, msg, - NULL, + ar->controls, ar, - replmd_replicated_uptodate_modify_callback); - if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - return ldb_next_request(ar->module, ar->sub.change_req); -#else - ret = ldb_next_request(ar->module, ar->sub.change_req); + replmd_replicated_uptodate_modify_callback, + ar->req); if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - ar->sub.change_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.change_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.change_ret); - } - - talloc_free(ar->sub.mem_ctx); - ZERO_STRUCT(ar->sub); - - return replmd_replicated_request_done(ar); -#endif + return ldb_next_request(ar->module, change_req); } -static int replmd_replicated_uptodate_search_callback(struct ldb_context *ldb, - void *private_data, +static int replmd_replicated_uptodate_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct replmd_replicated_request *ar = talloc_get_type(private_data, + struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); - bool is_done = false; + int ret; + + if (!ares) { + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS && + ares->error != LDB_ERR_NO_SUCH_OBJECT) { + return ldb_module_done(ar->req, ares->controls, + ares->response, ares->error); + } switch (ares->type) { case LDB_REPLY_ENTRY: - ar->sub.search_msg = talloc_steal(ar->sub.mem_ctx, ares->message); + ar->search_msg = talloc_steal(ar, ares->message); break; + case LDB_REPLY_REFERRAL: /* we ignore referrals */ break; - case LDB_REPLY_EXTENDED: - case LDB_REPLY_DONE: - is_done = true; - } - - talloc_free(ares); -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - if (is_done) { - ar->sub.search_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.search_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.search_ret); + case LDB_REPLY_DONE: + if (ar->search_msg == NULL) { + ret = replmd_replicated_request_werror(ar, WERR_DS_DRA_INTERNAL_ERROR); + } else { + ret = replmd_replicated_uptodate_modify(ar); } - if (!ar->sub.search_msg) { - return replmd_replicated_request_werror(ar, WERR_DS_DRA_INTERNAL_ERROR); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ar->req, NULL, NULL, ret); } - - return replmd_replicated_uptodate_modify(ar); } -#endif + + talloc_free(ares); return LDB_SUCCESS; } -static int replmd_replicated_uptodate_search(struct replmd_replicated_request *ar) + +static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *ar) { int ret; static const char *attrs[] = { @@ -1448,49 +1348,32 @@ static int replmd_replicated_uptodate_search(struct replmd_replicated_request *a "repsFrom", NULL }; + struct ldb_request *search_req; - ret = ldb_build_search_req(&ar->sub.search_req, + ar->search_msg = NULL; + + ret = ldb_build_search_req(&search_req, ar->module->ldb, - ar->sub.mem_ctx, + ar, ar->objs->partition_dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, ar, - replmd_replicated_uptodate_search_callback); + replmd_replicated_uptodate_search_callback, + ar->req); if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - return ldb_next_request(ar->module, ar->sub.search_req); -#else - ret = ldb_next_request(ar->module, ar->sub.search_req); - if (ret != LDB_SUCCESS) return replmd_replicated_request_error(ar, ret); - - ar->sub.search_ret = ldb_wait(ar->sub.search_req->handle, LDB_WAIT_ALL); - if (ar->sub.search_ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ar->sub.search_ret); - } - if (!ar->sub.search_msg) { - return replmd_replicated_request_werror(ar, WERR_DS_DRA_INTERNAL_ERROR); - } - - return replmd_replicated_uptodate_modify(ar); -#endif -} - -static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *ar) -{ - ar->sub.mem_ctx = talloc_new(ar); - if (!ar->sub.mem_ctx) return replmd_replicated_request_werror(ar, WERR_NOMEM); - - return replmd_replicated_uptodate_search(ar); + return ldb_next_request(ar->module, search_req); } static int replmd_extended_replicated_objects(struct ldb_module *module, struct ldb_request *req) { struct dsdb_extended_replicated_objects *objs; struct replmd_replicated_request *ar; + struct ldb_control **ctrls; + int ret; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_extended_replicated_objects\n"); @@ -1506,25 +1389,35 @@ static int replmd_extended_replicated_objects(struct ldb_module *module, struct return LDB_ERR_PROTOCOL_ERROR; } - ar = replmd_replicated_init_handle(module, req, objs); - if (!ar) { + ar = replmd_ctx_init(module, req); + if (!ar) return LDB_ERR_OPERATIONS_ERROR; + + ar->objs = objs; + ar->schema = dsdb_get_schema(module->ldb); + if (!ar->schema) { + ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "replmd_ctx_init: no loaded schema found\n"); + talloc_free(ar); + return LDB_ERR_CONSTRAINT_VIOLATION; } -#ifdef REPLMD_FULL_ASYNC /* TODO: activate this code when ldb support full async code */ - return replmd_replicated_apply_next(ar); -#else - while (ar->index_current < ar->objs->num_objects && - req->handle->state != LDB_ASYNC_DONE) { - replmd_replicated_apply_next(ar); + ctrls = req->controls; + + if (req->controls) { + req->controls = talloc_memdup(ar, req->controls, + talloc_get_size(req->controls)); + if (!req->controls) return replmd_replicated_request_werror(ar, WERR_NOMEM); } - if (req->handle->state != LDB_ASYNC_DONE) { - replmd_replicated_uptodate_vector(ar); + ret = ldb_request_add_control(req, DSDB_CONTROL_REPLICATED_UPDATE_OID, false, NULL); + if (ret != LDB_SUCCESS) { + return ret; } - return LDB_SUCCESS; -#endif + ar->controls = req->controls; + req->controls = ctrls; + + return replmd_replicated_apply_next(ar); } static int replmd_extended(struct ldb_module *module, struct ldb_request *req) @@ -1536,53 +1429,9 @@ static int replmd_extended(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } -static int replmd_wait_none(struct ldb_handle *handle) { - struct replmd_replicated_request *ar; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ar = talloc_get_type(handle->private_data, struct replmd_replicated_request); - if (!ar) { - return LDB_ERR_OPERATIONS_ERROR; - } - - /* we do only sync calls */ - if (handle->state != LDB_ASYNC_DONE) { - return LDB_ERR_OPERATIONS_ERROR; - } - - return handle->status; -} - -static int replmd_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = replmd_wait_none(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; -} - -static int replmd_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return replmd_wait_all(handle); - } else { - return replmd_wait_none(handle); - } -} - _PUBLIC_ const struct ldb_module_ops ldb_repl_meta_data_module_ops = { .name = "repl_meta_data", .add = replmd_add, .modify = replmd_modify, .extended = replmd_extended, - .wait = replmd_wait }; diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index ebc90d4cf3..b38e182cf7 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -4,7 +4,7 @@ rootDSE ldb module Copyright (C) Andrew Tridgell 2005 - Copyright (C) Simo Sorce 2005 + Copyright (C) Simo Sorce 2005-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 @@ -221,40 +221,77 @@ failed: struct rootdse_context { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); - - const char * const * attrs; + struct ldb_request *req; }; -static int rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static struct rootdse_context *rootdse_init_context(struct ldb_module *module, + struct ldb_request *req) +{ + struct rootdse_context *ac; + + ac = talloc_zero(req, struct rootdse_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return NULL; + } + + ac->module = module; + ac->req = req; + + return ac; +} + +static int rootdse_callback(struct ldb_request *req, struct ldb_reply *ares) { struct rootdse_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct rootdse_context); - ac = talloc_get_type(context, struct rootdse_context); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - if (ares->type == LDB_REPLY_ENTRY) { + switch (ares->type) { + case LDB_REPLY_ENTRY: /* * if the client explicit asks for the 'netlogon' attribute * the reply_entry needs to be skipped */ - if (ac->attrs && ldb_attr_in_list(ac->attrs, "netlogon")) { + if (ac->req->op.search.attrs && + ldb_attr_in_list(ac->req->op.search.attrs, "netlogon")) { talloc_free(ares); return LDB_SUCCESS; } /* for each record returned post-process to add any dynamic attributes that have been asked for */ - if (rootdse_add_dynamic(ac->module, ares->message, ac->attrs) != LDB_SUCCESS) { - goto error; + ret = rootdse_add_dynamic(ac->module, ares->message, + ac->req->op.search.attrs); + if (ret != LDB_SUCCESS) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, ret); } - } - return ac->up_callback(ldb, ac->up_context, ares); + return ldb_module_send_entry(ac->req, ares->message); + + case LDB_REPLY_REFERRAL: + /* should we allow the backend to return referrals in this case + * ?? */ + break; + + case LDB_REPLY_DONE: + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } -error: talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_SUCCESS; } static int rootdse_search(struct ldb_module *module, struct ldb_request *req) @@ -270,48 +307,25 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - ac = talloc(req, struct rootdse_context); + ac = rootdse_init_context(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac->module = module; - ac->up_context = req->context; - ac->up_callback = req->callback; - ac->attrs = req->op.search.attrs; - - down_req = talloc_zero(req, struct ldb_request); - if (down_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - down_req->operation = req->operation; /* in our db we store the rootDSE with a DN of @ROOTDSE */ - down_req->op.search.base = ldb_dn_new(down_req, module->ldb, "@ROOTDSE"); - down_req->op.search.scope = LDB_SCOPE_BASE; - down_req->op.search.tree = ldb_parse_tree(down_req, NULL); - if (down_req->op.search.base == NULL || down_req->op.search.tree == NULL) { - ldb_oom(module->ldb); - talloc_free(down_req); - return LDB_ERR_OPERATIONS_ERROR; - } - down_req->op.search.attrs = req->op.search.attrs; - down_req->controls = req->controls; - - down_req->context = ac; - down_req->callback = rootdse_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - - /* perform the search */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_search_req(&down_req, module->ldb, ac, + ldb_dn_new(ac, module->ldb, "@ROOTDSE"), + LDB_SCOPE_BASE, + NULL, + req->op.search.attrs, + NULL,/* for now skip the controls from the client */ + ac, rootdse_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; + return ldb_next_request(module, down_req); } static int rootdse_register_control(struct ldb_module *module, struct ldb_request *req) @@ -332,9 +346,9 @@ static int rootdse_register_control(struct ldb_module *module, struct ldb_reques priv->num_controls += 1; priv->controls = list; - return LDB_SUCCESS; + return ldb_module_done(req, NULL, NULL, LDB_SUCCESS); } - + static int rootdse_register_partition(struct ldb_module *module, struct ldb_request *req) { struct private_data *priv = talloc_get_type(module->private_data, struct private_data); @@ -353,9 +367,9 @@ static int rootdse_register_partition(struct ldb_module *module, struct ldb_requ priv->num_partitions += 1; priv->partitions = list; - return LDB_SUCCESS; + return ldb_module_done(req, NULL, NULL, LDB_SUCCESS); } - + static int rootdse_request(struct ldb_module *module, struct ldb_request *req) { diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index bd491bd011..95a16b5527 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -1,8 +1,8 @@ -/* +/* SAM ldb module - Copyright (C) Simo Sorce 2004 Copyright (C) Andrew Bartlett 2005 + Copyright (C) Simo Sorce 2004-2008 * NOTICE: this module is NOT released under the GNU LGPL license as * other ldb code. This module is release under the GNU GPL v3 or @@ -12,12 +12,12 @@ 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 . */ @@ -37,728 +37,1266 @@ #include "lib/ldb/include/ldb_errors.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_private.h" +#include "lib/events/events.h" #include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_security.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" +#include "ldb_wrap.h" + +struct samldb_ctx; + +typedef int (*samldb_step_fn_t)(struct samldb_ctx *); + +struct samldb_step { + struct samldb_step *next; + samldb_step_fn_t fn; +}; + +struct samldb_ctx { + struct ldb_module *module; + struct ldb_request *req; -int samldb_notice_sid(struct ldb_module *module, - TALLOC_CTX *mem_ctx, const struct dom_sid *sid); + /* the resulting message */ + struct ldb_message *msg; + + /* used to apply templates */ + const char *type; + + /* used to find parent domain */ + struct ldb_dn *check_dn; + struct ldb_dn *domain_dn; + struct dom_sid *domain_sid; + uint32_t next_rid; + + /* generic storage, remember to zero it before use */ + struct ldb_reply *ares; + + /* holds the entry SID */ + struct dom_sid *sid; + + /* all the async steps necessary to complete the operation */ + struct samldb_step *steps; + struct samldb_step *curstep; +}; -static bool samldb_msg_add_sid(struct ldb_module *module, struct ldb_message *msg, const char *name, const struct dom_sid *sid) +static struct samldb_ctx *samldb_ctx_init(struct ldb_module *module, + struct ldb_request *req) { - struct ldb_val v; - enum ndr_err_code ndr_err; + struct samldb_ctx *ac; - ndr_err = ndr_push_struct_blob(&v, msg, NULL, sid, - (ndr_push_flags_fn_t)ndr_push_dom_sid); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - return false; + ac = talloc_zero(req, struct samldb_ctx); + if (ac == NULL) { + ldb_oom(module->ldb); + return NULL; } - return (ldb_msg_add_value(msg, name, &v, NULL) == 0); + + ac->module = module; + ac->req = req; + + return ac; } -/* - allocate a new id, attempting to do it atomically - return 0 on failure, the id on success -*/ -static int samldb_set_next_rid(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, - struct ldb_dn *dn, uint32_t old_id, uint32_t new_id) +static int samldb_add_step(struct samldb_ctx *ac, samldb_step_fn_t fn) { - struct ldb_message msg; - int ret; - struct ldb_val vals[2]; - struct ldb_message_element els[2]; + struct samldb_step *step; - if (new_id == 0) { - /* out of IDs ! */ - ldb_set_errstring(ldb, "Are we out of valid IDs ?\n"); + step = talloc_zero(ac, struct samldb_step); + if (step == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - /* we do a delete and add as a single operation. That prevents - a race, in case we are not actually on a transaction db */ - ZERO_STRUCT(msg); - msg.dn = ldb_dn_copy(mem_ctx, dn); - if (!msg.dn) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + if (ac->steps == NULL) { + ac->steps = step; + ac->curstep = step; + } else { + ac->curstep->next = step; + ac->curstep = step; } - msg.num_elements = 2; - msg.elements = els; - els[0].num_values = 1; - els[0].values = &vals[0]; - els[0].flags = LDB_FLAG_MOD_DELETE; - els[0].name = talloc_strdup(mem_ctx, "nextRid"); - if (!els[0].name) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } + step->fn = fn; - els[1].num_values = 1; - els[1].values = &vals[1]; - els[1].flags = LDB_FLAG_MOD_ADD; - els[1].name = els[0].name; + return LDB_SUCCESS; +} - vals[0].data = (uint8_t *)talloc_asprintf(mem_ctx, "%u", old_id); - if (!vals[0].data) { - ldb_oom(ldb); +static int samldb_first_step(struct samldb_ctx *ac) +{ + if (ac->steps == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - vals[0].length = strlen((char *)vals[0].data); - vals[1].data = (uint8_t *)talloc_asprintf(mem_ctx, "%u", new_id); - if (!vals[1].data) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + ac->curstep = ac->steps; + return ac->curstep->fn(ac); +} + +static int samldb_next_step(struct samldb_ctx *ac) +{ + if (ac->curstep->next) { + ac->curstep = ac->curstep->next; + return ac->curstep->fn(ac); } - vals[1].length = strlen((char *)vals[1].data); - ret = ldb_modify(ldb, &msg); - return ret; + /* it is an error if the last step does not properly + * return to the upper module by itself */ + return LDB_ERR_OPERATIONS_ERROR; } -/* - allocate a new id, attempting to do it atomically - return 0 on failure, the id on success -*/ -static int samldb_find_next_rid(struct ldb_module *module, TALLOC_CTX *mem_ctx, - struct ldb_dn *dn, uint32_t *old_rid) +static int samldb_search_template_callback(struct ldb_request *req, + struct ldb_reply *ares) { - const char * const attrs[2] = { "nextRid", NULL }; - struct ldb_result *res = NULL; + struct samldb_ctx *ac; int ret; - const char *str; - ret = ldb_search(module->ldb, dn, LDB_SCOPE_BASE, "nextRid=*", attrs, &res); - if (ret != LDB_SUCCESS) { - return ret; + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } - if (res->count != 1) { - talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - str = ldb_msg_find_attr_as_string(res->msgs[0], "nextRid", NULL); - if (str == NULL) { - ldb_asprintf_errstring(module->ldb, - "attribute nextRid not found in %s\n", - ldb_dn_get_linearized(dn)); - talloc_free(res); - return LDB_ERR_OPERATIONS_ERROR; + switch (ares->type) { + case LDB_REPLY_ENTRY: + /* save entry */ + if (ac->ares != NULL) { + /* one too many! */ + ldb_set_errstring(ac->module->ldb, + "Invalid number of results while searching " + "for template objects"); + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + + ac->ares = talloc_steal(ac, ares); + ret = LDB_SUCCESS; + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + ret = LDB_SUCCESS; + break; + + case LDB_REPLY_DONE: + + talloc_free(ares); + ret = samldb_next_step(ac); + break; + } + +done: + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); } - *old_rid = strtol(str, NULL, 0); - talloc_free(res); return LDB_SUCCESS; } -static int samldb_allocate_next_rid(struct ldb_module *module, TALLOC_CTX *mem_ctx, - struct ldb_dn *dn, const struct dom_sid *dom_sid, - struct dom_sid **new_sid) +static int samldb_search_template(struct samldb_ctx *ac) { - struct dom_sid *obj_sid; - uint32_t old_rid; + struct event_context *ev; + struct loadparm_context *lparm_ctx; + struct ldb_context *templates_ldb; + char *templates_ldb_path; + struct ldb_request *req; + struct ldb_dn *basedn; + void *opaque; int ret; - - ret = samldb_find_next_rid(module, mem_ctx, dn, &old_rid); - if (ret) { - return ret; + + opaque = ldb_get_opaque(ac->module->ldb, "loadparm"); + lparm_ctx = talloc_get_type(opaque, struct loadparm_context); + if (lparm_ctx == NULL) { + ldb_set_errstring(ac->module->ldb, + "Unable to find loadparm context\n"); + return LDB_ERR_OPERATIONS_ERROR; } - - /* return the new object sid */ - obj_sid = dom_sid_add_rid(mem_ctx, dom_sid, old_rid); - - *new_sid = dom_sid_add_rid(mem_ctx, dom_sid, old_rid + 1); - if (!*new_sid) { + + opaque = ldb_get_opaque(ac->module->ldb, "templates_ldb"); + templates_ldb = talloc_get_type(opaque, struct ldb_context); + + /* make sure we have the templates ldb */ + if (!templates_ldb) { + templates_ldb_path = samdb_relative_path(ac->module->ldb, ac, + "templates.ldb"); + if (!templates_ldb_path) { + ldb_set_errstring(ac->module->ldb, + "samldb_init_template: ERROR: Failed " + "to contruct path for template db"); + return LDB_ERR_OPERATIONS_ERROR; + } + + ev = ldb_get_event_context(ac->module->ldb); + + templates_ldb = ldb_wrap_connect(ac->module->ldb, ev, + lparm_ctx, templates_ldb_path, + NULL, NULL, 0, NULL); + talloc_free(templates_ldb_path); + + if (!templates_ldb) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (!talloc_reference(templates_ldb, ev)) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_set_opaque(ac->module->ldb, + "templates_ldb", templates_ldb); + if (ret != LDB_SUCCESS) { + return ret; + } + } + + /* search template */ + basedn = ldb_dn_new_fmt(ac, templates_ldb, + "cn=Template%s,cn=Templates", ac->type); + if (basedn == NULL) { + ldb_set_errstring(ac->module->ldb, + "samldb_init_template: ERROR: Failed " + "to contruct DN for template"); return LDB_ERR_OPERATIONS_ERROR; } - ret = samldb_notice_sid(module, mem_ctx, *new_sid); - if (ret != 0) { - /* gah, there are conflicting sids. - * This is a critical situation it means that someone messed up with - * the DB and nextRid is not returning free RIDs, report an error - * and refuse to create any user until the problem is fixed */ - ldb_asprintf_errstring(module->ldb, - "Critical Error: unconsistent DB, unable to retireve an unique RID to generate a new SID: %s", - ldb_errstring(module->ldb)); + /* pull the template record */ + ret = ldb_build_search_req(&req, templates_ldb, ac, + basedn, LDB_SCOPE_BASE, + "(distinguishedName=*)", NULL, + NULL, + ac, samldb_search_template_callback, + ac->req); + if (ret != LDB_SUCCESS) { return ret; } - return ret; + + talloc_steal(req, basedn); + ac->ares = NULL; + + return ldb_request(templates_ldb, req); } -/* search the domain related to the provided dn - allocate a new RID for the domain - return the new sid string -*/ -static int samldb_get_new_sid(struct ldb_module *module, - TALLOC_CTX *mem_ctx, struct ldb_dn *obj_dn, - struct ldb_dn *dom_dn, - struct dom_sid **sid) +static int samldb_apply_template(struct samldb_ctx *ac) +{ + struct ldb_message_element *el; + struct ldb_message *msg; + int i, j; + int ret; + + msg = ac->ares->message; + + for (i = 0; i < msg->num_elements; i++) { + el = &msg->elements[i]; + /* some elements should not be copied */ + if (ldb_attr_cmp(el->name, "cn") == 0 || + ldb_attr_cmp(el->name, "name") == 0 || + ldb_attr_cmp(el->name, "objectClass") == 0 || + ldb_attr_cmp(el->name, "sAMAccountName") == 0 || + ldb_attr_cmp(el->name, "sAMAccountName") == 0 || + ldb_attr_cmp(el->name, "distinguishedName") == 0 || + ldb_attr_cmp(el->name, "objectGUID") == 0) { + continue; + } + for (j = 0; j < el->num_values; j++) { + ret = samdb_find_or_add_attribute( + ac->module->ldb, ac->msg, el->name, + (char *)el->values[j].data); + if (ret != LDB_SUCCESS) { + ldb_set_errstring(ac->module->ldb, + "Failed adding template attribute\n"); + return LDB_ERR_OPERATIONS_ERROR; + } + } + } + + return samldb_next_step(ac); +} + +static int samldb_get_parent_domain(struct samldb_ctx *ac); + +static int samldb_get_parent_domain_callback(struct ldb_request *req, + struct ldb_reply *ares) { - const char * const attrs[2] = { "objectSid", NULL }; - struct ldb_result *res = NULL; + struct samldb_ctx *ac; + const char *nextRid; int ret; - struct dom_sid *dom_sid; - /* get the domain component part of the provided dn */ + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + /* save entry */ + if (ac->domain_dn != NULL) { + /* one too many! */ + ldb_set_errstring(ac->module->ldb, + "Invalid number of results while searching " + "for domain object"); + ret = LDB_ERR_OPERATIONS_ERROR; + break; + } + + nextRid = ldb_msg_find_attr_as_string(ares->message, + "nextRid", NULL); + if (nextRid == NULL) { + ldb_asprintf_errstring(ac->module->ldb, + "attribute nextRid not found in %s\n", + ldb_dn_get_linearized(ares->message->dn)); + ret = LDB_ERR_OPERATIONS_ERROR; + break;; + } + + ac->next_rid = strtol(nextRid, NULL, 0); + + ac->domain_sid = samdb_result_dom_sid(ac, ares->message, + "objectSid"); + if (ac->domain_sid == NULL) { + ldb_set_errstring(ac->module->ldb, + "error retrieving parent domain domain sid!\n"); + ret = LDB_ERR_CONSTRAINT_VIOLATION; + break; + } + ac->domain_dn = talloc_steal(ac, ares->message->dn); + + talloc_free(ares); + ret = LDB_SUCCESS; + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + ret = LDB_SUCCESS; + break; - /* find the domain sid */ + case LDB_REPLY_DONE: - ret = ldb_search(module->ldb, dom_dn, LDB_SCOPE_BASE, "objectSid=*", attrs, &res); + talloc_free(ares); + if (ac->domain_dn == NULL) { + /* search again */ + ret = samldb_get_parent_domain(ac); + } else { + /* found, go on */ + ret = samldb_next_step(ac); + } + break; + } + +done: if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, - "samldb_get_new_sid: error retrieving domain sid from %s: %s!\n", - ldb_dn_get_linearized(dom_dn), - ldb_errstring(module->ldb)); - talloc_free(res); - return ret; + return ldb_module_done(ac->req, NULL, NULL, ret); } - if (res->count != 1) { - ldb_asprintf_errstring(module->ldb, - "samldb_get_new_sid: error retrieving domain sid from %s: not found!\n", - ldb_dn_get_linearized(dom_dn)); - talloc_free(res); - return LDB_ERR_CONSTRAINT_VIOLATION; + return LDB_SUCCESS; +} + +/* Find a domain object in the parents of a particular DN. */ +static int samldb_get_parent_domain(struct samldb_ctx *ac) +{ + static const char * const attrs[3] = { "objectSid", "nextRid", NULL }; + struct ldb_request *req; + struct ldb_dn *dn; + int ret; + + if (ac->check_dn == NULL) { + return LDB_ERR_OPERATIONS_ERROR; } - dom_sid = samdb_result_dom_sid(res, res->msgs[0], "objectSid"); - if (dom_sid == NULL) { - ldb_set_errstring(module->ldb, "samldb_get_new_sid: error parsing domain sid!\n"); - talloc_free(res); + dn = ldb_dn_get_parent(ac, ac->check_dn); + if (dn == NULL) { + ldb_set_errstring(ac->module->ldb, + "Unable to find parent domain object"); return LDB_ERR_CONSTRAINT_VIOLATION; } - /* allocate a new Rid for the domain */ - ret = samldb_allocate_next_rid(module, mem_ctx, dom_dn, dom_sid, sid); - if (ret != 0) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Failed to increment nextRid of %s: %s\n", ldb_dn_get_linearized(dom_dn), ldb_errstring(module->ldb)); - talloc_free(res); + ac->check_dn = dn; + + ret = ldb_build_search_req(&req, ac->module->ldb, ac, + dn, LDB_SCOPE_BASE, + "(|(objectClass=domain)" + "(objectClass=builtinDomain)" + "(objectClass=samba4LocalDomain))", + attrs, + NULL, + ac, samldb_get_parent_domain_callback, + ac->req); + + if (ret != LDB_SUCCESS) { return ret; } - talloc_free(res); + return ldb_next_request(ac->module, req); +} + +static int samldb_generate_samAccountName(struct ldb_message *msg) +{ + char *name; + + /* Format: $000000-000000000000 */ - return ret; + name = talloc_asprintf(msg, "$%.6X-%.6X%.6X", + (unsigned int)generate_random(), + (unsigned int)generate_random(), + (unsigned int)generate_random()); + if (name == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + return ldb_msg_add_steal_string(msg, "samAccountName", name); } -/* If we are adding new users/groups, we need to update the nextRid - * attribute to be 'above' all incoming users RIDs. This tries to - * avoid clashes in future */ +static int samldb_check_samAccountName_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct samldb_ctx *ac; + int ret; + + ac = talloc_get_type(req->context, struct samldb_ctx); -int samldb_notice_sid(struct ldb_module *module, - TALLOC_CTX *mem_ctx, const struct dom_sid *sid) + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + + /* if we get an entry it means this samAccountName + * already exists */ + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_ENTRY_ALREADY_EXISTS); + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + ret = LDB_SUCCESS; + break; + + case LDB_REPLY_DONE: + + /* not found, go on */ + talloc_free(ares); + ret = samldb_next_step(ac); + break; + } + +done: + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + return LDB_SUCCESS; +} + +static int samldb_check_samAccountName(struct samldb_ctx *ac) { + struct ldb_request *req; + const char *name; + char *filter; int ret; - struct ldb_dn *dom_dn; - struct dom_sid *dom_sid; - const char *attrs[] = { NULL }; - struct ldb_result *dom_res; - struct ldb_result *res; - uint32_t old_rid; - - /* find if this SID already exists */ - ret = ldb_search_exp_fmt(module->ldb, mem_ctx, &res, - NULL, LDB_SCOPE_SUBTREE, attrs, - "(objectSid=%s)", ldap_encode_ndr_dom_sid(mem_ctx, sid)); - if (ret == LDB_SUCCESS) { - if (res->count > 0) { - talloc_free(res); - ldb_asprintf_errstring(module->ldb, - "Attempt to add record with SID %s rejected," - " because this SID is already in the database", - dom_sid_string(mem_ctx, sid)); - /* We have a duplicate SID, we must reject the add */ - return LDB_ERR_CONSTRAINT_VIOLATION; + + if (ldb_msg_find_element(ac->msg, "samAccountName") == NULL) { + ret = samldb_generate_samAccountName(ac->msg); + if (ret != LDB_SUCCESS) { + return ret; } - talloc_free(res); - } else { - ldb_asprintf_errstring(module->ldb, - "samldb_notice_sid: error searching to see if sid %s is in use: %s\n", - dom_sid_string(mem_ctx, sid), - ldb_errstring(module->ldb)); - return ret; } - dom_sid = dom_sid_dup(mem_ctx, sid); - if (!dom_sid) { + name = ldb_msg_find_attr_as_string(ac->msg, "samAccountName", NULL); + if (name == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + filter = talloc_asprintf(ac, "samAccountName=%s", name); + if (filter == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - /* get the domain component part of the provided SID */ - dom_sid->num_auths--; - - /* find the domain DN */ - ret = ldb_search_exp_fmt(module->ldb, mem_ctx, &dom_res, - NULL, LDB_SCOPE_SUBTREE, attrs, - "(&(objectSid=%s)(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain)))", - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid)); - if (ret == LDB_SUCCESS) { - if (dom_res->count == 0) { - talloc_free(dom_res); - /* This isn't an operation on a domain we know about, so nothing to update */ - return LDB_SUCCESS; - } - if (dom_res->count > 1) { - talloc_free(dom_res); - ldb_asprintf_errstring(module->ldb, - "samldb_notice_sid: error retrieving domain from sid: duplicate (found %d) domain: %s!\n", - dom_res->count, dom_sid_string(dom_res, dom_sid)); - return LDB_ERR_OPERATIONS_ERROR; - } - } else { - ldb_asprintf_errstring(module->ldb, - "samldb_notice_sid: error retrieving domain from sid: %s: %s\n", - dom_sid_string(dom_res, dom_sid), - ldb_errstring(module->ldb)); + ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ac->domain_dn, LDB_SCOPE_SUBTREE, + filter, NULL, + NULL, + ac, samldb_check_samAccountName_callback, + ac->req); + talloc_free(filter); + if (ret != LDB_SUCCESS) { return ret; } + ac->ares = NULL; + return ldb_next_request(ac->module, req); +} - dom_dn = dom_res->msgs[0]->dn; +static int samldb_check_samAccountType(struct samldb_ctx *ac) +{ + unsigned int account_type; + unsigned int group_type; + unsigned int uac; + int ret; - ret = samldb_find_next_rid(module, mem_ctx, - dom_dn, &old_rid); - if (ret) { - talloc_free(dom_res); - return ret; + /* make sure sAMAccountType is not specified */ + if (ldb_msg_find_element(ac->msg, "sAMAccountType") != NULL) { + ldb_asprintf_errstring(ac->module->ldb, + "sAMAccountType must not be specified"); + return LDB_ERR_UNWILLING_TO_PERFORM; } - if (old_rid <= sid->sub_auths[sid->num_auths - 1]) { - ret = samldb_set_next_rid(module->ldb, mem_ctx, dom_dn, old_rid, - sid->sub_auths[sid->num_auths - 1] + 1); + if (strcmp("user", ac->type) == 0) { + uac = samdb_result_uint(ac->msg, "userAccountControl", 0); + if (uac == 0) { + ldb_asprintf_errstring(ac->module->ldb, + "userAccountControl invalid"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } else { + account_type = samdb_uf2atype(uac); + ret = samdb_msg_add_uint(ac->module->ldb, + ac->msg, ac->msg, + "sAMAccountType", + account_type); + if (ret != LDB_SUCCESS) { + return ret; + } + } + } else + if (strcmp("group", ac->type) == 0) { + + group_type = samdb_result_uint(ac->msg, "groupType", 0); + if (group_type == 0) { + ldb_asprintf_errstring(ac->module->ldb, + "groupType invalid"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } else { + account_type = samdb_gtype2atype(group_type); + ret = samdb_msg_add_uint(ac->module->ldb, + ac->msg, ac->msg, + "sAMAccountType", + account_type); + if (ret != LDB_SUCCESS) { + return ret; + } + } } - talloc_free(dom_res); - return ret; + + return samldb_next_step(ac); } -static int samldb_handle_sid(struct ldb_module *module, - TALLOC_CTX *mem_ctx, struct ldb_message *msg2, - struct ldb_dn *parent_dn) +static int samldb_get_sid_domain_callback(struct ldb_request *req, + struct ldb_reply *ares) { + struct samldb_ctx *ac; + const char *nextRid; int ret; - - struct dom_sid *sid = samdb_result_dom_sid(mem_ctx, msg2, "objectSid"); - if (sid == NULL) { - ret = samldb_get_new_sid(module, msg2, msg2->dn, parent_dn, &sid); - if (ret != 0) { - return ret; + + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + /* save entry */ + if (ac->next_rid != 0) { + /* one too many! */ + ldb_set_errstring(ac->module->ldb, + "Invalid number of results while searching " + "for domain object"); + ret = LDB_ERR_OPERATIONS_ERROR; + break; } - if ( ! samldb_msg_add_sid(module, msg2, "objectSid", sid)) { - talloc_free(sid); - return LDB_ERR_OPERATIONS_ERROR; + nextRid = ldb_msg_find_attr_as_string(ares->message, + "nextRid", NULL); + if (nextRid == NULL) { + ldb_asprintf_errstring(ac->module->ldb, + "attribute nextRid not found in %s\n", + ldb_dn_get_linearized(ares->message->dn)); + ret = LDB_ERR_OPERATIONS_ERROR; + break; } - talloc_free(sid); + + ac->next_rid = strtol(nextRid, NULL, 0); + + ac->domain_dn = talloc_steal(ac, ares->message->dn); + + talloc_free(ares); ret = LDB_SUCCESS; - } else { - ret = samldb_notice_sid(module, msg2, sid); + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + ret = LDB_SUCCESS; + break; + + case LDB_REPLY_DONE: + + if (ac->next_rid == 0) { + ldb_asprintf_errstring(ac->module->ldb, + "Unable to get nextRid from domain entry\n"); + ret = LDB_ERR_OPERATIONS_ERROR; + break; + } + + /* found, go on */ + ret = samldb_next_step(ac); + break; + } + +done: + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); } - return ret; + + return LDB_SUCCESS; } -static int samldb_generate_samAccountName(struct ldb_module *module, TALLOC_CTX *mem_ctx, - struct ldb_dn *dom_dn, char **name) +/* Find a domain object in the parents of a particular DN. */ +static int samldb_get_sid_domain(struct samldb_ctx *ac) { - const char *attrs[] = { NULL }; - struct ldb_result *res; + static const char * const attrs[2] = { "nextRid", NULL }; + struct ldb_request *req; + char *filter; int ret; - - /* Format: $000000-000000000000 */ - - do { - *name = talloc_asprintf(mem_ctx, "$%.6X-%.6X%.6X", (unsigned int)generate_random(), (unsigned int)generate_random(), (unsigned int)generate_random()); - /* TODO: Figure out exactly what this is meant to conflict with */ - ret = ldb_search_exp_fmt(module->ldb, - mem_ctx, &res, dom_dn, LDB_SCOPE_SUBTREE, attrs, - "samAccountName=%s", - ldb_binary_encode_string(mem_ctx, *name)); - if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, "samldb: Failure searching to determine if samAccountName %s is unique: %s", - *name, ldb_errstring(module->ldb)); - return ret; - } - if (res->count == 0) { - talloc_free(res); - /* Great. There are no conflicting users/groups/etc */ - return LDB_SUCCESS; - } else { - talloc_free(*name); - /* gah, there is a conflicting name, lets move around the loop again... */ - } - } while (1); + if (ac->sid == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->domain_sid = dom_sid_dup(ac, ac->sid); + if (!ac->domain_sid) { + return LDB_ERR_OPERATIONS_ERROR; + } + /* get the domain component part of the provided SID */ + ac->domain_sid->num_auths--; + + filter = talloc_asprintf(ac, "(&(objectSid=%s)" + "(|(objectClass=domain)" + "(objectClass=builtinDomain)" + "(objectClass=samba4LocalDomain)))", + ldap_encode_ndr_dom_sid(ac, ac->domain_sid)); + if (filter == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ldb_get_default_basedn(ac->module->ldb), + LDB_SCOPE_SUBTREE, + filter, attrs, + NULL, + ac, samldb_get_sid_domain_callback, + ac->req); + + if (ret != LDB_SUCCESS) { + return ret; + } + + ac->next_rid = 0; + return ldb_next_request(ac->module, req); } -static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_message *msg, - struct ldb_message **ret_msg) +static bool samldb_msg_add_sid(struct ldb_message *msg, + const char *name, + const struct dom_sid *sid) { - int ret; - unsigned int group_type; - char *name; - struct ldb_message *msg2; - struct ldb_dn *dom_dn; - const char *rdn_name; - TALLOC_CTX *mem_ctx = talloc_new(msg); - const char *errstr; - if (!mem_ctx) { + struct ldb_val v; + enum ndr_err_code ndr_err; + + ndr_err = ndr_push_struct_blob(&v, msg, NULL, sid, + (ndr_push_flags_fn_t)ndr_push_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return false; + } + return (ldb_msg_add_value(msg, name, &v, NULL) == 0); +} + +static int samldb_new_sid(struct samldb_ctx *ac) +{ + + if (ac->domain_sid == NULL || ac->next_rid == 0) { return LDB_ERR_OPERATIONS_ERROR; } - /* build the new msg */ - msg2 = ldb_msg_copy(mem_ctx, msg); - if (!msg2) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_group_object: ldb_msg_copy failed!\n"); - talloc_free(mem_ctx); + ac->sid = dom_sid_add_rid(ac, ac->domain_sid, ac->next_rid + 1); + if (ac->sid == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ret = samdb_copy_template(module->ldb, msg2, - "group", - &errstr); - if (ret != 0) { - - talloc_free(mem_ctx); - return ret; + if ( ! samldb_msg_add_sid(ac->msg, "objectSid", ac->sid)) { + return LDB_ERR_OPERATIONS_ERROR; } - rdn_name = ldb_dn_get_rdn_name(msg2->dn); + return samldb_next_step(ac); +} - if (strcasecmp(rdn_name, "cn") != 0) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_group_object: Bad RDN (%s) for group!\n", rdn_name); - talloc_free(mem_ctx); - return LDB_ERR_CONSTRAINT_VIOLATION; +static int samldb_check_sid_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct samldb_ctx *ac; + int ret; + + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - ret = samdb_search_for_parent_domain(module->ldb, mem_ctx, msg2->dn, &dom_dn, &errstr); + switch (ares->type) { + case LDB_REPLY_ENTRY: + + /* if we get an entry it means an object with the + * requested sid exists */ + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_CONSTRAINT_VIOLATION); + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: + + /* not found, go on */ + talloc_free(ares); + ret = samldb_next_step(ac); + break; + } + +done: + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + return LDB_SUCCESS; +} + +static int samldb_check_sid(struct samldb_ctx *ac) +{ + const char *const attrs[2] = { "objectSid", NULL }; + struct ldb_request *req; + char *filter; + int ret; + + if (ac->sid == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + filter = talloc_asprintf(ac, "(objectSid=%s)", + ldap_encode_ndr_dom_sid(ac, ac->sid)); + if (filter == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ldb_get_default_basedn(ac->module->ldb), + LDB_SCOPE_SUBTREE, + filter, attrs, + NULL, + ac, samldb_check_sid_callback, + ac->req); + if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, - "samldb_fill_group_object: %s", errstr); return ret; } - /* Generate a random name, if no samAccountName was supplied */ - if (ldb_msg_find_element(msg2, "samAccountName") == NULL) { - ret = samldb_generate_samAccountName(module, mem_ctx, dom_dn, &name); - if (ret != LDB_SUCCESS) { - talloc_free(mem_ctx); - return ret; - } - ret = samdb_find_or_add_attribute(module->ldb, msg2, "sAMAccountName", name); - if (ret) { - talloc_free(mem_ctx); - return ret; - } + return ldb_next_request(ac->module, req); +} + +static int samldb_notice_sid_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct samldb_ctx *ac; + int ret; + + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } - - if (ldb_msg_find_element(msg2, "sAMAccountType") != NULL) { - ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified"); - talloc_free(mem_ctx); - return LDB_ERR_UNWILLING_TO_PERFORM; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - group_type = samdb_result_uint(msg2, "groupType", 0); - if (group_type == 0) { - ldb_asprintf_errstring(module->ldb, "groupType invalid"); - talloc_free(mem_ctx); - return LDB_ERR_UNWILLING_TO_PERFORM; - } else { - unsigned int account_type = samdb_gtype2atype(group_type); - ret = samdb_msg_add_uint(module->ldb, msg2, msg2, - "sAMAccountType", - account_type); - if (ret != LDB_SUCCESS) { - return ret; - } + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, + "Invalid reply type!\n"); + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } - /* Manage SID allocation, conflicts etc */ - ret = samldb_handle_sid(module, mem_ctx, msg2, dom_dn); + ret = samldb_next_step(ac); - if (ret == LDB_SUCCESS) { - talloc_steal(msg, msg2); - *ret_msg = msg2; +done: + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); } - talloc_free(mem_ctx); - return ret; + + return LDB_SUCCESS; } -static int samldb_fill_user_or_computer_object(struct ldb_module *module, const struct ldb_message *msg, struct ldb_message **ret_msg) +/* If we are adding new users/groups, we need to update the nextRid + * attribute to be 'above' the new/incoming RID. Attempt to do it + *atomically. */ +static int samldb_notice_sid(struct samldb_ctx *ac) { + uint32_t old_id, new_id; + struct ldb_request *req; + struct ldb_message *msg; + struct ldb_message_element *els; + struct ldb_val *vals; int ret; - char *name; - struct ldb_message *msg2; - struct ldb_dn *dom_dn; - const char *rdn_name; - TALLOC_CTX *mem_ctx = talloc_new(msg); - const char *errstr; - unsigned int user_account_control; - if (!mem_ctx) { + + old_id = ac->next_rid; + new_id = ac->sid->sub_auths[ac->sid->num_auths - 1]; + + if (old_id >= new_id) { + /* no need to update the domain nextRid attribute */ + return samldb_next_step(ac); + } + + /* we do a delete and add as a single operation. That prevents + a race, in case we are not actually on a transaction db */ + msg = talloc_zero(ac, struct ldb_message); + if (msg == NULL) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + els = talloc_array(msg, struct ldb_message_element, 2); + if (els == NULL) { + ldb_oom(ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } + vals = talloc_array(msg, struct ldb_val, 2); + if (vals == NULL) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + msg->dn = ac->domain_dn; + msg->num_elements = 2; + msg->elements = els; - /* build the new msg */ - msg2 = ldb_msg_copy(mem_ctx, msg); - if (!msg2) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_user_or_computer_object: ldb_msg_copy failed!\n"); - talloc_free(mem_ctx); + els[0].num_values = 1; + els[0].values = &vals[0]; + els[0].flags = LDB_FLAG_MOD_DELETE; + els[0].name = talloc_strdup(msg, "nextRid"); + if (!els[0].name) { + ldb_oom(ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = samdb_copy_template(module->ldb, msg2, - "user", - &errstr); - if (ret) { - ldb_asprintf_errstring(module->ldb, - "samldb_fill_user_or_computer_object: Error copying user template: %s\n", - errstr); - talloc_free(mem_ctx); + els[1].num_values = 1; + els[1].values = &vals[1]; + els[1].flags = LDB_FLAG_MOD_ADD; + els[1].name = els[0].name; + + vals[0].data = (uint8_t *)talloc_asprintf(vals, "%u", old_id); + if (!vals[0].data) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + vals[0].length = strlen((char *)vals[0].data); + + vals[1].data = (uint8_t *)talloc_asprintf(vals, "%u", new_id); + if (!vals[1].data) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + vals[1].length = strlen((char *)vals[1].data); + + ret = ldb_build_mod_req(&req, ac->module->ldb, ac, + msg, NULL, + ac, samldb_notice_sid_callback, + ac->req); + if (ret != LDB_SUCCESS) { return ret; } - rdn_name = ldb_dn_get_rdn_name(msg2->dn); + return ldb_next_request(ac->module, req); +} - if (strcasecmp(rdn_name, "cn") != 0) { - ldb_asprintf_errstring(module->ldb, "Bad RDN (%s=) for user/computer, should be CN=!\n", rdn_name); - talloc_free(mem_ctx); - return LDB_ERR_CONSTRAINT_VIOLATION; +static int samldb_add_entry_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct samldb_ctx *ac; + + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, + "Invalid reply type!\n"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ret = samdb_search_for_parent_domain(module->ldb, mem_ctx, msg2->dn, &dom_dn, &errstr); + /* we exit the samldb module here */ + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); +} + +static int samldb_add_entry(struct samldb_ctx *ac) +{ + struct ldb_request *req; + int ret; + + ret = ldb_build_add_req(&req, ac->module->ldb, ac, + ac->msg, + ac->req->controls, + ac, samldb_add_entry_callback, + ac->req); if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, - "samldb_fill_user_or_computer_object: %s", errstr); return ret; } - if (ldb_msg_find_element(msg2, "samAccountName") == NULL) { - ret = samldb_generate_samAccountName(module, mem_ctx, dom_dn, &name); - if (ret != LDB_SUCCESS) { - talloc_free(mem_ctx); - return ret; - } - ret = samdb_find_or_add_attribute(module->ldb, msg2, "sAMAccountName", name); - if (ret) { - talloc_free(mem_ctx); - return ret; - } + return ldb_next_request(ac->module, req); +} + +static int samldb_fill_object(struct samldb_ctx *ac, const char *type) +{ + int ret; + + /* first look for the template */ + ac->type = type; + ret = samldb_add_step(ac, samldb_search_template); + if (ret != LDB_SUCCESS) return ret; + + /* then apply it */ + ret = samldb_add_step(ac, samldb_apply_template); + if (ret != LDB_SUCCESS) return ret; + + /* search for a parent domain objet */ + ac->check_dn = ac->req->op.add.message->dn; + ret = samldb_add_step(ac, samldb_get_parent_domain); + if (ret != LDB_SUCCESS) return ret; + + /* check if we have a valid samAccountName */ + ret = samldb_add_step(ac, samldb_check_samAccountName); + if (ret != LDB_SUCCESS) return ret; + + /* check account_type/group_type */ + ret = samldb_add_step(ac, samldb_check_samAccountType); + if (ret != LDB_SUCCESS) return ret; + + /* check if we have a valid SID */ + ac->sid = samdb_result_dom_sid(ac, ac->msg, "objectSid"); + if ( ! ac->sid) { + ret = samldb_add_step(ac, samldb_new_sid); + if (ret != LDB_SUCCESS) return ret; + } else { + ret = samldb_add_step(ac, samldb_get_sid_domain); + if (ret != LDB_SUCCESS) return ret; } - if (ldb_msg_find_element(msg2, "sAMAccountType") != NULL) { - ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified"); - talloc_free(mem_ctx); - return LDB_ERR_UNWILLING_TO_PERFORM; + ret = samldb_add_step(ac, samldb_check_sid); + if (ret != LDB_SUCCESS) return ret; + + ret = samldb_add_step(ac, samldb_notice_sid); + if (ret != LDB_SUCCESS) return ret; + + /* finally proceed with adding the entry */ + ret = samldb_add_step(ac, samldb_add_entry); + if (ret != LDB_SUCCESS) return ret; + + return samldb_first_step(ac); + + /* TODO: userAccountControl, badPwdCount, codePage, + * countryCode, badPasswordTime, lastLogoff, lastLogon, + * pwdLastSet, primaryGroupID, accountExpires, logonCount */ + +} + +static int samldb_foreign_notice_sid_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct samldb_ctx *ac; + const char *nextRid; + const char *name; + int ret; + + ac = talloc_get_type(req->context, struct samldb_ctx); + + if (!ares) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } - user_account_control = samdb_result_uint(msg2, "userAccountControl", 0); - if (user_account_control == 0) { - ldb_asprintf_errstring(module->ldb, "userAccountControl invalid"); - talloc_free(mem_ctx); - return LDB_ERR_UNWILLING_TO_PERFORM; - } else { - unsigned int account_type = samdb_uf2atype(user_account_control); - ret = samdb_msg_add_uint(module->ldb, msg2, msg2, - "sAMAccountType", - account_type); - if (ret != LDB_SUCCESS) { - return ret; - } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - /* Manage SID allocation, conflicts etc */ - ret = samldb_handle_sid(module, mem_ctx, msg2, dom_dn); + switch (ares->type) { + case LDB_REPLY_ENTRY: + /* save entry */ + if (ac->next_rid != 0) { + /* one too many! */ + ldb_set_errstring(ac->module->ldb, + "Invalid number of results while searching " + "for domain object"); + ret = LDB_ERR_OPERATIONS_ERROR; + break; + } - /* TODO: userAccountControl, badPwdCount, codePage, countryCode, badPasswordTime, lastLogoff, lastLogon, pwdLastSet, primaryGroupID, accountExpires, logonCount */ + nextRid = ldb_msg_find_attr_as_string(ares->message, + "nextRid", NULL); + if (nextRid == NULL) { + ldb_asprintf_errstring(ac->module->ldb, + "attribute nextRid not found in %s\n", + ldb_dn_get_linearized(ares->message->dn)); + ret = LDB_ERR_OPERATIONS_ERROR; + break; + } + + ac->next_rid = strtol(nextRid, NULL, 0); + + ac->domain_dn = talloc_steal(ac, ares->message->dn); + + name = samdb_result_string(ares->message, "name", NULL); + ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, + "NOTE (strange but valid): Adding foreign SID " + "record with SID %s, but this domain (%s) is " + "not foreign in the database", + dom_sid_string(ares, ac->sid), name); - if (ret == 0) { - *ret_msg = msg2; - talloc_steal(msg, msg2); + talloc_free(ares); + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: + + /* if this is a fake foreign SID, notice the SID */ + if (ac->domain_dn) { + ret = samldb_notice_sid(ac); + break; + } + + /* found, go on */ + ret = samldb_next_step(ac); + break; + } + +done: + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); } - talloc_free(mem_ctx); - return ret; + + return LDB_SUCCESS; } - -static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module, const struct ldb_message *msg, - struct ldb_message **ret_msg) + +/* Find a domain object in the parents of a particular DN. */ +static int samldb_foreign_notice_sid(struct samldb_ctx *ac) { - struct ldb_message *msg2; - const char *rdn_name; - struct dom_sid *dom_sid; - struct dom_sid *sid; - const char *dom_attrs[] = { "name", NULL }; - struct ldb_message **dom_msgs; - const char *errstr; + static const char * const attrs[3] = { "nextRid", "name", NULL }; + struct ldb_request *req; + char *filter; int ret; - TALLOC_CTX *mem_ctx = talloc_new(msg); - if (!mem_ctx) { + if (ac->sid == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - /* build the new msg */ - msg2 = ldb_msg_copy(mem_ctx, msg); - if (!msg2) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_foreignSecurityPrincipal_object: ldb_msg_copy failed!\n"); - talloc_free(mem_ctx); + ac->domain_sid = dom_sid_dup(ac, ac->sid); + if (!ac->domain_sid) { return LDB_ERR_OPERATIONS_ERROR; } + /* get the domain component part of the provided SID */ + ac->domain_sid->num_auths--; - ret = samdb_copy_template(module->ldb, msg2, - "ForeignSecurityPrincipal", - &errstr); - if (ret != 0) { - ldb_asprintf_errstring(module->ldb, - "samldb_fill_foreignSecurityPrincipal_object: " - "Error copying template: %s", - errstr); - talloc_free(mem_ctx); - return ret; + filter = talloc_asprintf(ac, "(&(objectSid=%s)(objectclass=domain))", + ldap_encode_ndr_dom_sid(ac, ac->domain_sid)); + if (filter == NULL) { + return LDB_ERR_OPERATIONS_ERROR; } - rdn_name = ldb_dn_get_rdn_name(msg2->dn); + ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ldb_get_default_basedn(ac->module->ldb), + LDB_SCOPE_SUBTREE, + filter, attrs, + NULL, + ac, samldb_foreign_notice_sid_callback, + ac->req); - if (strcasecmp(rdn_name, "cn") != 0) { - ldb_asprintf_errstring(module->ldb, "Bad RDN (%s=) for ForeignSecurityPrincipal, should be CN=!", rdn_name); - talloc_free(mem_ctx); - return LDB_ERR_CONSTRAINT_VIOLATION; + if (ret != LDB_SUCCESS) { + return ret; } - sid = samdb_result_dom_sid(msg2, msg, "objectSid"); - if (!sid) { - /* Slightly different for the foreign sids. We don't want - * domain SIDs ending up there, it would cause all sorts of - * pain */ - - sid = dom_sid_parse_talloc(msg2, (const char *)ldb_dn_get_rdn_val(msg2->dn)->data); - if (!sid) { - ldb_set_errstring(module->ldb, "No valid found SID in ForeignSecurityPrincipal CN!"); - talloc_free(mem_ctx); - return LDB_ERR_CONSTRAINT_VIOLATION; - } + ac->next_rid = 0; + return ldb_next_request(ac->module, req); +} - if ( ! samldb_msg_add_sid(module, msg2, "objectSid", sid)) { - talloc_free(sid); - return LDB_ERR_OPERATIONS_ERROR; - } +static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac) +{ + int ret; - dom_sid = dom_sid_dup(mem_ctx, sid); - if (!dom_sid) { - talloc_free(mem_ctx); - return LDB_ERR_OPERATIONS_ERROR; + ac->sid = samdb_result_dom_sid(ac->msg, ac->msg, "objectSid"); + if (ac->sid == NULL) { + ac->sid = dom_sid_parse_talloc(ac->msg, + (const char *)ldb_dn_get_rdn_val(ac->msg->dn)->data); + if (!ac->sid) { + ldb_set_errstring(ac->module->ldb, + "No valid found SID in " + "ForeignSecurityPrincipal CN!"); + talloc_free(ac); + return LDB_ERR_CONSTRAINT_VIOLATION; } - /* get the domain component part of the provided SID */ - dom_sid->num_auths--; - - /* find the domain DN */ - - ret = gendb_search(module->ldb, - mem_ctx, NULL, &dom_msgs, dom_attrs, - "(&(objectSid=%s)(objectclass=domain))", - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid)); - if (ret >= 1) { - /* We don't really like the idea of foreign sids that are not foreign, but it happens */ - const char *name = samdb_result_string(dom_msgs[0], "name", NULL); - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "NOTE (strange but valid): Adding foreign SID record with SID %s, but this domian (%s) is already in the database", - dom_sid_string(mem_ctx, sid), name); - } else if (ret == -1) { - ldb_asprintf_errstring(module->ldb, - "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n", - dom_sid_string(mem_ctx, dom_sid)); - talloc_free(dom_msgs); + if ( ! samldb_msg_add_sid(ac->msg, "objectSid", ac->sid)) { + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } } - /* This isn't an operation on a domain we know about, so just - * check for the SID, looking for duplicates via the common - * code */ - ret = samldb_notice_sid(module, msg2, sid); - if (ret == 0) { - talloc_steal(msg, msg2); - *ret_msg = msg2; - } - - return ret; + /* first look for the template */ + ac->type = "foreignSecurityPrincipal"; + ret = samldb_add_step(ac, samldb_search_template); + if (ret != LDB_SUCCESS) return ret; + + /* then apply it */ + ret = samldb_add_step(ac, samldb_apply_template); + if (ret != LDB_SUCCESS) return ret; + + /* check we do not already have this SID */ + ret = samldb_add_step(ac, samldb_check_sid); + if (ret != LDB_SUCCESS) return ret; + + /* check if we need to notice this SID */ + ret = samldb_add_step(ac, samldb_foreign_notice_sid); + if (ret != LDB_SUCCESS) return ret; + + /* finally proceed with adding the entry */ + ret = samldb_add_step(ac, samldb_add_entry); + if (ret != LDB_SUCCESS) return ret; + + return samldb_first_step(ac); } -/* add_record */ +static int samldb_check_rdn(struct ldb_module *module, struct ldb_dn *dn) +{ + const char *rdn_name; -/* - * FIXME - * - * Actually this module is not async at all as it does a number of sync searches - * in the process. It still to be decided how to deal with it properly so it is - * left SYNC for now until we think of a good solution. - */ + rdn_name = ldb_dn_get_rdn_name(dn); + + if (strcasecmp(rdn_name, "cn") != 0) { + ldb_asprintf_errstring(module->ldb, + "Bad RDN (%s=) for samldb object, " + "should be CN=!\n", rdn_name); + return LDB_ERR_CONSTRAINT_VIOLATION; + } + return LDB_SUCCESS; +} + +/* add_record */ static int samldb_add(struct ldb_module *module, struct ldb_request *req) { - const struct ldb_message *msg = req->op.add.message; - struct ldb_message *msg2 = NULL; - struct ldb_request *down_req; + struct samldb_ctx *ac; int ret; ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_add_record\n"); - if (ldb_dn_is_special(msg->dn)) { /* do not manipulate our control entries */ + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.add.message->dn)) { return ldb_next_request(module, req); } - /* is user or computer? */ - if ((samdb_find_attribute(module->ldb, msg, "objectclass", "user") != NULL) || - (samdb_find_attribute(module->ldb, msg, "objectclass", "computer") != NULL)) { - /* add all relevant missing objects */ - ret = samldb_fill_user_or_computer_object(module, msg, &msg2); - if (ret) { - return ret; - } + ac = samldb_ctx_init(module, req); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; } - /* is group? add all relevant missing objects */ - if ( ! msg2 ) { - if (samdb_find_attribute(module->ldb, msg, "objectclass", "group") != NULL) { - ret = samldb_fill_group_object(module, msg, &msg2); - if (ret) { - return ret; - } - } + /* build the new msg */ + ac->msg = ldb_msg_copy(ac, ac->req->op.add.message); + if (!ac->msg) { + talloc_free(ac); + ldb_debug(ac->module->ldb, LDB_DEBUG_FATAL, + "samldb_add: ldb_msg_copy failed!\n"); + return LDB_ERR_OPERATIONS_ERROR; } - /* perhaps a foreignSecurityPrincipal? */ - if ( ! msg2 ) { - if (samdb_find_attribute(module->ldb, msg, "objectclass", "foreignSecurityPrincipal") != NULL) { - ret = samldb_fill_foreignSecurityPrincipal_object(module, msg, &msg2); - if (ret) { - return ret; - } + if (samdb_find_attribute(module->ldb, ac->msg, + "objectclass", "computer") != NULL) { + + /* make sure the computer object also has the 'user' + * objectclass so it will be handled by the next call */ + ret = samdb_find_or_add_value(module->ldb, ac->msg, + "objectclass", "user"); + if (ret != LDB_SUCCESS) { + talloc_free(ac); + return ret; } } - if (msg2 == NULL) { - return ldb_next_request(module, req); - } + if (samdb_find_attribute(module->ldb, ac->msg, + "objectclass", "user") != NULL) { - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + ret = samldb_check_rdn(module, ac->req->op.add.message->dn); + if (ret != LDB_SUCCESS) { + talloc_free(ac); + return ret; + } + + return samldb_fill_object(ac, "user"); } - *down_req = *req; - - down_req->op.add.message = talloc_steal(down_req, msg2); + if (samdb_find_attribute(module->ldb, ac->msg, + "objectclass", "group") != NULL) { + + ret = samldb_check_rdn(module, ac->req->op.add.message->dn); + if (ret != LDB_SUCCESS) { + talloc_free(ac); + return ret; + } - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); + return samldb_fill_object(ac, "group"); + } - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); + /* perhaps a foreignSecurityPrincipal? */ + if (samdb_find_attribute(module->ldb, ac->msg, + "objectclass", + "foreignSecurityPrincipal") != NULL) { - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = samldb_check_rdn(module, ac->req->op.add.message->dn); + if (ret != LDB_SUCCESS) { + talloc_free(ac); + return ret; + } + + return samldb_fill_foreignSecurityPrincipal_object(ac); } - return ret; + talloc_free(ac); + + /* nothing matched, go on */ + return ldb_next_request(module, req); } /* modify */ @@ -777,6 +1315,8 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_UNWILLING_TO_PERFORM; } + /* TODO: do not modify original request, create a new one */ + el = ldb_msg_find_element(req->op.mod.message, "groupType"); if (el && el->flags & (LDB_FLAG_MOD_ADD|LDB_FLAG_MOD_REPLACE) && el->num_values == 1) { req->op.mod.message = msg = ldb_msg_copy_shallow(req, req->op.mod.message); diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index 968b19c038..0266654811 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -29,7 +29,7 @@ #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg, @@ -62,8 +62,10 @@ struct schema_fsmo_private_data { }; struct schema_fsmo_search_data { - struct schema_fsmo_private_data *module_context; - struct ldb_request *orig_req; + struct ldb_module *module; + struct ldb_request *req; + + const struct dsdb_schema *schema; }; static int schema_fsmo_init(struct ldb_module *module) @@ -152,6 +154,16 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) uint32_t id32; WERROR status; + /* special objects should always go through */ + if (ldb_dn_is_special(req->op.add.message->dn)) { + return ldb_next_request(module, req); + } + + /* replicated update should always go through */ + if (ldb_request_get_control(req, DSDB_CONTROL_REPLICATED_UPDATE_OID)) { + return ldb_next_request(module, req); + } + schema = dsdb_get_schema(module->ldb); if (!schema) { return ldb_next_request(module, req); @@ -307,7 +319,7 @@ static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message } } } - return 0; + return LDB_SUCCESS; } @@ -315,41 +327,54 @@ static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message /* Add objectClasses, attributeTypes and dITContentRules from the schema object (they are not stored in the database) */ -static int schema_fsmo_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - const struct dsdb_schema *schema = dsdb_get_schema(ldb); - struct schema_fsmo_search_data *search_data = talloc_get_type(context, struct schema_fsmo_search_data); - struct ldb_request *orig_req = search_data->orig_req; - TALLOC_CTX *mem_ctx; + struct schema_fsmo_search_data *ac; + struct schema_fsmo_private_data *mc; int i, ret; - /* Only entries are interesting, and we handle the case of the parent seperatly */ - if (ares->type != LDB_REPLY_ENTRY) { - return orig_req->callback(ldb, orig_req->context, ares); - } + ac = talloc_get_type(req->context, struct schema_fsmo_search_data); + mc = talloc_get_type(ac->module->private_data, struct schema_fsmo_private_data); - if (ldb_dn_compare(ares->message->dn, search_data->module_context->aggregate_dn) != 0) { - talloc_free(mem_ctx); - return orig_req->callback(ldb, orig_req->context, ares); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - - mem_ctx = talloc_new(ares); - if (!mem_ctx) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } + /* Only entries are interesting, and we handle the case of the parent seperatly */ - for (i=0; i < ARRAY_SIZE(generated_attrs); i++) { - if (ldb_attr_in_list(orig_req->op.search.attrs, generated_attrs[i].attr)) { - ret = generated_attrs[i].fn(ldb, ares->message, schema); - if (ret != LDB_SUCCESS) { - return ret; + switch (ares->type) { + case LDB_REPLY_ENTRY: + + if (ldb_dn_compare(ares->message->dn, mc->aggregate_dn) != 0) { + return ldb_module_send_entry(ac->req, ares->message); + } + + for (i=0; i < ARRAY_SIZE(generated_attrs); i++) { + if (ldb_attr_in_list(ac->req->op.search.attrs, generated_attrs[i].attr)) { + ret = generated_attrs[i].fn(ac->module->ldb, ares->message, ac->schema); + if (ret != LDB_SUCCESS) { + return ret; + } } } + + return ldb_module_send_entry(ac->req, ares->message); + + case LDB_REPLY_REFERRAL: + + return ldb_module_send_referral(ac->req, ares->referral); + + case LDB_REPLY_DONE: + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - talloc_free(mem_ctx); - return orig_req->callback(ldb, orig_req->context, ares); + return LDB_SUCCESS; } /* search */ @@ -380,27 +405,24 @@ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - down_req = talloc(req, struct ldb_request); - if (!down_req) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - *down_req = *req; - search_context->orig_req = req; - search_context->module_context = talloc_get_type(module->private_data, struct schema_fsmo_private_data); - down_req->context = search_context; - down_req->callback = schema_fsmo_search_callback; + search_context->module = module; + search_context->req = req; + search_context->schema = schema; - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_search_req_ex(&down_req, module->ldb, search_context, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + req->op.search.attrs, + req->controls, + search_context, schema_fsmo_search_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - return ret; + + return ldb_next_request(module, down_req); } diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c index 361cf226dc..0e3b46debe 100644 --- a/source4/dsdb/samdb/ldb_modules/show_deleted.c +++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c @@ -27,7 +27,7 @@ * * Component: ldb deleted objects control module * - * Description: this module hides deleted objects, and returns them if the control is there + * Description: this module hides deleted objects, and returns them if the right control is there * * Author: Stefan Metzmacher */ @@ -42,36 +42,38 @@ struct show_deleted_search_request { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); - - bool remove_from_msg; + struct ldb_request *req; }; -static int show_deleted_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int show_deleted_search_callback(struct ldb_request *req, + struct ldb_reply *ares) { struct show_deleted_search_request *ar; - ar = talloc_get_type(context, struct show_deleted_search_request); + ar = talloc_get_type(req->context, struct show_deleted_search_request); - if (ares->type == LDB_REPLY_ENTRY) { - bool isDeleted; + if (!ares) { + return ldb_module_done(ar->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ar->req, ares->controls, + ares->response, ares->error); + } - isDeleted = ldb_msg_find_attr_as_bool(ares->message, "isDeleted", false); + switch (ares->type) { + case LDB_REPLY_ENTRY: - if (isDeleted) { - goto skip_deleted; - } + return ldb_module_send_entry(ar->req, ares->message); - if (ar->remove_from_msg) { - ldb_msg_remove_attr(ares->message, "isDeleted"); - } - } + case LDB_REPLY_REFERRAL: + return ldb_module_send_referral(ar->req, ares->referral); - return ar->up_callback(ldb, ar->up_context, ares); + case LDB_REPLY_DONE: + return ldb_module_done(ar->req, ares->controls, + ares->response, LDB_SUCCESS); -skip_deleted: - talloc_free(ares); + } return LDB_SUCCESS; } @@ -81,116 +83,68 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re struct ldb_control **saved_controls; struct show_deleted_search_request *ar; struct ldb_request *down_req; - char **new_attrs; - uint32_t num_attrs = 0; - uint32_t i; + char *old_filter; + char *new_filter; int ret; - /* check if there's a show deleted control */ - control = ldb_request_get_control(req, LDB_CONTROL_SHOW_DELETED_OID); - - /* copy the request for modification */ - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { - ldb_oom(module->ldb); + ar = talloc_zero(req, struct show_deleted_search_request); + if (ar == NULL) { return LDB_ERR_OPERATIONS_ERROR; } + ar->module = module; + ar->req = req; - /* copy the request */ - *down_req = *req; + /* check if there's a show deleted control */ + control = ldb_request_get_control(req, LDB_CONTROL_SHOW_DELETED_OID); - /* if a control is there remove if from the modified request */ - if (control && !save_controls(control, down_req, &saved_controls)) { - return LDB_ERR_OPERATIONS_ERROR; - } + if ( ! control) { + old_filter = ldb_filter_from_tree(ar, req->op.search.tree); + new_filter = talloc_asprintf(ar, "(&(!(isDeleted=TRUE))%s)", + old_filter); - /* if we had a control, then just go on to the next request as we have nothing to hide */ - if (control) { - goto next_request; - } + ret = ldb_build_search_req(&down_req, module->ldb, ar, + req->op.search.base, + req->op.search.scope, + new_filter, + req->op.search.attrs, + req->controls, + ar, show_deleted_search_callback, + req); - ar = talloc(down_req, struct show_deleted_search_request); - if (ar == NULL) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - ar->module = module; - ar->up_context = req->context; - ar->up_callback = req->callback; - ar->remove_from_msg = true; - - /* check if attrs only is specified, in that case check wether we need to modify them */ - if (down_req->op.search.attrs) { - for (i=0; (down_req->op.search.attrs && down_req->op.search.attrs[i]); i++) { - num_attrs++; - if (strcasecmp(down_req->op.search.attrs[i], "*") == 0) { - ar->remove_from_msg = false; - } else if (strcasecmp(down_req->op.search.attrs[i], "isDeleted") == 0) { - ar->remove_from_msg = false; - } - } } else { - ar->remove_from_msg = false; + ret = ldb_build_search_req_ex(&down_req, module->ldb, ar, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + req->op.search.attrs, + req->controls, + ar, show_deleted_search_callback, + req); } - - if (ar->remove_from_msg) { - new_attrs = talloc_array(down_req, char *, num_attrs + 2); - if (!new_attrs) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - for (i=0; i < num_attrs; i++) { - new_attrs[i] = discard_const_p(char, down_req->op.search.attrs[i]); - } - new_attrs[i] = talloc_strdup(new_attrs, "isDeleted"); - if (!new_attrs[i]) { - ldb_oom(module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - new_attrs[i+1] = NULL; - down_req->op.search.attrs = (const char * const *)new_attrs; + if (ret != LDB_SUCCESS) { + return ret; } - down_req->context = ar; - down_req->callback = show_deleted_search_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - -next_request: - /* perform the search */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + /* if a control is there remove if from the modified request */ + if (control && !save_controls(control, down_req, &saved_controls)) { + return LDB_ERR_OPERATIONS_ERROR; } - return ret; + /* perform the search */ + return ldb_next_request(module, down_req); } static int show_deleted_init(struct ldb_module *module) { - struct ldb_request *req; int ret; - req = talloc(module, struct ldb_request); - if (req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - req->operation = LDB_REQ_REGISTER_CONTROL; - req->op.reg_control.oid = LDB_CONTROL_SHOW_DELETED_OID; - req->controls = NULL; - - ret = ldb_request(module->ldb, req); + ret = ldb_mod_register_control(module, LDB_CONTROL_SHOW_DELETED_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "show_deleted: Unable to register control with rootdse!\n"); - talloc_free(req); + ldb_debug(module->ldb, LDB_DEBUG_ERROR, + "extended_dn: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } - talloc_free(req); return ldb_next_init(module); } diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index 8f92995145..c353914e2c 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -36,6 +36,11 @@ #include "librpc/ndr/libndr.h" #include "dsdb/samdb/samdb.h" +struct entryuuid_private { + struct ldb_context *ldb; + struct ldb_dn **base_dns; +}; + static struct ldb_val encode_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { struct GUID guid; @@ -598,10 +603,18 @@ static int nsuniqueid_init(struct ldb_module *module) return ldb_next_init(module); } -static int get_seq(struct ldb_context *ldb, void *context, - struct ldb_reply *ares) +static int get_seq_callback(struct ldb_request *req, + struct ldb_reply *ares) { - unsigned long long *seq = (unsigned long long *)context; + unsigned long long *seq = (unsigned long long *)req->context; + + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_request_done(req, ares->error); + } + if (ares->type == LDB_REPLY_ENTRY) { struct ldb_message_element *el = ldb_msg_find_element(ares->message, "contextCSN"); if (el) { @@ -609,6 +622,11 @@ static int get_seq(struct ldb_context *ldb, void *context, } } + if (ares->type == LDB_REPLY_DONE) { + return ldb_request_done(req, LDB_SUCCESS); + } + + talloc_free(ares); return LDB_SUCCESS; } @@ -617,7 +635,7 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque int ret; struct map_private *map_private; struct entryuuid_private *entryuuid_private; - unsigned long long seq = 0; + unsigned long long seq_num = 0; struct ldb_request *search_req; const struct ldb_control *partition_ctrl; @@ -627,6 +645,12 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque "contextCSN", NULL }; + struct ldb_seqnum_request *seq; + struct ldb_seqnum_result *seqr; + struct ldb_extended *ext; + + seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request); + map_private = talloc_get_type(module->private_data, struct map_private); entryuuid_private = talloc_get_type(map_private->caller_private, struct entryuuid_private); @@ -635,7 +659,7 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID); if (!partition_ctrl) { ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, - "instancetype_add: no current partition control found"); + "entryuuid_sequence_number: no current partition control found"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -643,74 +667,79 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque struct dsdb_control_current_partition); SMB_ASSERT(partition && partition->version == DSDB_CONTROL_CURRENT_PARTITION_VERSION); - search_req = talloc(req, struct ldb_request); - if (search_req == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return LDB_ERR_OPERATIONS_ERROR; + ret = ldb_build_search_req(&search_req, module->ldb, req, + partition->dn, LDB_SCOPE_BASE, + NULL, contextCSN_attr, NULL, + &seq_num, get_seq_callback, + NULL); + if (ret != LDB_SUCCESS) { + return ret; } - - /* Finally, we have it. This saves searching over more - * partitions than we expose to the client, such as a cn=samba - * configuration partition */ - search_req->operation = LDB_SEARCH; - search_req->op.search.base = partition->dn; - search_req->op.search.scope = LDB_SCOPE_BASE; - - search_req->op.search.tree = ldb_parse_tree(search_req, "objectClass=*"); - if (search_req->op.search.tree == NULL) { - ldb_set_errstring(module->ldb, "Unable to parse search expression"); - talloc_free(search_req); - return LDB_ERR_OPERATIONS_ERROR; - } - - search_req->op.search.attrs = contextCSN_attr; - search_req->controls = NULL; - search_req->context = &seq; - search_req->callback = get_seq; - ldb_set_timeout(module->ldb, search_req, 0); /* use default timeout */ - ret = ldb_next_request(module, search_req); - + if (ret == LDB_SUCCESS) { ret = ldb_wait(search_req->handle, LDB_WAIT_ALL); } - + talloc_free(search_req); if (ret != LDB_SUCCESS) { return ret; } - switch (req->op.seq_num.type) { + ext = talloc_zero(req, struct ldb_extended); + if (!ext) { + return LDB_ERR_OPERATIONS_ERROR; + } + seqr = talloc_zero(req, struct ldb_seqnum_result); + if (seqr == NULL) { + talloc_free(ext); + return LDB_ERR_OPERATIONS_ERROR; + } + ext->oid = LDB_EXTENDED_SEQUENCE_NUMBER; + ext->data = seqr; + + switch (seq->type) { case LDB_SEQ_HIGHEST_SEQ: - req->op.seq_num.seq_num = seq; + seqr->seq_num = seq_num; break; case LDB_SEQ_NEXT: - req->op.seq_num.seq_num = seq; - req->op.seq_num.seq_num++; + seqr->seq_num = seq_num; + seqr->seq_num++; break; case LDB_SEQ_HIGHEST_TIMESTAMP: { - req->op.seq_num.seq_num = (seq >> 24); + seqr->seq_num = (seq_num >> 24); break; } } - req->op.seq_num.flags = 0; - req->op.seq_num.flags |= LDB_SEQ_TIMESTAMP_SEQUENCE; - req->op.seq_num.flags |= LDB_SEQ_GLOBAL_SEQUENCE; - return LDB_SUCCESS; + seqr->flags = 0; + seqr->flags |= LDB_SEQ_TIMESTAMP_SEQUENCE; + seqr->flags |= LDB_SEQ_GLOBAL_SEQUENCE; + + /* send request done */ + return ldb_module_done(req, NULL, ext, LDB_SUCCESS); +} + +static int entryuuid_extended(struct ldb_module *module, struct ldb_request *req) +{ + if (strcmp(req->op.extended.oid, LDB_EXTENDED_SEQUENCE_NUMBER) == 0) { + return entryuuid_sequence_number(module, req); + } + + return ldb_next_request(module, req); } _PUBLIC_ const struct ldb_module_ops ldb_entryuuid_module_ops = { .name = "entryuuid", .init_context = entryuuid_init, - .sequence_number = entryuuid_sequence_number, + .extended = entryuuid_extended, LDB_MAP_OPS }; _PUBLIC_ const struct ldb_module_ops ldb_nsuniqueid_module_ops = { .name = "nsuniqueid", .init_context = nsuniqueid_init, - .sequence_number = entryuuid_sequence_number, + .extended = entryuuid_extended, LDB_MAP_OPS }; diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c index 9c332d2969..10e2dc25ce 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c @@ -3,6 +3,7 @@ Copyright (C) Andrew Bartlett 2006-2007 Copyright (C) Stefan Metzmacher 2007 + Copyright (C) Simo Sorce 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 @@ -31,104 +32,88 @@ #include "ldb_includes.h" struct subtree_delete_context { - enum sd_step {SD_SEARCH, SD_DO_DEL} step; - struct ldb_module *module; - struct ldb_handle *handle; - struct ldb_request *orig_req; - - struct ldb_request *search_req; - struct ldb_request *down_req; + struct ldb_request *req; int num_children; }; -static struct subtree_delete_context *subtree_delete_init_handle(struct ldb_request *req, - struct ldb_module *module) +static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module, + struct ldb_request *req) { struct subtree_delete_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - ac = talloc_zero(h, struct subtree_delete_context); + ac = talloc_zero(req, struct subtree_delete_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); + ldb_oom(module->ldb); return NULL; } - h->private_data = ac; - ac->module = module; - ac->handle = h; - ac->orig_req = req; - - req->handle = h; + ac->req = req; return ac; } -static int subtree_delete_check_for_children(struct subtree_delete_context *ac) +static int subtree_delete_search_callback(struct ldb_request *req, + struct ldb_reply *ares) { - if (ac->num_children > 0) { - ldb_asprintf_errstring(ac->module->ldb, "Cannot delete %s, not a leaf node (has %d children)\n", - ldb_dn_get_linearized(ac->orig_req->op.del.dn), ac->num_children); - return LDB_ERR_NOT_ALLOWED_ON_NON_LEAF; - } else { - struct ldb_request *req = talloc(ac, struct ldb_request); - if (!req) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - *req = *ac->orig_req; - - /* Ensure any (io) errors during the search for - * children don't propgate back in the error string */ - ldb_set_errstring(ac->module->ldb, NULL); + struct subtree_delete_context *ac; + int ret; - ac->down_req = req; - ac->step = SD_DO_DEL; - return ldb_next_request(ac->module, req); - } -} + ac = talloc_get_type(req->context, struct subtree_delete_context); -static int subtree_delete_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) -{ - struct subtree_delete_context *ac = talloc_get_type(context, struct subtree_delete_context); - TALLOC_CTX *mem_ctx = talloc_new(ac); - - if (!mem_ctx) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - /* OK, we have one of *many* search results here: - We should also get the entry we tried to rename. This - callback handles this and everything below it. - */ + switch (ares->type) { + case LDB_REPLY_ENTRY: - /* Only entries are interesting, and we handle the case of the parent seperatly */ - if (ares->type == LDB_REPLY_ENTRY - && ldb_dn_compare(ares->message->dn, ac->orig_req->op.del.dn) != 0) { - /* And it is an actual entry: now object bitterly that we are not a leaf node */ + talloc_free(ares); ac->num_children++; + break; + + case LDB_REPLY_REFERRAL: + + /* ignore */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: + + if (ac->num_children > 0) { + talloc_free(ares); + ldb_asprintf_errstring(ac->module->ldb, + "Cannot delete %s, not a leaf node " + "(has %d children)\n", + ldb_dn_get_linearized(ac->req->op.del.dn), + ac->num_children); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_NOT_ALLOWED_ON_NON_LEAF); + } + + /* ok no children, let the original request through */ + ret = ldb_next_request(ac->module, ac->req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + /* free our own context we are not going to be called back */ + talloc_free(ac); } - talloc_free(ares); return LDB_SUCCESS; } -/* rename */ static int subtree_delete(struct ldb_module *module, struct ldb_request *req) { - const char *attrs[] = { NULL }; - struct ldb_request *new_req; + static const char * const attrs[2] = { "distinguishedName", NULL }; + struct ldb_request *search_req; struct subtree_delete_context *ac; int ret; if (ldb_dn_is_special(req->op.rename.olddn)) { /* do not manipulate our control entries */ @@ -142,119 +127,28 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req) - return an error if there are any */ - ac = subtree_delete_init_handle(req, module); + ac = subdel_ctx_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&new_req, module->ldb, req, - req->op.del.dn, - LDB_SCOPE_SUBTREE, - "(objectClass=*)", - attrs, + /* we do not really need to find all descendents, + * if there is even one single direct child, that's + * enough to bail out */ + ret = ldb_build_search_req(&search_req, module->ldb, ac, + req->op.del.dn, LDB_SCOPE_ONELEVEL, + "(objectClass=*)", attrs, req->controls, - ac, - subtree_delete_search_callback); - + ac, subtree_delete_search_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); - - if (ret != LDB_SUCCESS) { - return ret; - } - - ac->search_req = new_req; - if (req == NULL) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - return ldb_next_request(module, new_req); -} - - -static int subtree_delete_wait_none(struct ldb_handle *handle) { - struct subtree_delete_context *ac; - int ret = LDB_ERR_OPERATIONS_ERROR; - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct subtree_delete_context); - - switch (ac->step) { - case SD_SEARCH: - ret = ldb_wait(ac->search_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) { - handle->status = ret; - goto done; - } - if (ac->search_req->handle->status != LDB_SUCCESS - && ac->search_req->handle->status != LDB_ERR_NO_SUCH_OBJECT) { - handle->status = ac->search_req->handle->status; - goto done; - } - - return subtree_delete_check_for_children(ac); - - case SD_DO_DEL: - ret = ldb_wait(ac->down_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req->handle->status; - goto done; - } - - if (ac->down_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; - } -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - -static int subtree_delete_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = subtree_delete_wait_none(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; -} - -static int subtree_delete_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return subtree_delete_wait_all(handle); - } else { - return subtree_delete_wait_none(handle); - } + return ldb_next_request(module, search_req); } const struct ldb_module_ops ldb_subtree_delete_module_ops = { .name = "subtree_delete", .del = subtree_delete, - .wait = subtree_delete_wait, }; diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c index fd1388d416..d3ceb8ad97 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c @@ -30,137 +30,182 @@ #include "ldb_includes.h" +struct subren_msg_store { + struct subren_msg_store *next; + struct ldb_dn *olddn; + struct ldb_dn *newdn; +}; + struct subtree_rename_context { struct ldb_module *module; - struct ldb_handle *handle; - struct ldb_request *orig_req; - - struct ldb_request **down_req; - int num_requests; - int finished_requests; + struct ldb_request *req; - int num_children; + struct subren_msg_store *list; + struct subren_msg_store *current; }; -static struct subtree_rename_context *subtree_rename_init_handle(struct ldb_request *req, - struct ldb_module *module) +static struct subtree_rename_context *subren_ctx_init(struct ldb_module *module, + struct ldb_request *req) { struct subtree_rename_context *ac; - struct ldb_handle *h; - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ac = talloc_zero(req, struct subtree_rename_context); + if (ac == NULL) { + ldb_oom(module->ldb); return NULL; } - h->module = module; + ac->module = module; + ac->req = req; - ac = talloc_zero(h, struct subtree_rename_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; + return ac; +} + +static int subtree_rename_next_request(struct subtree_rename_context *ac); + +static int subtree_rename_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct subtree_rename_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct subtree_rename_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - h->private_data = ac; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ac->module = module; - ac->handle = h; - ac->orig_req = req; + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, "Invalid reply type!\n"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - req->handle = h; + if (ac->current == NULL) { + /* this was the last one */ + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + } - return ac; -} + ret = subtree_rename_next_request(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + talloc_free(ares); + return LDB_SUCCESS; +} -static int subtree_rename_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int subtree_rename_next_request(struct subtree_rename_context *ac) { struct ldb_request *req; - struct subtree_rename_context *ac = talloc_get_type(context, struct subtree_rename_context); - TALLOC_CTX *mem_ctx = talloc_new(ac); - - if (!mem_ctx) { - ldb_oom(ac->module->ldb); + int ret; + + if (ac->current == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - /* OK, we have one of *many* search results here: - - We should also get the entry we tried to rename. This - callback handles this and everything below it. - */ - - /* Only entries are interesting, and we handle the case of the parent seperatly */ - if (ares->type == LDB_REPLY_ENTRY - && ldb_dn_compare(ares->message->dn, ac->orig_req->op.rename.olddn) != 0) { - /* And it is an actual entry: now create a rename from it */ - int ret; - - struct ldb_dn *newdn = ldb_dn_copy(mem_ctx, ares->message->dn); - if (!newdn) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + + ret = ldb_build_rename_req(&req, ac->module->ldb, ac->current, + ac->current->olddn, + ac->current->newdn, + ac->req->controls, + ac, subtree_rename_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; + } + + ac->current = ac->current->next; + + return ldb_next_request(ac->module, req); +} + +static int subtree_rename_search_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct subren_msg_store *store; + struct subtree_rename_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct subtree_rename_context); + + if (!ares || !ac->current) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + + if (ldb_dn_compare(ares->message->dn, ac->list->olddn) == 0) { + /* this was already stored by the + * subtree_rename_search() */ + talloc_free(ares); + return LDB_SUCCESS; } - - ldb_dn_remove_base_components(newdn, ldb_dn_get_comp_num(ac->orig_req->op.rename.olddn)); - if (!ldb_dn_add_base(newdn, ac->orig_req->op.rename.newdn)) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + store = talloc_zero(ac, struct subren_msg_store); + if (store == NULL) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } + ac->current->next = store; + ac->current = store; - ret = ldb_build_rename_req(&req, ldb, mem_ctx, - ares->message->dn, - newdn, - NULL, - NULL, - NULL); - - if (ret != LDB_SUCCESS) { - return ret; + /* the first list element contains the base for the rename */ + store->olddn = talloc_steal(store, ares->message->dn); + store->newdn = ldb_dn_copy(store, store->olddn); + + if ( ! ldb_dn_remove_base_components(store->newdn, + ldb_dn_get_comp_num(ac->list->olddn))) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ret = ldb_set_timeout_from_prev_req(ldb, ac->orig_req, req); - - if (ret != LDB_SUCCESS) { - return ret; + if ( ! ldb_dn_add_base(store->newdn, ac->list->newdn)) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - talloc_steal(req, newdn); + break; - talloc_steal(req, ares->message->dn); - - talloc_free(ares); - - } else if (ares->type == LDB_REPLY_DONE) { - req = talloc(mem_ctx, struct ldb_request); - *req = *ac->orig_req; - talloc_free(ares); + case LDB_REPLY_REFERRAL: + /* ignore */ + break; - } else { - talloc_free(ares); - return LDB_SUCCESS; - } - - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; + case LDB_REPLY_DONE: + + /* rewind ac->current */ + ac->current = ac->list; + + /* All dns set up, start with the first one */ + ret = subtree_rename_next_request(ac); + + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + break; } - ac->down_req[ac->num_requests] = req; - ac->num_requests++; - - return ldb_next_request(ac->module, req); - + + talloc_free(ares); + return LDB_SUCCESS; } /* rename */ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) { - const char *attrs[] = { NULL }; - struct ldb_request *new_req; + static const char *attrs[2] = { "distinguishedName", NULL }; + struct ldb_request *search_req; struct subtree_rename_context *ac; int ret; if (ldb_dn_is_special(req->op.rename.olddn)) { /* do not manipulate our control entries */ @@ -176,110 +221,37 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) - Regain our sainity */ - ac = subtree_rename_init_handle(req, module); + ac = subren_ctx_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&new_req, module->ldb, req, + /* add this entry as the first to do */ + ac->current = talloc_zero(ac, struct subren_msg_store); + if (ac->current == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + ac->current->olddn = req->op.rename.olddn; + ac->current->newdn = req->op.rename.newdn; + ac->list = ac->current; + + ret = ldb_build_search_req(&search_req, module->ldb, ac, req->op.rename.olddn, LDB_SCOPE_SUBTREE, "(objectClass=*)", attrs, - req->controls, + NULL, ac, - subtree_rename_search_callback); - - if (ret != LDB_SUCCESS) { - return ret; - } - - ret = ldb_set_timeout_from_prev_req(module->ldb, req, new_req); - + subtree_rename_search_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ac->down_req[ac->num_requests] = new_req; - if (req == NULL) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ac->num_requests++; - return ldb_next_request(module, new_req); -} - - -static int subtree_rename_wait_none(struct ldb_handle *handle) { - struct subtree_rename_context *ac; - int i, ret = LDB_ERR_OPERATIONS_ERROR; - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct subtree_rename_context); - - for (i=0; i < ac->num_requests; i++) { - ret = ldb_wait(ac->down_req[i]->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req[i]->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req[i]->handle->status; - goto done; - } - - if (ac->down_req[i]->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - } - -done: - handle->state = LDB_ASYNC_DONE; - return ret; - -} - -static int subtree_rename_wait_all(struct ldb_handle *handle) { - - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = subtree_rename_wait_none(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; -} - -static int subtree_rename_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return subtree_rename_wait_all(handle); - } else { - return subtree_rename_wait_none(handle); - } + return ldb_next_request(module, search_req); } const struct ldb_module_ops ldb_subtree_rename_module_ops = { .name = "subtree_rename", .rename = subtree_rename, - .wait = subtree_rename_wait, }; diff --git a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py index 428e6b4d4b..1fc531902d 100644 --- a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py +++ b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py @@ -1,7 +1,7 @@ #!/usr/bin/python # Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 2005-2007 +# Copyright (C) Jelmer Vernooij 2005-2008 # Copyright (C) Martin Kuehl 2006 # # This is a Python port of the original in testprogs/ejs/samba3sam.js @@ -23,19 +23,26 @@ """Tests for the samba3sam LDB module, which maps Samba3 LDAP to AD LDAP.""" import os -import sys -import samba import ldb from ldb import SCOPE_DEFAULT, SCOPE_BASE, SCOPE_SUBTREE from samba import Ldb, substitute_var -from samba.tests import LdbTestCase, TestCaseInTempDir +from samba.tests import LdbTestCase, TestCaseInTempDir, cmdline_loadparm +import samba.dcerpc.security +import samba.security +import samba.ndr + +datadir = os.path.join(os.path.dirname(__file__), + "../../../../../testdata/samba3") + +def read_datafile(filename): + return open(os.path.join(datadir, filename), 'r').read() + +def ldb_debug(l, text): + print text -datadir = os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3") class MapBaseTestCase(TestCaseInTempDir): - def setup_data(self, obj, ldif): - self.assertTrue(ldif is not None) - obj.db.add_ldif(substitute_var(ldif, obj.substvars)) + """Base test case for mapping tests.""" def setup_modules(self, ldb, s3, s4): ldb.add({"dn": "@MAP=samba3sam", @@ -46,40 +53,53 @@ class MapBaseTestCase(TestCaseInTempDir): "@LIST": "rootdse,paged_results,server_sort,extended_dn,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,partition"}) ldb.add({"dn": "@PARTITION", - "partition": [s4.basedn + ":" + s4.url, s3.basedn + ":" + s3.url], + "partition": ["%s:%s" % (s4.basedn, s4.url), + "%s:%s" % (s3.basedn, s3.url)], "replicateEntries": ["@ATTRIBUTES", "@INDEXLIST"]}) def setUp(self): super(MapBaseTestCase, self).setUp() def make_dn(basedn, rdn): - return rdn + ",sambaDomainName=TESTS," + basedn + return "%s,sambaDomainName=TESTS,%s" % (rdn, basedn) def make_s4dn(basedn, rdn): - return rdn + "," + basedn + return "%s,%s" % (rdn, basedn) self.ldbfile = os.path.join(self.tempdir, "test.ldb") self.ldburl = "tdb://" + self.ldbfile tempdir = self.tempdir - print tempdir class Target: - """Simple helper class that contains data for a specific SAM connection.""" + """Simple helper class that contains data for a specific SAM + connection.""" def __init__(self, file, basedn, dn): self.file = os.path.join(tempdir, file) self.url = "tdb://" + self.file self.basedn = basedn self.substvars = {"BASEDN": self.basedn} - self.db = Ldb() + self.db = Ldb(lp=cmdline_loadparm) self._dn = dn def dn(self, rdn): - return self._dn(rdn, self.basedn) + return self._dn(self.basedn, rdn) def connect(self): return self.db.connect(self.url) + def setup_data(self, path): + self.add_ldif(read_datafile(path)) + + def subst(self, text): + return substitute_var(text, self.substvars) + + def add_ldif(self, ldif): + self.db.add_ldif(self.subst(ldif)) + + def modify_ldif(self, ldif): + self.db.modify_ldif(self.subst(ldif)) + self.samba4 = Target("samba4.ldb", "dc=vernstok,dc=nl", make_s4dn) self.samba3 = Target("samba3.ldb", "cn=Samba3Sam", make_dn) self.templates = Target("templates.ldb", "cn=templates", None) @@ -95,56 +115,70 @@ class MapBaseTestCase(TestCaseInTempDir): os.unlink(self.samba4.file) super(MapBaseTestCase, self).tearDown() + def assertSidEquals(self, text, ndr_sid): + sid_obj1 = samba.ndr.ndr_unpack(samba.dcerpc.security.dom_sid, + str(ndr_sid[0])) + sid_obj2 = samba.security.Sid(text) + # For now, this is the only way we can compare these since the + # classes are in different places. Should reconcile that at some point. + self.assertEquals(sid_obj1.sid_rev_num, sid_obj2.sid_rev_num) + self.assertEquals(sid_obj1.num_auths, sid_obj2.num_auths) + # FIXME: self.assertEquals(sid_obj1.id_auth, sid_obj2.id_auth) + # FIXME: self.assertEquals(sid_obj1.sub_auths[:sid_obj1.num_auths], + # sid_obj2.sub_auths[:sid_obj2.num_auths]) + class Samba3SamTestCase(MapBaseTestCase): + def setUp(self): super(Samba3SamTestCase, self).setUp() - ldb = Ldb(self.ldburl) - self.setup_data(self.samba3, open(os.path.join(datadir, "samba3.ldif"), 'r').read()) - self.setup_data(self.templates, open(os.path.join(datadir, "provision_samba3sam_templates.ldif"), 'r').read()) - ldif = open(os.path.join(datadir, "provision_samba3sam.ldif"), 'r').read() - ldb.add_ldif(substitute_var(ldif, self.samba4.substvars)) + ldb = Ldb(self.ldburl, lp=cmdline_loadparm) + self.samba3.setup_data("samba3.ldif") + self.templates.setup_data("provision_samba3sam_templates.ldif") + ldif = read_datafile("provision_samba3sam.ldif") + ldb.add_ldif(self.samba4.subst(ldif)) self.setup_modules(ldb, self.samba3, self.samba4) - self.ldb = Ldb(self.ldburl) + del ldb + self.ldb = Ldb(self.ldburl, lp=cmdline_loadparm) - def test_s3sam_search(self): - print "Looking up by non-mapped attribute" + def test_search_non_mapped(self): + """Looking up by non-mapped attribute""" msg = self.ldb.search(expression="(cn=Administrator)") self.assertEquals(len(msg), 1) self.assertEquals(msg[0]["cn"], "Administrator") - print "Looking up by mapped attribute" + def test_search_non_mapped(self): + """Looking up by mapped attribute""" msg = self.ldb.search(expression="(name=Backup Operators)") self.assertEquals(len(msg), 1) self.assertEquals(msg[0]["name"], "Backup Operators") - print "Looking up by old name of renamed attribute" + def test_old_name_of_renamed(self): + """Looking up by old name of renamed attribute""" msg = self.ldb.search(expression="(displayName=Backup Operators)") self.assertEquals(len(msg), 0) - print "Looking up mapped entry containing SID" + def test_mapped_containing_sid(self): + """Looking up mapped entry containing SID""" msg = self.ldb.search(expression="(cn=Replicator)") self.assertEquals(len(msg), 1) - print msg[0].dn - self.assertEquals(str(msg[0].dn), "cn=Replicator,ou=Groups,dc=vernstok,dc=nl") - self.assertEquals(msg[0]["objectSid"], "S-1-5-21-4231626423-2410014848-2360679739-552") - - print "Checking mapping of objectClass" + self.assertEquals(str(msg[0].dn), + "cn=Replicator,ou=Groups,dc=vernstok,dc=nl") + self.assertTrue("objectSid" in msg[0]) + self.assertSidEquals("S-1-5-21-4231626423-2410014848-2360679739-552", + msg[0]["objectSid"]) oc = set(msg[0]["objectClass"]) - self.assertTrue(oc is not None) - for i in oc: - self.assertEquals(oc[i] == "posixGroup" or oc[i], "group") + self.assertEquals(oc, set(["group"])) - print "Looking up by objectClass" + def test_search_by_objclass(self): + """Looking up by objectClass""" msg = self.ldb.search(expression="(|(objectClass=user)(cn=Administrator))") - self.assertEquals(len(msg), 2) - for i in range(len(msg)): - self.assertEquals((str(msg[i].dn), "unixName=Administrator,ou=Users,dc=vernstok,dc=nl") or - (str(msg[i].dn) == "unixName=nobody,ou=Users,dc=vernstok,dc=nl")) - + self.assertEquals(set([str(m.dn) for m in msg]), + set(["unixName=Administrator,ou=Users,dc=vernstok,dc=nl", + "unixName=nobody,ou=Users,dc=vernstok,dc=nl"])) def test_s3sam_modify(self): - print "Adding a record that will be fallbacked" + # Adding a record that will be fallbacked self.ldb.add({"dn": "cn=Foo", "foo": "bar", "blah": "Blie", @@ -152,33 +186,36 @@ class Samba3SamTestCase(MapBaseTestCase): "showInAdvancedViewOnly": "TRUE"} ) - print "Checking for existence of record (local)" - # TODO: This record must be searched in the local database, which is currently only supported for base searches + # Checking for existence of record (local) + # TODO: This record must be searched in the local database, which is + # currently only supported for base searches # msg = ldb.search(expression="(cn=Foo)", ['foo','blah','cn','showInAdvancedViewOnly')] # TODO: Actually, this version should work as well but doesn't... # # - msg = self.ldb.search(expression="(cn=Foo)", base="cn=Foo", scope=SCOPE_BASE, attrs=['foo','blah','cn','showInAdvancedViewOnly']) + msg = self.ldb.search(expression="(cn=Foo)", base="cn=Foo", + scope=SCOPE_BASE, + attrs=['foo','blah','cn','showInAdvancedViewOnly']) self.assertEquals(len(msg), 1) self.assertEquals(msg[0]["showInAdvancedViewOnly"], "TRUE") self.assertEquals(msg[0]["foo"], "bar") self.assertEquals(msg[0]["blah"], "Blie") - print "Adding record that will be mapped" + # Adding record that will be mapped self.ldb.add({"dn": "cn=Niemand,cn=Users,dc=vernstok,dc=nl", "objectClass": "user", "unixName": "bin", "sambaUnicodePwd": "geheim", "cn": "Niemand"}) - print "Checking for existence of record (remote)" + # Checking for existence of record (remote) msg = self.ldb.search(expression="(unixName=bin)", attrs=['unixName','cn','dn', 'sambaUnicodePwd']) self.assertEquals(len(msg), 1) self.assertEquals(msg[0]["cn"], "Niemand") self.assertEquals(msg[0]["sambaUnicodePwd"], "geheim") - print "Checking for existence of record (local && remote)" + # Checking for existence of record (local && remote) msg = self.ldb.search(expression="(&(unixName=bin)(sambaUnicodePwd=geheim))", attrs=['unixName','cn','dn', 'sambaUnicodePwd']) self.assertEquals(len(msg), 1) # TODO: should check with more records @@ -186,21 +223,23 @@ class Samba3SamTestCase(MapBaseTestCase): self.assertEquals(msg[0]["unixName"], "bin") self.assertEquals(msg[0]["sambaUnicodePwd"], "geheim") - print "Checking for existence of record (local || remote)" + # Checking for existence of record (local || remote) msg = self.ldb.search(expression="(|(unixName=bin)(sambaUnicodePwd=geheim))", attrs=['unixName','cn','dn', 'sambaUnicodePwd']) - print "got " + len(msg) + " replies" + #print "got %d replies" % len(msg) self.assertEquals(len(msg), 1) # TODO: should check with more records self.assertEquals(msg[0]["cn"], "Niemand") - self.assertEquals(msg[0]["unixName"] == "bin" or msg[0]["sambaUnicodePwd"], "geheim") + self.assertEquals(msg[0]["unixName"], "bin") + self.assertEquals(msg[0]["sambaUnicodePwd"], "geheim") - print "Checking for data in destination database" - msg = s3.db.search("(cn=Niemand)") + # Checking for data in destination database + msg = self.samba3.db.search(expression="(cn=Niemand)") self.assertTrue(len(msg) >= 1) - self.assertEquals(msg[0]["sambaSID"], "S-1-5-21-4231626423-2410014848-2360679739-2001") + self.assertEquals(msg[0]["sambaSID"], + "S-1-5-21-4231626423-2410014848-2360679739-2001") self.assertEquals(msg[0]["displayName"], "Niemand") - print "Adding attribute..." + # Adding attribute... self.ldb.modify_ldif(""" dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl changetype: modify @@ -208,13 +247,13 @@ add: description description: Blah """) - print "Checking whether changes are still there..." + # Checking whether changes are still there... msg = self.ldb.search(expression="(cn=Niemand)") self.assertTrue(len(msg) >= 1) self.assertEquals(msg[0]["cn"], "Niemand") self.assertEquals(msg[0]["description"], "Blah") - print "Modifying attribute..." + # Modifying attribute... self.ldb.modify_ldif(""" dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl changetype: modify @@ -222,64 +261,66 @@ replace: description description: Blie """) - print "Checking whether changes are still there..." + # Checking whether changes are still there... msg = self.ldb.search(expression="(cn=Niemand)") self.assertTrue(len(msg) >= 1) self.assertEquals(msg[0]["description"], "Blie") - print "Deleting attribute..." + # Deleting attribute... self.ldb.modify_ldif(""" dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl changetype: modify delete: description """) - print "Checking whether changes are no longer there..." + # Checking whether changes are no longer there... msg = self.ldb.search(expression="(cn=Niemand)") self.assertTrue(len(msg) >= 1) - self.assertTrue(not "description" in res[0]) + self.assertTrue(not "description" in msg[0]) - print "Renaming record..." - self.ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", "cn=Niemand2,cn=Users,dc=vernstok,dc=nl") + # Renaming record... + self.ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", + "cn=Niemand2,cn=Users,dc=vernstok,dc=nl") - print "Checking whether DN has changed..." + # Checking whether DN has changed... msg = self.ldb.search(expression="(cn=Niemand2)") self.assertEquals(len(msg), 1) - self.assertEquals(str(msg[0].dn), "cn=Niemand2,cn=Users,dc=vernstok,dc=nl") + self.assertEquals(str(msg[0].dn), + "cn=Niemand2,cn=Users,dc=vernstok,dc=nl") - print "Deleting record..." + # Deleting record... self.ldb.delete("cn=Niemand2,cn=Users,dc=vernstok,dc=nl") - print "Checking whether record is gone..." + # Checking whether record is gone... msg = self.ldb.search(expression="(cn=Niemand2)") self.assertEquals(len(msg), 0) - class MapTestCase(MapBaseTestCase): + def setUp(self): super(MapTestCase, self).setUp() - ldb = Ldb(self.ldburl) - self.setup_data(self.templates, open(os.path.join(datadir, "provision_samba3sam_templates.ldif"), 'r').read()) - ldif = open(os.path.join(datadir, "provision_samba3sam.ldif"), 'r').read() - ldb.add_ldif(substitute_var(ldif, self.samba4.substvars)) + ldb = Ldb(self.ldburl, lp=cmdline_loadparm) + self.templates.setup_data("provision_samba3sam_templates.ldif") + ldif = read_datafile("provision_samba3sam.ldif") + ldb.add_ldif(self.samba4.subst(ldif)) self.setup_modules(ldb, self.samba3, self.samba4) - self.ldb = Ldb(self.ldburl) + del ldb + self.ldb = Ldb(self.ldburl, lp=cmdline_loadparm) def test_map_search(self): - print "Running search tests on mapped data" - ldif = """ -dn: """ + "sambaDomainName=TESTS,""" + self.samba3.basedn + """ -objectclass: sambaDomain -objectclass: top -sambaSID: S-1-5-21-4231626423-2410014848-2360679739 -sambaNextRid: 2000 -sambaDomainName: TESTS""" - self.samba3.db.add_ldif(substitute_var(ldif, self.samba3.substvars)) - - print "Add a set of split records" - ldif = """ -dn: """ + self.samba4.dn("cn=X") + """ + """Running search tests on mapped data.""" + self.samba3.db.add({ + "dn": "sambaDomainName=TESTS," + self.samba3.basedn, + "objectclass": ["sambaDomain", "top"], + "sambaSID": "S-1-5-21-4231626423-2410014848-2360679739", + "sambaNextRid": "2000", + "sambaDomainName": "TESTS" + }) + + # Add a set of split records + self.ldb.add_ldif(""" +dn: """+ self.samba4.dn("cn=X") + """ objectClass: user cn: X codePage: x @@ -291,127 +332,128 @@ description: x objectSid: S-1-5-21-4231626423-2410014848-2360679739-552 primaryGroupID: 1-5-21-4231626423-2410014848-2360679739-512 -dn: """ + self.samba4.dn("cn=Y") + """ -objectClass: top -cn: Y -codePage: x -revision: x -dnsHostName: y -nextRid: y -lastLogon: y -description: x - -dn: """ + self.samba4.dn("cn=Z") + """ -objectClass: top -cn: Z -codePage: x -revision: y -dnsHostName: z -nextRid: y -lastLogon: z -description: y -""" - - self.ldb.add_ldif(substitute_var(ldif, self.samba4.substvars)) - - print "Add a set of remote records" - - ldif = """ -dn: """ + self.samba3.dn("cn=A") + """ -objectClass: posixAccount -cn: A -sambaNextRid: x -sambaBadPasswordCount: x -sambaLogonTime: x -description: x -sambaSID: S-1-5-21-4231626423-2410014848-2360679739-552 -sambaPrimaryGroupSID: S-1-5-21-4231626423-2410014848-2360679739-512 - -dn: """ + self.samba3.dn("cn=B") + """ -objectClass: top -cn:B -sambaNextRid: x -sambaBadPasswordCount: x -sambaLogonTime: y -description: x +""") -dn: """ + self.samba3.dn("cn=C") + """ -objectClass: top -cn: C -sambaNextRid: x -sambaBadPasswordCount: y -sambaLogonTime: z -description: y -""" - self.samba3.add_ldif(substitute_var(ldif, self.samba3.substvars)) + self.ldb.add({ + "dn": self.samba4.dn("cn=Y"), + "objectClass": "top", + "cn": "Y", + "codePage": "x", + "revision": "x", + "dnsHostName": "y", + "nextRid": "y", + "lastLogon": "y", + "description": "x"}) - print "Testing search by DN" + self.ldb.add({ + "dn": self.samba4.dn("cn=Z"), + "objectClass": "top", + "cn": "Z", + "codePage": "x", + "revision": "y", + "dnsHostName": "z", + "nextRid": "y", + "lastLogon": "z", + "description": "y"}) + + # Add a set of remote records + + self.samba3.db.add({ + "dn": self.samba3.dn("cn=A"), + "objectClass": "posixAccount", + "cn": "A", + "sambaNextRid": "x", + "sambaBadPasswordCount": "x", + "sambaLogonTime": "x", + "description": "x", + "sambaSID": "S-1-5-21-4231626423-2410014848-2360679739-552", + "sambaPrimaryGroupSID": "S-1-5-21-4231626423-2410014848-2360679739-512"}) + + self.samba3.db.add({ + "dn": self.samba3.dn("cn=B"), + "objectClass": "top", + "cn": "B", + "sambaNextRid": "x", + "sambaBadPasswordCount": "x", + "sambaLogonTime": "y", + "description": "x"}) + + self.samba3.db.add({ + "dn": self.samba3.dn("cn=C"), + "objectClass": "top", + "cn": "C", + "sambaNextRid": "x", + "sambaBadPasswordCount": "y", + "sambaLogonTime": "z", + "description": "y"}) + + # Testing search by DN # Search remote record by local DN dn = self.samba4.dn("cn=A") - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.ldb.search(dn, scope=SCOPE_BASE, + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 1) - self.assertEquals(str(str(res[0].dn)), dn) + self.assertEquals(str(res[0].dn), dn) self.assertTrue(not "dnsHostName" in res[0]) self.assertEquals(res[0]["lastLogon"], "x") # Search remote record by remote DN dn = self.samba3.dn("cn=A") - attrs = ["dnsHostName", "lastLogon", "sambaLogonTime"] - res = self.samba3.db.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.samba3.db.search(dn, scope=SCOPE_BASE, + attrs=["dnsHostName", "lastLogon", "sambaLogonTime"]) self.assertEquals(len(res), 1) - self.assertEquals(str(str(res[0].dn)), dn) + self.assertEquals(str(res[0].dn), dn) self.assertTrue(not "dnsHostName" in res[0]) self.assertTrue(not "lastLogon" in res[0]) self.assertEquals(res[0]["sambaLogonTime"], "x") # Search split record by local DN dn = self.samba4.dn("cn=X") - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.ldb.search(dn, scope=SCOPE_BASE, + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 1) - self.assertEquals(str(str(res[0].dn)), dn) + self.assertEquals(str(res[0].dn), dn) self.assertEquals(res[0]["dnsHostName"], "x") self.assertEquals(res[0]["lastLogon"], "x") # Search split record by remote DN dn = self.samba3.dn("cn=X") - attrs = ["dnsHostName", "lastLogon", "sambaLogonTime"] - res = self.samba3.db.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.samba3.db.search(dn, scope=SCOPE_BASE, + attrs=["dnsHostName", "lastLogon", "sambaLogonTime"]) self.assertEquals(len(res), 1) - self.assertEquals(str(str(res[0].dn)), dn) + self.assertEquals(str(res[0].dn), dn) self.assertTrue(not "dnsHostName" in res[0]) self.assertTrue(not "lastLogon" in res[0]) self.assertEquals(res[0]["sambaLogonTime"], "x") - print "Testing search by attribute" + # Testing search by attribute # Search by ignored attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(revision=x)", scope=SCOPE_DEFAULT, attrs=attrs) + res = self.ldb.search(expression="(revision=x)", scope=SCOPE_DEFAULT, + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) - self.assertEquals(str(str(res[0].dn)), self.samba4.dn("cn=Y")) + self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") self.assertEquals(res[0]["lastLogon"], "y") - self.assertEquals(str(str(res[1].dn)), self.samba4.dn("cn=X")) + self.assertEquals(str(res[1].dn), self.samba4.dn("cn=X")) self.assertEquals(res[1]["dnsHostName"], "x") self.assertEquals(res[1]["lastLogon"], "x") # Search by kept attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(description=y)", scope=SCOPE_DEFAULT, attrs=attrs) + res = self.ldb.search(expression="(description=y)", + scope=SCOPE_DEFAULT, attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) - self.assertEquals(str(str(res[0].dn)), self.samba4.dn("cn=Z")) + self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Z")) self.assertEquals(res[0]["dnsHostName"], "z") self.assertEquals(res[0]["lastLogon"], "z") - self.assertEquals(str(str(res[1].dn)), self.samba4.dn("cn=C")) + self.assertEquals(str(res[1].dn), self.samba4.dn("cn=C")) self.assertTrue(not "dnsHostName" in res[1]) self.assertEquals(res[1]["lastLogon"], "z") # Search by renamed attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(badPwdCount=x)", scope=SCOPE_DEFAULT, attrs=attrs) + res = self.ldb.search(expression="(badPwdCount=x)", scope=SCOPE_DEFAULT, + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) @@ -421,27 +463,30 @@ description: y self.assertEquals(res[1]["lastLogon"], "x") # Search by converted attribute - attrs = ["dnsHostName", "lastLogon", "objectSid"] # TODO: # Using the SID directly in the parse tree leads to conversion # errors, letting the search fail with no results. #res = self.ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-552)", scope=SCOPE_DEFAULT, attrs) - res = self.ldb.search(expression="(objectSid=*)", attrs=attrs) + res = self.ldb.search(expression="(objectSid=*)", base=None, scope=SCOPE_DEFAULT, attrs=["dnsHostName", "lastLogon", "objectSid"]) self.assertEquals(len(res), 3) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=X")) self.assertEquals(res[0]["dnsHostName"], "x") self.assertEquals(res[0]["lastLogon"], "x") - self.assertEquals(res[0]["objectSid"], "S-1-5-21-4231626423-2410014848-2360679739-552") + self.assertSidEquals("S-1-5-21-4231626423-2410014848-2360679739-552", + res[0]["objectSid"]) + self.assertTrue("objectSid" in res[0]) self.assertEquals(str(res[1].dn), self.samba4.dn("cn=A")) self.assertTrue(not "dnsHostName" in res[1]) self.assertEquals(res[1]["lastLogon"], "x") - self.assertEquals(res[1]["objectSid"], "S-1-5-21-4231626423-2410014848-2360679739-552") + self.assertSidEquals("S-1-5-21-4231626423-2410014848-2360679739-552", + res[1]["objectSid"]) + self.assertTrue("objectSid" in res[1]) # Search by generated attribute # In most cases, this even works when the mapping is missing # a `convert_operator' by enumerating the remote db. - attrs = ["dnsHostName", "lastLogon", "primaryGroupID"] - res = self.ldb.search(expression="(primaryGroupID=512)", attrs=attrs) + res = self.ldb.search(expression="(primaryGroupID=512)", + attrs=["dnsHostName", "lastLogon", "primaryGroupID"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) self.assertTrue(not "dnsHostName" in res[0]) @@ -463,8 +508,8 @@ description: y # # Search by remote name of renamed attribute */ - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(sambaBadPasswordCount=*)", attrs=attrs) + res = self.ldb.search(expression="(sambaBadPasswordCount=*)", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 0) # Search by objectClass @@ -474,39 +519,34 @@ description: y self.assertEquals(str(res[0].dn), self.samba4.dn("cn=X")) self.assertEquals(res[0]["dnsHostName"], "x") self.assertEquals(res[0]["lastLogon"], "x") - self.assertTrue(res[0]["objectClass"] is not None) self.assertEquals(res[0]["objectClass"][0], "user") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=A")) self.assertTrue(not "dnsHostName" in res[1]) self.assertEquals(res[1]["lastLogon"], "x") - self.assertTrue(res[1]["objectClass"] is not None) self.assertEquals(res[1]["objectClass"][0], "user") # Prove that the objectClass is actually used for the search - res = self.ldb.search(expression="(|(objectClass=user)(badPwdCount=x))", attrs=attrs) + res = self.ldb.search(expression="(|(objectClass=user)(badPwdCount=x))", + attrs=attrs) self.assertEquals(len(res), 3) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) self.assertEquals(res[0]["lastLogon"], "y") - self.assertTrue(res[0]["objectClass"] is not None) - for oc in set(res[0]["objectClass"]): - self.assertEquals(oc, "user") + self.assertEquals(set(res[0]["objectClass"]), set(["top"])) self.assertEquals(str(res[1].dn), self.samba4.dn("cn=X")) self.assertEquals(res[1]["dnsHostName"], "x") self.assertEquals(res[1]["lastLogon"], "x") - self.assertTrue(res[1]["objectClass"] is not None) self.assertEquals(res[1]["objectClass"][0], "user") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=A")) self.assertTrue(not "dnsHostName" in res[2]) self.assertEquals(res[2]["lastLogon"], "x") - self.assertTrue(res[2]["objectClass"] is not None) self.assertEquals(res[2]["objectClass"][0], "user") - print "Testing search by parse tree" + # Testing search by parse tree # Search by conjunction of local attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(&(codePage=x)(revision=x))", attrs=attrs) + res = self.ldb.search(expression="(&(codePage=x)(revision=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") @@ -516,8 +556,8 @@ description: y self.assertEquals(res[1]["lastLogon"], "x") # Search by conjunction of remote attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(&(lastLogon=x)(description=x))", attrs=attrs) + res = self.ldb.search(expression="(&(lastLogon=x)(description=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=X")) self.assertEquals(res[0]["dnsHostName"], "x") @@ -527,8 +567,8 @@ description: y self.assertEquals(res[1]["lastLogon"], "x") # Search by conjunction of local and remote attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(&(codePage=x)(description=x))", attrs=attrs) + res = self.ldb.search(expression="(&(codePage=x)(description=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") @@ -539,14 +579,16 @@ description: y # Search by conjunction of local and remote attribute w/o match attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(&(codePage=x)(nextRid=x))", attrs=attrs) + res = self.ldb.search(expression="(&(codePage=x)(nextRid=x))", + attrs=attrs) self.assertEquals(len(res), 0) - res = self.ldb.search(expression="(&(revision=x)(lastLogon=z))", attrs=attrs) + res = self.ldb.search(expression="(&(revision=x)(lastLogon=z))", + attrs=attrs) self.assertEquals(len(res), 0) # Search by disjunction of local attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(|(revision=x)(dnsHostName=x))", attrs=attrs) + res = self.ldb.search(expression="(|(revision=x)(dnsHostName=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 2) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") @@ -556,41 +598,41 @@ description: y self.assertEquals(res[1]["lastLogon"], "x") # Search by disjunction of remote attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(|(badPwdCount=x)(lastLogon=x))", attrs=attrs) + res = self.ldb.search(expression="(|(badPwdCount=x)(lastLogon=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 3) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) - self.assertTrue("dnsHostName" in res[0]) + self.assertFalse("dnsHostName" in res[0]) self.assertEquals(res[0]["lastLogon"], "y") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=X")) self.assertEquals(res[1]["dnsHostName"], "x") self.assertEquals(res[1]["lastLogon"], "x") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=A")) - self.assertTrue("dnsHostName" in res[2]) + self.assertFalse("dnsHostName" in res[2]) self.assertEquals(res[2]["lastLogon"], "x") # Search by disjunction of local and remote attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(|(revision=x)(lastLogon=y))", attrs=attrs) + res = self.ldb.search(expression="(|(revision=x)(lastLogon=y))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 3) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") self.assertEquals(res[0]["lastLogon"], "y") self.assertEquals(str(res[1].dn), self.samba4.dn("cn=B")) - self.assertTrue("dnsHostName" in res[1]) + self.assertFalse("dnsHostName" in res[1]) self.assertEquals(res[1]["lastLogon"], "y") self.assertEquals(str(res[2].dn), self.samba4.dn("cn=X")) self.assertEquals(res[2]["dnsHostName"], "x") self.assertEquals(res[2]["lastLogon"], "x") # Search by disjunction of local and remote attribute w/o match - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(|(codePage=y)(nextRid=z))", attrs=attrs) + res = self.ldb.search(expression="(|(codePage=y)(nextRid=z))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 0) # Search by negated local attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(revision=x))", attrs=attrs) + res = self.ldb.search(expression="(!(revision=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 5) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) @@ -606,8 +648,8 @@ description: y self.assertEquals(res[3]["lastLogon"], "z") # Search by negated remote attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(description=x))", attrs=attrs) + res = self.ldb.search(expression="(!(description=x))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 3) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Z")) self.assertEquals(res[0]["dnsHostName"], "z") @@ -617,8 +659,8 @@ description: y self.assertEquals(res[1]["lastLogon"], "z") # Search by negated conjunction of local attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(&(codePage=x)(revision=x)))", attrs=attrs) + res = self.ldb.search(expression="(!(&(codePage=x)(revision=x)))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 5) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) @@ -634,8 +676,8 @@ description: y self.assertEquals(res[3]["lastLogon"], "z") # Search by negated conjunction of remote attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(&(lastLogon=x)(description=x)))", attrs=attrs) + res = self.ldb.search(expression="(!(&(lastLogon=x)(description=x)))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 5) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") @@ -651,8 +693,8 @@ description: y self.assertEquals(res[3]["lastLogon"], "z") # Search by negated conjunction of local and remote attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(&(codePage=x)(description=x)))", attrs=attrs) + res = self.ldb.search(expression="(!(&(codePage=x)(description=x)))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 5) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) @@ -668,8 +710,8 @@ description: y self.assertEquals(res[3]["lastLogon"], "z") # Search by negated disjunction of local attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(|(revision=x)(dnsHostName=x)))", attrs=attrs) + res = self.ldb.search(expression="(!(|(revision=x)(dnsHostName=x)))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) self.assertEquals(res[0]["lastLogon"], "y") @@ -684,8 +726,8 @@ description: y self.assertEquals(res[3]["lastLogon"], "z") # Search by negated disjunction of remote attributes - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(|(badPwdCount=x)(lastLogon=x)))", attrs=attrs) + res = self.ldb.search(expression="(!(|(badPwdCount=x)(lastLogon=x)))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 4) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=Y")) self.assertEquals(res[0]["dnsHostName"], "y") @@ -698,8 +740,8 @@ description: y self.assertEquals(res[2]["lastLogon"], "z") # Search by negated disjunction of local and remote attribute - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(!(|(revision=x)(lastLogon=y)))", attrs=attrs) + res = self.ldb.search(expression="(!(|(revision=x)(lastLogon=y)))", + attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 4) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=A")) self.assertTrue(not "dnsHostName" in res[0]) @@ -711,9 +753,8 @@ description: y self.assertTrue(not "dnsHostName" in res[2]) self.assertEquals(res[2]["lastLogon"], "z") - print "Search by complex parse tree" - attrs = ["dnsHostName", "lastLogon"] - res = self.ldb.search(expression="(|(&(revision=x)(dnsHostName=x))(!(&(description=x)(nextRid=y)))(badPwdCount=y))", attrs=attrs) + # Search by complex parse tree + res = self.ldb.search(expression="(|(&(revision=x)(dnsHostName=x))(!(&(description=x)(nextRid=y)))(badPwdCount=y))", attrs=["dnsHostName", "lastLogon"]) self.assertEquals(len(res), 6) self.assertEquals(str(res[0].dn), self.samba4.dn("cn=B")) self.assertTrue(not "dnsHostName" in res[0]) @@ -754,10 +795,12 @@ description: y self.assertEquals(res[0]["revision"], "1") self.assertEquals(res[0]["description"], "test") # Check it's not in the local db - res = self.samba4.db.search(expression="(cn=test)", scope=SCOPE_DEFAULT, attrs=attrs) + res = self.samba4.db.search(expression="(cn=test)", + scope=SCOPE_DEFAULT, attrs=attrs) self.assertEquals(len(res), 0) # Check it's not in the remote db - res = self.samba3.db.search(expression="(cn=test)", scope=SCOPE_DEFAULT, attrs=attrs) + res = self.samba3.db.search(expression="(cn=test)", + scope=SCOPE_DEFAULT, attrs=attrs) self.assertEquals(len(res), 0) # Modify local record @@ -805,8 +848,8 @@ description: foo "sambaBadPasswordCount": "3", "sambaNextRid": "1001"}) # Check it's there - attrs = ["description", "sambaBadPasswordCount", "sambaNextRid"] - res = self.samba3.db.search(dn2, scope=SCOPE_BASE, attrs=attrs) + res = self.samba3.db.search(dn2, scope=SCOPE_BASE, + attrs=["description", "sambaBadPasswordCount", "sambaNextRid"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) self.assertEquals(res[0]["description"], "foo") @@ -814,7 +857,7 @@ description: foo self.assertEquals(res[0]["sambaNextRid"], "1001") # Check in mapped db attrs = ["description", "badPwdCount", "nextRid"] - res = self.ldb.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.ldb.search(dn, scope=SCOPE_BASE, attrs=attrs, expression="") self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) self.assertEquals(res[0]["description"], "foo") @@ -834,16 +877,16 @@ badPwdCount: 4 """ self.ldb.modify_ldif(ldif) # Check in mapped db - attrs = ["description", "badPwdCount", "nextRid"] - res = self.ldb.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.ldb.search(dn, scope=SCOPE_BASE, + attrs=["description", "badPwdCount", "nextRid"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) self.assertEquals(res[0]["description"], "test") self.assertEquals(res[0]["badPwdCount"], "4") self.assertEquals(res[0]["nextRid"], "1001") # Check in remote db - attrs = ["description", "sambaBadPasswordCount", "sambaNextRid"] - res = self.samba3.db.search(dn2, scope=SCOPE_BASE, attrs=attrs) + res = self.samba3.db.search(dn2, scope=SCOPE_BASE, + attrs=["description", "sambaBadPasswordCount", "sambaNextRid"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) self.assertEquals(res[0]["description"], "test") @@ -855,8 +898,8 @@ badPwdCount: 4 self.ldb.rename(dn, dn2) # Check in mapped db dn = dn2 - attrs = ["description", "badPwdCount", "nextRid"] - res = self.ldb.search(dn, scope=SCOPE_BASE, attrs=attrs) + res = self.ldb.search(dn, scope=SCOPE_BASE, + attrs=["description", "badPwdCount", "nextRid"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn) self.assertEquals(res[0]["description"], "test") @@ -864,8 +907,8 @@ badPwdCount: 4 self.assertEquals(res[0]["nextRid"], "1001") # Check in remote db dn2 = self.samba3.dn("cn=toast") - attrs = ["description", "sambaBadPasswordCount", "sambaNextRid"] - res = self.samba3.db.search(dn2, scope=SCOPE_BASE, attrs=attrs) + res = self.samba3.db.search(dn2, scope=SCOPE_BASE, + attrs=["description", "sambaBadPasswordCount", "sambaNextRid"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) self.assertEquals(res[0]["description"], "test") @@ -874,7 +917,7 @@ badPwdCount: 4 # Delete remote record self.ldb.delete(dn) - # Check in mapped db + # Check in mapped db that it's removed res = self.ldb.search(dn, scope=SCOPE_BASE) self.assertEquals(len(res), 0) # Check in remote db @@ -899,6 +942,7 @@ add: revision revision: 1 replace: description description: test + """ self.ldb.modify_ldif(ldif) # Check in mapped db @@ -954,7 +998,8 @@ description: test self.assertTrue(not "nextRid" in res[0]) self.assertEquals(res[0]["revision"], "1") # Check in remote db - attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", "revision"] + attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", + "revision"] res = self.samba3.db.search(dn2, scope=SCOPE_BASE, attrs=attrs) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) @@ -992,7 +1037,8 @@ revision: 2 self.assertTrue(not "nextRid" in res[0]) self.assertEquals(res[0]["revision"], "2") # Check in remote db - attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", "revision"] + attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", + "revision"] res = self.samba3.db.search(dn2, scope=SCOPE_BASE, attrs=attrs) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) @@ -1024,8 +1070,9 @@ revision: 2 self.assertEquals(res[0]["revision"], "2") # Check in remote db dn2 = self.samba3.dn("cn=toast") - attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", "revision"] - res = self.samba3.db.search(dn2, scope=SCOPE_BASE, attrs=attrs) + res = self.samba3.db.search(dn2, scope=SCOPE_BASE, + attrs=["description", "sambaBadPasswordCount", "sambaNextRid", + "revision"]) self.assertEquals(len(res), 1) self.assertEquals(str(res[0].dn), dn2) self.assertEquals(res[0]["description"], "test") diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index b36c2c9b71..8eb49b5792 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -43,6 +43,39 @@ struct update_kt_private { struct dn_list *changed_dns; }; +struct update_kt_ctx { + struct ldb_module *module; + struct ldb_request *req; + + struct ldb_dn *dn; + bool delete; + + struct ldb_reply *op_reply; + bool found; +}; + +static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module, + struct ldb_request *req) +{ + struct update_kt_ctx *ac; + + ac = talloc_zero(req, struct update_kt_ctx); + if (ac == NULL) { + ldb_oom(module->ldb); + return NULL; + } + + ac->module = module; + ac->req = req; + + return ac; +} + +/* FIXME: too many semi-async searches here for my taste, direct and indirect as + * cli_credentials_set_secrets() performs a sync ldb search. + * Just hope we are lucky and nothing breaks (using the tdb backend masks a lot + * of async issues). -SSS + */ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) { struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); struct dn_list *item; @@ -59,8 +92,8 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, dn, LDB_SCOPE_BASE, - filter, attrs, &res); + ret = ldb_search(module->ldb, data, &res, + dn, LDB_SCOPE_BASE, attrs, "%s", filter); if (ret != LDB_SUCCESS) { talloc_free(filter); return ret; @@ -80,7 +113,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - + item->creds = cli_credentials_init(item); if (!item->creds) { DEBUG(1, ("cli_credentials_init failed!")); @@ -90,7 +123,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet } cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm")); - status = cli_credentials_set_secrets(item->creds, ldb_get_opaque(module->ldb, "EventContext"), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter); + status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter); talloc_free(filter); if (NT_STATUS_IS_OK(status)) { if (delete) { @@ -105,60 +138,237 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet return LDB_SUCCESS; } +static int ukt_search_modified(struct update_kt_ctx *ac); + +static int update_kt_op_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct update_kt_ctx *ac; + int ret; + + ac = talloc_get_type(req->context, struct update_kt_ctx); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(ac->module->ldb, "Invalid request type!\n"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + if (ac->delete) { + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + } + + ac->op_reply = talloc_steal(ac, ares); + + ret = ukt_search_modified(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + + return LDB_SUCCESS; +} + +static int ukt_del_op(struct update_kt_ctx *ac) +{ + struct ldb_request *down_req; + int ret; + + ret = ldb_build_del_req(&down_req, ac->module->ldb, ac, + ac->dn, + ac->req->controls, + ac, update_kt_op_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; + } + return ldb_next_request(ac->module, down_req); +} + +static int ukt_search_modified_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct update_kt_ctx *ac; + int ret; + + ac = talloc_get_type(req->context, struct update_kt_ctx); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + + ac->found = true; + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + break; + + case LDB_REPLY_DONE: + + if (ac->found) { + /* do the dirty sync job here :/ */ + ret = add_modified(ac->module, ac->dn, ac->delete); + } + + if (ac->delete) { + ret = ukt_del_op(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + break; + } + + return ldb_module_done(ac->req, ac->op_reply->controls, + ac->op_reply->response, LDB_SUCCESS); + } + + talloc_free(ares); + return LDB_SUCCESS; +} + +static int ukt_search_modified(struct update_kt_ctx *ac) +{ + static const char * const attrs[] = { "distinguishedName", NULL }; + struct ldb_request *search_req; + int ret; + + ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ac->dn, LDB_SCOPE_BASE, + "(&(objectClass=kerberosSecret)" + "(privateKeytab=*))", attrs, + NULL, + ac, ukt_search_modified_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return ret; + } + return ldb_next_request(ac->module, search_req); +} + + /* add */ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) { + struct update_kt_ctx *ac; + struct ldb_request *down_req; int ret; - ret = ldb_next_request(module, req); + + ac = update_kt_ctx_init(module, req); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->dn = req->op.add.message->dn; + + ret = ldb_build_add_req(&down_req, module->ldb, ac, + req->op.add.message, + req->controls, + ac, update_kt_op_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - return add_modified(module, req->op.add.message->dn, false); + + return ldb_next_request(module, down_req); } /* modify */ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req) { + struct update_kt_ctx *ac; + struct ldb_request *down_req; int ret; - ret = ldb_next_request(module, req); + + ac = update_kt_ctx_init(module, req); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->dn = req->op.mod.message->dn; + + ret = ldb_build_mod_req(&down_req, module->ldb, ac, + req->op.mod.message, + req->controls, + ac, update_kt_op_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - return add_modified(module, req->op.mod.message->dn, false); + + return ldb_next_request(module, down_req); } /* delete */ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req) { - int ret; - /* Before we delete it, record the details */ - ret = add_modified(module, req->op.del.dn, true); - if (ret != LDB_SUCCESS) { - return ret; + struct update_kt_ctx *ac; + + ac = update_kt_ctx_init(module, req); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; } - return ldb_next_request(module, req); + + ac->dn = req->op.del.dn; + ac->delete = true; + + return ukt_search_modified(ac); } /* rename */ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) { + struct update_kt_ctx *ac; + struct ldb_request *down_req; int ret; - ret = ldb_next_request(module, req); + + ac = update_kt_ctx_init(module, req); + if (ac == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->dn = req->op.rename.newdn; + + ret = ldb_build_rename_req(&down_req, module->ldb, ac, + req->op.rename.olddn, + req->op.rename.newdn, + req->controls, + ac, update_kt_op_callback, + req); if (ret != LDB_SUCCESS) { return ret; } - return add_modified(module, req->op.rename.newdn, false); + + return ldb_next_request(module, down_req); } /* end a transaction */ static int update_kt_end_trans(struct ldb_module *module) { struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); - struct dn_list *p; + for (p=data->changed_dns; p; p = p->next) { int kret; - kret = cli_credentials_update_keytab(p->creds, ldb_get_opaque(module->ldb, "EventContext"), ldb_get_opaque(module->ldb, "loadparm")); + kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm")); if (kret != 0) { talloc_free(data->changed_dns); data->changed_dns = NULL; @@ -169,6 +379,7 @@ static int update_kt_end_trans(struct ldb_module *module) talloc_free(data->changed_dns); data->changed_dns = NULL; + return ldb_next_end_trans(module); } @@ -176,7 +387,7 @@ static int update_kt_end_trans(struct ldb_module *module) static int update_kt_del_trans(struct ldb_module *module) { struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); - + talloc_free(data->changed_dns); data->changed_dns = NULL; diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c index b5b7ddfdc6..f75ea3c4f7 100644 --- a/source4/dsdb/samdb/samdb.c +++ b/source4/dsdb/samdb/samdb.c @@ -34,7 +34,7 @@ #include "system/time.h" #include "system/filesys.h" #include "ldb_wrap.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" #include "param/param.h" @@ -175,7 +175,7 @@ int samdb_copy_template(struct ldb_context *ldb, } /* pull the template record */ - ret = ldb_search(templates_ldb, basedn, LDB_SCOPE_BASE, "distinguishedName=*", NULL, &res); + ret = ldb_search(templates_ldb, msg, &res, basedn, LDB_SCOPE_BASE, NULL, "distinguishedName=*"); talloc_free(basedn); if (ret != LDB_SUCCESS) { *errstring = talloc_steal(msg, ldb_errstring(templates_ldb)); diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index f24a75fd8f..93068d66ef 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -56,6 +56,9 @@ struct dsdb_control_current_partition { struct ldb_module *module; }; +#define DSDB_CONTROL_REPLICATED_UPDATE_OID "1.3.6.1.4.1.7165.4.3.3" +/* DSDB_CONTROL_REPLICATED_UPDATE_OID has NULL data */ + #define DSDB_EXTENDED_REPLICATED_OBJECTS_OID "1.3.6.1.4.1.7165.4.4.1" struct dsdb_extended_replicated_object { struct ldb_message *msg; diff --git a/source4/dsdb/samdb/samdb_privilege.c b/source4/dsdb/samdb/samdb_privilege.c index 688d1ef9de..d4ef79aac1 100644 --- a/source4/dsdb/samdb/samdb_privilege.c +++ b/source4/dsdb/samdb/samdb_privilege.c @@ -24,7 +24,7 @@ #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "libcli/security/security.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "param/param.h" /* diff --git a/source4/dsdb/schema/schema_description.c b/source4/dsdb/schema/schema_description.c index 6884c5284e..c3c37b4653 100644 --- a/source4/dsdb/schema/schema_description.c +++ b/source4/dsdb/schema/schema_description.c @@ -33,7 +33,6 @@ char *schema_attribute_description(TALLOC_CTX *mem_ctx, const char *seperator, const char *oid, const char *name, - const char *description, const char *equality, const char *substring, const char *syntax, @@ -46,15 +45,6 @@ char *schema_attribute_description(TALLOC_CTX *mem_ctx, "NAME '%s'%s", name, seperator); IF_NULL_FAIL_RET(schema_entry); - if (description) { -#if 0 - /* Need a way to escape ' characters from the description */ - schema_entry = talloc_asprintf_append(schema_entry, - "DESC '%s'%s", description, seperator); - IF_NULL_FAIL_RET(schema_entry); -#endif - } - if (equality) { schema_entry = talloc_asprintf_append(schema_entry, "EQUALITY %s%s", equality, seperator); @@ -104,7 +94,7 @@ char *schema_attribute_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_att " ", attribute->attributeID_oid, attribute->lDAPDisplayName, - NULL, NULL, NULL, talloc_asprintf(tmp_ctx, "'%s'", syntax), + NULL, NULL, talloc_asprintf(tmp_ctx, "'%s'", syntax), attribute->isSingleValued, attribute->systemOnly); talloc_free(tmp_ctx); @@ -149,7 +139,6 @@ char *schema_class_description(TALLOC_CTX *mem_ctx, const char *oid, const char *name, const char **auxillary_classes, - const char *description, const char *subClassOf, int objectClassCategory, char **must, @@ -164,12 +153,6 @@ char *schema_class_description(TALLOC_CTX *mem_ctx, "NAME '%s'%s", name, seperator); IF_NULL_FAIL_RET(schema_entry); - if (description) { - schema_entry = talloc_asprintf_append(schema_entry, - "DESC '%s'%s", description, seperator); - IF_NULL_FAIL_RET(schema_entry); - } - if (auxillary_classes) { schema_entry = talloc_asprintf_append(schema_entry, "AUX ( "); @@ -262,7 +245,6 @@ char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class * " ", class->governsID_oid, class->lDAPDisplayName, - NULL, NULL, class->subClassOf, class->objectClassCategory, @@ -308,8 +290,11 @@ char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_clas class->governsID_oid, class->lDAPDisplayName, (const char **)aux_class_list, - NULL, - class->subClassOf, + NULL, /* Must not specify a + * SUP (subclass) in + * ditContentRules + * per MS-ADTS + * 3.1.1.3.1.1.1 */ -1, must_attr_list, may_attr_list); talloc_free(tmp_ctx); return schema_description; diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 3ed7daee59..69d4c2ce80 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -23,7 +23,7 @@ #include "includes.h" #include "dsdb/samdb/samdb.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" @@ -199,9 +199,8 @@ WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema, return ntstatus_to_werror(nt_status); } - *schemaInfo = strhex_to_data_blob(schema->schema_info); + *schemaInfo = strhex_to_data_blob(mem_ctx, schema->schema_info); W_ERROR_HAVE_NO_MEMORY(schemaInfo->data); - talloc_steal(mem_ctx, schemaInfo->data); return WERR_OK; } @@ -525,18 +524,21 @@ WERROR dsdb_read_prefixes_from_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, return WERR_FOOBAR; } - ret = ldb_search(ldb, schema_dn, LDB_SCOPE_BASE,NULL, schema_attrs,&schema_res); + ret = ldb_search(ldb, mem_ctx, &schema_res, schema_dn, LDB_SCOPE_BASE, schema_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { DEBUG(0,("dsdb_read_prefixes_from_ldb: no prefix map present\n")); + talloc_free(schema_res); return WERR_FOOBAR; } else if (ret != LDB_SUCCESS) { DEBUG(0,("dsdb_read_prefixes_from_ldb: failed to search the schema head\n")); + talloc_free(schema_res); return WERR_FOOBAR; } prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap"); if (!prefix_val) { DEBUG(0,("dsdb_read_prefixes_from_ldb: no prefixMap attribute found\n")); + talloc_free(schema_res); return WERR_FOOBAR; } @@ -550,9 +552,12 @@ WERROR dsdb_read_prefixes_from_ldb(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0,("dsdb_read_prefixes_from_ldb: ndr_pull_struct_blob failed\n")); talloc_free(blob); + talloc_free(schema_res); return WERR_FOOBAR; } + talloc_free(schema_res); + if (blob->version != PREFIX_MAP_VERSION_DSDB) { DEBUG(0,("dsdb_read_prefixes_from_ldb: blob->version incorect\n")); talloc_free(blob); @@ -813,12 +818,11 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, } info_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "schemaInfo"); if (!info_val) { - info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000"); + info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000"); if (!info_val_default.data) { dsdb_oom(error_string, mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } - talloc_steal(mem_ctx, info_val_default.data); info_val = &info_val_default; } @@ -905,7 +909,7 @@ static int fetch_oc_recursive(struct ldb_context *ldb, struct ldb_dn *schemadn, const char *name = ldb_msg_find_attr_as_string(search_from->msgs[i], "lDAPDisplayname", NULL); - ret = ldb_search_exp_fmt(ldb, mem_ctx, &res, + ret = ldb_search(ldb, mem_ctx, &res, schemadn, LDB_SCOPE_SUBTREE, NULL, "(&(&(objectClass=classSchema)(subClassOf=%s))(!(lDAPDisplayName=%s)))", name, name); @@ -946,9 +950,9 @@ static int fetch_objectclass_schema(struct ldb_context *ldb, struct ldb_dn *sche } /* Download 'top' */ - ret = ldb_search(ldb, schemadn, LDB_SCOPE_SUBTREE, - "(&(objectClass=classSchema)(lDAPDisplayName=top))", - NULL, &top_res); + ret = ldb_search(ldb, local_ctx, &top_res, + schemadn, LDB_SCOPE_SUBTREE, NULL, + "(&(objectClass=classSchema)(lDAPDisplayName=top))"); if (ret != LDB_SUCCESS) { *error_string = talloc_asprintf(mem_ctx, "dsdb_schema: failed to search for top classSchema object: %s", @@ -956,8 +960,6 @@ static int fetch_objectclass_schema(struct ldb_context *ldb, struct ldb_dn *sche return ret; } - talloc_steal(local_ctx, top_res); - if (top_res->count != 1) { *error_string = talloc_asprintf(mem_ctx, "dsdb_schema: failed to find top classSchema object"); @@ -1008,10 +1010,8 @@ int dsdb_schema_from_schema_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, /* * setup the prefix mappings and schema info */ - ret = ldb_search(ldb, schema_dn, - LDB_SCOPE_BASE, - NULL, schema_attrs, - &schema_res); + ret = ldb_search(ldb, tmp_ctx, &schema_res, + schema_dn, LDB_SCOPE_BASE, schema_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { talloc_free(tmp_ctx); return ret; @@ -1022,7 +1022,6 @@ int dsdb_schema_from_schema_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, talloc_free(tmp_ctx); return ret; } - talloc_steal(tmp_ctx, schema_res); if (schema_res->count != 1) { *error_string_out = talloc_asprintf(mem_ctx, "dsdb_schema: [%u] schema heads found on a base search", @@ -1034,10 +1033,9 @@ int dsdb_schema_from_schema_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, /* * load the attribute definitions */ - ret = ldb_search(ldb, schema_dn, - LDB_SCOPE_ONELEVEL, - "(objectClass=attributeSchema)", NULL, - &a_res); + ret = ldb_search(ldb, tmp_ctx, &a_res, + schema_dn, LDB_SCOPE_ONELEVEL, NULL, + "(objectClass=attributeSchema)"); if (ret != LDB_SUCCESS) { *error_string_out = talloc_asprintf(mem_ctx, "dsdb_schema: failed to search attributeSchema objects: %s", @@ -1045,7 +1043,6 @@ int dsdb_schema_from_schema_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, talloc_free(tmp_ctx); return ret; } - talloc_steal(tmp_ctx, a_res); /* * load the objectClass definitions diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 2303b88a05..d0aae4e221 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -24,7 +24,7 @@ #include "dsdb/samdb/samdb.h" #include "lib/ldb/include/ldb_errors.h" #include "lib/ldb/include/ldb_private.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" @@ -116,7 +116,7 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem /* Try to avoid churning the attributes too much - we only want to do this if they have changed */ - ret = ldb_search_exp_fmt(ldb, mem_ctx, &res, msg->dn, LDB_SCOPE_BASE, NULL, "dn=%s", ldb_dn_get_linearized(msg->dn)); + ret = ldb_search(ldb, mem_ctx, &res, msg->dn, LDB_SCOPE_BASE, NULL, "dn=%s", ldb_dn_get_linearized(msg->dn)); if (ret == LDB_ERR_NO_SUCH_OBJECT) { ret = ldb_add(ldb, msg); } else if (ret != LDB_SUCCESS) { @@ -144,7 +144,7 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem /* Now write out the indexs, as found in the schema (if they have changed) */ - ret = ldb_search_exp_fmt(ldb, mem_ctx, &res_idx, msg_idx->dn, LDB_SCOPE_BASE, NULL, "dn=%s", ldb_dn_get_linearized(msg_idx->dn)); + ret = ldb_search(ldb, mem_ctx, &res_idx, msg_idx->dn, LDB_SCOPE_BASE, NULL, "dn=%s", ldb_dn_get_linearized(msg_idx->dn)); if (ret == LDB_ERR_NO_SUCH_OBJECT) { ret = ldb_add(ldb, msg_idx); } else if (ret != LDB_SUCCESS) { @@ -328,11 +328,10 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf info_val = ldb_msg_find_ldb_val(msg, "schemaInfo"); if (!info_val) { - info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000"); + info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000"); if (!info_val_default.data) { goto nomem; } - talloc_steal(mem_ctx, info_val_default.data); info_val = &info_val_default; } diff --git a/source4/dynconfig/config.mk b/source4/dynconfig/config.mk index b10018384f..f79cdb8e75 100644 --- a/source4/dynconfig/config.mk +++ b/source4/dynconfig/config.mk @@ -3,22 +3,22 @@ DYNCONFIG_OBJ_FILES = $(dynconfigsrcdir)/dynconfig.o # set these to where to find various files -# These can be overridden by command line switches (see smbd(8)) +# These can be overridden by command line switches (see samba(8)) # or in smb.conf (see smb.conf(5)) -CONFIGFILE = $(sysconfdir)/smb.conf -PKGCONFIGDIR = $(libdir)/pkgconfig -LMHOSTSFILE = $(sysconfdir)/lmhosts +CONFIG4FILE = $(sysconfdir)/smb.conf +pkgconfigdir = $(libdir)/pkgconfig +LMHOSTSFILE4 = $(sysconfdir)/lmhosts -$(dynconfigsrcdir)/dynconfig.o: CFLAGS+=-DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(bindir)\" \ - -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \ +$(dynconfigsrcdir)/dynconfig.o: CFLAGS+=-DCONFIGFILE=\"$(CONFIG4FILE)\" -DBINDIR=\"$(bindir)\" \ + -DLMHOSTSFILE=\"$(LMHOSTSFILE4)\" \ -DLOCKDIR=\"$(lockdir)\" -DPIDDIR=\"$(piddir)\" -DDATADIR=\"$(datadir)\" \ -DLOGFILEBASE=\"$(logfilebase)\" \ - -DCONFIGDIR=\"$(sysconfdir)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \ - -DSWATDIR=\"$(SWATDIR)\" \ + -DCONFIGDIR=\"$(sysconfdir)\" -DNCALRPCDIR=\"$(ncalrpcdir)\" \ + -DSWATDIR=\"$(swatdir)\" \ -DPRIVATE_DIR=\"$(privatedir)\" \ - -DMODULESDIR=\"$(modulesdir)\" -DJSDIR=\"$(JSDIR)\" \ - -DTORTUREDIR=\"$(TORTUREDIR)\" \ - -DSETUPDIR=\"$(SETUPDIR)\" \ + -DMODULESDIR=\"$(modulesdir)\" \ + -DTORTUREDIR=\"$(torturedir)\" \ + -DSETUPDIR=\"$(setupdir)\" \ -DWINBINDD_PRIVILEGED_SOCKET_DIR=\"$(winbindd_privileged_socket_dir)\" \ -DWINBINDD_SOCKET_DIR=\"$(winbindd_socket_dir)\" \ -DNTP_SIGND_SOCKET_DIR=\"$(ntp_signd_socket_dir)\" diff --git a/source4/dynconfig/dynconfig.c b/source4/dynconfig/dynconfig.c index 507570318d..e0cabef317 100644 --- a/source4/dynconfig/dynconfig.c +++ b/source4/dynconfig/dynconfig.c @@ -79,9 +79,6 @@ _PUBLIC_ const char *dyn_SWATDIR = SWATDIR; /** SETUP files (source files used by the provision) */ _PUBLIC_ const char *dyn_SETUPDIR = SETUPDIR; -/** EJS Javascript library includes */ -_PUBLIC_ const char *dyn_JSDIR = JSDIR; - /** Where to find the winbindd socket */ _PUBLIC_ const char *dyn_WINBINDD_SOCKET_DIR = WINBINDD_SOCKET_DIR; diff --git a/source4/headermap.txt b/source4/headermap.txt index e2bbb167ed..43119d2695 100644 --- a/source4/headermap.txt +++ b/source4/headermap.txt @@ -1,18 +1,18 @@ # FIXME: This file should be autogenerated by the build system at some # point -lib/util/util.h: util.h -lib/util/debug.h: util/debug.h -lib/util/mutex.h: util/mutex.h -lib/util/attr.h: util/attr.h -lib/util/byteorder.h: util/byteorder.h -lib/util/safe_string.h: util/safe_string.h -lib/util/xfile.h: util/xfile.h +../lib/util/util.h: util.h +../lib/util/debug.h: util/debug.h +../lib/util/mutex.h: util/mutex.h +../lib/util/attr.h: util/attr.h +../lib/util/byteorder.h: util/byteorder.h +../lib/util/safe_string.h: util/safe_string.h +../lib/util/xfile.h: util/xfile.h lib/tdr/tdr.h: tdr.h librpc/rpc/dcerpc.h: dcerpc.h lib/ldb/include/ldb.h: ldb.h lib/ldb/include/ldb_errors.h: ldb_errors.h auth/gensec/gensec.h: gensec.h -librpc/ndr/libndr.h: ndr.h +../librpc/ndr/libndr.h: ndr.h lib/registry/registry.h: registry.h libcli/util/werror.h: core/werror.h libcli/util/doserr.h: core/doserr.h @@ -52,21 +52,21 @@ librpc/gen_ndr/svcctl.h: gen_ndr/svcctl.h librpc/gen_ndr/ndr_svcctl.h: gen_ndr/ndr_svcctl.h librpc/gen_ndr/ndr_svcctl_c.h: gen_ndr/ndr_svcctl_c.h lib/cmdline/popt_common.h: samba/popt.h -lib/util/dlinklist.h: dlinklist.h -lib/util/data_blob.h: util/data_blob.h -lib/util/time.h: util/time.h +../lib/util/dlinklist.h: dlinklist.h +../lib/util/data_blob.h: util/data_blob.h +../lib/util/time.h: util/time.h version.h: samba/version.h param/param.h: param.h -lib/util/asn1.h: samba/asn1.h +../lib/util/asn1.h: samba/asn1.h libcli/util/error.h: core/error.h lib/tdb_wrap.h: tdb_wrap.h lib/ldb_wrap.h: ldb_wrap.h torture/smbtorture.h: smbtorture.h librpc/gen_ndr/winbind.h: gen_ndr/winbind.h param/share.h: share.h -lib/util/util_tdb.h: util_tdb.h -lib/util/util_ldb.h: util_ldb.h -lib/util/wrap_xattr.h: wrap_xattr.h +../lib/util/util_tdb.h: util_tdb.h +../lib/util/util_ldb.h: util_ldb.h +../lib/util/wrap_xattr.h: wrap_xattr.h lib/events/events.h: events/events.h lib/events/events_internal.h: events/events_internal.h libcli/ldap/ldap_ndr.h: ldap_ndr.h diff --git a/source4/heimdal/kdc/krb5tgs.c b/source4/heimdal/kdc/krb5tgs.c index 19dff5e01d..d557da2a5b 100644 --- a/source4/heimdal/kdc/krb5tgs.c +++ b/source4/heimdal/kdc/krb5tgs.c @@ -1393,6 +1393,8 @@ tgs_build_reply(krb5_context context, char opt_str[128]; int signedpath = 0; + Key *tkey; + memset(&sessionkey, 0, sizeof(sessionkey)); memset(&adtkt, 0, sizeof(adtkt)); krb5_data_zero(&rspac); @@ -1630,26 +1632,22 @@ server_lookup: } /* check PAC if not cross realm and if there is one */ - if (!cross_realm) { - Key *tkey; - - ret = hdb_enctype2key(context, &krbtgt->entry, - krbtgt_etype, &tkey); - if(ret) { - kdc_log(context, config, 0, + ret = hdb_enctype2key(context, &krbtgt->entry, + krbtgt_etype, &tkey); + if(ret) { + kdc_log(context, config, 0, "Failed to find key for krbtgt PAC check"); - goto out; - } + goto out; + } - ret = check_PAC(context, config, cp, - client, server, ekey, &tkey->key, - tgt, &rspac, &signedpath); - if (ret) { - kdc_log(context, config, 0, - "Verify PAC failed for %s (%s) from %s with %s", - spn, cpn, from, krb5_get_err_text(context, ret)); - goto out; - } + ret = check_PAC(context, config, cp, + client, server, ekey, &tkey->key, + tgt, &rspac, &signedpath); + if (ret) { + kdc_log(context, config, 0, + "Verify PAC failed for %s (%s) from %s with %s", + spn, cpn, from, krb5_get_err_text(context, ret)); + goto out; } /* also check the krbtgt for signature */ diff --git a/source4/heimdal/kpasswd/kpasswd.c b/source4/heimdal/kpasswd/kpasswd.c new file mode 100644 index 0000000000..b844628f6f --- /dev/null +++ b/source4/heimdal/kpasswd/kpasswd.c @@ -0,0 +1,247 @@ +/* + * Copyright (c) 1997-2004 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "kpasswd_locl.h" +RCSID("$Id: kpasswd.c 19078 2006-11-20 18:12:41Z lha $"); + +static int version_flag; +static int help_flag; +static char *admin_principal_str; +static char *cred_cache_str; + +static struct getargs args[] = { + { "admin-principal", 0, arg_string, &admin_principal_str }, + { "cache", 'c', arg_string, &cred_cache_str }, + { "version", 0, arg_flag, &version_flag }, + { "help", 0, arg_flag, &help_flag } +}; + +static void +usage (int ret, struct getargs *a, int num_args) +{ + arg_printusage (a, num_args, NULL, "[principal ...]"); + exit (ret); +} + +static int +change_password(krb5_context context, + krb5_principal principal, + krb5_ccache id) +{ + krb5_data result_code_string, result_string; + int result_code; + krb5_error_code ret; + char pwbuf[BUFSIZ]; + char *msg, *name; + + krb5_data_zero (&result_code_string); + krb5_data_zero (&result_string); + + name = msg = NULL; + if (principal == NULL) + asprintf(&msg, "New password: "); + else { + ret = krb5_unparse_name(context, principal, &name); + if (ret) + krb5_err(context, 1, ret, "krb5_unparse_name"); + + asprintf(&msg, "New password for %s: ", name); + } + + if (msg == NULL) + krb5_errx (context, 1, "out of memory"); + + ret = UI_UTIL_read_pw_string (pwbuf, sizeof(pwbuf), msg, 1); + free(msg); + if (name) + free(name); + if (ret != 0) { + return 1; + } + + ret = krb5_set_password_using_ccache (context, id, pwbuf, + principal, + &result_code, + &result_code_string, + &result_string); + if (ret) { + krb5_warn (context, ret, "krb5_set_password_using_ccache"); + return 1; + } + + printf ("%s%s%.*s\n", krb5_passwd_result_to_string(context, result_code), + result_string.length > 0 ? " : " : "", + (int)result_string.length, + result_string.length > 0 ? (char *)result_string.data : ""); + + krb5_data_free (&result_code_string); + krb5_data_free (&result_string); + + return ret != 0; +} + + +int +main (int argc, char **argv) +{ + krb5_error_code ret; + krb5_context context; + krb5_principal principal; + int optind = 0; + krb5_get_init_creds_opt *opt; + krb5_ccache id = NULL; + int exit_value; + + optind = krb5_program_setup(&context, argc, argv, + args, sizeof(args) / sizeof(args[0]), usage); + + if (help_flag) + usage (0, args, sizeof(args) / sizeof(args[0])); + + if(version_flag){ + print_version (NULL); + exit(0); + } + + argc -= optind; + argv += optind; + + ret = krb5_init_context (&context); + if (ret) + errx (1, "krb5_init_context failed: %d", ret); + + ret = krb5_get_init_creds_opt_alloc (context, &opt); + if (ret) + krb5_err(context, 1, ret, "krb5_get_init_creds_opt_alloc"); + + krb5_get_init_creds_opt_set_tkt_life (opt, 300); + krb5_get_init_creds_opt_set_forwardable (opt, FALSE); + krb5_get_init_creds_opt_set_proxiable (opt, FALSE); + + if (cred_cache_str) { + ret = krb5_cc_resolve(context, cred_cache_str, &id); + if (ret) + krb5_err (context, 1, ret, "krb5_cc_resolve"); + } else { + ret = krb5_cc_gen_new(context, &krb5_mcc_ops, &id); + if (ret) + krb5_err (context, 1, ret, "krb5_cc_gen_new"); + } + + if (cred_cache_str == NULL) { + krb5_principal admin_principal = NULL; + krb5_creds cred; + + if (admin_principal_str) { + ret = krb5_parse_name (context, admin_principal_str, + &admin_principal); + if (ret) + krb5_err (context, 1, ret, "krb5_parse_name"); + } else if (argc == 1) { + ret = krb5_parse_name (context, argv[0], &admin_principal); + if (ret) + krb5_err (context, 1, ret, "krb5_parse_name"); + } else { + ret = krb5_get_default_principal (context, &admin_principal); + if (ret) + krb5_err (context, 1, ret, "krb5_get_default_principal"); + } + + ret = krb5_get_init_creds_password (context, + &cred, + admin_principal, + NULL, + krb5_prompter_posix, + NULL, + 0, + "kadmin/changepw", + opt); + switch (ret) { + case 0: + break; + case KRB5_LIBOS_PWDINTR : + return 1; + case KRB5KRB_AP_ERR_BAD_INTEGRITY : + case KRB5KRB_AP_ERR_MODIFIED : + krb5_errx(context, 1, "Password incorrect"); + break; + default: + krb5_err(context, 1, ret, "krb5_get_init_creds"); + } + + krb5_get_init_creds_opt_free(context, opt); + + ret = krb5_cc_initialize(context, id, admin_principal); + krb5_free_principal(context, admin_principal); + if (ret) + krb5_err(context, 1, ret, "krb5_cc_initialize"); + + ret = krb5_cc_store_cred(context, id, &cred); + if (ret) + krb5_err(context, 1, ret, "krb5_cc_store_cred"); + + krb5_free_cred_contents (context, &cred); + } + + if (argc == 0) { + exit_value = change_password(context, NULL, id); + } else { + exit_value = 0; + + while (argc-- > 0) { + + ret = krb5_parse_name (context, argv[0], &principal); + if (ret) + krb5_err (context, 1, ret, "krb5_parse_name"); + + ret = change_password(context, principal, id); + if (ret) + exit_value = 1; + krb5_free_principal(context, principal); + argv++; + } + } + + if (cred_cache_str == NULL) { + ret = krb5_cc_destroy(context, id); + if (ret) + krb5_err (context, 1, ret, "krb5_cc_destroy"); + } else { + ret = krb5_cc_close(context, id); + if (ret) + krb5_err (context, 1, ret, "krb5_cc_close"); + } + + krb5_free_context (context); + return ret; +} diff --git a/source4/heimdal/kpasswd/kpasswd_locl.h b/source4/heimdal/kpasswd/kpasswd_locl.h new file mode 100644 index 0000000000..b797ceb26d --- /dev/null +++ b/source4/heimdal/kpasswd/kpasswd_locl.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: kpasswd_locl.h 11444 2002-09-10 20:03:49Z joda $ */ + +#ifndef __KPASSWD_LOCL_H__ +#define __KPASSWD_LOCL_H__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_SYS_UIO_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_PWD_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_NETINET_IN6_H +#include +#endif +#ifdef HAVE_NETINET6_IN6_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_DLFCN_H +#include +#endif +#ifdef HAVE_UTIL_H +#include +#endif +#ifdef HAVE_LIBUTIL_H +#include +#endif +#include +#include +#include +#include +#include "crypto-headers.h" /* for des_read_pw_string */ + +#endif /* __KPASSWD_LOCL_H__ */ diff --git a/source4/heimdal/lib/hdb/hdb.c b/source4/heimdal/lib/hdb/hdb.c index 3fddabb2d0..19c170767d 100644 --- a/source4/heimdal/lib/hdb/hdb.c +++ b/source4/heimdal/lib/hdb/hdb.c @@ -31,34 +31,27 @@ * SUCH DAMAGE. */ +#include "krb5.h" +#include "krb5_locl.h" #include "hdb_locl.h" - RCSID("$Id$"); #ifdef HAVE_DLFCN_H #include #endif -struct hdb_method { - const char *prefix; - krb5_error_code (*create)(krb5_context, HDB **, const char *filename); -}; - static struct hdb_method methods[] = { #if HAVE_DB1 || HAVE_DB3 - {"db:", hdb_db_create}, + {HDB_INTERFACE_VERSION, "db:", hdb_db_create}, #endif #if HAVE_NDBM - {"ndbm:", hdb_ndbm_create}, + {HDB_INTERFACE_VERSION, "ndbm:", hdb_ndbm_create}, #endif #if defined(OPENLDAP) && !defined(OPENLDAP_MODULE) - {"ldap:", hdb_ldap_create}, - {"ldapi:", hdb_ldapi_create}, -#endif -#ifdef HAVE_LDB /* Used for integrated samba build */ - {"ldb:", hdb_ldb_create}, + {HDB_INTERFACE_VERSION, "ldap:", hdb_ldap_create}, + {HDB_INTERFACE_VERSION, "ldapi:", hdb_ldapi_create}, #endif - {NULL, NULL} + {0, NULL, NULL} }; #if HAVE_DB1 || HAVE_DB3 @@ -398,11 +391,32 @@ hdb_create(krb5_context context, HDB **db, const char *filename) { const struct hdb_method *h; const char *residual; + krb5_error_code ret; + struct krb5_plugin *list = NULL, *e; if(filename == NULL) filename = HDB_DEFAULT_DB; krb5_add_et_list(context, initialize_hdb_error_table_r); h = find_method (filename, &residual); + + if (h == NULL) { + ret = _krb5_plugin_find(context, PLUGIN_TYPE_DATA, "hdb", &list); + if(ret == 0 && list != NULL) { + for (e = list; e != NULL; e = _krb5_plugin_get_next(e)) { + h = _krb5_plugin_get_symbol(e); + if (strncmp (filename, h->prefix, strlen(h->prefix)) == 0 + && h->interface_version == HDB_INTERFACE_VERSION) { + residual = filename + strlen(h->prefix); + break; + } + } + if (e == NULL) { + h = NULL; + _krb5_plugin_free(list); + } + } + } + #ifdef HAVE_DLOPEN if (h == NULL) h = find_dynamic_method (context, filename, &residual); diff --git a/source4/heimdal/lib/hdb/hdb.h b/source4/heimdal/lib/hdb/hdb.h index bc1b744015..5c2097ea59 100644 --- a/source4/heimdal/lib/hdb/hdb.h +++ b/source4/heimdal/lib/hdb/hdb.h @@ -139,6 +139,12 @@ typedef krb5_error_code (*hdb_foreach_func_t)(krb5_context, HDB*, hdb_entry_ex*, void*); extern krb5_kt_ops hdb_kt_ops; +struct hdb_method { + int interface_version; + const char *prefix; + krb5_error_code (*create)(krb5_context, HDB **, const char *filename); +}; + #include #endif /* __HDB_H__ */ diff --git a/source4/heimdal/lib/hdb/keys.c b/source4/heimdal/lib/hdb/keys.c index e649f445e0..a2637eb0b9 100644 --- a/source4/heimdal/lib/hdb/keys.c +++ b/source4/heimdal/lib/hdb/keys.c @@ -39,7 +39,7 @@ RCSID("$Id$"); * free all the memory used by (len, keys) */ -void +static void hdb_free_keys (krb5_context context, int len, Key *keys) { int i; @@ -250,7 +250,7 @@ add_enctype_to_key_set(Key **key_set, size_t *nkeyset, * it's random keys that is going to be created. */ -krb5_error_code +static krb5_error_code hdb_generate_key_set(krb5_context context, krb5_principal principal, Key **ret_key_set, size_t *nkeyset, int no_salt) { @@ -362,7 +362,7 @@ hdb_generate_key_set(krb5_context context, krb5_principal principal, } -krb5_error_code +static krb5_error_code hdb_generate_key_set_password(krb5_context context, krb5_principal principal, const char *password, diff --git a/source4/lib/replace/timegm.c b/source4/heimdal/lib/krb5/prog_setup.c similarity index 63% rename from source4/lib/replace/timegm.c rename to source4/heimdal/lib/krb5/prog_setup.c index 395c684e11..0586155ac4 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/heimdal/lib/krb5/prog_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -31,48 +31,36 @@ * SUCH DAMAGE. */ -/* - adapted for Samba4 by Andrew Tridgell -*/ +#include "krb5_locl.h" +#include +#include -#include "replace.h" -#include "system/time.h" +RCSID("$Id: prog_setup.c 15470 2005-06-17 04:29:41Z lha $"); -static int is_leap(unsigned y) +void KRB5_LIB_FUNCTION +krb5_std_usage(int code, struct getargs *args, int num_args) { - y += 1900; - return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); + arg_printusage(args, num_args, NULL, ""); + exit(code); } -time_t rep_timegm(struct tm *tm) +int KRB5_LIB_FUNCTION +krb5_program_setup(krb5_context *context, int argc, char **argv, + struct getargs *args, int num_args, + void (*usage)(int, struct getargs*, int)) { - static const unsigned ndays[2][12] ={ - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; - time_t res = 0; - unsigned i; + krb5_error_code ret; + int optidx = 0; + + if(usage == NULL) + usage = krb5_std_usage; - if (tm->tm_mon > 12 || - tm->tm_mon < 0 || - tm->tm_mday > 31 || - tm->tm_min > 60 || - tm->tm_sec > 60 || - tm->tm_hour > 24) { - /* invalid tm structure */ - return 0; - } - - for (i = 70; i < tm->tm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; + setprogname(argv[0]); + ret = krb5_init_context(context); + if (ret) + errx (1, "krb5_init_context failed: %d", ret); + + if(getarg(args, num_args, argc, argv, &optidx)) + (*usage)(1, args, num_args); + return optidx; } diff --git a/source4/heimdal/lib/roken/rkpty.c b/source4/heimdal/lib/roken/rkpty.c new file mode 100644 index 0000000000..e29b2c5aca --- /dev/null +++ b/source4/heimdal/lib/roken/rkpty.c @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2008 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" + +#ifndef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_WAIT_H +#include +#endif +#include +#include +#include +#ifdef HAVE_PTY_H +#include +#endif +#ifdef HAVE_UTIL_H +#include +#endif + +#include "roken.h" +#include + +struct command { + enum { CMD_EXPECT = 0, CMD_SEND, CMD_PASSWORD } type; + unsigned int lineno; + char *str; + struct command *next; +}; + +/* + * + */ + +static struct command *commands, **next = &commands; + +static sig_atomic_t alarmset = 0; + +static int timeout = 10; +static int verbose; +static int help_flag; +static int version_flag; + +static int master; +static int slave; +static char line[256] = { 0 }; + +static void +caught_signal(int signo) +{ + alarmset = signo; +} + + +static void +open_pty(void) +{ +#if defined(HAVE_OPENPTY) || defined(__linux) || defined(__osf__) /* XXX */ + if(openpty(&master, &slave, line, 0, 0) == 0) + return; +#endif /* HAVE_OPENPTY .... */ + /* more cases, like open /dev/ptmx, etc */ + + exit(77); +} + +/* + * + */ + +static char * +iscmd(const char *buf, const char *s) +{ + size_t len = strlen(s); + if (strncmp(buf, s, len) != 0) + return NULL; + return estrdup(buf + len); +} + +static void +parse_configuration(const char *fn) +{ + struct command *c; + char s[1024]; + char *str; + unsigned int lineno = 0; + FILE *cmd; + + cmd = fopen(fn, "r"); + if (cmd == NULL) + err(1, "open: %s", fn); + + while (fgets(s, sizeof(s), cmd) != NULL) { + + s[strcspn(s, "#\n")] = '\0'; + lineno++; + + c = calloc(1, sizeof(*c)); + if (c == NULL) + errx(1, "malloc"); + + c->lineno = lineno; + (*next) = c; + next = &(c->next); + + if ((str = iscmd(s, "expect ")) != NULL) { + c->type = CMD_EXPECT; + c->str = str; + } else if ((str = iscmd(s, "send ")) != NULL) { + c->type = CMD_SEND; + c->str = str; + } else if ((str = iscmd(s, "password ")) != NULL) { + c->type = CMD_PASSWORD; + c->str = str; + } else + errx(1, "Invalid command on line %d: %s", lineno, s); + } + + fclose(cmd); +} + + +/* + * + */ + +static int +eval_parent(pid_t pid) +{ + struct command *c; + char in; + size_t len = 0; + ssize_t sret; + + for (c = commands; c != NULL; c = c->next) { + switch(c->type) { + case CMD_EXPECT: + if (verbose) + printf("[expecting %s]", c->str); + len = 0; + alarm(timeout); + while((sret = read(master, &in, sizeof(in))) > 0) { + alarm(timeout); + printf("%c", in); + if (c->str[len] != in) { + len = 0; + continue; + } + len++; + if (c->str[len] == '\0') + break; + } + alarm(0); + if (alarmset == SIGALRM) + errx(1, "timeout waiting for %s (line %u)", + c->str, c->lineno); + else if (alarmset) + errx(1, "got a signal %d waiting for %s (line %u)", + alarmset, c->str, c->lineno); + if (sret <= 0) + errx(1, "end command while waiting for %s (line %u)", + c->str, c->lineno); + break; + case CMD_SEND: + case CMD_PASSWORD: { + size_t i = 0; + const char *msg = (c->type == CMD_PASSWORD) ? "****" : c->str; + + if (verbose) + printf("[send %s]", msg); + + len = strlen(c->str); + + while (i < len) { + if (c->str[i] == '\\' && i < len - 1) { + char ctrl; + i++; + switch(c->str[i]) { + case 'n': ctrl = '\n'; break; + case 'r': ctrl = '\r'; break; + case 't': ctrl = '\t'; break; + default: + errx(1, "unknown control char %c (line %u)", + c->str[i], c->lineno); + } + if (net_write(master, &ctrl, 1) != 1) + errx(1, "command refused input (line %u)", c->lineno); + } else { + if (net_write(master, &c->str[i], 1) != 1) + errx(1, "command refused input (line %u)", c->lineno); + } + i++; + } + break; + } + default: + abort(); + } + } + while(read(master, &in, sizeof(in)) > 0) + printf("%c", in); + + if (verbose) + printf("[end of program]\n"); + + /* + * Fetch status from child + */ + { + int ret, status; + + ret = waitpid(pid, &status, 0); + if (ret == -1) + err(1, "waitpid"); + if (WIFEXITED(status) && WEXITSTATUS(status)) + return WEXITSTATUS(status); + else if (WIFSIGNALED(status)) { + printf("killed by signal: %d\n", WTERMSIG(status)); + return 1; + } + } + return 0; +} + +/* + * + */ + +static struct getargs args[] = { + { "timeout", 't', arg_integer, &timeout, "timout", "seconds" }, + { "verbose", 'v', arg_counter, &verbose, "verbose debugging" }, + { "version", 0, arg_flag, &version_flag, "print version" }, + { "help", 0, arg_flag, &help_flag, NULL } +}; + +static void +usage(int ret) +{ + arg_printusage (args, sizeof(args)/sizeof(*args), NULL, "infile command.."); + exit (ret); +} + +int +main(int argc, char **argv) +{ + int optidx = 0; + pid_t pid; + + setprogname(argv[0]); + + if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx)) + usage(1); + + if (help_flag) + usage (0); + + if (version_flag) { + fprintf (stderr, "%s from %s-%s\n", getprogname(), PACKAGE, VERSION); + return 0; + } + + argv += optidx; + argc -= optidx; + + if (argc < 2) + usage(1); + + parse_configuration(argv[0]); + + argv += 1; + argc -= 1; + + open_pty(); + + pid = fork(); + switch (pid) { + case -1: + err(1, "Failed to fork"); + case 0: + + if(setsid()<0) + err(1, "setsid"); + + dup2(slave, STDIN_FILENO); + dup2(slave, STDOUT_FILENO); + dup2(slave, STDERR_FILENO); + closefrom(STDERR_FILENO + 1); + + execvp(argv[0], argv); /* add NULL to end of array ? */ + err(1, "Failed to exec: %s", argv[0]); + default: + close(slave); + { + struct sigaction sa; + + sa.sa_handler = caught_signal; + sa.sa_flags = 0; + sigemptyset (&sa.sa_mask); + + sigaction(SIGALRM, &sa, NULL); + } + + return eval_parent(pid); + } +} diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h index 38cdfbb6a6..e15c6effa8 100644 --- a/source4/heimdal_build/config.h +++ b/source4/heimdal_build/config.h @@ -7,7 +7,7 @@ #define HAVE_HEIMDAL_CONFIG_H #include "include/config.h" -#include "lib/replace/replace.h" +#include "../replace/replace.h" #define RCSID(msg) struct __rcsid { int __rcsdi; } #define KRB5 diff --git a/source4/heimdal_build/gssapi-glue.c b/source4/heimdal_build/gssapi-glue.c index 0885c2165b..0c27f5100f 100644 --- a/source4/heimdal_build/gssapi-glue.c +++ b/source4/heimdal_build/gssapi-glue.c @@ -19,9 +19,10 @@ along with this program. If not, see . */ -#include "lib/replace/replace.h" +#include "../replace/replace.h" +#include "heimdal/lib/gssapi/gssapi_mech.h" -void *__gss_ntlm_initialize(void) +gssapi_mech_interface __gss_ntlm_initialize(void) { return NULL; } diff --git a/source4/heimdal_build/internal.m4 b/source4/heimdal_build/internal.m4 index 038c4d9417..06e798ce27 100644 --- a/source4/heimdal_build/internal.m4 +++ b/source4/heimdal_build/internal.m4 @@ -49,6 +49,7 @@ AC_CHECK_HEADERS([ \ errno.h \ inttypes.h \ netdb.h \ + pty.h \ signal.h \ sys/bswap.h \ sys/file.h \ @@ -158,6 +159,13 @@ m4_include(heimdal/cf/find-func-no-libs.m4) m4_include(heimdal/cf/find-func-no-libs2.m4) m4_include(heimdal/cf/resolv.m4) + +AC_CHECK_LIB_EXT(util, OPENPTY_LIBS, openpty) + +SMB_ENABLE(OPENPTY,YES) + +SMB_EXT_LIB(OPENPTY,[${OPENPTY_LIBS}],[${OPENPTY_CFLAGS}],[${OPENPTY_CPPFLAGS}],[${OPENPTY_LDFLAGS}]) + smb_save_LIBS=$LIBS RESOLV_LIBS="" LIBS="" diff --git a/source4/heimdal_build/internal.mk b/source4/heimdal_build/internal.mk index 67fda9dd58..85ce6d3ab0 100644 --- a/source4/heimdal_build/internal.mk +++ b/source4/heimdal_build/internal.mk @@ -322,6 +322,7 @@ HEIMDAL_KRB5_OBJ_FILES = \ $(heimdalsrcdir)/lib/krb5/pkinit.o \ $(heimdalsrcdir)/lib/krb5/plugin.o \ $(heimdalsrcdir)/lib/krb5/principal.o \ + $(heimdalsrcdir)/lib/krb5/prog_setup.o \ $(heimdalsrcdir)/lib/krb5/pac.o \ $(heimdalsrcdir)/lib/krb5/prompter_posix.o \ $(heimdalsrcdir)/lib/krb5/rd_cred.o \ @@ -600,6 +601,7 @@ HEIMDAL_ROKEN_OBJ_FILES = \ $(heimdalsrcdir)/lib/roken/dumpdata.o \ $(heimdalsrcdir)/lib/roken/emalloc.o \ $(heimdalsrcdir)/lib/roken/ecalloc.o \ + $(heimdalsrcdir)/lib/roken/getarg.o \ $(heimdalsrcdir)/lib/roken/get_window_size.o \ $(heimdalsrcdir)/lib/roken/h_errno.o \ $(heimdalsrcdir)/lib/roken/issuid.o \ @@ -612,6 +614,7 @@ HEIMDAL_ROKEN_OBJ_FILES = \ $(heimdalsrcdir)/lib/roken/roken_gethostby.o \ $(heimdalsrcdir)/lib/roken/signal.o \ $(heimdalsrcdir)/lib/roken/vis.o \ + $(heimdalsrcdir)/lib/roken/setprogname.o \ $(heimdalsrcdir)/lib/roken/strlwr.o \ $(heimdalsrcdir)/lib/roken/strsep_copy.o \ $(heimdalsrcdir)/lib/roken/strsep.o \ @@ -652,7 +655,7 @@ HEIMDAL_COM_ERR_OBJ_FILES = \ # Start BINARY asn1_compile [BINARY::asn1_compile] USE_HOSTCC = YES -PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN LIBREPLACE_NETWORK ASN1C = $(builddir)/bin/asn1_compile @@ -676,13 +679,6 @@ dist:: $(heimdalsrcdir)/lib/asn1/lex.c asn1_compile_OBJ_FILES = \ $(asn1_compile_ASN1_OBJ_FILES) \ - $(heimdalsrcdir)/lib/roken/emalloc.ho \ - $(heimdalsrcdir)/lib/roken/getarg.ho \ - $(heimdalsrcdir)/lib/roken/setprogname.ho \ - $(heimdalsrcdir)/lib/roken/strupr.ho \ - $(heimdalsrcdir)/lib/roken/get_window_size.ho \ - $(heimdalsrcdir)/lib/roken/estrdup.ho \ - $(heimdalsrcdir)/lib/roken/ecalloc.ho \ $(heimdalsrcdir)/lib/vers/print_version.ho \ $(socketwrappersrcdir)/socket_wrapper.ho \ $(heimdalbuildsrcdir)/replace.ho @@ -703,7 +699,7 @@ $(eval $(call heimdal_proto_header_template, \ # Start BINARY compile_et [BINARY::compile_et] USE_HOSTCC = YES -PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN LIBREPLACE_NETWORK # End BINARY compile_et ####################### @@ -713,10 +709,6 @@ compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \ $(heimdalsrcdir)/lib/com_err/parse.ho \ $(heimdalsrcdir)/lib/com_err/lex.ho \ $(heimdalsrcdir)/lib/com_err/compile_et.ho \ - $(heimdalsrcdir)/lib/roken/getarg.ho \ - $(heimdalsrcdir)/lib/roken/get_window_size.ho \ - $(heimdalsrcdir)/lib/roken/strupr.ho \ - $(heimdalsrcdir)/lib/roken/setprogname.ho \ $(socketwrappersrcdir)/socket_wrapper.ho \ $(heimdalbuildsrcdir)/replace.ho @@ -761,8 +753,30 @@ PRIVATE_DEPENDENCIES = HEIMDAL_KRB5 HEIMDAL_NTLM ####################### samba4kinit_OBJ_FILES = $(heimdalsrcdir)/kuser/kinit.o \ - $(heimdalsrcdir)/lib/vers/print_version.o \ - $(heimdalsrcdir)/lib/roken/setprogname.o \ - $(heimdalsrcdir)/lib/roken/getarg.o + $(heimdalsrcdir)/lib/vers/print_version.o $(samba4kinit_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken + +####################### +# Start BINARY compile_et +[BINARY::samba4kpasswd] +PRIVATE_DEPENDENCIES = HEIMDAL_KRB5 HEIMDAL_NTLM +# End BINARY compile_et +####################### + +samba4kpasswd_OBJ_FILES = $(heimdalsrcdir)/kpasswd/kpasswd.o \ + $(heimdalsrcdir)/lib/vers/print_version.o + +$(samba4kpasswd_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken + +####################### +# Start BINARY compile_et +[BINARY::rkpty] +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN OPENPTY +# End BINARY compile_et +####################### + +rkpty_OBJ_FILES = $(heimdalsrcdir)/lib/roken/rkpty.o \ + $(socketwrappersrcdir)/socket_wrapper.o + +$(rkpty_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -DPACKAGE=\"Samba\" diff --git a/source4/include/includes.h b/source4/include/includes.h index df0d8f7713..7b623120a9 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -20,7 +20,7 @@ along with this program. If not, see . */ -#include "lib/replace/replace.h" +#include "../replace/replace.h" /* make sure we have included the correct config.h */ #ifndef NO_CONFIG_H /* for some tests */ @@ -42,12 +42,13 @@ #ifndef _PRINTF_ATTRIBUTE #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) #endif -#include "util/util.h" +#include "../lib/util/util.h" +#include "../lib/util/debug.h" #include "libcli/util/error.h" /* String routines */ -#include "util/safe_string.h" +#include "../lib/util/safe_string.h" #if 0 /* darn, we can't do this now that we don't link the ldb tools to all the smb libs */ diff --git a/source4/kdc/config.mk b/source4/kdc/config.mk index 2c96e22cb3..dfd2879bd6 100644 --- a/source4/kdc/config.mk +++ b/source4/kdc/config.mk @@ -4,9 +4,9 @@ # Start SUBSYSTEM KDC [MODULE::KDC] INIT_FUNCTION = server_service_kdc_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = \ - HEIMDAL_KDC HDB_LDB + HEIMDAL_KDC HDB_SAMBA4 # End SUBSYSTEM KDC ####################### @@ -14,7 +14,7 @@ KDC_OBJ_FILES = $(addprefix $(kdcsrcdir)/, kdc.o kpasswdd.o) ####################### # Start SUBSYSTEM KDC -[SUBSYSTEM::HDB_LDB] +[SUBSYSTEM::HDB_SAMBA4] CFLAGS = -Iheimdal/kdc -Iheimdal/lib/hdb PRIVATE_DEPENDENCIES = \ LIBLDB auth_sam auth_sam_reply CREDENTIALS \ @@ -22,5 +22,5 @@ PRIVATE_DEPENDENCIES = \ # End SUBSYSTEM KDC ####################### -HDB_LDB_OBJ_FILES = $(addprefix $(kdcsrcdir)/, hdb-ldb.o pac-glue.o) -$(eval $(call proto_header_template,$(kdcsrcdir)/pac_glue.h,$(HDB_LDB_OBJ_FILES:.o=.c))) +HDB_SAMBA4_OBJ_FILES = $(addprefix $(kdcsrcdir)/, hdb-samba4.o pac-glue.o) +$(eval $(call proto_header_template,$(kdcsrcdir)/pac_glue.h,$(HDB_SAMBA4_OBJ_FILES:.o=.c))) diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-samba4.c similarity index 94% rename from source4/kdc/hdb-ldb.c rename to source4/kdc/hdb-samba4.c index ef3a0bcb8a..b6a48e79d0 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-samba4.c @@ -41,7 +41,7 @@ #include "auth/auth.h" #include "auth/credentials/credentials.h" #include "auth/auth_sam.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "dsdb/samdb/samdb.h" #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_drsblobs.h" @@ -50,11 +50,11 @@ #include "param/param.h" #include "events/events.h" #include "kdc/kdc.h" -#include "lib/crypto/md4.h" +#include "../lib/crypto/md4.h" enum hdb_ldb_ent_type -{ HDB_LDB_ENT_TYPE_CLIENT, HDB_LDB_ENT_TYPE_SERVER, - HDB_LDB_ENT_TYPE_KRBTGT, HDB_LDB_ENT_TYPE_TRUST, HDB_LDB_ENT_TYPE_ANY }; +{ HDB_SAMBA4_ENT_TYPE_CLIENT, HDB_SAMBA4_ENT_TYPE_SERVER, + HDB_SAMBA4_ENT_TYPE_KRBTGT, HDB_SAMBA4_ENT_TYPE_TRUST, HDB_SAMBA4_ENT_TYPE_ANY }; enum trust_direction { UNKNOWN = 0, @@ -115,26 +115,26 @@ static HDBFlags uf2HDBFlags(krb5_context context, int userAccountControl, enum h /* Account types - clear the invalid bit if it turns out to be valid */ if (userAccountControl & UF_NORMAL_ACCOUNT) { - if (ent_type == HDB_LDB_ENT_TYPE_CLIENT || ent_type == HDB_LDB_ENT_TYPE_ANY) { + if (ent_type == HDB_SAMBA4_ENT_TYPE_CLIENT || ent_type == HDB_SAMBA4_ENT_TYPE_ANY) { flags.client = 1; } flags.invalid = 0; } if (userAccountControl & UF_INTERDOMAIN_TRUST_ACCOUNT) { - if (ent_type == HDB_LDB_ENT_TYPE_CLIENT || ent_type == HDB_LDB_ENT_TYPE_ANY) { + if (ent_type == HDB_SAMBA4_ENT_TYPE_CLIENT || ent_type == HDB_SAMBA4_ENT_TYPE_ANY) { flags.client = 1; } flags.invalid = 0; } if (userAccountControl & UF_WORKSTATION_TRUST_ACCOUNT) { - if (ent_type == HDB_LDB_ENT_TYPE_CLIENT || ent_type == HDB_LDB_ENT_TYPE_ANY) { + if (ent_type == HDB_SAMBA4_ENT_TYPE_CLIENT || ent_type == HDB_SAMBA4_ENT_TYPE_ANY) { flags.client = 1; } flags.invalid = 0; } if (userAccountControl & UF_SERVER_TRUST_ACCOUNT) { - if (ent_type == HDB_LDB_ENT_TYPE_CLIENT || ent_type == HDB_LDB_ENT_TYPE_ANY) { + if (ent_type == HDB_SAMBA4_ENT_TYPE_CLIENT || ent_type == HDB_SAMBA4_ENT_TYPE_ANY) { flags.client = 1; } flags.invalid = 0; @@ -186,7 +186,7 @@ static HDBFlags uf2HDBFlags(krb5_context context, int userAccountControl, enum h return flags; } -static int hdb_ldb_destrutor(struct hdb_ldb_private *private) +static int hdb_ldb_destructor(struct hdb_ldb_private *private) { hdb_entry_ex *entry_ex = private->entry_ex; free_hdb_entry(&entry_ex->entry); @@ -277,12 +277,11 @@ static krb5_error_code LDB_message2entry_keys(krb5_context context, if (scpk) { DATA_BLOB blob; - blob = strhex_to_data_blob(scpk->data); + blob = strhex_to_data_blob(mem_ctx, scpk->data); if (!blob.data) { ret = ENOMEM; goto out; } - talloc_steal(mem_ctx, blob.data); /* we cannot use ndr_pull_struct_blob_all() here, as w2k and w2k3 add padding bytes */ ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, iconv_convenience, &_pkb, @@ -542,7 +541,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, private->iconv_convenience = lp_iconv_convenience(lp_ctx); private->netbios_name = lp_netbios_name(lp_ctx); - talloc_set_destructor(private, hdb_ldb_destrutor); + talloc_set_destructor(private, hdb_ldb_destructor); entry_ex->ctx = private; entry_ex->free_entry = hdb_ldb_free_entry; @@ -551,7 +550,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.principal = malloc(sizeof(*(entry_ex->entry.principal))); - if (ent_type == HDB_LDB_ENT_TYPE_ANY && principal == NULL) { + if (ent_type == HDB_SAMBA4_ENT_TYPE_ANY && principal == NULL) { const char *samAccountName = ldb_msg_find_attr_as_string(msg, "samAccountName", NULL); if (!samAccountName) { krb5_set_error_string(context, "LDB_message2entry: no samAccountName present"); @@ -587,7 +586,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.flags = uf2HDBFlags(context, userAccountControl, ent_type); - if (ent_type == HDB_LDB_ENT_TYPE_KRBTGT) { + if (ent_type == HDB_SAMBA4_ENT_TYPE_KRBTGT) { entry_ex->entry.flags.invalid = 0; entry_ex->entry.flags.server = 1; entry_ex->entry.flags.forwardable = 1; @@ -631,7 +630,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, *entry_ex->entry.valid_end = nt_time_to_unix(acct_expiry); } - if (ent_type != HDB_LDB_ENT_TYPE_KRBTGT) { + if (ent_type != HDB_SAMBA4_ENT_TYPE_KRBTGT) { NTTIME must_change_time = samdb_result_force_password_change((struct ldb_context *)db->hdb_db, mem_ctx, domain_dn, msg); @@ -728,7 +727,7 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, private->iconv_convenience = lp_iconv_convenience(lp_ctx); private->netbios_name = lp_netbios_name(lp_ctx); - talloc_set_destructor(private, hdb_ldb_destrutor); + talloc_set_destructor(private, hdb_ldb_destructor); entry_ex->ctx = private; entry_ex->free_entry = hdb_ldb_free_entry; @@ -757,13 +756,20 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, goto out; } - ndr_err = ndr_pull_struct_blob_all(password_val, mem_ctx, private->iconv_convenience, &password_blob, + ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, private->iconv_convenience, &password_blob, (ndr_pull_flags_fn_t)ndr_pull_trustAuthInOutBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { ret = EINVAL; goto out; } + entry_ex->entry.kvno = -1; + for (i=0; i < password_blob.count; i++) { + if (password_blob.current->array[i].AuthType == TRUST_AUTH_TYPE_VERSION) { + entry_ex->entry.kvno = password_blob.current->array[i].AuthInfo.version.version; + } + } + for (i=0; i < password_blob.count; i++) { if (password_blob.current->array[i].AuthType == TRUST_AUTH_TYPE_CLEAR) { password_utf16 = data_blob_const(password_blob.current->array[i].AuthInfo.clear.password, @@ -806,6 +812,8 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, entry_ex->entry.keys.len++; } + entry_ex->entry.principal = malloc(sizeof(*(entry_ex->entry.principal))); + ret = copy_Principal(principal, entry_ex->entry.principal); if (ret) { krb5_clear_error_string(context); @@ -909,16 +917,16 @@ static krb5_error_code LDB_lookup_principal(krb5_context context, struct ldb_con } switch (ent_type) { - case HDB_LDB_ENT_TYPE_CLIENT: - case HDB_LDB_ENT_TYPE_TRUST: - case HDB_LDB_ENT_TYPE_ANY: + case HDB_SAMBA4_ENT_TYPE_CLIENT: + case HDB_SAMBA4_ENT_TYPE_TRUST: + case HDB_SAMBA4_ENT_TYPE_ANY: /* Can't happen */ return EINVAL; - case HDB_LDB_ENT_TYPE_KRBTGT: + case HDB_SAMBA4_ENT_TYPE_KRBTGT: filter = talloc_asprintf(mem_ctx, "(&(objectClass=user)(samAccountName=%s))", KRB5_TGS_NAME); break; - case HDB_LDB_ENT_TYPE_SERVER: + case HDB_SAMBA4_ENT_TYPE_SERVER: filter = talloc_asprintf(mem_ctx, "(&(objectClass=user)(samAccountName=%s))", short_princ_talloc); break; @@ -929,8 +937,8 @@ static krb5_error_code LDB_lookup_principal(krb5_context context, struct ldb_con return ENOMEM; } - lret = ldb_search(ldb_ctx, realm_dn, LDB_SCOPE_SUBTREE, filter, princ_attrs, &res); - + lret = ldb_search(ldb_ctx, mem_ctx, &res, realm_dn, + LDB_SCOPE_SUBTREE, princ_attrs, "%s", filter); if (lret != LDB_SUCCESS) { DEBUG(3, ("Failed to search for %s: %s\n", filter, ldb_errstring(ldb_ctx))); return HDB_ERR_NOENTRY; @@ -963,8 +971,9 @@ static krb5_error_code LDB_lookup_trust(krb5_context context, struct ldb_context return ENOMEM; } - lret = ldb_search(ldb_ctx, ldb_get_default_basedn(ldb_ctx), LDB_SCOPE_SUBTREE, filter, attrs, &res); - + lret = ldb_search(ldb_ctx, mem_ctx, &res, + ldb_get_default_basedn(ldb_ctx), + LDB_SCOPE_SUBTREE, attrs, "%s", filter); if (lret != LDB_SUCCESS) { DEBUG(3, ("Failed to search for %s: %s\n", filter, ldb_errstring(ldb_ctx))); return HDB_ERR_NOENTRY; @@ -988,7 +997,7 @@ static krb5_error_code LDB_lookup_realm(krb5_context context, struct ldb_context struct ldb_result *cross_ref_res; struct ldb_dn *partitions_basedn = samdb_partitions_dn(ldb_ctx, mem_ctx); - ret = ldb_search_exp_fmt(ldb_ctx, mem_ctx, &cross_ref_res, + ret = ldb_search(ldb_ctx, mem_ctx, &cross_ref_res, partitions_basedn, LDB_SCOPE_SUBTREE, realm_ref_attrs, "(&(&(|(&(dnsRoot=%s)(nETBIOSName=*))(nETBIOSName=%s))(objectclass=crossRef))(ncName=*))", realm, realm); @@ -1074,7 +1083,7 @@ static krb5_error_code LDB_fetch_client(krb5_context context, HDB *db, } ret = LDB_message2entry(context, db, mem_ctx, - principal, HDB_LDB_ENT_TYPE_CLIENT, + principal, HDB_SAMBA4_ENT_TYPE_CLIENT, msg[0], realm_ref_msg[0], entry_ex); return ret; } @@ -1135,7 +1144,7 @@ static krb5_error_code LDB_fetch_krbtgt(krb5_context context, HDB *db, ret = LDB_lookup_principal(context, (struct ldb_context *)db->hdb_db, mem_ctx, - principal, HDB_LDB_ENT_TYPE_KRBTGT, realm_dn, &msg); + principal, HDB_SAMBA4_ENT_TYPE_KRBTGT, realm_dn, &msg); if (ret != 0) { krb5_warnx(context, "LDB_fetch: could not find principal in DB"); @@ -1144,10 +1153,10 @@ static krb5_error_code LDB_fetch_krbtgt(krb5_context context, HDB *db, } ret = LDB_message2entry(context, db, mem_ctx, - principal, HDB_LDB_ENT_TYPE_KRBTGT, + principal, HDB_SAMBA4_ENT_TYPE_KRBTGT, msg[0], realm_ref_msg_1[0], entry_ex); if (ret != 0) { - krb5_warnx(context, "LDB_fetch: message2entry failed"); + krb5_warnx(context, "LDB_fetch: self krbtgt message2entry failed"); } return ret; @@ -1185,7 +1194,7 @@ static krb5_error_code LDB_fetch_krbtgt(krb5_context context, HDB *db, principal, direction, msg[0], entry_ex); if (ret != 0) { - krb5_warnx(context, "LDB_fetch: message2entry failed"); + krb5_warnx(context, "LDB_fetch: trust_message2entry failed"); } return ret; @@ -1264,7 +1273,7 @@ static krb5_error_code LDB_fetch_server(krb5_context context, HDB *db, ret = LDB_lookup_principal(context, (struct ldb_context *)db->hdb_db, mem_ctx, - principal, HDB_LDB_ENT_TYPE_SERVER, realm_dn, &msg); + principal, HDB_SAMBA4_ENT_TYPE_SERVER, realm_dn, &msg); if (ret != 0) { return ret; @@ -1272,7 +1281,7 @@ static krb5_error_code LDB_fetch_server(krb5_context context, HDB *db, } ret = LDB_message2entry(context, db, mem_ctx, - principal, HDB_LDB_ENT_TYPE_SERVER, + principal, HDB_SAMBA4_ENT_TYPE_SERVER, msg[0], realm_ref_msg[0], entry_ex); if (ret != 0) { krb5_warnx(context, "LDB_fetch: message2entry failed"); @@ -1357,7 +1366,7 @@ static krb5_error_code LDB_seq(krb5_context context, HDB *db, unsigned flags, hd if (priv->index < priv->count) { ret = LDB_message2entry(context, db, mem_ctx, - NULL, HDB_LDB_ENT_TYPE_ANY, + NULL, HDB_SAMBA4_ENT_TYPE_ANY, priv->msgs[priv->index++], priv->realm_ref_msgs[0], entry); } else { @@ -1432,9 +1441,9 @@ static krb5_error_code LDB_firstkey(krb5_context context, HDB *db, unsigned flag priv->realm_ref_msgs = talloc_steal(priv, realm_ref_msgs); - lret = ldb_search(ldb_ctx, realm_dn, - LDB_SCOPE_SUBTREE, "(objectClass=user)", - user_attrs, &res); + lret = ldb_search(ldb_ctx, priv, &res, + realm_dn, LDB_SCOPE_SUBTREE, user_attrs, + "(objectClass=user)"); if (lret != LDB_SUCCESS) { talloc_free(priv); @@ -1475,7 +1484,7 @@ static krb5_error_code LDB_destroy(krb5_context context, HDB *db) * (hdb_ldb_create) from the kpasswdd -> krb5 -> keytab_hdb -> hdb * code */ -NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx, +NTSTATUS kdc_hdb_samba4_create(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx, struct loadparm_context *lp_ctx, krb5_context context, struct HDB **db, const char *arg) @@ -1535,12 +1544,12 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -krb5_error_code hdb_ldb_create(krb5_context context, struct HDB **db, const char *arg) +krb5_error_code hdb_samba4_create(krb5_context context, struct HDB **db, const char *arg) { NTSTATUS nt_status; /* The global kdc_mem_ctx and kdc_lp_ctx, Disgusting, ugly hack, but it means one less private hook */ - nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, event_context_find(kdc_mem_ctx), kdc_lp_ctx, - context, db, arg); + nt_status = kdc_hdb_samba4_create(kdc_mem_ctx, event_context_find(kdc_mem_ctx), kdc_lp_ctx, + context, db, arg); if (NT_STATUS_IS_OK(nt_status)) { return 0; diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index b7009b030f..45fa803d04 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -29,7 +29,7 @@ #include "lib/events/events.h" #include "lib/socket/socket.h" #include "system/network.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/messaging/irpc.h" #include "lib/stream/packet.h" #include "librpc/gen_ndr/samr.h" @@ -484,7 +484,7 @@ static NTSTATUS kdc_add_socket(struct kdc_server *kdc, const char *address, /* within the kdc task we want to be a single process, so ask for the single process model ops and pass these to the stream_setup_socket() call. */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(kdc->task->event_ctx, "single"); if (!model_ops) { DEBUG(0,("Can't find 'single' process model_ops\n")); talloc_free(kdc_socket); @@ -584,13 +584,11 @@ static NTSTATUS kdc_check_generic_kerberos(struct irpc_message *msg, return NT_STATUS_INVALID_PARAMETER; } -#if 0 - /* Windows does not check this */ if (pac_validate.MessageType != 3) { /* We don't implement any other message types - such as certificate validation - yet */ return NT_STATUS_INVALID_PARAMETER; } -#endif + if (pac_validate.ChecksumAndSignature.length != (pac_validate.ChecksumLength + pac_validate.SignatureLength) || pac_validate.ChecksumAndSignature.length < pac_validate.ChecksumLength || pac_validate.ChecksumAndSignature.length < pac_validate.SignatureLength ) { @@ -659,6 +657,11 @@ static NTSTATUS kdc_check_generic_kerberos(struct irpc_message *msg, } +static struct hdb_method hdb_samba4 = { + .interface_version = HDB_INTERFACE_VERSION, + .prefix = "samba4:", + .create = hdb_samba4_create +}; /* startup the kdc task @@ -726,7 +729,7 @@ static void kdc_task_init(struct task_server *task) } kdc->config->num_db = 1; - status = kdc_hdb_ldb_create(kdc, task->event_ctx, task->lp_ctx, + status = kdc_hdb_samba4_create(kdc, task->event_ctx, task->lp_ctx, kdc->smb_krb5_context->krb5_context, &kdc->config->db[0], NULL); if (!NT_STATUS_IS_OK(status)) { @@ -734,6 +737,16 @@ static void kdc_task_init(struct task_server *task) return; } + + /* Register hdb-samba4 hooks */ + ret = krb5_plugin_register(kdc->smb_krb5_context->krb5_context, + PLUGIN_TYPE_DATA, "hdb", + &hdb_samba4); + if(ret) { + task_server_terminate(task, "kdc: failed to register hdb keytab"); + return; + } + ret = krb5_kt_register(kdc->smb_krb5_context->krb5_context, &hdb_kt_ops); if(ret) { task_server_terminate(task, "kdc: failed to register hdb keytab"); diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c index 603332e69e..1336b0157e 100644 --- a/source4/kdc/kpasswdd.c +++ b/source4/kdc/kpasswdd.c @@ -25,7 +25,7 @@ #include "lib/events/events.h" #include "lib/socket/socket.h" #include "system/network.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/ldb/include/ldb.h" #include "auth/gensec/gensec.h" #include "auth/credentials/credentials.h" @@ -175,7 +175,7 @@ static bool kpasswd_make_pwchange_reply(struct kdc_server *kdc, static bool kpasswdd_change_password(struct kdc_server *kdc, TALLOC_CTX *mem_ctx, struct auth_session_info *session_info, - const char *password, + const DATA_BLOB *password, DATA_BLOB *reply) { NTSTATUS status; @@ -219,6 +219,8 @@ static bool kpasswd_process_request(struct kdc_server *kdc, DATA_BLOB *reply) { struct auth_session_info *session_info; + ssize_t pw_len; + if (!NT_STATUS_IS_OK(gensec_session_info(gensec_security, &session_info))) { return kpasswdd_make_error_reply(kdc, mem_ctx, @@ -230,12 +232,20 @@ static bool kpasswd_process_request(struct kdc_server *kdc, switch (version) { case KRB5_KPASSWD_VERS_CHANGEPW: { - char *password = talloc_strndup(mem_ctx, (const char *)input->data, input->length); - if (!password) { + DATA_BLOB password; + pw_len = convert_string_talloc(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), + CH_UTF8, CH_UTF16, + (const char *)input->data, + input->length, + (void **)&password.data); + + if (pw_len == -1) { return false; } + password.length = pw_len; + return kpasswdd_change_password(kdc, mem_ctx, session_info, - password, reply); + &password, reply); break; } case KRB5_KPASSWD_VERS_SETPW: @@ -248,7 +258,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc, krb5_context context = kdc->smb_krb5_context->krb5_context; ChangePasswdDataMS chpw; - char *password; + DATA_BLOB password; krb5_principal principal; char *set_password_on_princ; @@ -271,13 +281,18 @@ static bool kpasswd_process_request(struct kdc_server *kdc, reply); } - password = talloc_strndup(mem_ctx, - (const char *)chpw.newpasswd.data, - chpw.newpasswd.length); - if (!password) { + pw_len = convert_string_talloc(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx), + CH_UTF8, CH_UTF16, + (const char *)chpw.newpasswd.data, + chpw.newpasswd.length, + (void **)&password.data); + if (pw_len == -1) { free_ChangePasswdDataMS(&chpw); return false; } + + password.length = pw_len; + if ((chpw.targname && !chpw.targrealm) || (!chpw.targname && chpw.targrealm)) { return kpasswdd_make_error_reply(kdc, mem_ctx, @@ -306,7 +321,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc, } else { free_ChangePasswdDataMS(&chpw); return kpasswdd_change_password(kdc, mem_ctx, session_info, - password, reply); + &password, reply); } free_ChangePasswdDataMS(&chpw); @@ -371,7 +386,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc, /* Admin password set */ status = samdb_set_password(samdb, mem_ctx, set_password_on_dn, NULL, - msg, password, NULL, NULL, + msg, &password, NULL, NULL, false, /* this is not a user password change */ &reject_reason, &dominfo); } diff --git a/source4/ldap_server/config.mk b/source4/ldap_server/config.mk index 65f5b17f9a..4c35117a72 100644 --- a/source4/ldap_server/config.mk +++ b/source4/ldap_server/config.mk @@ -4,7 +4,7 @@ # Start SUBSYSTEM LDAP [MODULE::LDAP] INIT_FUNCTION = server_service_ldap_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = CREDENTIALS \ LIBCLI_LDAP SAMDB \ process_model \ diff --git a/source4/ldap_server/ldap_backend.c b/source4/ldap_server/ldap_backend.c index 504dcf1c0f..32fc00832e 100644 --- a/source4/ldap_server/ldap_backend.c +++ b/source4/ldap_server/ldap_backend.c @@ -19,7 +19,7 @@ #include "includes.h" #include "ldap_server/ldap_server.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/ldap/ldap.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" @@ -158,6 +158,8 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call) struct ldb_dn *basedn; struct ldb_result *res = NULL; struct ldb_request *lreq; + struct ldb_control *search_control; + struct ldb_search_options_control *search_options; enum ldb_scope scope = LDB_SCOPE_DEFAULT; const char **attrs = NULL; const char *scope_str, *errstr = NULL; @@ -216,21 +218,24 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call) DEBUG(5,("ldb_request %s dn=%s filter=%s\n", scope_str, req->basedn, ldb_filter_from_tree(call, req->tree))); - lreq = talloc(local_ctx, struct ldb_request); - NT_STATUS_HAVE_NO_MEMORY(lreq); + res = talloc_zero(local_ctx, struct ldb_result); + NT_STATUS_HAVE_NO_MEMORY(res); - lreq->operation = LDB_SEARCH; - lreq->op.search.base = basedn; - lreq->op.search.scope = scope; - lreq->op.search.tree = req->tree; - lreq->op.search.attrs = attrs; + ldb_ret = ldb_build_search_req_ex(&lreq, samdb, local_ctx, + basedn, scope, + req->tree, attrs, + call->request->controls, + res, ldb_search_default_callback, + NULL); - lreq->controls = call->request->controls; + if (ldb_ret != LDB_SUCCESS) { + goto reply; + } if (call->conn->global_catalog) { - struct ldb_control *search_control = ldb_request_get_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID); - - struct ldb_search_options_control *search_options = NULL; + search_control = ldb_request_get_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID); + + search_options = NULL; if (search_control) { search_options = talloc_get_type(search_control->data, struct ldb_search_options_control); search_options->search_options |= LDB_SEARCH_OPTION_PHANTOM_ROOT; @@ -241,14 +246,6 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call) ldb_request_add_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID, false, search_options); } } - - res = talloc_zero(lreq, struct ldb_result); - NT_STATUS_HAVE_NO_MEMORY(res); - - lreq->context = res; - lreq->callback = ldb_search_default_callback; - - /* Copy the timeout from the incoming call */ ldb_set_timeout(samdb, lreq, req->timelimit); ldb_ret = ldb_request(samdb, lreq); @@ -688,8 +685,8 @@ reply: NT_STATUS_HAVE_NO_MEMORY(compare_r); if (result == LDAP_SUCCESS) { - ldb_ret = ldb_search(samdb, dn, LDB_SCOPE_BASE, filter, attrs, &res); - talloc_steal(local_ctx, res); + ldb_ret = ldb_search(samdb, local_ctx, &res, + dn, LDB_SCOPE_BASE, attrs, "%s", filter); if (ldb_ret != LDB_SUCCESS) { result = map_ldb_error(samdb, ldb_ret, &errstr); DEBUG(10,("CompareRequest: error: %s\n", errstr)); diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c index f37ef31c0a..20777e5261 100644 --- a/source4/ldap_server/ldap_bind.c +++ b/source4/ldap_server/ldap_bind.c @@ -180,9 +180,6 @@ static NTSTATUS ldapsrv_BindSASL(struct ldapsrv_call *call) input = *req->creds.SASL.secblob; } - resp->SASL.secblob = talloc(reply, DATA_BLOB); - NT_STATUS_HAVE_NO_MEMORY(resp->SASL.secblob); - status = gensec_update(conn->gensec, reply, input, &output); @@ -211,6 +208,7 @@ static NTSTATUS ldapsrv_BindSASL(struct ldapsrv_call *call) } else { ctx->conn = conn; status = gensec_socket_init(conn->gensec, + conn->connection, conn->connection->socket, conn->connection->event.ctx, stream_io_handler_callback, diff --git a/source4/ldap_server/ldap_extended.c b/source4/ldap_server/ldap_extended.c index fe917cf7f2..334e427d79 100644 --- a/source4/ldap_server/ldap_extended.c +++ b/source4/ldap_server/ldap_extended.c @@ -19,7 +19,7 @@ #include "includes.h" #include "ldap_server/ldap_server.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/ldap/ldap.h" #include "lib/tls/tls.h" #include "smbd/service_stream.h" diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index 39a55f4420..f08f24595a 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -26,8 +26,8 @@ #include "auth/auth.h" #include "auth/credentials/credentials.h" #include "librpc/gen_ndr/ndr_samr.h" -#include "lib/util/dlinklist.h" -#include "lib/util/asn1.h" +#include "../lib/util/dlinklist.h" +#include "../lib/util/asn1.h" #include "ldap_server/ldap_server.h" #include "smbd/service_task.h" #include "smbd/service_stream.h" @@ -253,13 +253,11 @@ static int ldapsrv_load_limits(struct ldapsrv_connection *conn) goto failed; } - ret = ldb_search(conn->ldb, basedn, LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(conn->ldb, tmp_ctx, &res, basedn, LDB_SCOPE_BASE, attrs, NULL); if (ret != LDB_SUCCESS) { goto failed; } - talloc_steal(tmp_ctx, res); - if (res->count != 1) { goto failed; } @@ -275,13 +273,11 @@ static int ldapsrv_load_limits(struct ldapsrv_connection *conn) goto failed; } - ret = ldb_search(conn->ldb, policy_dn, LDB_SCOPE_BASE, NULL, attrs2, &res); + ret = ldb_search(conn->ldb, tmp_ctx, &res, policy_dn, LDB_SCOPE_BASE, attrs2, NULL); if (ret != LDB_SUCCESS) { goto failed; } - talloc_steal(tmp_ctx, res); - if (res->count != 1) { goto failed; } @@ -529,7 +525,7 @@ static void ldapsrv_task_init(struct task_server *task) task_server_set_title(task, "task[ldapsrv]"); /* run the ldap server as a single process */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(task->event_ctx, "single"); if (!model_ops) goto failed; ldap_service = talloc_zero(task, struct ldapsrv_service); diff --git a/source4/lib/appweb/README b/source4/lib/appweb/README deleted file mode 100644 index bdc943446b..0000000000 --- a/source4/lib/appweb/README +++ /dev/null @@ -1,6 +0,0 @@ -The lib/appweb directory is a partial import of the appweb ejs and esp -code from http://www.appwebserver.org/ - -Many thanks to the mbedthis people, and especially Michael O'Brien for -his assistance in getting this code integrated into Samba4. - diff --git a/source4/lib/appweb/config.m4 b/source4/lib/appweb/config.m4 deleted file mode 100644 index 69b4048c4a..0000000000 --- a/source4/lib/appweb/config.m4 +++ /dev/null @@ -1 +0,0 @@ -AC_CHECK_HEADERS(math.h) diff --git a/source4/lib/appweb/config.mk b/source4/lib/appweb/config.mk deleted file mode 100644 index 4d27b69fb5..0000000000 --- a/source4/lib/appweb/config.mk +++ /dev/null @@ -1,25 +0,0 @@ -####################### -# Start SUBSYSTEM MPR -[SUBSYSTEM::MPR] -# End SUBSYSTEM MPR -####################### - -MPR_OBJ_FILES = $(addprefix $(appwebsrcdir)/mpr/, miniMpr.o var.o) - -####################### -# Start SUBSYSTEM EJS -[SUBSYSTEM::EJS] -PUBLIC_DEPENDENCIES = MPR -# End SUBSYSTEM EJS -####################### - -EJS_OBJ_FILES = $(addprefix $(appwebsrcdir)/ejs/, ejsLib.o ejsLex.o ejsParser.o ejsProcs.o) - -####################### -# Start SUBSYSTEM ESP -[SUBSYSTEM::ESP] -PUBLIC_DEPENDENCIES = EJS -# End SUBSYSTEM ESP -####################### - -ESP_OBJ_FILES = $(addprefix $(appwebsrcdir)/esp/, esp.o espProcs.o) diff --git a/source4/lib/appweb/ejs-2.0/.bashrc b/source4/lib/appweb/ejs-2.0/.bashrc deleted file mode 100644 index c05ee0e6e8..0000000000 --- a/source4/lib/appweb/ejs-2.0/.bashrc +++ /dev/null @@ -1,153 +0,0 @@ -# -# .bashrc -- Login shell startup script for windows using Mbedthis winTools -# -# Copyright (c) Mbedthis Software, 2003-2005. All Rights Reserved. -# - -TERM=ansi -# -# Set the desired .NET Framework -# -# FRAMEWORK=v1.0.3705 -FRAMEWORK=v1.1.4322 -# FRAMEWORK=v2.0.40607 - -# -# Set the desired Microsoft C Compiler version -# -# PREFERRED_CC=VS2005 -# PREFERRED_CC=VS2003 -# PREFERRED_CC=VS.NET -PREFERRED_CC=VS6 - -# -# Set to 1 if VXWORKS support is required -# -# VXWORKS=1 - -HOME=`pwd` -if [ ! -x winTools -o ! -x winTools/cygpath.exe ] -then - echo "Can't find build tools. Install build tools in $HOME/winTools" -fi - -ROOT=`winTools/cygpath -u $HOMEDRIVE` -: ${ROOT:=C:/} -APPWEB_PATH="${HOME}/bin/DEBUG:${HOME}/bin/RELEASE:${HOME}/bin:${HOME}/winTools" -CDPATH=".:${HOME}:${HOME}/http:${HOME}/http/modules:${HOME}/packages" -PS1="$ " - -export CDPATH INCLUDE LIB LIBPATH PATH PS1 TERM - -echo -e "\n\n###################################################" -echo "Mbedthis AppWeb, Cygwin build tools." -echo "Using compiler: $PREFERRED_CC, .NET framework: $FRAMEWORK" -echo -e "###################################################" - -################################################################################ - -# -# Setup for Visual Studio and SDK -# -if [ $PREFERRED_CC == "VS2005" ] -then - # - # Visual Studio .NET 2005 defines. - # - CYNET="${ROOT}/Program Files/Microsoft Visual Studio 8" - DOSNET="C:/Program Files/Microsoft Visual Studio 8" - PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC/BIN:$CYNET/VC/VCPackages:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin:$CYNET/SDK/v2.0/bin:`cygpath -W`/Microsoft.NET/Framework/v2.0.40607:$CYNET/SDK/v2.0/bin:$PATH" - INCLUDE="$DOSNET/VC/ATLMFC/INCLUDE;$DOSNET/VC/INCLUDE;$DOSNET/VC/PlatformSDK/include;$DOSNET/SDK/v2.0/include;$INCLUDE" - LIB="$DOSNET/VC/ATLMFC/LIB;$DOSNET/VC/LIB;$DOSNET/VC/PlatformSDK/lib;$DOSNET/SDK/v2.0/lib;$LIB" - LIBPATH=c:/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK -fi - -if [ $PREFERRED_CC == "VS2003" ] -then - # - # Visual Studio .NET 2003 defines. - # - CYNET="${ROOT}/Program Files/Microsoft Visual Studio .NET 2003" - DOSNET="C:/Program Files/Microsoft Visual Studio .NET 2003" - PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:${ROOT}/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.1/bin:$PATH" - INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE" - LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB" -fi - - -if [ $PREFERRED_CC == "VS.NET" ] -then - # - # Visual Studio .NET defines. - # - CYNET="${ROOT}/Program Files/Microsoft Visual Studio .NET" - DOSNET="C:/Program Files/Microsoft Visual Studio .NET" - PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:${ROOT}/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.0/bin:$PATH" - INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE" - LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB" -fi - - -if [ $PREFERRED_CC == "VS6" ] -then - # Visual Studio 6 defines. - # - CYNET="${ROOT}/Program Files/Microsoft Visual Studio" - DOSNET="C:/Program Files/Microsoft Visual Studio" - PATH="$APPWEB_PATH:$CYNET/Common/MSDev98/bin:$CYNET/VC98/BIN:$CYNET/Common/IDE:$CYNET/Common/Tools/WinNT:$CYNET/Common/Tools:$PATH" - INCLUDE="$DOSNET/VC98/ATLMFC/INCLUDE;$DOSNET/VC98/INCLUDE;$DOSNET/VC98/MFC/INCLUDE;$INCLUDE" - LIB="$DOSNET/VC98/LIB;$DOSNET/VC98/MFC/LIB;$LIB" -fi - -if [ $VXWORKS ] -then - # - # Required by VxWorks - # - WIND_BASE=C:/tornado - WIND_HOST_TYPE=x86-win32 - WIND_REGISTRY=coalsack - WIND_LMHOST=coalsack - BLD_VX_HOST=i386-wrs-vxworks - VX_TOOLS=`cygpath $WIND_BASE`/host/$WIND_HOST_TYPE - export WIND_BASE WIND_HOST_TYPE WIND_REGISTRY WIND_LMHOST BLD_VX_HOST - - # - # Use cygwin make and tools by preference - # - PATH="$APPWEB_PATH:$VX_TOOLS/bin:$PATH" -fi - -# -# Make required directories for CYGWIN -# -if [ ! -x /bin/bash.exe ] -then - DIR=`cygpath -w "$HOME/winTools"` - echo -e "\nCreating /bin" - echo Mounting \"${DIR}\" as /bin - mount -f -b "$DIR" /bin -fi - -if [ ! -x /tmp ] -then - mkdir -p tmp - DIR=`cygpath -w "$HOME/tmp"` - echo -e "\nCreating /tmp" - echo Mounting \"${DIR}\" as /tmp - mount -f -b "$DIR" /tmp -fi -echo - -################################################################################ -# -# Do a bit of validation -# -type cl 2>/dev/null >/dev/null -if [ $? -ne 0 ] -then - echo "Can't find compiler: cl. Check WIN/bashrc settings for PATH" -fi -set -o vi - -################################################################################ diff --git a/source4/lib/appweb/ejs-2.0/.exrc b/source4/lib/appweb/ejs-2.0/.exrc deleted file mode 100644 index dd37846529..0000000000 --- a/source4/lib/appweb/ejs-2.0/.exrc +++ /dev/null @@ -1 +0,0 @@ -set ts=4 sw=4 diff --git a/source4/lib/appweb/ejs-2.0/.ignore b/source4/lib/appweb/ejs-2.0/.ignore deleted file mode 100644 index 866f06c6c1..0000000000 --- a/source4/lib/appweb/ejs-2.0/.ignore +++ /dev/null @@ -1,57 +0,0 @@ -*.class -*.dll -*.exe -*.exp -*.jar -*.lib -*.lnk -*.map -*.new -*.old -*.pdb -*.res -*.sln -*.suo -*.sym -*.tmp -*.sav -.ICEauthority -.bash_history -.changes -.cvsignore -.esd_auth -.fonts.cache-1 -.viminfo -make.dep -thumbs.db -vc70.pdb -*.ncb -*.opt -*.idb -*.pch -*.dep -*.aps -all -tmp -make.vars -sh.vars -config.make -config.h -config.sh -configure -make.os -.firstBuild -.viminfo -.ssh -_viminfo -buildConfig.h -buildConfig.make -buildConfig.sh -.ccache -appWeb.kdev* -subversion -.vimrc -.subversion -.ignore -njs -msvc diff --git a/source4/lib/appweb/ejs-2.0/.loginrc b/source4/lib/appweb/ejs-2.0/.loginrc deleted file mode 100644 index 90b76a2ad0..0000000000 --- a/source4/lib/appweb/ejs-2.0/.loginrc +++ /dev/null @@ -1,218 +0,0 @@ -# -# .loginrc -- Michael's login shell startup script (used only for Windows) -# -# NOTE: this should not be distributed with releases. -# -# Copyright (c) Mbedthis Software, 2003-2005. All Rights Reserved. -# -HOME=`pwd` - -TERM=ansi -CYROOT=/cygdrive/c -JDK="/cygdrive/c/program files/java/jdk1.5.0_07/bin" -H=$CYROOT -R=usr/svn/appWeb/main -CDPATH=".:${H}/usr/svn/appWeb:${H}/${R}/http:${H}/${R}/http/modules:${H}/${R}:${H}/usr/svn/appWeb/releases:${H}/usr/svn/packages:${H}/usr/svn/bling/player/trunk:${H}/usr/svn/bling/player/trunk/src:${H}/usr/svn/bling/player/trunk/appdir:${H}/usr/svn:${H}:${H}/usr/svn:${H}/usr" -APPWEB_PATH="${H}/${R}/bin/DEBUG:${H}/${R}/bin/RELEASE:${H}/${R}/bin:${H}/usr/bin" -PATH="${H}/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$PATH:${H}/tcl/bin:${JDK}" - -CLASSPATH="c:/usr/svn/j/ggperf" -PS1='`cygpath -m $PWD`> ' -SVN_EDITOR=C:/cygwin/bin/vim.exe - -umask 022 - -export TERM CDPATH INCLUDE LIB LIBPATH PATH PS1 SVN_EDITOR MSCL CLASSPATH - -################################################################################ -# -# Set the dev environment PATH and other critical environment variables -# - -# export BLD_ALTERNATE_CONFIG=WIN/buildConfig - -# -# Desired .NET Framework -# -# FRAMEWORK=v1.0.3705 -# FRAMEWORK=v1.1.4322 -FRAMEWORK=v2.0.50727 - -# -# Desired C Compiler -# -# MSCL=VS2005 -# MSCL=VS2003 -# MSCL=VS.NET -MSCL=VS6 -VXWORKS=1 - -echo "Using compiler: $MSCL, .NET framework: $FRAMEWORK" - -# -# Setup for Visual Studio and SDK -# -if [ $MSCL == "VS2005" ] -then - # - # Visual Studio .NET 2005 defines. - # - CYNET="$H/Program Files/Microsoft Visual Studio 8" - DOSNET="C:/Program Files/Microsoft Visual Studio 8" - PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC/BIN:$CYNET/VC/VCPackages:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin:$CYNET/SDK/v2.0/bin:$CYROOT/WINDOWS/Microsoft.NET/Framework/v2.0.40607:$CYNET/SDK/v2.0/bin:$PATH" - INCLUDE="$DOSNET/VC/ATLMFC/INCLUDE;$DOSNET/VC/INCLUDE;$DOSNET/VC/PlatformSDK/include;$DOSNET/SDK/v2.0/include;$INCLUDE" - LIB="$DOSNET/VC/ATLMFC/LIB;$DOSNET/VC/LIB;$DOSNET/VC/PlatformSDK/lib;$DOSNET/SDK/v2.0/lib;$LIB" - LIBPATH=c:/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK - - # MOB -- old - # PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$PATH" - # INCLUDE="$DOSNET/VC/ATLMFC/INCLUDE;$DOSNET/VC/INCLUDE;$DOSNET/VC/PlatformSDK/include/prerelease;$DOSNET/VC/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE" - # LIB="$DOSNET/VC/ATLMFC/LIB;$DOSNET/VC/LIB;$DOSNET/VC/PlatformSDK/lib/prerelease;$DOSNET/VC/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB" -fi - -if [ $MSCL == "VS2003" ] -then - # - # Visual Studio .NET 2003 defines. - # - CYNET="$H/Program Files/Microsoft Visual Studio .NET 2003" - DOSNET="C:/Program Files/Microsoft Visual Studio .NET 2003" - PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.1/bin:$PATH" - INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE" - LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB" -fi - - -if [ $MSCL == "VS.NET" ] -then - # - # Visual Studio .NET defines. - # - CYNET="$H/Program Files/Microsoft Visual Studio .NET" - DOSNET="C:/Program Files/Microsoft Visual Studio .NET" - PATH="$APPWEB_PATH:$CYNET/Common7/IDE:$CYNET/VC7/BIN:$CYNET/Common7/Tools:$CYNET/Common7/Tools/bin/prerelease:$CYNET/Common7/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$CYNET/SDK/v1.0/bin:$PATH" - INCLUDE="$DOSNET/VC7/ATLMFC/INCLUDE;$DOSNET/VC7/INCLUDE;$DOSNET/VC7/PlatformSDK/include/prerelease;$DOSNET/VC7/PlatformSDK/include;$DOSNET/FrameworkSDK/include;$INCLUDE" - LIB="$DOSNET/VC7/ATLMFC/LIB;$DOSNET/VC7/LIB;$DOSNET/VC7/PlatformSDK/lib/prerelease;$DOSNET/VC7/PlatformSDK/lib;$DOSNET/FrameworkSDK/lib;$LIB" -fi - - -if [ $MSCL == "VS6" ] -then - # Visual Studio 6 defines. - # - CYNET="$H/Program Files/Microsoft Visual Studio" - DOSNET="C:/Program Files/Microsoft Visual Studio" - PATH="$APPWEB_PATH:$CYNET/Common/MSDev98/bin:$CYNET/VC98/BIN:$CYNET/Common/IDE:$CYNET/Common/Tools/WinNT:$CYNET/Common/Tools:$PATH" - # OLD PATH="$APPWEB_PATH:$CYNET/Common/IDE:$CYNET/VC98/BIN:$CYNET/Common/MSDev98/bin:$CYNET/Common/Tools:$CYNET/Common/Tools/bin/prerelease:$CYNET/Common/Tools/bin:$CYNET/FrameworkSDK/bin:$H/WINDOWS/Microsoft.NET/Framework/$FRAMEWORK:$PATH" - INCLUDE="$DOSNET/VC98/ATLMFC/INCLUDE;$DOSNET/VC98/INCLUDE;$DOSNET/VC98/MFC/INCLUDE;$INCLUDE" - LIB="$DOSNET/VC98/LIB;$DOSNET/VC98/MFC/LIB;$LIB" -fi - -if [ $VXWORKS ] -then - # - # Required by VxWorks - # - WIND_BASE=C:/tornado - WIND_HOST_TYPE=x86-win32 - WIND_REGISTRY=coalsack - WIND_LMHOST=coalsack - BLD_VX_HOST=i386-wrs-vxworks - export WIND_BASE WIND_HOST_TYPE WIND_REGISTRY WIND_LMHOST BLD_VX_HOST - - VX_TOOLS=`cygpath $WIND_BASE`/host/$WIND_HOST_TYPE - # - # Use cygwin make and tools by preference - # - PATH="$APPWEB_PATH:$PATH:$VX_TOOLS/bin" -fi - -# -# Make required directories for CYGWIN -# -if [ ! -x /bin/bash.exe ] -then - DIR=`cygpath -w "$HOME/winTools"` - echo -e "\nCreating /bin" - echo Mounting \"${DIR}\" as /bin - mount -f -b "$DIR" /bin -fi - -if [ ! -x /tmp ] -then - mkdir -p tmp - DIR=`cygpath -w "$HOME/tmp"` - echo -e "\nCreating /tmp" - echo Mounting \"${DIR}\" as /tmp - mount -f -b "$DIR" /tmp -fi -echo - - -################################################################################ -# -# Do a bit of validation (MOB -- extend) -# -type cl 2>/dev/null >/dev/null -if [ $? -ne 0 ] -then - echo "Can't find compiler: cl. Check WIN/bashrc settings for PATH" -fi - -################################################################################ -# -# Some convenient functions -# -pvi () { - - pattern=$1 - shift - files=$* - if [ -z "${files}" ] - then - files='*.c *.cpp *.h Makefile *.html *.aspx *.cs' - fi - vi -c "/${pattern}" $(grep -l "${pattern}" ${files}) -} - -################################################################################ - -g() { - pattern=$1 - shift - files=$* - if [ -z "${files}" ] - then - files=`echo *.c *.cpp *.h Makefile *.html *.aspx *.cs` - fi - eval grep "${pattern}" ${files} -} - -################################################################################ - -usedvi() { - pvi $1 $HOME/mr/*.c $HOME/mr/*.h $HOME/mr/WIN/*.c $HOME/lib/*/*.c -} - -################################################################################ - -alias ls='ls -CF $*' -alias lc='ls -CF $*' -alias lr='ls -R $*' -alias xwin='startxwin.sh' -alias htmlview='"C:/Program Files/Internet Explorer/iexplore.exe" $*' -set -o vi - -if [ `uname -o` = "Cygwin" ] -then - alias vim='"C:/Program Files/vim/vim64/vim.exe" $*' - alias gvim='"C:/Program Files/vim/vim64/gvim.exe" $*' -fi - -brew() { - "C:/Program Files/BREW SDK v2.1.3/Bin/BREW_Emulator.exe" -} - -js() { - cscript /nologo $* -} diff --git a/source4/lib/appweb/ejs-2.0/ejs/.ignore b/source4/lib/appweb/ejs-2.0/ejs/.ignore deleted file mode 100644 index 47f4ac63b2..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/.ignore +++ /dev/null @@ -1,2 +0,0 @@ -ejs -future diff --git a/source4/lib/appweb/ejs-2.0/ejs/Makefile b/source4/lib/appweb/ejs-2.0/ejs/Makefile deleted file mode 100644 index ea6be8c401..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -# -# Makefile for Embedded Javascript (EJS) -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -# -# Ejs may be linked into shared handlers so we must build the objects both -# shared and static if --shared was specified to configure. -# -COMPILE := *.c -EXPORT_OBJECTS := yes -PRE_DIRS := classes system db -MAKE_IFLAGS := -I../mpr -I../exml - -include make.dep - -ifeq ($(BLD_PRODUCT),ejs) -POST_DIRS := package -endif - -ifeq ($(BLD_FEATURE_TEST),1) -POST_DIRS += test -endif - -ifeq ($(BLD_FEATURE_EJS_DB),1) -LIBS += sqlite -endif - -TARGETS += $(BLD_BIN_DIR)/libejs$(BLD_LIB) -TARGETS += $(BLD_BIN_DIR)/ejs$(BLD_EXE) - -ifeq ($(BLD_FEATURE_EJS),1) -compileExtra: $(TARGETS) -endif - -$(BLD_BIN_DIR)/libejs$(BLD_LIB): files \ - $(shell BLD_OBJ=$(BLD_OBJ) \; BLD_OBJ_DIR=$(BLD_OBJ_DIR) \; \ - eval echo `cat files`) - @bld --library $(BLD_BIN_DIR)/libejs \ - --objectsDir $(BLD_OBJ_DIR) --objectList files \ - --libs "exml mpr $(LIBS)" - -$(BLD_BIN_DIR)/ejs$(BLD_EXE): $(BLD_BIN_DIR)/libejs$(BLD_LIB) \ - $(BLD_BIN_DIR)/libmpr$(BLD_LIB) \ - $(BLD_BIN_DIR)/libejs$(BLD_LIB) $(FILES) - @bld --executable $(BLD_BIN_DIR)/ejs$(BLD_EXE) \ - --rpath "$(BLD_PREFIX)/bin" \ - --preferStatic --smartLibs "ejs exml mpr $(LIBS)" \ - --objectsDir $(BLD_OBJ_DIR) \ - --objects "$(BLD_OBJ_DIR)/ejsCmd$(BLD_OBJ)" - -cleanExtra: - @echo "rm -f $(TARGETS)" | $(BLDOUT) - @rm -f $(TARGETS) - @rm -f $(BLD_BIN_DIR)/libejs.* - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/.ignore b/source4/lib/appweb/ejs-2.0/ejs/classes/.ignore deleted file mode 100644 index fb5a29031e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/.ignore +++ /dev/null @@ -1 +0,0 @@ -.updated diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/Makefile b/source4/lib/appweb/ejs-2.0/ejs/classes/Makefile deleted file mode 100644 index ce12bb3829..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# -# Makefile to build the EJS Classes -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I.. -I../../mpr -I../../exml - -include make.dep - -compileExtra: .updated - -.updated: $(FILES) - @touch .updated - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c deleted file mode 100644 index feb64b1aa8..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsArray.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * @file ejsArray.c - * @brief Array class - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/************************************ Code ************************************/ - -int ejsDefineArrayClass(Ejs *ep) -{ - if (ejsDefineClass(ep, "Array", "Object", ejsArrayConstructor) == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - return 0; -} - -/******************************************************************************/ -/* - * Routine to create the base array type - */ - -EjsVar *ejsCreateArrayInternal(EJS_LOC_DEC(ep, loc), int size) -{ - EjsProperty *pp; - EjsVar *obj, *vp; - - /* MOB -- need to supply hash size -- max(size, 503)); */ - - obj = ejsCreateSimpleObjInternal(EJS_LOC_PASS(ep, loc), "Array"); - if (obj == 0) { - mprAssert(0); - return obj; - } - obj->isArray = 1; - - /* MOB -- call constructor here and replace this code */ - - pp = ejsSetPropertyToInteger(ep, obj, "length", size); - ejsMakePropertyEnumerable(pp, 0); - - vp = ejsGetVarPtr(pp); - vp->isArrayLength = 1; - - return obj; -} - -/******************************************************************************/ - -EjsVar *ejsAddArrayElt(Ejs *ep, EjsVar *op, EjsVar *element, - EjsCopyDepth copyDepth) -{ - EjsProperty *pp; - EjsVar *vp; - char idx[16]; - int length; - - mprAssert(op->isArray); - - length = ejsGetPropertyAsInteger(ep, op, "length"); - - mprItoa(idx, sizeof(idx), length); - pp = ejsCreateProperty(ep, op, idx); - vp = ejsGetVarPtr(pp); - - ejsWriteVar(ep, vp, element, copyDepth); - - ejsSetPropertyToInteger(ep, op, "length", length + 1); - - return vp; -} - -/******************************************************************************/ -/* - * Constructor - */ - -int ejsArrayConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsProperty *pp; - EjsVar *vp; - char idx[16]; - int i, max; - - thisObj->isArray = 1; - max = 0; - - if (argc > 0) { - if (argc == 1 && ejsVarIsNumber(argv[0])) { - /* - * x = new Array(size); - */ - max = (int) ejsVarToInteger(argv[0]); - - } else { - /* - * x = new Array(element0, element1, ..., elementN): - */ - max = argc; - for (i = 0; i < max; i++) { - mprItoa(idx, sizeof(idx), i); - pp = ejsCreateSimpleProperty(ep, thisObj, idx); - vp = ejsGetVarPtr(pp); - ejsWriteVar(ep, vp, argv[i], EJS_SHALLOW_COPY); - } - } - } - - pp = ejsCreateSimpleProperty(ep, thisObj, "length"); - ejsMakePropertyEnumerable(pp, 0); - vp = ejsGetVarPtr(pp); - ejsWriteVarAsInteger(ep, vp, max); - vp->isArrayLength = 1; - - return 0; -} - -/******************************************************************************/ - -#else -void ejsArrayDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c deleted file mode 100755 index 096316a822..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsDate.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * @file ejsStndClasses.c - * @brief EJS support methods - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS && 0 - -/******************************************************************************/ -/* - * Date constructor - - * - * Date(); - * Date(milliseconds); - * Date(dateString); - * Date(year, month, date); - * Date(year, month, date, hour, minute, second); - */ - -int ejsDateConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - return 0; -} - -/******************************************************************************/ - -static int load(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const char *fileName; - XmlState *parser; - Exml *xp; - MprFile *file; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ep, EJS_ARG_ERROR, "Bad args. Usage: load(fileName);"); - return -1; - } - fileName = argv[0]->string; - - /* FUTURE -- not romable - Need rom code in MPR not MprServices - */ - file = mprOpen(ep, fileName, O_RDONLY, 0664); - if (file == 0) { - ejsError(ep, EJS_IO_ERROR, "Can't open: %s", fileName); - return -1; - } - - xp = initParser(ep, thisObj, fileName); - parser = exmlGetParseArg(xp); - - exmlSetInputStream(xp, readFileData, (void*) file); - - if (exmlParse(xp) < 0) { - if (! ejsGotException(ep)) { - ejsError(ep, EJS_IO_ERROR, "Can't parse XML file: %s\nDetails %s", - fileName, exmlGetErrorMsg(xp)); - } - termParser(xp); - mprClose(file); - return -1; - } - - ejsSetReturnValue(ep, parser->nodeStack[0].obj); - - termParser(xp); - mprClose(file); - - return 0; -} - -/******************************************************************************/ - -int ejsDefineDateClass(Ejs *ep) -{ - EjsVar *dateClass; - - dateClass = ejsDefineClass(ep, "Date", "Object", ejsDateConstructor); - if (dateClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - ejsDefineCMethod(ep, dateClass, "getDate", xxxProc, EJS_NO_LOCAL); - - /* Returns "Friday" or 4 ? */ - ejsDefineCMethod(ep, dateClass, "getDay", xxxProc, EJS_NO_LOCAL); - - ejsDefineCMethod(ep, dateClass, "getMonth", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getFullYear", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getYear", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getHours", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getMinutes", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getSeconds", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getMilliseconds", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getTime", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "getTimeZoneOffset", xxxProc, EJS_NO_LOCAL); - - ejsDefineCMethod(ep, dateClass, "parse", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setDate", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setMonth", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setFullYear", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setYear", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setMinutes", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setSeconds", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setMilliseconds", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "setTime", xxxProc, EJS_NO_LOCAL); - - ejsDefineCMethod(ep, dateClass, "toString", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "toGMTString", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "toUTCString", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "toLocaleString", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "UTC", xxxProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, dateClass, "valueOf", xxxProc, EJS_NO_LOCAL); - /* - UTC: getUTCDate, getUTCDay, getUTCMonth, getUTCFullYear, getUTCHours, - getUTCMinutes, getUTCSeconds, getUTCMilliseconds - setUTCDate, setUTCDay, setUTCMonth, setUTCFullYear, setUTCHours, - setUTCMinutes, setUTCSeconds, setUTCMilliseconds - */ - - return ejsObjHasErrors(dateClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ -/* - Time is since 1970/01/01 GMT - - Normal: Fri Feb 10 2006 05:06:44 GMT-0800 (Pacific Standard Time) - UTC: Sat, 11 Feb 2006 05:06:44 GMT - - // Using without New - - println(Date()); - - var myDate = new Date(); - myDate.setFullYear(2010, 0, 14); - - var today = new Date(); - - if (myDate > today) { - } else { - } - - - X=Date() should be equivalent to X=(new Date()).toString() - - */ -/******************************************************************************/ - -#else -void ejsStndClassesDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c deleted file mode 100755 index 99445afc7c..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsError.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * @file ejsError.c - * @brief Error class - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/************************************ Code ************************************/ -/* - * Parse the args and return the message. Convert non-string args using - * .toString. - */ - -static char *getMessage(Ejs *ep, int argc, EjsVar **argv) -{ - if (argc == 0) { - return ""; - - } else if (argc == 1) { - if (! ejsVarIsString(argv[0])) { - if (ejsRunMethod(ep, argv[0], "toString", 0) < 0) { - return 0; - } - return ep->result->string; - - } else { - return argv[0]->string; - } - - } else { - /* Don't call ejsError here or it will go recursive. */ - return 0; - } -} - - -/******************************************************************************/ -/* - * Error Constructor and also used for constructor for sub classes. - * - * Usage: new Error([message]) - */ - -int ejsErrorCons(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *msg, *stack; - - msg = getMessage(ep, argc, argv); - if (msg == 0) { - return -1; - } - - ejsSetPropertyToString(ep, thisObj, "name", ejsGetBaseClassName(thisObj)); - ejsSetPropertyToString(ep, thisObj, "message", msg); - - ejsSetPropertyToUndefined(ep, thisObj, "stack"); - - stack = ejsFormatStack(ep); - if (stack) { - ejsSetPropertyToString(ep, thisObj, "stack", stack); - mprFree(stack); - } - - if (ejsObjHasErrors(thisObj)) { - return -1; - } - - return 0; -} - -/******************************************************************************/ - -int ejsDefineErrorClasses(Ejs *ep) -{ - if (ejsDefineClass(ep, "Error", "Object", ejsErrorCons) == 0 || - ejsDefineClass(ep, "AssertError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "EvalError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "InternalError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "IOError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "MemoryError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "RangeError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "ReferenceError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "SyntaxError", "Error", ejsErrorCons) == 0 || - ejsDefineClass(ep, "TypeError", "Error", ejsErrorCons) == 0) { - - return MPR_ERR_CANT_INITIALIZE; - } - return 0; -} - -/******************************************************************************/ - -#else -void ejsErrorDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c deleted file mode 100644 index 4f2e23beb2..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsObject.c +++ /dev/null @@ -1,588 +0,0 @@ -/* - * @file ejsObject.c - * @brief Object class - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ -/* - * Support routines - */ - -static void formatVar(Ejs *ep, MprBuf *bp, EjsVar *vp); - -/******************************************************************************/ -/* - * Routine to create an object of the desired class. Class name may - * contain "." - * - * The created object will be a stand-alone class NOT entered into the - * properties of any other object. Callers must do this if required. ClassName - * may contain "." and is interpreted relative to "obj" if supplied. - * - * Note: this does not call the constructors for the various objects and base - * classes. - */ - -EjsVar *ejsCreateSimpleObjInternal(EJS_LOC_DEC(ep, loc), const char *className) -{ - EjsVar *baseClass; - - if (className && *className) { - baseClass = ejsGetClass(ep, 0, className); - if (baseClass == 0) { - mprError(ep, MPR_LOC, "Can't find base class %s", className); - return 0; - } - } else { - baseClass = 0; - } - - return ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc), - baseClass); -} - -/******************************************************************************/ -/* - * Create an object based upon the specified base class object. It will be a - * stand-alone class not entered into the properties of any other object. - * Callers must do this if required. - * - * Note: this does not call the constructors for the various objects and base - * classes. - */ - -EjsVar *ejsCreateSimpleObjUsingClassInt(EJS_LOC_DEC(ep, loc), - EjsVar *baseClass) -{ - EjsVar *vp; - - mprAssert(baseClass); - - if (baseClass == 0) { - mprError(ep, MPR_LOC, "Missing base class\n"); - return 0; - } - - vp = ejsCreateObjVarInternal(EJS_LOC_PASS(ep, loc)); - if (vp == 0) { - return vp; - } - - ejsSetBaseClass(vp, baseClass); - - /* - * This makes all internal method accesses faster - * NOTE: this code is duplicated in ejsCreateSimpleClass - */ - mprAssert(vp->objectState); - vp->objectState->methods = baseClass->objectState->methods; - - return vp; -} - -/******************************************************************************/ - -void ejsSetMethods(Ejs *ep, EjsVar *op) -{ - op->objectState->methods = ep->global->objectState->methods; -} - -/******************************************************************************/ -/******************************** Internal Methods ****************************/ -/******************************************************************************/ - -static EjsVar *createObjProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsGetVarPtr(ejsCreateSimpleProperty(ep, obj, property)); -} - -/******************************************************************************/ - -static int deleteObjProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsDeleteProperty(ep, obj, property); -} - -/******************************************************************************/ - -static EjsVar *getObjProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsGetVarPtr(ejsGetSimpleProperty(ep, obj, property)); -} - -/******************************************************************************/ -/* - * Set the value of a property. Create if it does not exist - */ - -static EjsVar *setObjProperty(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value) -{ - EjsProperty *pp; - EjsVar *vp; - - pp = ejsCreateSimpleProperty(ep, obj, property); - if (pp == 0) { - mprAssert(pp); - return 0; - } - vp = ejsGetVarPtr(pp); - if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) < 0) { - mprAssert(0); - return 0; - } - return ejsGetVarPtr(pp); -} - -/******************************************************************************/ -/*********************************** Constructors *****************************/ -/******************************************************************************/ -#if UNUSED -/* - * Object constructor. We don't use this for speed. Think very carefully if - * you add an object constructor. - */ - -int ejsObjectConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - return 0; -} - -#endif -/******************************************************************************/ -/******************************** Visible Methods *****************************/ -/******************************************************************************/ - -static int cloneMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int copyDepth; - - copyDepth = EJS_DEEP_COPY; - - if (argc == 1 && ejsVarToBoolean(argv[0])) { - copyDepth = EJS_RECURSIVE_DEEP_COPY; - } - - ejsWriteVar(ep, ep->result, thisObj, copyDepth); - - return 0; -} - -/******************************************************************************/ - -static int toStringMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprBuf *bp; - int saveMaxDepth, saveDepth, saveFlags; - - saveMaxDepth = ep->maxDepth; - - if (argc >= 1) { - ep->maxDepth = ejsVarToInteger(argv[0]); - } else if (ep->maxDepth == 0) { - ep->maxDepth = MAXINT; - } - - saveFlags = ep->flags; - if (argc >= 2) { - if (ejsVarToBoolean(argv[1])) { - ep->flags |= EJS_FLAGS_ENUM_HIDDEN; - } - } - if (argc == 3) { - if (ejsVarToBoolean(argv[2])) { - ep->flags |= EJS_FLAGS_ENUM_BASE; - } - } - - bp = mprCreateBuf(ep, 0, 0); - - saveDepth = ep->depth; - - formatVar(ep, bp, thisObj); - - ep->depth = saveDepth; - ep->maxDepth = saveMaxDepth; - - mprAddNullToBuf(bp); - - ejsWriteVarAsString(ep, ep->result, mprGetBufStart(bp)); - mprFree(bp); - - ep->flags = saveFlags; - - return 0; -} - -/******************************************************************************/ - -static int valueOfMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 0) { - mprAssert(0); - return -1; - } - - switch (thisObj->type) { - default: - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_OBJECT: - case EJS_TYPE_METHOD: - case EJS_TYPE_STRING_CMETHOD: - ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY); - break; - - case EJS_TYPE_STRING: - ejsWriteVarAsInteger(ep, ep->result, atoi(thisObj->string)); - break; - - case EJS_TYPE_BOOL: - case EJS_TYPE_INT: -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: -#endif -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: -#endif - ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY); - break; - } - return 0; -} - -/******************************************************************************/ - -static int hashGetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ejs, (int) thisObj->objectState); - return 0; -} - -/******************************************************************************/ - -static int classGetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (thisObj->objectState == 0 || thisObj->objectState->baseClass == 0) { - ejsSetReturnValueToString(ejs, "object"); - } else { - ejsSetReturnValueToString(ejs, - thisObj->objectState->baseClass->objectState->className); - } - return 0; -} - -/******************************************************************************/ -/* - * Format an object. Called recursively to format properties and contained - * objects. - */ - -static void formatVar(Ejs *ep, MprBuf *bp, EjsVar *vp) -{ - EjsProperty *pp, *first; - EjsVar *propVar, *baseClass; - char *buf, *value; - int i; - - if (vp->type == EJS_TYPE_OBJECT) { - if (!vp->objectState->visited) { - - mprPutStringToBuf(bp, vp->isArray ? "[\n" : "{\n"); - - ep->depth++; - vp->objectState->visited = 1; - - if (ep->depth <= ep->maxDepth) { - first = ejsGetFirstProperty(vp, EJS_ENUM_ALL); - - if (ep->flags & EJS_FLAGS_ENUM_BASE) { - baseClass = vp->objectState->baseClass; - if (baseClass) { - for (i = 0; i < ep->depth; i++) { - mprPutStringToBuf(bp, " "); - } - mprPutStringToBuf(bp, baseClass->objectState->objName); - mprPutStringToBuf(bp, ": /* Base Class */ "); - if (baseClass->objectState == vp->objectState) { - value = "this"; - } else if (ejsRunMethodCmd(ep, baseClass, "toString", - "%d", ep->maxDepth) < 0) { - value = "[object Object]"; - } else { - mprAssert(ejsVarIsString(ep->result)); - value = ep->result->string; - } - mprPutStringToBuf(bp, value); - if (first) { - mprPutStringToBuf(bp, ",\n"); - } - } - } - - pp = first; - while (pp) { - if (! pp->dontEnumerate || - ep->flags & EJS_FLAGS_ENUM_HIDDEN) { - for (i = 0; i < ep->depth; i++) { - mprPutStringToBuf(bp, " "); - } - - if (! vp->isArray) { - mprPutStringToBuf(bp, pp->name); - mprPutStringToBuf(bp, ": "); - } - - propVar = ejsGetVarPtr(pp); - if (propVar->type == EJS_TYPE_OBJECT) { - if (pp->var.objectState == vp->objectState) { - value = "this"; - } else if (ejsRunMethodCmd(ep, propVar, - "toString", "%d", ep->maxDepth) < 0) { - value = "[object Object]"; - } else { - mprAssert(ejsVarIsString(ep->result)); - value = ep->result->string; - } - mprPutStringToBuf(bp, value); - - } else { - formatVar(ep, bp, &pp->var); - } - - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - if (pp) { - mprPutStringToBuf(bp, ",\n"); - } - } else { - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - } - } - vp->objectState->visited = 0; - - mprPutCharToBuf(bp, '\n'); - - ep->depth--; - for (i = 0; i < ep->depth; i++) { - mprPutStringToBuf(bp, " "); - } - mprPutCharToBuf(bp, vp->isArray ? ']' : '}'); - } - - } else if (vp->type == EJS_TYPE_METHOD) { - - mprPutStringToBuf(bp, "function ("); - for (i = 0; i < vp->method.args->length; i++) { - mprPutStringToBuf(bp, vp->method.args->items[i]); - if ((i + 1) < vp->method.args->length) { - mprPutStringToBuf(bp, ", "); - } - } - mprPutStringToBuf(bp, ") {"); - mprPutStringToBuf(bp, vp->method.body); - for (i = 0; i < ep->depth; i++) { - mprPutStringToBuf(bp, " "); - } - mprPutStringToBuf(bp, "}"); - - } else { - - if (vp->type == EJS_TYPE_STRING) { - mprPutCharToBuf(bp, '\"'); - } - - /* - * We don't use ejsVarToString for arrays, objects and strings. - * This is because ejsVarToString does not call "obj.toString" - * and it is not required for strings. - * MOB - rc - */ - buf = ejsVarToString(ep, vp); - mprPutStringToBuf(bp, buf); - - if (vp->type == EJS_TYPE_STRING) { - mprPutCharToBuf(bp, '\"'); - } - } -} - -/******************************************************************************/ -/* - * mixin code. Blends code at the "thisObj" level. - */ - -static int mixinMethod(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsProperty *pp; - char *buf; - int fid, i, rc; - - mprAssert(argv); - - /* - * Create a variable scope block set to the current object - */ - rc = 0; - fid = ejsSetBlock(ep, thisObj); - - for (i = 0; i < argc; i++) { - - if (ejsVarIsString(argv[i])) { - rc = ejsEvalScript(ep, argv[i]->string, 0); - - } else if (ejsVarIsObject(argv[i])) { - - /* MOB -- OPT. When we have proper scope chains, we should just - refer to the module and not copy */ - pp = ejsGetFirstProperty(argv[i], EJS_ENUM_ALL); - while (pp) { - ejsSetProperty(ep, thisObj, pp->name, ejsGetVarPtr(pp)); - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - - } else { - /* MOB - rc */ - buf = ejsVarToString(ep, argv[i]); - rc = ejsEvalScript(ep, buf, 0); - - } - if (rc < 0) { - ejsCloseBlock(ep, fid); - return -1; - } - } - ejsCloseBlock(ep, fid); - return 0; -} - -/******************************************************************************/ -/* - * Create the object class - */ - -int ejsDefineObjectClass(Ejs *ep) -{ - EjsMethods *methods; - EjsProperty *objectProp, *protoProp; - EjsVar *op, *globalClass; - - /* - * Must specially hand-craft the object class as it is the base class - * of all objects. - */ - op = ejsCreateObjVar(ep); - if (op == 0) { - return MPR_ERR_CANT_CREATE; - } - ejsSetClassName(ep, op, "Object"); - - /* - * Don't use a constructor for objects for speed - */ - ejsMakeClassNoConstructor(op); - - /* - * MOB -- should mark properties as public / private and class or instance. - */ - ejsDefineCMethod(ep, op, "clone", cloneMethod, EJS_NO_LOCAL); - ejsDefineCMethod(ep, op, "toString", toStringMethod, EJS_NO_LOCAL); - ejsDefineCMethod(ep, op, "valueOf", valueOfMethod, EJS_NO_LOCAL); - ejsDefineCMethod(ep, op, "mixin", mixinMethod, EJS_NO_LOCAL); - - ejsDefineCAccessors(ep, op, "hash", hashGetAccessor, 0, EJS_NO_LOCAL); - ejsDefineCAccessors(ep, op, "baseClass", classGetAccessor, 0, EJS_NO_LOCAL); - - /* - * MOB -- make this an accessor - */ - protoProp = ejsSetProperty(ep, op, "prototype", op); - if (protoProp == 0) { - ejsFreeVar(ep, op); - return MPR_ERR_CANT_CREATE; - } - - /* - * Setup the internal methods. Most classes will never override these. - * The XML class will. We rely on talloc to free internal. Use "ep" as - * the parent as we need "methods" to live while the interpreter lives. - */ - methods = mprAllocTypeZeroed(ep, EjsMethods); - op->objectState->methods = methods; - - methods->createProperty = createObjProperty; - methods->deleteProperty = deleteObjProperty; - methods->getProperty = getObjProperty; - methods->setProperty = setObjProperty; - - objectProp = ejsSetPropertyAndFree(ep, ep->global, "Object", op); - - /* - * Change the global class to use Object's methods - */ - globalClass = ep->service->globalClass; - globalClass->objectState->methods = methods; - globalClass->objectState->baseClass = ejsGetVarPtr(protoProp); - - ep->objectClass = ejsGetVarPtr(objectProp); - - if (ejsObjHasErrors(ejsGetVarPtr(objectProp))) { - ejsFreeVar(ep, op); - return MPR_ERR_CANT_CREATE; - } - return 0; -} - -/******************************************************************************/ - -#else -void ejsObjectDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c deleted file mode 100644 index fd6cda7813..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsStndClasses.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * @file ejsStndClasses.c - * @brief EJS support methods - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/******************************************************************************/ -/******************************* Function Class *******************************/ -/******************************************************************************/ - -int ejsDefineFunctionClass(Ejs *ep) -{ - if (ejsDefineClass(ep, "Function", "Object", ejsFunctionConstructor) == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - return 0; -} - -/******************************************************************************/ -/* - * Function constructor - */ - -int ejsFunctionConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsArgError(ep, "Usage: Function(\"function (arg) { script };\");"); - } - - rc = ejsEvalScript(ep, argv[0]->string, 0); - - /* - * Note: this will convert the object into a method. It will cease to be - * an object. - */ - if (rc == 0 && ejsVarIsMethod(ep->result)) { - /* - * Must make thisObj collectable. - */ - ejsMakeObjPermanent(thisObj, 0); - ejsMakeObjLive(thisObj, 1); - mprAssert(ejsObjIsCollectable(thisObj)); - ejsWriteVar(ep, thisObj, ep->result, EJS_SHALLOW_COPY); - } - return rc; -} - -/******************************************************************************/ -/******************************* Boolean Class ********************************/ -/******************************************************************************/ - -int ejsDefineBooleanClass(Ejs *ep) -{ - if (ejsDefineClass(ep, "Boolean", "Object", ejsBooleanConstructor) == 0){ - return MPR_ERR_CANT_INITIALIZE; - } - return 0; -} - -/******************************************************************************/ -/* - * Boolean constructor - */ - -int ejsBooleanConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - return 0; -} - -/******************************************************************************/ -/******************************** Number Class ********************************/ -/******************************************************************************/ - -int ejsDefineNumberClass(Ejs *ep) -{ - if (ejsDefineClass(ep, "Number", "Object", ejsNumberConstructor) == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - return 0; -} - -/******************************************************************************/ -/* - * Number constructor - */ - -int ejsNumberConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - return 0; -} - -/******************************************************************************/ - -#else -void ejsStndClassesDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c deleted file mode 100644 index 2339650361..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsString.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * @file ejsString.c - * @brief EJScript string class - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS -/******************************************************************************/ -/*********************************** Constructors *****************************/ -/******************************************************************************/ -/* - * String constructor. - */ - -int ejsStringConstructor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *str; - - if (argc == 0) { - ejsSetReturnValueToString(ejs, ""); - - } else if (argc == 1) { - /* MOB -- rc */ - str = ejsVarToString(ejs, argv[0]); - ejsSetReturnValueToString(ejs, str); - - } else { - ejsArgError(ejs, "usage: String([var])"); - return -1; - } - - return 0; -} - -/******************************************************************************/ -/******************************** Visible Methods *****************************/ -/******************************************************************************/ -/* - * Return a string containing the character at a given index - * - * String string.charAt(Number) - */ - -static int charAt(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsNum num; - char buf[2]; - - if (argc != 1) { - ejsArgError(ejs, "usage: charAt(integer)"); - return -1; - } - - num = ejsVarToNumber(argv[0]); - if (num < 0 || num >= thisObj->length) { - ejsError(ejs, EJS_RANGE_ERROR, "Bad index"); - return -1; - } - - mprAssert(ejsVarIsString(thisObj)); - - buf[0] = argv[0]->string[num]; - buf[1] = '\0'; - ejsSetReturnValueToString(ejs, buf); - - return 0; -} - -/******************************************************************************/ -/* - * Return an integer containing the character at a given index - * - * Number string.charCodeAt(Number) - */ - -static EjsNum charCodeAt(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsNum num; - - if (argc != 1) { - ejsArgError(ejs, "usage: charCodeAt(integer)"); - return -1; - } - - num = ejsVarToNumber(argv[0]); - if (num < 0 || num >= thisObj->length) { - ejsError(ejs, EJS_RANGE_ERROR, "Bad index"); - return -1; - } - ejsSetReturnValueToNumber(ejs, (EjsNum) argv[0]->string[num]); - - return 0; -} - -/******************************************************************************/ -/* - * Catenate - * - * String string.catenate(var, ...) - */ - -static int concat(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int i; - - if (argc == 0) { - ejsArgError(ejs, "usage: concat(String, ...)"); - return -1; - } - - mprAssert(ejsVarIsString(thisObj)); - - for (i = 0; i < argc; i++) { - if (ejsStrcat(ejs, thisObj, argv[i]) < 0) { - ejsMemoryError(ejs); - return -1; - } - } - ejsSetReturnValue(ejs, thisObj); - return 0; -} - -/******************************************************************************/ -/* - * Return the position of the first occurance of a substring - * - * Number string.indexOf(String subString [, Number start]) - */ - -static int indexOf(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *pat, *s1, *s2, *origin; - int start, i; - - if (argc == 0 || argc > 2) { - ejsArgError(ejs, "usage: indexOf(String [, Number])"); - return -1; - } - - pat = ejsVarToString(ejs, argv[0]); - - if (argc == 2) { - start = ejsVarToNumber(argv[1]); - if (start > thisObj->length) { - start = thisObj->length; - } - } else { - start = 0; - } - - i = start; - for (origin = &thisObj->string[i]; i < thisObj->length; i++, origin++) { - s1 = origin; - for (s2 = pat; *s1 && *s2; s1++, s2++) { - if (*s1 != *s2) { - break; - } - } - if (*s2 == '\0') { - ejsSetReturnValueToNumber(ejs, (EjsNum) (origin - thisObj->string)); - } - } - - ejsSetReturnValueToNumber(ejs, (EjsNum) -1); - return 0; -} - -/******************************************************************************/ -/* - * Return the position of the last occurance of a substring - * - * Number string.lastIndexOf(String subString [, Number start]) - */ - -static int lastIndexOf(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *pat, *s1, *s2, *origin; - int start; - - if (argc == 0 || argc > 2) { - ejsArgError(ejs, "usage: indexOf(String [, Number])"); - return -1; - } - - pat = ejsVarToString(ejs, argv[0]); - - if (argc == 2) { - start = ejsVarToNumber(argv[1]); - if (start > thisObj->length) { - start = thisObj->length; - } - } else { - start = 0; - } - - origin = &thisObj->string[thisObj->length - 1]; - for (; origin >= &thisObj->string[start]; origin--) { - - s1 = origin; - for (s2 = pat; *s1 && *s2; s1++, s2++) { - if (*s1 != *s2) { - break; - } - } - if (*s2 == '\0') { - ejsSetReturnValueToNumber(ejs, (EjsNum) (origin - thisObj->string)); - } - } - - ejsSetReturnValueToNumber(ejs, (EjsNum) -1); - return 0; -} - -/******************************************************************************/ -/* - * Return a substring - * - * Number string.slice(Number start, Number end) - */ - -static int slice(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsNum start, end; - - if (argc != 2) { - ejsArgError(ejs, "usage: slice(Number, Number)"); - return -1; - } - - start = ejsVarToNumber(argv[0]); - end = ejsVarToNumber(argv[1]); - if (start < 0 || start >= thisObj->length) { - ejsError(ejs, EJS_RANGE_ERROR, "Bad start index"); - return-1; - } - if (end < 0 || end >= thisObj->length) { - ejsError(ejs, EJS_RANGE_ERROR, "Bad end index"); - return -1; - } - - mprAssert(ejsVarIsString(thisObj)); - - ejsSetReturnValueToBinaryString(ejs, (uchar*) &thisObj->string[start], - end - start); - - return 0; -} - -/******************************************************************************/ -/* - * Split a string - * - * Number string.split(String delimiter [, Number limit]) - */ - -static int split(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsVar *array, *vp; - char *delim, *last, *cp; - int len, limit, alloc; - - if (argc == 0 || argc > 2) { - ejsArgError(ejs, "usage: split(String [, Number])"); - return -1; - } - - delim = ejsVarToStringEx(ejs, argv[0], &alloc); - - limit = ejsVarToNumber(argv[1]); - - array = ejsCreateArray(ejs, 0); - - len = strlen(delim); - - last = thisObj->string; - for (cp = last; *cp; cp++) { - if (*cp == *delim && strncmp(cp, delim, len) == 0) { - if (cp > last) { - vp = ejsCreateBinaryStringVar(ejs, (uchar*) last, (cp - last)); - ejsAddArrayElt(ejs, array, vp, EJS_SHALLOW_COPY); - ejsFreeVar(ejs, vp); - } - } - } - - ejsSetReturnValue(ejs, array); - ejsFreeVar(ejs, array); - - if (alloc) { - mprFree(delim); - } - - return 0; -} - -/******************************************************************************/ -/* - * Create the object class - */ - -int ejsDefineStringClass(Ejs *ejs) -{ - EjsVar *sc; - - sc = ejsDefineClass(ejs, "String", "Object", ejsStringConstructor); - if (sc == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - ejsDefineCMethod(ejs, sc, "charAt", charAt, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "charCodeAt", charCodeAt, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "concat", concat, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "indexOf", indexOf, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "lastIndexOf", lastIndexOf, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "slice", slice, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "split", split, EJS_NO_LOCAL); -#if UNUSED - ejsDefineCMethod(ejs, sc, "match", match, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "replace", replace, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "search", search, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "substring", substring, EJS_NO_LOCAL); - // MOB bad name - ejsDefineCMethod(ejs, sc, "substr", substr, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "toLowerCase", toLowerCase, EJS_NO_LOCAL); - ejsDefineCMethod(ejs, sc, "toUpperCase", toUpperCase, EJS_NO_LOCAL); - - // Static method - ejsDefineCMethod(ejs, sc, "fromCharCode", fromCharCode, 0, EJS_NO_LOCAL); -#endif - - if (ejsObjHasErrors(sc)) { - ejsFreeVar(ejs, sc); - return MPR_ERR_CANT_CREATE; - } - return 0; -} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c b/source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c deleted file mode 100644 index a2ef8d1390..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/classes/ejsXml.c +++ /dev/null @@ -1,1327 +0,0 @@ -/* - * @file ejsXml.c - * @brief E4X XML support - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/************************************ Doc *************************************/ -/* - * Javascript class definition - * - * class XML { - * public XML(); - * public XML(string xmlString); // ""); - Operators: - var prices = order..price; - var urgentItems = order.item(@level == "rush"); - var itemAttrs = order.item[0].@*; # @ for attributes - XML Literals - order.customer.address = -
..... - {zipCode} Where {var} is a JS var - ... Also for attributes -
- Omit namespaces - Example: - var html = ; - html.head.title = "My title"; - head.body@bgcolor = "#e4e4e4"; -*/ - -/********************************** Includes **********************************/ - -#include "ejs.h" -#include "exml.h" - -/************************************ Data ************************************/ -#if BLD_FEATURE_EJS_E4X - -/* - * Per tag state - */ -typedef struct XmlTagState { - EjsVar *obj; - EjsVar *attributes; - EjsVar *comments; -} XmlTagState; - -/* - * Parser state - */ -typedef struct XmlState { - Ejs *ep; - EjsVar *xmlClass; - EjsVar *xmlListClass; - XmlTagState nodeStack[E4X_MAX_NODE_DEPTH]; - int topOfStack; - long inputSize; - long inputPos; - const char *inputBuf; - const char *fileName; -} XmlState; - -/****************************** Forward Declarations **************************/ -/* - * XML methods - */ -static int text(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int name(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int load(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int save(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int toString(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int valueOf(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); - -/* MOB -- temp */ -static int getList(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int setText(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); - -#if FUTURE -static int length(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int toXmlString(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); - -static int appendChild(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int attributes(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int child(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int children(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int comments(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int decendants(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int elements(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int insertChildAfter(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int insertChildBefore(Ejs *ep, EjsVar *thisObj, int argc, - EjsVar **argv); -static int replace(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int setName(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -static int text(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv); -#endif - -/* - * Internal methods - */ -static EjsVar *createXmlProperty(Ejs *ep, EjsVar *obj, const char *property); -static int deleteXmlProperty(Ejs *ep, EjsVar *obj, const char *property); -static EjsVar *getXmlProperty(Ejs *ep, EjsVar *obj, const char *property); -static EjsVar *setXmlProperty(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value); -static int loadXmlString(Ejs *ep, EjsVar *thisObj, const char *xmlString); - -/* - * XMLList methods - */ -static EjsVar *createXmlListProperty(Ejs *ep, EjsVar *obj, - const char *property); -static int deleteXmlListProperty(Ejs *ep, EjsVar *obj, - const char *property); -static EjsVar *getXmlListProperty(Ejs *ep, EjsVar *obj, const char *property); -static EjsVar *setXmlListProperty(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value); - -/* - * Misc - */ -static int readFileData(Exml *xp, void *data, char *buf, int size); -static int readStringData(Exml *xp, void *data, char *buf, int size); -static int parserHandler(Exml *xp, int state, const char *tagName, - const char *attName, const char *value); -static void termParser(Exml *xp); -static Exml *initParser(Ejs *ep, EjsVar *thisObj, const char *fileName); -static int getNumElements(EjsVar *obj); -static int getText(MprBuf *buf, EjsVar *obj); -static int xmlToString(Ejs *ep, MprBuf *buf, EjsVar *obj, int indentLevel); -static void indent(MprBuf *bp, int level); -static char *cleanTagName(char *name); - -/******************************************************************************/ -/* - * Define the E4X classes (XML, XMLList) - */ - -int ejsDefineXmlClasses(Ejs *ep) -{ - EjsMethods *methods; - EjsVar *xmlClass, *xmlListClass; - - /* - * Create the XML class - */ - xmlClass = ejsDefineClass(ep, "XML", "Object", ejsXmlConstructor); - if (xmlClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the XML class methods - */ - ejsDefineCMethod(ep, xmlClass, "text", text, EJS_NO_LOCAL); - ejsDefineCMethod(ep, xmlClass, "name", name, EJS_NO_LOCAL); - ejsDefineCMethod(ep, xmlClass, "load", load, EJS_NO_LOCAL); - ejsDefineCMethod(ep, xmlClass, "save", save, EJS_NO_LOCAL); - ejsDefineCMethod(ep, xmlClass, "toString", toString, EJS_NO_LOCAL); - ejsDefineCMethod(ep, xmlClass, "valueOf", valueOf, EJS_NO_LOCAL); - -/* MOB -- temporary only */ - ejsDefineCMethod(ep, xmlClass, "getList", getList, EJS_NO_LOCAL); - ejsDefineCMethod(ep, xmlClass, "setText", setText, EJS_NO_LOCAL); - - /* - * Setup the XML internal methods. - */ - methods = mprAllocTypeZeroed(ep, EjsMethods); - xmlClass->objectState->methods = methods; - - methods->createProperty = createXmlProperty; - methods->deleteProperty = deleteXmlProperty; - methods->getProperty = getXmlProperty; - methods->setProperty = setXmlProperty; - - /* - * Create the XMLList class - */ - xmlListClass = ejsDefineClass(ep, "XMLList", "Array", - ejsXmlListConstructor); - - /* - * Define the XMLList class methods - */ - - /* - * Setup the XML internal methods. - */ - methods = mprAllocTypeZeroed(ep, EjsMethods); - xmlListClass->objectState->methods = methods; - - methods->createProperty = createXmlListProperty; - methods->deleteProperty = deleteXmlListProperty; - methods->getProperty = getXmlListProperty; - methods->setProperty = setXmlListProperty; - - /* MOB -- need to complete xmlListClass */ - - return (ejsObjHasErrors(xmlClass) || ejsObjHasErrors(xmlListClass)) - ? MPR_ERR_CANT_INITIALIZE : 0; - return 0; -} - -/******************************************************************************/ -/* - * Routine to create an XML object using a default constructor - */ - -EjsVar *ejsCreateXml(Ejs *ep) -{ - EjsVar *op; - - op = ejsCreateSimpleObj(ep, "XML"); - if (op == 0) { - mprAssert(op); - return op; - } - ejsSetVarName(ep, op, "xmlNode"); - - /* - * Invoke class constructors manually (for speed and space) - */ - if (ejsXmlConstructor(ep, op, 0, 0) < 0) { - mprFree(op); - mprAssert(0); - return 0; - } - return op; -} - -/******************************************************************************/ -/* - * XML constructor - */ - -int ejsXmlConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsVar *vp; - const char *str; - - ejsSetVarFlags(thisObj, EJS_XML_FLAGS_ELEMENT); - - if (argc == 1) { - vp = argv[0]; - - if (ejsVarIsObject(vp)) { - /* Convert DOM to XML. Not implemented */; - - } else if (ejsVarIsString(vp)) { - str = vp->string; - if (str == 0) { - return 0; - } - if (*str == '<') { - /* XML Literal */ - return loadXmlString(ep, thisObj, str); - - } else { - /* Load from file */ - return load(ep, thisObj, argc, argv); - } - } else { - ejsError(ep, EJS_TYPE_ERROR, "Bad type passed to XML constructor"); - return -1; - } - } - return 0; -} - -/******************************************************************************/ -/* - * Routine to create an XMLList object - */ - -EjsVar *ejsCreateXmlList(Ejs *ep) -{ - EjsVar *op; - - /* Sanity limit for size of hash table */ - - op = ejsCreateSimpleObj(ep, "XMLList"); - if (op == 0) { - mprAssert(0); - return op; - } - if (ejsArrayConstructor(ep, op, 0, 0) < 0 || - ejsXmlConstructor(ep, op, 0, 0) < 0) { - mprFree(op); - mprAssert(0); - return 0; - } - return op; -} - -/******************************************************************************/ -/* - * XMLList constructor - */ - -int ejsXmlListConstructor(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - // ejsSetVarFlags(vp, EJS_XML_FLAGS_ELEMENT); - return 0; -} - -/******************************************************************************/ -/******************************** Internal Methods ****************************/ -/******************************************************************************/ - -static EjsVar *createXmlProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsGetVarPtr(ejsCreateSimpleProperty(ep, obj, property)); -} - -/******************************************************************************/ - -static int deleteXmlProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsDeleteProperty(ep, obj, property); -} - -/******************************************************************************/ -/* MOB -- need ep as an arg */ -static EjsVar *getXmlProperty(Ejs *ep, EjsVar *obj, const char *property) -{ -#if NEW - EjsVar *lp; - - lp = ejsCreateXmlList(ep); - if (isdigit(*property)) { - /* MOB -- where do we store these. Do we need them ? */ - lp->targetObject = obj - lp->targetProperty = property - return getXmlListProperty(lp, property); - } - - /* What about a simple elment. Should it not return the text */ - - if (*property == '@') { - ap = ejsGetFirstProperty(obj, EJS_ENUM_ALL); - while (ap) { - vp = ejsGetVarPtr(ap); - /* MOB -- are attributes unique ? */ - if (vp->flags & EJS_XML_FLAGS_ATTRIBUTE && - strcmp(property, ap->name) == 0) { - ejsAppendXml(lp, vp); - } - ap = ejsGetNexttProperty(ap, EJS_ENUM_ALL); - } - } else { - while (ap) { - vp = ejsGetVarPtr(ap); - /* MOB -- are attributes unique ? */ - if (vp->flags & EJS_XML_FLAGS_ELEMENT && - strcmp(property, ap->name) == 0) { - ejsAppendXml(lp, vp); - } - ap = ejsGetNexttProperty(ap, EJS_ENUM_ALL); - } - } - return l; - - // Must always return XML or XMLList event for comments and attributes -#endif - return ejsGetVarPtr(ejsGetSimpleProperty(ep, obj, property)); -} - -/******************************************************************************/ - -static EjsVar *setXmlProperty(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value) -{ - EjsProperty *pp; - EjsVar *vp; - - pp = ejsCreateSimpleProperty(ep, obj, property); - if (pp == 0) { - /* Should never happen */ - mprAssert(pp); - return 0; - } - vp = ejsGetVarPtr(pp); - if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) < 0) { - return 0; - } - return ejsGetVarPtr(pp); -} - -/******************************************************************************/ -/* - NEW - -static EjsVar *setXmlProperty(Ejs *ep, EjsVar *op, const char *property, - EjsVar *value) -{ - - if ((value->objectState->baseClass != XML && - value->objectState->baseClass != XMLList) || - value->string[0] != '<') { - ejsVarToString(luevalue.toString(); - ejsRunMethod(ep, value, "toString", 0); - value = ejsDupVar(ep->result); - - } else { - value = ejsDupVar(value); - } - - if (isdigit(*property)) { - // ERROR -- reserved for future versions - return 0; - } - - if (*property == '@') { - if (op->objectState->baseClass == XMLList) { - if (op->obj.LENGTH_PROPERTY == 0) { - c = ""; - } else { - // Catenate all result of toString on all elts in list - } - } else { - c = c.toString(); - } - // Replace existing attribute of same name or insert - return; - } - for (i = op->obj.LENGTH - 1; i >= 0; i--) { - // Delete item of same name - } - if (not Found) { - Append new Xml object - - set [[name]], [[class]] == "element" - } - - mprFree(value); -} - - */ -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ - -static int load(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const char *fileName; - XmlState *parser; - Exml *xp; - MprFile *file; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ep, EJS_ARG_ERROR, "Bad args. Usage: load(fileName);"); - return -1; - } - fileName = argv[0]->string; - - /* MOB -- not romable - Need rom code in MPR not MprServices - */ - file = mprOpen(ep, fileName, O_RDONLY, 0664); - if (file == 0) { - ejsError(ep, EJS_IO_ERROR, "Can't open: %s", fileName); - return -1; - } - - /* MOB -- should we empty thisObj of all existing properties ? */ - - xp = initParser(ep, thisObj, fileName); - parser = exmlGetParseArg(xp); - - exmlSetInputStream(xp, readFileData, (void*) file); - - if (exmlParse(xp) < 0) { - if (! ejsGotException(ep)) { - ejsError(ep, EJS_IO_ERROR, "Can't parse XML file: %s\nDetails %s", - fileName, exmlGetErrorMsg(xp)); - } - termParser(xp); - mprClose(file); - return -1; - } - - ejsSetReturnValue(ep, parser->nodeStack[0].obj); - - termParser(xp); - mprClose(file); - - return 0; -} - -/******************************************************************************/ - -static int loadXmlString(Ejs *ep, EjsVar *thisObj, const char *xmlString) -{ - XmlState *parser; - Exml *xp; - - xp = initParser(ep, thisObj, "string"); - parser = exmlGetParseArg(xp); - - parser->inputBuf = xmlString; - parser->inputSize = strlen(xmlString); - - exmlSetInputStream(xp, readStringData, (void*) 0); - - if (exmlParse(xp) < 0) { - if (! ejsGotException(ep)) { - ejsError(ep, EJS_IO_ERROR, "Can't parse XML string\nError %s", - exmlGetErrorMsg(xp)); - } - termParser(xp); - return -1; - } - - ejsSetReturnValue(ep, parser->nodeStack[0].obj); - - termParser(xp); - - return 0; -} - -/******************************************************************************/ - -static int text(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetSimpleProperty(ep, thisObj, E4X_TEXT_PROPERTY)); - if (vp == 0) { - ejsSetReturnValueToString(ep, ""); - return 0; - } - ejsSetReturnValue(ep, vp); - return 0; -} - -/******************************************************************************/ -/* - * Return the tag name - */ - -static int name(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetSimpleProperty(ep, thisObj, E4X_TAG_NAME_PROPERTY)); - if (vp == 0) { - ejsSetReturnValueToString(ep, ""); - return 0; - } - ejsSetReturnValue(ep, vp); -#if UNDEFINED - char *name; - /* MOB -- not ideal as we can't guarantee thisObj is a property */ - name = ejsGetPropertyPtr(thisObj)->name; - if (name == 0) { - name = ""; - } - ejsSetReturnValueToString(ep, name); -#endif - return 0; -} - -/******************************************************************************/ -/* MOB -- temporary only */ - -static int setText(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsArgError(ep, "usage: setText(string)"); - } - - ejsSetProperty(ep, thisObj, E4X_TEXT_PROPERTY, argv[0]); - ejsSetReturnValue(ep, argv[0]); - return 0; -} - -/******************************************************************************/ - -static Exml *initParser(Ejs *ep, EjsVar *thisObj, const char *fileName) -{ - XmlState *parser; - Exml *xp; - - xp = exmlOpen(ep, 512, E4X_BUF_MAX); - mprAssert(xp); - - /* - * Create the parser stack - */ - parser = mprAllocTypeZeroed(ep, XmlState); - parser->ep = ep; - parser->nodeStack[0].obj = thisObj; - parser->xmlClass = ejsGetClass(ep, 0, "XML"); - parser->xmlListClass = ejsGetClass(ep, 0, "XMLList"); - parser->fileName = fileName; - - exmlSetParseArg(xp, parser); - exmlSetParserHandler(xp, parserHandler); - - return xp; -} - -/******************************************************************************/ - -static void termParser(Exml *xp) -{ - mprFree(exmlGetParseArg(xp)); - exmlClose(xp); -} - -/******************************************************************************/ -/* - * XML parsing callback. Called for each elt and attribute/value pair. - * For speed, we handcraft the object model here rather than calling - * putXmlProperty. - * - * "" parseHandler(efd, , EXML_COMMENT); - * "" parseHandler(efd, , EXML_ELT_DEFINED); - * "" parseHandler(efd, , EXML_SOLO_ELT_DEFINED); - * " ...<" parseHandler(efd, , EXML_ELT_DATA); - * "..." parseHandler(efd, , EXML_END_ELT); - * - * Note: we recurse on every new nested elt. - */ - -static int parserHandler(Exml *xp, int state, const char *tagName, - const char *attName, const char *value) -{ - XmlState *parser; - XmlTagState *tos; - EjsVar *currentNode, *vp, *tagNode, *parent, *vpx; - EjsProperty *pp; - Ejs *ep; - char *name; - - parser = (XmlState*) xp->parseArg; - ep = parser->ep; - tos = &parser->nodeStack[parser->topOfStack]; - currentNode = tos->obj; - - mprAssert(state >= 0); - mprAssert(tagName && *tagName); - - switch (state) { - case EXML_PI: - /* - * By using a property name with a leading space, we can store - * non-user-visible processing instructions as regular properties. - */ - pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode, E4X_PI_PROPERTY); - ejsMakePropertyEnumerable(pp, 1); - vp = ejsGetVarPtr(pp); - ejsWriteVarAsString(ep, vp, value); - ejsSetVarFlags(vp, EJS_XML_FLAGS_PI); - break; - - case EXML_COMMENT: - /* - * By using a property name with a leading space, we can store - * non- user-visible comments as regular properties. - */ - pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode, - E4X_COMMENT_PROPERTY); - ejsMakePropertyEnumerable(pp, 1); - vp = ejsGetVarPtr(pp); - ejsWriteVarAsString(ep, vp, value); - ejsSetVarFlags(vp, EJS_XML_FLAGS_COMMENT); - break; - - case EXML_NEW_ELT: - if (parser->topOfStack > E4X_MAX_NODE_DEPTH) { - ejsError(ep, EJS_IO_ERROR, - "XML nodes nested too deeply in %s at line %d", - parser->fileName, exmlGetLineNumber(xp)); - return MPR_ERR_BAD_SYNTAX; - } - - name = mprStrdup(xp, tagName); - if (name == 0) { - return MPR_ERR_MEMORY; - } - - if (cleanTagName(name) < 0) { - ejsError(ep, EJS_TYPE_ERROR, "Bad XML tag name in %s at %d", - parser->fileName, exmlGetLineNumber(xp)); - mprFree(name); - return MPR_ERR_BAD_SYNTAX; - } - - pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode, name); - ejsMakePropertyEnumerable(pp, 1); - - tagNode = ejsGetVarPtr(pp); - - /* MOB -- OPT */ - vpx = ejsCreateXml(ep); - vp = ejsWriteVar(ep, tagNode, vpx, EJS_SHALLOW_COPY); - ejsMakeObjLive(vp, 1); - ejsFreeVar(ep, vpx); - - /* MOB -- return code */ - pp = ejsSetPropertyToString(ep, vp, E4X_TAG_NAME_PROPERTY, name); - ejsMakePropertyEnumerable(pp, 0); - - ejsSetVarFlags(vp, EJS_XML_FLAGS_ELEMENT); - ejsMakePropertyEnumerable(ejsGetPropertyPtr(vp), 1); - - tos = &parser->nodeStack[++(parser->topOfStack)]; - currentNode = tos->obj = vp; - tos->attributes = 0; - tos->comments = 0; - mprFree(name); - break; - - case EXML_NEW_ATT: - if (mprAllocSprintf(MPR_LOC_ARGS(xp), &name, 0, "@%s", attName) < 0) { - return MPR_ERR_MEMORY; - } - pp = ejsCreateProperty(ep, currentNode, name); - ejsMakePropertyEnumerable(pp, 1); - - vp = ejsGetVarPtr(pp); - ejsWriteVarAsString(ep, vp, value); - ejsSetVarFlags(vp, EJS_XML_FLAGS_ATTRIBUTE); - mprFree(name); - break; - - case EXML_SOLO_ELT_DEFINED: - parser->topOfStack--; - mprAssert(parser->topOfStack >= 0); - tos = &parser->nodeStack[parser->topOfStack]; - break; - - case EXML_ELT_DEFINED: - if (parser->topOfStack > 0) { - parent = parser->nodeStack[parser->topOfStack - 1].obj; - ejsSetProperty(ep, currentNode, E4X_PARENT_PROPERTY, parent); - } - break; - - case EXML_ELT_DATA: - case EXML_CDATA: - pp = ejsCreateSimpleNonUniqueProperty(ep, currentNode, - E4X_TEXT_PROPERTY); - ejsMakePropertyEnumerable(pp, 1); - vp = ejsGetVarPtr(pp); - ejsWriteVarAsString(ep, vp, value); - ejsSetVarFlags(vp, EJS_XML_FLAGS_TEXT); - break; - - case EXML_END_ELT: - /* - * This is the closing element in a pair "...". - * Pop the stack frame off the elt stack - */ - parser->topOfStack--; - mprAssert(parser->topOfStack >= 0); - tos = &parser->nodeStack[parser->topOfStack]; - break; - - default: - ejsError(ep, EJS_IO_ERROR, "XML error in %s at %d\nDetails %s", - parser->fileName, exmlGetLineNumber(xp), exmlGetErrorMsg(xp)); - mprAssert(0); - return MPR_ERR_BAD_SYNTAX; - } - return 0; -} - -/******************************************************************************/ - -static char *cleanTagName(char *name) -{ - char *cp; - - for (cp = name; *cp; cp++) { - if (*cp == ':') { - *cp = '_'; - } else if (!isalnum(*cp) && *cp != '_' && *cp != '$' && *cp != '@') { - return 0; - } - } - return name; -} - -/******************************************************************************/ - -static int readFileData(Exml *xp, void *data, char *buf, int size) -{ - mprAssert(xp); - mprAssert(data); - mprAssert(buf); - mprAssert(size > 0); - - return mprRead((MprFile*) data, buf, size); -} - -/******************************************************************************/ - -static int readStringData(Exml *xp, void *data, char *buf, int size) -{ - XmlState *parser; - int rc, len; - - mprAssert(xp); - mprAssert(buf); - mprAssert(size > 0); - - parser = (XmlState*) xp->parseArg; - - if (parser->inputPos < parser->inputSize) { - len = min(size, (parser->inputSize - parser->inputPos)); - rc = mprMemcpy(buf, size, &parser->inputBuf[parser->inputPos], len); - parser->inputPos += len; - return rc; - } - return 0; -} - -/******************************************************************************/ - -static int save(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const char *fileName; - MprBuf *buf; - MprFile *file; - int bytes, len; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ep, EJS_ARG_ERROR, "Bad args. Usage: save(fileName);"); - return -1; - } - fileName = argv[0]->string; - - /* MOB -- not romable - Need rom code in MPR not MprServices - */ - - /* - * Convert to a string - */ - buf = mprCreateBuf(ep, E4X_BUF_SIZE, E4X_BUF_MAX); - if (xmlToString(ep, buf, thisObj, -1) < 0) { - mprFree(buf); - return -1; - } - - file = mprOpen(ep, fileName, - O_CREAT | O_TRUNC | O_WRONLY | O_TEXT, 0664); - if (file == 0) { - ejsError(ep, EJS_IO_ERROR, "Can't open: %s, %d", fileName, - mprGetOsError()); - return -1; - } - - len = mprGetBufLength(buf); - bytes = mprWrite(file, buf->start, len); - if (bytes != len) { - ejsError(ep, EJS_IO_ERROR, "Can't write to: %s", fileName); - mprClose(file); - return -1; - } - mprWrite(file, "\n", 1); - mprFree(buf); - - mprClose(file); - - return 0; -} - -/******************************************************************************/ - -static int toString(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprBuf *buf; - - buf = mprCreateBuf(ep, E4X_BUF_SIZE, E4X_BUF_MAX); - - if (xmlToString(ep, buf, thisObj, -1) < 0) { - mprFree(buf); - return -1; - } - ejsWriteVarAsString(ep, ep->result, (char*) buf->start); - - mprFree(buf); - - return 0; -} - -/******************************************************************************/ -/* MOB -- need to support XMLList */ - -static int xmlToString(Ejs *ep, MprBuf *buf, EjsVar *obj, int indentLevel) -{ - EjsProperty *pp; - EjsVar *vp; - char *varBuf; - int endTag, sawElements; - - if (indentLevel < 0) { - mprPutStringToBuf(buf, ""); - } - - switch (obj->type) { - case EJS_TYPE_STRING: - if (obj->flags & EJS_XML_FLAGS_ATTRIBUTE) { - mprPutFmtStringToBuf(buf, " %s=\"%s\"", - &ejsGetPropertyPtr(obj)->name[1], obj->string); - /* No new line */ - - } else if (obj->flags & EJS_XML_FLAGS_COMMENT) { - mprPutCharToBuf(buf, '\n'); - indent(buf, indentLevel); - mprPutFmtStringToBuf(buf, "", obj->string); - - } else if (obj->flags & EJS_XML_FLAGS_TEXT) { - mprPutStringToBuf(buf, obj->string); - - } else { -// indent(buf, indentLevel); - mprPutStringToBuf(buf, obj->string); -// mprPutCharToBuf(buf, '\n'); - } - break; - - default: - /* Primitive types come here */ - indent(buf, indentLevel); - /* MOB -- rc */ - varBuf = ejsVarToString(ep, obj); - mprPutStringToBuf(buf, varBuf); - break; - - case EJS_TYPE_OBJECT: - if (obj->objectState->baseClass == ejsGetClass(ep, 0, "XML")) { - if (!obj->objectState->visited) { - obj->objectState->visited = 1; - - /* MOB -- opt. Flags would be quicker */ - if (strcmp(ejsGetPropertyPtr(obj)->name, - E4X_PARENT_PROPERTY) == 0) { - return 0; - } - /* - * MOB -- short term fix for tags with no body but with - * attributes - */ - if (getNumElements(obj) == 0 && 0) { - /* - * XML element is simple with no elements, so return just - * the text. - */ - if (getText(buf, obj) < 0) { - ejsError(ep, EJS_IO_ERROR, - "XML is to big to convert to a string"); - obj->objectState->visited = 0; - return -1; - } - - } else if (obj->flags & (EJS_XML_FLAGS_ELEMENT)) { - /* - * XML object is complex (has elements) so return full XML - * content. - */ - mprPutCharToBuf(buf, '\n'); - indent(buf, indentLevel); - - /* - * When called from toString, obj is not a property - */ - if (indentLevel >= 0) { - mprPutFmtStringToBuf(buf, "<%s", - ejsGetPropertyPtr(obj)->name); - endTag = 0; - - } else { - endTag = 1; - } - - sawElements = 0; - pp = ejsGetFirstProperty(obj, 0); - while (pp) { - vp = ejsGetVarPtr(pp); - - if (! (vp->flags & EJS_XML_FLAGS_ATTRIBUTE)) { - if (endTag == 0) { - endTag++; - mprPutStringToBuf(buf, ">"); - } - } - if (vp->flags & EJS_XML_FLAGS_ELEMENT) { - if (strcmp(ejsGetPropertyPtr(vp)->name, - E4X_PARENT_PROPERTY) != 0) { - sawElements++; - } - } - - if (xmlToString(ep, buf, ejsGetVarPtr(pp), - indentLevel + 1) < 0){ - return -1; - } - - pp = ejsGetNextProperty(pp, 0); - } - if (indentLevel >= 0) { - if (sawElements) { - mprPutCharToBuf(buf, '\n'); - indent(buf, indentLevel); - } - mprPutFmtStringToBuf(buf, "", - ejsGetPropertyPtr(obj)->name); - } - } - obj->objectState->visited = 0; - } - return 0; - } - - if (obj->objectState->baseClass == ejsGetClass(ep, 0, "XMLList")) { - indent(buf, indentLevel); - /* MOB -- TBD */ - return 0; - } - - /* - * All other objects. Allow other objects to override toString - */ - if (ejsRunMethod(ep, obj->objectState->baseClass, "toString", - 0) < 0) { - return -1; - } - if (ejsVarIsString(ep->result)) { - indent(buf, indentLevel); - mprPutStringToBuf(buf, obj->string); - } - break; - } - return 0; -} - -/******************************************************************************/ - -static void indent(MprBuf *bp, int level) -{ - int i; - - for (i = 0; i < level; i++) { - mprPutCharToBuf(bp, '\t'); - } -} - -/******************************************************************************/ - -static int valueOf(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 0) { - mprAssert(0); - return -1; - } - - switch (thisObj->type) { - default: - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_OBJECT: - case EJS_TYPE_METHOD: - case EJS_TYPE_STRING_CMETHOD: - ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY); - break; - - case EJS_TYPE_STRING: - ejsWriteVarAsInteger(ep, ep->result, atoi(thisObj->string)); - break; - - case EJS_TYPE_BOOL: - case EJS_TYPE_INT: -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: -#endif -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: -#endif - ejsWriteVar(ep, ep->result, thisObj, EJS_SHALLOW_COPY); - break; - } - return 0; -} - -/******************************************************************************/ - -static int getList(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const char *nodeName; - EjsProperty *pp; - EjsVar *list, *vp; - - if (argc != 1) { - nodeName = 0; - } else { - nodeName = argv[0]->string; - } - - list = ejsCreateArray(ep, 0); - - pp = ejsGetFirstProperty(thisObj, EJS_ENUM_ALL); - while (pp) { - vp = ejsGetVarPtr(pp); - if (vp->type == EJS_TYPE_OBJECT) { - if (strcmp(ejsGetPropertyPtr(vp)->name, E4X_PARENT_PROPERTY) != 0) { - if (vp->flags & EJS_XML_FLAGS_ELEMENT && - (nodeName == 0 || strcmp(nodeName, pp->name) == 0)) { - ejsAddArrayElt(ep, list, vp, EJS_SHALLOW_COPY); - } - } - } - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - - ejsSetReturnValueAndFree(ep, list); - return 0; -} - -/******************************************************************************/ - -static int getNumElements(EjsVar *obj) -{ - EjsProperty *pp; - int count; - - count = 0; - pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL); - while (pp) { - if (ejsGetVarPtr(pp)->flags & EJS_XML_FLAGS_ELEMENT) { - count++; - } - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - return count; -} - -/******************************************************************************/ -/* MOB - This needs to be a public method */ - -static int getText(MprBuf *buf, EjsVar *obj) -{ - EjsProperty *pp; - EjsVar *vp; - - pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL); - while (pp) { - vp = ejsGetVarPtr(pp); - if (vp->flags & EJS_XML_FLAGS_TEXT) { - /* MOB -- should test for overflow */ - mprPutStringToBuf(buf, vp->string); - } - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - return 0; -} - -/******************************************************************************/ -/******************************************************************************/ -/******************************** Internal Methods ****************************/ -/******************************************************************************/ - -static EjsVar *createXmlListProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsGetVarPtr(ejsCreateProperty(ep, obj, property)); -} - -/******************************************************************************/ - -static int deleteXmlListProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - return ejsDeleteProperty(ep, obj, property); -} - -/******************************************************************************/ - -static EjsVar *getXmlListProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - // Must always return XML or XMLList event for comments and attributes - return ejsGetVarPtr(ejsGetSimpleProperty(ep, obj, property)); -} - -/******************************************************************************/ - -static EjsVar *setXmlListProperty(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value) -{ - EjsProperty *pp; - EjsVar *vp; - - pp = ejsGetSimpleProperty(ep, obj, property); - if (pp == 0) { - mprAssert(pp); - return 0; - } - vp = ejsGetVarPtr(pp); - if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) < 0){ - mprAssert(0); - return 0; - } - return ejsGetVarPtr(pp); -} - -/******************************************************************************/ -/* - NEW - -static EjsVar *putXmlListProperty(EjsVar *op, const char *property, - EjsVar *value) -{ - - if ((value->objectState->baseClass != XML && - value->objectState->baseClass != XMLList) || - value->string[0] != '<') { - c = value.toString(); - } else { - value = ejsDupVar(value); - ?? - } - if (isdigit(*property)) { - // ERROR - return 0; - } - if (*property == '@') { - if (op->objectState->baseClass == XMLList) { - if (op->obj.LENGTH_PROPERTY == 0) { - c = ""; - } else { - // Catenate all result of toString on all elts in list - } - } else { - c = c.toString(); - } - // Replace existing attribute of same name or insert - return; - } - for (i = op->obj.LENGTH - 1; i >= 0; i--) { - // Delete item of same name - } - if (not Found) { - Append new Xml object - - set [[name]], [[class]] == "element" - } -} - - */ - -/******************************************************************************/ -#else -void ejs4xDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS_E4X */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejs.c b/source4/lib/appweb/ejs-2.0/ejs/ejs.c deleted file mode 100644 index 0fcc6f0545..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejs.c +++ /dev/null @@ -1,1378 +0,0 @@ -/* - * @file ejs.c - * @brief Embedded JavaScript (EJS) - * @overview Main module interface logic. - * @remarks The initialization code must be run single-threaded. Includes: - * ejsOpen, ejsClose. - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/************************************* Code ***********************************/ -/* - * Initialize the EJS subsystem - */ - -EjsService *ejsOpenService(MprCtx ctx) -{ - EjsService *service; - Ejs *interp; - - service = mprAllocTypeZeroed(ctx, EjsService); - if (service == 0) { - mprError(ctx, MPR_LOC, "Can't allocate service memory"); - return 0; - } - - interp = ejsCreateInterp(service, 0, 0, 0, 1); - if (interp == 0) { - mprError(ctx, MPR_LOC, "Can't create master interpreter"); - mprFree(service); - return 0; - } - service->master = interp; - - /* - * Restore the default GC settings for the master interpreter. - * ejsCreateInterp will have initialized them. - */ - ejsGCInit(interp, EJS_DEFAULT_OBJ_INC, EJS_DEFAULT_PROP_INC, - EJS_DEFAULT_VAR_INC, EJS_DEFAULT_STR_INC); - - /* - * Save the default interpreter and global class for all to access - * MOB -- don't store these. Store the service - */ - mprSetKeyValue(interp, "ejsMaster", interp); - mprSetKeyValue(interp, "ejsGlobalClass", interp->global); - - /* - * Once the Object class is created, this routine will also make the - * Global class a subclass of Object. - */ - if (ejsDefineObjectClass(interp) < 0) { - mprError(ctx, MPR_LOC, "Can't define EJS object class"); - mprFree(service); - return 0; - } - - /* - * Create all the standard classes - */ - if (ejsDefineStandardClasses(interp) < 0) { - mprError(ctx, MPR_LOC, "Can't define EJS standard classes"); - mprFree(service); - return 0; - } - - if (ejsDefineSystemClasses(interp) < 0) { - mprError(ctx, MPR_LOC, "Can't define EJS system classes"); - mprFree(service); - return 0; - } - - if (ejsCreateObjectModel(interp) < 0) { - mprError(ctx, MPR_LOC, "Can't create EJS object model"); - mprFree(service); - return 0; - } - -#if UNUSED && BLD_FEATURE_ALLOC_STATS -{ - EjsVar v; - mprLog(ctx, 0, "Obj %d, Var %d, Prop %d\n", sizeof(EjsObj), sizeof(EjsVar), - sizeof(EjsProperty)); - mprLog(ctx, 0, "GCLink %d\n", sizeof(EjsGCLink)); - mprLog(ctx, 0, "objectState %d\n", (uint) &v.objectState - (uint) &v); -} -#endif - - return service; -} - -/******************************************************************************/ -/* - * Close down the EJS Service - */ - -void ejsCloseService(EjsService *sp, bool doStats) -{ - Ejs *ep; - - mprAssert(sp); - - ep = sp->master; - mprAssert(ep); - - ejsTermSystemClasses(ep); - - if (ep) { - ejsFreeVar(ep, sp->globalClass); - -#if BLD_FEATURE_ALLOC_STATS - if (doStats) { - mprLog(sp, 0, "GC Statistics for the Global Interpreter"); - } -#endif - ejsDestroyInterp(ep, doStats); - } - - mprRemoveKeyValue(sp, "ejsMaster"); - mprRemoveKeyValue(sp, "ejsGlobalClass"); - - mprFree(sp); -} - -/******************************************************************************/ - -Ejs *ejsGetMasterInterp(EjsService *sp) -{ - return sp->master; -} - -/******************************************************************************/ -#if BLD_FEATURE_MULTITHREAD - -int ejsSetServiceLocks(EjsService *sp, EjsLockFn lock, EjsUnlockFn unlock, - void *data) -{ - mprAssert(sp); - - sp->lock = lock; - sp->unlock = unlock; - sp->lockData = data; - return 0; -} - -#endif -/******************************************************************************/ -/* - * Create and initialize an EJS interpreter. Interpreters have a global object - * that has the service global class set as a base class. This way, it - * inherits all the desired global properties, methods and classes. - * - * The primary and alternate handles are provided to C methods depending on - * the flags provided when the C methods are defined. The global variable - * (optionally) defines a predefined global variable space. - */ - -Ejs *ejsCreateInterp(EjsService *sp, void *primaryHandle, void *altHandle, - EjsVar *global, bool useOwnSlab) -{ - EjsProperty *pp; - EjsVar *baseClass; - Ejs *ep; - - ep = mprAllocTypeZeroed(sp, Ejs); - if (ep == 0) { - mprAssert(0); - return ep; - } - - ep->stkPtr = &ep->stack[EJS_MAX_STACK]; - - ep->service = sp; - ep->primaryHandle = primaryHandle; - ep->altHandle = altHandle; - - if (sp->master) { - ep->objectClass = sp->master->objectClass; - } - - if (useOwnSlab) { - ep->slabs = (EjsSlab*) mprAllocZeroed(ep, sizeof(EjsSlab) * - EJS_SLAB_MAX); - ep->slabAllocContext = ep; - - } else { - ep->slabs = sp->master->slabs; - ep->slabAllocContext = sp->master; - ep->flags |= EJS_FLAGS_SHARED_SLAB; - } - - ep->frames = mprCreateItemArray(ep, EJS_INC_FRAMES, EJS_MAX_FRAMES); - if (ep->frames == 0) { - mprFree(ep); - return 0; - } - - ejsGCInit(ep, EJS_OBJ_INC, EJS_PROP_INC, EJS_VAR_INC, EJS_STR_INC); - - if (sp->globalClass == 0) { - /* - * Only do this for the Global interpreter. Create a global class - * (prototype) object. This is base class from which all global - * spaces will inherit. - */ - sp->globalClass = ejsCreateObjVar(ep); - if (sp->globalClass == 0) { - mprFree(ep); - return 0; - } - ejsSetClassName(ep, sp->globalClass, "Global"); - global = sp->globalClass; - } - - if (global) { - /* - * The default interpreter uses the Global class as its global - * space. - */ - ep->global = ejsDupVar(ep, global, EJS_SHALLOW_COPY); - if (ep->global == 0) { - mprFree(ep); - return 0; - } - if (ep->global->objectState != sp->globalClass->objectState) { - ejsSetBaseClass(ep->global, sp->globalClass); - } - - } else { - /* - * Use the global class as our global so we can find the object class - */ - baseClass = ejsGetClass(ep, sp->globalClass, "Object"); - if (baseClass) { - ep->global = ejsCreateSimpleObjUsingClass(ep, baseClass); - if (ep->global == 0) { - mprFree(ep); - return 0; - } - - /* - * Override the base class and set to the master Global class - */ - ejsSetBaseClass(ep->global, sp->globalClass); - - } else { - ep->global = ejsCreateObjVar(ep); - } - } - - /* - * The "global" variable points to the global space - */ - pp = ejsSetProperty(ep, ep->global, "global", ep->global); - if (pp == 0) { - mprFree(ep); - return 0; - } - ejsMakePropertyEnumerable(pp, 0); - - /* - * The "Global" variable points to the Global class - */ - pp = ejsSetProperty(ep, ep->global, "Global", sp->globalClass); - if (pp == 0) { - mprFree(ep); - return 0; - } - ejsMakePropertyEnumerable(pp, 0); - - ep->local = ejsDupVar(ep, ep->global, EJS_SHALLOW_COPY); - if (ep->frames == 0 || ep->global == 0 || ep->local == 0) { - mprFree(ep); - return 0; - } - ejsSetVarName(ep, ep->local, "topLevelLocal"); - - if (mprAddItem(ep->frames, ep->global) < 0 || - mprAddItem(ep->frames, ep->local) < 0) { - mprFree(ep); - return 0; - } - - ep->result = ejsCreateUndefinedVar(ep); - if (ep->result == 0) { - mprFree(ep); - return 0; - } - - return ep; -} - -/******************************************************************************/ -/* - * Close an EJS interpreter - */ - -void ejsDestroyInterp(Ejs *ep, bool doStats) -{ - ejsCleanInterp(ep, doStats); - - mprFree(ep); -} - -/******************************************************************************/ -/* - * Clean an EJS interpreter of all allocated variables, but DONT destroy. - * We use this rather than DestroyInterp so we delay freeing the Ejs struct - * until after the service is closed. - */ - -void ejsCleanInterp(Ejs *ep, bool doStats) -{ - int i; - - if (ep->global) { - ejsDeleteProperty(ep, ep->local, "global"); - ejsDeleteProperty(ep, ep->global, "global"); - ep->global = 0; - } - if (ep->local) { - ejsFreeVar(ep, ep->local); - ep->local = 0; - } - if (ep->global) { - ejsFreeVar(ep, ep->global); - ep->global = 0; - } - if (ep->result) { - ejsFreeVar(ep, ep->result); - ep->result = 0; - } - if (ep->castAlloc && ep->castTemp) { - mprFree(ep->castTemp); - ep->castTemp = 0; - } - if (ep->frames) { - for (i = ep->frames->length - 1; i >= 0; i--) { - mprRemoveItemByIndex(ep->frames, i); - } - mprFree(ep->frames); - ep->frames = 0; - } - - if (doStats) { - -#if BLD_FEATURE_ALLOC_STATS - mprLog(ep, 0, " "); - mprLog(ep, 0, "GC Statistics for Interpreter (0x%X)", (uint) ep); -#endif - - /* - * Cleanup before printing the alloc report - */ - ejsSetGCDebugLevel(ep, 3); - ejsCollectGarbage(ep, -1); - -#if BLD_DEBUG - /* - * If we are the master, dump objects - */ - if (ep->service->master == ep) { - ejsDumpObjects(ep); - } -#endif - -#if BLD_FEATURE_ALLOC_STATS - /* - * Print an alloc report. 1 == do leak report - */ - ejsPrintAllocReport(ep, 1); -#endif - - } else { - /* - * Must collect garbage here incase sharing interpreters with the - * master. If we don't, the mprFree later in DestroyInterp will free - * all memory and when the master does GC --> crash. - */ - ejsCollectGarbage(ep, -1); - } -} - -/******************************************************************************/ -/* - * Evaluate an EJS script file. This will evaluate the script at the current - * context. Ie. if inside a function, declarations will be local. - */ - -int ejsEvalFile(Ejs *ep, const char *path, EjsVar *result) -{ - MprFile *file; - MprFileInfo info; - char *script; - char *saveFileName; - int rc; - - mprAssert(path && *path); - - if ((file = mprOpen(ep, path, O_RDONLY | O_BINARY, 0666)) == 0) { - ejsError(ep, EJS_IO_ERROR, "Can't open %s", path); - return -1; - } - - if (mprGetFileInfo(ep, path, &info) < 0) { - ejsError(ep, EJS_IO_ERROR, "Can't get file info for %s", path); - goto error; - } - - if ((script = (char*) mprAlloc(ep, info.size + 1)) == NULL) { - ejsError(ep, "MemoryError", "Cant malloc %d", (int) info.size); - goto error; - } - - if (mprRead(file, script, info.size) != (int) info.size) { - mprFree(script); - ejsError(ep, EJS_IO_ERROR, "Error reading %s", path); - goto error; - } - mprClose(file); - script[info.size] = '\0'; - - saveFileName = ep->fileName; - ep->fileName = mprStrdup(ep, path); - - rc = ejsEvalScript(ep, script, result); - mprFree(script); - - mprFree(ep->fileName); - ep->fileName = saveFileName; - - return rc; - -/* - * Error return - */ -error: - mprClose(file); - return -1; -} - -/******************************************************************************/ -/* - * Create a new variable scope block. This pushes the old local frame down - * the stack and creates a new local variables frame. - */ - -int ejsOpenBlock(Ejs *ep) -{ - EjsProperty *pp; - int fid; - - ep->local = ejsCreateSimpleObj(ep, "Object"); - ejsSetVarName(ep, ep->local, "local"); - - if (ep->local == 0) { - ejsMemoryError(ep); - return -1; - } - - if (ep->frames->length > EJS_MAX_FRAMES && !ep->gotException) { - ejsError(ep, EJS_RANGE_ERROR, "Recursion too deep: Max depth %d", - EJS_MAX_FRAMES); - return -1; - } - - /* - * Must add to frames before ejsSetProperty which will make the object live - */ - fid = mprAddItem(ep->frames, ep->local); - if (fid < 0) { - ejsMemoryError(ep); - return -1; - } - - /* Self reference */ - pp = ejsSetProperty(ep, ep->local, "local", ep->local); - ejsMakePropertyEnumerable(pp, 0); - - return fid; -} - -/******************************************************************************/ -/* - * Set a new variable scope block. This pushes the old local frame down - * the stack and creates a new local variables frame. - */ - -int ejsSetBlock(Ejs *ep, EjsVar *local) -{ - ep->local = ejsDupVar(ep, local, EJS_SHALLOW_COPY); - ejsMakeObjPermanent(ep->local, 1); - return mprAddItem(ep->frames, ep->local); -} - -/******************************************************************************/ -/* - * Close a variable scope block opened via ejsOpenBlock. Pop back the old - * local variables frame. - */ - -int ejsCloseBlock(Ejs *ep, int fid) -{ - mprAssert(ep->local >= 0); - mprAssert(fid >= 0); - - mprAssert(ep->local == (EjsVar*) mprGetItem(ep->frames, fid)); - - if (ep->local) { - /* Allow GC */ - ejsMakeObjPermanent(ep->local, 0); - ejsFreeVar(ep, ep->local); - } - - mprRemoveItemByIndex(ep->frames, fid); - - ep->local = (EjsVar*) mprGetItem(ep->frames, - mprGetItemCount(ep->frames) - 1); - - return 0; -} - -/******************************************************************************/ -/* - * Create a new variable scope block and evaluate a script. All frames - * created during this context will be automatically deleted when complete. - * vp is optional. i.e. created local variables will be discarded - * when this routine returns. - */ - -int ejsEvalBlock(Ejs *ep, char *script, EjsVar *vp) -{ - int rc, fid; - - mprAssert(script); - - fid = ejsOpenBlock(ep); - if (fid < 0) { - return fid; - } - - rc = ejsEvalScript(ep, script, vp); - - ejsCloseBlock(ep, fid); - - return rc; -} - -/******************************************************************************/ -/* - * Parse and evaluate a EJS. The script is evaluated at the current context. - * Return the result in *vp. The result is "owned" by EJ and the caller - * must not free it. Returns -1 on errors and zero for success. - */ - -int ejsEvalScript(Ejs *ep, const char *script, EjsVar *vp) -{ - int state; - - ejsClearVar(ep, ep->result); - ep->gotException = 0; - - if (script == 0) { - return 0; - } - - /* - * Allocate a new evaluation block, and save the old one - */ - if (ejsLexOpenScript(ep, script) < 0) { - return MPR_ERR_MEMORY; - } - - /* - * Do the actual parsing and evaluation - */ - ep->scriptStatus = 0; - - do { - state = ejsParse(ep, EJS_STATE_BEGIN, EJS_FLAGS_EXE); - - if (state == EJS_STATE_RET) { - state = EJS_STATE_EOF; - } - } while (state != EJS_STATE_EOF && state != EJS_STATE_ERR); - - ejsLexCloseScript(ep); - - if (state == EJS_STATE_ERR) { - return -1; - } - - if (vp) { - /* Caller must not free. */ - *vp = *ep->result; - } - - return ep->scriptStatus; -} - -/******************************************************************************/ - -void ejsSetFileName(Ejs *ep, const char *fileName) -{ - mprFree(ep->fileName); - ep->fileName = mprStrdup(ep, fileName); -} - -/******************************************************************************/ -/* - * Format the stack backtrace - */ - -char *ejsFormatStack(Ejs* ep) -{ - EjsInput *ip; - char *errbuf; - int frame, len; - - mprAssert(ep); - - ip = ep->input; - - errbuf = 0; - - len = 0; - frame = 0; - while (ip && frame < EJS_MAX_BACKTRACE) { - char *traceLine, *newErrbuf, *line; - for (line = ip->line; *line && isspace(*line); line++) { - ; - } - mprAllocSprintf(MPR_LOC_ARGS(ep), &traceLine, MPR_MAX_STRING, - " [%02d] %s, %s, line %d -> %s\n", - frame++, - ip->fileName ? ip->fileName : "script", - ip->procName ? ip->procName: "global", - ip->lineNumber, line); - if (traceLine == 0) { - break; - } - newErrbuf = mprRealloc(ep, errbuf, len + strlen(traceLine) + 1); - if (newErrbuf == NULL) { - break; - } - errbuf = newErrbuf; - memcpy(&errbuf[len], traceLine, strlen(traceLine) + 1); - len += strlen(traceLine); - mprFree(traceLine); - ip = ip->next; - } - return errbuf; -} - -/******************************************************************************/ -/* - * Internal use method to set the error message - * - * Error, ArgError, AssertError, IOError, MemoryError, RangeError, - * ReferenceError, SyntaxError, TypeError, MemoryError - */ - -void ejsError(Ejs* ep, const char *errorType, const char* fmt, ...) -{ - va_list fmtArgs; - EjsVar *error; - char *msg, *stack; - - va_start(fmtArgs, fmt); - mprAllocVsprintf(MPR_LOC_ARGS(ep), &msg, MPR_MAX_STRING, fmt, fmtArgs); - va_end(fmtArgs); - - /* - * Create a new Error exception object. If bad error type, default to - * "Error" - */ - if (ejsGetClass(ep, 0, errorType) == 0) { - errorType = "Error"; - } - ep->gotException = 1; - - error = ejsCreateObj(ep, 0, errorType, msg); - if (error == 0) { - return; - } - mprFree(msg); - - stack = ejsFormatStack(ep); - ejsSetPropertyToString(ep, error, "stack", stack); - mprFree(stack); - - ejsWriteVar(ep, ep->result, error, EJS_SHALLOW_COPY); - ejsFreeVar(ep, error); -} - -/******************************************************************************/ - -void ejsSyntaxError(Ejs *ep, const char *msg) -{ - if (msg == 0) { - msg = " "; - } - ejsError(ep, EJS_SYNTAX_ERROR, msg); -} - -/******************************************************************************/ - -void ejsMemoryError(Ejs *ep) -{ - ejsError(ep, EJS_MEMORY_ERROR, "Memory allocation error"); -} - -/******************************************************************************/ - -void ejsArgError(Ejs *ep, const char *msg) -{ - mprAssert(msg && *msg); - - ejsError(ep, EJS_ARG_ERROR, msg); -} - -/******************************************************************************/ - -void ejsInternalError(Ejs *ep, const char *msg) -{ - mprAssert(msg && *msg); - - ejsError(ep, EJS_INTERNAL_ERROR, msg); -} - -/******************************************************************************/ -/* - * Public routine to set the error message. Caller MUST NOT free. - */ - -char *ejsGetErrorMsg(Ejs *ep) -{ - EjsVar *error; - const char *message, *stack, *name; - char *buf; - - error = ep->result; - - if (! ejsVarIsObject(error)) { - name = message = stack = 0; - } else { - name = ejsGetPropertyAsString(ep, error, "name"); - message = ejsGetPropertyAsString(ep, error, "message"); - stack = ejsGetPropertyAsString(ep, error, "stack"); - } - if (name == 0 || message == 0) { - buf = mprStrdup(ep, "Unspecified execution error\n"); - } else { - mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, - "%s Exception: %s\nStack:\n%s\n", - name, message, stack ? stack : " " ); - } - mprFree(ep->errorMsg); - ep->errorMsg = buf; - return buf; -} - -/******************************************************************************/ -/* - * Get the current line number - */ - -int ejsGetLineNumber(Ejs *ep) -{ - if (ep->input == 0) { - return -1; - } - return ep->input->lineNumber; -} - -/******************************************************************************/ -/* - * Return the local object - */ - -EjsVar *ejsGetLocalObj(Ejs *ep) -{ - return ep->local; -} - -/******************************************************************************/ -/* - * Return the global object - */ - -EjsVar *ejsGetGlobalObj(Ejs *ep) -{ - return ep->global; -} - -/******************************************************************************/ -/* - * Set the expression return value - */ - -void ejsSetReturnValue(Ejs *ep, EjsVar *vp) -{ - mprAssert(ep); - mprAssert(vp); - - if (vp == 0) { - return; - } - ejsWriteVar(ep, ep->result, vp, EJS_SHALLOW_COPY); -} - -/******************************************************************************/ -/* - * Set the expression return value and free the arg. - */ - -void ejsSetReturnValueAndFree(Ejs *ep, EjsVar *vp) -{ - mprAssert(ep); - mprAssert(vp); - - ejsWriteVar(ep, ep->result, vp, EJS_SHALLOW_COPY); - ejsFreeVar(ep, vp); -} - -/******************************************************************************/ -/* - * Set the expression return value to a string value. - */ - -void ejsSetReturnValueToString(Ejs *ep, const char *value) -{ - mprAssert(ep); - mprAssert(value); - - ejsWriteVarAsString(ep, ep->result, value); -} - -/******************************************************************************/ -/* - * Set the expression return value to a binary string value. - */ - -void ejsSetReturnValueToBinaryString(Ejs *ep, const uchar *value, int len) -{ - mprAssert(ep); - mprAssert(value); - - ejsWriteVarAsBinaryString(ep, ep->result, value, len); -} - -/******************************************************************************/ -/* - * Set the expression return value to a integer value. - */ - -void ejsSetReturnValueToInteger(Ejs *ep, int value) -{ - mprAssert(ep); - - ejsWriteVarAsInteger(ep, ep->result, value); -} - -/******************************************************************************/ -/* - * Set the expression return value to an EjsNum value. - */ - -void ejsSetReturnValueToNumber(Ejs *ep, EjsNum value) -{ - mprAssert(ep); - - ejsWriteVarAsNumber(ep, ep->result, value); -} - -/******************************************************************************/ -/* - * Set the expression return value to a boolean value. - */ - -void ejsSetReturnValueToBoolean(Ejs *ep, int value) -{ - mprAssert(ep); - - ejsWriteVarAsBoolean(ep, ep->result, value); -} - -/******************************************************************************/ -/* - * Set the expression return value to a boolean value. - */ - -void ejsSetReturnValueToUndefined(Ejs *ep) -{ - mprAssert(ep); - - ejsWriteVarAsUndefined(ep, ep->result); -} - -/******************************************************************************/ -/* - * Get the expression return value - */ - -EjsVar *ejsGetReturnValue(Ejs *ep) -{ - mprAssert(ep); - - return ep->result; -} - -/******************************************************************************/ - -void *ejsGetUserData(Ejs *ep) -{ - mprAssert(ep); - - return ep->userData; -} - -/******************************************************************************/ -/* - * Get a variable given a full variable spec possibly containing "." or "[]". - */ - -EjsVar *ejsGetVar(Ejs *ep, const char *fullName) -{ - mprAssert(ep); - mprAssert(fullName && *fullName); - - return ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0); -} - -/******************************************************************************/ -/* - * Get a string var given a full variable spec possibly containing "." or "[]". - */ - -const char *ejsGetStr(Ejs *ep, const char *fullName, const char *defaultValue) -{ - EjsVar *vp; - - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0); - if (vp == 0 || !ejsVarIsString(vp)) { - return defaultValue; - } - /* MOB -- what about VarToStr */ - return vp->string; -} - -/******************************************************************************/ -/* - * Get an int var given a full variable spec possibly containing "." or "[]". - */ - -int ejsGetInt(Ejs *ep, const char *fullName, int defaultValue) -{ - EjsVar *vp; - - mprAssert(ep); - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0); - if (vp == 0 || !ejsVarIsInteger(vp)) { - return defaultValue; - } - /* MOB -- should use VarToInt */ - return vp->integer; -} - -/******************************************************************************/ -/* - * Get an bool var given a full variable spec possibly containing "." or "[]". - */ - -int ejsGetBool(Ejs *ep, const char *fullName, int defaultValue) -{ - EjsVar *vp; - - mprAssert(ep); - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 0); - if (vp == 0 || !ejsVarIsBoolean(vp)) { - return defaultValue; - } - /* MOB -- should use VarToBool */ - return vp->boolean; -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. - */ - -int ejsSetVar(Ejs *ep, const char *fullName, const EjsVar *value) -{ - EjsVar *vp; - - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1); - if (vp == 0) { - return MPR_ERR_CANT_CREATE; - } - - if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) == 0) { - return MPR_ERR_CANT_WRITE; - } - - return 0; -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. - */ - -int ejsSetStr(Ejs *ep, const char *fullName, const char *value) -{ - EjsVar *vp; - - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1); - if (vp == 0) { - return MPR_ERR_CANT_CREATE; - } - - if (ejsWriteVarAsString(ep, vp, value) == 0) { - return MPR_ERR_CANT_WRITE; - } - - return 0; -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. - */ - -int ejsSetInt(Ejs *ep, const char *fullName, int value) -{ - EjsVar *vp; - - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1); - if (vp == 0) { - return MPR_ERR_CANT_CREATE; - } - - /* Can't fail */ - ejsWriteVarAsInteger(ep, vp, value); - - return 0; -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. - */ - -int ejsSetBool(Ejs *ep, const char *fullName, bool value) -{ - EjsVar *vp; - - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1); - if (vp == 0) { - return MPR_ERR_CANT_CREATE; - } - - /* Can't fail */ - ejsWriteVarAsBoolean(ep, vp, value); - - return 0; -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. Free the value passed in. - */ - -int ejsSetVarAndFree(Ejs *ep, const char *fullName, EjsVar *value) -{ - EjsVar *vp; - - mprAssert(fullName && *fullName); - - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, fullName, 1); - if (vp == 0) { - return MPR_ERR_CANT_CREATE; - } - - if (ejsWriteVar(ep, vp, value, EJS_SHALLOW_COPY) == 0) { - ejsFreeVar(ep, value); - return MPR_ERR_CANT_WRITE; - } - - ejsFreeVar(ep, value); - return 0; -} - -/******************************************************************************/ -/* - * Delete a variable - */ - -int ejsDeleteVar(Ejs *ep, const char *fullName) -{ - EjsVar *vp; - EjsVar *obj; - char *propertyName; - - vp = ejsFindProperty(ep, &obj, &propertyName, ep->global, ep->local, - fullName, 0); - if (vp == 0) { - return -1; - } - - mprAssert(propertyName); - mprAssert(propertyName); - - return ejsDeleteProperty(ep, obj, propertyName); -} - -/******************************************************************************/ -/* - * Utility routine to crack JavaScript arguments. Return the number of args - * seen. This routine only supports %s and %d type args. - * - * Typical usage: - * - * if (ejsParseArgs(argc, argv, "%s %d", &name, &age) < 2) { - * // Insufficient args - * return -1; - * } - */ - -int ejsParseArgs(int argc, char **argv, const char *fmt, ...) -{ - va_list vargs; - const char *cp; - char **sp, *s; - int *bp, *ip, argn; - - va_start(vargs, fmt); - - if (argv == 0) { - return 0; - } - - for (argn = 0, cp = fmt; cp && *cp && argn < argc && argv[argn]; ) { - if (*cp++ != '%') { - continue; - } - - s = argv[argn]; - switch (*cp) { - case 'b': - bp = va_arg(vargs, int*); - if (bp) { - if (strcmp(s, "true") == 0 || s[0] == '1') { - *bp = 1; - } else { - *bp = 0; - } - } else { - *bp = 0; - } - break; - - case 'd': - ip = va_arg(vargs, int*); - *ip = atoi(s); - break; - - case 's': - sp = va_arg(vargs, char**); - *sp = s; - break; - - default: - mprAssert(0); - } - argn++; - } - - va_end(vargs); - return argn; -} - -/******************************************************************************/ -/* - * Define the standard classes - */ - -int ejsDefineStandardClasses(Ejs *master) -{ - if (ejsDefineArrayClass(master) != 0 || - ejsDefineBooleanClass(master) != 0 || - ejsDefineErrorClasses(master) != 0 || - ejsDefineFunctionClass(master) != 0 || - ejsDefineNumberClass(master) != 0 || -#if FUTURE - ejsDefineDateClass(master) != 0 || -#endif -#if BLD_FEATURE_EJS_E4X - ejsDefineXmlClasses(master) != 0 || -#endif -#if BLD_FEATURE_EJS_DB && NOT_HERE - ejsDefineDbClasses(master) != 0 || -#endif - ejsDefineStringClass(master) != 0) { - return MPR_ERR_MEMORY; - } - return 0; -} - -/******************************************************************************/ -/* - * Define the EJS System Object Model - */ - -int ejsDefineSystemClasses(Ejs *master) -{ - if (ejsDefineSystemClass(master) != 0 || - ejsDefineAppClass(master) != 0 || - ejsDefineMemoryClass(master) != 0 || - ejsDefineLogClass(master) != 0 || - ejsDefineDebugClass(master) != 0 || - ejsDefineGCClass(master) != 0 || - ejsDefineFileSystemClass(master) != 0 || -#if BREW - ejsDefineFileClass(master) != 0 || - ejsDefineHTTPClass(master) != 0 || -#endif - ejsDefineGlobalProperties(master) != 0) { - return MPR_ERR_MEMORY; - } - return 0; -} - -/******************************************************************************/ -/* - * Terminate the system object model and classes - */ - -int ejsTermSystemClasses(Ejs *master) -{ -#if BREW - ejsTermHTTPClass(master); -#endif - return 0; -} - -/******************************************************************************/ -/* - * Define the EJS object model - */ - -int ejsCreateObjectModel(Ejs *ejs) -{ - EjsProperty *pp; - - pp = ejsSetPropertyToNewObj(ejs, ejs->global, "system", "System", 0); - if (pp == 0) { - return MPR_ERR_MEMORY; - } - - if (ejsSetPropertyToNewObj(ejs, ejsGetVarPtr(pp), "app", "System.App", - 0) == 0) { - return MPR_ERR_MEMORY; - } - return 0; -} - -/******************************************************************************/ - -void ejsTrace(Ejs *ep, const char *fmt, ...) -{ - va_list args; - char buf[MPR_MAX_LOG_STRING]; - int len; - - va_start(args, fmt); - len = mprVsprintf(buf, sizeof(buf) - 1, fmt, args); - va_end(args); - - mprLog(ep, 0, buf, len); - - va_end(args); -} - -/******************************************************************************/ - -bool ejsGotException(Ejs *ep) -{ - return (bool) ep->gotException; -} - -/******************************************************************************/ - -void ejsSetPrimaryHandle(Ejs *ep, void *primaryHandle) -{ - mprAssert(ep); - - ep->primaryHandle = primaryHandle; -} - -/******************************************************************************/ - -void ejsSetAlternateHandle(Ejs *ep, void *alternateHandle) -{ - mprAssert(ep); - - ep->altHandle = alternateHandle; -} - -/******************************************************************************/ - -#else -void ejsDummy() {} - -#endif /* BLD_FEATURE_EJS */ - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejs.h b/source4/lib/appweb/ejs-2.0/ejs/ejs.h deleted file mode 100644 index a926446524..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejs.h +++ /dev/null @@ -1,849 +0,0 @@ -/* - * ejs.h - EJScript Language (ECMAScript) header. - */ - -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#ifndef _h_EJS -#define _h_EJS 1 - -#include "mpr.h" -#include "ejsVar.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/********************************* Prototypes *********************************/ -/* - * Constants - */ -#if BLD_FEATURE_SQUEEZE - #define EJS_GC_WORK_QUOTA 160 /* Allocations required before - garbage colllection */ - - #define EJS_PARSE_INCR 256 /* Growth factor */ - #define EJS_MAX_RECURSE 25 /* Sanity for maximum recursion */ - #define EJS_SMALL_OBJ_HASH_SIZE 11 /* Small object hash size */ - #define EJS_LIST_INCR 8 /* Growth increment for lists */ - #define EJS_MAX_BACKTRACE 10 /* Recursion limit for assert */ - -#else - #define EJS_GC_WORK_QUOTA 500 - - #define EJS_PARSE_INCR 1024 - #define EJS_MAX_RECURSE 100 - #define EJS_SMALL_OBJ_HASH_SIZE 11 - #define EJS_LIST_INCR 16 - #define EJS_MAX_BACKTRACE 25 - -#endif - -/* - * Allocation increments for the default interpreter - */ -#define EJS_DEFAULT_VAR_INC 8 /* Var allocation increment */ -#define EJS_DEFAULT_PROP_INC 96 /* Property allocation increment */ -#define EJS_DEFAULT_OBJ_INC 24 /* Object allocation increment */ -#define EJS_DEFAULT_STR_INC 64 /* Object allocation increment */ - -#define EJS_MIN_TIME_FOR_GC 300 /**< Need 1/3 sec for GC */ -#define EJS_GC_MIN_WORK_QUOTA 50 /**< Min to stop thrashing */ - -/* - * Allocation increments for all non-default interpreters - */ -#define EJS_VAR_INC 32 -#define EJS_PROP_INC 64 -#define EJS_OBJ_INC 64 -#define EJS_STR_INC 64 - -#define EJS_INC_FRAMES 8 /* Frame stack increment */ -#define EJS_MAX_FRAMES 64 /* Max frame stack */ - -/* - * Lexical analyser tokens - */ -#define EJS_TOK_ERR -1 /* Any error */ -#define EJS_TOK_LPAREN 1 /* ( */ -#define EJS_TOK_RPAREN 2 /* ) */ -#define EJS_TOK_IF 3 /* if */ -#define EJS_TOK_ELSE 4 /* else */ -#define EJS_TOK_LBRACE 5 /* { */ -#define EJS_TOK_RBRACE 6 /* } */ -#define EJS_TOK_LOGICAL 7 /* ||, &&, ! */ -#define EJS_TOK_EXPR 8 /* +, -, /, % */ -#define EJS_TOK_SEMI 9 /* ; */ -#define EJS_TOK_LITERAL 10 /* literal string */ -#define EJS_TOK_METHOD_NAME 11 /* methodName( */ -#define EJS_TOK_NEWLINE 12 /* newline white space */ -#define EJS_TOK_ID 13 /* Identifier */ -#define EJS_TOK_EOF 14 /* End of script */ -#define EJS_TOK_COMMA 15 /* Comma */ -#define EJS_TOK_VAR 16 /* var */ -#define EJS_TOK_ASSIGNMENT 17 /* = */ -#define EJS_TOK_FOR 18 /* for */ -#define EJS_TOK_INC_DEC 19 /* ++, -- */ -#define EJS_TOK_RETURN 20 /* return */ -#define EJS_TOK_PERIOD 21 /* . */ -#define EJS_TOK_LBRACKET 22 /* [ */ -#define EJS_TOK_RBRACKET 23 /* ] */ -#define EJS_TOK_NEW 24 /* new */ -#define EJS_TOK_DELETE 25 /* delete */ -#define EJS_TOK_IN 26 /* in */ -#define EJS_TOK_FUNCTION 27 /* function */ -#define EJS_TOK_NUMBER 28 /* Number */ -#define EJS_TOK_CLASS 29 /* class */ -#define EJS_TOK_EXTENDS 30 /* extends */ -#define EJS_TOK_PUBLIC 31 /* public */ -#define EJS_TOK_PRIVATE 32 /* private */ -#define EJS_TOK_PROTECTED 33 /* private */ -#define EJS_TOK_TRY 34 /* try */ -#define EJS_TOK_CATCH 35 /* catch */ -#define EJS_TOK_FINALLY 36 /* finally */ -#define EJS_TOK_THROW 37 /* throw */ -#define EJS_TOK_COLON 38 /* : */ -#define EJS_TOK_GET 39 /* get */ -#define EJS_TOK_SET 40 /* set */ -#define EJS_TOK_MODULE 41 /* module */ -#define EJS_TOK_EACH 42 /* each */ - -/* - * Expression operators - */ -#define EJS_EXPR_LESS 1 /* < */ -#define EJS_EXPR_LESSEQ 2 /* <= */ -#define EJS_EXPR_GREATER 3 /* > */ -#define EJS_EXPR_GREATEREQ 4 /* >= */ -#define EJS_EXPR_EQ 5 /* == */ -#define EJS_EXPR_NOTEQ 6 /* != */ -#define EJS_EXPR_PLUS 7 /* + */ -#define EJS_EXPR_MINUS 8 /* - */ -#define EJS_EXPR_DIV 9 /* / */ -#define EJS_EXPR_MOD 10 /* % */ -#define EJS_EXPR_LSHIFT 11 /* << */ -#define EJS_EXPR_RSHIFT 12 /* >> */ -#define EJS_EXPR_MUL 13 /* * */ -#define EJS_EXPR_ASSIGNMENT 14 /* = */ -#define EJS_EXPR_INC 15 /* ++ */ -#define EJS_EXPR_DEC 16 /* -- */ -#define EJS_EXPR_BOOL_COMP 17 /* ! */ - -/* - * Conditional operators - */ -#define EJS_COND_AND 1 /* && */ -#define EJS_COND_OR 2 /* || */ -#define EJS_COND_NOT 3 /* ! */ - -/** - * EJ Parsing States. Error and Return are be negative. - */ -#define EJS_STATE_ERR -1 /**< Error state */ -#define EJS_STATE_RET -2 /**< Return statement */ -#define EJS_STATE_EOF -3 /**< End of file */ -#define EJS_STATE_COND 2 /* Parsing a conditional stmt */ -#define EJS_STATE_COND_DONE 3 -#define EJS_STATE_RELEXP 4 /* Parsing a relational expr */ -#define EJS_STATE_RELEXP_DONE 5 -#define EJS_STATE_EXPR 6 /* Parsing an expression */ -#define EJS_STATE_EXPR_DONE 7 -#define EJS_STATE_STMT 8 /* Parsing General statement */ -#define EJS_STATE_STMT_DONE 9 -#define EJS_STATE_STMT_BLOCK_DONE 10 /* End of block "}" */ -#define EJS_STATE_ARG_LIST 11 /* Method arg list */ -#define EJS_STATE_ARG_LIST_DONE 12 -#define EJS_STATE_DEC_LIST 16 /* Declaration list */ -#define EJS_STATE_DEC_LIST_DONE 17 -#define EJS_STATE_DEC 18 /* Declaration statement */ -#define EJS_STATE_DEC_DONE 19 - -#define EJS_STATE_BEGIN EJS_STATE_STMT - -/* - * General parsing flags. - */ -#define EJS_FLAGS_EXE 0x1 /* Execute statements */ -#define EJS_FLAGS_LOCAL 0x2 /* Get local vars only */ -#define EJS_FLAGS_GLOBAL 0x4 /* Get global vars only */ -#define EJS_FLAGS_CREATE 0x8 /* Create var */ -#define EJS_FLAGS_ASSIGNMENT 0x10 /* In assignment stmt */ -#define EJS_FLAGS_DELETE 0x20 /* Deleting a variable */ -#define EJS_FLAGS_NEW 0x80 /* In a new stmt() */ -#define EJS_FLAGS_EXIT 0x100 /* Must exit */ -#define EJS_FLAGS_LHS 0x200 /* Left-hand-side of assignment */ -#define EJS_FLAGS_FORIN 0x400 /* In "for (v in ..." */ -#define EJS_FLAGS_CLASS_DEC 0x800 /* "class name [extends] name " */ -#define EJS_FLAGS_TRY 0x2000 /* In a try {} block */ -#define EJS_FLAGS_CATCH 0x4000 /* "catch (variable)" */ -#define EJS_FLAGS_DONT_GC 0x8000 /* Don't garbage collect */ -#define EJS_FLAGS_NO_ARGS 0x10000 /* Accessors don't use args */ -#define EJS_FLAGS_ENUM_HIDDEN 0x20000 /* Enumerate hidden fields */ -#define EJS_FLAGS_ENUM_BASE 0x40000 /* Enumerate base classes */ -#define EJS_FLAGS_TRACE_ARGS 0x80000 /* Support for printv */ -#define EJS_FLAGS_SHARED_SLAB 0x100000/* Using a shared slab */ - -/* - * Exceptions - */ -#define EJS_ARG_ERROR "ArgError" /**< Method argument error */ -#define EJS_ASSERT_ERROR "AssertError" /**< Assertion error */ -#define EJS_EVAL_ERROR "EvalError" /**< General evalation error */ -#define EJS_INTERNAL_ERROR "InternalError" /**< Internal error */ -#define EJS_IO_ERROR "IOError" /**< IO or data error */ -#define EJS_MEMORY_ERROR "MemoryError" /**< Memory allocation error */ -#define EJS_RANGE_ERROR "RangeError" /**< Data out of range (div by 0) */ -#define EJS_REFERENCE_ERROR "ReferenceError"/**< Object or property reference */ -#define EJS_SYNTAX_ERROR "SyntaxError" /**< Javascript syntax error */ -#define EJS_TYPE_ERROR "TypeError" /**< Wrong type supplied */ - -/* - * E4X - */ -#if BLD_FEATURE_EJS_E4X -#if BLD_FEATURE_SQUEEZE -#define E4X_BUF_SIZE 512 /* Initial buffer size for tokens */ -#define E4X_BUF_MAX (32 * 1024) /* Max size for tokens */ -#define E4X_MAX_NODE_DEPTH 24 /* Max nesting of tags */ -#else -#define E4X_BUF_SIZE 4096 -#define E4X_BUF_MAX (128 * 1024) -#define E4X_MAX_NODE_DEPTH 128 -#endif - -#define E4X_MAX_ELT_SIZE (E4X_BUF_MAX-1) -#define E4X_TEXT_PROPERTY "-txt" -#define E4X_TAG_NAME_PROPERTY "-tag" -#define E4X_COMMENT_PROPERTY "-com" -#define E4X_ATTRIBUTES_PROPERTY "-att" -#define E4X_PI_PROPERTY "-pi" -#define E4X_PARENT_PROPERTY "-parent" -#endif - -#if BLD_FEATURE_MULTITHREAD -/** - * Multithreaded lock function - */ -typedef void (*EjsLockFn)(void *lockData); -/** - * Multithreaded unlock function - */ -typedef void (*EjsUnlockFn)(void *lockData); -#endif - -/* - * Token limits - */ -#define EJS_MAX_LINE 128 /* Maximum input line buffer */ -#define EJS_MAX_TOKEN 640 /* Max input parse token */ -#define EJS_TOKEN_STACK 3 /* Put back token stack */ - -/* - * Putback token - */ - -typedef struct EjsToken { - char tokbuf[EJS_MAX_TOKEN]; - int tid; /* Token ID */ -} EjsToken; - -/* - * EJ evaluation block structure - */ -typedef struct EjsInput { - EjsToken putBack[EJS_TOKEN_STACK]; /* Put back token stack */ - int putBackIndex; /* Top of stack index */ - char line[EJS_MAX_LINE]; /* Current line */ - char *fileName; /* File or script name */ - int lineLength; /* Current line length */ - int lineNumber; /* Parse line number */ - int lineColumn; /* Column in line */ - struct EjsInput *next; /* Used for backtraces */ - const char *procName; /* Gives name in backtrace */ - const char *script; /* Input script for parsing */ - char *scriptServp; /* Next token in the script */ - int scriptSize; /* Length of script */ - char tokbuf[EJS_MAX_TOKEN]; /* Current token */ - int tid; /* Token ID */ - char *tokEndp; /* Pointer past end of token */ - char *tokServp; /* Pointer to next token char */ - struct EjsInput *nextInput; /* Free list of input structs */ -} EjsInput; - -/* - * Method call structure - */ -typedef struct EjsProc { - MprArray *args; /* Args for method */ - EjsVar *fn; /* Method definition */ - char *procName; /* Method name */ -} EjsProc; - - -/** - * @overview EJScript Service structure - * @description The EJScript service manages the overall language runtime. It - * is the factory that creates interpreter instances via ejsCreateInterp. - * The EJScript service creates a master interpreter that holds the - * standard language classes and properties. When user interpreters are - * created, they reference (without copying) the master interpreter to - * gain access to the standard classes and types. - * @stability Prototype. - * @library libejs. - * @see ejsOpenService, ejsCloseService, ejsCreateInterp, ejsDestoryInterp - */ -typedef struct EjsService { - EjsVar *globalClass; /* Global class */ - struct Ejs *master; /* Master Interp inherited by all */ -#if BLD_FEATURE_MULTITHREAD - EjsLockFn lock; - EjsUnlockFn unlock; - void *lockData; -#endif -} EjsService; - - -/* - * Memory statistics - */ -typedef struct EjsMemStats { - uint maxMem; - uint usedMem; -} EjsMemStats; - - -/* - * Garbage collection block alignment - */ -#define EJS_ALLOC_ALIGN(ptr) \ - (((ptr) + sizeof(void*) - 1) & ~(sizeof(void*) - 1)) - -/* - * Default GC tune factors - */ -#define EJS_GC_START_THRESHOLD (32 * 1024) - -/* - * The Garbage collector is a generational collector. It ages blocks and - * optimizes the mark / sweep algorithm to focus on new and recent blocks - */ -typedef enum EjsGeneration { - EJS_GEN_NEW = 0, - EJS_GEN_RECENT_1 = 1, - EJS_GEN_RECENT_2 = 2, - EJS_GEN_OLD = 3, - EJS_GEN_PERMANENT = 4, - EJS_GEN_MAX = 5, -} EjsGeneration; - -/* - * Garbage collector control - */ -typedef struct EjsGC { - bool enable; - bool enableDemandCollect; - bool enableIdleCollect; - /* - * maxMemory should be set to be 95% of the real max memory limit - */ - uint maxMemory; /* Above this, Throw Memory exception. */ - int workQuota; /* Quota of work before GC */ - int workDone; /* Count of allocations */ - int degraded; /* Have exceeded maxMemory */ - - /* - * Debug Levels 0-N (increases verbosity) - * 1 -- Sweep and collection count - * 2 -- Trace objects deleted - * 3 -- Trace objects marked - * 4 -- Print alloc report when needing a demand allocation - * - */ - int debugLevel; /* In debug mode */ - int collecting; /* Running garbage collection */ - uint collectionCount; /* Number of times GC ran */ -#if BLD_DEBUG - int gcIndent; /* Indent formatting */ - int objectsInUse; /* Objects currently reachable */ - int propertiesInUse; /* Properties currently reachable */ -#endif -} EjsGC; - -/* - * Slab memory allocation - */ -typedef struct EjsSlab { - uint allocIncrement; /* Growth increment in slab */ - uint size; /* Size of allocations */ - EjsGCLink freeList; /* Free list (only next ptr is used) */ - EjsObj *lastRecentBlock; /* Saved for GC age generations phase */ - EjsGCLink allocList[EJS_GEN_MAX]; /* Allocated block list */ - -#if BLD_FEATURE_ALLOC_STATS - uint totalAlloc; /* Total count of allocation calls */ - uint freeCount; /* Number of blocks on the slab freelist */ - uint allocCount; /* Number of allocated blocks */ - uint peakAllocated; /* Peak allocated */ - uint peakFree; /* Peak on the free list */ - uint totalReclaimed; /* Total blocks reclaimed on sweeps */ - uint totalSweeps; /* Total sweeps */ -#endif -} EjsSlab; - - -/** - * @overview EJ interpreter control structure. - * @description EJ allocates one control structure per active interpreter. - * The \ref ejsCreateInterp routine creates the Ejs structure and returns - * a reference to be used in subsequent EJ API calls. - * @stability Prototype. - * @library libejs. - * @see ejsCreateInterp, ejsDestroyInterp, ejsOpenService - */ -struct Ejs { - void *altHandle; /* Alternate callback handle */ - bool castAlloc; /* True if castTemp is allocated */ - char *castTemp; /* Temporary string for casting */ - char *currentClass; /* Current class name */ - EjsVar *currentObj; /* Ptr to current object */ - EjsVar *thisObject; /* Ptr to current "this" */ - EjsProperty *currentProperty; /* Ptr to current property */ - EjsGC gc; /* Garbage collector control */ - char *errorMsg; /* Error message */ - char *fileName; /* File or script name */ - int lineNumber; /* File line number */ - int scriptStatus; /* Status to exit() */ - int flags; /* Flags */ - MprArray *frames; /* List of variable frames */ - EjsVar *global; /* Global object */ - EjsVar *objectClass; /* Object class */ - int gotException; /* Exception thrown */ - EjsInput *input; /* Input evaluation block */ - int depth; /* Recursion depth */ - EjsVar *local; /* Local object */ - int maxDepth; /* Maximum depth for formatting */ - void *primaryHandle; /* primary callback handle */ - EjsProc *proc; /* Current method */ - int recurseCount; /* Recursion counter */ - EjsVar *result; /* Variable result */ - int tid; /* Current token id */ - char *token; /* Pointer to token string */ - EjsVar tokenNumber; /* Parsed number */ - EjsService *service; /* Service object */ - void *userData; /* Method user data */ - - EjsSlab *slabs; /* Memory allocation slabs */ - MprCtx slabAllocContext; /* Allocation context */ - EjsInput *inputList; /* Free list of input structs */ - -#if BLD_FEATURE_MULTITHREAD - EjsLockFn lock; /* Lock method */ - EjsUnlockFn unlock; /* Unlock method */ - void *lockData; /* Lock data argument */ -#endif -#define EJS_MAX_STACK (10 * 1024) - char stack[EJS_MAX_STACK]; /* Local variable stack */ - char *stkPtr; /* Local variable stack ptr */ - void *inputMarker; /* Recurse protection */ -}; - - -typedef struct EjsModule -{ - int dummy; -} EjsModule; - - -/* - * Method callback when using Alternate handles. GaCompat uses these and - * passes the web server request structure via the altHandle. - */ -typedef void *EjsHandle; -typedef int (*EjsAltCMethod)(Ejs *ejs, EjsHandle altHandle, - EjsVar *thisObj, int argc, EjsVar **argv); -typedef int (*EjsAltStringCMethod)(Ejs *ejs, EjsHandle altHandle, - EjsVar *thisObj, int argc, char **argv); - - -/* - * API Constants - */ -#define EJS_USE_OWN_SLAB 1 - -/******************************** Internal API ********************************/ -/* - * Ejs Lex - */ -extern int ejsLexOpenScript(Ejs *ejs, const char *script); -extern void ejsLexCloseScript(Ejs *ejs); -extern int ejsInitInputState(EjsInput *ip); -extern void ejsLexSaveInputState(Ejs *ejs, EjsInput* state); -extern void ejsLexFreeInputState(Ejs *ejs, EjsInput* state); -extern void ejsLexRestoreInputState(Ejs *ejs, EjsInput* state); -extern int ejsLexGetToken(Ejs *ejs, int state); -extern void ejsLexPutbackToken(Ejs *ejs, int tid, char *string); - -/* - * Parsing - */ -extern int ejsParse(Ejs *ejs, int state, int flags); -extern int ejsGetFlags(Ejs *ejs); - -/* - * Create variable scope blocks - */ -extern int ejsOpenBlock(Ejs *ejs); -extern int ejsSetBlock(Ejs *ejs, EjsVar *local); -extern int ejsCloseBlock(Ejs *ejs, int vid); -extern int ejsEvalBlock(Ejs *ejs, char *script, EjsVar *vp); -extern void ejsSetFileName(Ejs *ejs, const char *fileName); - -/* - * Class definitions - */ -extern EjsVar *ejsCreateSimpleClass(Ejs *ejs, EjsVar *baseClass, - const char *className); -extern int ejsDefineObjectClass(Ejs *ejs); -extern int ejsDefineArrayClass(Ejs *ejs); -extern int ejsDefineBooleanClass(Ejs *ejs); -extern int ejsDefineErrorClasses(Ejs *ejs); -extern int ejsDefineFileClass(Ejs *ejs); -extern int ejsDefineFileSystemClass(Ejs *ejs); -extern int ejsDefineHTTPClass(Ejs *ejs); -extern int ejsDefineFunctionClass(Ejs *ejs); -extern int ejsDefineNumberClass(Ejs *ejs); -extern int ejsDefineStringClass(Ejs *ejs); -extern int ejsDefineDateClass(Ejs *ejs); -extern int ejsDefineStandardClasses(Ejs *ejs); - -#if BLD_FEATURE_EJS_E4X -extern int ejsDefineXmlClasses(Ejs *ejs); -extern EjsVar *ejsCreateXml(Ejs *ejs); -#endif - -#if BLD_FEATURE_EJS_DB -extern int ejsDefineDbClasses(Ejs *ejs); -#endif - -/* - * System class definitions - */ -extern int ejsDefineSystemClasses(Ejs *ejs); -extern int ejsDefineSystemClass(Ejs *ejs); -extern int ejsDefineAppClass(Ejs *ejs); -extern int ejsDefineDebugClass(Ejs *ejs); -extern int ejsDefineLogClass(Ejs *ejs); -extern int ejsDefineMemoryClass(Ejs *ejs); -extern int ejsDefineGCClass(Ejs *ejs); -extern int ejsDefineGlobalProperties(Ejs *ejs); - -extern int ejsTermSystemClasses(Ejs *ejs); -extern void ejsTermHTTPClass(Ejs *ejs); - -extern int ejsCreateObjectModel(Ejs *ejs); - -/* - * Class constructors - */ -extern int ejsArrayConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv); -extern int ejsXmlConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv); -extern int ejsXmlListConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv); -extern int ejsBooleanConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **agv); -extern int ejsFunctionConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **agv); -extern int ejsNumberConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv); -extern int ejsStringConstructor(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv); -extern int ejsDateConstructor(Ejs *ejs, EjsVar *thisObj, - int argc, EjsVar **argv); - -/* - * Garbage collection - */ -extern void ejsGCInit(Ejs *ejs, int objInc, int propInc, int varInc, - int strInc); -extern int ejsIsTimeForGC(Ejs *ep, int timeTillNextEvent); - -extern bool ejsSetGCDebugLevel(Ejs *ep, int debugLevel); -extern void ejsSweepAll(Ejs *ep); - -extern EjsObj *ejsAllocObj(EJS_LOC_DEC(ejs, loc)); -extern EjsProperty *ejsAllocProperty(EJS_LOC_DEC(ejs, loc)); -extern EjsVar *ejsAllocVar(EJS_LOC_DEC(ejs, loc)); -extern void ejsFree(Ejs *ejs, void *ptr, int slabIndex); - -extern int ejsCollectGarbage(Ejs *ejs, int slabIndex); -extern int ejsIncrementalCollectGarbage(Ejs *ejs); - -#if BLD_DEBUG -extern void ejsDumpObjects(Ejs *ejs); -#endif - -#if BLD_FEATURE_ALLOC_STATS -extern void ejsPrintAllocReport(Ejs *ejs, bool printLeakReport); -#endif - -extern void ejsCleanInterp(Ejs *ejs, bool doStats); -extern void ejsSetInternalMethods(Ejs *ejs, EjsVar *op); -extern void ejsSetPrimaryHandle(Ejs *ep, void *primaryHandle); -extern void ejsSetAlternateHandle(Ejs *ep, void *alternateHandle); -extern void *ejsGetUserData(Ejs *ejs); - -/* - * Could possibly make these routines public - */ - -extern int ejsSetGCMaxMemory(Ejs *ep, uint maxMemory); -extern uint ejsGetUsedMemory(Ejs *ejs); -extern uint ejsGetAllocatedMemory(Ejs *ejs); -extern uint ejsGetAvailableMemory(Ejs *ejs); -extern char *ejsFormatStack(Ejs* ep);; - -/********************************* Prototypes *********************************/ -#if BLD_FEATURE_MULTITHREAD -extern int ejsSetServiceLocks(EjsService *sp, EjsLockFn lock, - EjsUnlockFn unlock, void *data); -#endif - -/* - * Ejs service and interpreter management - */ -extern EjsService *ejsOpenService(MprCtx ctx); -extern void ejsCloseService(EjsService *sp, bool doStats); - -extern Ejs *ejsCreateInterp(EjsService *sp, void *primaryHandle, - void *altHandle, EjsVar *global, bool useOwnSlab); -extern void ejsDestroyInterp(Ejs *ejs, bool doStats); - -extern Ejs *ejsGetMasterInterp(EjsService *sp); -extern EjsVar *ejsGetGlobalClass(Ejs *ejs); - -/* - * Module support - */ -extern EjsModule *ejsCreateModule(const char *name, const char *version, - int (*start)(EjsModule*), int (*stop)(EjsModule*)); - -/* - * Native Objects - */ - -void ejsSetNativeData(EjsVar *obj, void *data); -void ejsSetNativeHelpers(Ejs *ejs, EjsVar *nativeClass, - int (*createInstance)(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv), - void (*disposeInstance)(Ejs *ejs, EjsVar *thisObj), - bool (*hasProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop), - int (*deleteProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop), - int (*getProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop, - EjsVar *dest), - int (*setProperty)(Ejs *ejs, EjsVar *thisObj, const char *prop, - EjsVar *value), - int (*doOperator)(Ejs *ejs, EjsVar *thisObj, EjsOp *op, EjsVar - *result, EjsVar *lhs, EjsVar *rhs, int *code) - ); - -/* - * Evaluation methods - */ -extern int ejsEvalFile(Ejs *ejs, const char *path, EjsVar *result); -extern int ejsEvalScript(Ejs *ejs, const char *script, EjsVar *result); -extern int ejsRunMethod(Ejs *ejs, EjsVar *obj, - const char *methodName, MprArray *args); -extern int ejsRunMethodCmd(Ejs *ejs, EjsVar *obj, - const char *methodName, const char *cmdFmt, ...); -extern EjsVar *ejsGetReturnValue(Ejs *ejs); - -extern EjsVar *ejsGetLocalObj(Ejs *ejs); -extern EjsVar *ejsGetGlobalObj(Ejs *ejs); - -/* - * Define a class in the specified interpreter. If used with the default - * interpeter, then the class is defined for all interpreters. - */ -extern EjsVar *ejsDefineClass(Ejs *ejs, const char *className, - const char *extends, EjsCMethod constructor); -extern EjsVar *ejsGetClass(Ejs *ejs, EjsVar *parentClass, - const char *className); - -extern const char *ejsGetClassName(EjsVar *obj); -extern const char *ejsGetBaseClassName(EjsVar *obj); - -extern bool ejsIsSubClass(EjsVar *target, EjsVar *baseClass); -extern EjsVar *ejsGetBaseClass(EjsVar *obj); -extern void ejsSetBaseClass(EjsVar *obj, EjsVar *baseClass); - - -#define ejsCreateSimpleObj(ejs, className) \ - ejsCreateSimpleObjInternal(EJS_LOC_ARGS(ejs), className) -extern EjsVar *ejsCreateSimpleObjInternal(EJS_LOC_DEC(ejs, loc), - const char *className); - -#define ejsCreateSimpleObjUsingClass(ejs, baseClass) \ - ejsCreateSimpleObjUsingClassInt(EJS_LOC_ARGS(ejs), \ - baseClass) -extern EjsVar *ejsCreateSimpleObjUsingClassInt(EJS_LOC_DEC(ejs, loc), - EjsVar *baseClass); - -/* - * This will create an object and call all required constructors - */ -extern EjsVar *ejsCreateObj(Ejs *ejs, EjsVar *obj, - const char *className, const char *constructorArgs); - -#define ejsCreateObjUsingArgv(ejs, obj, className, args) \ - ejsCreateObjUsingArgvInternal(EJS_LOC_ARGS(ejs), obj, \ - className, args) -extern EjsVar *ejsCreateObjUsingArgvInternal(EJS_LOC_DEC(ejs, loc), - EjsVar *obj, const char *className, MprArray *args); - -#define ejsCreateArray(ejs, size) \ - ejsCreateArrayInternal(EJS_LOC_ARGS(ejs), size) -extern EjsVar *ejsCreateArrayInternal(EJS_LOC_DEC(ejs, loc), - int size); - -/* - * Array methods. MOB -- need other array methods - */ -/* MOB -- spell out element */ -extern EjsVar *ejsAddArrayElt(Ejs *ejs, EjsVar *op, EjsVar *element, - EjsCopyDepth copyDepth); -/* - * Required: Array methods - * - array = obj.getMethods(); - array = obj.getProperties(); - - array.property.isPublic(); - array.property.isPrivate(); - array.property.isMethod(); - array.property.isEnumerable(); - array.property.isReadOnly(); - array.property.allowsNonUnique(); - array.property.getParent(); -*/ - -/* MOB -- should we have an API that takes a EjsCopyDepth */ -extern void ejsSetReturnValue(Ejs *ejs, EjsVar *vp); -extern void ejsSetReturnValueAndFree(Ejs *ejs, EjsVar *vp); -extern void ejsSetReturnValueToBoolean(Ejs *ejs, bool value); -extern void ejsSetReturnValueToBinaryString(Ejs *ejs, - const uchar *value, int len); -extern void ejsSetReturnValueToInteger(Ejs *ejs, int value); -extern void ejsSetReturnValueToNumber(Ejs *ejs, EjsNum value); -extern void ejsSetReturnValueToString(Ejs *ejs, const char *value); -extern void ejsSetReturnValueToUndefined(Ejs *ejs); - -/* - * Variable access and control. The fullName arg can contain "[]" and "." - */ -extern bool ejsGetBool(Ejs *ejs, const char *fullName, bool defaultValue); -extern int ejsGetInt(Ejs *ejs, const char *fullName, int defaultValue); -extern const char *ejsGetStr(Ejs *ejs, const char *fullName, - const char *defaultValue); -extern EjsVar *ejsGetVar(Ejs *ejs, const char *fullName); - -extern int ejsSetBool(Ejs *ejs, const char *fullName, bool value); -extern int ejsSetInt(Ejs *ejs, const char *fullName, int value); -extern int ejsSetStr(Ejs *ejs, const char *fullName, const char *value); -extern int ejsSetVar(Ejs *ejs, const char *fullName, const EjsVar *value); -extern int ejsSetVarAndFree(Ejs *ejs, const char *fullName, EjsVar *value); - -extern int ejsDeleteVar(Ejs *ejs, const char *fullName); - -/* - * Error handling - */ -extern void ejsError(Ejs *ejs, const char *errorType, const char *fmt, - ...) PRINTF_ATTRIBUTE(3,4); -/* MOB -- this should take no arguments */ -extern void ejsArgError(Ejs *ejs, const char *msg); -extern void ejsInternalError(Ejs *ejs, const char *msg); -extern void ejsMemoryError(Ejs *ejs); -extern void ejsSyntaxError(Ejs *ejs, const char *msg); - -/* - * Utility methods - */ -extern int ejsParseArgs(int argc, char **argv, const char *fmt, ...); - -extern void ejsExit(Ejs *ejs, int status); -extern bool ejsIsExiting(Ejs *ejs); -extern void ejsClearExiting(Ejs *ejs); - -extern bool ejsGotException(Ejs *ejs); - -/* MOB -- rename Method to Function */ -extern void ejsFreeMethodArgs(Ejs *ep, MprArray *args); -extern int ejsStrcat(Ejs *ep, EjsVar *dest, EjsVar *src); - -/* - * Debugging routines - */ -extern char *ejsGetErrorMsg(Ejs *ejs); -extern int ejsGetLineNumber(Ejs *ejs); -extern void ejsTrace(Ejs *ejs, const char *fmt, ...); - -/* - * Multithreaded lock routines - */ -#if BLD_FEATURE_MULTITHREAD -#define ejsLock(sp) if (sp->lock) { (sp->lock)(sp->lockData); } else -#define ejsUnlock(sp) if (sp->unlock) { (sp->unlock)(sp->lockData); } else -#else -#define ejsLock(sp) -#define ejsUnlock(sp) -#endif - -#ifdef __cplusplus -} -#endif -#endif /* _h_EJS */ - -/*****************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsClass.c b/source4/lib/appweb/ejs-2.0/ejs/ejsClass.c deleted file mode 100644 index 58609adf3f..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsClass.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * @file ejsClass.c - * @brief EJS class support - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************* Includes ***********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/************************************ Code ************************************/ -/* - * Internal API - * - * Routine to create a simple class object. This routine will create a - * stand-alone class object. Callers must insert this into the relevant - * "global" object for name resolution. From these class objects, instance - * objects may be created via the javascript "new" command. - * - * Users should use ejsDefineClass - */ - -EjsVar *ejsCreateSimpleClass(Ejs *ep, EjsVar *baseClass, const char *className) -{ - EjsProperty *pp; - EjsVar *classObj; - - /* - * Create an instance of an Object to act as the static class object - */ - classObj = ejsCreateSimpleObjUsingClass(ep, baseClass); - if (classObj == 0) { - mprAssert(classObj); - return 0; - } - ejsSetClassName(ep, classObj, className); - - /* - * Set the propotype property to point to this class. - * Note: this is a self reference so the alive bit will not be turned on. - */ - pp = ejsSetProperty(ep, classObj, "prototype", classObj); - ejsMakePropertyEnumerable(pp, 0); - - return classObj; -} - -/******************************************************************************/ -/* - * Define a class in the given interpreter. If parentClass is specified, the - * class is defined in the parent. Otherwise, the class will be defined - * locally/globally. ClassName and extends are full variable specs - * (may contain ".") - */ - -EjsVar *ejsDefineClass(Ejs *ep, const char *className, const char *extends, - EjsCMethod constructor) -{ - EjsVar *parentClass, *classObj, *baseClass, *vp; - char *name; - char *cp; - - /* - * If the className is a qualified name (with "."), then get the - * parent class name. - */ - name = mprStrdup(ep, className); - cp = strrchr(name, '.'); - if (cp != 0) { - *cp++ = '\0'; - className = cp; - parentClass = ejsFindProperty(ep, 0, 0, ep->global, ep->local, name, 0); - if (parentClass == 0 || parentClass->type != EJS_TYPE_OBJECT) { - mprError(ep, MPR_LOC, "Can't find class's parent class %s", name); - mprFree(name); - return 0; - } - - } else { - /* - * Simple class name without a "." so create the class locally - * if a local scope exists, otherwise globally. - */ - parentClass = (ep->local) ? ep->local : ep->global; - } - - if (parentClass == 0) { - mprError(ep, MPR_LOC, "Can't find parent class"); - mprFree(name); - return 0; - } - - /* OPT should use function that doesn't parse [] . */ - baseClass = ejsGetClass(ep, 0, extends); - if (baseClass == 0) { - mprAssert(baseClass); - mprFree(name); - return 0; - } - - classObj = ejsCreateSimpleClass(ep, baseClass, className); - if (classObj == 0) { - mprAssert(classObj); - mprFree(name); - return 0; - } - - if (constructor) { - ejsDefineCMethod(ep, classObj, className, constructor, 0); - } - - ejsSetPropertyAndFree(ep, parentClass, className, classObj); - - vp = ejsGetPropertyAsVar(ep, parentClass, className); - mprFree(name); - - return vp; -} - -/******************************************************************************/ -/* - * Find a class and return the property defining the class. ClassName may - * contain "." and is interpreted relative to obj. Obj is typically some - * parent object, ep->local or ep->global. If obj is null, then the global - * space is used. - */ - -EjsVar *ejsGetClass(Ejs *ep, EjsVar *obj, const char *className) -{ - EjsVar *vp; - - mprAssert(ep); - - /* - * Search first for a constructor of the name of class - * global may not be defined yet. - */ - if (obj) { - vp = ejsFindProperty(ep, 0, 0, obj, 0, className, 0); - - } else { - mprAssert(ep->global); - vp = ejsFindProperty(ep, 0, 0, ep->global, ep->local, className, 0); - } - if (vp == 0 || vp->type != EJS_TYPE_OBJECT) { - return 0; - } - - /* - * Return a reference to the prototype (self) reference. This - * ensures that even if "obj" is deleted, this reference will remain - * usable. - */ - return ejsGetPropertyAsVar(ep, vp, "prototype"); -} - -/******************************************************************************/ -/* - * Return the class name of a class or object - */ - -const char *ejsGetClassName(EjsVar *vp) -{ - EjsObj *obj; - - mprAssert(vp); - mprAssert(vp->type == EJS_TYPE_OBJECT); - mprAssert(vp->objectState->baseClass); - - if (vp == 0 || !ejsVarIsObject(vp)) { - return 0; - } - obj = vp->objectState; - - return obj->className; -} - -/******************************************************************************/ -/* - * Return the class name of an objects underlying class - * If called on an object, it returns the base class. - * If called on a class, it returns the base class for the class. - */ - -const char *ejsGetBaseClassName(EjsVar *vp) -{ - EjsObj *obj; - - mprAssert(vp); - mprAssert(vp->type == EJS_TYPE_OBJECT); - mprAssert(vp->objectState->baseClass); - - if (vp == 0 || !ejsVarIsObject(vp)) { - return 0; - } - obj = vp->objectState; - if (obj->baseClass == 0) { - return 0; - } - mprAssert(obj->baseClass->objectState); - - return obj->baseClass->objectState->className; -} - -/******************************************************************************/ - -EjsVar *ejsGetBaseClass(EjsVar *vp) -{ - if (vp == 0 || !ejsVarIsObject(vp) || vp->objectState == 0) { - mprAssert(0); - return 0; - } - return vp->objectState->baseClass; -} - -/******************************************************************************/ - -void ejsSetBaseClass(EjsVar *vp, EjsVar *baseClass) -{ - if (vp == 0 || !ejsVarIsObject(vp) || vp->objectState == 0) { - mprAssert(0); - return; - } - vp->objectState->baseClass = baseClass; -} - -/******************************************************************************/ - -#else -void ejsProcsDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c b/source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c deleted file mode 100644 index 74b57de4d0..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsCmd.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * @file ejsCmd.c - * @brief Embedded JavaScript (EJS) command line program. - * @overview - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS && !BREW - -/************************************ Defines *********************************/ - -#define EJS_MAX_CMD_LINE (16 * 1024) -#define EJS_MAX_SCRIPT (4 * 1024 * 1024) -#define EJS_MAX_RESULT_SIZE (4 * 1024 * 1024) -#define EJS_PROMPT "ejs> " - -/****************************** Forward Declarations **************************/ - -static int parseFile(EjsService *ejsService, Ejs *ejs, const char *fileName, - const char *testName, MprFile *testLogFile); -static int ifConsole(); - -static int interactiveUse(MprApp *app, Ejs *ejs, FILE *input, - char *fileName); -static char *readCmd(MprApp *app, FILE *input); - -static int memoryFailure(MprApp *app, uint size, uint total, bool granted); - -static int isConsole = 0; -static int traceCmds = 0; -static int stats = 0; -static int verbose = 0; - -/************************************ Main ************************************/ - -int main(int argc, char *argv[]) -{ - MprApp *app; - const char *programName; - MprFile *testLogFile; - EjsService *ejsService; - Ejs *ejs; - char *commandLine; - const char *testName; - char *argp, *cmd, *testLog; - int i, rc, nextArg, err, len, firstArg, iterations, debugLevel; - - app = mprInit(memoryFailure); - - isConsole = ifConsole(); - programName = mprGetBaseName(argv[0]); - debugLevel = 0; - - ejsService = ejsOpenService(app); - if (ejsService == 0) { - mprError(app, MPR_LOC, "Can't initialize the EJS service."); - return -1; - } - - err = 0; - iterations = 1; - stats = 0; - testLog = getenv("TEST_LOG"); - testLogFile = 0; - testName = 0; - - for (nextArg = 1; nextArg < argc; nextArg++) { - argp = argv[nextArg]; - if (*argp != '-') { - break; - } - if (strcmp(argp, "--debug") == 0) { - if (nextArg >= argc) { - err++; - } else { - debugLevel = atoi(argv[++nextArg]); - } - - } else if (strcmp(argp, "--stats") == 0) { - stats++; - - } else if (strcmp(argp, "--trace") == 0) { - traceCmds++; - - } else if (strcmp(argp, "--iterations") == 0) { - if (nextArg >= argc) { - err++; - } else { - iterations = atoi(argv[++nextArg]); - } - - } else if (strcmp(argp, "--log") == 0) { - /* Get file to log test results to when using ejs as a test shell */ - if (nextArg >= argc) { - err++; - } else { - testLog = argv[++nextArg]; - } - - } else if (strcmp(argp, "--testName") == 0) { - if (nextArg >= argc) { - err++; - } else { - testName = argv[++nextArg]; - } - - } else if (strcmp(argp, "-v") == 0) { - verbose++; - - } else if (strcmp(argp, "-vv") == 0) { - verbose += 2; - - } else if (strcmp(argp, "--verbose") == 0) { - verbose += 2; - - } else { - err++; - break; - } - if (err) { - mprErrorPrintf(app, - "Usage: %s [options] files... or\n" - " %s < file or\n" - " %s or\n" - " Switches:\n" - " --iterations num # Number of iterations to eval file\n" - " --stats # Output stats on exit\n" - " --testName name # Set the test name", - programName, programName, programName); - return -1; - } - } - - if (testName) { - i = 0; - commandLine = 0; - len = mprAllocStrcat(MPR_LOC_ARGS(app), &commandLine, 0, " ", - mprGetBaseName(argv[i++]), NULL); - for (; i < argc; i++) { - len = mprReallocStrcat(MPR_LOC_ARGS(app), &commandLine, 0, len, - " ", argv[i], NULL); - } - mprPrintf(app, " %s\n", commandLine); - } - if (testLog) { - testLogFile = mprOpen(app, testLog, - O_CREAT | O_APPEND | O_WRONLY | O_TEXT, 0664); - if (testLogFile == 0) { - mprError(app, MPR_LOC, "Can't open %s", testLog); - return MPR_ERR_CANT_OPEN; - } - mprFprintf(testLogFile, "\n %s\n", commandLine); - } - - ejs = ejsCreateInterp(ejsService, 0, 0, 0, 0); - if (ejs == 0) { - mprError(app, MPR_LOC, "Can't create EJS interpreter"); - ejsCloseService(ejsService, stats); - if (testLogFile) { - mprClose(testLogFile); - } - mprTerm(app, stats); - exit(-1); - } - - if (debugLevel > 0) { - ejsSetGCDebugLevel(ejs, debugLevel); - } - - rc = 0; - - if (nextArg < argc) { - /* - * Process files supplied on the command line - */ - firstArg = nextArg; - for (i = 0; i < iterations; i++) { - for (nextArg = firstArg; nextArg < argc; nextArg++) { - rc = parseFile(ejsService, ejs, argv[nextArg], testName, - testLogFile); - if (rc < 0) { - return rc; - } - } - } - if (testName) { - if (verbose == 1) { - mprPrintf(app, "\n"); - } - if (verbose <= 1) { - mprPrintf(app, " # PASSED all tests for \"%s\"\n", testName); - } - } - - } else if (! isConsole) { - /* - * Read a script from stdin - */ - cmd = readCmd(app, stdin); - - ejsSetFileName(ejs, "stdin"); - - rc = ejsEvalScript(ejs, cmd, 0); - if (rc < 0) { - mprPrintf(app, "ejs: Error: %s\n", ejsGetErrorMsg(ejs)); - } - mprFree(cmd); - - } else { - /* - * Interactive use. Read commands from the command line. - */ - rc = interactiveUse(app, ejs, stdin, "stdin"); - } - - /* - * Cleanup. Do stats if required. - */ - if (ejs) { - ejsCleanInterp(ejs, 0); - ejsCleanInterp(ejs->service->master, 0); - ejsDestroyInterp(ejs, 0); - } - - ejsCloseService(ejsService, stats); - - if (testLogFile) { - mprClose(testLogFile); - } - - mprTerm(app, stats); - return rc; -} - -/******************************************************************************/ - -static int parseFile(EjsService *ejsService, Ejs *ejs, const char *fileName, - const char *testName, MprFile *testLogFile) -{ - int rc; - - if (testName && verbose == 1) { - mprPrintf(ejs, "."); - } - if (verbose > 1) { - mprPrintf(ejs, "File: %s\n", fileName); - } - - rc = ejsEvalFile(ejs, fileName, 0); - - if (testName) { - char fileBuf[MPR_MAX_FNAME], *cp; - mprStrcpy(fileBuf, sizeof(fileBuf), fileName); - if ((cp = strstr(fileBuf, ".ejs")) != 0) { - *cp = '\0'; - } - if (rc == 0) { - if (verbose > 1) { - mprPrintf(ejs, " # PASSED test \"%s.%s\"\n", testName, - fileBuf); - } - if (testLogFile) { - mprFprintf(testLogFile, " # PASSED test \"%s.%s\"\n", - testName, fileBuf); - } - - } else { - - mprPrintf(ejs, "FAILED test \"%s.%s\"\nDetails: %s\n", - testName, fileBuf, ejsGetErrorMsg(ejs)); - - if (testLogFile) { - mprFprintf(testLogFile, - "FAILED test \"%s.%s\"\nDetails: %s\n", - testName, fileBuf, ejsGetErrorMsg(ejs)); - } - } - } else if (rc < 0) { - mprPrintf(ejs, "ejs: %sIn file \"%s\"\n", - ejsGetErrorMsg(ejs), fileName); - } - return rc; -} - -/******************************************************************************/ - -static char *readCmd(MprApp *app, FILE *input) -{ - char line[EJS_MAX_CMD_LINE]; - char *cmd; - int len, cmdLen; - - cmd = 0; - cmdLen = 0; - - line[sizeof(line) - 1] = '\0'; - - while (1) { - - if (fgets(line, sizeof(line) - 1, input) == NULL) { - break; - } - - len = strlen(line); - - if (line[len - 1] == '\\') { - line[len - 1] = '\0'; - } - cmdLen = mprReallocStrcat(MPR_LOC_ARGS(app), &cmd, EJS_MAX_SCRIPT, - cmdLen, 0, line, NULL); - } - return cmd; -} - -/******************************************************************************/ - -static int interactiveUse(MprApp *app, Ejs *ejs, FILE *input, char *fileName) -{ - EjsVar result; - char line[EJS_MAX_CMD_LINE]; - char *cmd, *buf; - int len, cmdLen, rc; - - cmd = 0; - cmdLen = 0; - - line[sizeof(line) - 1] = '\0'; - - ejsSetFileName(ejs, "console"); - - while (! ejsIsExiting(ejs)) { - - if (isConsole) { - write(1, EJS_PROMPT, strlen(EJS_PROMPT)); - } - - if (fgets(line, sizeof(line) - 1, input) == NULL) { - break; - } - - len = strlen(line); - while (len > 0 && - (line[len - 1] == '\n' || line[len - 1] == '\r')) { - len--; - line[len] = '\0'; - } - - if (line[len - 1] == '\\') { - line[len - 1] = '\0'; - cmdLen = mprReallocStrcat(MPR_LOC_ARGS(app), &cmd, EJS_MAX_SCRIPT, - cmdLen, 0, line, NULL); - - } else { - - cmdLen = mprReallocStrcat(MPR_LOC_ARGS(app), &cmd, EJS_MAX_SCRIPT, - cmdLen, 0, line, NULL); - - - if (traceCmds) { - mprPrintf(ejs, "# %s\n", cmd); - } - - if (cmd[0] == 0x4 || cmd[0] == 0x26 || strcmp(cmd, "quit") == 0) { - ejsExit(ejs, 0); - - } else if ((rc = ejsEvalScript(ejs, cmd, &result)) < 0) { - - mprPrintf(app, "ejs: Error: %s\n", ejsGetErrorMsg(ejs)); - - if (! isConsole) { - return rc; - } - - } else { - if (isConsole || traceCmds) { - buf = ejsVarToString(ejs, &result); - mprPrintf(ejs, "%s\n", buf); - } - } - mprFree(cmd); - cmd = 0; - cmdLen = 0; - } - } - return 0; -} - -/******************************************************************************/ - -static int ifConsole() -{ -#if WIN - INPUT_RECORD irec[1]; - int records = 0; - - if (PeekConsoleInput(GetStdHandle(STD_INPUT_HANDLE), irec, 1, - &records) != 0) { - return 1; - } -#else - return isatty(0); -#endif - return 0; -} - -/******************************************************************************/ - -static int memoryFailure(MprApp *app, uint size, uint total, bool granted) -{ - if (!granted) { - mprPrintf(app, "Can't allocate memory block of size %d\n", size); - mprPrintf(app, "Total memory used %d\n", total); - exit(255); - } - mprPrintf(app, "Memory request for %d bytes exceeds memory red-line\n", - size); - mprPrintf(app, "Total memory used %d\n", total); - return 0; -} - -/******************************************************************************/ - -#else -void ejsCmdLineDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c b/source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c deleted file mode 100755 index 264da05721..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsGarbage.c +++ /dev/null @@ -1,1214 +0,0 @@ -/* - * @file ejsGarbage.c - * @brief EJS Garbage collector. - * @overview This implements a generational mark and sweep collection scheme. - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ - -static void mark(Ejs *ep); -static void markObjByVar(Ejs *ep, EjsVar *op); -static void markObj(EjsObj *obj); -static void markPerm(Ejs *ep, uint gen); -static int sweep(Ejs *ep, uint gen); -static EjsGCLink *ejsAlloc(EJS_LOC_DEC(ep, loc), int slabIndex); -static void ejsGracefulDegrade(Ejs *ep); -static void resetMarks(Ejs *ep, EjsSlab *slab); - -#if FUTURE -static void ageGenerations(Ejs *ep); -#endif - -#if BLD_DEBUG && (!BREW || BREW_SIMULATOR) -uint breakAddr; -#endif - -/************************************* Code ***********************************/ - -void ejsGCInit(Ejs *ep, int objInc, int propInc, int varInc, int strInc) -{ - EjsSlab *slab; - - if (ep->service && ep->service->globalClass) { - ep->service->globalClass->objectState->gcMarked = 1; - } - - slab = &ep->slabs[EJS_SLAB_OBJ]; - slab->allocIncrement = objInc; - slab->size = EJS_ALLOC_ALIGN(sizeof(EjsObj)); - - slab = &ep->slabs[EJS_SLAB_PROPERTY]; - slab->allocIncrement = propInc; - slab->size = EJS_ALLOC_ALIGN(sizeof(EjsProperty)); - - slab = &ep->slabs[EJS_SLAB_VAR]; - slab->allocIncrement = varInc; - slab->size = EJS_ALLOC_ALIGN(sizeof(EjsVar)); - - /* - * Initialize GC. - * Enable GC both idle and demand collections. - * Set no limits and garbage collect if the slabs are - * empty and we have used more than the THRESHOLD of ram. - */ - ep->gc.debugLevel = 0; - ep->gc.enable = 1; - ep->gc.enableIdleCollect = 1; - ep->gc.enableDemandCollect = 1; - ep->gc.workQuota = EJS_GC_WORK_QUOTA; - ep->gc.maxMemory = 0; -} - - -/******************************************************************************/ -#if BLD_FEATURE_ALLOC_STATS - -void ejsPrintAllocReport(Ejs *ep, bool printLeakReport) -{ - EjsSlab *slab; - char *name; - int slabIndex, isObj; - - for (slabIndex = 0; slabIndex < EJS_SLAB_MAX; slabIndex++) { - slab = &ep->slabs[slabIndex]; - if (slabIndex == EJS_SLAB_VAR) { - name = "var"; - } else if (slabIndex == EJS_SLAB_PROPERTY) { - name = "prop"; - } else { - name = "obj"; - } - mprLog(ep, 0, " "); - mprLog(ep, 0, " GC \"%s\" local slab", name); - mprLog(ep, 0, " Total blocks %14d", - slab->allocCount + slab->freeCount); - mprLog(ep, 0, " Block size %14d", slab->size); - mprLog(ep, 0, " Slab RAM allocated %14d", - (slab->allocCount + slab->freeCount) * slab->size); - mprLog(ep, 0, " Slab RAM in use %14d", - slab->allocCount * slab->size); - mprLog(ep, 0, " Blocks in use %14d", slab->allocCount); - mprLog(ep, 0, " Free blocks %14d", slab->freeCount); - mprLog(ep, 0, " Peak allocated %14d", slab->peakAllocated); - mprLog(ep, 0, " Peak free %14d", slab->peakFree); - mprLog(ep, 0, " Total allocations %14d", slab->totalAlloc); - mprLog(ep, 0, " Total blocks reclaimed %14d", slab->totalReclaimed); - mprLog(ep, 0, " Total sweeps %14d", slab->totalSweeps); - mprLog(ep, 0, " Allocation inc %14d", slab->allocIncrement); - } - - mprLog(ep, 0, " "); - mprLog(ep, 0, " Total EJS memory in use %10d", ejsGetUsedMemory(ep)); - mprLog(ep, 0, " Total EJS memory allocated %10d", - ejsGetAllocatedMemory(ep)); - - if (printLeakReport) { - mprLog(ep, 0, " "); - for (slabIndex = 0; slabIndex < EJS_SLAB_MAX; slabIndex++) { - int size; - - slab = &ep->slabs[slabIndex]; - - isObj = 0; - mprLog(ep, 0, " "); - if (slabIndex == EJS_SLAB_VAR) { - name = "var"; - size = sizeof(EjsVar); - } else if (slabIndex == EJS_SLAB_PROPERTY) { - name = "prop"; - size = sizeof(EjsProperty); - } else { - name = "obj"; - size = sizeof(EjsObj); - isObj++; - } -#if BLD_FEATURE_ALLOC_LEAK_TRACK -{ - EjsGCLink *lp; - EjsObj *obj; - int count; - - mprLog(ep, 0, "EJS Leak Report for \"%s\"", name); - count = 0; - - for (lp = slab->allocList[0].next; lp; lp = lp->next) { - mprLog(ep, 0, " %-20s %10d", lp->allocatedBy, size); - if (isObj) { - obj = (EjsObj*) lp; - mprLog(ep, 0, " %-20s %10d %s %s", - lp->allocatedBy, size, - obj->permanent ? "permanent" : "", - obj->alive ? "alive" : "" - ); - } else { - mprLog(ep, 0, " %-20s %10d", lp->allocatedBy, - size); - } - count++; - } - mprLog(ep, 0, " Total blocks %14d", count); -} -#endif - } - mprLog(ep, 0, " "); - } -} - -#endif -/******************************************************************************/ -/* - * Slab allocator - */ - -static EjsGCLink *ejsAlloc(EJS_LOC_DEC(ep, loc), int slabIndex) -{ - EjsSlab *slab; - EjsGCLink *block; - EjsGC *gc; - uint allocatedMemory; - int i; - - mprStackCheck(ep); - - if (slabIndex < 0 || slabIndex >= EJS_SLAB_MAX) { - mprAssert(0); - return 0; - } - - /* - * See if the slab has some free blocks - */ - slab = &ep->slabs[slabIndex]; - if ((block = slab->freeList.next) == 0) { - - allocatedMemory = ejsGetAllocatedMemory(ep); - gc = &ep->gc; - - /* - * No blocks available. If demand collection is enabled, try - * to garbage collect first. We collect if we have done a good - * work quota or we are over the max memory limit. - */ - if (slabIndex != EJS_SLAB_VAR && - ep->gc.enable && ep->gc.enableDemandCollect) { - if ((ep->gc.workDone > ep->gc.workQuota) || - (gc->maxMemory > 0 && allocatedMemory > gc->maxMemory)) { - -#if DEBUG_USE_ONLY - if (ep->gc.debugLevel > 0) { - mprLog(ep, 0, "Need GC, EJS RAM %d, MPR RAM %d\n", - allocatedMemory, mprGetAllocatedMemory(ep)); - if (ep->gc.debugLevel > 4) { - ejsPrintAllocReport(ep, 0); - } - } -#endif - if (ejsCollectGarbage(ep, slabIndex) == 0) { - block = slab->freeList.next; - } - } - } - - if (block == 0) { - if (gc->maxMemory > 0 && allocatedMemory > gc->maxMemory) { - /* - * We are above the max memory limit. We will fail this - * memory allocation, but allow subsequent allocations to - * permit error recovery. We gracefully degrade by setting - * slab chunk sizes to 1. This minimizes real memory - * consumption. This allows us to create - * an exception block to be created by upper layers. - */ - if (! gc->degraded) { - ejsGracefulDegrade(ep); - return 0; - } - } - - /* - * Still non available, so allocate more memory for a set of blocks - * OPT -- should bypass mprAlloc. Need mprMalloc. - */ - block = mprAlloc(ep->slabAllocContext, - slab->size * slab->allocIncrement); - if (block == 0) { - /* - * Now we're in trouble. We should really never get here - * as the graceful degrade will have signaled a memory - * allocation failure. - */ - mprAssert(block != 0); - return 0; - } - - /* - * Chain all the blocks together onto the slab free list - */ - for (i = slab->allocIncrement - 1; i >= 0; i--) { - block->next = slab->freeList.next; -#if BLD_DEBUG - block->magic = EJS_MAGIC_FREE; -#endif - slab->freeList.next = block; - block = (EjsGCLink*) ((char*) block + slab->size); - } - - block = slab->freeList.next; - -#if BLD_FEATURE_ALLOC_STATS - slab->freeCount += slab->allocIncrement; - if (slab->freeCount > slab->peakFree) { - slab->peakFree = slab->freeCount; - } -#endif - } - } - - /* - * We use block to point to the user data in the block. We only - * store the magic number (if debug). No other data is stored in the - * user block. - */ -#if BLD_DEBUG - mprAssert(block->magic == EJS_MAGIC_FREE); -#endif - - /* - * Remove from the free list - */ - slab->freeList.next = block->next; - - /* - * Zero block - */ - memset(block, 0, slab->size); - -#if BLD_DEBUG - block->magic = EJS_MAGIC; -#endif - -#if BLD_FEATURE_ALLOC_STATS - slab->totalAlloc++; - if (++slab->allocCount > slab->peakAllocated) { - slab->peakAllocated = slab->allocCount; - } - slab->freeCount--; -#endif - -#if BLD_DEBUG && (!BREW || BREW_SIMULATOR) - if ((uint) block == breakAddr) { - mprBreakpoint(MPR_LOC, "Watched Block"); - } -#endif - return block; -} - - -/******************************************************************************/ - -EjsObj *ejsAllocObj(EJS_LOC_DEC(ep, loc)) -{ - EjsObj *obj; - EjsSlab *slab; - - obj = (EjsObj*) ejsAlloc(EJS_LOC_PASS(ep, loc), EJS_SLAB_OBJ); - - /* - * Add to the allocated block list for the New generation. - */ - if (obj) { - slab = &ep->slabs[EJS_SLAB_OBJ]; - obj->gc.next = slab->allocList[EJS_GEN_NEW].next; - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - obj->gc.allocatedBy = loc; -#endif - - obj->ejs = ep; - slab->allocList[EJS_GEN_NEW].next = (EjsGCLink*) obj; - - ep->gc.workDone++; - } - - return obj; -} - - -/******************************************************************************/ - -EjsProperty *ejsAllocProperty(EJS_LOC_DEC(ep, loc)) -{ - EjsProperty *prop; - - prop = (EjsProperty*) ejsAlloc(EJS_LOC_PASS(ep, loc), EJS_SLAB_PROPERTY); - mprAssert(prop); - - if (prop) { - prop->var.type = EJS_TYPE_NULL; - prop->var.isProperty = 1; -#if BLD_FEATURE_ALLOC_LEAK_TRACK - prop->var.gc.allocatedBy = loc; -#endif - } - return prop; -} - - -/******************************************************************************/ - -EjsVar *ejsAllocVar(EJS_LOC_DEC(ep, loc)) -{ - EjsVar *vp; - - vp = (EjsVar*) ejsAlloc(EJS_LOC_PASS(ep, loc), EJS_SLAB_VAR); - mprAssert(vp); - - if (vp) { -#if BLD_FEATURE_ALLOC_LEAK_TRACK - EjsSlab *slab; - vp->gc.allocatedBy = loc; - slab = &ep->slabs[EJS_SLAB_VAR]; - vp->gc.next = slab->allocList[EJS_GEN_NEW].next; - slab->allocList[EJS_GEN_NEW].next = (EjsGCLink*) vp; -#endif -#if BLD_DEBUG - vp->propertyName = 0; -#endif - } - return vp; -} - - -/******************************************************************************/ -/* - * Return the block back to the relevant slab - */ - -void ejsFree(Ejs *ep, void *ptr, int slabIndex) -{ - EjsSlab *slab; - EjsGCLink *block; - - mprAssert(ep); - mprAssert(ptr); - - if (slabIndex < 0 || slabIndex >= EJS_SLAB_MAX) { - mprAssert(slabIndex >= 0 && slabIndex < EJS_SLAB_MAX); - return; - } - slab = &ep->slabs[slabIndex]; - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - if (slabIndex == EJS_SLAB_VAR) { - EjsVar *vp, *np, *prev; - - /* - * Remove the block rom the alloc list. WARNING: this is slow - * and should not be used in production code. - */ - vp = (EjsVar*) ptr; - prev = 0; - for (np = (EjsVar*) slab->allocList[0].next; np; - np = (EjsVar*) np->gc.next) { - if (vp == np) { - if (prev) { - prev->gc.next = (EjsGCLink*) np->gc.next; - } else { - slab->allocList[0].next = (EjsGCLink*) np->gc.next; - } - break; - } - prev = np; - } - if (np == 0) { - mprAssert(0); - } - } -#endif - - /* - * Insert into the free list. Only use the next ptr - */ - block = (EjsGCLink*) ptr; - -#if BLD_DEBUG -#if !BREW || BREW_SIMULATOR - if ((uint) block == breakAddr) { - mprBreakpoint(MPR_LOC, "Watched Block"); - } -#endif - mprAssert(block->magic == EJS_MAGIC); - block->magic = EJS_MAGIC_FREE; -#endif - - block->next = slab->freeList.next; - slab->freeList.next = block; - -#if BLD_FEATURE_ALLOC_STATS - slab->allocCount--; - if (++slab->freeCount >= slab->peakFree) { - slab->peakFree = slab->freeCount; - } - slab->totalReclaimed++; - if (slabIndex != 2) { - slabIndex = slabIndex; - } -#endif -} - -/******************************************************************************/ -/* - * Mark an object as being in-use. Traverse all properties for referenced - * objects and base classes. - */ - -static void markObjByVar(Ejs *ep, EjsVar *obj) -{ - EjsProperty *pp; - EjsVar *vp, *baseClass; - - mprAssert(ep); - mprAssert(obj); - - obj->objectState->gcMarked = 1; - -#if BLD_DEBUG - if (ep->gc.debugLevel >= 3) { - int indent = min(ep->gc.gcIndent * 2, 32); - mprLog(ep, 0, "%.*s %-24s %.*s 0x%08X", - indent, " ", - obj->propertyName, - 32 - indent, "................................ ", - (uint) obj->objectState); - ep->gc.gcIndent++; - } - ep->gc.objectsInUse++; -#endif - - /* - * Traverse all referenced objects - * OPT -- optimize by directly accessing the object links and not using - * ejsGetFirst/NextProperty. Then just examine objects - * OPT -- first property in global is global. Should optimize this. - */ - pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL); - while (pp) { - vp = ejsGetVarPtr(pp); - if (vp->type == EJS_TYPE_OBJECT) { - if (!vp->objectState->gcMarked) { -#if FUTURE - /* - * OPT -- we can use the dirty bit on objects to avoid - * visiting permanent objects that are clean. If so, don't - * forget the else case below. - */ - obj = vp->objectState; - if ((!obj->alive && !obj->permanent) || obj->dirty) -#endif - markObjByVar(ep, vp); - } - - } else { -#if BLD_DEBUG - if (ep->gc.debugLevel >= 3) { - int indent = min(ep->gc.gcIndent * 2, 32); - mprLog(ep, 0, "%.*s %-24s %.*s %s", - indent, " ", - vp->propertyName, - 32 - indent, "................................ ", - ejsGetVarTypeAsString(vp)); - } - ep->gc.propertiesInUse++; -#endif - } - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - - /* - * Traverse the base class - */ - baseClass = obj->objectState->baseClass; - if (baseClass) { - mprAssert(baseClass->type == EJS_TYPE_OBJECT); - mprAssert(baseClass->objectState); - if (baseClass->objectState) { - if (! baseClass->objectState->gcMarked) { - markObjByVar(ep, baseClass); - } - } - } -#if BLD_DEBUG - if (ep->gc.debugLevel >= 3) { - ep->gc.gcIndent--; - } -#endif -} - - -/******************************************************************************/ -/* - * Mark phase. Examine all variable frames and the return result. - */ - -static void mark(Ejs *ep) -{ - EjsVar *vp; - int i; - -#if BLD_DEBUG - if (ep->gc.debugLevel >= 3) { - mprLog(ep, 0, " "); - mprLog(ep, 0, "GC: Marked Blocks:"); - } -#endif - - if (ep->frames) { - for (i = 0; i < mprGetItemCount(ep->frames); i++) { - - vp = (EjsVar*) mprGetItem(ep->frames, i); - mprAssert(vp->type == EJS_TYPE_OBJECT); - - if (! vp->objectState->gcMarked) { - markObjByVar(ep, vp); - } - } - } - - vp = ep->result; - if (vp && vp->type == EJS_TYPE_OBJECT && ! vp->objectState->gcMarked) { - markObjByVar(ep, vp); - } - - vp = ep->currentObj; - if (vp && vp->type == EJS_TYPE_OBJECT && ! vp->objectState->gcMarked) { - markObjByVar(ep, vp); - } - - vp = ejsGetVarPtr(ep->currentProperty); - if (vp && vp->type == EJS_TYPE_OBJECT && ! vp->objectState->gcMarked) { - markObjByVar(ep, vp); - } - - /* - * OPT -- we could mark master as "mark permanent" somehow and - * then we would not need to walk the master objects. - */ - if (ep->slabAllocContext == ep->service->master) { - if (ep->service->master->global) { - markObjByVar(ep, ep->service->master->global); - } - } - -#if BLD_DEBUG - if (ep->gc.debugLevel >= 3) { - mprLog(ep, 0, " "); - } -#endif -} - - -/******************************************************************************/ -#if UNUSED - -static void resetMark(EjsVar *obj) -{ - EjsProperty *pp; - EjsVar *vp, *baseClass; - - obj->objectState->gcMarked = 0; - obj->objectState->visited = 1; - - pp = ejsGetFirstProperty(obj, EJS_ENUM_ALL); - while (pp) { - vp = ejsGetVarPtr(pp); - if (vp->type == EJS_TYPE_OBJECT && !vp->objectState->visited) { - resetMark(vp); - } - pp = ejsGetNextProperty(pp, EJS_ENUM_ALL); - } - - baseClass = obj->objectState->baseClass; - if (baseClass) { - mprAssert(baseClass->type == EJS_TYPE_OBJECT); - mprAssert(baseClass->objectState); - if (baseClass->objectState) { - if (! baseClass->objectState->visited) { - resetMark(baseClass); - } - } - } - obj->objectState->visited = 0; -} - -/******************************************************************************/ -/* - * Mark phase. Examine all variable frames and the return result. - */ - -static void resetAllMarks(Ejs *ep) -{ - EjsVar *vp; - int i; - - for (i = 0; i < mprGetItemCount(ep->frames); i++) { - vp = (EjsVar*) mprGetItem(ep->frames, i); - resetMark(vp); - } - - if (ep->result && ep->result->type == EJS_TYPE_OBJECT && - ! ep->result->objectState->gcMarked) { - resetMark(ep->result); - } -} - -#endif -/******************************************************************************/ -/* - * Sweep up the garbage - */ - -static void resetMarks(Ejs *ep, EjsSlab *slab) -{ - EjsVar *vp; - EjsObj *obj; - int gen, i; - - for (gen = EJS_GEN_NEW; gen < EJS_GEN_MAX; gen++) { - obj = (EjsObj*) slab->allocList[gen].next; - for (; obj; obj = (EjsObj*) obj->gc.next) { - obj->gcMarked = 0; - obj->visited = 0; - } - } - - if (ep->frames) { - for (i = 0; i < mprGetItemCount(ep->frames); i++) { - - vp = (EjsVar*) mprGetItem(ep->frames, i); - mprAssert(vp->type == EJS_TYPE_OBJECT); - - vp->objectState->gcMarked = 0; - vp->objectState->visited = 0; - } - } - - if (ep->result && ep->result->type == EJS_TYPE_OBJECT) { - ep->result->objectState->gcMarked = 0; - } -} - -/******************************************************************************/ -/* - * Mark all permanent and non-alive objects - */ - -static void markPerm(Ejs *ep, uint gen) -{ - EjsSlab *slab; - EjsObj *obj; - - slab = &ep->slabs[EJS_SLAB_OBJ]; - - for (obj = (EjsObj*) slab->allocList[gen].next; obj; ) { - - if (! obj->gcMarked) { - if (!obj->alive || obj->permanent) { - markObj(obj); - } - } - obj = (EjsObj*) obj->gc.next; - - } -} - -/******************************************************************************/ - -static void markObj(EjsObj *obj) -{ - EjsProperty *pp; - EjsPropLink *lp, *head; - EjsObj *op; - - mprAssert(obj); - - obj->gcMarked = 1; - - head = &obj->link; - for (lp = head->next; lp != head; lp = lp->next) { - - pp = ejsGetPropertyFromLink(lp); - - if (pp->var.type == EJS_TYPE_OBJECT) { - op = pp->var.objectState; - if (op != 0 && !op->gcMarked) { - markObj(op); - } - } - } -} - -/******************************************************************************/ -/* - * Sweep up the garbage. Return the number of objects freed. - */ - -static int sweep(Ejs *ep, uint gen) -{ - EjsSlab *slab; - EjsObj *obj, *next, *prev; - int count; - - slab = &ep->slabs[EJS_SLAB_OBJ]; - - /* - * Examine allocated objects in the specified generation (only). - * NOTE: we only sweep object allocated to this interpreter and so - * we do not sweep any permanent objects in the default interpreter. - */ - prev = 0; - count = 0; - for (obj = (EjsObj*) slab->allocList[gen].next; obj; obj = next) { - - next = (EjsObj*) obj->gc.next; - -#if BLD_DEBUG && (!BREW || BREW_SIMULATOR) - if ((uint) obj == breakAddr) { - mprBreakpoint(MPR_LOC, "Watched Block"); - } -#endif - - /* - * If object has not been marked inuse and is not a permanent - * object, then free it. - */ - if (! obj->gcMarked && obj->alive && !obj->permanent) { - -#if BLD_DEBUG - if (ep->gc.debugLevel >= 2) { - if (obj->objName) { - mprLog(ep, 0, "GC: destroy %-18s %10d, %8X", - obj->objName, (uint) obj, (uint) obj); - } else { - mprLog(ep, 0, "GC: destroy UNKNOWN %x", (uint) obj); - } - } -#endif - if (ejsDestroyObj(ep, obj) < 0) { - prev = obj; - obj->gcMarked = 0; - continue; - } - - if (prev) { - prev->gc.next = (EjsGCLink*) next; - } else { - slab->allocList[gen].next = (EjsGCLink*) next; - } - count++; - - } else { - prev = obj; - /* Reset for next time */ - obj->gcMarked = 0; - } - } - - if (gen == (EJS_GEN_OLD - 1)) { - slab->lastRecentBlock = prev; - } -#if BLD_FEATURE_ALLOC_STATS - slab->totalSweeps++; -#endif -#if BLD_DEBUG - if (ep->gc.debugLevel > 0) { - mprLog(ep, 0, "GC: Sweep freed %d objects", count); - } -#endif - return count; -} - -/******************************************************************************/ -/* - * Sweep all variables - */ - -void ejsSweepAll(Ejs *ep) -{ - EjsSlab *slab; - EjsObj *obj, *next, *prev; - int gen; - - slab = &ep->slabs[EJS_SLAB_OBJ]; - - for (gen = EJS_GEN_NEW; gen < EJS_GEN_MAX; gen++) { - prev = 0; - for (obj = (EjsObj*) slab->allocList[gen].next; obj; obj = next) { - next = (EjsObj*) obj->gc.next; - ejsDestroyObj(ep, obj); - } - break; - } -} - -/******************************************************************************/ - -bool ejsObjIsCollectable(EjsVar *vp) -{ - if (vp == 0 || !ejsVarIsObject(vp)) { - return 0; - } - return (vp->objectState->alive && !vp->objectState->permanent); -} - -/******************************************************************************/ -#if FUTURE - -static void ageGenerations(Ejs *ep) -{ - EjsSlab *slab; - EjsGCLink *oldList; - int gen; - - slab = &ep->slabs[EJS_SLAB_OBJ]; - - /* - * Age all blocks. First append all (old - 1) blocks onto the old - * alloc list - */ - oldList = &slab->allocList[EJS_GEN_OLD]; - - if (slab->lastRecentBlock) { - slab->lastRecentBlock->gc.next = oldList->next; - oldList->next = (EjsGCLink*) slab->lastRecentBlock; - } - - /* - * Now simply copy all allocation lists up one generation - */ - for (gen = EJS_GEN_OLD - 1; gen > 0; gen--) { - slab->allocList[gen] = slab->allocList[gen - 1]; - } - slab->allocList[0].next = 0; -} - -#endif -/******************************************************************************/ -/* - * Collect the garbage. This is a mark and sweep over all possible objects. - * If an object is not referenced, it and all contained properties will be - * freed. If a slabIndex is provided, the collection halts when a block is - * available for allocation on that slab. - * - * Return 0 if memory is now available after collecting garbage. Otherwise, - * return MPR_ERR_MEMORY. - */ - -int ejsCollectGarbage(Ejs *ep, int slabIndex) -{ - EjsGeneration gen; - - if (ep->flags & EJS_FLAGS_DONT_GC) { - return -1; - } - - /* - * Prevent destructors invoking the garbage collector - */ - if (ep->gc.collecting) { - return 0; - } - ep->gc.collecting = 1; - - resetMarks(ep, &ep->slabs[EJS_SLAB_OBJ]); - - /* - * Examine each generation of objects starting with the most recent - * generation. Stop scanning when we have a free block to use. - */ - for (gen = EJS_GEN_NEW; gen < EJS_GEN_MAX; gen++) { - - if (slabIndex >= 0 && ep->slabs[slabIndex].freeList.next) { - break; - } - - /* - * FUTURE OPT. Should mark objects in new generation and those - * with a dirty bit set in older generations. Don't need to mark - * entire heap. But how to keep list of dirty objects. - */ - mark(ep); - markPerm(ep, gen); - sweep(ep, gen); - - /* FUTURE - not using generations yet */ - break; - } - - /* - * FUTURE -- not using generations yet. - * - * ageGenerations(ep); - */ - - ep->gc.workDone = 0; - ep->gc.collecting = 0; - - return (gen < EJS_GEN_MAX) ? 0 : MPR_ERR_MEMORY; -} - - -/******************************************************************************/ -/* - * Should be called when the app has been idle for a little while and when it - * is likely to be idle a bit longer. Call ejsIsTimeForGC to see if this is - * true. Return the count of objects collected . - */ - -int ejsIncrementalCollectGarbage(Ejs *ep) -{ - int count; - - if (ep->gc.collecting) { - return 0; - } - - ep->gc.collecting = 1; - - resetMarks(ep, &ep->slabs[EJS_SLAB_OBJ]); - mark(ep); - - /* Not generational yet */ - count = sweep(ep, EJS_GEN_NEW); - - ep->gc.collecting = 0; - ep->gc.workDone = 0; - - return count; -} - -/******************************************************************************/ -#if BLD_DEBUG - -void ejsDumpObjects(Ejs *ep) -{ - int oldDebugLevel; - - mprLog(ep, 0, "Dump of objects in use\n"); - - oldDebugLevel = ep->gc.debugLevel; - - ep->gc.debugLevel = 3; - ep->gc.objectsInUse = 0; - ep->gc.propertiesInUse = 0; - ep->gc.collecting = 1; - - resetMarks(ep, &ep->slabs[EJS_SLAB_OBJ]); - mark(ep); - - ep->gc.collecting = 0; - ep->gc.debugLevel = oldDebugLevel; - - mprLog(ep, 0, "%d objects and %d properties in use", - ep->gc.objectsInUse, ep->gc.propertiesInUse); - mprLog(ep, 0, "%d object bytes, %d property bytes and %d total", - (int) (ep->gc.objectsInUse * sizeof(EjsObj)), - (int) (ep->gc.propertiesInUse * sizeof(EjsProperty)), - (int) ((ep->gc.objectsInUse * sizeof(EjsObj) + - ep->gc.propertiesInUse * sizeof(EjsProperty)))); -} - -#endif -/******************************************************************************/ -/* - * Return true if there is time to do a garbage collection and if we will - * benefit from it. - */ - -int ejsIsTimeForGC(Ejs *ep, int timeTillNextEvent) -{ - EjsGC *gc; - - if (timeTillNextEvent < EJS_MIN_TIME_FOR_GC) { - /* - * Not enough time to complete a collection - */ - return 0; - } - - gc = &ep->gc; - - /* - * Return if we haven't done enough work to warrant a collection - * Trigger a little short of the work quota to try to run GC before - * a demand allocation requires it. - */ - if (!gc->enable || !gc->enableIdleCollect || - (gc->workDone < (gc->workQuota - EJS_GC_MIN_WORK_QUOTA))) { - return 0; - } - -#if UNUSED - mprLog(ep, 0, "Time for GC. Work done %d, time till next event %d", - gc->workDone, timeTillNextEvent); -#endif - return 1; -} - -/******************************************************************************/ -/* - * Return the amount of memory in use by EJS - */ - -uint ejsGetUsedMemory(Ejs *ep) -{ -#if BLD_FEATURE_ALLOC_STATS - EjsSlab *slab; - int i, totalMemory, slabMemory; - - totalMemory = 0; - for (i = 0; i < EJS_SLAB_MAX; i++) { - slab = &ep->slabs[i]; - slabMemory = slab->allocCount * slab->size; - totalMemory += slabMemory; - } - return totalMemory; -#else - return 0; -#endif -} - -/******************************************************************************/ -/* - * Return the amount of memory allocated by EJS - */ - -uint ejsGetAllocatedMemory(Ejs *ep) -{ -#if BLD_FEATURE_ALLOC_STATS - EjsSlab *slab; - int i, totalMemory, slabMemory; - - totalMemory = 0; - for (i = 0; i < EJS_SLAB_MAX; i++) { - slab = &ep->slabs[i]; - slabMemory = (slab->allocCount + slab->freeCount) * slab->size; - totalMemory += slabMemory; - } - return totalMemory; -#else - return 0; -#endif -} - -/******************************************************************************/ -/* - * On a memory allocation failure, go into graceful degrade mode. Set all - * slab allocation chunk increments to 1 so we can create an exception block - * to throw. - */ - -static void ejsGracefulDegrade(Ejs *ep) -{ - EjsSlab *slab; - int i; - - mprLog(ep, 1, "WARNING: Memory almost depleted. In graceful degrade mode"); - for (i = 0; i < EJS_SLAB_MAX; i++) { - slab = &ep->slabs[i]; - slab->allocIncrement = 8; - } - ep->gc.degraded = 1; -} - -/******************************************************************************/ - -int ejsSetGCDebugLevel(Ejs *ep, int debugLevel) -{ - int old; - - old = ep->gc.debugLevel; - ep->gc.debugLevel = debugLevel; - return old; -} - -/******************************************************************************/ - -int ejsSetGCMaxMemory(Ejs *ep, uint maxMemory) -{ - int old; - - old = ep->gc.maxMemory; - ep->gc.maxMemory = maxMemory; - - return old; -} - -/******************************************************************************/ - -bool ejsBlockInUseInt(EjsVar *vp) -{ - if (vp) { -#if BLD_DEBUG - if (vp->gc.magic != EJS_MAGIC) { - return 0; - } - if (vp->type == EJS_TYPE_OBJECT && vp->objectState && - vp->objectState->gc.magic != EJS_MAGIC) { - return 0; - } -#endif - return 1; - } - return 1; -} - -/******************************************************************************/ -#else -void ejsGarbageDummy() {} - -#endif /* BLD_FEATURE_EJS */ - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsLex.c b/source4/lib/appweb/ejs-2.0/ejs/ejsLex.c deleted file mode 100644 index fbfee6e4d5..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsLex.c +++ /dev/null @@ -1,1033 +0,0 @@ -/* - * @file ejsLex.c - * @brief EJS Lexical Analyser - * @overview EJS lexical analyser. This implementes a lexical analyser - * for a subset of the JavaScript language. - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ - -static int getLexicalToken(Ejs *ep, int state); -static int tokenAddChar(Ejs *ep, int c); -static int inputGetc(Ejs *ep); -static void inputPutback(Ejs *ep, int c); -static int charConvert(Ejs *ep, int base, int maxDig); -static void parseNumber(Ejs *ep, EjsType type); - -/************************************* Code ***********************************/ -/* - * Open a new input script - */ - -int ejsLexOpenScript(Ejs *ep, const char *script) -{ - EjsInput *ip; - - mprAssert(ep); - mprAssert(script); - - if ((ip = mprAllocTypeZeroed(ep, EjsInput)) == NULL) { - return MPR_ERR_MEMORY; - } - ip->next = ep->input; - ep->input = ip; - ip->procName = ep->proc ? ep->proc->procName : NULL; - ip->fileName = ep->fileName ? ep->fileName : NULL; - -/* - * Create the parse token buffer and script buffer - */ - ip->tokServp = ip->tokbuf; - ip->tokEndp = ip->tokbuf; - - ip->script = script; - ip->scriptSize = strlen(script); - ip->scriptServp = (char*) ip->script; - - ip->lineNumber = 1; - ip->lineColumn = 0; - - ip->putBackIndex = -1; - - return 0; -} - -/******************************************************************************/ -/* - * Close the input script - */ - -void ejsLexCloseScript(Ejs *ep) -{ - EjsInput *ip; - - mprAssert(ep); - - ip = ep->input; - mprAssert(ip); - ep->input = ip->next; - - mprFree(ip); -} - -/******************************************************************************/ -/* - * Initialize an input state structure - */ - -int ejsInitInputState(EjsInput *ip) -{ - mprAssert(ip); - - memset(ip, 0, sizeof(*ip)); - ip->putBackIndex = -1; - - return 0; -} -/******************************************************************************/ -/* - * Save the input state - */ - -void ejsLexSaveInputState(Ejs *ep, EjsInput *state) -{ - EjsInput *ip; - int i; - - mprAssert(ep); - - ip = ep->input; - mprAssert(ip); - - *state = *ip; - - for (i = 0; i <= ip->putBackIndex; i++) { - mprStrcpy(state->putBack[i].tokbuf, EJS_MAX_TOKEN, - ip->putBack[i].tokbuf); - state->putBack[i].tid = ip->putBack[i].tid; - } - - mprStrcpy(state->line, sizeof(state->line), ip->line); - - state->lineColumn = ip->lineColumn; - state->lineNumber = ip->lineNumber; -} - -/******************************************************************************/ -/* - * Restore the input state - */ - -void ejsLexRestoreInputState(Ejs *ep, EjsInput *state) -{ - EjsInput *ip; - EjsToken *tp; - int i; - - mprAssert(ep); - mprAssert(state); - - ip = ep->input; - mprAssert(ip); - - mprStrcpy(ip->tokbuf, sizeof(ip->tokbuf), state->tokbuf); - ip->tokServp = state->tokServp; - ip->tokEndp = state->tokEndp; - - ip->script = state->script; - ip->scriptServp = state->scriptServp; - ip->scriptSize = state->scriptSize; - - ip->putBackIndex = state->putBackIndex; - for (i = 0; i <= ip->putBackIndex; i++) { - tp = &ip->putBack[i]; - tp->tid = state->putBack[i].tid; - mprStrcpy(tp->tokbuf, sizeof(tp->tokbuf), state->putBack[i].tokbuf); - } - - mprStrcpy(ip->line, sizeof(ip->line), state->line); - - ip->lineColumn = state->lineColumn; - ip->lineNumber = state->lineNumber; -} - -/******************************************************************************/ -/* - * Free a saved input state - */ - -void ejsLexFreeInputState(Ejs *ep, EjsInput *state) -{ - mprAssert(ep); - mprAssert(state); - - state->putBackIndex = -1; - state->lineColumn = 0; -} - -/******************************************************************************/ -/* - * Get the next EJS token - */ - -int ejsLexGetToken(Ejs *ep, int state) -{ - mprAssert(ep); - - ep->tid = getLexicalToken(ep, state); - return ep->tid; -} - -/******************************************************************************/ - -/* - * Check for reserved words "if", "else", "var", "for", "delete", "function", - * "class", "extends", "public", "private", "protected", "try", "catch", - * "finally", "throw", "return", "get", "set", "this", "module", "each" - * - * The "new" and "in" reserved words are handled below. The "true", "false", - * "null" "typeof" and "undefined" reserved words are handled as global - * objects. - * - * Other reserved words not supported: - * "break", "case", "continue", "default", "do", - * "instanceof", "switch", "while", "with" - * - * ECMA extensions reserved words (not supported): - * "abstract", "boolean", "byte", "char", "const", - * "debugger", "double", "enum", "export", - * "final", "float", "goto", "implements", "import", "int", - * "interface", "long", "native", "package", - * "short", "static", "super", "synchronized", "transient", "volatile" - * - * FUTURE -- use a hash lookup - */ - -static int checkReservedWord(Ejs *ep, int state, int c, int tid) -{ - /* FUTURE -- probably should return for all tokens != EJS_TOK_ID */ - /* FUTURE -- Should have a hash for this. MUCH faster. */ - - if (!isalpha(ep->token[0]) || tid == EJS_TOK_LITERAL) { - return tid; - } - if (state == EJS_STATE_STMT) { - /* FUTURE OPT -- convert to hash lookup */ - if (strcmp(ep->token, "if") == 0) { - inputPutback(ep, c); - return EJS_TOK_IF; - } else if (strcmp(ep->token, "else") == 0) { - inputPutback(ep, c); - return EJS_TOK_ELSE; - } else if (strcmp(ep->token, "var") == 0) { - inputPutback(ep, c); - return EJS_TOK_VAR; - } else if (strcmp(ep->token, "new") == 0) { - inputPutback(ep, c); - return EJS_TOK_NEW; - } else if (strcmp(ep->token, "for") == 0) { - inputPutback(ep, c); - return EJS_TOK_FOR; - } else if (strcmp(ep->token, "delete") == 0) { - inputPutback(ep, c); - return EJS_TOK_DELETE; - } else if (strcmp(ep->token, "function") == 0) { - inputPutback(ep, c); - return EJS_TOK_FUNCTION; - } else if (strcmp(ep->token, "class") == 0) { - inputPutback(ep, c); - return EJS_TOK_CLASS; - } else if (strcmp(ep->token, "module") == 0) { - inputPutback(ep, c); - return EJS_TOK_MODULE; - } else if (strcmp(ep->token, "extends") == 0) { - inputPutback(ep, c); - return EJS_TOK_EXTENDS; - } else if (strcmp(ep->token, "try") == 0) { - inputPutback(ep, c); - return EJS_TOK_TRY; - } else if (strcmp(ep->token, "catch") == 0) { - inputPutback(ep, c); - return EJS_TOK_CATCH; - } else if (strcmp(ep->token, "finally") == 0) { - inputPutback(ep, c); - return EJS_TOK_FINALLY; - } else if (strcmp(ep->token, "throw") == 0) { - inputPutback(ep, c); - return EJS_TOK_THROW; - } else if (strcmp(ep->token, "public") == 0) { - inputPutback(ep, c); - return EJS_TOK_PUBLIC; - } else if (strcmp(ep->token, "protected") == 0) { - inputPutback(ep, c); - return EJS_TOK_PROTECTED; - } else if (strcmp(ep->token, "private") == 0) { - inputPutback(ep, c); - return EJS_TOK_PRIVATE; - } else if (strcmp(ep->token, "get") == 0) { - inputPutback(ep, c); - return EJS_TOK_GET; - } else if (strcmp(ep->token, "set") == 0) { - inputPutback(ep, c); - return EJS_TOK_SET; - } else if (strcmp(ep->token, "extends") == 0) { - inputPutback(ep, c); - return EJS_TOK_EXTENDS; - } else if (strcmp(ep->token, "try") == 0) { - inputPutback(ep, c); - return EJS_TOK_TRY; - } else if (strcmp(ep->token, "catch") == 0) { - inputPutback(ep, c); - return EJS_TOK_CATCH; - } else if (strcmp(ep->token, "finally") == 0) { - inputPutback(ep, c); - return EJS_TOK_FINALLY; - } else if (strcmp(ep->token, "throw") == 0) { - inputPutback(ep, c); - return EJS_TOK_THROW; - } else if (strcmp(ep->token, "public") == 0) { - inputPutback(ep, c); - return EJS_TOK_PUBLIC; - } else if (strcmp(ep->token, "protected") == 0) { - inputPutback(ep, c); - return EJS_TOK_PROTECTED; - } else if (strcmp(ep->token, "private") == 0) { - inputPutback(ep, c); - return EJS_TOK_PRIVATE; - } else if (strcmp(ep->token, "get") == 0) { - inputPutback(ep, c); - return EJS_TOK_GET; - } else if (strcmp(ep->token, "set") == 0) { - inputPutback(ep, c); - return EJS_TOK_SET; - } else if (strcmp(ep->token, "each") == 0) { - inputPutback(ep, c); - return EJS_TOK_EACH; - } else if (strcmp(ep->token, "return") == 0) { - if ((c == ';') || (c == '(')) { - inputPutback(ep, c); - } - return EJS_TOK_RETURN; - } - - } else if (state == EJS_STATE_EXPR) { - if (strcmp(ep->token, "new") == 0) { - inputPutback(ep, c); - return EJS_TOK_NEW; - } else if (strcmp(ep->token, "in") == 0) { - inputPutback(ep, c); - return EJS_TOK_IN; - } else if (strcmp(ep->token, "function") == 0) { - inputPutback(ep, c); - return EJS_TOK_FUNCTION; - } - - } else if (state == EJS_STATE_DEC) { - if (strcmp(ep->token, "extends") == 0) { - inputPutback(ep, c); - return EJS_TOK_EXTENDS; - } - } - return tid; -} - -/******************************************************************************/ -/* - * Get the next EJS token - */ - -static int getLexicalToken(Ejs *ep, int state) -{ - EjsType type; - EjsInput *ip; - int done, tid, c, quote, style, idx, isHex; - - mprAssert(ep); - ip = ep->input; - mprAssert(ip); - - ep->tid = -1; - tid = -1; - type = BLD_FEATURE_NUM_TYPE_ID; - isHex = 0; - - /* - * Use a putback tokens first. Don't free strings as caller needs access. - */ - if (ip->putBackIndex >= 0) { - idx = ip->putBackIndex; - tid = ip->putBack[idx].tid; - ep->token = (char*) ip->putBack[idx].tokbuf; - tid = checkReservedWord(ep, state, 0, tid); - ip->putBackIndex--; - return tid; - } - ep->token = ip->tokServp = ip->tokEndp = ip->tokbuf; - *ip->tokServp = '\0'; - - if ((c = inputGetc(ep)) < 0) { - return EJS_TOK_EOF; - } - - /* - * Main lexical analyser - */ - for (done = 0; !done; ) { - switch (c) { - case -1: - return EJS_TOK_EOF; - - case ' ': - case '\t': - case '\r': - do { - if ((c = inputGetc(ep)) < 0) - break; - } while (c == ' ' || c == '\t' || c == '\r'); - break; - - case '\n': - return EJS_TOK_NEWLINE; - - case '(': - tokenAddChar(ep, c); - return EJS_TOK_LPAREN; - - case ')': - tokenAddChar(ep, c); - return EJS_TOK_RPAREN; - - case '[': - tokenAddChar(ep, c); - return EJS_TOK_LBRACKET; - - case ']': - tokenAddChar(ep, c); - return EJS_TOK_RBRACKET; - - case '.': - tokenAddChar(ep, c); - return EJS_TOK_PERIOD; - - case '{': - tokenAddChar(ep, c); - return EJS_TOK_LBRACE; - - case '}': - tokenAddChar(ep, c); - return EJS_TOK_RBRACE; - - case '+': - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c != '+' ) { - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_PLUS); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_INC); - return EJS_TOK_INC_DEC; - - case '-': - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c != '-' ) { - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_MINUS); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_DEC); - return EJS_TOK_INC_DEC; - - case '*': - tokenAddChar(ep, EJS_EXPR_MUL); - return EJS_TOK_EXPR; - - case '%': - tokenAddChar(ep, EJS_EXPR_MOD); - return EJS_TOK_EXPR; - - case '/': - /* - * Handle the division operator and comments - */ - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c != '*' && c != '/') { - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_DIV); - return EJS_TOK_EXPR; - } - style = c; - /* - * Eat comments. Both C and C++ comment styles are supported. - */ - while (1) { - if ((c = inputGetc(ep)) < 0) { - if (style == '/') { - return EJS_TOK_EOF; - } - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c == '\n' && style == '/') { - break; - } else if (c == '*') { - c = inputGetc(ep); - if (style == '/') { - if (c == '\n') { - break; - } - } else { - if (c == '/') { - break; - } - } - } - } - /* - * Continue looking for a token, so get the next character - */ - if ((c = inputGetc(ep)) < 0) { - return EJS_TOK_EOF; - } - break; - - case '<': /* < and <= */ - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c == '<') { - tokenAddChar(ep, EJS_EXPR_LSHIFT); - return EJS_TOK_EXPR; - } else if (c == '=') { - tokenAddChar(ep, EJS_EXPR_LESSEQ); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_LESS); - inputPutback(ep, c); - return EJS_TOK_EXPR; - - case '>': /* > and >= */ - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c == '>') { - tokenAddChar(ep, EJS_EXPR_RSHIFT); - return EJS_TOK_EXPR; - } else if (c == '=') { - tokenAddChar(ep, EJS_EXPR_GREATEREQ); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_GREATER); - inputPutback(ep, c); - return EJS_TOK_EXPR; - - case '=': /* "==" */ - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c == '=') { - tokenAddChar(ep, EJS_EXPR_EQ); - return EJS_TOK_EXPR; - } - inputPutback(ep, c); - return EJS_TOK_ASSIGNMENT; - - case '!': /* "!=" or "!"*/ - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - if (c == '=') { - tokenAddChar(ep, EJS_EXPR_NOTEQ); - return EJS_TOK_EXPR; - } - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_BOOL_COMP); - return EJS_TOK_EXPR; - - case ';': - tokenAddChar(ep, c); - return EJS_TOK_SEMI; - - case ',': - tokenAddChar(ep, c); - return EJS_TOK_COMMA; - - case ':': - tokenAddChar(ep, c); - return EJS_TOK_COLON; - - case '|': /* "||" */ - if ((c = inputGetc(ep)) < 0 || c != '|') { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - tokenAddChar(ep, EJS_COND_OR); - return EJS_TOK_LOGICAL; - - case '&': /* "&&" */ - if ((c = inputGetc(ep)) < 0 || c != '&') { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - tokenAddChar(ep, EJS_COND_AND); - return EJS_TOK_LOGICAL; - - case '\"': /* String quote */ - case '\'': - quote = c; - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, 0); - return EJS_TOK_ERR; - } - - while (c != quote) { - /* - * Check for escape sequence characters - */ - if (c == '\\') { - c = inputGetc(ep); - - if (isdigit(c)) { - /* - * Octal support, \101 maps to 65 = 'A'. Put first - * char back so converter will work properly. - */ - inputPutback(ep, c); - c = charConvert(ep, 8, 3); - - } else { - switch (c) { - case 'n': - c = '\n'; break; - case 'b': - c = '\b'; break; - case 'f': - c = '\f'; break; - case 'r': - c = '\r'; break; - case 't': - c = '\t'; break; - case 'x': - /* - * Hex support, \x41 maps to 65 = 'A' - */ - c = charConvert(ep, 16, 2); - break; - case 'u': - /* - * Unicode support, \x0401 maps to 65 = 'A' - */ - c = charConvert(ep, 16, 2); - c = c*16 + charConvert(ep, 16, 2); - - break; - case '\'': - case '\"': - case '\\': - break; - default: - if (tokenAddChar(ep, '\\') < 0) { - return EJS_TOK_ERR; - } - } - } - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - } else { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - } - if ((c = inputGetc(ep)) < 0) { - ejsSyntaxError(ep, "Unmatched Quote"); - return EJS_TOK_ERR; - } - } - return EJS_TOK_LITERAL; - - case '0': - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - if (tolower(c) == 'x') { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - isHex = 1; - if (! isxdigit(c)) { - parseNumber(ep, type); - inputPutback(ep, c); - return EJS_TOK_NUMBER; - } - } else if (! isdigit(c)) { -#if BLD_FEATURE_FLOATING_POINT - if (c == '.' || tolower(c) == 'e' || c == '+' || c == '-') { - /* Fall through */ - type = EJS_TYPE_FLOAT; - } else -#endif - { - parseNumber(ep, type); - inputPutback(ep, c); - return EJS_TOK_NUMBER; - } - } - /* Fall through to get more digits */ - - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (isHex) { - do { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - } while (isxdigit(c)); - - } else { -#if BLD_FEATURE_FLOATING_POINT - do { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - c = tolower(c); - if (c == '.' || c == 'e' || c == 'f') { - type = EJS_TYPE_FLOAT; - } - } while (isdigit(c) || c == '.' || c == 'e' || - c == 'f' || - ((type == EJS_TYPE_FLOAT) && (c == '+' || c == '-'))); -#else - do { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - } while (isdigit(c)); -#endif - } - - parseNumber(ep, type); - inputPutback(ep, c); - return EJS_TOK_NUMBER; - - default: - /* - * Identifiers or a function names - */ - while (1) { - if (c == '\\') { - if ((c = inputGetc(ep)) < 0) { - break; - } - if (c == '\n' || c == '\r') { - break; - } - } else if (tokenAddChar(ep, c) < 0) { - break; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - if (!isalnum(c) && c != '$' && c != '_' && - c != '\\' && c != '@') { - break; - } - } - if (*ep->token == '\0') { - c = inputGetc(ep); - break; - } - - if (! isalpha((int) *ep->token) && *ep->token != '$' && - *ep->token != '_' && *ep->token != '@') { - ejsError(ep, EJS_SYNTAX_ERROR, "Invalid identifier %s", - ep->token); - return EJS_TOK_ERR; - } - - tid = checkReservedWord(ep, state, c, EJS_TOK_ID); - if (tid != EJS_TOK_ID) { - return tid; - } - - /* - * Skip white space after token to find out whether this is - * a function or not. - */ - while (c == ' ' || c == '\t' || c == '\r' || c == '\n') { - if ((c = inputGetc(ep)) < 0) - break; - } - - tid = EJS_TOK_ID; - if ((strlen(ep->token) + 1) >= EJS_MAX_ID) { - ejsError(ep, EJS_SYNTAX_ERROR, - "Identifier too big. Max is %d letters.", EJS_MAX_ID); - return EJS_TOK_ERR; - } - done++; - } - } - - /* - * Putback the last extra character for next time - */ - inputPutback(ep, c); - return tid; -} - -/******************************************************************************/ - -static void parseNumber(Ejs *ep, EjsType type) -{ - switch (type) { - case EJS_TYPE_INT: - ep->tokenNumber.integer = ejsParseInteger(ep->token); - ep->tokenNumber.type = type; - break; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - ep->tokenNumber.floating = atof(ep->token); - ep->tokenNumber.type = type; - break; -#endif - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - ep->tokenNumber.integer64 = ejsParseInteger64(ep->token); - ep->tokenNumber.type = type; - break; -#endif - } -} - -/******************************************************************************/ -/* - * Convert a hex or octal character back to binary, return original char if - * not a hex digit - */ - -static int charConvert(Ejs *ep, int base, int maxDig) -{ - int i, c, lval, convChar; - - lval = 0; - for (i = 0; i < maxDig; i++) { - if ((c = inputGetc(ep)) < 0) { - break; - } - /* - * Initialize to out of range value - */ - convChar = base; - if (isdigit(c)) { - convChar = c - '0'; - } else if (c >= 'a' && c <= 'f') { - convChar = c - 'a' + 10; - } else if (c >= 'A' && c <= 'F') { - convChar = c - 'A' + 10; - } - /* - * If unexpected character then return it to buffer. - */ - if (convChar >= base) { - inputPutback(ep, c); - break; - } - lval = (lval * base) + convChar; - } - return lval; -} - -/******************************************************************************/ -/* - * Putback the last token read. Accept at most one push back token. - */ - -void ejsLexPutbackToken(Ejs *ep, int tid, char *string) -{ - EjsInput *ip; - EjsToken *tp; - int idx; - - mprAssert(ep); - ip = ep->input; - mprAssert(ip); - - ip->putBackIndex += 1; - - mprAssert(ip->putBackIndex < EJS_TOKEN_STACK); - idx = ip->putBackIndex; - - tp = &ip->putBack[idx]; - tp->tid = tid; - - mprStrcpy(tp->tokbuf, sizeof(tp->tokbuf), string); -} - -/******************************************************************************/ -/* - * Add a character to the token buffer - */ - -static int tokenAddChar(Ejs *ep, int c) -{ - EjsInput *ip; - - mprAssert(ep); - ip = ep->input; - mprAssert(ip); - - if (ip->tokEndp >= &ip->tokbuf[sizeof(ip->tokbuf) - 1]) { - ejsSyntaxError(ep, "Token too big"); - return -1; - } - *ip->tokEndp++ = c; - *ip->tokEndp = '\0'; - - return 0; -} - -/******************************************************************************/ -/* - * Get another input character - */ - -static int inputGetc(Ejs *ep) -{ - EjsInput *ip; - int c; - - mprAssert(ep); - ip = ep->input; - - if (ip->scriptSize <= 0) { - return -1; - } - - c = (uchar) (*ip->scriptServp++); - ip->scriptSize--; - - /* - * For debugging, accumulate the line number and the currenly parsed line - */ - if (c == '\n') { -#if 0 && BLD_DEBUG - if (ip->lineColumn > 0) { - printf("PARSED: %s\n", ip->line); - } -#endif - ip->lineNumber++; - ip->lineColumn = 0; - } else if ((ip->lineColumn + 2) < sizeof(ip->line)) { - ip->line[ip->lineColumn++] = c; - ip->line[ip->lineColumn] = '\0'; - } - return c; -} - -/******************************************************************************/ -/* - * Putback a character onto the input queue - */ - -static void inputPutback(Ejs *ep, int c) -{ - EjsInput *ip; - - mprAssert(ep); - - if (c > 0) { - ip = ep->input; - *--ip->scriptServp = c; - ip->scriptSize++; - if (--(ip->lineColumn) < 0) { - ip->lineColumn = 0; - } - mprAssert(ip->line); - mprAssert(ip->lineColumn >= 0); - mprAssert(ip->lineColumn < sizeof(ip->line)); - ip->line[ip->lineColumn] = '\0'; - } -} - -/******************************************************************************/ - -#else -void ejsLexDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsParser.c b/source4/lib/appweb/ejs-2.0/ejs/ejsParser.c deleted file mode 100644 index 9fce6d27ee..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsParser.c +++ /dev/null @@ -1,4514 +0,0 @@ -/* - * @file ejsParser.c - * @brief EJS Parser and Execution - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ - -static int createClass(Ejs *ep, EjsVar *parentClass, - const char *className, EjsVar *baseClass); -static int createProperty(Ejs *ep, EjsVar **obj, const char *id, - int state); -static int evalCond(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs); -static int evalExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs); -#if BLD_FEATURE_FLOATING_POINT -static int evalFloatExpr(Ejs *ep, double l, int rel, double r); -#endif -static int evalBoolExpr(Ejs *ep, int l, int rel, int r); -static int evalNumericExpr(Ejs *ep, EjsNum l, int rel, EjsNum r); -static int evalObjExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs) ; -static int evalStringExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs); -static int evalMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, int flags); -static EjsProperty *findProperty(Ejs *ep, EjsVar *op, const char *property, - int flags); -static EjsVar *pickSpace(Ejs *ep, int state, const char *property, int flags); -static void freeProc(Ejs *ep, EjsProc *proc); -static int parseArgs(Ejs *ep, int state, int flags); -static int parseArrayLiteral(Ejs *ep, int state, int flags, char *id); -static int parseAssignment(Ejs *ep, int state, int flags, char *id); -static int parseClass(Ejs *ep, int state, int flags); -static int parseForInner(Ejs *ep, int state, int flags, - EjsInput *condScript, EjsInput *incrScript, - EjsInput *bodyScript, EjsInput *endScript); -static int parseCond(Ejs *ep, int state, int flags); -static int parseDeclaration(Ejs *ep, int state, int flags); -static int parseExpr(Ejs *ep, int state, int flags); -static int parseFor(Ejs *ep, int state, int flags); -static int parseRegFor(Ejs *ep, int state, int flags); -static int parseForIn(Ejs *ep, int state, int flags, int each); -static int parseId(Ejs *ep, int state, int flags, char **id, int *done); -static int parseInc(Ejs *ep, int state, int flags); -static int parseIf(Ejs *ep, int state, int flags, int *done); -static int parseFunction(Ejs *ep, int state, int flags); -static int parseMethod(Ejs *ep, int state, int flags, char *id); -static int parseObjectLiteral(Ejs *ep, int state, int flags, char *id); -static int parseStmt(Ejs *ep, int state, int flags); -static int parseThrow(Ejs *ep, int state, int flags); -static int parseTry(Ejs *ep, int state, int flags); -static void removeNewlines(Ejs *ep, int state); -static EjsProperty *searchSpacesForProperty(Ejs *ep, int state, EjsVar *obj, - char *property, int flags); -static int assignPropertyValue(Ejs *ep, char *id, int state, EjsVar *value, - int flags); -static int updateProperty(Ejs *ep, EjsVar *obj, const char *id, int state, - EjsVar *value); -static void updateResult(Ejs *ep, int state, int flags, EjsVar *vp); -static int getNextNonSpaceToken(Ejs *ep, int state); - -static int callConstructor(Ejs *ep, EjsVar *thisObj, EjsVar *baseClass, - MprArray *args); -static int callCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, - EjsVar *prototype); -static int callStringCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, - EjsVar *prototype); -static int callMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, - EjsVar *prototype); -static int runMethod(Ejs *ep, EjsVar *thisObj, EjsVar *method, - const char *methodName, MprArray *args); - -static EjsInput *getInputStruct(Ejs *ep); -static void freeInputStruct(Ejs *ep, EjsInput *input); - -static void *pushFrame(Ejs *ep, int size); -static void *popFrame(Ejs *ep, int size); - -/************************************* Code ***********************************/ -/* - * Recursive descent parser for EJS - */ - -int ejsParse(Ejs *ep, int state, int flags) -{ - mprAssert(ep); - -#if MOB - if (mprStackCheck(ep)) { - char *stack; - stack = ejsFormatStack(ep); - mprLog(ep, 0, "\nStack grew : MAX %d\n", mprStackSize(ep)); - mprLog(ep, 0, "Stack\n %s\n", stack); - mprFree(stack); - } -#endif - - if (ep->flags & EJS_FLAGS_EXIT) { - return EJS_STATE_RET; - } - - ep->inputMarker = ep->input->scriptServp; - - switch (state) { - /* - * Any statement, method arguments or conditional expressions - */ - case EJS_STATE_STMT: - state = parseStmt(ep, state, flags); - if (state != EJS_STATE_STMT_BLOCK_DONE && state != EJS_STATE_STMT_DONE){ - goto err; - } - break; - - case EJS_STATE_DEC: - state = parseStmt(ep, state, flags); - if (state != EJS_STATE_DEC_DONE) { - goto err; - } - break; - - case EJS_STATE_EXPR: - state = parseStmt(ep, state, flags); - if (state != EJS_STATE_EXPR_DONE) { - goto err; - } - break; - - /* - * Variable declaration list - */ - case EJS_STATE_DEC_LIST: - state = parseDeclaration(ep, state, flags); - if (state != EJS_STATE_DEC_LIST_DONE) { - goto err; - } - break; - - /* - * Method argument string - */ - case EJS_STATE_ARG_LIST: - state = parseArgs(ep, state, flags); - if (state != EJS_STATE_ARG_LIST_DONE) { - goto err; - } - break; - - /* - * Logical condition list (relational operations separated by &&, ||) - */ - case EJS_STATE_COND: - state = parseCond(ep, state, flags); - if (state != EJS_STATE_COND_DONE) { - goto err; - } - break; - - /* - * Expression list - */ - case EJS_STATE_RELEXP: - state = parseExpr(ep, state, flags); - if (state != EJS_STATE_RELEXP_DONE) { - goto err; - } - break; - } - - /* - * Recursion protection - */ - if (ep->input->scriptServp == ep->inputMarker) { - if (ep->recurseCount++ > 20) { - ejsSyntaxError(ep, "Input syntax error"); - state = EJS_STATE_ERR; - } - } else { - ep->recurseCount = 0; - } - - if (state == EJS_STATE_RET || state == EJS_STATE_EOF) { - return state; - } - -done: - return state; - -err: - if (state == EJS_STATE_RET || state == EJS_STATE_EOF) { - goto done; - } - if (state != EJS_STATE_ERR) { - ejsSyntaxError(ep, 0); - } - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseStmt { - EjsProc *saveProc; - EjsProperty *pp; - EjsVar *saveObj, *exception; - char *str, *id; - int done, tid, rs, saveObjPerm, expectEndOfStmt; -} ParseStmt; - -/* - * Parse expression (leftHandSide operator rightHandSide) - */ - - -static int parseStmt(Ejs *ep, int state, int flags) -{ - ParseStmt *sp; - - mprAssert(ep); - - if ((sp = pushFrame(ep, sizeof(ParseStmt))) == 0) { - return EJS_STATE_ERR; - } - - sp->id = 0; - sp->expectEndOfStmt = 0; - sp->saveProc = NULL; - - ep->currentObj = 0; - ep->currentProperty = 0; - - for (sp->done = 0; !sp->done && state != EJS_STATE_ERR; ) { - sp->tid = ejsLexGetToken(ep, state); - -#if (WIN || BREW_SIMULATOR) && BLD_DEBUG && DISABLED - /* MOB -- make cross platform */ - _CrtCheckMemory(); -#endif - - switch (sp->tid) { - default: - ejsLexPutbackToken(ep, sp->tid, ep->token); - goto done; - - case EJS_TOK_EXPR: - if (state == EJS_STATE_EXPR) { - ejsLexPutbackToken(ep, EJS_TOK_EXPR, ep->token); - } - goto done; - - case EJS_TOK_LOGICAL: - ejsLexPutbackToken(ep, sp->tid, ep->token); - goto done; - - case EJS_TOK_ERR: - if (state != EJS_STATE_ERR && !ep->gotException) { - ejsSyntaxError(ep, 0); - } - state = EJS_STATE_ERR; - goto done; - - case EJS_TOK_EOF: - state = EJS_STATE_EOF; - goto done; - - case EJS_TOK_NEWLINE: - break; - - case EJS_TOK_SEMI: - /* - * This case is when we discover no statement and just a lone ';' - */ - if (state != EJS_STATE_STMT) { - ejsLexPutbackToken(ep, sp->tid, ep->token); - } - goto done; - - case EJS_TOK_LBRACKET: - if (flags & EJS_FLAGS_EXE) { - ep->currentObj = &ep->currentProperty->var; - if (ep->currentObj != 0 && ep->currentObj->type != - EJS_TYPE_OBJECT) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Property reference to a non-object type \"%s\"\n", - sp->id); - goto err; - } - } - - sp->saveObj = ep->currentObj; - sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1); - - sp->rs = ejsParse(ep, EJS_STATE_RELEXP, flags); - - ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm); - ep->currentObj = sp->saveObj; - - if (sp->rs < 0) { - state = sp->rs; - goto done; - } - - mprFree(sp->id); - /* MOB rc */ - sp->str = ejsVarToString(ep, ep->result); - sp->id = mprStrdup(ep, sp->str); - - if (sp->id[0] == '\0') { - if (flags & EJS_FLAGS_EXE) { - ejsError(ep, EJS_RANGE_ERROR, - "[] expression evaluates to the empty string\n"); - goto err; - } - } else { - sp->pp = searchSpacesForProperty(ep, state, ep->currentObj, - sp->id, flags); - ep->currentProperty = sp->pp; - updateResult(ep, state, flags, ejsGetVarPtr(sp->pp)); - } - - if ((sp->tid = ejsLexGetToken(ep, state)) != EJS_TOK_RBRACKET) { - ejsSyntaxError(ep, "Missing ']'"); - goto err; - } - break; - - case EJS_TOK_PERIOD: - if (flags & EJS_FLAGS_EXE) { - if (ep->currentProperty == 0) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Undefined object \"%s\"", sp->id); - goto err; - } - } - ep->currentObj = &ep->currentProperty->var; - if (flags & EJS_FLAGS_EXE) { - if (ep->currentObj != 0 && ep->currentObj->type != - EJS_TYPE_OBJECT) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Property reference to a non-object type \"%s\"\n", - sp->id); - goto err; - } - } - if ((sp->tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) { - ejsError(ep, EJS_REFERENCE_ERROR, "Bad property after '.': %s", - ep->token); - goto err; - } - /* Fall through */ - - case EJS_TOK_ID: - state = parseId(ep, state, flags, &sp->id, &sp->done); - if (sp->done && state == EJS_STATE_STMT) { - sp->expectEndOfStmt = 1; - } - break; - - case EJS_TOK_ASSIGNMENT: - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid == EJS_TOK_LBRACE) { - /* - * var = { name: value, name: value, ... } - */ - if (parseObjectLiteral(ep, state, flags, sp->id) < 0) { - ejsSyntaxError(ep, "Bad object literal"); - goto err; - } - - } else if (sp->tid == EJS_TOK_LBRACKET) { - /* - * var = [ array elements ] - */ - if (parseArrayLiteral(ep, state, flags, sp->id) < 0) { - ejsSyntaxError(ep, "Bad array literal"); - goto err; - } - - } else if (sp->tid == EJS_TOK_EXPR && - (int) *ep->token == EJS_EXPR_LESS) { - /* - * var = .../ - */ - ejsSyntaxError(ep, "XML literals are not yet supported"); - goto err; - - } else { - /* - * var = expression - */ - ejsLexPutbackToken(ep, sp->tid, ep->token); - state = parseAssignment(ep, state, flags, sp->id); - if (state == EJS_STATE_ERR) { - if (ep->flags & EJS_FLAGS_EXIT) { - state = EJS_STATE_RET; - goto done; - } - if (!ep->gotException) { - ejsSyntaxError(ep, 0); - } - goto err; - } - } - - if (flags & EJS_FLAGS_EXE) { - if (assignPropertyValue(ep, sp->id, state, ep->result, - flags) < 0) { - if (ep->gotException == 0) { - ejsError(ep, EJS_EVAL_ERROR, "Can't set property %s", - sp->id); - } - goto err; - } - } - - if (state == EJS_STATE_STMT) { - sp->expectEndOfStmt = 1; - goto done; - } - break; - - case EJS_TOK_INC_DEC: - state = parseInc(ep, state, flags); - if (state == EJS_STATE_STMT) { - sp->expectEndOfStmt = 1; - } - break; - - case EJS_TOK_NEW: - /* MOB -- could we remove rs and just use state */ - sp->rs = ejsParse(ep, EJS_STATE_EXPR, flags | EJS_FLAGS_NEW); - if (sp->rs < 0) { - state = sp->rs; - goto done; - } - break; - - case EJS_TOK_DELETE: - sp->rs = ejsParse(ep, EJS_STATE_EXPR, flags | EJS_FLAGS_DELETE); - if (sp->rs < 0) { - state = sp->rs; - goto done; - } - if (flags & EJS_FLAGS_EXE) { - /* Single place where properties are deleted */ - if (ep->currentObj == 0 || ep->currentProperty == 0) { - ejsError(ep, EJS_EVAL_ERROR, - "Can't find property to delete"); - goto err; - } - if (ep->currentObj->isArray) { - ejsSetArrayLength(ep, ep->currentObj, 0, - ep->currentProperty->name, 0); - } - ejsDeleteProperty(ep, ep->currentObj, - ep->currentProperty->name); - ep->currentProperty = 0; - } - goto done; - - case EJS_TOK_FUNCTION: - /* - * Parse a function declaration - */ - state = parseFunction(ep, state, flags); - goto done; - - case EJS_TOK_THROW: - state = parseThrow(ep, state, flags); - goto done; - - case EJS_TOK_TRY: - state = parseTry(ep, state, flags); - goto done; - - case EJS_TOK_CLASS: - case EJS_TOK_MODULE: - state = parseClass(ep, state, flags); - goto done; - - case EJS_TOK_LITERAL: - /* - * Set the result to the string literal - */ - if (flags & EJS_FLAGS_EXE) { - ejsWriteVarAsString(ep, ep->result, ep->token); - ejsSetVarName(ep, ep->result, ""); - } - if (state == EJS_STATE_STMT) { - sp->expectEndOfStmt = 1; - } - goto done; - - case EJS_TOK_NUMBER: - /* - * Set the result to the parsed number - */ - if (flags & EJS_FLAGS_EXE) { - ejsWriteVar(ep, ep->result, &ep->tokenNumber, 0); - } - if (state == EJS_STATE_STMT) { - sp->expectEndOfStmt = 1; - } - goto done; - - case EJS_TOK_METHOD_NAME: - /* - * parse a method() invocation - */ - mprAssert(ep->currentObj); - state = parseMethod(ep, state, flags, sp->id); - if (state == EJS_STATE_STMT) { - sp->expectEndOfStmt = 1; - } - if (ep->flags & EJS_FLAGS_EXIT) { - state = EJS_STATE_RET; - } - goto done; - - case EJS_TOK_IF: - state = parseIf(ep, state, flags, &sp->done); - if (state < 0) { - goto done; - } - break; - - case EJS_TOK_FOR: - state = parseFor(ep, state, flags); - goto done; - - case EJS_TOK_VAR: - if ((sp->rs = ejsParse(ep, EJS_STATE_DEC_LIST, flags)) < 0) { - state = sp->rs; - goto done; - } - goto done; - - case EJS_TOK_COMMA: - ejsLexPutbackToken(ep, sp->tid, ep->token); - goto done; - - case EJS_TOK_LPAREN: - if (state == EJS_STATE_EXPR) { - if ((sp->rs = ejsParse(ep, EJS_STATE_RELEXP, flags)) < 0) { - state = sp->rs; - goto done; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - ejsSyntaxError(ep, 0); - goto err; - } - goto done; - - } else if (state == EJS_STATE_STMT) { - ejsLexPutbackToken(ep, EJS_TOK_METHOD_NAME, ep->token); - } - break; - - case EJS_TOK_RPAREN: - ejsLexPutbackToken(ep, sp->tid, ep->token); - goto done; - - case EJS_TOK_EXTENDS: - if (! (flags & EJS_FLAGS_CLASS_DEC)) { - ejsSyntaxError(ep, 0); - goto err; - } - sp->saveObj = ep->currentObj; - sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1); - - sp->rs = ejsParse(ep, EJS_STATE_STMT, flags); - ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm); - - if (sp->rs < 0) { - state = sp->rs; - goto done; - } - - if (flags & EJS_FLAGS_EXE) { - if (createClass(ep, sp->saveObj, sp->id, - ejsGetVarPtr(ep->currentProperty)) < 0) { - goto err; - } - } - if (ejsLexGetToken(ep, state) != EJS_TOK_LBRACE) { - ejsSyntaxError(ep, 0); - goto err; - } - ejsLexPutbackToken(ep, ep->tid, ep->token); - goto done; - - case EJS_TOK_LBRACE: - if (flags & EJS_FLAGS_CLASS_DEC) { - if (state == EJS_STATE_DEC) { - if (flags & EJS_FLAGS_EXE) { - if (createClass(ep, ep->currentObj, sp->id, 0) < 0) { - goto err; - } - } - ejsLexPutbackToken(ep, sp->tid, ep->token); - - } else if (state == EJS_STATE_STMT) { - ejsLexPutbackToken(ep, sp->tid, ep->token); - } - goto done; - } - - /* - * This handles any code in braces except "if () {} else {}" - */ - if (state != EJS_STATE_STMT) { - ejsSyntaxError(ep, 0); - goto err; - } - - /* - * Parse will return EJS_STATE_STMT_BLOCK_DONE when the RBRACE - * is seen. - */ - sp->exception = 0; - do { - state = ejsParse(ep, EJS_STATE_STMT, flags); - if (state == EJS_STATE_ERR) { - /* - * We need to keep parsing to get to the end of the block - */ - if (sp->exception == 0) { - sp->exception = ejsDupVar(ep, ep->result, - EJS_SHALLOW_COPY); - if (sp->exception == 0) { - ejsMemoryError(ep); - goto err; - } - if (sp->exception->type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(sp->exception, 0); - mprAssert(sp->exception->objectState->alive == 0); - } - - /* - * If we're in a try block, we need to keep parsing - * so we can find the end of the block and the start - * of the catch block. Otherwise, we are done. - */ - if (!(flags & EJS_FLAGS_TRY)) { - break; - } - } - flags &= ~EJS_FLAGS_EXE; - if (ep->recurseCount > 20) { - break; - } - state = EJS_STATE_STMT_DONE; - ep->gotException = 0; - } - - } while (state == EJS_STATE_STMT_DONE); - - if (sp->exception) { - ep->gotException = 1; - ejsWriteVar(ep, ep->result, sp->exception, EJS_SHALLOW_COPY); - - /* Eat the closing brace */ - ejsLexGetToken(ep, state); - ejsFreeVar(ep, sp->exception); - - goto err; - } - ejsFreeVar(ep, sp->exception); - - if (state < 0) { - goto done; - } - - if (ejsLexGetToken(ep, state) != EJS_TOK_RBRACE) { - ejsSyntaxError(ep, 0); - goto err; - } - state = EJS_STATE_STMT_DONE; - goto done; - - case EJS_TOK_RBRACE: - if (state == EJS_STATE_STMT) { - ejsLexPutbackToken(ep, sp->tid, ep->token); - state = EJS_STATE_STMT_BLOCK_DONE; - - } else if (state == EJS_STATE_EXPR) { - ejsLexPutbackToken(ep, sp->tid, ep->token); - state = EJS_STATE_EXPR; - - } else { - ejsSyntaxError(ep, 0); - state = EJS_STATE_ERR; - } - goto done; - - case EJS_TOK_RETURN: - if ((sp->rs = ejsParse(ep, EJS_STATE_RELEXP, flags)) < 0) { - state = sp->rs; - goto done; - } - if (flags & EJS_FLAGS_EXE) { - state = EJS_STATE_RET; - goto done; - } - break; - } - } -done: - mprFree(sp->id); - - if (sp->expectEndOfStmt && state >= 0) { - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid == EJS_TOK_RBRACE) { - ejsLexPutbackToken(ep, EJS_TOK_RBRACE, ep->token); - - } else if (sp->tid != EJS_TOK_SEMI && sp->tid != EJS_TOK_NEWLINE && - sp->tid != EJS_TOK_EOF) { - ejsSyntaxError(ep, 0); - state = EJS_STATE_ERR; - - } else { - /* - * Skip newlines after semi-colon - */ - removeNewlines(ep, state); - } - } - - /* - * Advance the state - */ - switch (state) { - case EJS_STATE_STMT: - case EJS_STATE_STMT_DONE: - state = EJS_STATE_STMT_DONE; - break; - - case EJS_STATE_DEC: - case EJS_STATE_DEC_DONE: - state = EJS_STATE_DEC_DONE; - break; - - case EJS_STATE_EXPR: - case EJS_STATE_EXPR_DONE: - state = EJS_STATE_EXPR_DONE; - break; - - case EJS_STATE_STMT_BLOCK_DONE: - case EJS_STATE_EOF: - case EJS_STATE_RET: - break; - - default: - if (state != EJS_STATE_ERR) { - ejsSyntaxError(ep, 0); - } - state = EJS_STATE_ERR; - } - popFrame(ep, sizeof(ParseStmt)); - return state; - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseFor { - char *initToken; - int tid, foundVar, initId, each; -} ParseFor; - -/* - * Parse method arguments - */ - -static int parseFor(Ejs *ep, int state, int flags) -{ - ParseFor *sp; - - if ((sp = pushFrame(ep, sizeof(ParseFor))) == 0) { - return EJS_STATE_ERR; - } - - mprAssert(ep); - - if (state != EJS_STATE_STMT) { - ejsSyntaxError(ep, 0); - goto err; - } - - if ((sp->tid = ejsLexGetToken(ep, state)) == EJS_TOK_EACH) { - sp->each = 1; - sp->tid = ejsLexGetToken(ep, state); - - } else { - sp->each = 0; - } - - if (sp->tid != EJS_TOK_LPAREN) { - ejsSyntaxError(ep, 0); - goto err; - } - - /* - * Need to peek 2-3 tokens ahead and see if this is a - * for [each] ([var] x in set) - * or - * for (init ; whileCond; incr) - */ - sp->initId = ejsLexGetToken(ep, EJS_STATE_EXPR); - sp->foundVar = 0; - if (sp->initId == EJS_TOK_ID && strcmp(ep->token, "var") == 0) { - sp->foundVar = 1; - sp->initId = ejsLexGetToken(ep, EJS_STATE_EXPR); - } - sp->initToken = mprStrdup(ep, ep->token); - - sp->tid = ejsLexGetToken(ep, EJS_STATE_EXPR); - - ejsLexPutbackToken(ep, sp->tid, ep->token); - ejsLexPutbackToken(ep, sp->initId, sp->initToken); - mprFree(sp->initToken); - - if (sp->foundVar) { - ejsLexPutbackToken(ep, EJS_TOK_ID, "var"); - } - - if (sp->tid == EJS_TOK_IN) { - state = parseForIn(ep, state, flags, sp->each); - - } else { - state = parseRegFor(ep, state, flags); - } - -done: - popFrame(ep, sizeof(ParseFor)); - return state; - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Parse method arguments - */ - -static int parseArgs(Ejs *ep, int state, int flags) -{ - EjsVar *vp; - int tid; - - mprAssert(ep); - - do { - /* - * Peek and see if there are no args - */ - tid = ejsLexGetToken(ep, state); - ejsLexPutbackToken(ep, tid, ep->token); - if (tid == EJS_TOK_RPAREN) { - break; - } - - /* - * If this is part of a constructor, must run methods in args normally - */ - flags &= ~EJS_FLAGS_NEW; - - state = ejsParse(ep, EJS_STATE_RELEXP, flags); - if (state < 0) { - return state; - } - if (flags & EJS_FLAGS_EXE) { - mprAssert(ep->proc->args); - vp = ejsDupVar(ep, ep->result, EJS_SHALLOW_COPY); - if (vp == 0) { - ejsMemoryError(ep); - return EJS_STATE_ERR; - } - /* MOB */ - if (vp->type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(vp, 0); - mprAssert(vp->objectState->alive == 0); - } - - /* - * Propagate the name - */ - ejsSetVarName(ep, vp, ep->result->propertyName); - - mprAddItem(ep->proc->args, vp); - - } - /* - * Peek at the next token, continue if more args (ie. comma seen) - */ - tid = ejsLexGetToken(ep, state); - if (tid != EJS_TOK_COMMA) { - ejsLexPutbackToken(ep, tid, ep->token); - } - } while (tid == EJS_TOK_COMMA); - - if (tid != EJS_TOK_RPAREN && state != EJS_STATE_RELEXP_DONE) { - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - return EJS_STATE_ARG_LIST_DONE; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseAssign { - EjsProperty *saveProperty; - EjsVar *saveObj; - int saveObjPerm, savePropPerm, rc; -} ParseAssign; - -/* - * Parse an assignment statement - */ - -static int parseAssignment(Ejs *ep, int state, int flags, char *id) -{ - ParseAssign *sp; - - - if (id == 0) { - if (!ep->gotException) { - ejsSyntaxError(ep, 0); - } - return EJS_STATE_ERR; - } - - if ((sp = pushFrame(ep, sizeof(ParseAssign))) == 0) { - return EJS_STATE_ERR; - } - - mprAssert(ep->currentObj); - - /* - * Parse the right hand side of the "=" - */ - sp->saveObj = ep->currentObj; - sp->saveProperty = ep->currentProperty; - - sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1); - sp->savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(sp->saveProperty), 1); - - sp->rc = ejsParse(ep, EJS_STATE_RELEXP, flags | EJS_FLAGS_ASSIGNMENT); - - ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm); - ejsMakeObjPermanent(ejsGetVarPtr(sp->saveProperty), sp->savePropPerm); - - if (sp->rc < 0) { - state = EJS_STATE_ERR; - } - - ep->currentObj = sp->saveObj; - ep->currentProperty = sp->saveProperty; - - popFrame(ep, sizeof(ParseAssign)); - - if (! (flags & EJS_FLAGS_EXE)) { - return state; - } - - return state; -} - -/******************************************************************************/ - -static int assignPropertyValue(Ejs *ep, char *id, int state, EjsVar *value, - int flags) -{ - EjsProperty *saveProperty; - EjsVar *saveObj, *obj, *vp; - char *procName; - int saveObjPerm, savePropPerm, rc; - - mprAssert(flags & EJS_FLAGS_EXE); - - if (ep->currentProperty && - !ep->currentProperty->var.flags & EJS_GET_ACCESSOR) { - obj = ep->currentObj; - - } else { - /* - * Handle any set accessors. - * FUTURE OPT -- could be faster - * FUTURE OPT -- coming here even when doing just a set "x = value"; - */ - procName = 0; - if (mprAllocStrcat(MPR_LOC_ARGS(ep), &procName, EJS_MAX_ID + 5, 0, - "-set-", id, 0) > 0) { - - MprArray *args; - - ep->currentProperty = searchSpacesForProperty(ep, state, - ep->currentObj, procName, flags); - - if (ep->currentProperty) { - args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - - vp = ejsDupVar(ep, value, EJS_SHALLOW_COPY); - mprAddItem(args, vp); - mprAssert(! ejsObjIsCollectable(vp)); - - saveObj = ep->currentObj; - saveProperty = ep->currentProperty; - - saveObjPerm = ejsMakeObjPermanent(saveObj, 1); - savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), - 1); - - /* - * Invoke the set accessor - */ - rc = ejsRunMethod(ep, ep->currentObj, procName, args); - mprFree(procName); - ejsFreeMethodArgs(ep, args); - - ejsMakeObjPermanent(saveObj, saveObjPerm); - ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), savePropPerm); - - ep->currentObj = saveObj; - ep->currentProperty = saveProperty; - - if (rc < 0) { - return EJS_STATE_ERR; - } - return state; - } - mprFree(procName); - } - - if (ep->currentProperty == 0) { - /* - * MOB -- can we omit this as updateProperty below will create - */ - if (createProperty(ep, &obj, id, state) < 0) { - return EJS_STATE_ERR; - } - } - } - - if (updateProperty(ep, obj, id, state, value) < 0) { - return EJS_STATE_ERR; - } - - vp = ejsGetVarPtr(ep->currentProperty); - if (vp->type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(vp, 1); - } - - return state; -} - -/******************************************************************************/ - -static int parseObjectLiteral(Ejs *ep, int state, int flags, char *id) -{ - EjsProperty *saveProperty; - EjsVar *saveObj; - EjsVar *obj; - char *name; - int saveObjPerm, savePropPerm, tid; - - name = 0; - - saveObj = ep->currentObj; - saveProperty = ep->currentProperty; - - saveObjPerm = ejsMakeObjPermanent(saveObj, 1); - savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), 1); - - if (flags & EJS_FLAGS_EXE) { - obj = ejsCreateSimpleObj(ep, "Object"); - if (obj == 0) { - ejsMemoryError(ep); - goto err; - } - mprAssert(! ejsObjIsCollectable(obj)); - - } else { - obj = 0; - } - - do { - tid = getNextNonSpaceToken(ep, state); - if (tid != EJS_TOK_ID) { - ejsSyntaxError(ep, 0); - goto err; - } - name = mprStrdup(ep, ep->token); - - tid = getNextNonSpaceToken(ep, state); - if (tid != EJS_TOK_COLON) { - ejsSyntaxError(ep, 0); - goto err; - } - - if (flags & EJS_FLAGS_EXE) { - /* FUTURE OPT -- can we optimize this. We are double accessing id - with the Put below. Should we be using this or ejsSetProperty - */ - if (ejsCreatePropertyMethod(ep, obj, name) == 0) { - ejsMemoryError(ep); - goto err; - } - } - - if (ejsParse(ep, EJS_STATE_RELEXP, flags) < 0) { - goto err; - } - if (flags & EJS_FLAGS_EXE) { - if (ejsSetPropertyMethod(ep, obj, name, ep->result) == 0) { - ejsMemoryError(ep); - goto err; - } - } - mprFree(name); - name = 0; - - tid = getNextNonSpaceToken(ep, state); - - } while (tid == EJS_TOK_COMMA); - - if (tid != EJS_TOK_RBRACE) { - ejsSyntaxError(ep, 0); - goto err; - } - - if (flags & EJS_FLAGS_EXE) { - ejsMakeObjLive(obj, 1); - ejsWriteVar(ep, ep->result, obj, EJS_SHALLOW_COPY); - } - -done: - ejsMakeObjPermanent(saveObj, saveObjPerm); - ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), savePropPerm); - - ep->currentObj = saveObj; - ep->currentProperty = saveProperty; - - if (obj) { - ejsFreeVar(ep, obj); - } - return state; - -err: - mprFree(name); - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ - -static int parseArrayLiteral(Ejs *ep, int state, int flags, char *id) -{ - EjsProperty *saveProperty; - EjsVar *saveObj; - EjsVar *obj; - int saveObjPerm, savePropPerm, tid; - - saveObj = ep->currentObj; - saveProperty = ep->currentProperty; - - saveObjPerm = ejsMakeObjPermanent(saveObj, 1); - savePropPerm = ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), 1); - - if (flags & EJS_FLAGS_EXE) { - obj = ejsCreateArray(ep, 0); - if (obj == 0) { - ejsMemoryError(ep); - goto err; - } - mprAssert(! ejsObjIsCollectable(obj)); - - } else { - obj = 0; - } - - do { - if (ejsParse(ep, EJS_STATE_RELEXP, flags) < 0) { - goto err; - } - if (flags & EJS_FLAGS_EXE) { - /* MOB _- should this be put[array.length] */ - if (ejsAddArrayElt(ep, obj, ep->result, EJS_SHALLOW_COPY) == 0) { - goto err; - } - } - - tid = getNextNonSpaceToken(ep, state); - - } while (tid == EJS_TOK_COMMA); - - if (tid != EJS_TOK_RBRACKET) { - ejsSyntaxError(ep, "Missing right bracket"); - goto err; - } - - if (flags & EJS_FLAGS_EXE) { - ejsMakeObjLive(obj, 1); - ejsWriteVar(ep, ep->result, obj, EJS_SHALLOW_COPY); - } - -done: - ejsMakeObjPermanent(saveObj, saveObjPerm); - ejsMakeObjPermanent(ejsGetVarPtr(saveProperty), savePropPerm); - - ep->currentObj = saveObj; - ep->currentProperty = saveProperty; - - ejsFreeVar(ep, obj); - return state; - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Create a property. - */ - -/* -MOB -- simplify this. Enforce ep->currentObj to be always set. -Then we can delete this and just call - - ejsCreatePropertyMethod(ep->currentObj, id); -*/ -//XX -static int createProperty(Ejs *ep, EjsVar **objp, const char *id, int state) -{ - EjsVar *obj, *vp; - - mprAssert(id && *id); - mprAssert(objp); - - /* - * Determine the variable scope to use for the property. - * Standard says: "var x" means declare locally. - * "x = 2" means declare globally if x is undefined. - */ - if (ep->currentObj) { - if (ep->currentObj->type != EJS_TYPE_OBJECT) { - ejsSyntaxError(ep, "Reference is not an object"); - return EJS_STATE_ERR; - } - obj = ep->currentObj; - - } else { - /* MOB -- we should never be doing this here. ep->currentObj should - always be set already */ - obj = (state == EJS_STATE_DEC) ? ep->local : ep->global; - } - mprAssert(obj); - - vp = ejsCreatePropertyMethod(ep, obj, id); - if (vp == 0) { - if (!ep->gotException) { - ejsMemoryError(ep); - } - return EJS_STATE_ERR; - } - - *objp = obj; - return state; -} - -/******************************************************************************/ -/* - * Update a property. - * - * Return with ep->currentProperty updated to point to the property. - */ - -static int updateProperty(Ejs *ep, EjsVar *obj, const char *id, int state, - EjsVar *value) -{ - EjsVar *vp; - - /* - * MOB -- do ready-only check here - */ - vp = ejsSetPropertyMethod(ep, obj, id, value); - if (vp == 0) { - ejsMemoryError(ep); - return EJS_STATE_ERR; - } - ep->currentProperty = ejsGetPropertyPtr(vp); - - obj->objectState->dirty = 1; - - return state; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseCond { - EjsVar lhs, rhs; - int tid, operator; -} ParseCond; - -/* - * Parse conditional expression (relational ops separated by ||, &&) - */ - -static int parseCond(Ejs *ep, int state, int flags) -{ - ParseCond *sp; - - if ((sp = pushFrame(ep, sizeof(ParseCond))) == 0) { - return EJS_STATE_ERR; - } - - mprAssert(ep); - - if (flags & EJS_FLAGS_EXE) { - ejsClearVar(ep, ep->result); - } - - sp->lhs.type = sp->rhs.type = EJS_TYPE_UNDEFINED; - sp->lhs.objectState = sp->rhs.objectState = 0; - sp->lhs.allocatedData = sp->rhs.allocatedData = 0; - - ejsSetVarName(ep, &sp->lhs, "lhs"); - ejsSetVarName(ep, &sp->rhs, "rhs"); - - sp->operator = 0; - - do { - /* - * Recurse to handle one side of a conditional. Accumulate the - * left hand side and the final result in ep->result. - */ - state = ejsParse(ep, EJS_STATE_RELEXP, flags); - if (state < 0) { - break; - } - - if (flags & EJS_FLAGS_EXE) { - if (sp->operator > 0) { - /* - * FUTURE -- does not do precedence - */ - ejsWriteVar(ep, &sp->rhs, ep->result, EJS_SHALLOW_COPY); - if (evalCond(ep, &sp->lhs, sp->operator, &sp->rhs) < 0) { - state = EJS_STATE_ERR; - break; - } - /* Result left in ep->result */ - /* MOB */ - if (sp->lhs.type == EJS_TYPE_OBJECT) { - mprAssert(sp->lhs.objectState->alive == 0); - } - if (sp->rhs.type == EJS_TYPE_OBJECT) { - mprAssert(sp->rhs.objectState->alive == 0); - } - } - } - - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid == EJS_TOK_LOGICAL) { - sp->operator = (int) *ep->token; - - } else if (sp->tid == EJS_TOK_RPAREN || sp->tid == EJS_TOK_SEMI) { - ejsLexPutbackToken(ep, sp->tid, ep->token); - state = EJS_STATE_COND_DONE; - break; - - } else { - ejsLexPutbackToken(ep, sp->tid, ep->token); - } - - if (flags & EJS_FLAGS_EXE) { - ejsWriteVar(ep, &sp->lhs, ep->result, EJS_SHALLOW_COPY); - } - - } while (state == EJS_STATE_RELEXP_DONE); - - ejsClearVar(ep, &sp->lhs); - ejsClearVar(ep, &sp->rhs); - - popFrame(ep, sizeof(ParseCond)); - - return state; -} - -/******************************************************************************/ -/* - * Parse variable declaration list. Declarations can be of the following forms: - * var x; - * var x, y, z; - * var x = 1 + 2 / 3, y = 2 + 4; - * var x = { property: value, property: value ... }; - * var x = [ property: value, property: value ... ]; - * - * We set the variable to NULL if there is no associated assignment. - */ - -static int parseDeclaration(Ejs *ep, int state, int flags) -{ - int tid; - - mprAssert(ep); - - do { - if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) { - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - ejsLexPutbackToken(ep, tid, ep->token); - - /* - * Parse the entire assignment or simple identifier declaration - */ - if (ejsParse(ep, EJS_STATE_DEC, flags) != EJS_STATE_DEC_DONE) { - return EJS_STATE_ERR; - } - - /* - * Peek at the next token, continue if comma seen - * Stop on ";" or "in" which is used in a "for (var x in ..." - */ - tid = ejsLexGetToken(ep, state); - - if (tid == EJS_TOK_SEMI) { - return EJS_STATE_DEC_LIST_DONE; - - } else if (tid == EJS_TOK_IN) { - ejsLexPutbackToken(ep, tid, ep->token); - return EJS_STATE_DEC_LIST_DONE; - - } else if (flags & EJS_FLAGS_CLASS_DEC && - (tid == EJS_TOK_LBRACE || tid == EJS_TOK_EXTENDS)) { - ejsLexPutbackToken(ep, tid, ep->token); - return EJS_STATE_DEC_LIST_DONE; - - } else if (tid == EJS_TOK_RPAREN && flags & EJS_FLAGS_CATCH) { - ejsLexPutbackToken(ep, tid, ep->token); - return EJS_STATE_DEC_LIST_DONE; - - } else if (tid != EJS_TOK_COMMA) { - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - - } while (tid == EJS_TOK_COMMA); - - if (tid != EJS_TOK_SEMI) { - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - return EJS_STATE_DEC_LIST_DONE; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseExpr { - EjsVar lhs, rhs; - int rel, tid, unaryMinus; -} ParseExpr; - -/* - * Parse expression (leftHandSide operator rightHandSide) - */ - -static int parseExpr(Ejs *ep, int state, int flags) -{ - ParseExpr *sp; - - mprAssert(ep); - - if ((sp = pushFrame(ep, sizeof(ParseExpr))) == 0) { - return EJS_STATE_ERR; - } - - if (flags & EJS_FLAGS_EXE) { - ejsClearVar(ep, ep->result); - } - - sp->lhs.type = sp->rhs.type = EJS_TYPE_UNDEFINED; - sp->lhs.objectState = sp->rhs.objectState = 0; - sp->lhs.allocatedData = sp->rhs.allocatedData = 0; - - ejsSetVarName(ep, &sp->lhs, "lhs"); - ejsSetVarName(ep, &sp->rhs, "rhs"); - - sp->rel = 0; - sp->tid = 0; - sp->unaryMinus = 0; - - do { - /* - * This loop will handle an entire expression list. We call parse - * to evalutate each term which returns the result in ep->result. - */ - if (sp->tid == EJS_TOK_LOGICAL) { - state = ejsParse(ep, EJS_STATE_RELEXP, flags); - if (state < 0) { - break; - } - } else { - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid == EJS_TOK_EXPR && (int) *ep->token == EJS_EXPR_MINUS) { - sp->unaryMinus = 1; - - } else { - ejsLexPutbackToken(ep, sp->tid, ep->token); - } - - state = ejsParse(ep, EJS_STATE_EXPR, flags); - if (state < 0) { - break; - } - } - - if (flags & EJS_FLAGS_EXE) { - if (sp->unaryMinus) { - switch (ep->result->type) { - default: - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_STRING_CMETHOD: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_METHOD: - case EJS_TYPE_PTR: - case EJS_TYPE_OBJECT: - case EJS_TYPE_STRING: - case EJS_TYPE_BOOL: - ejsError(ep, EJS_SYNTAX_ERROR, "Invalid unary minus"); - state = EJS_STATE_ERR; - break; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - ep->result->floating = - ep->result->floating; - break; -#endif - - case EJS_TYPE_INT: - ep->result->integer = - ep->result->integer; - break; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - ep->result->integer64 = - ep->result->integer64; - break; -#endif - } - } - sp->unaryMinus = 0; - - if (sp->rel > 0) { - ejsWriteVar(ep, &sp->rhs, ep->result, EJS_SHALLOW_COPY); - if (sp->tid == EJS_TOK_LOGICAL) { - if (evalCond(ep, &sp->lhs, sp->rel, &sp->rhs) < 0) { - state = EJS_STATE_ERR; - break; - } - } else { - if (evalExpr(ep, &sp->lhs, sp->rel, &sp->rhs) < 0) { - state = EJS_STATE_ERR; - break; - } - } - } - /* MOB */ - if (sp->lhs.type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(&sp->lhs, 0); - mprAssert(sp->lhs.objectState->alive == 0); - } - if (sp->rhs.type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(&sp->rhs, 0); - mprAssert(sp->rhs.objectState->alive == 0); - } - } - - if ((sp->tid = ejsLexGetToken(ep, state)) == EJS_TOK_EXPR || - sp->tid == EJS_TOK_INC_DEC || sp->tid == EJS_TOK_LOGICAL) { - sp->rel = (int) *ep->token; - ejsWriteVar(ep, &sp->lhs, ep->result, EJS_SHALLOW_COPY); - - } else { - ejsLexPutbackToken(ep, sp->tid, ep->token); - state = EJS_STATE_RELEXP_DONE; - } - - } while (state == EJS_STATE_EXPR_DONE); - - ejsClearVar(ep, &sp->lhs); - ejsClearVar(ep, &sp->rhs); - - popFrame(ep, sizeof(ParseExpr)); - - return state; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseForIn { - EjsInput *endScript, *bodyScript; - EjsProperty *pp, *nextp; - EjsVar *iteratorVar, *setVar, *vp; - int forFlags, tid; -} ParseForIn; - -/* - * Parse the "for ... in" statement. Format for the statement is: - * - * for [each] (var varName in expression) { - * body; - * } - */ - -static int parseForIn(Ejs *ep, int state, int flags, int each) -{ - ParseForIn *sp; - - mprAssert(ep); - - if ((sp = pushFrame(ep, sizeof(ParseForIn))) == 0) { - return EJS_STATE_ERR; - } - - sp->setVar = 0; - sp->iteratorVar = 0; - sp->bodyScript = 0; - sp->endScript = 0; - - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid != EJS_TOK_ID && sp->tid != EJS_TOK_VAR) { - ejsSyntaxError(ep, 0); - goto err; - } - ejsLexPutbackToken(ep, sp->tid, ep->token); - - state = ejsParse(ep, EJS_STATE_EXPR, EJS_FLAGS_FORIN | flags); - if (state < 0) { - goto done; - } - if (flags & EJS_FLAGS_EXE) { - if (ep->currentProperty == 0) { - ejsSyntaxError(ep, 0); - goto err; - } - sp->iteratorVar = &ep->currentProperty->var; - } else { - sp->iteratorVar = 0; - } - - if (ejsLexGetToken(ep, state) != EJS_TOK_IN) { - ejsSyntaxError(ep, 0); - goto err; - } - - /* - * Get the set - */ - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid != EJS_TOK_ID) { - ejsSyntaxError(ep, 0); - goto err; - } - ejsLexPutbackToken(ep, sp->tid, ep->token); - - state = ejsParse(ep, EJS_STATE_EXPR, flags); - if (state < 0) { - goto done; - } - - if ((flags & EJS_FLAGS_EXE) && - (ep->result == 0 || ep->result->type == EJS_TYPE_UNDEFINED)) { - ejsError(ep, EJS_REFERENCE_ERROR, "Can't access array or object"); - goto err; - } - - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - ejsSyntaxError(ep, 0); - goto err; - } - - sp->setVar = ejsDupVar(ep, ep->result, EJS_SHALLOW_COPY); - - sp->bodyScript = getInputStruct(ep); - - /* - * Parse the body and remember the end of the body script - */ - sp->forFlags = flags & ~EJS_FLAGS_EXE; - ejsLexSaveInputState(ep, sp->bodyScript); - - state = ejsParse(ep, EJS_STATE_STMT, sp->forFlags); - if (state < 0) { - goto done; - } - - sp->endScript = getInputStruct(ep); - ejsInitInputState(sp->endScript); - ejsLexSaveInputState(ep, sp->endScript); - - /* - * Enumerate the properties - */ - if (flags & EJS_FLAGS_EXE) { - if (sp->setVar->type == EJS_TYPE_OBJECT) { - - sp->setVar->objectState->preventDeleteProp = 1; - - sp->pp = ejsGetFirstProperty(sp->setVar, 0); - while (sp->pp) { - sp->nextp = ejsGetNextProperty(sp->pp, 0); - if (! sp->pp->dontEnumerate && !sp->pp->delayedDelete) { - if (each) { - sp->vp = ejsWriteVar(ep, sp->iteratorVar, - ejsGetVarPtr(sp->pp), EJS_SHALLOW_COPY); - } else { - sp->vp = ejsWriteVarAsString(ep, sp->iteratorVar, - sp->pp->name); - } - if (sp->vp == 0) { - ejsError(ep, EJS_MEMORY_ERROR, - "Can't write to variable"); - goto err; - } - - ejsLexRestoreInputState(ep, sp->bodyScript); - - state = ejsParse(ep, EJS_STATE_STMT, flags); - - if (state < 0) { - if (sp->setVar->objectState) { - sp->setVar->objectState->preventDeleteProp = 0; - } - goto done; - } - } - sp->pp = sp->nextp; - } - - /* - * Process delayed deletes - */ - if (sp->setVar->objectState) { - sp->setVar->objectState->preventDeleteProp = 0; - if (sp->setVar->objectState->delayedDeleteProp) { - sp->pp = ejsGetFirstProperty(sp->setVar, 0); - while (sp->pp) { - sp->nextp = ejsGetNextProperty(sp->pp, 0); - if (sp->pp->delayedDelete) { - ejsDeleteProperty(ep, sp->setVar, sp->pp->name); - } - sp->pp = sp->nextp; - } - sp->setVar->objectState->delayedDeleteProp = 0; - } - } - - } else { - ejsError(ep, EJS_REFERENCE_ERROR, - "Variable to iterate over is not an array or object"); - goto err; - } - } - - ejsLexRestoreInputState(ep, sp->endScript); - -done: - if (sp->endScript) { - ejsLexFreeInputState(ep, sp->endScript); - ejsLexFreeInputState(ep, sp->bodyScript); - } - - if (sp->bodyScript) { - freeInputStruct(ep, sp->bodyScript); - } - if (sp->endScript) { - freeInputStruct(ep, sp->endScript); - } - - if (sp->setVar) { - ejsFreeVar(ep, sp->setVar); - } - - popFrame(ep, sizeof(ParseForIn)); - - return state; - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Parse the for statement. Format for the expression is: - * - * for (initial; condition; incr) { - * body; - * } - */ - -static int parseRegFor(Ejs *ep, int state, int flags) -{ - EjsInput *condScript, *endScript, *bodyScript, *incrScript; - - endScript = getInputStruct(ep); - bodyScript = getInputStruct(ep); - incrScript = getInputStruct(ep); - condScript = getInputStruct(ep); - - ejsInitInputState(endScript); - ejsInitInputState(bodyScript); - ejsInitInputState(incrScript); - ejsInitInputState(condScript); - - state = parseForInner(ep, state, flags, - condScript, incrScript, bodyScript, endScript); - - ejsLexFreeInputState(ep, condScript); - ejsLexFreeInputState(ep, incrScript); - ejsLexFreeInputState(ep, endScript); - ejsLexFreeInputState(ep, bodyScript); - - freeInputStruct(ep, condScript); - freeInputStruct(ep, incrScript); - freeInputStruct(ep, endScript); - freeInputStruct(ep, bodyScript); - - return state; -} - -/******************************************************************************/ - -static int parseForInner(Ejs *ep, int state, int flags, EjsInput *condScript, - EjsInput *incrScript, EjsInput *bodyScript, EjsInput *endScript) -{ - int forFlags, cond, rs; - - mprAssert(ep); - - /* - * Evaluate the for loop initialization statement - */ - if ((state = ejsParse(ep, EJS_STATE_STMT, flags)) < 0) { - return state; - } - - /* - * The first time through, we save the current input context just prior - * to each step: prior to the conditional, the loop increment and - * the loop body. - */ - ejsLexSaveInputState(ep, condScript); - if ((rs = ejsParse(ep, EJS_STATE_COND, flags)) < 0) { - return rs; - } - - cond = (ep->result->boolean != 0); - - if (ejsLexGetToken(ep, state) != EJS_TOK_SEMI) { - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - - /* - * Don't execute the loop increment statement or the body - * first time. - */ - forFlags = flags & ~EJS_FLAGS_EXE; - ejsLexSaveInputState(ep, incrScript); - if ((rs = ejsParse(ep, EJS_STATE_EXPR, forFlags)) < 0) { - return rs; - } - - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - - /* - * Parse the body and remember the end of the body script - */ - ejsLexSaveInputState(ep, bodyScript); - if ((rs = ejsParse(ep, EJS_STATE_STMT, forFlags)) < 0) { - return rs; - } - ejsLexSaveInputState(ep, endScript); - - /* - * Now actually do the for loop. Note loop has been rotated - */ - while (cond && (flags & EJS_FLAGS_EXE)) { - /* - * Evaluate the body - */ - ejsLexRestoreInputState(ep, bodyScript); - - if ((rs = ejsParse(ep, EJS_STATE_STMT, flags)) < 0) { - return rs; - } - - /* - * Evaluate the increment script - */ - ejsLexRestoreInputState(ep, incrScript); - if ((rs = ejsParse(ep, EJS_STATE_EXPR, flags)) < 0) { - return rs; - } - /* - * Evaluate the condition - */ - ejsLexRestoreInputState(ep, condScript); - if ((rs = ejsParse(ep, EJS_STATE_COND, flags)) < 0) { - return 0; - } - mprAssert(ep->result->type == EJS_TYPE_BOOL); - cond = (ep->result->boolean != 0); - } - - ejsLexRestoreInputState(ep, endScript); - - return state; -} - -/******************************************************************************/ -/* - * Create the bare class object - */ - -static int createClass(Ejs *ep, EjsVar *obj, const char *className, - EjsVar *baseClass) -{ - EjsVar *classObj, *existingClass; - - existingClass = ejsGetClass(ep, obj, className); - if (existingClass) { - /* - * We allow partial clases and method redefinition - * FUTURE -- should prevent this if the class is sealed. - * DISABLED Error message and return OK. - */ - /* ejsError(ep, EJS_EVAL_ERROR, "Can't create class %s", className); */ - return 0; - } - - if (baseClass == 0) { - baseClass = ejsGetClass(ep, ep->service->globalClass, "Object"); - mprAssert(baseClass); - } - - classObj = ejsCreateSimpleClass(ep, baseClass, className); - if (classObj == 0) { - ejsMemoryError(ep); - return -1; - } - mprAssert(! ejsObjIsCollectable(classObj)); - - ep->currentProperty = ejsSetPropertyAndFree(ep, obj, className, classObj); - mprAssert(ep->currentProperty); - - if (ep->currentProperty == 0) { - return -1; - } - - return 0; -} - -/******************************************************************************/ -/* - * Local vars for parseTry - */ - -typedef struct ParseTry { - EjsVar *exception; - int tid, caught, rs, catchFlags; -} ParseTry; - -/* - * Parse try block - * - * try {} - */ - -static int parseTry(Ejs *ep, int state, int flags) -{ - ParseTry *sp; - - if ((sp = pushFrame(ep, sizeof(ParseTry))) == 0) { - return EJS_STATE_ERR; - } - - mprAssert(ep); - - sp->caught = 0; - sp->exception = 0; - sp->catchFlags = flags; - - /* - * Execute the code in the try block - */ - sp->rs = ejsParse(ep, EJS_STATE_STMT, flags | EJS_FLAGS_TRY); - if (sp->rs < 0) { - if (sp->rs == EJS_STATE_ERR) { - sp->exception = ejsDupVar(ep, ep->result, EJS_SHALLOW_COPY); - if (sp->exception == 0) { - ejsMemoryError(ep); - goto err; - } - } else { - state = sp->rs; - goto done; - } - - } else { - sp->catchFlags = flags & ~EJS_FLAGS_EXE; - } - - /* - * On success path or when an exception is caught, we must parse all - * catch and finally blocks. - */ - sp->tid = getNextNonSpaceToken(ep, state); - - if (sp->tid == EJS_TOK_CATCH) { - - ep->gotException = 0; - - sp->tid = getNextNonSpaceToken(ep, state); - - if (sp->tid == EJS_TOK_LBRACE) { - /* - * Unqualified "catch " - */ - ejsLexPutbackToken(ep, sp->tid, ep->token); - if (ejsParse(ep, EJS_STATE_STMT, sp->catchFlags) >= 0) { - sp->caught++; - } - - } else if (sp->tid == EJS_TOK_LPAREN) { - - /* - * Qualified "catch (variable) " - */ - if ((sp->rs = ejsParse(ep, EJS_STATE_DEC_LIST, - sp->catchFlags | EJS_FLAGS_CATCH)) < 0) { - ejsSyntaxError(ep, "Bad catch statement"); - state = sp->rs; - goto done; - } - - sp->tid = getNextNonSpaceToken(ep, state); - if (sp->tid != EJS_TOK_RPAREN) { - ejsSyntaxError(ep, 0); - goto err; - } - - if (sp->catchFlags & EJS_FLAGS_EXE) { - if (ep->currentProperty == 0) { - ejsError(ep, EJS_EVAL_ERROR, "Can't define catch variable"); - goto err; - } - - /* - * Set the catch variable - */ - if (ejsWriteVar(ep, - ejsGetVarPtr(ep->currentProperty), sp->exception, - EJS_SHALLOW_COPY) == 0) { - ejsError(ep, EJS_EVAL_ERROR, "Can't update catch variable"); - goto err; - } - } - - /* - * Parse the catch block - */ - if ((sp->rs = ejsParse(ep, EJS_STATE_STMT, sp->catchFlags)) < 0) { - state = sp->rs; - goto done; - } - sp->caught++; - ep->gotException = 0; - } - sp->tid = getNextNonSpaceToken(ep, state); - } - - /* - * Parse the finally block - */ - if (sp->tid == EJS_TOK_FINALLY) { - if (ejsParse(ep, EJS_STATE_STMT, flags) < 0) { - goto err; - } - } else { - ejsLexPutbackToken(ep, sp->tid, ep->token); - } - - /* - * Set the exception value - */ - if (sp->exception && !sp->caught) { - ejsWriteVar(ep, ep->result, sp->exception, EJS_SHALLOW_COPY); - goto err; - } - - state = EJS_STATE_STMT_DONE; - -done: - if (sp->exception) { - ejsFreeVar(ep, sp->exception); - } - - popFrame(ep, sizeof(ParseTry)); - return state; - - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Parse throw statement - * - * throw expression - */ - -static int parseThrow(Ejs *ep, int state, int flags) -{ - int rc; - - mprAssert(ep); - - if ((rc = ejsParse(ep, EJS_STATE_EXPR, flags)) < 0) { - return rc; - } - - - if (flags & EJS_FLAGS_EXE) { - /* - * We have thrown the exception so set the state to ERR - */ - ep->gotException = 1; - return EJS_STATE_ERR; - } - return state; -} - -/******************************************************************************/ -/* - * Parse a class and module declaration - * - * class [extends baseClass] { - * [public | private | ... ] var declarations ... - * [constructor] function declarations ... - * } - * - * Modules are identical except declared with a "module" instead of - * "class". Modules cannot be instantiated and are used for mixins. - * - */ - -static int parseClass(Ejs *ep, int state, int flags) -{ - int originalToken, tid, fid; - - mprAssert(ep); - - originalToken = ep->tid; - - /* - * Parse "class Name [extends BaseClass]" - */ - if (ejsParse(ep, EJS_STATE_DEC_LIST, flags | EJS_FLAGS_CLASS_DEC) < 0) { - return EJS_STATE_ERR; - } - - tid = getNextNonSpaceToken(ep, state); - - if (tid != EJS_TOK_LBRACE) { - return EJS_STATE_ERR; - } - - /* - * After parsing the class body, ep->local will contain the actual - * class/module object. So, we save ep->local by creating a new block. - */ - if (flags & EJS_FLAGS_EXE) { - fid = ejsSetBlock(ep, ejsGetVarPtr(ep->currentProperty)); - ejsSetVarName(ep, ep->local, ep->currentProperty->name); - - } else { - fid = -1; - } - - /* FUTURE -- should prevent modules from being instantiated */ - - /* - * Parse class body - */ - do { - state = ejsParse(ep, EJS_STATE_STMT, flags); - if (state < 0) { - if (fid >= 0) { - ejsCloseBlock(ep, fid); - } - return state; - } - tid = getNextNonSpaceToken(ep, state); - if (tid == EJS_TOK_RBRACE) { - break; - } - ejsLexPutbackToken(ep, tid, ep->token); - - } while (state >= 0); - - if (fid >= 0) { - ejsCloseBlock(ep, fid); - } - - if (tid != EJS_TOK_RBRACE) { - ejsSyntaxError(ep, 0); - state = EJS_STATE_ERR; - } - - return state; -} - -/******************************************************************************/ -/* - * Parse a function declaration - */ - -static int parseFunction(Ejs *ep, int state, int flags) -{ - EjsInput *endScript, *bodyScript; - EjsProperty *pp; - EjsVar *func, *funcProp, *currentObj, *vp, *baseClass; - char *procName; - int varFlags, len, tid, bodyFlags, innerState; - - mprAssert(ep); - - func = 0; - varFlags = 0; - - /* - * method (arg, arg, arg) { body }; - * method name(arg, arg, arg) { body }; - */ - - tid = ejsLexGetToken(ep, state); - - if (tid == EJS_TOK_GET) { - varFlags |= EJS_GET_ACCESSOR; - tid = ejsLexGetToken(ep, state); - - } else if (tid == EJS_TOK_SET) { - varFlags |= EJS_SET_ACCESSOR; - tid = ejsLexGetToken(ep, state); - } - - if (tid == EJS_TOK_ID) { - if (varFlags & EJS_SET_ACCESSOR) { - - if (mprAllocStrcat(MPR_LOC_ARGS(ep), &procName, EJS_MAX_ID + 5, - 0, "-set-", ep->token, 0) < 0) { - ejsError(ep, EJS_SYNTAX_ERROR, - "Name %s is too long", ep->token); - return EJS_STATE_ERR; - } - - } else { - procName = mprStrdup(ep, ep->token); - } - - tid = ejsLexGetToken(ep, state); - - } else { - procName = 0; - } - - if (tid != EJS_TOK_LPAREN) { - mprFree(procName); - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - - /* - * Hand craft the method value structure. - */ - if (flags & EJS_FLAGS_EXE) { - func = ejsCreateMethodVar(ep, 0, 0, 0); - if (func == 0) { - mprFree(procName); - ejsMemoryError(ep); - return EJS_STATE_ERR; - } - func->flags = varFlags; - } - - tid = ejsLexGetToken(ep, state); - while (tid == EJS_TOK_ID) { - if (flags & EJS_FLAGS_EXE) { - mprAddItem(func->method.args, - mprStrdup(func->method.args, ep->token)); - } - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_RPAREN || tid != EJS_TOK_COMMA) { - break; - } - tid = ejsLexGetToken(ep, state); - } - if (tid != EJS_TOK_RPAREN) { - mprFree(procName); - ejsFreeVar(ep, func); - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - - /* Allow new lines before opening brace */ - do { - tid = ejsLexGetToken(ep, state); - } while (tid == EJS_TOK_NEWLINE); - - if (tid != EJS_TOK_LBRACE) { - mprFree(procName); - ejsFreeVar(ep, func); - ejsSyntaxError(ep, 0); - return EJS_STATE_ERR; - } - - /* - * Register the method name early to allow for recursive - * method calls (see note in ECMA standard, page 71) - */ - funcProp = 0; - if (flags & EJS_FLAGS_EXE && procName) { - currentObj = pickSpace(ep, 0, procName, flags | EJS_FLAGS_LOCAL); - pp = ejsSetProperty(ep, currentObj, procName, func); - if (pp == 0) { - ejsFreeVar(ep, func); - ejsMemoryError(ep); - return EJS_STATE_ERR; - } - funcProp = ejsGetVarPtr(pp); - } - - - bodyScript = getInputStruct(ep); - - /* - * Parse the method body. Turn execute off. - */ - bodyFlags = flags & ~EJS_FLAGS_EXE; - ejsLexSaveInputState(ep, bodyScript); - - do { - innerState = ejsParse(ep, EJS_STATE_STMT, bodyFlags); - } while (innerState == EJS_STATE_STMT_DONE); - - tid = ejsLexGetToken(ep, state); - - if (innerState != EJS_STATE_STMT_BLOCK_DONE || tid != EJS_TOK_RBRACE) { - mprFree(procName); - ejsFreeVar(ep, func); - ejsLexFreeInputState(ep, bodyScript); - if (innerState != EJS_STATE_ERR) { - ejsSyntaxError(ep, 0); - } - freeInputStruct(ep, bodyScript); - return EJS_STATE_ERR; - } - - if (flags & EJS_FLAGS_EXE) { - endScript = getInputStruct(ep); - ejsLexSaveInputState(ep, endScript); - - /* - * Save the method body between the starting and ending parse - * positions. Overwrite the trailing '}' with a null. - */ - len = endScript->scriptServp - bodyScript->scriptServp; - func->method.body = mprAlloc(ep, len + 1); - memcpy(func->method.body, bodyScript->scriptServp, len); - - if (len <= 0) { - func->method.body[0] = '\0'; - } else { - func->method.body[len - 1] = '\0'; - } - ejsLexFreeInputState(ep, bodyScript); - ejsLexFreeInputState(ep, endScript); - freeInputStruct(ep, endScript); - - /* - * If we are in an assignment, don't register the method name, rather - * return the method structure in the parser result. - */ - if (procName) { - currentObj = pickSpace(ep, 0, procName, flags | EJS_FLAGS_LOCAL); - pp = ejsSetProperty(ep, currentObj, procName, func); - if (pp == 0) { - ejsFreeVar(ep, func); - ejsMemoryError(ep); - return EJS_STATE_ERR; - } - - if (currentObj->objectState->className && - strcmp(currentObj->objectState->className, procName) == 0) { - baseClass = currentObj->objectState->baseClass; - if (baseClass) { - if (strstr(func->method.body, "super(") != 0) { - funcProp->callsSuper = 1; - /* - * Define super() to point to the baseClass constructor - */ - vp = ejsGetPropertyAsVar(ep, baseClass, - baseClass->objectState->className); - if (vp) { - mprAssert(vp); - if (ejsSetProperty(ep, currentObj, "super", - vp) == 0) { - ejsFreeVar(ep, func); - ejsMemoryError(ep); - return EJS_STATE_ERR; - } - } - } - } - } - } - /* - * Always return the function. Try for all stmts to be expressions. - */ - /* MOB - rc */ - ejsWriteVar(ep, ep->result, func, EJS_SHALLOW_COPY); - } - freeInputStruct(ep, bodyScript); - - mprFree(procName); - ejsFreeVar(ep, func); - - return state; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseMethod { - EjsProc proc, *saveProc; - EjsVar *saveObj, *newObj; - int saveObjPerm, rc; - -} ParseMethod; - -/* - * Parse a method name and invoke the method. See parseFunction for - * function declarations. - */ - -static int parseMethod(Ejs *ep, int state, int flags, char *id) -{ - ParseMethod *sp; - - if ((sp = pushFrame(ep, sizeof(ParseMethod))) == 0) { - return EJS_STATE_ERR; - } - - /* - * Must save any current ep->proc value for the current stack frame - * to allow for recursive method calls. - */ - sp->saveProc = (ep->proc) ? ep->proc: 0; - - memset(&sp->proc, 0, sizeof(EjsProc)); - sp->proc.procName = mprStrdup(ep, id); - sp->proc.fn = &ep->currentProperty->var; - sp->proc.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - ep->proc = &sp->proc; - -#if BLD_DEBUG - if (strcmp(sp->proc.procName, "printv") == 0) { - flags |= EJS_FLAGS_TRACE_ARGS; - } -#endif - - if (flags & EJS_FLAGS_EXE) { - ejsClearVar(ep, ep->result); - } - - if (! (flags & EJS_FLAGS_NO_ARGS)) { - sp->saveObj = ep->currentObj; - sp->saveObjPerm = ejsMakeObjPermanent(sp->saveObj, 1); - sp->rc = ejsParse(ep, EJS_STATE_ARG_LIST, flags); - ejsMakeObjPermanent(sp->saveObj, sp->saveObjPerm); - if (sp->rc < 0) { - goto err; - } - ep->currentObj = sp->saveObj; - } - -#if BLD_DEBUG - flags &= ~EJS_FLAGS_TRACE_ARGS; -#endif - - /* - * Evaluate the method if required - */ - if (flags & EJS_FLAGS_EXE) { - if (flags & EJS_FLAGS_NEW) { - sp->newObj = ejsCreateObjUsingArgv(ep, ep->currentObj, - sp->proc.procName, sp->proc.args); - - if (sp->newObj == 0) { - state = EJS_STATE_ERR; - - } else { - mprAssert(! ejsObjIsCollectable(sp->newObj)); - - /* - * Return the newly created object as the result of the - * command. NOTE: newObj may not be an object! - */ - /* MOB - rc */ - ejsWriteVar(ep, ep->result, sp->newObj, EJS_SHALLOW_COPY); - if (ejsVarIsObject(sp->newObj)) { - ejsMakeObjLive(sp->newObj, 1); - mprAssert(ejsObjIsCollectable(sp->newObj)); - mprAssert(ejsBlockInUse(sp->newObj)); - } - ejsFreeVar(ep, sp->newObj); - } - - } else { - - if (evalMethod(ep, ep->currentObj, &sp->proc, flags) < 0) { - /* Methods must call ejsError to set exceptions */ - state = EJS_STATE_ERR; - } - } - } - - if (! (flags & EJS_FLAGS_NO_ARGS)) { - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - if (state != EJS_STATE_ERR) { - ejsSyntaxError(ep, 0); - } - state = EJS_STATE_ERR; - } - } - -done: - freeProc(ep, &sp->proc); - ep->proc = sp->saveProc; - - popFrame(ep, sizeof(ParseMethod)); - return state; - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Parse an identifier. This is a segment of a fully qualified variable. - * May come here for an initial identifier or for property names - * after a "." or "[...]". - */ - -static int parseId(Ejs *ep, int state, int flags, char **id, int *done) -{ - EjsVar *null; - int tid; - - mprFree(*id); - *id = mprStrdup(ep, ep->token); - - if (ep->currentObj == 0) { - /* First identifier segement */ - ep->currentObj = pickSpace(ep, state, *id, flags); - } - - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_ASSIGNMENT) { - flags |= EJS_FLAGS_LHS; - } - - /* - * Find the referenced variable and store it in currentProperty. - */ - if (flags & EJS_FLAGS_EXE) { - ep->currentProperty = searchSpacesForProperty(ep, state, - ep->currentObj, *id, flags); - - /* - * Handle properties that have been deleted inside an enumeration - */ - if (ep->currentProperty && ep->currentProperty->delayedDelete) { - ep->currentProperty = 0; - } - - if (ep->currentProperty && - ejsVarIsMethod(&ep->currentProperty->var) && - tid != EJS_TOK_LPAREN) { - if (ep->currentProperty->var.flags & EJS_GET_ACCESSOR) { - ejsLexPutbackToken(ep, tid, ep->token); - state = parseMethod(ep, state, flags | EJS_FLAGS_NO_ARGS, *id); - if (ep->flags & EJS_FLAGS_EXIT) { - state = EJS_STATE_RET; - } - if (state >= 0) { - ejsSetVarName(ep, ep->result, ep->currentProperty->name); - } - return state; - } - } - /* - * OPT. We should not have to do this always - */ - updateResult(ep, state, flags, ejsGetVarPtr(ep->currentProperty)); - } - - flags &= ~EJS_FLAGS_LHS; - - if (tid == EJS_TOK_LPAREN) { - if (ep->currentProperty == 0 && (flags & EJS_FLAGS_EXE)) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Method name not defined \"%s\"", *id); - return EJS_STATE_ERR; - } - ejsLexPutbackToken(ep, EJS_TOK_METHOD_NAME, ep->token); - return state; - } - - if (tid == EJS_TOK_PERIOD || tid == EJS_TOK_LBRACKET || - tid == EJS_TOK_ASSIGNMENT || tid == EJS_TOK_INC_DEC) { - ejsLexPutbackToken(ep, tid, ep->token); - return state; - } - - if (flags & EJS_FLAGS_CLASS_DEC) { - if (tid == EJS_TOK_LBRACE || tid == EJS_TOK_EXTENDS) { - ejsLexPutbackToken(ep, tid, ep->token); - return state; - } - } - - if (flags & EJS_FLAGS_DELETE) { - if (tid == EJS_TOK_RBRACE) { - ejsLexPutbackToken(ep, tid, ep->token); - } - } - - /* - * Only come here for variable access and declarations. - * Assignment handled elsewhere. - */ - if (flags & EJS_FLAGS_EXE) { - if (state == EJS_STATE_DEC) { - /* - * Declare a variable. Standard allows: var x ; var x ; - */ -#if DISABLED - if (ep->currentProperty != 0) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Variable already defined \"%s\"", *id); - return EJS_STATE_ERR; - } -#endif - /* - * Create or overwrite if it already exists - * Set newly declared variables to the null value. - */ - null = ejsCreateNullVar(ep); - ep->currentProperty = ejsSetPropertyAndFree(ep, ep->currentObj, - *id, null); - ejsClearVar(ep, ep->result); - - } else if (flags & EJS_FLAGS_FORIN) { - /* - * This allows "for (x" when x has not yet been defined - */ - if (ep->currentProperty == 0) { - /* MOB -- return code */ - ep->currentProperty = ejsCreateProperty(ep, - ep->currentObj, *id); - } - - } else if (ep->currentProperty == 0) { - - if (ep->currentObj && ((ep->currentObj == ep->global || - (ep->currentObj == ep->local)))) { - /* - * Test against currentObj and not currentObj->objectState - * as we must allow "i = global.x" and not allow - * "i = x" where x does not exist. - */ - ejsError(ep, EJS_REFERENCE_ERROR, - "Undefined variable \"%s\"", *id); - return EJS_STATE_ERR; - } - - if (flags & EJS_FLAGS_DELETE) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Undefined variable \"%s\"", *id); - return EJS_STATE_ERR; - } - } - } - ejsLexPutbackToken(ep, tid, ep->token); - if (tid == EJS_TOK_RBRACKET || tid == EJS_TOK_COMMA || - tid == EJS_TOK_IN) { - *done = 1; - } - return state; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct ParseIf { - int ifResult, thenFlags, elseFlags, tid, rs; -} ParseIf; - -/* - * Parse an "if" statement - */ - -static int parseIf(Ejs *ep, int state, int flags, int *done) -{ - ParseIf *sp; - - if ((sp = pushFrame(ep, sizeof(ParseIf))) == 0) { - return EJS_STATE_ERR; - } - - if (state != EJS_STATE_STMT) { - goto err; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_LPAREN) { - goto err; - } - - /* - * Evaluate the entire condition list "(condition)" - */ - if (ejsParse(ep, EJS_STATE_COND, flags) < 0) { - goto err; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - goto err; - } - - /* - * This is the "then" case. We need to always parse both cases and - * execute only the relevant case. - */ - sp->ifResult = ejsVarToBoolean(ep->result); - if (sp->ifResult) { - sp->thenFlags = flags; - sp->elseFlags = flags & ~EJS_FLAGS_EXE; - } else { - sp->thenFlags = flags & ~EJS_FLAGS_EXE; - sp->elseFlags = flags; - } - - /* - * Process the "then" case. - */ - if ((sp->rs = ejsParse(ep, EJS_STATE_STMT, sp->thenFlags)) < 0) { - if (! ep->gotException) { - state = sp->rs; - goto done; - } - } - - /* - * Check to see if there is an "else" case - */ - removeNewlines(ep, state); - sp->tid = ejsLexGetToken(ep, state); - if (sp->tid != EJS_TOK_ELSE) { - ejsLexPutbackToken(ep, sp->tid, ep->token); - *done = 1; - if (ep->gotException) { - goto err; - } - goto done; - } - - /* - * Process the "else" case. - */ - state = ejsParse(ep, EJS_STATE_STMT, sp->elseFlags); - -done: - *done = 1; - if (ep->gotException) { - state = EJS_STATE_ERR; - } - popFrame(ep, sizeof(ParseIf)); - return state; - - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Parse a postix "++" or "--" statement - */ - -static int parseInc(Ejs *ep, int state, int flags) -{ - EjsVar *one; - - if (! (flags & EJS_FLAGS_EXE)) { - return state; - } - - if (ep->currentProperty == 0) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Undefined variable \"%s\"", ep->token); - return EJS_STATE_ERR; - } - one = ejsCreateIntegerVar(ep, 1); - if (evalExpr(ep, &ep->currentProperty->var, (int) *ep->token, one) < 0) { - ejsFreeVar(ep, one); - return EJS_STATE_ERR; - } - if (ejsWriteVar(ep, &ep->currentProperty->var, ep->result, - EJS_SHALLOW_COPY) < 0) { - ejsError(ep, EJS_IO_ERROR, "Can't write to variable"); - ejsFreeVar(ep, one); - return EJS_STATE_ERR; - } - ejsFreeVar(ep, one); - return state; -} - -/******************************************************************************/ -/* - * Evaluate a condition. Implements &&, ||, !. Returns with a boolean result - * in ep->result. Returns EJS_STATE_ERR on errors, zero if successful. - */ - -static int evalCond(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs) -{ - int l, r, lval; - - mprAssert(rel > 0); - - l = ejsVarToBoolean(lhs); - r = ejsVarToBoolean(rhs); - - switch (rel) { - case EJS_COND_AND: - lval = l && r; - break; - case EJS_COND_OR: - lval = l || r; - break; - default: - ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel); - return -1; - } - - /* MOB - rc */ - ejsWriteVarAsBoolean(ep, ep->result, lval); - return 0; -} - - -/******************************************************************************/ -/* - * return true if this string is a valid number - */ - -static int stringIsNumber(const char *s) -{ - char *endptr = NULL; - - if (s == NULL || *s == 0) { - return 0; - } - /* MOB -- not ideal */ -#if BREW - /* MOB this should check all digits and not just the first. */ - /* Does not support floating point - easy */ - - if (isdigit(*s) || (*s == '-' && isdigit(s[1]))) { - return 1; - } -#else - strtod(s, &endptr); -#endif - if (endptr != NULL && *endptr == 0) { - return 1; - } - return 0; -} - -/******************************************************************************/ -/* - * Evaluate an operation. Returns with the result in ep->result. Returns -1 - * on errors, otherwise zero is returned. - */ - -static int evalExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs) -{ - EjsNum lval; - char *str; - int rc; - - mprAssert(rel > 0); - str = 0; - lval = 0; - - /* - * Type conversion. This is tricky and must be according to the standard. - * Only numbers (including floats) and strings can be compared. All other - * types are first converted to numbers by preference and if that fails, - * to strings. - * - * MOB -- should we do "valueOf" here also. - */ - if (lhs->type == EJS_TYPE_OBJECT && - (rhs->type != EJS_TYPE_OBJECT && - (rhs->type != EJS_TYPE_UNDEFINED && rhs->type != EJS_TYPE_NULL))) { - if (ejsVarIsNumber(rhs)) { - if (ejsRunMethod(ep, lhs, "toValue", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY); - } else { - if (ejsRunMethod(ep, lhs, "toString", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY); - } - } - - } else { - if (ejsRunMethod(ep, lhs, "toString", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY); - } else { - if (ejsRunMethod(ep, lhs, "toValue", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, lhs, ep->result, EJS_SHALLOW_COPY); - } - } - } - /* Nothing more can be done */ - } - - if (rhs->type == EJS_TYPE_OBJECT && - (lhs->type != EJS_TYPE_OBJECT && - (lhs->type != EJS_TYPE_UNDEFINED && lhs->type != EJS_TYPE_NULL))) { - if (ejsVarIsNumber(lhs)) { - /* If LHS is number, then convert to a value first */ - if (ejsRunMethod(ep, rhs, "toValue", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY); - } else { - if (ejsRunMethod(ep, rhs, "toString", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY); - } - } - - } else { - /* If LHS is not a number, then convert to a string first */ - if (ejsRunMethod(ep, rhs, "toString", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY); - - } else { - if (ejsRunMethod(ep, rhs, "toValue", 0) == 0) { - /* MOB - rc */ - ejsWriteVar(ep, rhs, ep->result, EJS_SHALLOW_COPY); - } - } - } - /* Nothing more can be done */ - } - - /* - * undefined and null are special, in that they don't get promoted when - * comparing. - */ - if (rel == EJS_EXPR_EQ || rel == EJS_EXPR_NOTEQ) { - if (lhs->type == EJS_TYPE_UNDEFINED || - rhs->type == EJS_TYPE_UNDEFINED) { - return evalBoolExpr(ep, - lhs->type == EJS_TYPE_UNDEFINED, - rel, - rhs->type == EJS_TYPE_UNDEFINED); - } - - if (lhs->type == EJS_TYPE_NULL || rhs->type == EJS_TYPE_NULL) { - return evalBoolExpr(ep, - lhs->type == EJS_TYPE_NULL, - rel, - rhs->type == EJS_TYPE_NULL); - } - } - - /* - * From here on, lhs and rhs may contain allocated data (strings), so - * we must always destroy before overwriting. - */ - - /* - * Only allow a few bool operations. Otherwise convert to number. - */ - if (lhs->type == EJS_TYPE_BOOL && rhs->type == EJS_TYPE_BOOL && - (rel != EJS_EXPR_EQ && rel != EJS_EXPR_NOTEQ && - rel != EJS_EXPR_BOOL_COMP)) { - ejsWriteVarAsNumber(ep, lhs, ejsVarToNumber(lhs)); - } - - /* - * Types do not match, so try to coerce the right operand to match the left - * But first, try to convert a left operand that is a numeric stored as a - * string, into a numeric. - */ - if (lhs->type != rhs->type) { - if (lhs->type == EJS_TYPE_STRING) { - if (stringIsNumber(lhs->string)) { - ejsWriteVarAsNumber(ep, lhs, ejsVarToNumber(lhs)); - - /* Examine further below */ - - } else { - /* - * Convert the RHS to a string - * MOB rc - */ - str = ejsVarToString(ep, rhs); - ejsWriteVarAsString(ep, rhs, str); - } - -#if BLD_FEATURE_FLOATING_POINT - } else if (lhs->type == EJS_TYPE_FLOAT) { - /* - * Convert rhs to floating - */ - ejsWriteVarAsFloat(ep, rhs, ejsVarToFloat(rhs)); - -#endif -#if BLD_FEATURE_INT64 - } else if (lhs->type == EJS_TYPE_INT64) { - /* - * Convert the rhs to 64 bit - */ - ejsWriteVarAsInteger64(ep, rhs, ejsVarToInteger64(rhs)); -#endif - } else if (lhs->type == EJS_TYPE_BOOL || lhs->type == EJS_TYPE_INT) { - - if (rhs->type == EJS_TYPE_STRING) { - if (stringIsNumber(rhs->string)) { - ejsWriteVarAsNumber(ep, rhs, ejsVarToNumber(rhs)); - } else { - /* - * Convert to lhs to a string - */ - str = ejsVarToString(ep, lhs); - /* MOB -- rc */ - if (str) { - ejsWriteVarAsString(ep, lhs, str); - } - } - -#if BLD_FEATURE_FLOATING_POINT - } else if (rhs->type == EJS_TYPE_FLOAT) { - /* - * Convert lhs to floating - */ - ejsWriteVarAsFloat(ep, lhs, ejsVarToFloat(lhs)); -#endif - - } else { - /* - * Forcibly convert both operands to numbers - */ - ejsWriteVarAsNumber(ep, lhs, ejsVarToNumber(lhs)); - ejsWriteVarAsNumber(ep, rhs, ejsVarToNumber(rhs)); - } - } - } - - /* - * We have failed to coerce the types to be the same. Special case here - * for undefined and null. We need to allow comparisions against these - * special values. - */ - if (lhs->type == EJS_TYPE_UNDEFINED || lhs->type == EJS_TYPE_NULL) { - switch (rel) { - case EJS_EXPR_EQ: - lval = lhs->type == rhs->type; - break; - case EJS_EXPR_NOTEQ: - lval = lhs->type != rhs->type; - break; - case EJS_EXPR_BOOL_COMP: - lval = ! ejsVarToBoolean(rhs); - break; - default: - ejsWriteVar(ep, ep->result, rhs, EJS_SHALLOW_COPY); - return 0; - } - ejsWriteVarAsBoolean(ep, ep->result, lval); - return 0; - } - - /* - * Types are the same here - */ - switch (lhs->type) { - default: - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - /* Should be handled above */ - mprAssert(0); - return 0; - - case EJS_TYPE_STRING_CMETHOD: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_METHOD: - case EJS_TYPE_PTR: - ejsWriteVarAsBoolean(ep, ep->result, 0); - return 0; - - case EJS_TYPE_OBJECT: - rc = evalObjExpr(ep, lhs, rel, rhs); - break; - - case EJS_TYPE_BOOL: - rc = evalBoolExpr(ep, lhs->boolean, rel, rhs->boolean); - break; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - rc = evalFloatExpr(ep, lhs->floating, rel, rhs->floating); - break; -#endif - - case EJS_TYPE_INT: - rc = evalNumericExpr(ep, (EjsNum) lhs->integer, rel, - (EjsNum) rhs->integer); - break; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - rc = evalNumericExpr(ep, (EjsNum) lhs->integer64, rel, - (EjsNum) rhs->integer64); - break; -#endif - - case EJS_TYPE_STRING: - rc = evalStringExpr(ep, lhs, rel, rhs); - } - - /* MOB */ - if (lhs->type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(lhs, 0); - mprAssert(lhs->objectState->alive == 0); - } - if (rhs->type == EJS_TYPE_OBJECT) { - ejsMakeObjLive(rhs, 0); - mprAssert(rhs->objectState->alive == 0); - } - - return rc; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Expressions with floating operands - */ - -static int evalFloatExpr(Ejs *ep, double l, int rel, double r) -{ - double lval; - int logical; - - lval = 0; - logical = 0; - - switch (rel) { - case EJS_EXPR_PLUS: - lval = l + r; - break; - case EJS_EXPR_INC: - lval = l + 1; - break; - case EJS_EXPR_MINUS: - lval = l - r; - break; - case EJS_EXPR_DEC: - lval = l - 1; - break; - case EJS_EXPR_MUL: - lval = l * r; - break; - case EJS_EXPR_DIV: - lval = l / r; - break; - default: - logical++; - break; - } - - /* - * Logical operators - */ - if (logical) { - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_LESS: - lval = (l < r) ? 1 : 0; - break; - case EJS_EXPR_LESSEQ: - lval = (l <= r) ? 1 : 0; - break; - case EJS_EXPR_GREATER: - lval = (l > r) ? 1 : 0; - break; - case EJS_EXPR_GREATEREQ: - lval = (l >= r) ? 1 : 0; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == 0) ? 1 : 0; - break; - default: - ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel); - return -1; - } - ejsWriteVarAsBoolean(ep, ep->result, lval != 0); - - } else { - ejsWriteVarAsFloat(ep, ep->result, lval); - } - return 0; -} - -#endif /* BLD_FEATURE_FLOATING_POINT */ -/******************************************************************************/ -/* - * Expressions with object operands - */ - -static int evalObjExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs) -{ - int lval; - - switch (rel) { - case EJS_EXPR_EQ: - lval = lhs->objectState == rhs->objectState; - break; - case EJS_EXPR_NOTEQ: - lval = lhs->objectState != rhs->objectState; - break; - default: - ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel); - return -1; - } - ejsWriteVarAsBoolean(ep, ep->result, lval); - return 0; -} - -/******************************************************************************/ -/* - * Expressions with boolean operands - */ - -static int evalBoolExpr(Ejs *ep, int l, int rel, int r) -{ - int lval; - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == 0) ? 1 : 0; - break; - default: - ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel); - return -1; - } - ejsWriteVarAsBoolean(ep, ep->result, lval); - return 0; -} - -/******************************************************************************/ -/* - * Expressions with numeric operands - */ - -static int evalNumericExpr(Ejs *ep, EjsNum l, int rel, EjsNum r) -{ - EjsNum lval; - int logical; - - lval = 0; - logical = 0; - - switch (rel) { - case EJS_EXPR_PLUS: - lval = l + r; - break; - case EJS_EXPR_INC: - lval = l + 1; - break; - case EJS_EXPR_MINUS: - lval = l - r; - break; - case EJS_EXPR_DEC: - lval = l - 1; - break; - case EJS_EXPR_MUL: - lval = l * r; - break; - case EJS_EXPR_DIV: - if (r != 0) { - lval = l / r; - } else { - ejsError(ep, EJS_RANGE_ERROR, "Divide by zero"); - return -1; - } - break; - case EJS_EXPR_MOD: - if (r != 0) { - lval = l % r; - } else { - ejsError(ep, EJS_RANGE_ERROR, "Modulo zero"); - return -1; - } - break; - case EJS_EXPR_LSHIFT: - lval = l << r; - break; - case EJS_EXPR_RSHIFT: - lval = l >> r; - break; - - default: - logical++; - break; - } - - /* - * Logical operators - */ - if (logical) { - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_LESS: - lval = (l < r) ? 1 : 0; - break; - case EJS_EXPR_LESSEQ: - lval = (l <= r) ? 1 : 0; - break; - case EJS_EXPR_GREATER: - lval = (l > r) ? 1 : 0; - break; - case EJS_EXPR_GREATEREQ: - lval = (l >= r) ? 1 : 0; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == 0) ? 1 : 0; - break; - default: - ejsError(ep, EJS_SYNTAX_ERROR, "Bad operator %d", rel); - return -1; - } - ejsWriteVarAsBoolean(ep, ep->result, lval != 0); - - } else { - ejsWriteVarAsNumber(ep, ep->result, lval); - } - return 0; -} - -/******************************************************************************/ -/* - * Expressions with string operands - */ - -static int evalStringExpr(Ejs *ep, EjsVar *lhs, int rel, EjsVar *rhs) -{ - int lval; - - mprAssert(ep); - mprAssert(lhs); - mprAssert(rhs); - - switch (rel) { - case EJS_EXPR_LESS: - lval = strcmp(lhs->string, rhs->string) < 0; - break; - case EJS_EXPR_LESSEQ: - lval = strcmp(lhs->string, rhs->string) <= 0; - break; - case EJS_EXPR_GREATER: - lval = strcmp(lhs->string, rhs->string) > 0; - break; - case EJS_EXPR_GREATEREQ: - lval = strcmp(lhs->string, rhs->string) >= 0; - break; - case EJS_EXPR_EQ: - lval = strcmp(lhs->string, rhs->string) == 0; - break; - case EJS_EXPR_NOTEQ: - lval = strcmp(lhs->string, rhs->string) != 0; - break; - case EJS_EXPR_PLUS: - /* - * This differs from all the above operations. We append rhs to lhs. - */ - ejsClearVar(ep, ep->result); - ejsStrcat(ep, ep->result, lhs); - ejsStrcat(ep, ep->result, rhs); - return 0; - - case EJS_EXPR_INC: - case EJS_EXPR_DEC: - case EJS_EXPR_MINUS: - case EJS_EXPR_DIV: - case EJS_EXPR_MOD: - case EJS_EXPR_LSHIFT: - case EJS_EXPR_RSHIFT: - default: - ejsSyntaxError(ep, "Bad operator"); - return -1; - } - - ejsWriteVarAsBoolean(ep, ep->result, lval); - return 0; -} - -/******************************************************************************/ -/* - * Evaluate a method. obj is set to the current object if a method is being - * run. - */ - -static int evalMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, int flags) -{ - EjsProperty *pp; - EjsVar *saveThis, *prototype; - int saveThisPerm, rc, fid; - - mprAssert(ep); - - rc = 0; - fid = -1; - saveThis = 0; - saveThisPerm = 0; - prototype = proc->fn; - - if (prototype == 0) { - ejsError(ep, EJS_EVAL_ERROR, "Undefined method"); - return EJS_STATE_ERR; - } - - if (prototype->type == EJS_TYPE_OBJECT) { - prototype = ejsGetPropertyAsVar(ep, prototype, proc->procName); - } - - if (prototype) { - /* - * Create a new variable stack frame. ie. new local variables. - * Some C methods (eg. include) don't create a new local context. - */ - if (! (prototype->flags & EJS_NO_LOCAL)) { - fid = ejsOpenBlock(ep); - if (fid < 0) { - return EJS_STATE_ERR; - } - mprAssert(ejsBlockInUse(ep->local)); - - pp = ejsSetProperty(ep, ep->local, "this", obj); - ejsMakePropertyEnumerable(pp, 0); - - /* - * Optimization. Save "this" during this block. - */ - saveThis = ep->thisObject; - ep->thisObject = ejsGetVarPtr(pp); - saveThisPerm = ejsMakeObjPermanent(saveThis, 1); - } - - switch (prototype->type) { - default: - mprAssert(0); - break; - - case EJS_TYPE_STRING_CMETHOD: - rc = callStringCMethod(ep, obj, proc, prototype); - break; - - case EJS_TYPE_CMETHOD: - rc = callCMethod(ep, obj, proc, prototype); - break; - - case EJS_TYPE_METHOD: - rc = callMethod(ep, obj, proc, prototype); - break; - } - - if (fid >= 0) { - ejsMakeObjPermanent(saveThis, saveThisPerm); - ep->thisObject = saveThis; - mprAssert(ejsBlockInUse(ep->local)); - mprAssert(ejsBlockInUse(ep->thisObject)); - ejsCloseBlock(ep, fid); - } - } - - return rc; -} - -/******************************************************************************/ -/* - * Create a new object and call all required constructors. - * obj may be null in which case we look globally for className. - */ - -EjsVar *ejsCreateObjUsingArgvInternal(EJS_LOC_DEC(ep, loc), EjsVar *obj, - const char *className, MprArray *args) -{ - EjsVar *baseClass, *objectClass, *thisObj; - int rc; - - mprAssert(className && *className); - - /* - * Create a new object of the required class and pass it into the - * constructor as the "this" local variable. - */ - baseClass = ejsGetClass(ep, obj, className); - if (baseClass == 0) { - - if (obj && obj->objectState->className && - strcmp(obj->objectState->className, className) == 0) { - /* - * Handle case where we are calling the constructor inside - * the class. In this case, obj == baseClass. - */ - thisObj = ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc), - obj); - - } else { - - /* - * If the baseClass does not exist, try to create an Object - * We do this for compatibility with JS 1.5 style new Function. - * MOB -- but this masks an error if we really need className. - */ - objectClass = ejsGetClass(ep, 0, "Object"); - thisObj = ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc), - objectClass); - } - - } else { - thisObj = ejsCreateSimpleObjUsingClassInt(EJS_LOC_PASS(ep, loc), - baseClass); - } - - if (thisObj == 0) { - ejsMemoryError(ep); - return 0; - } - - /* - * Make the object permanent. While currently not alive, the constructor - * below may make the object alive. - */ - ejsMakeObjPermanent(thisObj, 1); - mprAssert(! ejsObjIsCollectable(thisObj)); - - rc = 0; - if (baseClass) { - if (! baseClass->objectState->noConstructor) { - rc = callConstructor(ep, thisObj, baseClass, args); - } - } else { - /* - * className is the function name when calling new on functions - */ - rc = ejsRunMethod(ep, thisObj, className, args); - } - - /* - * Constructor may change the type to a non-object. - * Function() does this. Ensure object is not collectable yet. - */ - if (ejsVarIsObject(thisObj)) { - ejsMakeObjPermanent(thisObj, 0); - ejsMakeObjLive(thisObj, 0); - } - - if (rc < 0) { - if (rc == MPR_ERR_NOT_FOUND) { - /* No constructor (default) */ - return thisObj; - } - if (! (ep->flags & EJS_FLAGS_EXIT)) { - if (! ep->gotException) { - ejsMemoryError(ep); - } - } - ejsFreeVar(ep, thisObj); - return 0; - } - - mprAssert(ejsBlockInUse(thisObj)); - - return thisObj; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct CallCons { - EjsVar *subClassConstructor, *subClass, *method; -} CallCons; - -/* - * Create a new object and call all required constructors. - */ - -static int callConstructor(Ejs *ep, EjsVar *thisObj, EjsVar *baseClass, - MprArray *args) -{ - CallCons *sp; - int state; - - if ((sp = pushFrame(ep, sizeof(CallCons))) == 0) { - return EJS_STATE_ERR; - } - - mprAssert(baseClass); - mprAssert(baseClass->objectState); - - state = 0; - - /* - * method will be null if there is no constructor for this class - */ - sp->method = ejsGetPropertyAsVar(ep, baseClass, - baseClass->objectState->className); - - if (sp->method == 0 || !ejsVarIsMethod(sp->method) || - !sp->method->callsSuper) { - /* - * Invoke base class constructors in reverse order (RECURSIVE) - */ - sp->subClass = baseClass->objectState->baseClass; - if (sp->subClass) { - - /* - * Note that the Object class does not have a constructor for - * speed. Construction for the base Object is done via - * ejsCreateObj above. The code below will invoke constructors - * in the right order (bottom up) via recursion. MOB -- need to - * scan for super() MOB -- Bug. Fails poorly if no constructor. - * Should allows this and invoke a default constructor. - */ - sp->subClassConstructor = ejsGetPropertyAsVar(ep, sp->subClass, - sp->subClass->objectState->className); - - if (sp->subClassConstructor) { - - if (callConstructor(ep, thisObj, sp->subClass, 0) < 0) { - if (! ep->gotException) { - ejsMemoryError(ep); - } - goto err; - } - } - } - } - - if (sp->method) { - /* - * Finally, invoke the constructor for this class itself. - */ - state = runMethod(ep, thisObj, sp->method, - baseClass->objectState->className, args); - } - -done: - popFrame(ep, sizeof(CallCons)); - return state; - -err: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Create a new object and call all required constructors using string args. - * MOB -- would be good to parse constructorArgs for "," and break into - * separate args. - * Returned object is not yet collectable. Will have alive bit cleared. - */ - -EjsVar *ejsCreateObj(Ejs *ep, EjsVar *obj, const char *className, - const char *constructorArgs) -{ - MprArray *args; - EjsVar *newp, *vp; - - args = mprCreateItemArray(ep, 0, 0); - if (args == 0) { - return 0; - } - - if (constructorArgs && *constructorArgs) { - vp = ejsCreateStringVarInternal(EJS_LOC_ARGS(ep), constructorArgs); - - if (mprAddItem(args, vp) < 0) { - mprFree(args); - return 0; - } - } - - newp = ejsCreateObjUsingArgv(ep, obj, className, args); - - ejsFreeMethodArgs(ep, args); - - mprAssert(! ejsObjIsCollectable(newp)); - mprAssert(ejsBlockInUse(newp)); - - return newp; -} - -/******************************************************************************/ - -static int callStringCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, - EjsVar *prototype) -{ - EjsVar **argValues; - MprArray *actualArgs; - char **argBuf, *str; - int i, rc; - - actualArgs = proc->args; - argValues = (EjsVar**) actualArgs->items; - - if (actualArgs->length > 0) { - argBuf = mprAlloc(ep, actualArgs->length * sizeof(char*)); - for (i = 0; i < actualArgs->length; i++) { - str = ejsVarToString(ep, argValues[i]); - /* MOB rc */ - argBuf[i] = mprStrdup(ep, str); - } - } else { - argBuf = 0; - } - - /* - * Call the method depending on the various handle flags - */ - ep->userData = prototype->cMethodWithStrings.userData; - if (prototype->flags & EJS_ALT_HANDLE) { - /* - * Used by the AppWeb GaCompat module. The alt handle is set to the - * web server request struct - */ - rc = ((EjsAltStringCMethod) - prototype->cMethodWithStrings.fn) - (ep, ep->altHandle, obj, actualArgs->length, argBuf); - - } else if (prototype->flags & EJS_PRIMARY_HANDLE) { - /* - * Used by ESP. The primary handle is set to the esp struct - */ - rc = (prototype->cMethodWithStrings.fn)(ep->primaryHandle, - obj, actualArgs->length, argBuf); - - } else { - /* - * Used EJS for the standard procs - */ - rc = (prototype->cMethodWithStrings.fn)(ep, obj, actualArgs->length, - argBuf); - } - - if (actualArgs->length > 0) { - for (i = 0; i < actualArgs->length; i++) { - mprFree(argBuf[i]); - } - mprFree(argBuf); - } - ep->userData = 0; - - return rc; -} - -/******************************************************************************/ - -static int callCMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, EjsVar *prototype) -{ - EjsVar **argValues; - MprArray *actualArgs; - int rc; - - actualArgs = proc->args; - argValues = (EjsVar**) actualArgs->items; - - ep->userData = prototype->cMethod.userData; - - /* - * Call the method depending on the various handle flags - * Sometimes cMethod.fn is NULL if there is no constructor for - * an object. - */ - if (prototype->flags & EJS_ALT_HANDLE) { - /* - * Use by the GaCompat module. The alt handle is set to the - * web server request struct - */ - rc = ((EjsAltCMethod) prototype->cMethod.fn) - (ep, ep->altHandle, obj, actualArgs->length, argValues); - - } else if (prototype->flags & EJS_PRIMARY_HANDLE) { - /* - * Used by ESP. The primary handle is set to the esp struct - */ - rc = (prototype->cMethod.fn) - (ep->primaryHandle, obj, actualArgs->length, argValues); - - } else { - /* - * Used EJS for the standard procs - */ - rc = (prototype->cMethod.fn)(ep, obj, actualArgs->length, argValues); - } - - ep->userData = 0; - - return rc; -} - -/******************************************************************************/ -/* - * Local vars - */ - -typedef struct CallMethod { - MprArray *formalArgs, *actualArgs; - EjsVar *arguments, *callee, **argValues; - char **argNames, buf[16]; - int i, argumentsObj; -} CallMethod; - - -static int callMethod(Ejs *ep, EjsVar *obj, EjsProc *proc, EjsVar *prototype) -{ - CallMethod *sp; - int i; - - if ((sp = pushFrame(ep, sizeof(CallMethod))) == 0) { - return EJS_STATE_ERR; - } - - sp->arguments = 0; - sp->callee = 0; - - sp->actualArgs = proc->args; - sp->argValues = (EjsVar**) sp->actualArgs->items; - sp->formalArgs = prototype->method.args; - sp->argNames = (char**) sp->formalArgs->items; - - /* - * Only create arguments and callee if the function actually uses them - */ - sp->argumentsObj = 0; - if (strstr(prototype->method.body, "arguments") != 0) { - sp->argumentsObj++; - - /* - * Create the arguments and callee variables - * MOB -- should we make real arrays here ? YES - */ - sp->arguments = ejsCreateSimpleObj(ep, "Object"); - ejsSetVarName(ep, sp->arguments, "arguments"); - mprAssert(! ejsObjIsCollectable(sp->arguments)); - - sp->callee = ejsCreateSimpleObj(ep, "Object"); - ejsSetVarName(ep, sp->callee, "callee"); - mprAssert(! ejsObjIsCollectable(sp->callee)); - - /* - * Overwrite the length property - */ - ejsSetPropertyToInteger(ep, sp->arguments, "length", - sp->actualArgs->length); - ejsSetPropertyToInteger(ep, sp->callee, "length", - sp->formalArgs->length); - } - - /* - * Define all the agruments to be set to the actual parameters - */ - for (i = 0; i < sp->formalArgs->length; i++) { - if (i >= sp->actualArgs->length) { - /* MOB -- return code */ - ejsCreateProperty(ep, ep->local, sp->argNames[i]); - - } else { - /* MOB -- return code */ - ejsSetProperty(ep, ep->local, sp->argNames[i], sp->argValues[i]); - } - } - - if (sp->argumentsObj) { - for (i = 0; i < sp->actualArgs->length; i++) { - mprItoa(sp->buf, sizeof(sp->buf), i); - ejsSetProperty(ep, sp->arguments, sp->buf, sp->argValues[i]); - } - - ejsSetPropertyAndFree(ep, sp->arguments, "callee", sp->callee); - ejsSetPropertyAndFree(ep, ep->local, "arguments", sp->arguments); - } - - /* - * Actually run the method - */ - - i = ejsEvalScript(ep, prototype->method.body, 0); - - popFrame(ep, sizeof(CallMethod)); - return i; -} - -/******************************************************************************/ -/* - * Run a method. Obj is set to "this" object. MethodName must exist in it - * or in a sub class. - */ - -int ejsRunMethod(Ejs *ep, EjsVar *obj, const char *methodName, MprArray *args) -{ - EjsProperty *pp; - EjsProc proc, *saveProc; - int rc; - - mprAssert(obj); - mprAssert(methodName && *methodName); - - pp = ejsGetProperty(ep, obj, methodName); - if (pp == 0) { - /* MOB -- this should be all in some common accessor routine */ - pp = ejsGetProperty(ep, ep->local, methodName); - if (pp == 0) { - pp = ejsGetProperty(ep, ep->global, methodName); - if (pp == 0) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Undefined method \"%s\"", methodName); - return MPR_ERR_NOT_FOUND; - } - } - } - - saveProc = ep->proc; - ep->proc = &proc; - - memset(&proc, 0, sizeof(EjsProc)); - - ejsClearVar(ep, ep->result); - - /* MOB -- if closures are going to work, we need to have proc be an - Object and let the GC look after it */ - - proc.fn = &pp->var; - if (proc.fn == 0 || proc.fn->type == EJS_TYPE_UNDEFINED) { - ep->proc = saveProc; - return MPR_ERR_NOT_FOUND; - } - - proc.procName = mprStrdup(ep, methodName); - if (args == 0) { - proc.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - } else { - proc.args = args; - } - - rc = evalMethod(ep, obj, &proc, 0); - - if (args) { - proc.args = 0; - } - freeProc(ep, &proc); - - ep->proc = saveProc; - - return rc; -} - -/******************************************************************************/ -/* - * Run a method. Obj is set to "this" object. MethodName must exist in it - * or in a sub class. - */ - -int ejsRunMethodCmd(Ejs *ep, EjsVar *obj, const char *methodName, - const char *cmdFmt, ...) -{ - MprArray *args; - va_list cmdArgs; - char *buf, *arg, *cp; - int rc; - - mprAssert(methodName && *methodName); - mprAssert(cmdFmt && *cmdFmt); - - va_start(cmdArgs, cmdFmt); - mprAllocVsprintf(MPR_LOC_ARGS(ep), &buf, 0, cmdFmt, cmdArgs); - va_end(cmdArgs); - - args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - - for (arg = cp = buf; cp && *cp; cp++) { - if (*cp == ',') { - *cp = 0; - mprAddItem(args, ejsParseVar(ep, arg, 0)); - arg = cp + 1; - } - } - if (cp > arg) { - mprAddItem(args, ejsParseVar(ep, arg, 0)); - } - - rc = ejsRunMethod(ep, obj, methodName, args); - - ejsFreeMethodArgs(ep, args); - mprFree(buf); - - return rc; -} - -/******************************************************************************/ -/* - * Run a method. Obj is set to "this" object. - */ - -static int runMethod(Ejs *ep, EjsVar *thisObj, EjsVar *method, - const char *methodName, MprArray *args) -{ - EjsProc proc, *saveProc; - int rc; - - mprAssert(thisObj); - mprAssert(method); - - saveProc = ep->proc; - ep->proc = &proc; - - memset(&proc, 0, sizeof(EjsProc)); - - ejsClearVar(ep, ep->result); - - /* MOB -- if closures are going to work, we need to have proc be an - Object and let the GC look after it */ - - proc.fn = method; - if (proc.fn == 0 || proc.fn->type == EJS_TYPE_UNDEFINED) { - ep->proc = saveProc; - return MPR_ERR_NOT_FOUND; - } - - proc.procName = mprStrdup(ep, methodName); - if (args == 0) { - proc.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - } else { - proc.args = args; - } - - rc = evalMethod(ep, thisObj, &proc, 0); - - if (args) { - proc.args = 0; - } - freeProc(ep, &proc); - - ep->proc = saveProc; - - return rc; -} - -/******************************************************************************/ -/* - * Find which object contains the property given the current context. - * We call this when there is no explicit object and the object must be - * determined by the context. - */ - -static EjsVar *pickSpace(Ejs *ep, int state, const char *property, int flags) -{ - EjsVar *obj; - - mprAssert(ep); - mprAssert(property && *property); - - /* MOB - this is ugly and the logic is confused */ - - if (flags & EJS_FLAGS_GLOBAL) { - obj = ep->global; - - } else if (state == EJS_STATE_DEC || flags & EJS_FLAGS_LOCAL) { - obj = ep->local; - - } else { - /* First look local, then this and finally global */ - - if (ejsGetSimpleProperty(ep, ep->local, property)) { - obj = ep->local; - - } else if (ep->thisObject && - findProperty(ep, ep->thisObject, property, flags)) { - obj = ep->thisObject; - - } else { -#if EJS_ECMA_STND - obj = ep->global; -#else - if (flags & EJS_FLAGS_EXE && - !findProperty(ep, ep->global, property, flags)) { - obj = ep->local; - } else { - obj = ep->global; - } -#endif - } - } - return obj; -} - -/******************************************************************************/ -/* - * Find an object property given a object and a property name. We - * intelligently look in the local and global namespaces depending on - * our state. If not found in local or global, try base classes for method - * names only. Returns the property or NULL. - * MOB -- need to rework this API. - */ - -static EjsProperty *searchSpacesForProperty(Ejs *ep, int state, EjsVar *obj, - char *property, int flags) -{ - EjsProperty *pp; - - if (obj) { - return findProperty(ep, obj, property, flags); - } - - /* MOB -- really should have a search stack */ - - pp = findProperty(ep, ep->local, property, flags); - if (pp == 0 && state != EJS_STATE_DEC) { - - if (ep->thisObject) { - pp = findProperty(ep, ep->thisObject, property, flags); - } - if (pp == 0) { - pp = findProperty(ep, ep->global, property, flags); - } - } - return pp; -} - -/******************************************************************************/ -/* - * Search an object and its base classes to find an object given an object - * an a property name. If not an assignment (LHS), then follow base classes. - * Otherwise, just look in the specified object. - */ - -static EjsProperty *findProperty(Ejs *ep, EjsVar *op, const char *property, - int flags) -{ - /* MOB -- NEW. Remove when EXE fixes are in. */ - if (! (flags & EJS_FLAGS_EXE) && op->type == EJS_TYPE_UNDEFINED) { - return 0; - } - - if (flags & EJS_FLAGS_LHS) { - return ejsGetPropertyPtr(ejsGetSimpleProperty(ep, op, property)); - - } else { - /* - * Follow base classes - */ - return ejsGetPropertyPtr(ejsGetProperty(ep, op, property)); - } -} - -/******************************************************************************/ -/* - * Update result - */ - -static void updateResult(Ejs *ep, int state, int flags, EjsVar *vp) -{ - if (flags & EJS_FLAGS_EXE && state != EJS_STATE_DEC) { - ejsClearVar(ep, ep->result); - if (vp) { - ejsWriteVar(ep, ep->result, vp, EJS_SHALLOW_COPY); - ejsSetVarName(ep, ep->result, vp->propertyName); - } - } -} - -/******************************************************************************/ -/* - * Append to the pointer value - */ - -int ejsStrcat(Ejs *ep, EjsVar *dest, EjsVar *src) -{ - char *oldBuf, *buf, *str; - int oldLen, newLen, len; - - mprAssert(dest); - mprAssert(ejsVarIsString(src)); - - if (ejsVarIsValid(dest)) { - - if (! ejsVarIsString(dest)) { - /* Bad type for dest */ - return -1; - } - - if (! ejsVarIsString(src)) { - str = ejsVarToString(ep, src); - if (str == 0) { - return -1; - } - len = strlen(str); - - } else { - str = src->string; - len = src->length; - } - - oldBuf = dest->string; - oldLen = dest->length; - newLen = oldLen + len + 1; - - if (newLen < MPR_SLAB_STR_MAX) { - buf = oldBuf; - } else { - buf = mprRealloc(ep, oldBuf, newLen); - if (buf == 0) { - return -1; - } - dest->string = buf; - } - memcpy(&buf[oldLen], str, len); - dest->length += len; - - } else { - ejsWriteVarAsString(ep, dest, src->string); - } - return 0; -} - -/******************************************************************************/ -/* - * Exit the script - */ - -void ejsExit(Ejs *ep, int status) -{ - ep->scriptStatus = status; - ep->flags |= EJS_FLAGS_EXIT; -} - -/******************************************************************************/ -/* - * Free an argument list - */ - -static void freeProc(Ejs *ep, EjsProc *proc) -{ - if (proc->args) { - ejsFreeMethodArgs(ep, proc->args); - } - - if (proc->procName) { - mprFree(proc->procName); - proc->procName = NULL; - } -} - -/******************************************************************************/ - -void ejsFreeMethodArgs(Ejs *ep, MprArray *args) -{ - int i; - - for (i = args->length - 1; i >= 0; i--) { - ejsFreeVar(ep, args->items[i]); - mprRemoveItemByIndex(args, i); - } - mprFree(args); -} - -/******************************************************************************/ -/* - * This method removes any new lines. Used for else cases, etc. - */ - -static void removeNewlines(Ejs *ep, int state) -{ - int tid; - - do { - tid = ejsLexGetToken(ep, state); - } while (tid == EJS_TOK_NEWLINE); - - ejsLexPutbackToken(ep, tid, ep->token); -} - -/******************************************************************************/ - -static int getNextNonSpaceToken(Ejs *ep, int state) -{ - int tid; - - do { - tid = ejsLexGetToken(ep, state); - } while (tid == EJS_TOK_NEWLINE); - return tid; -} - -/******************************************************************************/ - -int ejsGetFlags(Ejs *ep) -{ - return ep->flags; -} - -/******************************************************************************/ - -bool ejsIsExiting(Ejs *ep) -{ - return (ep->flags & EJS_FLAGS_EXIT) ? 1: 0; -} - -/******************************************************************************/ - -void ejsClearExiting(Ejs *ep) -{ - ep->flags &= ~EJS_FLAGS_EXIT; -} - -/******************************************************************************/ - -static EjsInput *getInputStruct(Ejs *ep) -{ - EjsInput *input; - - if (ep->inputList) { - input = ep->inputList; - ep->inputList = input->nextInput; - - } else { - input = mprAlloc(ep, sizeof(EjsInput)); - } - return input; -} - -/******************************************************************************/ - -static void freeInputStruct(Ejs *ep, EjsInput *input) -{ - input->nextInput = ep->inputList; - ep->inputList = input; -} - -/******************************************************************************/ - -static void *pushFrame(Ejs *ep, int size) -{ - /* - * Grow down stack - */ - ep->stkPtr -= size; - if (ep->stkPtr < ep->stack) { - mprError(ep, MPR_LOC, "Exceeded parse stack"); - return 0; - } - return ep->stkPtr; -} - -/******************************************************************************/ - -static void *popFrame(Ejs *ep, int size) -{ - ep->stkPtr += size; - if (ep->stkPtr > &ep->stack[EJS_MAX_STACK]) { - mprError(ep, MPR_LOC, "Over poped parse stack"); - return 0; - } - return ep->stkPtr; -} - -/******************************************************************************/ -#else -void ejsParserDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.c b/source4/lib/appweb/ejs-2.0/ejs/ejsVar.c deleted file mode 100644 index 1f8e9266a3..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.c +++ /dev/null @@ -1,4033 +0,0 @@ -/** - * @file ejsVar.c - * @brief Mbedthis Portable Runtime Universal Variable Type - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/******************************* Documentation ********************************/ - -/* - * This module is NOT multithreaded. - * - * Properties are variables that are stored in an object type variable. - * Properties can be primitive data types, other objects or methods. - * Properties are indexed by a character name. - */ - -/********************************** Includes **********************************/ - -#include "ejs.h" - -/***************************** Forward Declarations ***************************/ - -static EjsProperty *allocProperty(Ejs *ep, EjsVar *op, const char *property, - int propertyIndex, EjsProperty *last); -static EjsVar *copyVar(EJS_LOC_DEC(ep, loc), EjsVar *dest, - const EjsVar *src, EjsCopyDepth copyDepth); -static EjsObj *createObj(EJS_LOC_DEC(ep, loc)); -static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen); -static int hash(const char *property); -static void unlinkProperty(EjsObj *obj, EjsPropLink *propLink); -static void linkPropertyBefore(EjsObj *obj, EjsPropLink *at, - EjsPropLink *propLink); -static int sortAllProperties(Ejs *ep, EjsProperty *p1, - EjsProperty *p2, const char *propertyName, int order); -static int sortByProperty(Ejs *ep, EjsProperty *p1, EjsProperty *p2, - const char *propertyName, int order); -static int dupString(MPR_LOC_DEC(ctx, loc), uchar **dest, - const void *src, int nbytes); -#if UNUSED && KEEP -static void linkPropertyAfter(EjsObj *obj, EjsPropLink *at, - EjsPropLink *propLink); -#endif - -static EjsProperty *hashLookup(EjsObj *obj, const char *property, - int *propertyIndex, EjsProperty **hashTail); - -/******************************************************************************/ -/********************************** Var Routines ******************************/ -/******************************************************************************/ - -EjsType ejsGetVarType(EjsVar *vp) -{ - mprAssert(vp); - - return vp->type; -} - -/******************************************************************************/ - -void ejsFreeVar(Ejs *ep, EjsVar *vp) -{ - if (vp) { - ejsClearVar(ep, vp); - ejsFree(ep, vp, EJS_SLAB_VAR); - } -} - -/******************************************************************************/ -#if UNUSED -/* - * Clear the value by freeing any allocated data. This will release objects - * so that later garbage collection can reclaim storage if there are no other - * object references. - */ - -void ejsZeroVar(Ejs *ep, EjsVar *vp) -{ - vp->type = EJS_TYPE_UNDEFINED; - vp->objectState = 0; - vp->method.body = 0; - vp->method.args = 0; - vp->callsSuper = 0; - vp->ptr.destructor = 0; - vp->allocatedData = 0; -} - -#endif -/******************************************************************************/ -/* - * Clear the value by freeing any allocated data. This will release objects - * so that later garbage collection can reclaim storage if there are no other - * object references. - */ - -void ejsClearVar(Ejs *ep, EjsVar *vp) -{ - MprArray *argList; - int i; - - mprAssert(vp); - mprAssert(ep); - - if (! vp->allocatedData) { - vp->type = EJS_TYPE_UNDEFINED; - return; - } - if (vp->type == EJS_TYPE_UNDEFINED) { - return; - } - - switch (vp->type) { - default: - break; - - case EJS_TYPE_STRING: - mprFree(vp->string); - vp->string = 0; - break; - - case EJS_TYPE_OBJECT: - /* - * Set the "alive" bit so that the GC will cleanup if no - * other references. - */ - if (vp->objectState) { - vp->objectState->alive = 1; - } - vp->objectState = 0; - break; - - case EJS_TYPE_METHOD: - argList = vp->method.args; - /* - * MOB OPT -- should be able to do just one mprFree(vp->method.args) - */ - mprFree(vp->method.body); - if (argList) { - for (i = 0; i < argList->length; i++) { - mprFree(argList->items[i]); - } - mprFree(vp->method.args); - } - vp->method.args = 0; - vp->method.body = 0; - vp->callsSuper = 0; - break; - - case EJS_TYPE_PTR: - if (vp->ptr.destructor) { - (vp->ptr.destructor)(ep, vp); - } - break; - } - - vp->type = EJS_TYPE_UNDEFINED; - vp->allocatedData = 0; -} - -/******************************************************************************/ -/* - * Initialize an undefined value. - */ - -EjsVar *ejsCreateUndefinedVar(Ejs *ep) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_UNDEFINED; - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize an null value. - */ - -EjsVar *ejsCreateNullVar(Ejs *ep) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_NULL; - } - return vp; -} - -/******************************************************************************/ - -EjsVar *ejsCreateBoolVar(Ejs *ep, int value) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_BOOL; - vp->boolean = value; - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize a C method. - */ - -EjsVar *ejsCreateCMethodVar(Ejs *ep, EjsCMethod fn, void *userData, int flags) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_CMETHOD; - vp->cMethod.fn = fn; - vp->cMethod.userData = userData; - vp->flags = flags; - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize a C method. - */ - -EjsVar *ejsCreateStringCMethodVar(Ejs *ep, EjsStringCMethod fn, - void *userData, int flags) -{ - EjsVar *vp; - - mprAssert(ep); - mprAssert(fn); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_STRING_CMETHOD; - vp->cMethodWithStrings.fn = fn; - vp->cMethodWithStrings.userData = userData; - vp->flags = flags; - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize an opaque pointer. - */ - -EjsVar *ejsCreatePtrVar(Ejs *ep, void *ptr, EjsDestructor destructor) -{ - EjsVar *vp; - - mprAssert(ep); - mprAssert(ptr); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_PTR; - vp->ptr.userPtr = ptr; - vp->ptr.destructor = destructor; - vp->allocatedData = 1; - } - return vp; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Initialize a floating value. - */ - -EjsVar *ejsCreateFloatVar(Ejs *ep, double value) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_FLOAT; - vp->floating = value; - } - return vp; -} - -#endif -/******************************************************************************/ -/* - * Initialize an integer value. - */ - -EjsVar *ejsCreateIntegerVar(Ejs *ep, int value) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_INT; - vp->integer = value; - } - return vp; -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 -/* - * Initialize a 64-bit integer value. - */ - -EjsVar *ejsCreateInteger64Var(Ejs *ep, int64 value) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_INT64; - vp->integer64 = value; - } - return vp; -} - -#endif /* BLD_FEATURE_INT64 */ -/******************************************************************************/ -/* - * Initialize an number variable. Type is defined by configure. - */ - -EjsVar *ejsCreateNumberVar(Ejs *ep, EjsNum value) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - mprAssert(vp); - - if (vp) { - vp->type = BLD_FEATURE_NUM_TYPE_ID; -#if BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_INT64 - vp->integer64 = value; -#elif BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_FLOAT - vp->float = value; -#else - vp->integer = value; -#endif - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize a (bare) JavaScript method. args and body can be null. - */ - -EjsVar *ejsCreateMethodVar(Ejs *ep, const char *body, MprArray *args, int flags) -{ - EjsVar *vp; - int i; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - mprAssert(vp); - - if (vp == 0) { - return 0; - } - - vp->type = EJS_TYPE_METHOD; - - vp->allocatedData = 1; - - vp->method.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - if (vp->method.args == 0) { - mprAssert(vp->method.args); - ejsFreeVar(ep, vp); - return 0; - } - - if (args) { - for (i = 0; i < args->length; i++) { - mprAddItem(vp->method.args, - mprStrdup(vp->method.args, mprGetItem(args, i))); - } - } - vp->method.body = mprStrdup(vp->method.args, body); - - if (vp->method.body == 0) { - ejsFreeVar(ep, vp); - return 0; - } - vp->flags = flags; - - return vp; -} - -/******************************************************************************/ -/* - * Initialize an object variable. - */ - -EjsVar *ejsCreateObjVarInternal(EJS_LOC_DEC(ep, loc)) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_PASS(ep, loc)); - mprAssert(vp); - - if (vp) { - vp->type = EJS_TYPE_OBJECT; - vp->objectState = createObj(EJS_LOC_PASS(ep, loc)); - if (vp->objectState == 0) { - ejsFreeVar(ep, vp); - return 0; - } - vp->allocatedData = 1; - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize a string value. - */ - -EjsVar *ejsCreateStringVarInternal(EJS_LOC_DEC(ep, loc), const char *value) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_PASS(ep, loc)); - mprAssert(vp); - - if (vp) { - vp->type = EJS_TYPE_STRING; - vp->string = mprStrdupInternal(EJS_LOC_PASS(ep, loc), value); - if (vp->string == 0) { - ejsFreeVar(ep, vp); - return 0; - } - vp->length = strlen(vp->string); - vp->allocatedData = 1; - } - return vp; -} - -/******************************************************************************/ -/* - * Initialize a binary string value. - */ - -EjsVar *ejsCreateBinaryStringVar(Ejs *ep, const uchar *value, int len) -{ - EjsVar *vp; - - mprAssert(ep); - - vp = ejsAllocVar(EJS_LOC_ARGS(ep)); - if (vp) { - vp->type = EJS_TYPE_STRING; - vp->length = dupString(MPR_LOC_ARGS(ep), &vp->ustring, value, len); - if (vp->length < 0) { - ejsFreeVar(ep, vp); - return 0; - } - vp->allocatedData = 1; - } - return vp; -} - -/******************************************************************************/ - -void ejsSetClassName(Ejs *ep, EjsVar *vp, const char *name) -{ - EjsObj *obj; - - if (vp == 0 || !ejsVarIsObject(vp) || vp->objectState == 0) { - mprAssert(0); - return; - } - obj = vp->objectState; - - if (obj->className) { - mprFree(obj->className); - } - obj->className = mprStrdup(ep, name); -} - -/******************************************************************************/ - -EjsVar *ejsDupVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *src, - EjsCopyDepth copyDepth) -{ - EjsVar *vp; - - vp = ejsAllocVar(EJS_LOC_PASS(ep, loc)); - if (vp == 0) { - return 0; - } - - vp->type = EJS_TYPE_UNDEFINED; - - return copyVar(EJS_LOC_PASS(ep, loc), vp, src, copyDepth); -} - -/******************************************************************************/ -/* - * Set a var to a new value - */ - -EjsVar *ejsWriteVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *dest, - const EjsVar *src, EjsCopyDepth copyDepth) -{ - mprAssert(dest); - mprAssert(src); - - return copyVar(EJS_LOC_PASS(ep, loc), dest, src, copyDepth); -} - -/******************************************************************************/ -/* - * Set a var using a new bool value - */ - -EjsVar *ejsWriteVarAsBoolean(Ejs *ep, EjsVar *dest, int value) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_BOOL; - dest->boolean = value; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var using a new C Method - */ - -EjsVar *ejsWriteVarAsCMethod(Ejs *ep, EjsVar *dest, EjsCMethod fn, - void *userData, int flags) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_CMETHOD; - dest->cMethod.fn = fn; - dest->cMethod.userData = userData; - dest->flags = flags; - dest->allocatedData = 0; - - return dest; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Set a var using a new float value - */ - -EjsVar *ejsWriteVarAsFloat(Ejs *ep, EjsVar *dest, double value) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_FLOAT; - dest->floating = value; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -#endif -/******************************************************************************/ -/* - * Set a var using a new integer value - */ - -EjsVar *ejsWriteVarAsInteger(Ejs *ep, EjsVar *dest, int value) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_INT; - dest->integer = value; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 -/* - * Set a var using a new integer value - */ - -EjsVar *ejsWriteVarAsInteger64(Ejs *ep, EjsVar *dest, int64 value) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_INT64; - dest->integer64 = value; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -#endif -/******************************************************************************/ -/* - * Set a var using a new Method - */ - -EjsVar *ejsWriteVarAsMethod(Ejs *ep, EjsVar *dest, const char *body, - MprArray *args) -{ - EjsVar **srcArgs, *arg; - int i; - - mprAssert(ep); - mprAssert(dest); - mprAssert(body); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->method.args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - if (dest->method.args == 0) { - return 0; - } - - dest->type = EJS_TYPE_METHOD; - - if (args) { - srcArgs = (EjsVar**) args->items; - for (i = 0; i < args->length; i++) { - arg = ejsDupVar(ep, srcArgs[i], EJS_SHALLOW_COPY); - if (arg == 0) { - return 0; - } - if (mprAddItem(dest->method.args, arg) < 0) { - return 0; - } - } - } - - dest->method.body = mprStrdup(dest->method.args, body); - if (dest->method.body == 0) { - return 0; - } - - dest->allocatedData = 1; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var to null - */ - -EjsVar *ejsWriteVarAsNull(Ejs *ep, EjsVar *dest) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_NULL; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var using a new number value - */ - -EjsVar *ejsWriteVarAsNumber(Ejs *ep, EjsVar *dest, EjsNum value) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_NUM_VAR; - dest->ejsNumber = value; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var using a new C Method - */ - -EjsVar *ejsWriteVarAsStringCMethod(Ejs *ep, EjsVar *dest, EjsStringCMethod fn, - void *userData, int flags) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_CMETHOD; - dest->cMethodWithStrings.fn = fn; - dest->cMethodWithStrings.userData = userData; - dest->flags = flags; - dest->allocatedData = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var using a new string value - */ - -EjsVar *ejsWriteVarAsStringInternal(EJS_LOC_DEC(ep, loc), EjsVar *dest, - const char *value) -{ - mprAssert(dest); - mprAssert(value); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->string = mprStrdupInternal(EJS_LOC_PASS(ep, loc), value); - if (dest->string == 0) { - return 0; - } - - dest->length = strlen(dest->string); - - dest->type = EJS_TYPE_STRING; - dest->allocatedData = 1; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var using a new string value - */ - -EjsVar *ejsWriteVarAsBinaryString(Ejs *ep, EjsVar *dest, const uchar *value, - int len) -{ - mprAssert(dest); - mprAssert(value); - - ejsClearVar(ep, dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->length = dupString(MPR_LOC_ARGS(ep), &dest->ustring, value, len); - if (dest->length < 0) { - return 0; - } - - dest->type = EJS_TYPE_STRING; - dest->allocatedData = 1; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Set a var to undefined - */ - -EjsVar *ejsWriteVarAsUndefined(Ejs *ep, EjsVar *dest) -{ - mprAssert(dest); - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->type = EJS_TYPE_UNDEFINED; - dest->allocatedData = 0; - dest->flags = 0; - - return dest; -} - -/******************************************************************************/ -/* - * Convert a value to a text based representation of its value - * If you provide a format, you MUST ensure you know the type. - * Caller must free the result. - */ - -char *ejsFormatVar(Ejs *ep, const char *fmt, EjsVar *vp) -{ - char *buf, *src, *value, *allocValue; - uchar *ubuf; - int len; - - buf = 0; - allocValue = 0; - value = 0; - - switch (vp->type) { - case EJS_TYPE_UNDEFINED: - value = "undefined"; - break; - - case EJS_TYPE_NULL: - value = "null"; - break; - - case EJS_TYPE_PTR: - if (fmt == NULL || *fmt == '\0') { - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, - "[Opaque Pointer %p]", vp->ptr.userPtr); - } else { - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->ptr); - } - goto done; - - case EJS_TYPE_BOOL: - value = (vp->boolean) ? "true" : "false"; - break; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - if (fmt == NULL || *fmt == '\0') { - fmt = "%f"; - } - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->floating); - goto done; -#endif - - case EJS_TYPE_INT: - if (fmt == NULL || *fmt == '\0') { - fmt = "%d"; - } - mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->integer); - goto done; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - if (fmt == NULL || *fmt == '\0') { - fmt = "%Ld"; - } - mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, vp->integer64); - goto done; -#endif - - case EJS_TYPE_CMETHOD: - value = "[C Method]"; - break; - - case EJS_TYPE_STRING_CMETHOD: - value = "[C StringMethod]"; - break; - - case EJS_TYPE_METHOD: - value = ejsVarToString(ep, vp); - break; - - case EJS_TYPE_OBJECT: - value = ejsVarToString(ep, vp); - break; - - case EJS_TYPE_STRING: - src = vp->string; - mprAssert(src); - - if (fmt && *fmt && src) { - mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, src); - - } else if (src == NULL) { - buf = mprStrdup(ep, "null"); - - } else { - ubuf = (uchar*) buf; - if (dupString(MPR_LOC_ARGS(ep), &ubuf, src, vp->length) < 0) { - return mprStrdup(ep, ""); - } - buf = (char*) ubuf; - } - break; - - default: - mprAssert(0); - } - - if (fmt == NULL || *fmt == '\0') { - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, "%s", value); - } else { - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &buf, 0, fmt, value); - } - -done: - if (allocValue) { - mprFree(allocValue); - } - return buf; -} - -/******************************************************************************/ -/* - * Convert the variable to a boolean. Only for primitive types. - */ - -int ejsVarToBoolean(EjsVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_STRING_CMETHOD: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_METHOD: - return 0; - - case EJS_TYPE_OBJECT: - return (vp->objectState != NULL); - - case EJS_TYPE_PTR: - return (vp->ptr.userPtr != NULL); - - case EJS_TYPE_BOOL: - return vp->boolean; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - return (vp->floating != 0 && !ejsIsNan(vp->floating)); -#endif - - case EJS_TYPE_INT: - return (vp->integer != 0); - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - return (vp->integer64 != 0); -#endif - - case EJS_TYPE_STRING: - return (vp->length > 0); -#if UNUSED - if (strcmp(vp->string, "true") == 0 || - strcmp(vp->string, "TRUE") == 0) { - return 1; - - } else if (strcmp(vp->string, "false") == 0 || - strcmp(vp->string, "FALSE") == 0) { - return 0; - - } else { - return atoi(vp->string); - } -#endif - } - - /* Not reached */ - return 0; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Convert the variable to a floating point number. Only for primitive types. - */ - -double ejsVarToFloat(EjsVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_STRING_CMETHOD: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_METHOD: - case EJS_TYPE_OBJECT: - case EJS_TYPE_PTR: - return 0; - - case EJS_TYPE_BOOL: - return (vp->boolean) ? 1.0 : 0.0; - - case EJS_TYPE_FLOAT: - return vp->floating; - - case EJS_TYPE_INT: - return (double) vp->integer; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - return (double) vp->integer64; -#endif - - case EJS_TYPE_STRING: - if (vp->length == 0) { - return 0.0; - } else { - return atof(vp->string); - } - } - - /* Not reached */ - return 0; -} - -#endif -/******************************************************************************/ -/* - * Convert the variable to an Integer type. Only works for primitive types. - */ - -int ejsVarToInteger(EjsVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_STRING_CMETHOD: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_METHOD: - case EJS_TYPE_OBJECT: - return 0; - - case EJS_TYPE_BOOL: - return (vp->boolean) ? 1 : 0; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - if (ejsIsNan(vp->floating)) { - return 0; - } - return (int) vp->floating; -#endif - - case EJS_TYPE_INT: - return vp->integer; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - return (int) vp->integer64; -#endif - - case EJS_TYPE_STRING: - if (vp->length == 0) { - return 0; - } else { - return ejsParseInteger(vp->string); - } - } - - /* Not reached */ - return 0; -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 -/* - * Convert the variable to an Integer64 type. Only works for primitive types. - */ - -int64 ejsVarToInteger64(EjsVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_STRING_CMETHOD: - case EJS_TYPE_CMETHOD: - case EJS_TYPE_METHOD: - case EJS_TYPE_OBJECT: - case EJS_TYPE_PTR: - return 0; - - case EJS_TYPE_BOOL: - return (vp->boolean) ? 1 : 0; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - if (ejsIsNan(vp->floating)) { - return 0; - } - return (int64) vp->floating; -#endif - - case EJS_TYPE_INT: - return vp->integer; - - case EJS_TYPE_INT64: - return vp->integer64; - - case EJS_TYPE_STRING: - if (vp->length == 0) { - return 0; - } else { - return ejsParseInteger64(vp->string); - } - } - - /* Not reached */ - return 0; -} - -#endif /* BLD_FEATURE_INT64 */ -/******************************************************************************/ -/* - * Convert the variable to a number type. Only works for primitive types. - */ - -EjsNum ejsVarToNumber(EjsVar *vp) -{ -#if BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_INT64 - return ejsVarToInteger64(vp); -#elif BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_FLOAT - return ejsVarToFloat(vp); -#else - return ejsVarToInteger(vp); -#endif -} - -/******************************************************************************/ -/* - * Convert a var to a string. Store the result in ep->castTemp. If allocated - * set ep->castAlloc to TRUE. Caller must NOT free the result. - */ - -char *ejsVarToString(Ejs *ep, EjsVar *vp) -{ - MprBuf *bp; - char numBuf[16]; - int len, i; - - if (ep->castAlloc) { - mprFree(ep->castTemp); - } - ep->castTemp = 0; - ep->castAlloc = 0; - - switch (vp->type) { - case EJS_TYPE_UNDEFINED: - ep->castTemp = "undefined"; - break; - - case EJS_TYPE_NULL: - ep->castTemp = "null"; - break; - - case EJS_TYPE_PTR: - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &ep->castTemp, 0, - "[Opaque Pointer %p]", vp->ptr.userPtr); - ep->castAlloc = 1; - break; - - case EJS_TYPE_BOOL: - if (vp->boolean) { - ep->castTemp = "true"; - } else { - ep->castTemp = "false"; - } - break; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - len = mprAllocSprintf(MPR_LOC_ARGS(ep), &ep->castTemp, 0, - "%f", vp->floating); - ep->castAlloc = 1; - break; -#endif - - case EJS_TYPE_INT: - mprItoa(numBuf, sizeof(numBuf), vp->integer); - ep->castTemp = mprStrdup(ep, numBuf); - ep->castAlloc = 1; - break; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - mprAllocSprintf(MPR_LOC_ARGS(ep), &ep->castTemp, 0, - "%Ld", vp->integer64); - ep->castAlloc = 1; - break; -#endif - - case EJS_TYPE_CMETHOD: - ep->castTemp = "[C Method]"; - break; - - case EJS_TYPE_STRING_CMETHOD: - ep->castTemp = "[C StringMethod]"; - break; - - case EJS_TYPE_METHOD: - bp = mprCreateBuf(ep, 0, 0); - mprPutStringToBuf(bp, "function ("); - for (i = 0; i < vp->method.args->length; i++) { - mprPutStringToBuf(bp, vp->method.args->items[i]); - if ((i + 1) < vp->method.args->length) { - mprPutStringToBuf(bp, ", "); - } - } - mprPutStringToBuf(bp, ") {"); - mprPutStringToBuf(bp, vp->method.body); - mprPutStringToBuf(bp, "}"); - mprAddNullToBuf(bp); - ep->castTemp = mprStealBuf(ep, bp); - ep->castAlloc = 1; - mprFree(bp); - break; - - case EJS_TYPE_OBJECT: - if (ejsRunMethod(ep, vp, "toString", 0) < 0) { - return mprStrdup(ep, "[object Object]"); - } - ep->castTemp = mprStrdup(ep, ep->result->string); - ep->castAlloc = 1; - break; - - case EJS_TYPE_STRING: - if (vp->string == 0) { - ep->castTemp = "null"; - } else { - ep->castTemp = vp->string; - } - break; - - default: - mprAssert(0); - } - - mprAssert(ep->castTemp); - return ep->castTemp; -} - -/******************************************************************************/ - -char *ejsVarToStringEx(Ejs *ep, EjsVar *vp, bool *alloc) -{ - char *str; - - mprAssert(alloc); - - str = ejsVarToString(ep, vp); - *alloc = ep->castAlloc; - ep->castAlloc = 0; - ep->castTemp = 0; - return str; -} - -/******************************************************************************/ -/* - * Parse a string based on formatting instructions and intelligently - * create a variable. - * - * Float format: [+|-]DIGITS][DIGITS][(e|E)[+|-]DIGITS] - */ - -EjsVar *ejsParseVar(Ejs *ep, const char *buf, EjsType preferredType) -{ - EjsType type; - const char *cp; - int isHex; - - mprAssert(buf); - - type = preferredType; - - if (preferredType == EJS_TYPE_UNDEFINED) { - isHex = 0; - if (*buf == '-' || *buf == '+') { - type = EJS_NUM_VAR; - - } else if (!isdigit((int) *buf)) { - if (strcmp(buf, "true") == 0 || strcmp(buf, "false") == 0) { - type = EJS_TYPE_BOOL; - } else { - type = EJS_TYPE_STRING; - } - - } else if (isdigit((int) *buf)) { - type = EJS_NUM_VAR; - cp = buf; - if (*cp && tolower(cp[1]) == 'x') { - cp = &cp[2]; - isHex = 1; - for (cp = buf; *cp; cp++) { - if (! isxdigit((int) *cp)) { - break; - } - } - } else { -#if BLD_FEATURE_FLOATING_POINT - /* Could be integer or float */ - for (cp = buf; *cp; cp++) { - if (! isdigit((int) *cp)) { - int c = tolower(*cp); - if (c == '.' || c == 'e' || c == 'f') { - type = EJS_TYPE_FLOAT; - break; - } - } - } -#endif - } - } - } - - switch (type) { - case EJS_TYPE_OBJECT: - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - case EJS_TYPE_PTR: - default: - break; - - case EJS_TYPE_BOOL: - return ejsCreateBoolVar(ep, ejsParseBoolean(buf)); - - case EJS_TYPE_INT: - return ejsCreateIntegerVar(ep, ejsParseInteger(buf)); - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - return ejsCreateInteger64Var(ep, ejsParseInteger64(buf)); -#endif - - case EJS_TYPE_STRING: - if (strcmp(buf, "null") == 0) { - return ejsCreateNullVar(ep); - - } else if (strcmp(buf, "undefined") == 0) { - return ejsCreateUndefinedVar(ep); - } - - return ejsCreateStringVar(ep, buf); - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - return ejsCreateFloatVar(ep, atof(buf)); -#endif - - } - return ejsCreateUndefinedVar(ep); -} - -/******************************************************************************/ -/* - * Convert the variable to a number type. Only works for primitive types. - */ - -bool ejsParseBoolean(const char *s) -{ - if (s == 0 || *s == '\0') { - return 0; - } - if (strcmp(s, "false") == 0 || strcmp(s, "FALSE") == 0) { - return 0; - } - return 1; -} - -/******************************************************************************/ -/* - * Convert the variable to a number type. Only works for primitive types. - */ - -EjsNum ejsParseNumber(const char *s) -{ -#if BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_INT64 - return ejsParseInteger64(s); -#elif BLD_FEATURE_NUM_TYPE_ID == EJS_TYPE_FLOAT - return ejsParseFloat(s); -#else - return ejsParseInteger(s); -#endif -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 -/* - * Convert the string buffer to an Integer64. - */ - -int64 ejsParseInteger64(const char *str) -{ - const char *cp; - int64 num64; - int radix, c, negative; - - mprAssert(str); - - cp = str; - num64 = 0; - negative = 0; - - if (*cp == '-') { - cp++; - negative = 1; - } else if (*cp == '+') { - cp++; - } - - /* - * Parse a number. Observe hex and octal prefixes (0x, 0) - */ - if (*cp != '0') { - /* - * Normal numbers (Radix 10) - */ - while (isdigit((int) *cp)) { - num64 = (*cp - '0') + (num64 * 10); - cp++; - } - } else { - cp++; - if (tolower(*cp) == 'x') { - cp++; - radix = 16; - while (*cp) { - c = tolower(*cp); - if (isdigit(c)) { - num64 = (c - '0') + (num64 * radix); - } else if (c >= 'a' && c <= 'f') { - num64 = (c - 'a' + 10) + (num64 * radix); - } else { - break; - } - cp++; - } - - } else{ - radix = 8; - while (*cp) { - c = tolower(*cp); - if (isdigit(c) && c < '8') { - num64 = (c - '0') + (num64 * radix); - } else { - break; - } - cp++; - } - } - } - - if (negative) { - return 0 - num64; - } - return num64; -} - -#endif /* BLD_FEATURE_INT64 */ -/******************************************************************************/ -/* - * Convert the string buffer to an Integer. - */ - -int ejsParseInteger(const char *str) -{ - const char *cp; - int num; - int radix, c, negative; - - mprAssert(str); - - cp = str; - num = 0; - negative = 0; - - if (*cp == '-') { - cp++; - negative = 1; - } else if (*cp == '+') { - cp++; - } - - /* - * Parse a number. Observe hex and octal prefixes (0x, 0) - */ - if (*cp != '0') { - /* - * Normal numbers (Radix 10) - */ - while (isdigit((int) *cp)) { - num = (*cp - '0') + (num * 10); - cp++; - } - } else { - cp++; - if (tolower(*cp) == 'x') { - cp++; - radix = 16; - while (*cp) { - c = tolower(*cp); - if (isdigit(c)) { - num = (c - '0') + (num * radix); - } else if (c >= 'a' && c <= 'f') { - num = (c - 'a' + 10) + (num * radix); - } else { - break; - } - cp++; - } - - } else{ - radix = 8; - while (*cp) { - c = tolower(*cp); - if (isdigit(c) && c < '8') { - num = (c - '0') + (num * radix); - } else { - break; - } - cp++; - } - } - } - - if (negative) { - return 0 - num; - } - return num; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Convert the string buffer to an Floating. - */ - -double ejsParseFloat(const char *str) -{ - return atof(str); -} - -/******************************************************************************/ - -int ejsIsNan(double f) -{ -#if WIN - return _isnan(f); -#elif VXWORKS - /* FUTURE */ - return (0); -#else - return (f == FP_NAN); -#endif -} -/******************************************************************************/ - -int ejsIsInfinite(double f) -{ -#if WIN - return !_finite(f); -#elif VXWORKS - /* FUTURE */ - return (0); -#else - return (f == FP_INFINITE); -#endif -} - -#endif /* BLD_FEATURE_FLOATING_POINT */ - -/******************************************************************************/ -/* - * Single point of control for all assignment to properties. - * - * Copy an objects core value (only). This preserves the destination object's - * name. This implements copy by reference for objects and copy by value for - * strings and other types. Caller must free dest prior to calling. - */ - -static EjsVar *copyVar(EJS_LOC_DEC(ep, loc), EjsVar *dest, const EjsVar *src, - EjsCopyDepth copyDepth) -{ - Ejs *ejsContext; - EjsObj *srcObj; - EjsProperty *destp; - const char **srcArgs; - char *str; - int i; - - mprAssert(dest); - mprAssert(src); - - if (dest == src) { - return dest; - } - - if (dest->type != EJS_TYPE_UNDEFINED) { - ejsClearVar(ep, dest); - } - - dest->allocatedData = 0; - - switch (src->type) { - default: - case EJS_TYPE_UNDEFINED: - case EJS_TYPE_NULL: - break; - - case EJS_TYPE_BOOL: - dest->boolean = src->boolean; - break; - - case EJS_TYPE_PTR: - dest->ptr = src->ptr; - if (dest->ptr.destructor) { - dest->allocatedData = 1; - } - break; - - case EJS_TYPE_STRING_CMETHOD: - dest->cMethodWithStrings = src->cMethodWithStrings; - break; - - case EJS_TYPE_CMETHOD: - dest->cMethod = src->cMethod; - break; - -#if BLD_FEATURE_FLOATING_POINT - case EJS_TYPE_FLOAT: - dest->floating = src->floating; - break; -#endif - - case EJS_TYPE_INT: - dest->integer = src->integer; - break; - -#if BLD_FEATURE_INT64 - case EJS_TYPE_INT64: - dest->integer64 = src->integer64; - break; -#endif - - case EJS_TYPE_OBJECT: - if (copyDepth == EJS_SHALLOW_COPY) { - - /* - * If doing a shallow copy and the src object is from the same - * interpreter, or we are copying from the master interpreter, or - * we are using a shared slab, then we can do a shallow copy. - * Otherwise, we must do a deep copy. - */ - srcObj = src->objectState; - if (srcObj->ejs == ep || srcObj->ejs == ep->service->master || - (ep->flags & EJS_FLAGS_SHARED_SLAB)) { - dest->objectState = src->objectState; - dest->allocatedData = 1; - break; - } - } - - /* - * Doing a deep or recursive deep. Can get here if doing a shallow - * copy and the object is from another non-master interpeter and not - * using a shared slab. - * - * We must make sure the data is allocated using the right memory - * context. It must be the same as the destination parent object. - * Otherwise, when we free the property memory, the parent may - * have a dangling pointer. - */ - if (dest->isProperty) { - destp = ejsGetPropertyPtr(dest); - if (destp->parentObj == 0) { - ejsContext = ep; - - } else { - mprAssert(destp->parentObj); - ejsContext = destp->parentObj->ejs; - mprAssert(ejsContext); - } - - } else { - ejsContext = ep; - } - - dest->objectState = createObj(EJS_LOC_PASS(ejsContext, loc)); - if (dest->objectState == 0) { - /* Memory Error */ - return 0; - } - - dest->objectState->baseClass = src->objectState->baseClass; - dest->objectState->methods = src->objectState->methods; - dest->objectState->noConstructor = src->objectState->noConstructor; - dest->objectState->objName = - mprStrdup(ejsContext, src->objectState->objName); - - if (dest->objectState->objName == 0) { - return 0; - } - - if (ejsCopyProperties(ep, dest, src, copyDepth) == 0) { - return 0; - } - dest->allocatedData = 1; - break; - - case EJS_TYPE_METHOD: - dest->method.args = mprCreateItemArray(ep, EJS_INC_ARGS, - EJS_MAX_ARGS); - if (dest->method.args == 0) { - return 0; - } - dest->allocatedData = 1; - if (src->method.args) { - srcArgs = (const char**) src->method.args->items; - for (i = 0; i < src->method.args->length; i++) { - str = mprStrdupInternal(EJS_LOC_PASS(dest->method.args, - loc), srcArgs[i]); - if (str == 0) { - mprFree(dest->method.args); - dest->method.args = 0; - return 0; - } - if (mprAddItem(dest->method.args, str) < 0) { - mprFree(dest->method.args); - dest->method.args = 0; - return 0; - } - } - } - dest->method.body = mprStrdup(dest->method.args, src->method.body); - if (dest->method.body == 0) { - mprFree(dest->method.args); - dest->method.args = 0; - return 0; - } - dest->callsSuper = src->callsSuper; - break; - - case EJS_TYPE_STRING: - dest->length = src->length; - if (src->string) { - /* Shallow, deep or recursive deep */ - dest->length = dupString(MPR_LOC_PASS(ep, loc), &dest->ustring, - src->ustring, src->length); - if (dest->length < 0) { - return 0; - } - dest->allocatedData = 1; - - } else { - dest->string = src->string; - dest->allocatedData = 0; - } - break; - } - - dest->type = src->type; - dest->flags = src->flags; - dest->isArray = src->isArray; - - return dest; -} - -/******************************************************************************/ -/* - * Copy all properies in an object. Must preserve property order - */ - -EjsVar *ejsCopyProperties(Ejs *ep, EjsVar *dest, const EjsVar *src, - EjsCopyDepth copyDepth) -{ - EjsProperty *srcProp, *destProp, *last, *next; - int propertyIndex; - - srcProp = ejsGetFirstProperty(src, EJS_ENUM_ALL); - while (srcProp) { - next = ejsGetNextProperty(srcProp, EJS_ENUM_ALL); - if (srcProp->visited) { - srcProp = next; - continue; - } - - /* - * This finds the last variable in the hash chain - * FUTURE OPT. This is slow. If used double link, we could locate the - * tail more easily. - */ - destProp = hashLookup(dest->objectState, srcProp->name, - &propertyIndex, &last); - mprAssert(destProp == 0); - - destProp = allocProperty(ep, dest, srcProp->name, propertyIndex, last); - if (destProp == 0) { - mprAssert(destProp); - return 0; - } - - /* - * Recursively copy the object. If DEEP_COPY, then we - * will do a shallow copy of the object contents. If - * RECURSIVE_DEEP, then we do a deep copy at all levels. - */ - srcProp->visited = 1; - - if (copyVar(EJS_LOC_ARGS(ep), ejsGetVarPtr(destProp), - ejsGetVarPtr(srcProp), - (copyDepth == EJS_DEEP_COPY) ? EJS_SHALLOW_COPY : copyDepth) - == 0) { - return 0; - } - srcProp->visited = 0; - - srcProp = next; - } - return dest; -} - -/******************************************************************************/ -/********************************** Properties ********************************/ -/******************************************************************************/ -/* - * Create a property in an object and return a pointer to it. If the property - * already exists then just return a pointer to it (no error). - * To test for existance of a property, use GetProperty - */ - -static EjsProperty *hashLookup(EjsObj *obj, const char *property, - int *propertyIndex, EjsProperty **hashTail) -{ - EjsProperty *prop, *last; - int index; - - mprAssert(obj); - mprAssert(property); - - if (obj == 0 || property == 0 || *property == '\0') { - mprAssert(0); - return 0; - } - - /* - * Find the property in the hash chain if it exists - */ - index = hash(property); - prop = obj->propertyHash[index]; - for (last = 0; prop != 0; last = prop, prop = prop->hashNext) { - if (prop->name[0] == property[0] && - strcmp(prop->name, property) == 0) { - break; - } - } - if (propertyIndex) { - *propertyIndex = index; - } - if (hashTail) { - *hashTail = last; - } - - return prop; -} - -/******************************************************************************/ -/* - * Create a property in an object and return a pointer to it. If the property - * already exists then just return a pointer to it (no error). If the property - * does not exist, create an undefined variable. To test for existance of a - * property, use GetProperty. - */ - -EjsProperty *ejsCreateSimpleProperty(Ejs *ep, EjsVar *op, const char *property) -{ - EjsProperty *prop, *last; - int propertyIndex; - - if (op == 0 || op->type != EJS_TYPE_OBJECT || property == 0 || - *property == '\0') { - mprAssert(0); - return 0; - } - - /* - * Find the property in the hash chain if it exists - */ - prop = hashLookup(op->objectState, property, &propertyIndex, &last); - - if (prop == 0) { - /* - * Create a new property - */ - prop = allocProperty(ep, op, property, propertyIndex, last); - if (prop == 0) { - mprAssert(prop == 0); - return 0; - } - } - return prop; -} - -/******************************************************************************/ -/* - * Create a property in an object and return a pointer to it. If the property - * already exists then just return a pointer to it (no error). - * To test for existance of a property, use GetProperty - */ - -EjsProperty *ejsCreateSimpleNonUniqueProperty(Ejs *ep, EjsVar *op, - const char *property) -{ - EjsProperty *prop, *last; - int propertyIndex; - - if (op == 0 || op->type != EJS_TYPE_OBJECT || property == 0 || - *property == '\0') { - mprAssert(0); - return 0; - } - - /* - * Find end of chain - */ - propertyIndex = hash(property); - prop = op->objectState->propertyHash[propertyIndex]; - for (last = 0; prop != 0; last = prop, prop = prop->hashNext) { - ; - } - - return allocProperty(ep, op, property, propertyIndex, last); -} - -/******************************************************************************/ -/* - * Find a property in an object and return a pointer to it. - * This does NOT traverse base classes. - */ - -EjsProperty *ejsGetSimpleProperty(Ejs *ep, EjsVar *op, const char *property) -{ - mprAssert(op); - mprAssert(op->type == EJS_TYPE_OBJECT); - mprAssert(property && *property); - - /* - * This is an internal API. It has very little checking. - */ - return hashLookup(op->objectState, property, 0, 0); -} - -/******************************************************************************/ - -/* - * NOTE: There is no ejsSetSimpleProperty as all the ejsSetProperty routines - * operate only on the instance and don't follow base classes. ie. there is - * no simple version required. However, there is a ejsSetBaseProperty routine - * that will follow base classes and is used to set static properties in base - * classes - */ - -/******************************************************************************/ -/******************************* Property Access ******************************/ -/******************************************************************************/ -/* - * The property get routines follow base classes and utilize the propery - * method access routines. The property set routines do not follow base - * classes. The property ejsSetBase... routines do follow base classes. - */ - -/* - * Find a property in an object and return a pointer to it. - * This follows base classes. - */ - -EjsProperty *ejsGetProperty(Ejs *ep, EjsVar *op, const char *property) -{ - EjsVar *vp, *newOp; - int maxBaseClasses = 50; - - do { - if (op->type != EJS_TYPE_OBJECT) { - mprAssert(op->type == EJS_TYPE_OBJECT); - return 0; - } - mprAssert(op->objectState); - - vp = ejsGetPropertyMethod(ep, op, property); - if (vp != 0) { - /* - * Found - */ - break; - } - - newOp = op->objectState->baseClass; - if (newOp == 0) { - if (op->objectState != ep->objectClass->objectState) { - newOp = ep->objectClass; - } - } - op = newOp; - - /* - * A little bit of sanity checking - */ - if (--maxBaseClasses <= 0) { - mprAssert(maxBaseClasses > 0); - break; - } - - } while (op); - - return ejsGetPropertyPtr(vp); -} - -/******************************************************************************/ -/* - * Get the property's variable. Optionally create if it does not exist. - */ - -EjsVar *ejsGetPropertyAsVar(Ejs *ep, EjsVar *vp, const char *property) -{ - return ejsGetVarPtr(ejsGetProperty(ep, vp, property)); -} - -/******************************************************************************/ -/* - * Get the property's value as a binary string. - */ - -const uchar *ejsGetPropertyAsBinaryString(Ejs *ep, EjsVar *obj, - const char *property, int *length) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property)); - if (vp == 0 || ejsVarIsUndefined(vp)) { - return 0; - } - - if (vp->type == EJS_TYPE_STRING) { - if (length) { - *length = vp->length; - } - return vp->ustring; - } - return 0; -} - -/******************************************************************************/ -/* - * Get the property's value as a string. - */ - -const char *ejsGetPropertyAsString(Ejs *ep, EjsVar *obj, const char *property) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property)); - if (vp == 0 || ejsVarIsUndefined(vp)) { - return 0; - } - - if (vp->type == EJS_TYPE_STRING) { - return vp->string; - } - return 0; -} - -/******************************************************************************/ -/* - * Get the property's value as a number. - */ - -BLD_FEATURE_NUM_TYPE ejsGetPropertyAsNumber(Ejs *ep, EjsVar *obj, - const char *property) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property)); - if (vp == 0 || ejsVarIsUndefined(vp)) { - return 0; - } - - return ejsVarToNumber(vp); -} - -/******************************************************************************/ -/* - * Get the property's value as a integer. - */ - -int ejsGetPropertyAsInteger(Ejs *ep, EjsVar *obj, const char *property) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property)); - if (vp == 0 || ejsVarIsUndefined(vp)) { - return 0; - } - - return ejsVarToInteger(vp); -} - -/******************************************************************************/ -/* - * Get the property's value as a boolean. - */ - -bool ejsGetPropertyAsBoolean(Ejs *ep, EjsVar *obj, const char *property) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property)); - if (vp == 0 || ejsVarIsUndefined(vp)) { - return 0; - } - - return ejsVarToBoolean(vp); -} - -/******************************************************************************/ -/* - * Get the property's value as a pointer. - */ - -void *ejsGetPropertyAsPtr(Ejs *ep, EjsVar *obj, const char *property) -{ - EjsVar *vp; - - vp = ejsGetVarPtr(ejsGetProperty(ep, obj, property)); - if (vp == 0 || ejsVarIsUndefined(vp)) { - return 0; - } - if (vp->type == EJS_TYPE_PTR) { - return vp->ptr.userPtr; - } - return 0; -} - -/******************************************************************************/ -/* - * Create a property in the object. This will override any base class - * properties. - * - * MOB -- need to spell out the difference between ejsSetProperty and - * ejsCreateProperty. - */ - -EjsProperty *ejsCreateProperty(Ejs *ep, EjsVar *obj, const char *property) -{ - EjsVar *vp; - - vp = ejsCreatePropertyMethod(ep, obj, property); - return ejsGetPropertyPtr(vp); -} - -/******************************************************************************/ -/* - * Set a property's variable value. Create the property if it does not exist. - * This routine DOES follow base classes. - */ - -EjsProperty *ejsSetBaseProperty(Ejs *ep, EjsVar *op, const char *property, - const EjsVar *value) -{ - EjsVar *vp, *newOp; - int maxBaseClasses = 50; - - do { - if (op->type != EJS_TYPE_OBJECT) { - mprAssert(op->type == EJS_TYPE_OBJECT); - return 0; - } - mprAssert(op->objectState); - - vp = ejsGetPropertyMethod(ep, op, property); - if (vp != 0) { - /* - * Found - */ - vp = ejsSetPropertyMethod(ep, op, property, value); - break; - } - - newOp = op->objectState->baseClass; - if (newOp == 0) { - if (op->objectState != ep->objectClass->objectState) { - newOp = ep->objectClass; - } - } - op = newOp; - - /* - * A little bit of sanity checking - */ - if (--maxBaseClasses <= 0) { - mprAssert(maxBaseClasses > 0); - break; - } - - } while (op); - - return ejsGetPropertyPtr(vp); -} - -/******************************************************************************/ -/* - * Set a property's variable value. Create the property if it does not exist. - * This does NOT follow base classes. Okay when updating instance properties, - * but not for class (static) properties. This does a shallow copy which - * will copy references. - */ - -EjsProperty *ejsSetProperty(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value) -{ - EjsVar *vp; - - vp = ejsSetPropertyMethod(ep, obj, property, value); - - return ejsGetPropertyPtr(vp); -} - -/******************************************************************************/ -/* - * Set a property's variable value by assigning the given value. The caller - * must NOT free value as it is assigned directly into the property's value. - */ - -EjsProperty *ejsSetPropertyAndFree(Ejs *ep, EjsVar *obj, - const char *property, EjsVar *value) -{ - EjsVar *vp; - - vp = ejsSetPropertyMethod(ep, obj, property, value); - - ejsFree(ep, value, EJS_SLAB_VAR); - - return ejsGetPropertyPtr(vp); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToCMethod(Ejs *ep, EjsVar *vp, const char *prop, - EjsCMethod fn, void *userData, int flags) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_CMETHOD); - v.cMethod.fn = fn; - v.cMethod.userData = userData; - v.flags = flags; - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToBoolean(Ejs *ep, EjsVar *vp, const char *prop, - int value) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_BOOL); - v.boolean = value; - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT - -EjsProperty *ejsSetPropertyToFloat(Ejs *ep, EjsVar *vp, const char *prop, - double value) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_FLOAT); - v.floating = value; - - return ejsSetProperty(ep, vp, prop, &v); -} - -#endif -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToInteger(Ejs *ep, EjsVar *vp, const char *prop, - int value) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_INT); - v.integer = value; - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 - -EjsProperty *ejsSetPropertyToInteger64(Ejs *ep, EjsVar *vp, const char *prop, - int64 value) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_INT64); - v.integer64 = value; - - return ejsSetProperty(ep, vp, prop, &v); -} - -#endif -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToNull(Ejs *ep, EjsVar *vp, const char *prop) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_NULL); - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToMethod(Ejs *ep, EjsVar *vp, const char *prop, - const char *body, MprArray *args, int flags) -{ - return ejsSetPropertyAndFree(ep, vp, prop, - ejsCreateMethodVar(ep, body, args, flags)); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToNumber(Ejs *ep, EjsVar *vp, const char *prop, - EjsNum value) -{ - return ejsSetPropertyAndFree(ep, vp, prop, ejsCreateNumberVar(ep, value)); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToStringCMethod(Ejs *ep, EjsVar *vp, - const char *prop, EjsStringCMethod fn, void *userData, int flags) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_STRING_CMETHOD); - v.cMethodWithStrings.fn = fn; - v.cMethodWithStrings.userData = userData; - v.flags = flags; - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToString(Ejs *ep, EjsVar *vp, const char *prop, - const char *value) -{ - EjsProperty *pp; - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_STRING); - - /* FUTURE OPT */ - v.string = mprStrdupInternal(EJS_LOC_ARGS(ep), value); - if (v.string == 0) { - return 0; - } - v.length = strlen(v.string); - v.allocatedData = 1; - - pp = ejsSetProperty(ep, vp, prop, &v); - - mprFree(v.string); - - return pp; -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToBinaryString(Ejs *ep, EjsVar *vp, - const char *prop, const uchar *value, int len) -{ - EjsProperty *pp; - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_STRING); - - /* FUTURE OPT */ - v.length = dupString(MPR_LOC_ARGS(ep), &v.ustring, value, len); - if (v.length < 0) { - return 0; - } - v.allocatedData = 1; - - pp = ejsSetProperty(ep, vp, prop, &v); - - mprFree(v.ustring); - - return pp; -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToUndefined(Ejs *ep, EjsVar *vp, const char *prop) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_UNDEFINED); - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToPtr(Ejs *ep, EjsVar *vp, const char *prop, - void *ptr, EjsDestructor destructor) -{ - EjsVar v; - - ejsInitVar(&v, EJS_TYPE_PTR); - v.ptr.userPtr = ptr; - v.ptr.destructor = destructor; - v.allocatedData = 1; - - return ejsSetProperty(ep, vp, prop, &v); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToNewObj(Ejs *ep, EjsVar *vp, const char *prop, - const char *className, MprArray *args) -{ - return ejsSetPropertyAndFree(ep, vp, prop, - ejsCreateObjUsingArgv(ep, 0, className, args)); -} - -/******************************************************************************/ - -EjsProperty *ejsSetPropertyToObj(Ejs *ep, EjsVar *op, const char *prop) -{ - return ejsSetPropertyAndFree(ep, op, prop, ejsCreateObjVar(ep)); -} - -/******************************************************************************/ -/* - * Convenience routines - */ - -EjsVar *ejsSetPropertyToObjAsVar(Ejs *ep, EjsVar *op, const char *prop) -{ - return ejsGetVarPtr(ejsSetPropertyToObj(ep, op, prop)); -} - -/******************************************************************************/ -/******************************************************************************/ -/******************************************************************************/ -/******************************************************************************/ -/* - * Create a script method - */ - -EjsProperty *ejsDefineMethod(Ejs *ep, EjsVar *vp, const char *prop, - const char *body, MprArray *args) -{ - if (vp == 0) { - vp = ejsGetGlobalObj(ep); - } - return ejsSetPropertyToMethod(ep, vp, prop, body, args, 0); -} - -/******************************************************************************/ -/* - * Create a C language method - */ - -EjsProperty *ejsDefineCMethod(Ejs *ep, EjsVar *vp, const char *prop, - EjsCMethod fn, int flags) -{ - if (vp == 0) { - vp = ejsGetGlobalObj(ep); - } - return ejsSetPropertyToCMethod(ep, vp, prop, fn, 0, flags); -} - -/******************************************************************************/ -/* - * Define accessors - */ - -EjsProperty *ejsDefineAccessors(Ejs *ep, EjsVar *vp, const char *prop, - const char *getBody, const char *setBody) -{ - EjsProperty *pp; - MprArray *args; - char *propName; - - if (vp == 0) { - vp = ejsGetGlobalObj(ep); - } - - if (ejsSetPropertyToMethod(ep, vp, prop, getBody, 0, EJS_GET_ACCESSOR) < 0){ - ejsMemoryError(ep); - return 0; - } - - /* MOB -- OPT to use SLAB */ - /* MOB -- need to encapsulate this logic */ - - if (mprAllocStrcat(MPR_LOC_ARGS(ep), &propName, EJS_MAX_ID+5, 0, - "-set-", prop, NULL) < 0) { - ejsMemoryError(ep); - return 0; - } - - args = mprCreateItemArray(ep, EJS_INC_ARGS, EJS_MAX_ARGS); - mprAddItem(args, mprStrdup(args, "value")); - - pp = ejsSetPropertyToMethod(ep, vp, propName, setBody, args, - EJS_SET_ACCESSOR); - mprFree(propName); - - if (pp == 0) { - ejsMemoryError(ep); - return 0; - } - - return pp; -} - -/******************************************************************************/ -/* - * Define C accessors - */ - -EjsProperty *ejsDefineCAccessors(Ejs *ep, EjsVar *vp, const char *prop, - EjsCMethod getFn, EjsCMethod setFn, int flags) -{ - EjsProperty *pp; - char *propName; - - if (vp == 0) { - vp = ejsGetGlobalObj(ep); - } - pp = ejsSetPropertyToCMethod(ep, vp, prop, getFn, 0, - flags | EJS_GET_ACCESSOR); - if (pp == 0) { - ejsMemoryError(ep); - return 0; - } - - /* MOB -- OPT to use SLAB */ - if (mprAllocStrcat(MPR_LOC_ARGS(ep), &propName, EJS_MAX_ID + 5, 0, - "-set-", prop, NULL) < 0) { - ejsMemoryError(ep); - return 0; - } - pp = ejsSetPropertyToCMethod(ep, vp, propName, setFn, 0, - flags | EJS_SET_ACCESSOR); - mprFree(propName); - - if (pp == 0) { - ejsMemoryError(ep); - return 0; - } - return pp; -} - -/******************************************************************************/ -/* - * Create a C language method with string arguments - */ - -EjsProperty *ejsDefineStringCMethod(Ejs *ep, EjsVar *vp, const char *prop, - EjsStringCMethod fn, int flags) -{ - if (vp == 0) { - vp = ejsGetGlobalObj(ep); - } - return ejsSetPropertyToStringCMethod(ep, vp, prop, fn, 0, flags); -} - -/******************************************************************************/ - -void ejsSetCMethodUserData(EjsVar *obj, void *userData) -{ - /* - * This is a little dirty. We rely on the userData being in the same - * place in the var structure. - */ - obj->cMethod.userData = userData; -} - -/******************************************************************************/ - -void ejsSetVarFlags(EjsVar *obj, int flags) -{ - obj->flags = flags; -} - -/******************************************************************************/ - -void *ejsGetCMethodUserData(EjsVar *obj) -{ - return obj->cMethod.userData; -} - -/******************************************************************************/ - -int ejsGetVarFlags(EjsVar *obj) -{ - return obj->flags; -} - -/******************************************************************************/ - -void ejsSetObjDestructor(Ejs *ep, EjsVar *obj, EjsDestructor destructor) -{ - obj->objectState->destructor = destructor; -} - -/******************************************************************************/ - -void ejsClearObjDestructor(Ejs *ep, EjsVar *obj) -{ - obj->objectState->destructor = 0; -} - -/******************************************************************************/ -/* - * Create a new property - */ - -static EjsProperty *allocProperty(Ejs *ep, EjsVar *op, const char *property, - int propertyIndex, EjsProperty *last) -{ - EjsProperty *prop; - EjsObj *obj; - - obj = op->objectState; - - /* - * Allocate the property using the memory context of the owning object - */ - prop = ejsAllocProperty(EJS_LOC_ARGS(obj->ejs)); - if (prop == 0) { - return 0; - } - if (mprStrcpy(prop->name, sizeof(prop->name), property) < 0) { - ejsError(ep, EJS_REFERENCE_ERROR, - "Property name %s is too long. Max is %d letters.", - prop->name, EJS_MAX_ID); - return 0; - } - - ejsSetVarName(ep, ejsGetVarPtr(prop), &prop->name[0]); - - /* - * Do hash linkage - */ - if (last) { - last->hashNext = prop; - } else { - obj->propertyHash[propertyIndex] = prop; - } - -#if BLD_DEBUG - prop->link.propertyName = prop->name; - prop->link.property = prop; - prop->link.head = &obj->link; -#endif - - /* - * Inserting before the dummy head will append to the end - */ - linkPropertyBefore(obj, &obj->link, &prop->link); - - obj->numProperties++; - prop->parentObj = obj; - mprAssert(obj->ejs); - - return prop; -} - -/******************************************************************************/ -/* - * Delete a property from this object - */ - -int ejsDeleteProperty(Ejs *ep, EjsVar *vp, const char *property) -{ - EjsProperty *prop, *last; - EjsObj *obj; - int propertyIndex; - - mprAssert(vp); - mprAssert(property && *property); - mprAssert(vp->type == EJS_TYPE_OBJECT); - - if (vp->type != EJS_TYPE_OBJECT) { - mprAssert(vp->type == EJS_TYPE_OBJECT); - return MPR_ERR_BAD_ARGS; - } - - prop = hashLookup(vp->objectState, property, &propertyIndex, &last); - if (prop == (EjsProperty*) 0) { - return MPR_ERR_NOT_FOUND; - } - obj = vp->objectState; - -#if FUTURE - if (prop->readonly) { - mprAssert(! prop->readonly); - return MPR_ERR_READ_ONLY; - } -#endif - - /* - * If doing enumerations, then the object will mark preventDelete to - * prevent any properties being deleted and thus disturbing the - * traversal. - */ - if (obj->preventDeleteProp) { - obj->delayedDeleteProp = 1; - prop->delayedDelete = 1; - return 0; - } - - /* - * Remove from hash - */ - if (last) { - last->hashNext = prop->hashNext; - } else { - obj->propertyHash[propertyIndex] = prop->hashNext; - } - - unlinkProperty(obj, &prop->link); - obj->numProperties--; - - /* - * Free any property data and return to the slab - */ - if (prop->var.type != EJS_TYPE_OBJECT) { - ejsClearVar(ep, ejsGetVarPtr(prop)); - } - ejsFree(ep, prop, EJS_SLAB_PROPERTY); - - return 0; -} - -/******************************************************************************/ -/* - * Remove a property's value from this object. The property is set to - * undefined. - */ - -EjsVar *ejsClearProperty(Ejs *ep, EjsVar *vp, const char *property) -{ - EjsProperty *prop; - - mprAssert(vp); - mprAssert(property && *property); - mprAssert(vp->type == EJS_TYPE_OBJECT); - - if (vp->type != EJS_TYPE_OBJECT) { - mprAssert(vp->type == EJS_TYPE_OBJECT); - return 0; - } - - prop = hashLookup(vp->objectState, property, 0, 0); - if (prop == (EjsProperty*) 0) { - return 0; - } -#if FUTURE - if (prop->readonly) { - mprAssert(! prop->readonly); - return 0; - } -#endif - - ejsClearVar(ep, &prop->var); - return &prop->var; -} - -/******************************************************************************/ -/* - * Unlink a property from the ordered list of properties - */ - -static void unlinkProperty(EjsObj *obj, EjsPropLink *propLink) -{ - propLink->prev->next = propLink->next; - propLink->next->prev = propLink->prev; -} - -/******************************************************************************/ -#if UNUSED && KEEP -/* - * Insert a link after a specified link. - */ - -static void linkPropertyAfter(EjsObj *obj, EjsPropLink *at, - EjsPropLink *propLink) -{ - propLink->next = at->next; - propLink->prev = at; - - at->next->prev = propLink; - at->next = propLink; -} - -#endif -/******************************************************************************/ -/* - * Insert a link before a specified link. - */ - -static void linkPropertyBefore(EjsObj *obj, EjsPropLink *at, - EjsPropLink *propLink) -{ - propLink->prev = at->prev; - propLink->next = at; - - at->prev->next = propLink; - at->prev = propLink; -} - -/******************************************************************************/ -/* - * This routine will sort properties in an object. If propertyName is not - * null, then the properties in op must be objects with a property of the - * name propertyName. If propertyName is null, then the properties of op - * are directly sorted. If order is 1, they are sorted in ascending order. - * If -1, they are sorted in descending order. - * - * NOTE: arrays keep their original index values. - */ - -void ejsSortProperties(Ejs *ep, EjsVar *op, EjsSortFn fn, - const char *propertyName, int order) -{ - EjsProperty *p1, *p2, *tmp; - EjsPropLink *l1, *l2, *oldL1Spot; - EjsObj *obj; - - obj = op->objectState; - - p1 = ejsGetFirstProperty(op, 0); - while (p1) { - if (p1->dontEnumerate) { - p1 = ejsGetNextProperty(p1, 0); - continue; - } - - p2 = ejsGetFirstProperty(op, 0); - while (p2 && p2 != p1) { - - if (p2->dontEnumerate) { - p2 = ejsGetNextProperty(p2, 0); - continue; - } - - if (fn == 0) { - if (propertyName) { - fn = sortByProperty; - } else { - fn = sortAllProperties; - } - } - - if (fn(ep, p1, p2, propertyName, order) < 0) { - - l1 = &p1->link; - l2 = &p2->link; - - /* - * Swap the properties without disturbing the hash chains. - * l1 is always after l2 in the list. Unlink l1 and remember - * the one after l1. - */ - oldL1Spot = l1->next; - unlinkProperty(obj, l1); - - /* - * Manually reinsert l1 by replacing l2 with l1. l2 is out of - * the chain. - */ - l2->prev->next = l1; - l2->next->prev = l1; - l1->prev = l2->prev; - l1->next = l2->next; - - /* - * Reinsert l2 before the spot where l1 was. - */ - linkPropertyBefore(obj, oldL1Spot, l2); - - /* - * Swap the pointers so we continue to traverse correctly - */ - tmp = p1; - p1 = p2; - p2 = tmp; - } - p2 = ejsGetNextProperty(p2, 0); - } - p1 = ejsGetNextProperty(p1, 0); - } -} - -/******************************************************************************/ -/* - * Sort properties. Strings are sorted in ascending ASCII collating sequence - * Numbers are sorted in increasing numerical order. - */ -static int sortAllProperties(Ejs *ep, EjsProperty *p1, EjsProperty *p2, - const char *propertyName, int order) -{ - EjsVar *v1, *v2; - char *buf1, *buf2; - int rc, buf1Alloc; - - v1 = ejsGetVarPtr(p1); - v2 = ejsGetVarPtr(p2); - - if (v1->type == v2->type) { - /* MOB -- should support Numbers */ - if (v1->type == EJS_TYPE_INT) { - if (v1->integer < v2->integer) { - return - order; - - } else if (v1->integer == v2->integer) { - return 0; - } - return order; - -#if BLD_FEATURE_FLOATING_POINT - } else if (v1->type == EJS_TYPE_FLOAT) { - if (v1->floating < v2->floating) { - return - order; - - } else if (v1->floating == v2->floating) { - return 0; - } - return order; - -#endif - } else if (v1->type == EJS_TYPE_STRING) { - /* MOB -- need binary support ? */ - return strcmp(v1->string, v2->string) * order; - - } else { - - buf1 = ejsVarToStringEx(ep, v1, &buf1Alloc); - buf2 = ejsVarToString(ep, v2); - - rc = strcmp(buf1, buf2); - - if (buf1Alloc) { - mprFree(buf1); - } - - return rc * order; - } - - } else { - /* Type mismatch in array */ - return 0; - } - return 0; -} - -/******************************************************************************/ -/* - * Sort an object by a given property. - */ -static int sortByProperty(Ejs *ep, EjsProperty *p1, EjsProperty *p2, - const char *propertyName, int order) -{ - EjsVar *o1, *o2, *v1, *v2; - char *buf1, *buf2; - int rc, buf1Alloc; - - o1 = ejsGetVarPtr(p1); - o2 = ejsGetVarPtr(p2); - - if (!ejsVarIsObject(o1) || !ejsVarIsObject(o2)) { - mprAssert(ejsVarIsObject(o1)); - mprAssert(ejsVarIsObject(o2)); - return 0; - } - - v1 = ejsGetPropertyAsVar(ep, o1, propertyName); - v2 = ejsGetPropertyAsVar(ep, o2, propertyName); - - if (v1 == 0 || v2 == 0) { - /* Property name not found */ - return 0; - } - - if (v1->type != v2->type) { - mprAssert(v1->type == v2->type); - return 0; - } - - if (v1->type == v2->type) { - /* MOB -- should support Numbers */ - if (v1->type == EJS_TYPE_INT) { - if (v1->integer < v2->integer) { - return -order; - - } else if (v1->integer == v2->integer) { - return 0; - } - return order; - -#if BLD_FEATURE_FLOATING_POINT - } else if (v1->type == EJS_TYPE_FLOAT) { - if (v1->floating < v2->floating) { - return -order; - - } else if (v1->floating == v2->floating) { - return 0; - } - return order; - -#endif - } else if (v1->type == EJS_TYPE_STRING) { - /* MOB -- need binary support ? */ - return strcmp(v1->string, v2->string) * order; - - } else { - buf1 = ejsVarToStringEx(ep, v1, &buf1Alloc); - - buf2 = ejsVarToString(ep, v2); - - rc = strcmp(buf1, buf2); - - if (buf1Alloc) { - mprFree(buf1); - } - - return rc * order; - } - - } else { - /* Type mismatch in array */ - return 0; - } - return 0; -} - -/******************************************************************************/ -/* - * Set a property's name - */ - -void ejsSetPropertyName(EjsProperty *pp, const char *property) -{ - mprStrcpy(pp->name, sizeof(pp->name), property); -} - -/******************************************************************************/ - -int ejsMakePropertyEnumerable(EjsProperty *prop, int enumerate) -{ - int oldValue; - - oldValue = prop->dontEnumerate; - prop->dontEnumerate = !enumerate; - return oldValue; -} - -/******************************************************************************/ - -void ejsMakePropertyPrivate(EjsProperty *prop, int isPrivate) -{ - prop->isPrivate = isPrivate; -} - -/******************************************************************************/ -/* - * Make a variable read only. Can still be deleted. - */ - -void ejsMakePropertyReadOnly(EjsProperty *prop, int readonly) -{ - prop->readonly = readonly; -} - -/******************************************************************************/ - -int ejsMakeObjPermanent(EjsVar *vp, int permanent) -{ - int oldValue; - - if (vp && vp->type == EJS_TYPE_OBJECT) { - oldValue = vp->objectState->permanent; - vp->objectState->permanent = permanent; - } else { - oldValue = 0; - } - return oldValue; -} - -/******************************************************************************/ - -int ejsMakeObjLive(EjsVar *vp, bool alive) -{ - int oldValue; - - oldValue = 0; - if (vp && vp->type == EJS_TYPE_OBJECT) { - oldValue = vp->objectState->alive; - vp->objectState->alive = alive; - } else { - oldValue = 0; - } - return oldValue; -} - -/******************************************************************************/ - -void ejsMakeClassNoConstructor(EjsVar *vp) -{ - mprAssert(vp->type == EJS_TYPE_OBJECT); - - if (vp->type == EJS_TYPE_OBJECT) { - vp->objectState->noConstructor = 1; - } -} - -/******************************************************************************/ -/* - * Get the count of properties. - */ - -int ejsGetPropertyCount(EjsVar *vp) -{ - EjsProperty *pp; - EjsPropLink *lp, *head; - int count; - - mprAssert(vp); - - if (vp->type != EJS_TYPE_OBJECT) { - return 0; - } - - count = 0; - - head = &vp->objectState->link; - for (lp = head->next; lp != head; lp = lp->next) { - pp = ejsGetPropertyFromLink(lp); - if (! pp->dontEnumerate) { - count++; - } - } - return count; -} - -/******************************************************************************/ -/* - * Get the first property in an object. Used for walking all properties in an - * object. This will only enumerate properties in this class and not in base - * classes. - */ - -EjsProperty *ejsGetFirstProperty(const EjsVar *op, int flags) -{ - EjsProperty *pp; - EjsObj *obj; - EjsPropLink *head, *lp; - - mprAssert(op); - mprAssert(op->type == EJS_TYPE_OBJECT); - - if (op->type != EJS_TYPE_OBJECT) { - mprAssert(op->type == EJS_TYPE_OBJECT); - return 0; - } - pp = 0; - - do { - obj = op->objectState; - - head = &obj->link; - lp = head->next; - - while (lp != head) { - pp = ejsGetPropertyFromLink(lp); - if (! pp->dontEnumerate || (flags & EJS_ENUM_HIDDEN)) { - break; - } - lp = lp->next; - } - if (lp != head || op->type != EJS_TYPE_OBJECT || - !(flags & EJS_ENUM_CLASSES)) { - break; - } - - op = obj->baseClass; - - } while (lp == 0 && op); - - return pp; -} - -/******************************************************************************/ -/* - * Get the next property in sequence. This will only enumerate properties in - * this class and not in base classes. - */ - -EjsProperty *ejsGetNextProperty(EjsProperty *last, int flags) -{ - EjsProperty *pp; - EjsObj *obj; - EjsPropLink *lp, *head; - - obj = last->parentObj; - - lp = last->link.next; - head = &obj->link; - pp = 0; - - while (obj) { - while (lp != head) { - pp = ejsGetPropertyFromLink(lp); - if (! pp->dontEnumerate || (flags & EJS_ENUM_HIDDEN)) { - break; - } - lp = lp->next; - } - if (lp != head || !(flags & EJS_ENUM_CLASSES)) { - break; - } - - /* - * Now iterate over properties in base classes (down the chain) - */ - if (obj->baseClass == 0) { - break; - } - - obj = obj->baseClass->objectState; - if (obj == 0) { - break; - } - } - return pp; -} - -/******************************************************************************/ -/* - * Find a variable given a variable name and return the parent object and - * the variable itself. This routine supports literal variable and property - * names that may be objects or arrays but may NOT have expressions. - * Returns -1 on errors or if the variable is not found. - * FUTURE -- Needs OPT - */ - -EjsVar *ejsFindProperty(Ejs *ep, EjsVar **obj, char **property, EjsVar *global, - EjsVar *local, const char *fullName, int create) -{ - EjsProperty *currentProp; - EjsVar *currentObj; - /* MOB -- WARNING BIG */ - char tokBuf[EJS_MAX_ID], propertyName[EJS_MAX_ID]; - char *token, *next, *cp, *endp; - - mprAssert(fullName && *fullName); - - currentProp = 0; - currentObj = 0; - - if (global == 0) { - global = ep->global; - } - - if (obj) { - *obj = 0; - } - if (property) { - *property = 0; - } - - if (fullName == 0) { - return 0; - } - - next = (char*) fullName; - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - mprStrcpy(propertyName, sizeof(propertyName), token); - - if (local) { - currentProp = ejsGetProperty(ep, local, token); - currentObj = local; - } - if (currentProp == 0) { - currentProp = ejsGetProperty(ep, global, token); - currentObj = global; - } - - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - - while (currentObj != 0 && token != 0 && *token) { - - if (currentProp == 0) { - return 0; - } - currentObj = ¤tProp->var; - currentProp = 0; - - if (*token == '[') { - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - - mprStrcpy(propertyName, sizeof(propertyName), token); - cp = propertyName; - if (*cp == '\"') { - cp++; - if ((endp = strchr(cp, '\"')) != 0) { - *endp = '\0'; - } - } else if (*cp == '\'') { - cp++; - if ((endp = strchr(cp, '\'')) != 0) { - *endp = '\0'; - } - } - - currentProp = ejsGetProperty(ep, currentObj, propertyName); - - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - if (*token != ']') { - return 0; - } - - } else if (*token == '.') { - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - if (!isalpha((int) token[0]) && - token[0] != '_' && token[0] != '$') { - return 0; - } - - mprStrcpy(propertyName, sizeof(propertyName), token); - currentProp = ejsGetProperty(ep, currentObj, token); - - } else { - currentProp = ejsGetProperty(ep, currentObj, token); - } - - if (next == 0 || *next == '\0') { - break; - } - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - } - - if (obj) { - *obj = currentObj; - } - - - if (currentProp == 0 && currentObj >= 0 && create) { - currentProp = ejsCreateSimpleProperty(ep, currentObj, propertyName); - } - - if (property) { - *property = currentProp->name; - } - return ejsGetVarPtr(currentProp); -} - -/******************************************************************************/ -/* - * Get the next token as part of a variable specification. This will return - * a pointer to the next token and will return a pointer to the next token - * (after this one) in "next". The tokBuf holds the parsed token. - */ - -static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen) -{ - char *start, *cp; - int len; - - start = *next; - while (isspace((int) *start) || *start == '\n' || *start == '\r') { - start++; - } - cp = start; - - if (*cp == '.' || *cp == '[' || *cp == ']') { - cp++; - } else { - while (*cp && *cp != '.' && *cp != '[' && *cp != ']' && - !isspace((int) *cp) && *cp != '\n' && *cp != '\r') { - cp++; - } - } - len = mprMemcpy(tokBuf, tokBufLen - 1, start, cp - start); - tokBuf[len] = '\0'; - - *next = cp; - return tokBuf; -} - -/******************************************************************************/ - -EjsVar *ejsGetGlobalClass(Ejs *ep) -{ - return ep->global; -} - -/******************************************************************************/ -/*************************** Property Access Methods **************************/ -/******************************************************************************/ -/* - * Create an undefined property. This routine calls the object method hooks. - */ - -/* MOB -- better suffix than "Method" */ -EjsVar *ejsCreatePropertyMethod(Ejs *ep, EjsVar *op, const char *property) -{ - EjsVar *vp; - - mprAssert(ep); - mprAssert(op); - mprAssert(property && *property); - - if (op == 0) { - return 0; - } - - mprAssert(op->type == EJS_TYPE_OBJECT); - mprAssert(op->objectState); - - if (op->objectState == 0) { - return 0; - } - - if (op->objectState->methods == 0) { - vp = ejsGetVarPtr(ejsCreateSimpleProperty(ep, op, property)); - } else { - vp = (op->objectState->methods->createProperty)(ep, op, property); - } - - if (vp == 0) { - mprAssert(vp); - op->objectState->hasErrors = 1; - return 0; - } - - /* - * FUTURE - find a better way. - */ - if (op->isArray) { - ejsSetArrayLength(ep, op, property, 0, 0); - } - return vp; -} - -/******************************************************************************/ - -int ejsDeletePropertyMethod(Ejs *ep, EjsVar *op, const char *property) -{ - int rc; - - mprAssert(ep); - mprAssert(op); - mprAssert(property && *property); - - if (op == 0) { - return -1; - } - - mprAssert(op->type == EJS_TYPE_OBJECT); - mprAssert(op->objectState); - - if (op->objectState == 0) { - return -1; - } - - if (op->objectState->methods == 0) { - rc = ejsDeleteProperty(ep, op, property); - } else { - rc = (op->objectState->methods->deleteProperty)(ep, op, property); - } - - if (rc < 0) { - op->objectState->hasErrors = 1; - } - - op->objectState->dirty = 1; - - return rc; -} - -/******************************************************************************/ -/* - * Set the value of a property. Create if it does not exist - * If the object has property accessor methods defined, use those. - */ - -EjsVar *ejsSetPropertyMethod(Ejs *ep, EjsVar *op, const char *property, - const EjsVar *value) -{ - EjsVar *vp; - - mprAssert(ep); - mprAssert(op); - mprAssert(property && *property); - mprAssert(value); - - if (op == 0) { - return 0; - } - - mprAssert(op->type == EJS_TYPE_OBJECT); - mprAssert(op->objectState); - - if (op->objectState == 0) { - return 0; - } - - if (op->objectState->methods == 0) { - vp = ejsGetVarPtr(ejsCreateSimpleProperty(ep, op, property)); - if (vp && ejsWriteVar(ep, vp, (EjsVar*) value, EJS_SHALLOW_COPY) < 0) { - mprAssert(0); - op->objectState->hasErrors = 1; - return 0; - } - - } else { - vp = (op->objectState->methods->setProperty)(ep, op, property, value); - } - - if (vp == 0) { - mprAssert(vp); - op->objectState->hasErrors = 1; - return 0; - } - - if (vp->type == EJS_TYPE_OBJECT) { - /* - * We make an object alive (and subject to garbage collection) when - * it is referenced in some other object. If this is undesirable, the - * caller should make the object permanent while calling this routine - * and then afterward clear the alive bit by calling ejsMakeObjLive(). - */ - if (op->objectState != vp->objectState) { - vp->objectState->alive = 1; - } -#if BLD_DEBUG - { - EjsProperty *pp = ejsGetPropertyPtr(vp); - ejsSetVarName(ep, vp, &pp->name[0]); - if (value->propertyName == 0) { - ejsSetVarName(ep, (EjsVar*) value, &pp->name[0]); - } - } -#endif - } - - /* - * Trap assignments to array.length. MOB - find a better way. - */ - if (vp->isArrayLength) { - ejsSetArrayLength(ep, op, 0, 0, value); - } - - op->objectState->dirty = 1; - - return vp; -} - -/******************************************************************************/ - -EjsVar *ejsGetPropertyMethod(Ejs *ep, EjsVar *op, const char *property) -{ - mprAssert(ep); - mprAssert(op); - mprAssert(property && *property); - - if (op == 0) { - return 0; - } - - mprAssert(op->type == EJS_TYPE_OBJECT); - mprAssert(op->objectState); - - if (op->objectState == 0) { - return 0; - } - - if (op->objectState->methods == 0) { - return ejsGetVarPtr(ejsGetSimpleProperty(ep, op, property)); - } else { - return (op->objectState->methods->getProperty)(ep, op, property); - } -} - -/******************************************************************************/ -/*************************** Advisory Locking Support *************************/ -/******************************************************************************/ -#if BLD_FEATURE_MULTITHREAD - -void ejsLockObj(EjsVar *vp) -{ - mprAssert(vp); - mprAssert(vp->type == EJS_TYPE_OBJECT); - mprAssert(vp->objectState); - - if (vp->objectState->mutex == 0) { - vp->objectState->mutex = mprCreateLock(vp->objectState->ejs); - } - mprLock(vp->objectState->mutex); -} - -/******************************************************************************/ - -void ejsUnlockObj(EjsVar *vp) -{ - mprAssert(vp); - mprAssert(vp->type == EJS_TYPE_OBJECT); - mprAssert(vp->objectState); - - if (vp->objectState->mutex) { - mprUnlock(vp->objectState->mutex); - } -} - -#endif -/******************************************************************************/ -/************************** Internal Support Routines *************************/ -/******************************************************************************/ -/* - * Create an object. - */ - -static EjsObj *createObj(EJS_LOC_DEC(ep, loc)) -{ - EjsObj *op; - EjsPropLink *lp; - - op = (EjsObj*) ejsAllocObj(EJS_LOC_PASS(ep, loc)); - if (op == NULL) { - return 0; - } - - /* - * The objectState holds the dummy head for the ordered list of properties - */ - lp = &op->link; - lp->next = lp->prev = lp; - -#if BLD_DEBUG - /* - * This makes it much easier to debug the list - */ - lp->head = lp; - lp->propertyName = "dummyHead"; -#endif - - return op; -} - -/******************************************************************************/ -/* - * Destroy an object. Called by the garbage collector if there are no more - * references to an object. - */ - -int ejsDestroyObj(Ejs *ep, EjsObj *obj) -{ - EjsProperty *pp; - EjsPropLink *lp, *head, *nextLink; - - mprAssert(obj); - - if (obj->destructor) { - EjsVar v; - memset(&v, 0, sizeof(v)); - v.type = EJS_TYPE_OBJECT; - v.objectState = obj; - ejsSetVarName(ep, &v, "destructor"); - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - v.gc.allocatedBy = "static"; -#endif - - if ((obj->destructor)(ep, &v) < 0) { - return -1; - } - } - mprFree(obj->objName); - obj->objName = 0; - - /* - * Just for safety. An object may be marked by a GC on the default - * interpreter. After destroying, it won't be on the free list and so - * won't be reset. - */ - obj->gcMarked = 0; - obj->visited = 0; - - head = &obj->link; - for (lp = head->next; lp != head; lp = nextLink) { - - pp = ejsGetPropertyFromLink(lp); - nextLink = lp->next; - - /* - * We don't unlink as we are destroying all properties. - * If an object, we don't need to clear either. - */ - if (pp->var.type != EJS_TYPE_OBJECT) { - ejsClearVar(ep, ejsGetVarPtr(pp)); - } - ejsFree(ep, pp, EJS_SLAB_PROPERTY); - } - -#if BLD_FEATURE_MULTITHREAD - if (obj->mutex) { - mprDestroyLock(obj->mutex); - } -#endif - - ejsFree(ep, obj, EJS_SLAB_OBJ); - return 0; -} - -/******************************************************************************/ -/* - * Fast hash. The history of this algorithm is part of lost computer science - * folk lore. - */ - -static int hash(const char *property) -{ - uint sum; - - mprAssert(property); - - sum = 0; - while (*property) { - sum += (sum * 33) + *property++; - } - - return sum % EJS_OBJ_HASH_SIZE; -} - -/******************************************************************************/ -/* - * Set a new length for an array. If create is non-null, then it is the name - * of a new array index. If delete is set, it is the name of an index being - * deleted. If setLength is set to a variable, it counts the new length for the - * array. Note that create and delete are ignored if they are non-integer - * array indexes (eg. normal properties). - */ - -void ejsSetArrayLength(Ejs *ep, EjsVar *obj, const char *create, - const char *delete, const EjsVar *setLength) -{ - EjsVar *vp; - char idx[16]; - int oldSize, newSize, i; - - vp = ejsGetPropertyAsVar(ep, obj, "length"); - oldSize = vp->integer; - newSize = oldSize; - - if (create) { - if (isdigit(*create)) { - i = atoi(create); - newSize = max(i + 1, oldSize); - } - } else if (delete) { - if (isdigit(*delete)) { - i = atoi(delete); - newSize = (i == (oldSize - 1) ? oldSize - 1 : oldSize); - } - } else { - newSize = setLength->integer; - } - - for (i = newSize; i < oldSize; i++) { - mprItoa(idx, sizeof(idx), i); - ejsDeleteProperty(ep, obj, idx); - } - - if (ejsWriteVarAsInteger(ep, vp, newSize) == 0) { - mprAssert(0); - } -} - -/******************************************************************************/ - -void ejsClearObjErrors(EjsVar *vp) -{ - if (vp == 0 || vp->type != EJS_TYPE_OBJECT || vp->objectState == 0) { - mprAssert(0); - return; - } - vp->objectState->hasErrors = 0; -} - -/******************************************************************************/ - -int ejsObjHasErrors(EjsVar *vp) -{ - if (vp == 0 || vp->type != EJS_TYPE_OBJECT || vp->objectState == 0) { - mprAssert(0); - return -1; - } - return vp->objectState->hasErrors; -} - -/******************************************************************************/ - -bool ejsIsObjDirty(EjsVar *vp) -{ - mprAssert(vp->type == EJS_TYPE_OBJECT && vp->objectState); - - if (vp->type == EJS_TYPE_OBJECT && vp->objectState) { - return vp->objectState->dirty; - } - return 0; -} - -/******************************************************************************/ - -void ejsResetObjDirtyBit(EjsVar *vp) -{ - mprAssert(vp->type == EJS_TYPE_OBJECT && vp->objectState); - - if (vp->type == EJS_TYPE_OBJECT && vp->objectState) { - vp->objectState->dirty = 0; - } -} - -/******************************************************************************/ -/* - * Copy a string. Always null terminate. - */ - -static int dupString(MPR_LOC_DEC(ctx, loc), uchar **dest, const void *src, - int nbytes) -{ - mprAssert(dest); - mprAssert(src); - - if (nbytes > 0) { - *dest = mprMemdupInternal(MPR_LOC_PASS(ctx, loc), src, nbytes + 1); - if (*dest == 0) { - return MPR_ERR_MEMORY; - } - - } else { - *dest = (uchar*) mprAlloc(ctx, 1); - nbytes = 0; - } - - (*dest)[nbytes] = '\0'; - - return nbytes; -} - -/******************************************************************************/ - -const char *ejsGetVarTypeAsString(EjsVar *vp) -{ - switch (vp->type) { - default: - case EJS_TYPE_UNDEFINED: - return "undefined"; - case EJS_TYPE_NULL: - return "null"; - case EJS_TYPE_BOOL: - return "bool"; - case EJS_TYPE_CMETHOD: - return "cmethod"; - case EJS_TYPE_FLOAT: - return "float"; - case EJS_TYPE_INT: - return "int"; - case EJS_TYPE_INT64: - return "int64"; - case EJS_TYPE_OBJECT: - return "object"; - case EJS_TYPE_METHOD: - return "method"; - case EJS_TYPE_STRING: - return "string"; - case EJS_TYPE_STRING_CMETHOD: - return "string method"; - case EJS_TYPE_PTR: - return "ptr"; - } -} - -/******************************************************************************/ - -void *ejsGetVarUserPtr(EjsVar *vp) -{ - mprAssert(vp); - mprAssert(vp->type == EJS_TYPE_PTR); - - if (!ejsVarIsPtr(vp)) { - return 0; - } - return vp->ptr.userPtr; -} - -/******************************************************************************/ - -void ejsSetVarUserPtr(EjsVar *vp, void *data) -{ - mprAssert(vp); - mprAssert(vp->type == EJS_TYPE_PTR); - - vp->ptr.userPtr = data; -} - -/******************************************************************************/ -/* - * Return TRUE if target is a subclass (or the same class) as baseClass. - */ - -bool ejsIsSubClass(EjsVar *target, EjsVar *baseClass) -{ - do { - if (target->objectState == baseClass->objectState) { - return 1; - } - target = target->objectState->baseClass; - } while (target); - - return 0; -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.h b/source4/lib/appweb/ejs-2.0/ejs/ejsVar.h deleted file mode 100644 index 071665e00b..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/ejsVar.h +++ /dev/null @@ -1,1091 +0,0 @@ -/* - * ejsVar.h -- EJS Universal Variable Type - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/* - * Variables can efficiently store primitive types and can hold references to - * objects. Objects can store properties which are themselves variables. - * Properties can be primitive data types, other objects or methods. - * Properties are indexed by a character name. A variable may store one of - * the following types: - * - * string, integer, integer-64bit, C method, C method with string args, - * Javascript method, Floating point number, boolean value, Undefined - * value and the Null value. - * - * Variables have names while objects may be referenced by multiple variables. - * Objects use reference counting for garbage collection. - * - * This module is not thread safe for performance and compactness. It relies - * on upper modules to provide thread synchronization as required. The API - * provides primitives to get variable/object references or to get copies of - * variables which will help minimize required lock times. - */ - -#ifndef _h_EJS_VAR -#define _h_EJS_VAR 1 - -/********************************* Includes ***********************************/ - -#include "mpr.h" - -/********************************** Defines ***********************************/ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Defined in ejs.h - */ -typedef struct Ejs Ejs; - -/* - * Constants - */ -#if BLD_FEATURE_SQUEEZE - /** - * Maximum property or variable name size - */ - #define EJS_MAX_ID 64 - - /* - * EJS_VAR_HASH_SIZE must be less than the size of the bit field - * propertyIndex in EjsProperty. - */ - #define EJS_OBJ_HASH_SIZE 13 - - /** - * Maximum number of arguments per function call - */ - #define EJS_MAX_ARGS 32 - #define EJS_INC_ARGS 8 /* Frame stack increment */ - -#else - #define EJS_MAX_ID 256 - #define EJS_OBJ_HASH_SIZE 29 - #define EJS_MAX_ARGS 64 - #define EJS_INC_ARGS 8 -#endif - -#define EJS_VAR_MAX_RECURSE 5 /* Max object loops */ - -#if !DOXYGEN -/* - * Forward declare types - */ -struct Ejs; -struct EjsObj; -struct EjsProperty; -struct EjsVar; -#endif - -/** - * @overview EJ primitive variable type - * @description EJ primitive variable values are stored in EjsVar structures. - * The type of the primitive data is described by an EjsType field. - * EjsVar variable types. - * @stability Prototype. - * @library libejs. - * @see EJS_TYPE_UNDEFINED, EJS_TYPE_NULL, EJS_TYPE_BOOL, EJS_TYPE_CMETHOD, - * EJS_TYPE_FLOAT, EJS_TYPE_INT, EJS_TYPE_INT64, EJS_TYPE_OBJECT, - * EJS_TYPE_METHOD, EJS_TYPE_STRING, EJS_TYPE_STRING_CMETHOD, EJS_TYPE_PTR, - */ -typedef uint EjsType; -#define EJS_TYPE_UNDEFINED 0 /**< Undefined. No value has been set */ -#define EJS_TYPE_NULL 1 /**< Value defined to be null. */ -#define EJS_TYPE_BOOL 2 /**< Boolean type. */ -#define EJS_TYPE_CMETHOD 3 /**< C method */ -#define EJS_TYPE_FLOAT 4 /**< Floating point number */ -#define EJS_TYPE_INT 5 /**< Integer number */ -#define EJS_TYPE_INT64 6 /**< 64-bit Integer number */ -#define EJS_TYPE_OBJECT 7 /**< Object reference */ -#define EJS_TYPE_METHOD 8 /**< JavaScript method */ -#define EJS_TYPE_STRING 9 /**< String (immutable) */ -#define EJS_TYPE_STRING_CMETHOD 10 /**< C method with string args */ -#define EJS_TYPE_PTR 11 /**< Opaque pointer */ - -/* - * Create a type for the default number type - * Config.h will define the default number type. For example: - * - * BLD_FEATURE_NUM_TYPE=int - * BLD_FEATURE_NUM_TYPE_ID=EJS_TYPE_INT - */ - -/** - * Set to the type used for EJS numeric variables. Will equate to int, int64 - * or double. - */ -typedef BLD_FEATURE_NUM_TYPE EjsNum; - -/** - * Set to the EJS_TYPE used for EJS numeric variables. Will equate to - * EJS_TYPE_INT, EJS_TYPE_INT64 or EJS_TYPE_FLOAT. - */ -#define EJS_NUM_VAR BLD_FEATURE_NUM_TYPE_ID -#define EJS_TYPE_NUM BLD_FEATURE_NUM_TYPE_ID - -/* - * Return TRUE if a variable is a method type - */ -#define ejsVarIsMethod(vp) \ - ((vp)->type == EJS_TYPE_METHOD || (vp)->type == EJS_TYPE_STRING_CMETHOD || \ - (vp)->type == EJS_TYPE_CMETHOD) - -/* - * Return TRUE if a variable is a numeric type - */ -#define ejsVarIsNumber(vp) \ - ((vp)->type == EJS_TYPE_INT || (vp)->type == EJS_TYPE_INT64 || \ - (vp)->type == EJS_TYPE_FLOAT) - -/* - * Return TRUE if a variable is a boolean - */ -#define ejsVarIsBoolean(vp) \ - ((vp)->type == EJS_TYPE_BOOL) - -/* - * Return TRUE if a variable is an integer type - */ -#define ejsVarIsInteger(vp) ((vp)->type == EJS_TYPE_INT) - -/* - * Return TRUE if a variable is a string - */ -#define ejsVarIsString(vp) \ - ((vp)->type == EJS_TYPE_STRING) - -/* - * Return TRUE if a variable is an object - */ -#define ejsVarIsObject(vp) \ - ((vp)->type == EJS_TYPE_OBJECT) - -/* - * Return TRUE if a variable is a floating number - */ -#define ejsVarIsFloating(vp) \ - ((vp)->type == EJS_TYPE_FLOAT) - -/* - * Return TRUE if a variable is undefined - */ -#define ejsVarIsUndefined(var) \ - ((var)->type == EJS_TYPE_UNDEFINED) - -/* - * Return TRUE if a variable is null - */ -#define ejsVarIsNull(var) \ - ((var)->type == EJS_TYPE_NULL) - -/* - * Return TRUE if a variable is a valid type (not null or undefined) - */ -#define ejsVarIsValid(var) \ - (((var)->type != EJS_TYPE_NULL) && ((var)->type != EJS_TYPE_UNDEFINED)) - -/* - * Return TRUE if a variable is a ptr type - */ -#define ejsVarIsPtr(vp) \ - ((vp)->type == EJS_TYPE_PTR) - -/* MOB -- convert all ep to ejs */ -/** - * @overview C Method signature - * @description This is the calling signature for C Methods. - * @param ejs Ejs reference returned from ejsCreateInterp - * @param thisObj Reference to the "this" object. (The object containing the - * method). - * @param argc Number of arguments. - * @param argv Array of arguments. Each argument is held in an EjsVar type. - * @stability Prototype. - * @library libejs. - * @see ejsCreateCMethodVar - */ -typedef int (*EjsCMethod)(struct Ejs *ejs, struct EjsVar *thisObj, - int argc, struct EjsVar **argv); - -/** - * C Method with string arguments signature - * @overview C Method with string arguments signature - * @description This is the calling signature for C Methods. - * @param ejs Ejs reference returned from ejsCreateInterp - * @param thisObj Reference to the "this" object (object containing the - * method. - * @param argc Number of arguments. - * @param argv Array of arguments. Each argument is held in an C string - * pointer. - * @stability Prototype. - * @library libejs. - * @see ejsCreateStringCMethodVar - */ -typedef int (*EjsStringCMethod)(struct Ejs *ep, struct EjsVar *thisObj, - int argc, char **argv); - -/** - * Flags for types: EJS_TYPE_CMETHOD, EJS_TYPE_STRING_CMETHOD - * NOTE: flags == 0 means to use the EJS handle on method callbacks - */ -/* Use the primary handle on method callbacks */ -#define EJS_PRIMARY_HANDLE 0x1 - -/* Use the alternate handle on method callbacks */ -#define EJS_ALT_HANDLE 0x2 - -/** Method should not create a new local variable block */ -#define EJS_NO_LOCAL 0x4 - -/* Method is a get accessor */ -#define EJS_GET_ACCESSOR 0x8 - -/* Method is a set accessor */ -#define EJS_SET_ACCESSOR 0x10 - -/* - * Flags for E4X (Xml type) - */ -/* Node is a text node */ -#define EJS_XML_FLAGS_TEXT 0x1 - -/* Node is a processing instruction */ -#define EJS_XML_FLAGS_PI 0x2 - -/* Node is a comment */ -#define EJS_XML_FLAGS_COMMENT 0x4 - -/* Node is an attribute */ -#define EJS_XML_FLAGS_ATTRIBUTE 0x8 - -/* Node is an element */ -#define EJS_XML_FLAGS_ELEMENT 0x10 - -/** - * Copy depth - * @overview Specifies how an object should be copied - * @description The EjsCopyDepth type specifies how an object's properties - * should be copied. Several routines take EjsCopyDepth parameters to - * control how the properties of an object should be copied. It provides - * three copy options: - * @see ejsWriteVar - */ -typedef enum EjsCopyDepth { - /** - * During an object copy, object property references will be copied so - * that the original object and the copy will share the same reference to - * a property object. Properties containing primitive types including - * strings will have their values copied and will not share references. - */ - EJS_SHALLOW_COPY, /** Copy strings. Copy object references. */ - /* - * During an object copy, object properties will be replicated so that - * the original object and the copy will not share references to the same - * object properties. If the original object's properties are themselves - * objects, their properties will not be copied. Only their references - * will be copied. i.e. the deep copy is one level deep. - */ - EJS_DEEP_COPY, /** Copy strings and copy object contents. */ - /* - * During an object copy, all object properties will be replicated so that - * the original object and the copy will not share references to the same - * object properties. If the original object's properties are themselves - * objects, their properties will be copied. i.e. the copy is of infinite - * depth. - */ - EJS_RECURSIVE_DEEP_COPY /** Copy strings and copy object contents - recursively (complete copy). */ -} EjsCopyDepth; - - -/* - * Enumeration flags - */ -/** Enumerate data properties */ -#define EJS_ENUM_DATA 0x0 - -/** Enumerate sub classes */ -#define EJS_ENUM_CLASSES 0x1 - -/** Enumerate non-enumerable properties */ -#define EJS_ENUM_HIDDEN 0x2 - -/** Enumerate all properties */ -#define EJS_ENUM_ALL (0x3) - -/** Magic number when allocated */ -#define EJS_MAGIC 0xe801e2ec -#define EJS_MAGIC_FREE 0xe701e3ea - - -/* - * Garbage Collection Linkage. Free list only uses the next pointers. - */ -typedef struct EjsGCLink { -#if BLD_DEBUG - uint magic; /* Magic number */ -#endif -#if BLD_FEATURE_ALLOC_LEAK_TRACK - const char *allocatedBy; /* Who allocated this */ -#endif - struct EjsGCLink *next; /* Next property */ -} EjsGCLink; - - -/** - * @overview EJS Variable Type - * @description The EJ language supports an extensive set of primitive types. - * These variable types can efficiently store primitive data types such as - * integers, strings, binary string, booleans, floating point numbers, - * pointer references, and objects. EjsVars are the universal type used by - * EJ to hold objects, classes and properties. - * \n\n - * An EjsVar may store one of the following types: - * @li Boolean - * @li Floating point (if supported in this build) - * @li Integer - * @li 64 bit integer (if supported in this build) - * @li String - * @li Binary string - * @li C function or C++ method - * @li C function with string args - * @li Javascript method - * @li Object - * @li Null value. - * @li Undefined value - * \n\n - * Objects can hold object properties which are themselves EJS variables. - * Properties are hash indexed by the property name and are stored in - * an ordered sequence. i.e. Order of properties is maintained. Objects may - * be referenced by multiple variables and they use garbage collection to - * reclaim memory no longer in use by objects and properties. - * - * @warning This module is @e not thread safe for performance and - * compactness. It relies on upper modules to provide thread - * synchronization as required. The API provides primitives to get - * variable/object references or to get copies of variables which should - * help minimize required lock times. - * @stability Prototype. - * @library libejs - * @see Ejs, EjsProperty, ejsCreateStringVar, ejsFreeVar - */ - -typedef struct EjsVar { /* Size 12 bytes */ - /* - * GC must be first - */ -#if BLD_DEBUG || BLD_FEATURE_ALLOC_LEAK_TRACK - EjsGCLink gc; /* Garbage collection links */ -#endif - -#if BLD_DEBUG - const char *propertyName; /* Ptr to property name */ -#endif - - /* - * Union of primitive types. When debugging on Linux, don't use unions - * as the gdb debugger can't display them. - */ -#if (!BLD_DEBUG && !VXWORKS) || WIN || BREW_SIMULATOR - union { -#endif - /* - * For debugging, we order the common types first - */ - struct EjsObj *objectState; /* Object state information */ - int integer; - bool boolean; - -#if BLD_FEATURE_FLOATING_POINT - double floating; -#endif -#if BLD_FEATURE_INT64 - int64 integer64; -#endif - - struct { - int length; /* String length (sans null) */ - /* - * All strings always have a trailing null allocated - */ - union { - char *string; /* String */ - uchar *ustring; /* Binary string */ - }; - }; - - struct { /* Javascript methods */ - MprArray *args; /* Null terminated */ - char *body; - } method; - - struct { /* Method with EjsVar args */ - EjsCMethod fn; /* Method pointer */ - void *userData; /* User data for method */ - } cMethod; - - struct { /* Method with string args */ - EjsStringCMethod fn; /* Method pointer */ - void *userData; /* User data for method */ - } cMethodWithStrings; - - struct { - void *userPtr; /* Opaque pointer */ - int (*destructor)(Ejs *ejs, struct EjsVar *vp); - } ptr; - -#if (!BLD_DEBUG && !VXWORKS) || WIN || BREW_SIMULATOR - }; -#endif - - /* - * Packed bit field (32 bits) - */ - uint flags : 8; /* Type specific flags */ - EjsType type : 4; /* Selector into union */ - uint stringLen : 4; /* Length of string if inline */ - uint allocatedData : 1; /* Node needs freeing */ - uint isArray : 1; /* Var is an array */ - uint isArrayLength : 1; /* Var is array.length */ - uint callsSuper : 1; /* Method calls super() */ - uint isProperty : 1; /* Part of a property */ - uint reserved : 11; /* Unused */ - -} EjsVar; - - -/* - * Linkage for the ordered list of properties - */ -typedef struct EjsPropLink { - struct EjsPropLink *next; /* Next property */ - struct EjsPropLink *prev; /* Previous property */ - - /* - * To make debugging easier - */ -#if BLD_DEBUG - const char *propertyName; /* Pointer to name */ - struct EjsProperty *property; /* Pointer to property */ - struct EjsPropLink *head; /* Dummy head of list */ -#endif -} EjsPropLink; - - -/** - * @overview Object Property Type - * @description The EjsProperty type is used to store all object properties. - * It contains the property name, property linkage, propery attributes - * such as public/private, enumerable and readonly settings. It also - * contains an EjsVar to store the property data value. - * @stability Prototype. - * @library libejs - * @see Ejs, EjsVar - */ -typedef struct EjsProperty { /* Size 96 bytes in squeeze */ - /* - * EjsVar must be first. We often take the address of "var" and take - * advantage of if an EjsProperty is null, then &prop->var will be null - * also. Be WARNED. External users should use ejsGetVarPtr and - * ejsGetPropertyPtr to convert between the two. - */ - EjsVar var; /* Property value */ - - /* OPT change this to a pointer to the base class property */ - char name[EJS_MAX_ID]; /* Name */ - - uint visited : 1; /* Has been traversed */ - uint isPrivate : 1; /* Property is private */ - uint isProtected : 1; /* Property is protected */ - uint dontEnumerate : 1; /* Not enumerable */ - uint dontDelete : 1; /* Prevent delete */ - uint readonly : 1; /* Unmodifiable */ - uint allowNonUnique : 1; /* Multiple of same name ok */ - uint delayedDelete : 1; - uint reserved : 24; - - EjsPropLink link; /* Ordered linked list */ - struct EjsProperty *hashNext; /* Hash table linkage */ - - /* MOB -- is this really required */ - struct EjsObj *parentObj; /* Pointer to parent object */ - -} EjsProperty; - - -#define EJS_OP_DOT 0x1 -#define EJS_OP_INDEX 0x2 -#define EJS_OP_PLUS 0x3 -#define EJS_OP_MINUS 0x4 -#define EJS_OP_MULTIPLY 0x5 -#define EJS_OP_DIVIDE 0x6 -#define EJS_OP_CALL 0x7 - -typedef struct EjsOp { - int opType; - -} EjsOp; - -/* - * Propety Access Methods. Used per class. - * MOB -- rename EjsHelpers - */ -typedef struct EjsMethods { -#if FUTURE - int (*create)(Ejs *ep, EjsVar *thisObj); - int (*deleteProperty)(Ejs *ep, EjsVar *thisObj, const char *prop); - EjsVar *(*getProperty)(Ejs *ep, EjsVar *thisObj, const char *prop); - EjsVar *(*setProperty)(Ejs *ep, EjsVar *thisObj, const char *prop); - int (*hasProperty)(Ejs *ep, EjsVar *thisObj, const char *prop); - int (*hasInstance)(Ejs *ep, EjsVar *thisObj, const char *prop); - int (*operate)(Ejs *ep, EjsVar *thisObj, EjsOp op, EjsVar *result, - EjsVar *lhs, EjsVar *rhs, int *code); -#else - - EjsVar *(*createProperty)(Ejs *ep, EjsVar *obj, const char *property); - int (*deleteProperty)(Ejs *ep, EjsVar *obj, const char *property); - EjsVar *(*getProperty)(Ejs *ep, EjsVar *obj, const char *property); - EjsVar *(*setProperty)(Ejs *ep, EjsVar *obj, const char *property, - const EjsVar *value); - /* - * Other implemented internal properties in ECMA-262 are: - * - * [[Construct]] implemented via EjsVar methods - * [[Prototype]] implemented via EjsObj->baseClass - * [[Class]] implemented via EjsObj->baseClass->name - * [[Value]] Implemented via EjsProperty + EjsVar + EjsObj - */ - - /* - * FUTURE -- not implemented - */ - int (*canPut)(Ejs *ep, EjsVar *obj, const char *property); - int (*defaultValue)(Ejs *ep, EjsVar *obj, const char *property, - const char *hint); - int (*hasProperty)(Ejs *ep, EjsVar *obj, const char *property); - EjsVar *(*call)(Ejs *ep, EjsVar *obj, const char *property, - EjsVar *args); - int (*hasInstance)(Ejs *ep, EjsVar *obj, const char *property); - int (*scope)(Ejs *ep, EjsVar *obj, const char *property); - int (*match)(Ejs *ep, EjsVar *obj, const char *property, - const char *string, int index); -#endif -} EjsMethods; - - -/* - * Ejs Object Type - */ -typedef struct EjsObj { - /* - * GC must be first - */ - EjsGCLink gc; /* Garbage collection links */ - - union { - char *objName; /* Object name */ - char *className; /* Class name */ - }; - - struct EjsVar *baseClass; /* Pointer to base class object */ - - EjsPropLink link; /* Ordered list of properties */ - - /* OPT -- dynamically allocate this only if required */ - EjsProperty *propertyHash[EJS_OBJ_HASH_SIZE]; /* Hash chains */ - - /* OPT -- could save this and store off baseClass only */ - EjsMethods *methods; /* Property access methods */ - void *nativeData; /* Native object data */ - - int (*destructor)(Ejs *ejs, struct EjsVar *vp); - - uint numProperties : 16; /* Total count of items */ - uint visited : 1; /* Has been traversed */ - uint gcMarked : 1; /* Node marked in-use by GC */ - uint permanent : 1; /* Permanent object, dont GC */ - uint alive : 1; /* Only GC if alive */ - uint noConstructor : 1; /* Object has no constructor */ - uint dirty : 1; /* Object has been modified */ - uint hasErrors : 1; /* Update error */ - uint preventDeleteProp : 1; /* Don't allow prop deletion */ - uint delayedDeleteProp : 1; /* Delayed delete of props */ - uint reserved : 7; /* Unused */ - - Ejs *ejs; /* Owning interp */ - -#if BLD_FEATURE_MULTITHREAD - MprLock *mutex; /* Advisory mutex lock */ -#endif -} EjsObj; - - -/* - * Define a field macro so code an use numbers in a "generic" fashion. - */ -#if EJS_NUM_VAR == EJS_TYPE_INT || DOXYGEN -/* - * Default numeric type - */ -#define ejsNumber integer -#endif -#if EJS_NUM_VAR == EJS_TYPE_INT64 -/* Default numeric type */ -#define ejsNumber integer64 -#endif -#if EJS_NUM_VAR == EJS_TYPE_FLOAT -/* Default numeric type */ -#define ejsNumber floating -#endif - -typedef BLD_FEATURE_NUM_TYPE EjsNumber; - -/* - * Memory allocation slabs - */ -#define EJS_SLAB_OBJ 0 -#define EJS_SLAB_PROPERTY 1 -#define EJS_SLAB_VAR 2 -#define EJS_SLAB_MAX 3 - -/** - * Object and pointer property destructory type - */ -typedef int (*EjsDestructor)(Ejs *ejs, EjsVar *vp); - -#if BLD_FEATURE_ALLOC_LEAK_TRACK || DOXYGEN -/* - * Line number information args and declarations for ejsAlloc. - * Use EJS_LOC_ARGS in normal user code. - * Use EJS_LOC_DEC in declarations. - * Use EJS_LOC_PASS in layered APIs to pass original line info down. - */ -#define EJS_LOC_ARGS(ejs) ejs, MPR_LOC -#define EJS_LOC_DEC(ejs, loc) Ejs *ejs, const char *loc -#define EJS_LOC_PASS(ejs, loc) ejs, loc -#else -#define EJS_LOC_ARGS(ejs) ejs -#define EJS_LOC_DEC(ejs, loc) Ejs *ejs -#define EJS_LOC_PASS(ejs, loc) ejs -#endif - -/******************************* Internal Prototypes **************************/ - -#define ejsInitVar(vp, varType) \ - if (1) { \ - (vp)->type = varType; \ - (vp)->isArray = 0; \ - (vp)->flags = 0; \ - } else -extern void ejsClearVar(Ejs *ep, EjsVar *vp); - -extern int ejsDestroyObj(Ejs *ep, EjsObj *obj); -extern EjsVar *ejsCreatePropertyMethod(Ejs *ep, EjsVar *obj, - const char *name); -extern EjsVar *ejsSetPropertyMethod(Ejs *ep, EjsVar *obj, const char *name, - const EjsVar *value); -extern EjsVar *ejsGetPropertyMethod(Ejs *ep, EjsVar *obj, const char *name); -extern int ejsDeletePropertyMethod(Ejs *ep, EjsVar *obj, - const char *name); -extern void ejsSetArrayLength(Ejs *ep, EjsVar *obj, const char *creating, - const char *deleting, const EjsVar *setLength); - -/* - * At the moment, these are the same routine - */ -extern void ejsSetClassName(Ejs *ep, EjsVar *obj, const char *name); -#define ejsSetObjName ejsSetObjName - -extern bool ejsIsObjDirty(EjsVar *vp); -extern void ejsResetObjDirtyBit(EjsVar *vp); - -extern int ejsObjHasErrors(EjsVar *vp); -extern void ejsClearObjErrors(EjsVar *vp); - -extern EjsVar *ejsClearProperty(Ejs *ep, EjsVar *obj, const char *prop); - -typedef int (*EjsSortFn)(Ejs *ep, EjsProperty *p1, EjsProperty *p2, - const char *propertyName, int order); -extern void ejsSortProperties(Ejs *ep, EjsVar *obj, EjsSortFn fn, - const char *propertyName, int order); - -#if BLD_DEBUG -#define ejsSetVarName(ep, vp, varName) \ - if (1) { \ - (vp)->propertyName = varName; \ - if ((vp)->type == EJS_TYPE_OBJECT && \ - (vp)->objectState && \ - ((vp)->objectState->objName == 0)) { \ - (vp)->objectState->objName = \ - mprStrdup(ep, varName); \ - } \ - } else -#else -#define ejsSetVarName(ep, vp, varName) -#endif - -EjsVar *ejsFindProperty(Ejs *ep, EjsVar **obj, char **property, - EjsVar *global, EjsVar *local, const char *fullName, - int create); - -extern EjsVar *ejsCopyProperties(Ejs *ep, EjsVar *dest, - const EjsVar *src, EjsCopyDepth copyDepth); - -#define EJS_LINK_OFFSET ((uint) (&((EjsProperty*) 0)->link)) -#define ejsGetPropertyFromLink(lp) \ - ((EjsProperty*) ((char*) lp - EJS_LINK_OFFSET)) - -#define ejsGetObjPtr(vp) ((EjsObj*) vp->objectState) - -extern void ejsMakePropertyPrivate(EjsProperty *pp, int isPrivate); -extern void ejsMakePropertyReadOnly(EjsProperty *pp, int readonly); -extern void ejsMakePropertyUndeleteable(EjsProperty *pp, int deletable); -extern int ejsMakeObjLive(EjsVar *vp, bool alive); -extern void ejsMakeClassNoConstructor(EjsVar *vp); - -extern bool ejsBlockInUseInt(EjsVar *vp); -#if BLD_DEBUG - #define ejsBlockInUse(vp) ejsBlockInUseInt(vp) -#else - #define ejsBlockInUse(vp) -#endif - -/********************************* Prototypes *********************************/ - -/* - * Variable constructors and destructors - */ -extern EjsVar *ejsCreateBinaryStringVar(Ejs *ep, const uchar *value, - int len); -extern EjsVar *ejsCreateBoolVar(Ejs *ep, int value); -extern EjsVar *ejsCreateCMethodVar(Ejs *ep, EjsCMethod fn, - void *userData, int flags); -#if BLD_FEATURE_FLOATING_POINT -extern EjsVar *ejsCreateFloatVar(Ejs *ep, double value); -#endif -extern EjsVar *ejsCreateIntegerVar(Ejs *ep, int value); -#if BLD_FEATURE_INT64 -extern EjsVar *ejsCreateInteger64Var(Ejs *ep, int64 value); -#endif - -extern EjsVar *ejsCreateMethodVar(Ejs *ep, const char *body, - MprArray *args, int flags); -extern EjsVar *ejsCreateNullVar(Ejs *ep); -extern EjsVar *ejsCreateNumberVar(Ejs *ep, EjsNumber value); - -#define ejsCreateObjVar(ep) \ - ejsCreateObjVarInternal(EJS_LOC_ARGS(ep)) -extern EjsVar *ejsCreateObjVarInternal(EJS_LOC_DEC(ep, loc)); - -extern EjsVar *ejsCreatePtrVar(Ejs *ep, void *ptr, EjsDestructor dest); - -extern EjsVar *ejsCreateStringCMethodVar(Ejs *ep, EjsStringCMethod fn, - void *userData, int flags); - -#define ejsCreateStringVar(ep, value) \ - ejsCreateStringVarInternal(EJS_LOC_ARGS(ep), value) -extern EjsVar *ejsCreateStringVarInternal(EJS_LOC_DEC(ep, loc), - const char *value); - -extern EjsVar *ejsCreateUndefinedVar(Ejs *ep); - -/* MOB -- naming. Should be Create/Destroy */ -extern void ejsFreeVar(Ejs *ep, EjsVar *vp); - -/* - * Var support routines - */ -extern int ejsGetVarFlags(EjsVar *vp); -extern void ejsSetVarFlags(EjsVar *obj, int flags); - -extern EjsType ejsGetVarType(EjsVar *vp); -extern const char *ejsGetVarTypeAsString(EjsVar *vp); - -extern void *ejsGetCMethodUserData(EjsVar *obj); -extern void ejsSetCMethodUserData(EjsVar *obj, void *userData); - -extern void *ejsGetVarUserPtr(EjsVar *vp); -extern void ejsSetVarUserPtr(EjsVar *vp, void *data); - - -/* - * Variable access and manipulation. These work on standalone objects. - */ -#define ejsDupVar(ep, src, copyDepth) \ - ejsDupVarInternal(EJS_LOC_ARGS(ep), src, copyDepth) -extern EjsVar *ejsDupVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *src, - EjsCopyDepth copyDepth); -#define ejsWriteVar(ep, dest, src, copyDepth) \ - ejsWriteVarInternal(EJS_LOC_ARGS(ep), dest, src, copyDepth) -extern EjsVar *ejsWriteVarInternal(EJS_LOC_DEC(ep, loc), EjsVar *dest, - const EjsVar *src, EjsCopyDepth copyDepth); -extern EjsVar *ejsWriteVarAsBinaryString(Ejs *ep, EjsVar *dest, - const uchar *value, int len); -extern EjsVar *ejsWriteVarAsBoolean(Ejs *ep, EjsVar *dest, bool value); -extern EjsVar *ejsWriteVarAsCMethod(Ejs *ep, EjsVar *dest, EjsCMethod fn, - void *userData, int flags); -#if BLD_FEATURE_FLOATING_POINT -extern EjsVar *ejsWriteVarAsFloat(Ejs *ep, EjsVar *dest, double value); -#endif -extern EjsVar *ejsWriteVarAsInteger(Ejs *ep, EjsVar *dest, int value); -#if BLD_FEATURE_INT64 -extern EjsVar *ejsWriteVarAsInteger64(Ejs *ep, EjsVar *dest, int64 value); -#endif -extern EjsVar *ejsWriteVarAsMethod(Ejs *ep, EjsVar *dest, - const char *body, MprArray *args); -extern EjsVar *ejsWriteVarAsNull(Ejs *ep, EjsVar *dest); -extern EjsVar *ejsWriteVarAsNumber(Ejs *ep, EjsVar *dest, EjsNum value); -#define ejsWriteVarAsString(ep, dest, value) \ - ejsWriteVarAsStringInternal(EJS_LOC_ARGS(ep), dest, value) -extern EjsVar *ejsWriteVarAsStringInternal(EJS_LOC_DEC(ep, loc), - EjsVar *dest, const char *value); -extern EjsVar *ejsWriteVarAsStringCMethod(Ejs *ep, EjsVar *dest, - EjsStringCMethod fn, void *userData, int flags); -extern EjsVar *ejsWriteVarAsUndefined(Ejs *ep, EjsVar *dest); - -/* - * These routines do not convert types - */ -/* MOB -- make this a fn and pass back the length as an arg */ -#define ejsReadVarAsBinaryString(vp) ((const uchar*) (vp->ustring)); -#define ejsReadVarAsBoolean(vp) (vp->boolean); -#define ejsReadVarAsCMethod(vp) (vp->cMethod); -#if BLD_FEATURE_FLOATING_POINT -#define ejsReadVarAsFloat(vp) (vp->floating); -#endif -#define ejsReadVarAsInteger(vp) (vp->integer); -#if BLD_FEATURE_INT64 -#define ejsReadVarAsInteger64(vp) (vp->int64); -#endif -#define ejsReadVarAsString(vp) ((const char*) (vp->string)); -#define ejsReadVarAsStringCMethod(vp) (vp->cMethodWithStrings); -/* MOB -- remove this fn */ -#define ejsReadVarStringLength(vp) (vp->length); - -/* - * Object property creation routines - */ -extern EjsProperty *ejsCreateProperty(Ejs *ep, EjsVar *obj, const char *prop); -extern EjsProperty *ejsCreateSimpleProperty(Ejs *ep, EjsVar *obj, - const char *prop); -extern EjsProperty *ejsCreateSimpleNonUniqueProperty(Ejs *ep, EjsVar *obj, - const char *prop); -/* MOB -- should be destroy */ -extern int ejsDeleteProperty(Ejs *ep, EjsVar *obj, const char *prop); - - -/* - * Get property routines - */ -extern EjsProperty *ejsGetProperty(Ejs *ep, EjsVar *obj, const char *prop); -extern EjsProperty *ejsGetSimpleProperty(Ejs *ep, EjsVar *obj, - const char *prop); - -extern EjsVar *ejsGetPropertyAsVar(Ejs *ep, EjsVar *obj, - const char *prop); -extern int ejsGetPropertyCount(EjsVar *obj); - -extern const uchar *ejsGetPropertyAsBinaryString(Ejs *ep, EjsVar *obj, - const char *prop, int *length); -extern bool ejsGetPropertyAsBoolean(Ejs *ep, EjsVar *obj, - const char *prop); -extern int ejsGetPropertyAsInteger(Ejs *ep, EjsVar *obj, - const char *prop); -extern int64 ejsGetPropertyAsInteger64(Ejs *ep, EjsVar *obj, - const char *prop); -extern EjsNum ejsGetPropertyAsNumber(Ejs *ep, EjsVar *obj, - const char *prop); -extern void *ejsGetPropertyAsPtr(Ejs *ep, EjsVar *obj, - const char *prop); -extern const char *ejsGetPropertyAsString(Ejs *ep, EjsVar *obj, - const char *prop); - -/* - * Object property update routines - */ -extern EjsProperty *ejsSetBaseProperty(Ejs *ep, EjsVar *obj, const char *prop, - const EjsVar *value); -extern EjsProperty *ejsSetProperty(Ejs *ep, EjsVar *obj, const char *prop, - const EjsVar *value); -extern EjsProperty *ejsSetPropertyAndFree(Ejs *ep, EjsVar *obj, - const char *prop, EjsVar *value); -extern EjsProperty *ejsSetPropertyToBinaryString(Ejs *ep, EjsVar *obj, - const char *prop, const uchar *value, int len); -extern EjsProperty *ejsSetPropertyToBoolean(Ejs *ep, EjsVar *obj, - const char *prop, bool value); -extern EjsProperty *ejsSetPropertyToCMethod(Ejs *ep, EjsVar *obj, - const char *prop, EjsCMethod fn, void *userData, - int flags); -#if BLD_FEATURE_FLOATING_POINT -extern EjsProperty *ejsSetPropertyToFloat(Ejs *ep, EjsVar *obj, - const char *prop, double value); -#endif -extern EjsProperty *ejsSetPropertyToInteger(Ejs *ep, EjsVar *obj, - const char *prop, int value); -#if BLD_FEATURE_INT64 -extern EjsProperty *ejsSetPropertyToInteger64(Ejs *ep, EjsVar *obj, - const char *prop, int64 value); -#endif -extern EjsProperty *ejsSetPropertyToMethod(Ejs *ep, EjsVar *obj, - const char *prop, const char *body, MprArray *args, - int flags); -extern EjsProperty *ejsSetPropertyToNewObj(Ejs *ep, EjsVar *obj, - const char *prop, const char *className, - MprArray *args); -extern EjsProperty *ejsSetPropertyToNull(Ejs *ep, EjsVar *obj, - const char *prop); -extern EjsProperty *ejsSetPropertyToNumber(Ejs *ep, EjsVar *obj, - const char *prop, EjsNum value); -extern EjsProperty *ejsSetPropertyToObj(Ejs *ep, EjsVar *obj, - const char *prop); -extern EjsProperty *ejsSetPropertyToPtr(Ejs *ep, EjsVar *obj, - const char *prop, void *ptr, EjsDestructor destructor); - -extern EjsProperty *ejsSetPropertyToStringCMethod(Ejs *ep, EjsVar *obj, - const char *prop, EjsStringCMethod fn, - void *userData, int flags); -extern EjsProperty *ejsSetPropertyToString(Ejs *ep, EjsVar *obj, - const char *prop, const char *value); -extern EjsProperty *ejsSetPropertyToUndefined(Ejs *ep, EjsVar *obj, - const char *prop); - - -/* Convenience function */ -extern EjsVar *ejsSetPropertyToObjAsVar(Ejs *ep, EjsVar *obj, - const char *prop); -extern void ejsSetObjDestructor(Ejs *ep, EjsVar *obj, - EjsDestructor destructor); -extern void ejsClearObjDestructor(Ejs *ep, EjsVar *obj); - -/* - * Enumeration of properties - * MOB -- should these take an ejs parameter to be consistent - */ -extern EjsProperty *ejsGetFirstProperty(const EjsVar *obj, int flags); -extern EjsProperty *ejsGetNextProperty(EjsProperty *last, int flags); - -/* - * Method definition and control. - */ -extern EjsProperty *ejsDefineMethod(Ejs *ep, EjsVar *obj, const char *prop, - const char *body, MprArray *args); -extern EjsProperty *ejsDefineCMethod(Ejs *ep, EjsVar *obj, const char *prop, - EjsCMethod fn, int flags); - -extern EjsProperty *ejsDefineStringCMethod(Ejs *ep, EjsVar *obj, - const char *prop, EjsStringCMethod fn, int flags); - -extern EjsProperty *ejsDefineAccessors(Ejs *ep, EjsVar *obj, - const char *prop, const char *getBody, - const char *setBody); -extern EjsProperty *ejsDefineCAccessors(Ejs *ep, EjsVar *obj, - const char *prop, EjsCMethod getFn, EjsCMethod setFn, - int flags); - -/* - * Macro to get the variable value portion of a property - */ -#define ejsGetVarPtr(pp) (&((pp)->var)) -#define ejsGetPropertyPtr(vp) ((EjsProperty*) vp) - -/* MOB -- take ejs to be consistent */ -extern int ejsMakePropertyEnumerable(EjsProperty *pp, bool enumerable); -extern int ejsMakeObjPermanent(EjsVar *vp, bool permanent); - - -/* - * Var conversion routines - * MOB -- should these take an Ejs as first arg for consistency - */ -extern bool ejsVarToBoolean(EjsVar *vp); -#if BLD_FEATURE_FLOATING_POINT -extern double ejsVarToFloat(EjsVar *vp); -#endif -extern int ejsVarToInteger(EjsVar *vp); -#if BLD_FEATURE_INT64 -extern int64 ejsVarToInteger64(EjsVar *vp); -#endif -extern EjsNum ejsVarToNumber(EjsVar *vp); -extern char *ejsVarToString(Ejs *ep, EjsVar *vp); -extern char *ejsVarToStringEx(Ejs *ep, EjsVar *vp, bool *alloc); -extern char *ejsFormatVar(Ejs *ep, const char *fmt, EjsVar *vp); - -#if BLD_FEATURE_FLOATING_POINT -extern double ejsParseFloat(const char *str); -#endif -/* - * Parsing and type range checking routines - */ -extern bool ejsParseBoolean(const char *str); -extern int ejsParseInteger(const char *str); -#if BLD_FEATURE_INT64 -extern int64 ejsParseInteger64(const char *str); -#endif -extern EjsNum ejsParseNumber(const char *str); -extern EjsVar *ejsParseVar(Ejs *ep, const char *str, EjsType prefType); - -#if BLD_FEATURE_FLOATING_POINT -extern bool ejsIsInfinite(double f); -extern bool ejsIsNan(double f); -#endif - -/* - * Advisory locking support - */ -#if BLD_FEATURE_MULTITHREAD -extern void ejsLockObj(EjsVar *vp); -extern void ejsUnlockObj(EjsVar *vp); -#endif - -/* - * Just for debugging - */ -extern bool ejsObjIsCollectable(EjsVar *vp); - -#ifdef __cplusplus -} -#endif - -/*****************************************************************************/ -#endif /* _h_EJS_VAR */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/event.js b/source4/lib/appweb/ejs-2.0/ejs/lib/event.js deleted file mode 100644 index 283a3ec72f..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/lib/event.js +++ /dev/null @@ -1,141 +0,0 @@ -/* - * @file event.js - * @brief Event class - * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - * - * Usage: - * listener = new System.Listener(); - * listener.onClick = function() { - * // Any code here - * } - * eventTarget.addListener(eventName, listener); - * or - * listener = new System.Listener(obj, method); - * eventTarget.addListener(eventName, listener); - * - * To fire events: - * eventTarget.fire(eventName, new System.Event("My Event")); - */ - -/******************************************************************************/ -/* - * Base event class - */ -class System.Event -{ - var type; // keyboard - var timeStamp; - var arg; - - /* MOB -- constructor should take a type */ - function Event(arg) - { - timeStamp = time(); - type = "default"; - this.arg = arg; - } -} - -/* MOB -- should not be needed */ -Event = System.Event; - -class System.Listener -{ - var obj; - var method; - - function Listener(obj, method) - { - if (arguments.length >= 1) { - this.obj = obj; - } else { - this.obj = this; - } - if (arguments.length == 2) { - this.method = method; - } else { - this.method = "onEvent"; - } - } -} -/* MOB -- should not be needed */ -Listener = System.Listener; - - -/* - * The Event target class - */ -class System.EventTarget -{ - // Private - var events; /* Hash of a event names */ - - function EventTarget() - { - events = new Object(); - } - - // Public - function addListener(eventName, listener) - { - var listeners = events[eventName]; - if (listeners == undefined) { - listeners = events[eventName] = new Array(); - } - if (arguments.length == 2) { - var method = eventName; - } - /* MOB OPT */ - for (var i = 0; i < listeners.length; i++) { - var l = listeners[i]; - if (l == listener) { - return; - } - } - listeners[listeners.length] = listener; - } - - function removeListener(eventName, listener) - { - var listeners = events[eventName]; - - if (listeners == undefined) { - return; - } - - for (var i = 0; i < listeners.length; i++) { - var l = listeners[i]; - if (l == listener) { - // MOB -- want listeners.splice here - // listeners.splice(i, 1); - for (var j = i; j < (listeners.length - 1); j++) { - listeners[j] = listeners[j + 1]; - } - delete listeners[listeners.length - 1]; - i = listeners.length; - } - } - } - - function fire(eventName, event) - { - var listeners = events[eventName]; - - if (listeners == undefined) { - // println("Event.fire(): unknown eventName " + eventName); - return; - } - - for (var i = listeners.length - 1; i >= 0; i--) { - var listener = listeners[i]; - var method = listener.obj[listener.method]; - if (method == undefined) { - throw new EvalError("Undefined method: " + listener.method); - } - listener.obj[listener.method](listener, event); - } - } -} - -/* MOB -- should not be needed */ -EventTarget = System.EventTarget; diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/global.js b/source4/lib/appweb/ejs-2.0/ejs/lib/global.js deleted file mode 100644 index f2daaa57c0..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/lib/global.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * @file global.js - * @brief Misc global functions - * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ - -/******************************************************************************/ - -function min(a, b) -{ - if (a < b) { - return a; - } else { - return b; - } -} - - -function max(a, b) -{ - if (a > b) { - return a; - } else { - return b; - } -} - -function abs(a) -{ - if (a < 0) { - return -a; - } - return a; -} diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/startup.js b/source4/lib/appweb/ejs-2.0/ejs/lib/startup.js deleted file mode 100644 index e627a96e04..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/lib/startup.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * @file startup.js - * @brief Embedded JavaScript Startup Code - * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - * - * Invoked automatically on startup. - */ - -/******************************************************************************/ - -// println("Loading startup.js ..."); - -include("lib/event.js"); -include("lib/global.js"); -include("lib/timer.js"); diff --git a/source4/lib/appweb/ejs-2.0/ejs/lib/timer.js b/source4/lib/appweb/ejs-2.0/ejs/lib/timer.js deleted file mode 100644 index f4cb8b12ce..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/lib/timer.js +++ /dev/null @@ -1,158 +0,0 @@ -/* - * @file timer.js - * @brief Timer class - * @copy Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - * - * Usage: - * timer = new System.Timer("name", period); - * timer.onTick = function(arg) { - * // Anything here - * } - * timer.start(); - * or - * - * timer = new System.Timer("name", period, obj, method); - * timer.start(); - */ - -/******************************************************************************/ - -class System.Timer -{ - var id; - - /* MOB -- really need accessor on period. If user updates period, - then due must be updated. */ - var period; - var due; - var runOnce; // Run timer just once - var method; // Callback method - var obj; // Callback object - - function Timer(id, period, obj, method) - { - this.id = id; - this.period = period; - due = time() + period; - - if (arguments.length >= 3) { - this.obj = obj; - } else { - this.obj = this; - } - if (arguments.length >= 4) { - this.method = method; - } else { - this.method = "onTick"; - } - } - - /* MOB this should be deprecated */ - function reschedule(period) - { - /* MOB -- should update the timer service somehow */ - this.period = period; - } - - function run(now) - { - if (obj[method] == undefined) { - trace("Timer cant find timer method " + method); - due = now + this.period; - return; - } - - /* - * Run the timer - */ - try { - obj[method](this); - } - catch (error) { - trace("Timer exception: " + error); - } - - if (runOnce) { - timerService.removeTimer(this); - - } else { - due = now + this.period; - } - } - - function start() - { - if (obj[method] == undefined) { - throw new Error("Callback method is undefined"); - } else { - timerService.addTimer(this); - } - } - - function stop() - { - timerService.removeTimer(this); - } - -} - -/* MOB -- should not need this */ -Timer = System.Timer; - - -/* - * Timer service - */ -class System.TimerService -{ - var timers; - var nextDue; - - function TimerService() - { - timers = new Object(); - nextDue = 0; - global.timerService = this; - } - - function addTimer(timer) - { - timers[timer.id] = timer; - } - - function removeTimer(timer) - { - try { - delete timers[timer.id]; - } - catch {} - } - - function getIdleTime() - { - return nextDue - time(); - } - - function runTimers() - { - var now = time(); - - nextDue = 2147483647; /* MOB -- MATH.MAX_INT; */ - - for each (var timer in timers) - { - if (timer.due < now) { - timer.run(now); - } - } - for each (var timer in timers) - { - if (timer.due < nextDue) { - nextDue = timer.due; - } - } - // println("runTimers leaving with " + (nextDue - now)); - return nextDue - time(); - } -} -TimerService = System.TimerService; diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/.ignore b/source4/lib/appweb/ejs-2.0/ejs/system/.ignore deleted file mode 100755 index fb5a29031e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/.ignore +++ /dev/null @@ -1 +0,0 @@ -.updated diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/Makefile b/source4/lib/appweb/ejs-2.0/ejs/system/Makefile deleted file mode 100755 index 2d83662655..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Makefile to build the EJS Object Model -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I.. -I../../mpr -I../../exml - -include make.dep - -ifeq ($(BLD_HOST_UNIX),1) -PRE_DIRS = UNIX -else -PRE_DIRS = $(BLD_HOST_OS) -endif - -compileExtra: .updated - -.updated: $(FILES) - @touch .updated - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/README.TXT b/source4/lib/appweb/ejs-2.0/ejs/system/README.TXT deleted file mode 100644 index a24e0e299c..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/README.TXT +++ /dev/null @@ -1,63 +0,0 @@ -Embedded JavaScript System Model - - -- Need args, arg types and exceptions thrown -- Error classes - -class Global - class System - class environment - var - class GC - void function run() - function tune() - function getUsedMemory() // Should be properties - function getAllocatedMemory() // Should be properties - - var javascript - var null - var undefined - var true - var false - var Nan - var Infinity - - function random // Not implemented - function sleep // Not implemented - function exit - function yield // Not implemented - - Debug - isDebugMode - - Limits - isLimitsMode // Not implemented - stack // Not implemented - heap // Not implemented - flash // Not implemented - - Memory - getUsedMemory() // Should be properties - getAvailableMemory() // Should be properties - used - flash // Not implemented - - assert() - breakpoint() - dirname() - basename() - eval() - exit() - print() - println() - printVars() - sleep() - sort() - time() - typeof() - include() - trace() - printf() // Not implemented - sprintf() - - diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore deleted file mode 100644 index fb5a29031e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/.ignore +++ /dev/null @@ -1 +0,0 @@ -.updated diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile deleted file mode 100755 index 424747052a..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# -# Makefile to build the EJS Object Model for WIN -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I../.. -I../../../mpr - -include make.dep - -compileExtra: .updated - -.updated: $(FILES) - @touch .updated - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c deleted file mode 100644 index 772303152e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFile.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * @file ejsFile.c - * @brief File class for the EJ System Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/******************************************************************************/ -/* - * Default Constructor - */ - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function open(); - */ - -static int openProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.open()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function close(); - */ - -static int closeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.close()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function read(); - */ - -static int readProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.read()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function write(); - */ - -static int writeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.write()\n"); - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineFileClass(Ejs *ep) -{ - EjsVar *fileClass; - - fileClass = ejsDefineClass(ep, "File", "Object", 0); - if (fileClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the methods - */ - ejsDefineCMethod(ep, fileClass, "open", openProc, 0); - ejsDefineCMethod(ep, fileClass, "close", closeProc, 0); - ejsDefineCMethod(ep, fileClass, "read", readProc, 0); - ejsDefineCMethod(ep, fileClass, "write", writeProc, 0); - - return ejsObjHasErrors(fileClass) ? MPR_ERR_CANT_INITIALIZE: 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c deleted file mode 100755 index 7b39c16e4d..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsFileSystem.c +++ /dev/null @@ -1,454 +0,0 @@ -/* - * @file ejsFileSystem.c - * @brief FileSystem class for the EJ System Object Model - * MOB -- this is almost the same as for Windows. Should common up. - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" -#include - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function void access(string path); - * MOB - API insufficient. Access for read or write? - */ - -static int accessProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: access(path)"); - return -1; - } - - rc = access(argv[0]->string, 04); - - ejsSetReturnValueToBoolean(ejs, (rc == 0) ? 1 : 0); - return 0; -} - -/******************************************************************************/ -/* - * function void mkdir(string path); - */ - -static int mkdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)"); - return -1; - } - - if (mprMakeDirPath(ejs, argv[0]->string) < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant create directory"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void rmdir(string path); - */ - -static int rmdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)"); - return -1; - } - - rc = mprDeleteDir(ejs, argv[0]->string); - - if (rc < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant remove directory"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void dirList(string path, [bool enumDirs]); - * MOB -- need pattern to match (what about "." and ".." and ".*" - */ - -static int dirListProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - DIR *dir; - struct dirent *dirent; - char path[MPR_MAX_FNAME]; - EjsVar *array, *vp; - uchar enumDirs; - - if (argc < 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: dirList(path)"); - return -1; - } - if (argc == 2) { - enumDirs = ejsVarToBoolean(argv[1]); - } else { - enumDirs = 0; - } - array = ejsCreateArray(ejs, 0); - ejsMakeObjPermanent(array, 1); - - /* - * First collect the files - */ - mprSprintf(path, sizeof(path), "%s/*.*", argv[0]->string); - - dir = opendir(path); - if (dir == 0) { - ejsError(ejs, EJS_ARG_ERROR, "Can't enumerate dirList(path)"); - return -1; - } - - while ((dirent = readdir(dir)) != 0) { - if (dirent->d_name[0] == '.') { - continue; - } - if (!enumDirs || (dirent->d_type & DT_DIR)) { - mprSprintf(path, sizeof(path), "%s/%s", argv[0]->string, - dirent->d_name); - vp = ejsCreateStringVar(ejs, path); - ejsAddArrayElt(ejs, array, vp, EJS_SHALLOW_COPY); - ejsFreeVar(ejs, vp); - } - } - - closedir(dir); - - ejsSetReturnValue(ejs, array); - ejsMakeObjPermanent(array, 0); - - /* - * Can free now as the return value holds the reference - */ - ejsFreeVar(ejs, array); - - return 0; -} - -/******************************************************************************/ -/* - * function void getFreeSpace(); - */ - -static int getFreeSpaceProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ -#if UNUSED - MprApp *app; - uint space; - - app = mprGetApp(ejs); - space = IFILEMGR_GetFreeSpace(app->fileMgr, 0); - ejsSetReturnValueToInteger(ejs, space); -#endif - - return 0; -} - -/******************************************************************************/ -/* - * function void writeFile(string path, var data); - */ - -static int writeFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprFile *file; - char *data, *buf; - int bytes, length, rc; - - if (argc != 2 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: writeFile(path, var)"); - return -1; - } - - if (ejsVarIsString(argv[1])) { - data = argv[1]->string; - length = argv[1]->length; - buf = 0; - } else { - buf = data = ejsVarToString(ejs, argv[1]); - length = strlen(data); - } - - /* - * Create fails if already present - */ - rc = mprDelete(ejs, argv[0]->string); - file = mprOpen(ejs, argv[0]->string, O_CREAT | O_WRONLY | O_BINARY, 0664); - if (file == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[0]->string); - mprFree(buf); - return -1; - } - - rc = 0; - bytes = mprWrite(file, data, length); - if (bytes != length) { - ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string); - rc = -1; - } - - mprClose(file); - - mprFree(buf); - return rc; -} - -/******************************************************************************/ -/* - * function string readFile(string path); - */ - -static int readFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprApp *app; - MprFile *file; - MprBuf *buf; - char *data; - int bytes, rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: readFile(path)"); - return -1; - } - buf = mprCreateBuf(ejs, MPR_BUF_INCR, MPR_MAX_BUF); - if (buf == 0) { - ejsMemoryError(ejs); - return -1; - } - - data = mprAlloc(ejs, MPR_BUFSIZE); - if (buf == 0) { - mprFree(buf); - ejsMemoryError(ejs); - return -1; - } - - app = mprGetApp(ejs); - file = mprOpen(ejs, argv[0]->string, O_RDONLY, 0664); - if (file == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string); - mprFree(buf); - return -1; - } - - rc = 0; - while ((bytes = mprRead(file, data, MPR_BUFSIZE)) > 0) { - if (mprPutBlockToBuf(buf, data, bytes) != bytes) { - ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string); - rc = -1; - break; - } - } - - ejsSetReturnValueToBinaryString(ejs, (uchar*) mprGetBufStart(buf), - mprGetBufLength(buf)); - - mprClose(file); - mprFree(data); - mprFree(buf); - - return rc; -} - -/******************************************************************************/ -/* - * function void remove(string path); - */ - -static int removeProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: remove(path)"); - return -1; - } - - rc = unlink(argv[0]->string); - if (rc < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant remove file"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void rename(string from, string to); - */ - -static int renameProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: rename(old, new)"); - return -1; - } - - unlink(argv[1]->string); - rc = rename(argv[0]->string, argv[1]->string); - if (rc < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant rename file"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void copy(string old, string new); - */ - -static int copyProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprFile *from, *to; - char *buf; - uint bytes; - int rc; - - if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: copy(old, new)"); - return -1; - } - - buf = mprAlloc(ejs, MPR_BUFSIZE); - if (buf == 0) { - ejsMemoryError(ejs); - return -1; - } - - from = mprOpen(ejs, argv[0]->string, O_RDONLY | O_BINARY, 0664); - if (from == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string); - mprFree(buf); - return -1; - } - - to = mprOpen(ejs, argv[1]->string, O_CREAT | O_BINARY, 0664); - if (to == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[1]->string); - mprClose(from); - mprFree(buf); - return -1; - } - - rc = 0; - while ((bytes = mprRead(from, buf, MPR_BUFSIZE)) > 0) { - if (mprWrite(to, buf, bytes) != bytes) { - ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string); - rc = -1; - break; - } - } - - mprClose(from); - mprClose(to); - mprFree(buf); - - return rc; -} - -/******************************************************************************/ -/* - * function FileInfo getFileInfo(string path); - * - * MOB -- should create a real class FileInfo - */ - -static int getFileInfoProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprFileInfo info; - EjsVar *fileInfo; - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: getFileInfo(path)"); - return -1; - } - - fileInfo = ejsCreateObjVar(ejs); - if (fileInfo == 0) { - ejsMemoryError(ejs); - return -1; - } - ejsMakeObjPermanent(fileInfo, 1); - - rc = mprGetFileInfo(ejs, argv[0]->string, &info); - if (rc < 0) { - ejsMakeObjPermanent(fileInfo, 0); - ejsFreeVar(ejs, fileInfo); - ejsError(ejs, EJS_IO_ERROR, "Cant get file info for %s", - argv[0]->string); - return -1; - } - - ejsSetPropertyToInteger(ejs, fileInfo, "created", info.ctime); - ejsSetPropertyToInteger(ejs, fileInfo, "length", info.size); - ejsSetPropertyToBoolean(ejs, fileInfo, "isDir", info.isDir); - - ejsSetReturnValue(ejs, fileInfo); - ejsMakeObjPermanent(fileInfo, 0); - - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineFileSystemClass(Ejs *ejs) -{ - EjsVar *fileSystemClass; - - fileSystemClass = ejsDefineClass(ejs, "FileSystem", "Object", 0); - if (fileSystemClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the methods - */ - ejsDefineCMethod(ejs, fileSystemClass, "access", accessProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "mkdir", mkdirProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "rmdir", rmdirProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "dirList", dirListProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "writeFile", writeFileProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "readFile", readFileProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "remove", removeProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "rename", renameProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "copy", copyProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "getFileInfo", getFileInfoProc, 0); - - // MOB -- should be a property with accessor - ejsDefineCMethod(ejs, fileSystemClass, "getFreeSpace", getFreeSpaceProc, 0); - - return ejsObjHasErrors(fileSystemClass) ? MPR_ERR_CANT_INITIALIZE: 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c b/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c deleted file mode 100755 index 25821f6960..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/UNIX/ejsHTTP.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - * @file ejsHTTP.c - * @brief HTTP class for the EJ System Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if UNUSED -/*********************************** Defines **********************************/ - -#define EJS_WEB_PROPERTY "-web" -#define EJS_HTTP_PROPERTY "-http" - -#define EJS_HTTP_DISPOSED 550 - -/* - * Control structure for one HTTP request structure - */ -typedef struct HTTPControl { - Ejs *ejs; - IWebResp *webResp; - AEECallback *callback; - MprBuf *buf; - EjsVar *thisObj; - char *url; - MprTime requestStarted; - uint timeout; -} HTTPControl; - -/****************************** Forward Declarations **************************/ - -static void cleanup(HTTPControl *hp); -static int createWeb(Ejs *ejs, EjsVar *thisObj); -static void brewCallback(HTTPControl *hp); -static int httpDestructor(Ejs *ejs, EjsVar *vp); -static void httpCallback(HTTPControl *hp, int responseCode); -static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv); - -/******************************************************************************/ -/* - * Constructor - */ - -int ejsHTTPConstructor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 0 && argc != 2) { - ejsError(ejs, EJS_ARG_ERROR, - "Bad usage: HTTP([obj = this, method = onComplete]);"); - return -1; - } - - if (createWeb(ejs, thisObj) < 0) { - return -1; - } - - setCallback(ejs, thisObj, argc, argv); - return 0; -} - -/******************************************************************************/ - -static int createWeb(Ejs *ejs, EjsVar *thisObj) -{ - MprApp *app; - void *web; - - app = mprGetApp(ejs); - - /* - * Create one instance of IWeb for the entire application. Do it here - * so only widgets that require HTTP incurr the overhead. - */ - web = mprGetKeyValue(ejs, "bpWeb"); - if (web == 0) { - if (ISHELL_CreateInstance(app->shell, AEECLSID_WEB, &web) != SUCCESS) { - ejsError(ejs, EJS_IO_ERROR, "Can't create IWEB"); - return -1; - } - } - mprSetKeyValue(ejs, "bpWeb", web); - return 0; -} - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function setCallback(obj, methodString); - */ - -static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc >= 1) { - ejsSetProperty(ejs, thisObj, "obj", argv[0]); - } else { - ejsSetProperty(ejs, thisObj, "obj", thisObj); - } - - if (argc >= 2) { - ejsSetProperty(ejs, thisObj, "method", argv[1]); - } else { - ejsSetPropertyToString(ejs, thisObj, "method", "onComplete"); - } - - return 0; -} - -/******************************************************************************/ -/* - * function fetch(); - */ - -static int fetchProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - HTTPControl *hp; - EjsProperty *pp; - MprApp *app; - IWeb *web; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: fetch(url)"); - return -1; - } - - app = mprGetApp(ejs); - web = (IWeb*) mprGetKeyValue(ejs, "bpWeb"); - - /* - * Web options - * - * WEBOPT_USERAGENT (char*) sets user agent - * WEBOPT_HANDLERDATA (void*) - * WEBOPT_CONNECTTIMEOUT (uint) msec - * WEBOPT_CONTENTLENGTH (long) - * WEBOPT_IDLECONNTIMEOUT (int) - * WEBOPT_ACTIVEXACTIONST (uint) Number of active requests - * - * WEBREQUEST_REDIRECT redirect transparently - * - */ - - hp = mprAllocType(ejs, HTTPControl); - if (hp == 0) { - ejsMemoryError(ejs); - return -1; - } - - hp->ejs = ejs; - hp->buf = mprCreateBuf(hp, MPR_BUF_INCR, MPR_MAX_BUF); - if (hp->buf == 0) { - mprFree(hp); - ejsMemoryError(ejs); - return -1; - } - - /* - * We copy thisObj because we need to preserve both the var and the object. - * We pass the var to brewCallback and so it must persist. The call to - * ejsMakeObjPermanent will stop the GC from collecting the object. - */ - hp->thisObj = ejsDupVar(ejs, thisObj, EJS_SHALLOW_COPY); - ejsSetVarName(ejs, hp->thisObj, "internalHttp"); - - /* - * Must keep a reference to the http object - */ - ejsMakeObjPermanent(hp->thisObj, 1); - - /* - * Make a property so we can access the HTTPControl structure from other - * methods. - */ - pp = ejsSetPropertyToPtr(ejs, thisObj, EJS_HTTP_PROPERTY, hp, 0); - ejsMakePropertyEnumerable(pp, 0); - ejsSetObjDestructor(ejs, hp->thisObj, httpDestructor); - - hp->url = mprStrdup(hp, argv[0]->string); - - hp->timeout = ejsGetPropertyAsInteger(ejs, thisObj, "timeout"); - mprGetTime(hp, &hp->requestStarted); - - hp->callback = mprAllocTypeZeroed(hp, AEECallback); - CALLBACK_Init(hp->callback, brewCallback, hp); - - hp->webResp = 0; - IWEB_GetResponse(web, - (web, &hp->webResp, hp->callback, hp->url, - WEBOPT_HANDLERDATA, hp, - WEBOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)", - WEBOPT_CONNECTTIMEOUT, hp->timeout, - WEBOPT_COPYOPTS, TRUE, - WEBOPT_CONTENTLENGTH, 0, - WEBOPT_END)); - - ejsSetPropertyToString(ejs, thisObj, "status", "active"); - - return 0; -} - -/******************************************************************************/ -/* - * Called whenver the http object is deleted. - */ - -static int httpDestructor(Ejs *ejs, EjsVar *thisObj) -{ - HTTPControl *hp; - - /* - * If the httpCallback has run, then this property will not exist - */ - hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY); - - if (hp) { - cleanup(hp); - } - - return 0; -} - -/******************************************************************************/ -/* - * Stop the request immediately without calling the callback - */ - -static int stopProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - HTTPControl *hp; - - hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY); - - if (hp) { - cleanup(hp); - } - - return 0; -} - -/******************************************************************************/ -/* - * Brew HTTP callback. Invoked for any return data. - */ - -static void brewCallback(HTTPControl *hp) -{ - Ejs *ejs; - EjsVar *thisObj; - ISource *source; - WebRespInfo *info; - char data[MPR_BUF_INCR]; - int bytes; - - mprAssert(hp); - mprAssert(hp->webResp); - - info = IWEBRESP_GetInfo(hp->webResp); - - if (info == 0) { - mprAssert(info); - /* should not happen */ - return; - } - - ejs = hp->ejs; - thisObj = hp->thisObj; - - if (! WEB_ERROR_SUCCEEDED(info->nCode)) { - ejsSetPropertyToString(ejs, thisObj, "status", "error"); - httpCallback(hp, info->nCode); - return; - } - - if (hp->timeout) { - if (mprGetTimeRemaining(hp, hp->requestStarted, hp->timeout) <= 0) { - ejsSetPropertyToString(ejs, thisObj, "status", "timeout"); - httpCallback(hp, 504); - return; - } - } - - /* - * Normal success - */ - source = info->pisMessage; - mprAssert(source); - - bytes = ISOURCE_Read(source, data, sizeof(data)); - - switch (bytes) { - case ISOURCE_WAIT: // No data yet - ISOURCE_Readable(source, hp->callback); - break; - - case ISOURCE_ERROR: - ejsSetPropertyToString(ejs, thisObj, "status", "error"); - httpCallback(hp, info->nCode); - break; - - case ISOURCE_END: - mprAddNullToBuf(hp->buf); - ejsSetPropertyToString(ejs, thisObj, "status", "complete"); - httpCallback(hp, info->nCode); - break; - - default: - if (bytes > 0) { - if (mprPutBlockToBuf(hp->buf, data, bytes) != bytes) { - ejsSetPropertyToString(ejs, thisObj, "status", "partialData"); - httpCallback(hp, 500); - } - } - ISOURCE_Readable(source, hp->callback); - break; - } -} - -/******************************************************************************/ -/* - * Invoke the HTTP completion method - */ - -static void httpCallback(HTTPControl *hp, int responseCode) -{ - Ejs *ejs; - EjsVar *thisObj, *callbackObj; - MprArray *args; - char *msg; - const char *callbackMethod; - - mprAssert(hp); - mprAssert(hp->webResp); - - thisObj = hp->thisObj; - ejs = hp->ejs; - - ejsSetPropertyToInteger(ejs, thisObj, "responseCode", responseCode); - if (mprGetBufLength(hp->buf) > 0) { - ejsSetPropertyToBinaryString(ejs, thisObj, "responseData", - mprGetBufStart(hp->buf), mprGetBufLength(hp->buf)); - } - - callbackObj = ejsGetPropertyAsVar(ejs, thisObj, "obj"); - callbackMethod = ejsGetPropertyAsString(ejs, thisObj, "method"); - - if (callbackObj != 0 && callbackMethod != 0) { - - args = mprCreateItemArray(ejs, EJS_INC_ARGS, EJS_MAX_ARGS); - mprAddItem(args, ejsDupVar(ejs, hp->thisObj, EJS_SHALLOW_COPY)); - - if (ejsRunMethod(ejs, callbackObj, callbackMethod, args) < 0) { - msg = ejsGetErrorMsg(ejs); - mprError(ejs, MPR_LOC, "HTTP callback failed. Details: %s", msg); - } - ejsFreeMethodArgs(ejs, args); - - } else if (ejsRunMethod(ejs, thisObj, "onComplete", 0) < 0) { - msg = ejsGetErrorMsg(ejs); - mprError(ejs, MPR_LOC, "HTTP onComplete failed. Details: %s", msg); - } - - cleanup(hp); -} - -/******************************************************************************/ -/* - * Cleanup - */ - -static void cleanup(HTTPControl *hp) -{ - Ejs *ejs; - MprApp *app; - int rc; - - mprAssert(hp); - mprAssert(hp->webResp); - - ejs = hp->ejs; - - if (hp->webResp) { - rc = IWEBRESP_Release(hp->webResp); - // mprAssert(rc == 0); - hp->webResp = 0; - } - - if (hp->callback) { - CALLBACK_Cancel(hp->callback); - mprFree(hp->callback); - hp->callback = 0; - } - - /* - * Once the property is deleted, then if the destructor runs, it will - * notice that the EJS_HTTP_PROPERTY is undefined. - */ - ejsDeleteProperty(ejs, hp->thisObj, EJS_HTTP_PROPERTY); - - /* - * Allow garbage collection to work on thisObj - */ - ejsMakeObjPermanent(hp->thisObj, 0); - ejsFreeVar(ejs, hp->thisObj); - - mprFree(hp->buf); - mprFree(hp->url); - - mprFree(hp); - - app = mprGetApp(ejs); - - - ISHELL_SendEvent(app->shell, (AEECLSID) app->classId, EVT_USER, 0, 0); -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineHTTPClass(Ejs *ejs) -{ - EjsVar *httpClass; - - httpClass = - ejsDefineClass(ejs, "HTTP", "Object", ejsHTTPConstructor); - if (httpClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the methods - */ - ejsDefineCMethod(ejs, httpClass, "fetch", fetchProc, 0); - ejsDefineCMethod(ejs, httpClass, "stop", stopProc, 0); - ejsDefineCMethod(ejs, httpClass, "setCallback", setCallback, 0); - -#if FUTURE - ejsDefineCMethod(ejs, httpClass, "put", put, 0); - ejsDefineCMethod(ejs, httpClass, "upload", upload, 0); - ejsDefineCMethod(ejs, httpClass, "addUploadFile", addUploadFile, 0); - ejsDefineCMethod(ejs, httpClass, "addPostData", addPostData, 0); - ejsDefineCMethod(ejs, httpClass, "setUserPassword", setUserPassword, 0); - ejsDefineCMethod(ejs, httpClass, "addCookie", addCookie, 0); -#endif - - /* - * Define properties - */ - ejsSetPropertyToString(ejs, httpClass, "status", "inactive"); - - /* This default should come from player.xml */ - - ejsSetPropertyToInteger(ejs, httpClass, "timeout", 30 * 1000); - ejsSetPropertyToInteger(ejs, httpClass, "responseCode", 0); - - return ejsObjHasErrors(httpClass) ? MPR_ERR_CANT_INITIALIZE: 0; -} - -/******************************************************************************/ - -void ejsTermHTTPClass(Ejs *ejs) -{ - IWeb *web; - int rc; - - web = (IWeb*) mprGetKeyValue(ejs, "bpWeb"); - if (web) { - rc = IWEB_Release(web); - mprAssert(rc == 0); - } -} - -#endif -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore deleted file mode 100644 index fb5a29031e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/.ignore +++ /dev/null @@ -1 +0,0 @@ -.updated diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile deleted file mode 100755 index 424747052a..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# -# Makefile to build the EJS Object Model for WIN -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I../.. -I../../../mpr - -include make.dep - -compileExtra: .updated - -.updated: $(FILES) - @touch .updated - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c deleted file mode 100644 index 24c521891e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFile.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * @file ejsFile.c - * @brief File class for the EJScript System Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/******************************************************************************/ -/* - * Default Constructor - */ - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function open(); - */ - -static int openProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.open()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function close(); - */ - -static int closeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.close()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function read(); - */ - -static int readProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.read()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function write(); - */ - -static int writeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "File.write()\n"); - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineFileClass(Ejs *ep) -{ - EjsVar *fileClass; - - fileClass = ejsDefineClass(ep, "File", "Object", 0); - if (fileClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the methods - */ - ejsDefineCMethod(ep, fileClass, "open", openProc, 0); - ejsDefineCMethod(ep, fileClass, "close", closeProc, 0); - ejsDefineCMethod(ep, fileClass, "read", readProc, 0); - ejsDefineCMethod(ep, fileClass, "write", writeProc, 0); - - return ejsObjHasErrors(fileClass) ? MPR_ERR_CANT_INITIALIZE: 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c deleted file mode 100755 index 66c3b84870..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsFileSystem.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * @file ejsFileSystem.c - * @brief FileSystem class for the EJ System Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/******************************************************************************/ -/* - * Default Constructor - */ - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function void access(string path); - * MOB - API insufficient. Access for read or write? - */ - -static int accessProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: access(path)"); - return -1; - } - - rc = access(argv[0]->string, 04); - - ejsSetReturnValueToBoolean(ejs, (rc == 0) ? 1 : 0); - return 0; -} - -/******************************************************************************/ -/* - * function void mkdir(string path); - */ - -static int mkdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)"); - return -1; - } - - if (mprMakeDirPath(ejs, argv[0]->string) < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant create directory"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void rmdir(string path); - */ - -static int rmdirProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: mkdir(path)"); - return -1; - } - - rc = mprDeleteDir(ejs, argv[0]->string); - - if (rc < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant remove directory"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void dirList(string path, [bool enumDirs]); - * MOB -- need pattern to match (what about "." and ".." and ".*" - */ - -static int dirListProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - WIN32_FIND_DATA findData; - HANDLE h; - char path[MPR_MAX_FNAME]; - EjsVar *array, *vp; - uchar enumDirs; - - if (argc < 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: dirList(path)"); - return -1; - } - if (argc == 2) { - enumDirs = ejsVarToBoolean(argv[1]); - } else { - enumDirs = 0; - } - array = ejsCreateArray(ejs, 0); - ejsMakeObjPermanent(array, 1); - - /* - * First collect the files - */ - mprSprintf(path, sizeof(path), "%s/*.*", argv[0]->string); - h = FindFirstFile(path, &findData); - if (h == INVALID_HANDLE_VALUE) { - ejsError(ejs, EJS_ARG_ERROR, "Can't enumerate dirList(path)"); - return -1; - } - - do { - if (findData.cFileName[0] == '.') { - continue; - } - if (!enumDirs || - (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - mprSprintf(path, sizeof(path), "%s/%s", argv[0]->string, - findData.cFileName); - vp = ejsCreateStringVar(ejs, path); - ejsAddArrayElt(ejs, array, vp, EJS_SHALLOW_COPY); - ejsFreeVar(ejs, vp); - } - } while (FindNextFile(h, &findData) != 0); - - FindClose(h); - - ejsSetReturnValue(ejs, array); - ejsMakeObjPermanent(array, 0); - - /* - * Can free now as the return value holds the reference - */ - ejsFreeVar(ejs, array); - - return 0; -} - -/******************************************************************************/ -/* - * function void getFreeSpace(); - */ - -static int getFreeSpaceProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ -#if UNUSED - MprApp *app; - uint space; - - app = mprGetApp(ejs); - space = IFILEMGR_GetFreeSpace(app->fileMgr, 0); - ejsSetReturnValueToInteger(ejs, space); -#endif - - return 0; -} - -/******************************************************************************/ -/* - * function void writeFile(string path, var data); - */ - -static int writeFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprFile *file; - char *data, *buf; - int bytes, length, rc; - - if (argc != 2 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: writeFile(path, var)"); - return -1; - } - - if (ejsVarIsString(argv[1])) { - data = argv[1]->string; - length = argv[1]->length; - buf = 0; - } else { - buf = data = ejsVarToString(ejs, argv[1]); - length = strlen(data); - } - - /* - * Create fails if already present - */ - rc = mprDelete(ejs, argv[0]->string); - file = mprOpen(ejs, argv[0]->string, O_CREAT | O_WRONLY | O_BINARY, 0664); - if (file == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[0]->string); - mprFree(buf); - return -1; - } - - rc = 0; - bytes = mprWrite(file, data, length); - if (bytes != length) { - ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string); - rc = -1; - } - - mprClose(file); - - mprFree(buf); - return rc; -} - -/******************************************************************************/ -/* - * function string readFile(string path); - */ - -static int readFileProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprApp *app; - MprFile *file; - MprBuf *buf; - char *data; - int bytes, rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: readFile(path)"); - return -1; - } - buf = mprCreateBuf(ejs, MPR_BUF_INCR, MPR_MAX_BUF); - if (buf == 0) { - ejsMemoryError(ejs); - return -1; - } - - data = mprAlloc(ejs, MPR_BUFSIZE); - if (buf == 0) { - mprFree(buf); - ejsMemoryError(ejs); - return -1; - } - - app = mprGetApp(ejs); - file = mprOpen(ejs, argv[0]->string, O_RDONLY, 0664); - if (file == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string); - mprFree(buf); - return -1; - } - - rc = 0; - while ((bytes = mprRead(file, data, MPR_BUFSIZE)) > 0) { - if (mprPutBlockToBuf(buf, data, bytes) != bytes) { - ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string); - rc = -1; - break; - } - } - - ejsSetReturnValueToBinaryString(ejs, mprGetBufStart(buf), - mprGetBufLength(buf)); - - mprClose(file); - mprFree(data); - mprFree(buf); - - return rc; -} - -/******************************************************************************/ -/* - * function void remove(string path); - */ - -static int removeProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: remove(path)"); - return -1; - } - - rc = unlink(argv[0]->string); - if (rc < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant remove file"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void rename(string from, string to); - */ - -static int renameProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int rc; - - if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: rename(old, new)"); - return -1; - } - - unlink(argv[1]->string); - rc = rename(argv[0]->string, argv[1]->string); - if (rc < 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant rename file"); - return -1; - } - return 0; -} - -/******************************************************************************/ -/* - * function void copy(string old, string new); - */ - -static int copyProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprFile *from, *to; - char *buf; - int bytes, rc; - - if (argc != 2 || !ejsVarIsString(argv[0]) || !ejsVarIsString(argv[1])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: copy(old, new)"); - return -1; - } - - buf = mprAlloc(ejs, MPR_BUFSIZE); - if (buf == 0) { - ejsMemoryError(ejs); - return -1; - } - - from = mprOpen(ejs, argv[0]->string, O_RDONLY | O_BINARY, 0664); - if (from == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant open %s", argv[0]->string); - mprFree(buf); - return -1; - } - - to = mprOpen(ejs, argv[1]->string, O_CREAT | O_BINARY, 0664); - if (to == 0) { - ejsError(ejs, EJS_IO_ERROR, "Cant create %s", argv[1]->string); - mprClose(from); - mprFree(buf); - return -1; - } - - rc = 0; - while ((bytes = mprRead(from, buf, MPR_BUFSIZE)) > 0) { - if (mprWrite(to, buf, bytes) != bytes) { - ejsError(ejs, EJS_IO_ERROR, "Write error to %s", argv[1]->string); - rc = -1; - break; - } - } - - mprClose(from); - mprClose(to); - mprFree(buf); - - return rc; -} - -/******************************************************************************/ -/* - * function FileInfo getFileInfo(string path); - * - * MOB -- should create a real class FileInfo - */ - -static int getFileInfoProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprFileInfo info; - EjsVar *fileInfo; - int rc; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: getFileInfo(path)"); - return -1; - } - - fileInfo = ejsCreateObjVar(ejs); - if (fileInfo == 0) { - ejsMemoryError(ejs); - return -1; - } - ejsMakeObjPermanent(fileInfo, 1); - - rc = mprGetFileInfo(ejs, argv[0]->string, &info); - if (rc < 0) { - ejsMakeObjPermanent(fileInfo, 0); - ejsFreeVar(ejs, fileInfo); - ejsError(ejs, EJS_IO_ERROR, "Cant get file info for %s", - argv[0]->string); - return -1; - } - - ejsSetPropertyToInteger(ejs, fileInfo, "created", info.ctime); - ejsSetPropertyToInteger(ejs, fileInfo, "length", info.size); - ejsSetPropertyToBoolean(ejs, fileInfo, "isDir", info.isDir); - - ejsSetReturnValue(ejs, fileInfo); - ejsMakeObjPermanent(fileInfo, 0); - - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineFileSystemClass(Ejs *ejs) -{ - EjsVar *fileSystemClass; - - fileSystemClass = ejsDefineClass(ejs, "FileSystem", "Object", 0); - if (fileSystemClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the methods - */ - ejsDefineCMethod(ejs, fileSystemClass, "access", accessProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "mkdir", mkdirProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "rmdir", rmdirProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "dirList", dirListProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "writeFile", writeFileProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "readFile", readFileProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "remove", removeProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "rename", renameProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "copy", copyProc, 0); - ejsDefineCMethod(ejs, fileSystemClass, "getFileInfo", getFileInfoProc, 0); - - // MOB -- should be a property with accessor - ejsDefineCMethod(ejs, fileSystemClass, "getFreeSpace", getFreeSpaceProc, 0); - - return ejsObjHasErrors(fileSystemClass) ? MPR_ERR_CANT_INITIALIZE: 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c b/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c deleted file mode 100755 index 25821f6960..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/WIN/ejsHTTP.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - * @file ejsHTTP.c - * @brief HTTP class for the EJ System Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if UNUSED -/*********************************** Defines **********************************/ - -#define EJS_WEB_PROPERTY "-web" -#define EJS_HTTP_PROPERTY "-http" - -#define EJS_HTTP_DISPOSED 550 - -/* - * Control structure for one HTTP request structure - */ -typedef struct HTTPControl { - Ejs *ejs; - IWebResp *webResp; - AEECallback *callback; - MprBuf *buf; - EjsVar *thisObj; - char *url; - MprTime requestStarted; - uint timeout; -} HTTPControl; - -/****************************** Forward Declarations **************************/ - -static void cleanup(HTTPControl *hp); -static int createWeb(Ejs *ejs, EjsVar *thisObj); -static void brewCallback(HTTPControl *hp); -static int httpDestructor(Ejs *ejs, EjsVar *vp); -static void httpCallback(HTTPControl *hp, int responseCode); -static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv); - -/******************************************************************************/ -/* - * Constructor - */ - -int ejsHTTPConstructor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 0 && argc != 2) { - ejsError(ejs, EJS_ARG_ERROR, - "Bad usage: HTTP([obj = this, method = onComplete]);"); - return -1; - } - - if (createWeb(ejs, thisObj) < 0) { - return -1; - } - - setCallback(ejs, thisObj, argc, argv); - return 0; -} - -/******************************************************************************/ - -static int createWeb(Ejs *ejs, EjsVar *thisObj) -{ - MprApp *app; - void *web; - - app = mprGetApp(ejs); - - /* - * Create one instance of IWeb for the entire application. Do it here - * so only widgets that require HTTP incurr the overhead. - */ - web = mprGetKeyValue(ejs, "bpWeb"); - if (web == 0) { - if (ISHELL_CreateInstance(app->shell, AEECLSID_WEB, &web) != SUCCESS) { - ejsError(ejs, EJS_IO_ERROR, "Can't create IWEB"); - return -1; - } - } - mprSetKeyValue(ejs, "bpWeb", web); - return 0; -} - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function setCallback(obj, methodString); - */ - -static int setCallback(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc >= 1) { - ejsSetProperty(ejs, thisObj, "obj", argv[0]); - } else { - ejsSetProperty(ejs, thisObj, "obj", thisObj); - } - - if (argc >= 2) { - ejsSetProperty(ejs, thisObj, "method", argv[1]); - } else { - ejsSetPropertyToString(ejs, thisObj, "method", "onComplete"); - } - - return 0; -} - -/******************************************************************************/ -/* - * function fetch(); - */ - -static int fetchProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - HTTPControl *hp; - EjsProperty *pp; - MprApp *app; - IWeb *web; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsError(ejs, EJS_ARG_ERROR, "Bad usage: fetch(url)"); - return -1; - } - - app = mprGetApp(ejs); - web = (IWeb*) mprGetKeyValue(ejs, "bpWeb"); - - /* - * Web options - * - * WEBOPT_USERAGENT (char*) sets user agent - * WEBOPT_HANDLERDATA (void*) - * WEBOPT_CONNECTTIMEOUT (uint) msec - * WEBOPT_CONTENTLENGTH (long) - * WEBOPT_IDLECONNTIMEOUT (int) - * WEBOPT_ACTIVEXACTIONST (uint) Number of active requests - * - * WEBREQUEST_REDIRECT redirect transparently - * - */ - - hp = mprAllocType(ejs, HTTPControl); - if (hp == 0) { - ejsMemoryError(ejs); - return -1; - } - - hp->ejs = ejs; - hp->buf = mprCreateBuf(hp, MPR_BUF_INCR, MPR_MAX_BUF); - if (hp->buf == 0) { - mprFree(hp); - ejsMemoryError(ejs); - return -1; - } - - /* - * We copy thisObj because we need to preserve both the var and the object. - * We pass the var to brewCallback and so it must persist. The call to - * ejsMakeObjPermanent will stop the GC from collecting the object. - */ - hp->thisObj = ejsDupVar(ejs, thisObj, EJS_SHALLOW_COPY); - ejsSetVarName(ejs, hp->thisObj, "internalHttp"); - - /* - * Must keep a reference to the http object - */ - ejsMakeObjPermanent(hp->thisObj, 1); - - /* - * Make a property so we can access the HTTPControl structure from other - * methods. - */ - pp = ejsSetPropertyToPtr(ejs, thisObj, EJS_HTTP_PROPERTY, hp, 0); - ejsMakePropertyEnumerable(pp, 0); - ejsSetObjDestructor(ejs, hp->thisObj, httpDestructor); - - hp->url = mprStrdup(hp, argv[0]->string); - - hp->timeout = ejsGetPropertyAsInteger(ejs, thisObj, "timeout"); - mprGetTime(hp, &hp->requestStarted); - - hp->callback = mprAllocTypeZeroed(hp, AEECallback); - CALLBACK_Init(hp->callback, brewCallback, hp); - - hp->webResp = 0; - IWEB_GetResponse(web, - (web, &hp->webResp, hp->callback, hp->url, - WEBOPT_HANDLERDATA, hp, - WEBOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)", - WEBOPT_CONNECTTIMEOUT, hp->timeout, - WEBOPT_COPYOPTS, TRUE, - WEBOPT_CONTENTLENGTH, 0, - WEBOPT_END)); - - ejsSetPropertyToString(ejs, thisObj, "status", "active"); - - return 0; -} - -/******************************************************************************/ -/* - * Called whenver the http object is deleted. - */ - -static int httpDestructor(Ejs *ejs, EjsVar *thisObj) -{ - HTTPControl *hp; - - /* - * If the httpCallback has run, then this property will not exist - */ - hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY); - - if (hp) { - cleanup(hp); - } - - return 0; -} - -/******************************************************************************/ -/* - * Stop the request immediately without calling the callback - */ - -static int stopProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - HTTPControl *hp; - - hp = ejsGetPropertyAsPtr(ejs, thisObj, EJS_HTTP_PROPERTY); - - if (hp) { - cleanup(hp); - } - - return 0; -} - -/******************************************************************************/ -/* - * Brew HTTP callback. Invoked for any return data. - */ - -static void brewCallback(HTTPControl *hp) -{ - Ejs *ejs; - EjsVar *thisObj; - ISource *source; - WebRespInfo *info; - char data[MPR_BUF_INCR]; - int bytes; - - mprAssert(hp); - mprAssert(hp->webResp); - - info = IWEBRESP_GetInfo(hp->webResp); - - if (info == 0) { - mprAssert(info); - /* should not happen */ - return; - } - - ejs = hp->ejs; - thisObj = hp->thisObj; - - if (! WEB_ERROR_SUCCEEDED(info->nCode)) { - ejsSetPropertyToString(ejs, thisObj, "status", "error"); - httpCallback(hp, info->nCode); - return; - } - - if (hp->timeout) { - if (mprGetTimeRemaining(hp, hp->requestStarted, hp->timeout) <= 0) { - ejsSetPropertyToString(ejs, thisObj, "status", "timeout"); - httpCallback(hp, 504); - return; - } - } - - /* - * Normal success - */ - source = info->pisMessage; - mprAssert(source); - - bytes = ISOURCE_Read(source, data, sizeof(data)); - - switch (bytes) { - case ISOURCE_WAIT: // No data yet - ISOURCE_Readable(source, hp->callback); - break; - - case ISOURCE_ERROR: - ejsSetPropertyToString(ejs, thisObj, "status", "error"); - httpCallback(hp, info->nCode); - break; - - case ISOURCE_END: - mprAddNullToBuf(hp->buf); - ejsSetPropertyToString(ejs, thisObj, "status", "complete"); - httpCallback(hp, info->nCode); - break; - - default: - if (bytes > 0) { - if (mprPutBlockToBuf(hp->buf, data, bytes) != bytes) { - ejsSetPropertyToString(ejs, thisObj, "status", "partialData"); - httpCallback(hp, 500); - } - } - ISOURCE_Readable(source, hp->callback); - break; - } -} - -/******************************************************************************/ -/* - * Invoke the HTTP completion method - */ - -static void httpCallback(HTTPControl *hp, int responseCode) -{ - Ejs *ejs; - EjsVar *thisObj, *callbackObj; - MprArray *args; - char *msg; - const char *callbackMethod; - - mprAssert(hp); - mprAssert(hp->webResp); - - thisObj = hp->thisObj; - ejs = hp->ejs; - - ejsSetPropertyToInteger(ejs, thisObj, "responseCode", responseCode); - if (mprGetBufLength(hp->buf) > 0) { - ejsSetPropertyToBinaryString(ejs, thisObj, "responseData", - mprGetBufStart(hp->buf), mprGetBufLength(hp->buf)); - } - - callbackObj = ejsGetPropertyAsVar(ejs, thisObj, "obj"); - callbackMethod = ejsGetPropertyAsString(ejs, thisObj, "method"); - - if (callbackObj != 0 && callbackMethod != 0) { - - args = mprCreateItemArray(ejs, EJS_INC_ARGS, EJS_MAX_ARGS); - mprAddItem(args, ejsDupVar(ejs, hp->thisObj, EJS_SHALLOW_COPY)); - - if (ejsRunMethod(ejs, callbackObj, callbackMethod, args) < 0) { - msg = ejsGetErrorMsg(ejs); - mprError(ejs, MPR_LOC, "HTTP callback failed. Details: %s", msg); - } - ejsFreeMethodArgs(ejs, args); - - } else if (ejsRunMethod(ejs, thisObj, "onComplete", 0) < 0) { - msg = ejsGetErrorMsg(ejs); - mprError(ejs, MPR_LOC, "HTTP onComplete failed. Details: %s", msg); - } - - cleanup(hp); -} - -/******************************************************************************/ -/* - * Cleanup - */ - -static void cleanup(HTTPControl *hp) -{ - Ejs *ejs; - MprApp *app; - int rc; - - mprAssert(hp); - mprAssert(hp->webResp); - - ejs = hp->ejs; - - if (hp->webResp) { - rc = IWEBRESP_Release(hp->webResp); - // mprAssert(rc == 0); - hp->webResp = 0; - } - - if (hp->callback) { - CALLBACK_Cancel(hp->callback); - mprFree(hp->callback); - hp->callback = 0; - } - - /* - * Once the property is deleted, then if the destructor runs, it will - * notice that the EJS_HTTP_PROPERTY is undefined. - */ - ejsDeleteProperty(ejs, hp->thisObj, EJS_HTTP_PROPERTY); - - /* - * Allow garbage collection to work on thisObj - */ - ejsMakeObjPermanent(hp->thisObj, 0); - ejsFreeVar(ejs, hp->thisObj); - - mprFree(hp->buf); - mprFree(hp->url); - - mprFree(hp); - - app = mprGetApp(ejs); - - - ISHELL_SendEvent(app->shell, (AEECLSID) app->classId, EVT_USER, 0, 0); -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineHTTPClass(Ejs *ejs) -{ - EjsVar *httpClass; - - httpClass = - ejsDefineClass(ejs, "HTTP", "Object", ejsHTTPConstructor); - if (httpClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the methods - */ - ejsDefineCMethod(ejs, httpClass, "fetch", fetchProc, 0); - ejsDefineCMethod(ejs, httpClass, "stop", stopProc, 0); - ejsDefineCMethod(ejs, httpClass, "setCallback", setCallback, 0); - -#if FUTURE - ejsDefineCMethod(ejs, httpClass, "put", put, 0); - ejsDefineCMethod(ejs, httpClass, "upload", upload, 0); - ejsDefineCMethod(ejs, httpClass, "addUploadFile", addUploadFile, 0); - ejsDefineCMethod(ejs, httpClass, "addPostData", addPostData, 0); - ejsDefineCMethod(ejs, httpClass, "setUserPassword", setUserPassword, 0); - ejsDefineCMethod(ejs, httpClass, "addCookie", addCookie, 0); -#endif - - /* - * Define properties - */ - ejsSetPropertyToString(ejs, httpClass, "status", "inactive"); - - /* This default should come from player.xml */ - - ejsSetPropertyToInteger(ejs, httpClass, "timeout", 30 * 1000); - ejsSetPropertyToInteger(ejs, httpClass, "responseCode", 0); - - return ejsObjHasErrors(httpClass) ? MPR_ERR_CANT_INITIALIZE: 0; -} - -/******************************************************************************/ - -void ejsTermHTTPClass(Ejs *ejs) -{ - IWeb *web; - int rc; - - web = (IWeb*) mprGetKeyValue(ejs, "bpWeb"); - if (web) { - rc = IWEB_Release(web); - mprAssert(rc == 0); - } -} - -#endif -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c deleted file mode 100644 index 411975f80e..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGC.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * @file ejsGC.c - * @brief Garbage collector class for the EJS Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -#if (WIN || BREW_SIMULATOR) && BLD_DEBUG - -static int checkProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - _CrtCheckMemory(); - return 0; -} - -#endif -/******************************************************************************/ - -static int debugProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "Bad args: debug(debugLevel)"); - return -1; - } - - ejsSetGCDebugLevel(ep, ejsVarToInteger(argv[0])); - return 0; -} - -/******************************************************************************/ -/* - * Print stats and dump objects - */ - -static int printStatsProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - bool leakStats; - - if (argc > 1) { - leakStats = ejsVarToInteger(argv[0]); - } else { - leakStats = 0; - } - -#if BLD_FEATURE_ALLOC_STATS - ejsPrintAllocReport(ep, 0); - - mprPrintAllocReport(mprGetApp(ep), leakStats, 0); -#endif - -#if BLD_DEBUG - ejsDumpObjects(ep); -#endif - - return 0; -} - -/******************************************************************************/ - -static int runProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc > 1) { - ejsError(ep, EJS_ARG_ERROR, "Bad args: run([quick])"); - return -1; - } - - if (argc == 1) { - ejsIncrementalCollectGarbage(ep); - } else { - ejsCollectGarbage(ep, -1); - } - return 0; -} - -/******************************************************************************/ - -static int usedMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ep, ejsGetUsedMemory(ep)); - return 0; -} - -/******************************************************************************/ - -static int allocatedMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, - EjsVar **argv) -{ -#if BLD_FEATURE_ALLOC_STATS - ejsSetReturnValueToInteger(ep, ejsGetAllocatedMemory(ep)); -#endif - return 0; -} - -/******************************************************************************/ - -static int mprMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ -#if BLD_FEATURE_ALLOC_STATS - ejsSetReturnValueToInteger(ep, mprGetAllocatedMemory(ep)); -#endif - return 0; -} - -/******************************************************************************/ - -static int peakMprMemoryProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ -#if BLD_FEATURE_ALLOC_STATS - ejsSetReturnValueToInteger(ep, mprGetPeakAllocatedMemory(ep)); -#endif - return 0; -} - -/******************************************************************************/ - -static int getDebugLevel(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ep, ep->gc.debugLevel); - return 0; -} - -/******************************************************************************/ - -static int setDebugLevel(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsArgError(ep, "Bad arguments"); - return -1; - } - ep->gc.debugLevel= ejsVarToInteger(argv[0]); - return 0; -} - -/******************************************************************************/ - -static int getEnable(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToBoolean(ep, ep->gc.enable); - return 0; -} - -/******************************************************************************/ - -static int setEnable(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsArgError(ep, "Bad arguments"); - return -1; - } - ep->gc.enable= ejsVarToBoolean(argv[0]); - return 0; -} - -/******************************************************************************/ - -static int getDemandCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToBoolean(ep, ep->gc.enableDemandCollect); - return 0; -} - -/******************************************************************************/ - -static int setDemandCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsArgError(ep, "Bad arguments"); - return -1; - } - ep->gc.enableDemandCollect = ejsVarToBoolean(argv[0]); - return 0; -} - -/******************************************************************************/ - -static int getIdleCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToBoolean(ep, ep->gc.enableIdleCollect); - return 0; -} - -/******************************************************************************/ - -static int setIdleCollect(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsArgError(ep, "Bad arguments"); - return -1; - } - ep->gc.enableIdleCollect = ejsVarToBoolean(argv[0]); - return 0; -} - -/******************************************************************************/ - -static int getWorkQuota(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ep, ep->gc.workQuota); - return 0; -} - -/******************************************************************************/ - -static int setWorkQuota(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int quota; - - if (argc != 1) { - ejsArgError(ep, "Bad arguments"); - return -1; - } - quota = ejsVarToInteger(argv[0]); - if (quota < EJS_GC_MIN_WORK_QUOTA && quota != 0) { - ejsArgError(ep, "Bad work quota"); - return -1; - } - - ep->gc.workQuota = quota; - return 0; -} - -/******************************************************************************/ - -static int getMaxMemory(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ep, ep->gc.maxMemory); - return 0; -} - -/******************************************************************************/ - -static int setMaxMemory(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int maxMemory; - - if (argc != 1) { - ejsArgError(ep, "Bad arguments"); - return -1; - } - maxMemory = ejsVarToInteger(argv[0]); - if (maxMemory < 0) { - ejsArgError(ep, "Bad maxMemory"); - return -1; - } - - ep->gc.maxMemory = maxMemory; - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineGCClass(Ejs *ep) -{ - EjsVar *gcClass; - int flags; - - flags = EJS_NO_LOCAL; - - /* - * NOTE: We create the GC class and define static methods on it. There - * is no object instance - */ - gcClass = ejsDefineClass(ep, "System.GC", "Object", 0); - if (gcClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * MOB -- convert these to properties with accessors when available - */ - ejsDefineCMethod(ep, gcClass, "printStats", printStatsProc, flags); - ejsDefineCMethod(ep, gcClass, "run", runProc, flags); - - ejsDefineCMethod(ep, gcClass, "getUsedMemory", usedMemoryProc, flags); - ejsDefineCMethod(ep, gcClass, "getAllocatedMemory", allocatedMemoryProc, - flags); - ejsDefineCMethod(ep, gcClass, "getMprMemory", mprMemoryProc, flags); - ejsDefineCMethod(ep, gcClass, "getPeakMprMemory", peakMprMemoryProc, flags); - ejsDefineCMethod(ep, gcClass, "debug", debugProc, flags); - -#if (WIN || BREW_SIMULATOR) && BLD_DEBUG - ejsDefineCMethod(ep, gcClass, "check", checkProc, flags); -#endif - - ejsDefineCAccessors(ep, gcClass, "debugLevel", - getDebugLevel, setDebugLevel, flags); - - ejsDefineCAccessors(ep, gcClass, "enable", - getEnable, setEnable, flags); - - ejsDefineCAccessors(ep, gcClass, "demandCollect", - getDemandCollect, setDemandCollect, flags); - - ejsDefineCAccessors(ep, gcClass, "idleCollect", - getIdleCollect, setIdleCollect, flags); - - ejsDefineCAccessors(ep, gcClass, "workQuota", - getWorkQuota, setWorkQuota, flags); - - ejsDefineCAccessors(ep, gcClass, "maxMemory", - getMaxMemory, setMaxMemory, flags); - - return ejsObjHasErrors(gcClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c deleted file mode 100755 index 6ab8f867e1..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsGlobal.c +++ /dev/null @@ -1,785 +0,0 @@ -/* - * @file ejsGlobal.c - * @brief EJS support methods - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -#if BLD_FEATURE_EJS - -/******************************************************************************/ -/************************************* Code ***********************************/ -/******************************************************************************/ -/* - * assert(condition) - */ - -static int assertProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int b; - - if (argc < 1) { - ejsError(ep, EJS_ARG_ERROR, "usage: assert(condition)"); - return -1; - } - b = ejsVarToBoolean(argv[0]); - if (b == 0) { - ejsError(ep, EJS_ASSERT_ERROR, "Assertion failure at line %d", - ejsGetLineNumber(ep)); - return -1; - } - ejsWriteVarAsBoolean(ep, ep->result, b); - return 0; -} - -/******************************************************************************/ -/* - * breakpoint(msg) - */ - -static int breakpointProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *buf; - - if (argc < 1) { - return 0; - } - buf = ejsVarToString(ep, argv[0]); - if (buf) { - mprBreakpoint(0, buf); - } - return 0; -} - -/******************************************************************************/ -/* - * basename(path) - */ - -static int basenameProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *path; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "usage: basename(path)"); - return -1; - } - - path = ejsVarToString(ep, argv[0]); - if (path == 0) { - return MPR_ERR_MEMORY; - } - ejsSetReturnValueToString(ep, mprGetBaseName(path)); - - return 0; -} - -/******************************************************************************/ -/* - * stripext(path) - */ - -static int stripextProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *cp, *path, *stripPath; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "usage: stripext(path)"); - return -1; - } - - path = ejsVarToString(ep, argv[0]); - if (path == 0) { - return MPR_ERR_MEMORY; - } - stripPath = mprStrdup(ep, path); - - if ((cp = strrchr(stripPath, '.')) != 0) { - *cp = '\0'; - } - - ejsSetReturnValueToString(ep, stripPath); - - mprFree(stripPath); - - return 0; -} - -/******************************************************************************/ -/* - * dirname(path) - */ - -static int dirnameProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *path; - char dirname[MPR_MAX_FNAME]; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "usage: dirname(path)"); - return -1; - } - - path = ejsVarToString(ep, argv[0]); - if (path == 0) { - return MPR_ERR_MEMORY; - } - - ejsSetReturnValueToString(ep, - mprGetDirName(dirname, sizeof(dirname), path)); - - return 0; -} - -/******************************************************************************/ -/* - * trim(string) -- trim white space - */ - -static int trimProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *str, *buf, *cp; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "usage: trim(string)"); - return -1; - } - - str = ejsVarToString(ep, argv[0]); - if (str == 0) { - return MPR_ERR_MEMORY; - } - str = buf = mprStrdup(ep, str); - - while (isspace(*str)) { - str++; - } - cp = &str[strlen(str) - 1]; - while (cp >= str) { - if (isspace(*cp)) { - *cp = '\0'; - } else { - break; - } - cp--; - } - - ejsSetReturnValueToString(ep, str); - - mprFree(buf); - - return 0; -} - -/******************************************************************************/ -/* - * Terminate the script - */ - -static int exitScript(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int status; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "usage: exit(status)"); - return -1; - } - status = (int) ejsVarToInteger(argv[0]); - ejsExit(ep, status); - - ejsWriteVarAsString(ep, ep->result, ""); - return 0; -} - -/******************************************************************************/ -/* - * include javascript libraries. - */ - -static int includeProc(Ejs *ep, EjsVar *thisObj, int argc, char **argv) -{ - int i; - - mprAssert(argv); - - for (i = 0; i < argc; i++) { - if (ejsEvalFile(ep, argv[i], 0) < 0) { - return -1; - } - } - return 0; -} - -/******************************************************************************/ -/* - * include javascript libraries at the global level - */ - -static int includeGlobalProc(Ejs *ep, EjsVar *thisObj, int argc, char **argv) -{ - int fid, i; - - mprAssert(argv); - - /* - * Create a new block and set the context to be the global scope - */ - fid = ejsSetBlock(ep, ep->global); - - for (i = 0; i < argc; i++) { - if (ejsEvalFile(ep, argv[i], 0) < 0) { - ejsCloseBlock(ep, fid); - return -1; - } - } - ejsCloseBlock(ep, fid); - return 0; -} - -/******************************************************************************/ -#if BLD_DEBUG -/* - * Print variables to stdout - */ - -static int printvProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsVar *vp; - char *buf; - int i; - - for (i = 0; i < argc; ) { - vp = argv[i++]; - - /* mprPrintf(ep, "arg[%d] = ", i); */ - - buf = ejsVarToString(ep, vp); - - if (vp->propertyName == 0 || *vp->propertyName == '\0') { - mprPrintf(ep, "%s: ", buf); - - } else if (i < argc) { - mprPrintf(ep, "%s = %s, ", vp->propertyName, buf); - } else { - mprPrintf(ep, "%s = %s\n", vp->propertyName, buf); - } - } - return 0; -} - -#endif -/******************************************************************************/ -/* - * Print the args to stdout - */ - -static int printProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *buf; - int i; - - for (i = 0; i < argc; i++) { - buf = ejsVarToString(ep, argv[i]); - mprPrintf(ep, "%s", buf); - } - return 0; -} - -/******************************************************************************/ -/* - * println - */ - -static int printlnProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - printProc(ep, thisObj, argc, argv); - mprPrintf(ep, "\n"); - return 0; -} - -/******************************************************************************/ -#if FUTURE -/* - * sprintf - */ - -static int sprintfProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - va_list ap; - char *buf; - void **args; - int result; - - if (argc <= 1) { - ejsError(ep, EJS_ARG_ERROR, "Usage: sprintf(fmt, [args ...])"); - return -1; - } - - args = mprAlloc(ep, sizeof(void*) * (argc - 1)); - if (args == 0) { - mprAssert(args); - return -1; - } - - for (i = 1; i < argc; i++) { - args[i - 1] = argv[i]); - } - - va_start(ap, fmt); - *buf = 0; - result = inner(0, &buf, MPR_MAX_STRING, fmt, args); - va_end(ap); - - ejsSetReturnValueToString(ep, buf); - - mprFree(buf); - return 0; -} - -/******************************************************************************/ - -inner(const char *fmt, void **args) -{ - va_list ap; - - va_start(ap, fmt); - *buf = 0; - mprSprintfCore(ctx, &buf, maxSize, fmt, ap, MPR_PRINTF_ARGV); - va_end(ap); -} - -#endif -/******************************************************************************/ -/* - * sleep - */ - -static int sleepProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "Usage: sleep(milliseconds)"); - return -1; - } - mprSleep(ep, ejsVarToInteger(argv[0])); - return 0; -} - -/******************************************************************************/ -/* - * sort properties - * FUTURE -- should have option to sort object based on a given property value - * ascending or descending - * Usage: sort(object, order = ascending, property = 0); - */ - -static int sortProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const char *property; - int error, order; - - error = 0; - property = 0; - - /* - * Default order is increasing - */ - order = 1; - - if (argc < 1 || argc > 3 || !ejsVarIsObject(argv[0])) { - error++; - } - - if (argc >= 2) { - order = ejsVarToInteger(argv[1]); - } - - /* - * If property is not defined, it sorts the properties in the object - */ - if (argc == 3) { - if (! ejsVarIsString(argv[2])) { - error++; - } else { - property = argv[2]->string; - } - } - - if (error) { - ejsError(ep, EJS_ARG_ERROR, "Usage: sort(object, [order], [property])"); - return -1; - } - ejsSortProperties(ep, argv[0], 0, property, order); - return 0; -} - -/******************************************************************************/ -/* - * Get a time mark - * MOB -- WARNING: this can overflow. OK on BREW, but other O/Ss it may have - * overflowed on the first call. It should be renamed. - * MOB -- replace with proper Date. - */ - -static int timeProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - MprTime now; - - mprGetTime(ep, &now); -#if WIN || LINUX || SOLARIS -{ - /* MOB -- poor hack */ - static MprTime initial; - if (initial.sec == 0) { - initial = now; - } - now.sec -= initial.sec; - - if (initial.msec > now.msec) { - now.msec = now.msec + 1000 - initial.msec; - now.sec--; - } else { - now.msec -= initial.msec; - } -} -#endif - /* MOB -- this can overflow */ - ejsSetReturnValueToInteger(ep, now.sec * 1000 + now.msec); - return 0; -} - -/******************************************************************************/ -/* - * MOB -- Temporary Get the date (time since Jan 6, 1980 GMT - */ - -static int dateProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ -#if BREW - uint now; - - now = GETTIMESECONDS(); - ejsSetReturnValueToInteger(ep, now); -#endif - return 0; -} - -/******************************************************************************/ -/* - * strlen(string) - */ - -static int strlenProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *buf; - int len; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "Usage: strlen(var)"); - return -1; - } - - len = 0; - if (! ejsVarIsString(argv[0])) { - buf = ejsVarToString(ep, argv[0]); - if (buf) { - len = strlen(buf); - } - - } else { - len = argv[0]->length; - } - - ejsSetReturnValueToInteger(ep, len); - return 0; -} - -/******************************************************************************/ -/* - * toint(num) - */ - -static int tointProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int i; - - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "Usage: toint(number)"); - return -1; - } - - i = ejsVarToInteger(argv[0]); - - ejsSetReturnValueToInteger(ep, i); - return 0; -} - -/******************************************************************************/ -/* - * string strstr(string, pat) - */ - -static int strstrProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - char *str, *pat; - char *s; - int strAlloc; - - if (argc != 2) { - ejsError(ep, EJS_ARG_ERROR, "Usage: strstr(string, pat)"); - return -1; - } - - str = ejsVarToString(ep, argv[0]); - - strAlloc = ep->castAlloc; - ep->castTemp = 0; - - pat = ejsVarToString(ep, argv[1]); - - s = strstr(str, pat); - - if (s == 0) { - ejsSetReturnValueToUndefined(ep); - } else { - ejsSetReturnValueToString(ep, s); - } - - if (strAlloc) { - mprFree(str); - } - - return 0; -} - -/******************************************************************************/ -/* - * Trace - */ - -static int traceProc(Ejs *ep, EjsVar *thisObj, int argc, char **argv) -{ - if (argc == 1) { - mprLog(ep, 0, "%s", argv[0]); - - } else if (argc == 2) { - mprLog(ep, atoi(argv[0]), "%s", argv[1]); - - } else { - ejsError(ep, EJS_ARG_ERROR, "Usage: trace([level], message)"); - return -1; - } - ejsWriteVarAsString(ep, ep->result, ""); - return 0; -} - -/******************************************************************************/ -/* - * Evaluate a sub-script. It is evaluated in the same variable scope as - * the calling script / method. - */ - -static int evalScriptProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - EjsVar *arg; - int i; - - ejsWriteVarAsUndefined(ep, ep->result); - - for (i = 0; i < argc; i++) { - arg = argv[i]; - if (arg->type != EJS_TYPE_STRING) { - continue; - } - if (ejsEvalScript(ep, arg->string, 0) < 0) { - return -1; - } - } - /* - * Return with the value of the last expression - */ - return 0; -} - -/******************************************************************************/ - -/* MOB -- need a real datatype returning int, int64, etc */ - -static int typeofProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const struct { - EjsType type; - const char *name; - } types[] = { - { EJS_TYPE_UNDEFINED, "undefined" }, -#if EJS_ECMA_STND - { EJS_TYPE_NULL, "object" }, -#else - { EJS_TYPE_NULL, "null" }, -#endif - { EJS_TYPE_BOOL, "boolean" }, - { EJS_TYPE_CMETHOD, "function" }, - { EJS_TYPE_FLOAT, "number" }, - { EJS_TYPE_INT, "number" }, - { EJS_TYPE_INT64, "number" }, - { EJS_TYPE_OBJECT, "object" }, - { EJS_TYPE_METHOD, "function" }, - { EJS_TYPE_STRING, "string" }, - { EJS_TYPE_STRING_CMETHOD, "function" }, - { EJS_TYPE_PTR, "pointer" } - }; - const char *type; - int i; - - type = NULL; - if (argc != 1) { - ejsError(ep, EJS_ARG_ERROR, "Bad args: typeof(var)"); - return -1; - } - - for (i = 0; i < MPR_ARRAY_SIZE(types); i++) { - if (argv[0]->type == types[i].type) { - type = types[i].name; - break; - } - } - if (type == NULL) { - mprAssert(type); - return -1; - } - - ejsSetReturnValueToString(ep, type); - return 0; -} - -/******************************************************************************/ -/* - * Define the standard properties and methods inherited by all interpreters - * Obj is set to the global class in the default interpreter. When an - * interpreter attempts to write to any property, a copy will be written - * into the interpeters own global space. This is like a "copy-on-write". - */ - -int ejsDefineGlobalProperties(Ejs *ep) -{ - EjsVar *obj; - - obj = ep->service->globalClass; - mprAssert(obj); - - ejsSetPropertyToNull(ep, obj, "null"); - ejsSetPropertyToUndefined(ep, obj, "undefined"); - ejsSetPropertyToBoolean(ep, obj, "true", 1); - ejsSetPropertyToBoolean(ep, obj, "false", 0); - -#if BLD_FEATURE_FLOATING_POINT - { - /* MOB. Fix. This generates warnings on some systems. - This is intended. */ - double d = 0.0; - double e = 0.0; - ejsSetPropertyToFloat(ep, obj, "NaN", e / d); - - d = MAX_FLOAT; - ejsSetPropertyToFloat(ep, obj, "Infinity", d * d); - } -#endif - -#if BLD_FEATURE_LEGACY_API - /* - * DEPRECATED: 2.0. - * So that ESP/ASP can ignore "language=javascript" statements - */ - ejsSetPropertyToInteger(ep, obj, "javascript", 0); -#endif - - /* - * Extension methods. We go directly to the mpr property APIs for speed. - * Flags will cause the callbacks to be supplied the Ejs handle. - */ - ejsDefineCMethod(ep, obj, "assert", assertProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "breakpoint", breakpointProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "basename", basenameProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "dirname", dirnameProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "stripext", stripextProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "trim", trimProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "eval", evalScriptProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "exit", exitScript, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "print", printProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "println", printlnProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "sleep", sleepProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "sort", sortProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "time", timeProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "date", dateProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "strlen", strlenProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "strstr", strstrProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "typeof", typeofProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "toint", tointProc, EJS_NO_LOCAL); - - ejsDefineStringCMethod(ep, obj, "include", includeProc, EJS_NO_LOCAL); - ejsDefineStringCMethod(ep, obj, "includeGlobal", includeGlobalProc, - EJS_NO_LOCAL); - ejsDefineStringCMethod(ep, obj, "trace", traceProc, EJS_NO_LOCAL); - -#if BLD_DEBUG - ejsDefineCMethod(ep, obj, "printv", printvProc, EJS_NO_LOCAL); -#endif - -#if FUTURE - ejsDefineCMethod(ep, obj, "printf", printfProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, obj, "sprintf", sprintfProc, EJS_NO_LOCAL); -#endif - - if (ejsObjHasErrors(obj)) { - return MPR_ERR_CANT_INITIALIZE; - } - return 0; -} - -/******************************************************************************/ - -#else -void ejsProcsDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c deleted file mode 100644 index e035e1c740..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystem.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * @file ejsSystem.c - * @brief System class for the EJS Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -#if UNUSED -/* - * function int random() - */ - -static int randomProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "random()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function void yield() - */ - -static int yieldProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "yield()\n"); - return 0; -} - -/******************************************************************************/ -/* - * function void sleep(int milliSeconds) - */ - -static int sleepProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ep, "sleep()\n"); - return 0; -} - -#endif -/******************************************************************************/ -/* - * function void exit(int status) - * - * Exit the widget with the given status. All JavaScript processing ceases. - */ - -static int exitProc(Ejs *ep, EjsVar *thisObj, int argc, EjsVar **argv) -{ - int status; - - status = 0; - if ((argc == 1) && ejsVarIsInteger(argv[0])) { - status = argv[0]->integer; - } - ejsExit(ep, status); - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineSystemClass(Ejs *ep) -{ - EjsVar *systemClass; - - /* - * We create the system class and define static methods on it. - * NOTE: There is no object instance - */ - systemClass = ejsDefineClass(ep, "System", "Object", 0); - if (systemClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - ejsDefineCMethod(ep, systemClass, "exit", exitProc, EJS_NO_LOCAL); - -#if UNUSED - ejsDefineCMethod(ep, systemClass, "random", randomProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, systemClass, "yield", yieldProc, EJS_NO_LOCAL); - ejsDefineCMethod(ep, systemClass, "sleep", sleepProc, EJS_NO_LOCAL); - - /* - * Define properties - */ - ejsSetPropertyToString(systemClass, "name", ""); -#endif - - return ejsObjHasErrors(systemClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c deleted file mode 100644 index e2f1ceb363..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemApp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * @file ejsSystemApp.c - * @brief App class - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software Inc, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/************************************ Code ************************************/ - -int ejsDefineAppClass(Ejs *ep) -{ - EjsVar *appClass; - - appClass = ejsDefineClass(ep, "System.App", "Object", 0); - if (appClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define properties - */ - ejsSetPropertyToString(ep, appClass, "name", BLD_PRODUCT); - ejsSetPropertyToString(ep, appClass, "title", BLD_NAME); - ejsSetPropertyToString(ep, appClass, "version", BLD_VERSION); - - /* - * Command line arguments - */ - ejsSetPropertyToNull(ep, appClass, "args"); - - return ejsObjHasErrors(appClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c deleted file mode 100644 index 5a011e2a2d..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemDebug.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * @file ejsSystemDebug.c - * @brief System.Debug class - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function bool isDebugMode() - * MOB -- convert to accessor - */ - -static int isDebugMode(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsTrace(ejs, "isDebugMode()\n"); - ejsSetReturnValueToInteger(ejs, mprGetDebugMode(ejs)); - return 0; -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineDebugClass(Ejs *ejs) -{ - EjsVar *systemDebugClass; - - systemDebugClass = ejsDefineClass(ejs, "System.Debug", "Object", 0); - if (systemDebugClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the class methods - */ - ejsDefineCMethod(ejs, systemDebugClass, "isDebugMode", isDebugMode, - EJS_NO_LOCAL); - - return ejsObjHasErrors(systemDebugClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c deleted file mode 100644 index 66467f8fcf..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemLog.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * @file ejsSystemLog.c - * @brief System.Log class for the EJS Object Model - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/*********************************** Usage ************************************/ -/* - * System.Log.setLog(path); - * System.Log.enable; - */ -/******************************************************************************/ - -static void logHandler(MPR_LOC_DEC(ctx, loc), int flags, int level, - const char *msg) -{ - MprApp *app; - char *buf; - int len; - - app = mprGetApp(ctx); - if (app->logFile == 0) { - return; - } - - if (flags & MPR_LOG_SRC) { - len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0, - "Log %d: %s\n", level, msg); - - } else if (flags & MPR_ERROR_SRC) { - len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0, - "Error: %s\n", msg); - - } else if (flags & MPR_FATAL_SRC) { - len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0, - "Fatal: %s\n", msg); - - } else if (flags & MPR_ASSERT_SRC) { -#if BLD_FEATURE_ALLOC_LEAK_TRACK - len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0, - "Assertion %s, failed at %s\n", - msg, loc); -#else - len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0, - "Assertion %s, failed\n", msg); -#endif - - } else if (flags & MPR_RAW) { - /* OPT */ - len = mprAllocSprintf(MPR_LOC_PASS(ctx, loc), &buf, 0, - "%s", msg); - - } else { - return; - } - - mprPuts(app->logFile, buf, len); - - mprFree(buf); -} - -/******************************************************************************/ -/************************************ Methods *********************************/ -/******************************************************************************/ -/* - * function int setLog(string path) - */ - -static int setLog(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - const char *path; - MprFile *file; - MprApp *app; - - if (argc != 1 || !ejsVarIsString(argv[0])) { - ejsArgError(ejs, "Usage: setLog(path)"); - return -1; - } - - app = mprGetApp(ejs); - - /* - * Ignore errors if we can't create the log file. - * Use the app context so this will live longer than the interpreter - * MOB -- this leaks files. - */ - path = argv[0]->string; - file = mprOpen(app, path, O_CREAT | O_TRUNC | O_WRONLY, 0664); - if (file) { - app->logFile = file; - mprSetLogHandler(ejs, logHandler); - } - mprLog(ejs, 0, "Test log"); - - return 0; -} - -/******************************************************************************/ -#if UNUSED - -static int enableSetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - if (argc != 1) { - ejsArgError(ejs, "Usage: set(value)"); - return -1; - } - ejsSetProperty(ejs, thisObj, "_enabled", argv[0]); - return 0; -} - -/******************************************************************************/ - -static int enableGetAccessor(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValue(ejs, ejsGetPropertyAsVar(ejs, thisObj, "_enabled")); - return 0; -} - -#endif -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineLogClass(Ejs *ejs) -{ - EjsVar *logClass; - - logClass = ejsDefineClass(ejs, "System.Log", "Object", 0); - if (logClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - ejsDefineCMethod(ejs, logClass, "setLog", setLog, EJS_NO_LOCAL); - -#if UNUSED - EjsProperty *pp; - ejsDefineCAccessors(ejs, logClass, "enable", enableSetAccessor, - enableGetAccessor, EJS_NO_LOCAL); - - pp = ejsSetPropertyToBoolean(ejs, logClass, "_enabled", 0); - ejsMakePropertyEnumerable(pp, 0); -#endif - - return ejsObjHasErrors(logClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c b/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c deleted file mode 100755 index d10787b1b4..0000000000 --- a/source4/lib/appweb/ejs-2.0/ejs/system/ejsSystemMemory.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * @file ejsSystemMemory.c - * @brief System.Memory class - */ -/********************************** Copyright *********************************/ -/* - * Copyright (c) Mbedthis Software LLC, 2005-2006. All Rights Reserved. - */ -/********************************** Includes **********************************/ - -#include "ejs.h" - -/****************************** Forward Declarations***************************/ - -static uint getUsedMemory(Ejs *ejs); - -/******************************************************************************/ -/*********************************** Methods *********************************/ -/******************************************************************************/ - -static int getUsedMemoryProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ejs, getUsedMemory(ejs)); - return 0; -} - -/******************************************************************************/ - -static int getUsedStackProc(Ejs *ejs, EjsVar *thisObj, int argc, EjsVar **argv) -{ - ejsSetReturnValueToInteger(ejs, mprStackSize(ejs)); - return 0; -} - -/******************************************************************************/ -/* - * Public function - */ - -uint ejsGetAvailableMemory(Ejs *ejs) -{ - EjsVar *memoryClass; - uint ram; - - memoryClass = ejsGetClass(ejs, 0, "System.Memory"); - - ram = ejsGetPropertyAsInteger(ejs, memoryClass, "ram"); - return ram - getUsedMemory(ejs); -} - -/******************************************************************************/ - -static int getAvailableMemoryProc(Ejs *ejs, EjsVar *thisObj, int argc, - EjsVar **argv) -{ - EjsVar *memoryClass; - uint ram; - - memoryClass = ejsGetClass(ejs, 0, "System.Memory"); - - ram = ejsGetPropertyAsInteger(ejs, memoryClass, "ram"); -#if BREW - ejsSetReturnValueToInteger(ejs, ram - getUsedMemory(ejs)); -#else - ejsSetReturnValueToInteger(ejs, 0); -#endif - return 0; -} - -/******************************************************************************/ - -static uint getUsedMemory(Ejs *ejs) -{ -#if BREW - MprApp *app; - IHeap *heap; - uint memInUse; - void *ptr; - - app = mprGetApp(ejs); - ptr = (void*) &heap; - if (ISHELL_CreateInstance(app->shell, AEECLSID_HEAP, (void**) ptr) - == SUCCESS) { - memInUse = IHEAP_GetMemStats(heap); - IHEAP_Release(heap); - } else { - memInUse = 0; - } - - return memInUse; -#else - return 0; -#endif -} - -/******************************************************************************/ -/******************************** Initialization ******************************/ -/******************************************************************************/ - -int ejsDefineMemoryClass(Ejs *ejs) -{ - EjsVar *memoryClass; - uint used; - -#if BREW - MprApp *app; - AEEDeviceInfo *info; - - /* - * Get needed information for class properties. - */ - info = mprAllocType(ejs, AEEDeviceInfo); - if (info == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - info->wStructSize = sizeof(AEEDeviceInfo); - app = mprGetApp(ejs); - ISHELL_GetDeviceInfo(app->shell, info); - used = getUsedMemory(ejs); -#else - used = 0; -#endif - - /* - * Create the class - */ - memoryClass = ejsDefineClass(ejs, "System.Memory", "Object", 0); - if (memoryClass == 0) { - return MPR_ERR_CANT_INITIALIZE; - } - - /* - * Define the class methods - * MOB -- change to accessors - */ - ejsDefineCMethod(ejs, memoryClass, "getUsedStack", getUsedStackProc, - EJS_NO_LOCAL); - ejsDefineCMethod(ejs, memoryClass, "getUsedMemory", getUsedMemoryProc, - EJS_NO_LOCAL); - ejsDefineCMethod(ejs, memoryClass, "getAvailableMemory", - getAvailableMemoryProc, EJS_NO_LOCAL); - - /* - * Define properties - */ -#if BREW - ejsSetPropertyToInteger(ejs, memoryClass, "ram", info->dwRAM); - -#if UNUSED - /* MOB -- delete this */ - ejsSetPropertyToInteger(ejs, memoryClass, "available", - info->dwRAM - used); -#endif -#endif - -#if UNUSED - ejsSetPropertyToInteger(ejs, memoryClass, "used", used); - ejsSetPropertyToInteger(ejs, memoryClass, "flash", 0); -#endif - - return ejsObjHasErrors(memoryClass) ? MPR_ERR_CANT_INITIALIZE : 0; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/exml/Makefile b/source4/lib/appweb/ejs-2.0/exml/Makefile deleted file mode 100644 index 663e65ed53..0000000000 --- a/source4/lib/appweb/ejs-2.0/exml/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -# -# Makefile for Embedded XML (EXML) -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -# -# EXML may be linked into shared handlers so we must build the objects both -# shared and static. -# -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I../mpr - -include make.dep - -ifeq ($(BLD_FEATURE_TEST),1) -POST_DIRS := test -endif - -TARGETS += $(BLD_BIN_DIR)/libexml$(BLD_LIB) - -ifeq ($(BLD_FEATURE_XML),1) -compileExtra: $(TARGETS) -endif - -# MOB -- remove when FEATURE_XML is defined -compileExtra: $(TARGETS) - -$(BLD_BIN_DIR)/libexml$(BLD_LIB): $(FILES) - @bld --library $(BLD_BIN_DIR)/libexml \ - --objectsDir $(BLD_OBJ_DIR) --objectList files --libs mpr - -cleanExtra: - @echo "rm -f $(TARGETS)" | $(BLDOUT) - @rm -f $(TARGETS) - @rm -f $(BLD_BIN_DIR)/libexml.* - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/exml/exml.h b/source4/lib/appweb/ejs-2.0/exml/exml.h deleted file mode 100644 index 44c50a56b9..0000000000 --- a/source4/lib/appweb/ejs-2.0/exml/exml.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * exml.h -- Embedded Xml Parser header - * - * Copyright (c) Mbedthis Software, LLC, 2003-2003. All Rights Reserved. -- MOB - */ - -#ifndef _h_EXML -#define _h_EXML 1 - -/******************************** Description *********************************/ - -#include "mpr.h" - -/********************************** Defines ***********************************/ - -#if BLD_FEATURE_SQUEEZE - #define EXML_BUFSIZE 512 /* Read buffer size */ -#else - #define EXML_BUFSIZE 1024 /* Read buffer size */ -#endif - -/* - * XML parser states. The states that are passed to the user handler have - * "U" appended to the comment. The error states (ERR and EOF) must be - * negative. - */ -#define EXML_ERR -1 /* Error */ -#define EXML_EOF -2 /* End of input */ -#define EXML_BEGIN 1 /* Before next tag */ -#define EXML_AFTER_LS 2 /* Seen "<" */ -#define EXML_COMMENT 3 /* Seen ""); - if (rc < 0) { - return TOKEN_TOO_BIG; - } else if (rc == 0) { - return TOKEN_ERR; - } - return TOKEN_COMMENT; - } - } - } - trimToken(xp); - return TOKEN_TEXT; - } - if ((c = getNextChar(xp)) < 0) { - return TOKEN_EOF; - } - } - - /* Should never get here */ - mprAssert(0); - return TOKEN_ERR; -} - -/******************************************************************************/ -/* - * Scan for a pattern. Eat and discard input up to the pattern. Return 1 if - * the pattern was found, return 0 if not found. Return < 0 on errors. - */ - -static int scanFor(Exml *xp, char *str) -{ - MprBuf *tokBuf; - char *cp; - int c; - - mprAssert(str); - - tokBuf = xp->tokBuf; - - while (1) { - for (cp = str; *cp; cp++) { - if ((c = getNextChar(xp)) < 0) { - return 0; - } - if (tokBuf) { - if (mprPutCharToBuf(tokBuf, c) < 0) { - return -1; - } - } - if (c != *cp) { - break; - } - } - if (*cp == '\0') { - /* - * Remove the pattern from the tokBuf - */ - if (tokBuf) { - mprAdjustBufEnd(tokBuf, -(int) strlen(str)); - trimToken(xp); - } - return 1; - } - } -} - -/******************************************************************************/ -/* - * Get another character. We read and buffer blocks of data if we need more - * data to parse. - */ - -static int getNextChar(Exml *xp) -{ - MprBuf *inBuf; - char c; - int l; - - inBuf = xp->inBuf; - if (mprGetBufLength(inBuf) <= 0) { - /* - * Flush to reset the servp/endp pointers to the start of the buffer - * so we can do a maximal read - */ - mprFlushBuf(inBuf); - l = (xp->readFn)(xp, xp->inputArg, mprGetBufStart(inBuf), - mprGetBufLinearSpace(inBuf)); - if (l <= 0) { - return -1; - } - mprAdjustBufEnd(inBuf, l); - } - c = mprGetCharFromBuf(inBuf); - - if (c == '\n') { - xp->lineNumber++; - } - return c; -} - -/******************************************************************************/ -/* - * Put back a character in the input buffer - */ - -static int putLastChar(Exml *xp, int c) -{ - if (mprInsertCharToBuf(xp->inBuf, (char) c) < 0) { - mprAssert(0); - return -1; - } - if (c == '\n') { - xp->lineNumber--; - } - return 0; -} - -/******************************************************************************/ -/* - * Output a parse message - */ - -static void error(Exml *xp, char *fmt, ...) -{ - va_list args; - char *buf; - - mprAssert(fmt); - - va_start(args, fmt); - mprAllocVsprintf(MPR_LOC_ARGS(xp), &buf, MPR_MAX_STRING, fmt, args); - va_end(args); - - /* - * MOB need to add the failing line text and a pointer to which column - */ - mprFree(xp->errMsg); - mprAllocSprintf(MPR_LOC_ARGS(xp), &xp->errMsg, MPR_MAX_STRING, - "XML error: %s\nAt line %d\n", buf, xp->lineNumber); - - mprFree(buf); -} - -/******************************************************************************/ -/* - * Remove trailing whitespace in a token and ensure it is terminated with - * a NULL for easy parsing - */ - -static void trimToken(Exml *xp) -{ - while (isspace(mprLookAtLastCharInBuf(xp->tokBuf))) { - mprAdjustBufEnd(xp->tokBuf, -1); - } - mprAddNullToBuf(xp->tokBuf); -} - -/******************************************************************************/ - -const char *exmlGetErrorMsg(Exml *xp) -{ - if (xp->errMsg == 0) { - return ""; - } - return xp->errMsg; -} - -/******************************************************************************/ - -int exmlGetLineNumber(Exml *xp) -{ - return xp->lineNumber; -} - -/******************************************************************************/ -#else - -void exmlParserDummy() {} -#endif /* BLD_FEATURE_EXML */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/exml/files b/source4/lib/appweb/ejs-2.0/exml/files deleted file mode 100644 index 0f10ea44dd..0000000000 --- a/source4/lib/appweb/ejs-2.0/exml/files +++ /dev/null @@ -1 +0,0 @@ -${BLD_OBJ_DIR}/exmlParser${BLD_OBJ} diff --git a/source4/lib/appweb/ejs-2.0/mpr/Makefile b/source4/lib/appweb/ejs-2.0/mpr/Makefile deleted file mode 100644 index 6dd0e45d9e..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# -# Makefile for the Mbedthis Portable Runtime (MPR) library -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes - -include make.dep - -ifeq ($(BLD_HOST_UNIX),1) -PRE_DIRS = UNIX -else -PRE_DIRS = $(BLD_HOST_OS) -endif - -POST_DIRS = package - -TARGETS += $(BLD_BIN_DIR)/libmpr$(BLD_LIB) - -compileExtra: $(TARGETS) - -# -# Build the mpr libraries -# -$(BLD_BIN_DIR)/libmpr$(BLD_LIB): files \ - $(shell BLD_OBJ=$(BLD_OBJ) \; BLD_OBJ_DIR=$(BLD_OBJ_DIR) \; \ - eval echo `cat files`) - @bld --library $(BLD_BIN_DIR)/libmpr \ - --objectsDir $(BLD_OBJ_DIR) --objectList files - -cleanExtra: - @echo "rm -f $(TARGETS)" | $(BLDOUT) - @rm -f $(TARGETS) - @rm -f $(BLD_BIN_DIR)/libmpr.* - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile b/source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile deleted file mode 100644 index 5259b1e3a0..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# -# Makefile for the Mbedthis Portable Runtime (MPR) library for UNIX -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I.. - -include make.dep - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c b/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c deleted file mode 100644 index f647f1ed56..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprFile.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file mprFile.c - * @brief File services for Unix - * @overview - * @remarks - * See mprGenFile.c for other file services. - */ - -/******************************************************************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "mpr.h" - -/************************************ Code ************************************/ - -int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info) -{ - struct stat s; - - mprAssert(path); - mprAssert(info); - - if (stat(path, &s) < 0) { - return -1; - } - - info->size = s.st_size; - info->ctime = s.st_ctime; - info->mtime = s.st_mtime; - info->inode = s.st_ino; - info->isDir = (s.st_mode & S_IFDIR) != 0; - info->isReg = (s.st_mode & S_IFREG) != 0; - - if (strcmp(path, "/dev/null") == 0) { - info->isReg = 0; - } - - return 0; -} - -/******************************************************************************/ - -int mprMakeDir(MprCtx ctx, const char *path, int perms) -{ - return mkdir(path, perms); -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c b/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c deleted file mode 100644 index 2c7fbf8a00..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprPlatform.c +++ /dev/null @@ -1,218 +0,0 @@ -/** - * @file mprPlatform.c - * @brief Cross platform routines - * @overview This module provides low level cross platform routines. - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ -/* - * We need to use the underlying str(cpy) routines to implement our safe - * alternatives - */ -#if !DOXYGEN -#define UNSAFE_FUNCTIONS_OK 1 -#endif - -#include "mpr.h" - -/************************************ Code ************************************/ - -char *mprInetToStr(char *buffer, int bufsize, const struct in_addr in) -{ -#if HAVE_NTOA_R - inet_ntoa_r(in, buffer, bufsize); -#else - uchar *cp; - /* FUTURE -- this is not portable */ - cp = (uchar*) ∈ - mprSprintf(buffer, bufsize, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]); -#endif - return buffer; -} - -/******************************************************************************/ - -void mprSetShell(MprCtx ctx, void *shell) -{ -} - -/******************************************************************************/ - -void *mprGetShell(MprCtx ctx) -{ - return 0; -} - -/******************************************************************************/ -/* - * Sleep. Period given in milliseconds. - */ - -void mprSleep(MprCtx ctx, int milliseconds) -{ - struct timespec timeout; - int rc; - - mprAssert(milliseconds >= 0); - timeout.tv_sec = milliseconds / 1000; - timeout.tv_nsec = (milliseconds % 1000) * 1000000; - do { - rc = nanosleep(&timeout, 0); - } while (rc < 0 && errno == EINTR); -} - -/******************************************************************************/ -/* - * Make intervening directories - */ - -int mprMakeDirPath(MprCtx ctx, const char *path) -{ - char dir[MPR_MAX_PATH], buf[MPR_MAX_PATH]; - char *dirSep; - char *next, *tok; - - dir[0] = '\0'; - dirSep = "/\\"; - - if (path == 0 || *path == '\0') { - return MPR_ERR_BAD_ARGS; - } - - mprStrcpy(buf, sizeof(buf), path); - next = mprStrTok(buf, dirSep, &tok); - if (*buf == '/') { - dir[0] = '/'; - } - while (next != NULL) { - if (strcmp(next, ".") == 0 ) { - next = mprStrTok(NULL, dirSep, &tok); - continue; - } - strcat(dir, next); - if (access(dir, R_OK) != 0) { - if (mkdir(dir, 0666) < 0) { - return MPR_ERR_CANT_CREATE; - } - } - strcat(dir, "/"); - next = mprStrTok(NULL, dirSep, &tok); - } - return 0; -} - -/******************************************************************************/ -/* - * Get a fully qualified file name for the given path. Return with forward - * slashes always - */ - -char *mprGetFullPathName(char *buf, int buflen, const char *path) -{ - if (mprStrcpy(buf, buflen, path) < 0) { - mprAssert(0); - return 0; - } - return buf; -} - -/******************************************************************************/ -/* - * Replacement for gethostbyname that is multi-thread safe - */ - -struct hostent *mprGetHostByName(MprCtx ctx, const char *name) -{ - MprApp *app; - struct hostent *hp; - struct hostent *ip; - int count, i; - - hp = (struct hostent*) mprAlloc(ctx, sizeof(struct hostent)); - memset(hp, 0, sizeof(struct hostent)); - - app = mprGetApp(ctx); - - #undef gethostbyname - - mprGlobalLock(app); - ip = gethostbyname(name); - mprGlobalUnlock(app); - - if (ip == 0) { - return 0; - } - hp->h_addrtype = ip->h_addrtype; - hp->h_length = ip->h_length; - hp->h_name = mprStrdup(hp, ip->h_name); - hp->h_addr_list = 0; - hp->h_aliases = 0; - - for (count = 0; ip->h_addr_list[count] != 0; ) { - count++; - } - if (count > 0) { - count++; - hp->h_addr_list = mprAlloc(hp, count * sizeof(char*)); - for (i = 0; ip->h_addr_list[i] != 0; i++) { - memcpy(&hp->h_addr_list[i], &ip->h_addr_list[i], ip->h_length); - } - hp->h_addr_list[i] = 0; - } - - for (count = 0; ip->h_aliases[count] != 0; ) { - count++; - } - if (count > 0) { - count++; - hp->h_aliases = mprAlloc(hp, count * sizeof(char*)); - for (i = 0; ip->h_aliases[i] != 0; i++) { - hp->h_aliases[i] = mprStrdup(hp, ip->h_aliases[i]); - } - hp->h_aliases[i] = 0; - } - return hp; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c b/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c deleted file mode 100644 index 0153c0622d..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/UNIX/mprTime.c +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @file mprTime.c - * @brief Time handling for Unix - * @overview - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************* Includes ***********************************/ - -#include "mpr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#undef localtime -#undef localtime_r -#undef gmtime -#undef gmtime_r -#undef ctime -#undef ctime_r -#undef asctime -#undef asctime_r - -/******************************************************************************/ -/* - * Returns time in seconds and milliseconds. This is NOT time-of-day. - */ - -MprTime *mprGetTime(MprCtx ctx, MprTime *tp) -{ - struct timeval tv; - - if (gettimeofday(&tv, 0) < 0) { - mprAssert(0); - tp->sec = 0; - tp->msec = 0; - return tp; - } - tp->sec = tv.tv_sec; - tp->msec = tv.tv_usec / 1000; - return tp; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of localtime - */ - -struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now) -{ - localtime_r(now, timep); - - return timep; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of gmtime - */ - -struct tm *mprGmtime(MprCtx ctx, time_t *now, struct tm *timep) -{ - gmtime_r(now, timep); - - return timep; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of ctime - */ - -int mprCtime(MprCtx ctx, char *buf, int bufsize, const time_t *timer) -{ - char localBuf[80]; - char *cp; - int len; - - mprAssert(buf); - - mprGlobalLock(ctx); - - cp = ctime_r(timer, localBuf); - if ((int) strlen(cp) >= bufsize) { - mprStrcpy(buf, bufsize, "WONT FIT"); - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - len = mprStrcpy(buf, bufsize, cp); - - if (buf[len - 1] == '\n') { - buf[len - 1] = '\0'; - } - - mprGlobalUnlock(ctx); - - return 0; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of asctime - */ - -int mprAsctime(MprCtx ctx, char *buf, int bufsize, const struct tm *timeptr) -{ - char *cp; - char localBuf[80]; - - cp = asctime_r(timeptr, localBuf); - if ((int) strlen(cp) >= bufsize) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - mprStrcpy(buf, bufsize, cp); - - return strlen(buf); -} - -/******************************************************************************/ - -#ifdef __cplusplus -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile deleted file mode 100644 index f3a2394b6e..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# -# Makefile for the Mbedthis Portable Runtime (MPR) library for VXWORKS -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I.. - -include make.dep - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c deleted file mode 100644 index ae0b523faa..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprFile.c +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file mprUnixFile.c - * @brief File services for Unix - * @overview - * @remarks - */ - -/******************************************************************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "mpr.h" - -/************************************ Code ************************************/ - -int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info) -{ - struct stat s; - - mprAssert(path); - mprAssert(info); - - if (stat(path, &s) < 0) { - return -1; - } - - info->size = s.st_size; - info->ctime = s.st_ctime; - info->mtime = s.st_mtime; - info->inode = s.st_ino; - info->isDir = (s.st_mode & S_IFDIR) != 0; - info->isReg = (s.st_mode & S_IFREG) != 0; - - if (strcmp(path, "/dev/null") == 0) { - info->isReg = 0; - } - - return 0; -} - -/******************************************************************************/ - -int mprMakeDir(MprCtx ctx, const char *path, int perms) -{ - return mkdir(path, perms); -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c deleted file mode 100644 index 29258dfe1c..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprPlatform.c +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @file mprPlatform.c - * @brief Cross platform routines - * @overview This module provides low level cross platform routines. - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ -/* - * We need to use the underlying str(cpy) routines to implement our safe - * alternatives - */ -#if !DOXYGEN -#define UNSAFE_FUNCTIONS_OK 1 -#endif - -#include "mpr.h" - -/************************************ Code ************************************/ - -char *mprInetToStr(char *buffer, int bufsize, const struct in_addr in) -{ -#if HAVE_NTOA_R - inet_ntoa_r(in, buffer, bufsize); -#else - uchar *cp; - /* FUTURE -- this is not portable */ - cp = (uchar*) ∈ - mprSprintf(buffer, bufsize, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]); -#endif - return buffer; -} - -/******************************************************************************/ - -void mprSetShell(MprCtx ctx, void *shell) -{ -} - -/******************************************************************************/ - -void *mprGetShell(MprCtx ctx) -{ - return 0; -} - -/******************************************************************************/ -/* - * Sleep. Period given in milliseconds. - */ - -void mprSleep(MprCtx ctx, int milliseconds) -{ - struct timeval timeout; - int rc; - - timeout.tv_sec = milliseconds / 1000; - timeout.tv_usec = (milliseconds % 1000) * 1000; - do { - rc = select(1, 0, 0, 0, &timeout); - } while (rc < 0 && errno == EINTR); -} - -/******************************************************************************/ -/* - * Make intervening directories - */ - -int mprMakeDirPath(MprCtx ctx, const char *path) -{ - char dir[MPR_MAX_PATH], buf[MPR_MAX_PATH]; - char *dirSep; - char *next, *tok; - - dir[0] = '\0'; - dirSep = "/\\"; - - if (path == 0 || *path == '\0') { - return MPR_ERR_BAD_ARGS; - } - - mprStrcpy(buf, sizeof(buf), path); - next = mprStrTok(buf, dirSep, &tok); - if (*buf == '/') { - dir[0] = '/'; - } - while (next != NULL) { - if (strcmp(next, ".") == 0 ) { - next = mprStrTok(NULL, dirSep, &tok); - continue; - } - strcat(dir, next); - if (access(dir, R_OK) != 0) { - if (mkdir(dir) < 0) { - return MPR_ERR_CANT_CREATE; - } - } - strcat(dir, "/"); - next = mprStrTok(NULL, dirSep, &tok); - } - return 0; -} - -/******************************************************************************/ -/* - * Get a fully qualified file name for the given path. Return with forward - * slashes always - */ - -char *mprGetFullPathName(char *buf, int buflen, const char *path) -{ - if (mprStrcpy(buf, buflen, path) < 0) { - mprAssert(0); - return 0; - } - return buf; -} - -/******************************************************************************/ -/* - * Replacement for gethostbyname that is multi-thread safe - */ - -struct hostent *mprGetHostByName(MprCtx ctx, const char *name) -{ - struct hostent *hp; - - hp = (struct hostent*) mprAlloc(ctx, sizeof(struct hostent)); - memset(hp, 0, sizeof(struct hostent)); - - struct in_addr inaddr; - inaddr.s_addr = (ulong) hostGetByName(name); - if (inaddr.s_addr < 0) { - mprAssert(0); - return 0; - } - hp->h_addrtype = AF_INET; - hp->h_length = sizeof(int); - hp->h_name = mprStrdup(name); - hp->h_addr_list = 0; - hp->h_aliases = 0; - - hp->h_addr_list = new char*[2]; - hp->h_addr_list[0] = (char *) mprAlloc(hp, sizeof(struct in_addr)); - memcpy(&hp->h_addr_list[0], &inaddr, hp->h_length); - hp->h_addr_list[1] = 0; - - return hp; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c b/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c deleted file mode 100755 index c9b7560f46..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/VXWORKS/mprTime.c +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @file mprTime.c - * @brief Time handling for VxWorks - * @overview - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************* Includes ***********************************/ - -#include "mpr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#undef localtime -#undef localtime_r -#undef gmtime -#undef gmtime_r -#undef ctime -#undef ctime_r -#undef asctime -#undef asctime_r - -/******************************************************************************/ -/* - * Returns time in seconds and milliseconds. This is NOT time-of-day. - */ - -MprTime *mprGetTime(MprCtx ctx, MprTime *tp) -{ - struct timeval tv; - - if (gettimeofday(&tv, 0) < 0) { - mprAssert(0); - tp->sec = 0; - tp->msec = 0; - return tp; - } - tp->sec = tv.tv_sec; - tp->msec = tv.tv_usec / 1000; - return tp; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of localtime - */ - -struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now) -{ - localtime_r(now, timep); - - return timep; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of gmtime - */ - -struct tm *mprGmtime(MprCtx ctx, time_t *now, struct tm *timep) -{ - gmtime_r(now, timep); - - return timep; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of ctime - */ - -int mprCtime(MprCtx ctx, char *buf, int bufsize, const time_t *timer) -{ - char localBuf[80]; - char *cp; - int len; - - mprAssert(buf); - - mprGlobalLock(ctx); - - cp = ctime_r(timer, localBuf); - if ((int) strlen(cp) >= bufsize) { - mprStrcpy(buf, bufsize, "WONT FIT"); - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - len = mprStrcpy(buf, bufsize, cp); - - if (buf[len - 1] == '\n') { - buf[len - 1] = '\0'; - } - - mprGlobalUnlock(ctx); - - return 0; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of asctime - */ - -int mprAsctime(MprCtx ctx, char *buf, int bufsize, const struct tm *timeptr) -{ - char *cp; - char localBuf[80]; - - cp = asctime_r(timeptr, localBuf); - if ((int) strlen(cp) >= bufsize) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - mprStrcpy(buf, bufsize, cp); - - return strlen(buf); -} - -/******************************************************************************/ - -#ifdef __cplusplus -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile b/source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile deleted file mode 100644 index 84e30ff8f1..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/WIN/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# -# Makefile for the Mbedthis Portable Runtime (MPR) library for Windows -# -# Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. -# - -COMPILE := *.c -EXPORT_OBJECTS := yes -MAKE_IFLAGS := -I.. - -include make.dep - -## Local variables: -## tab-width: 4 -## End: -## vim: tw=78 sw=4 ts=4 diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c b/source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c deleted file mode 100644 index 9ac1669f3d..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprFile.c +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @file mprWinFile.c - * @brief File services for Windows - * @overview - * @remarks - */ - -/******************************************************************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "mpr.h" - -/************************************ Code ************************************/ - -int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info) -{ - struct stat s; - - mprAssert(path); - mprAssert(info); - - if (stat(path, &s) < 0) { - return -1; - } - - info->size = s.st_size; - /* - * MOB -- these are time64_t. Loss of precision - */ - info->ctime = (uint) s.st_ctime; - info->mtime = (uint) s.st_mtime; - info->inode = s.st_ino; - info->isDir = (s.st_mode & S_IFDIR) != 0; - info->isReg = (s.st_mode & S_IFREG) != 0; - - /* - * Work hard on windows to determine if the file is a regular file. - * FUTURE -- OPT. Eliminate this CreateFile. - */ - if (info->isReg) { - long fileType, att; - - if ((att = GetFileAttributes(path)) == -1) { - return -1; - } - if (att & (FILE_ATTRIBUTE_REPARSE_POINT | - FILE_ATTRIBUTE_DIRECTORY | - FILE_ATTRIBUTE_ENCRYPTED | - FILE_ATTRIBUTE_SYSTEM | - FILE_ATTRIBUTE_OFFLINE)) { - /* - * Catch accesses to devices like CON, AUX, NUL, LPT etc - * att will be set to ENCRYPTED on Win9X and NT. - */ - info->isReg = 0; - } - if (info->isReg) { - HANDLE handle; - handle = CreateFile(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, - 0, OPEN_EXISTING, 0, 0); - if (handle == INVALID_HANDLE_VALUE) { - info->isReg = 0; - } else { - fileType = GetFileType(handle); - if (fileType == FILE_TYPE_CHAR || fileType == FILE_TYPE_PIPE) { - info->isReg = 0; - } - CloseHandle(handle); - } - } - } - if (strcmp(path, "nul") == 0) { - info->isReg = 0; - } - return 0; -} - -/******************************************************************************/ - -int mprMakeDir(MprCtx ctx, const char *path, int perms) -{ - return mkdir(path, perms); -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c b/source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c deleted file mode 100644 index 65718694b1..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprPlatform.c +++ /dev/null @@ -1,378 +0,0 @@ -/** - * @file mprPlatform.c - * @brief Cross platform routines - * @overview This module provides low level cross platform routines. - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ -/* - * We need to use the underlying str(cpy) routines to implement our safe - * alternatives - */ -#if !DOXYGEN -#define UNSAFE_FUNCTIONS_OK 1 -#endif - -#include "mpr.h" - -/**************************** Forward Declarations ****************************/ - -static const char *getHive(const char *keyPath, HKEY *hive); - -/************************************ Code ************************************/ - -char *mprInetToStr(char *buffer, int bufsize, const struct in_addr in) -{ -#if HAVE_NTOA_R - inet_ntoa_r(in, buffer, bufsize); -#else - uchar *cp; - cp = (uchar*) ∈ - mprSprintf(buffer, bufsize, "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]); -#endif - return buffer; -} - -/******************************************************************************/ - -void mprSetShell(MprCtx ctx, void *shell) -{ -} - -/******************************************************************************/ - -void *mprGetShell(MprCtx ctx) -{ - return 0; -} - -/******************************************************************************/ -/* - * Sleep. Period given in milliseconds. - */ - -void mprSleep(MprCtx ctx, int milliseconds) -{ - Sleep(milliseconds); -} - -/******************************************************************************/ -/* - * Make intervening directories - */ - -int mprMakeDirPath(MprCtx ctx, const char *path) -{ - char dir[MPR_MAX_PATH], buf[MPR_MAX_PATH]; - char *dirSep; - char *next, *tok; - - dir[0] = '\0'; - dirSep = "/\\"; - - if (path == 0 || *path == '\0') { - return MPR_ERR_BAD_ARGS; - } - - mprStrcpy(buf, sizeof(buf), path); - next = mprStrTok(buf, dirSep, &tok); - if (*buf == '/') { - dir[0] = '/'; - } - while (next != NULL) { - if (strcmp(next, ".") == 0 ) { - next = mprStrTok(NULL, dirSep, &tok); - continue; - } - strcat(dir, next); - if (access(dir, R_OK) != 0) { - if (_mkdir(dir) < 0) { - return MPR_ERR_CANT_CREATE; - } - } - strcat(dir, "/"); - next = mprStrTok(NULL, dirSep, &tok); - } - return 0; -} - -/******************************************************************************/ -/* - * Get a fully qualified file name for the given path. Return with forward - * slashes always - */ - -char *mprGetFullPathName(char *buf, int buflen, const char *path) -{ -#if (WIN || NW || OS2) && !BLD_FEATURE_ROMFS - char *junk, *cp; - int rc; - - --buflen; - rc = GetFullPathName(path, buflen, buf, &junk); - for (cp = buf; *cp; cp++) { - if (*cp == '\\') { - *cp = '/'; - } - } - buf[buflen] = '\0'; -#else - if (mprStrcpy(buf, buflen, path) < 0) { - mprAssert(0); - return 0; - } -#endif - return buf; -} - -/******************************************************************************/ -/* - * Replacement for gethostbyname that is multi-thread safe - */ - -struct hostent *mprGetHostByName(MprCtx ctx, const char *name) -{ - MprApp *app; - struct hostent *hp; - struct hostent *ip; - int count, i; - - hp = (struct hostent*) mprAlloc(ctx, sizeof(struct hostent)); - memset(hp, 0, sizeof(struct hostent)); - - app = mprGetApp(ctx); - - #undef gethostbyname - - mprGlobalLock(app); - ip = gethostbyname(name); - mprGlobalUnlock(app); - - if (ip == 0) { - return 0; - } - hp->h_addrtype = ip->h_addrtype; - hp->h_length = ip->h_length; - hp->h_name = mprStrdup(hp, ip->h_name); - hp->h_addr_list = 0; - hp->h_aliases = 0; - - for (count = 0; ip->h_addr_list[count] != 0; ) { - count++; - } - if (count > 0) { - count++; - hp->h_addr_list = mprAlloc(hp, count * sizeof(char*)); - for (i = 0; ip->h_addr_list[i] != 0; i++) { - memcpy(&hp->h_addr_list[i], &ip->h_addr_list[i], ip->h_length); - } - hp->h_addr_list[i] = 0; - } - - for (count = 0; ip->h_aliases[count] != 0; ) { - count++; - } - if (count > 0) { - count++; - hp->h_aliases = mprAlloc(hp, count * sizeof(char*)); - for (i = 0; ip->h_aliases[i] != 0; i++) { - hp->h_aliases[i] = mprStrdup(hp, ip->h_aliases[i]); - } - hp->h_aliases[i] = 0; - } - return hp; -} - -/******************************************************************************/ -/* - * Read a registry value. Returns allocated memory in buf. - */ - -int mprReadRegistry(MprCtx ctx, char **buf, int max, const char *key, - const char *name) -{ - HKEY top, h; - char *value; - ulong type, size; - - mprAssert(key && *key); - mprAssert(buf); - - /* - * Get the registry hive - */ - if ((key = getHive(key, &top)) == 0) { - return MPR_ERR_CANT_ACCESS; - } - - if (RegOpenKeyEx(top, key, 0, KEY_READ, &h) != ERROR_SUCCESS) { - return MPR_ERR_CANT_ACCESS; - } - - /* - * Get the type - */ - if (RegQueryValueEx(h, name, 0, &type, 0, &size) != ERROR_SUCCESS) { - RegCloseKey(h); - return MPR_ERR_CANT_READ; - } - if (type != REG_SZ && type != REG_EXPAND_SZ) { - RegCloseKey(h); - return MPR_ERR_BAD_TYPE; - } - - value = (char*) mprAlloc(ctx, size); - if ((int) size > max) { - RegCloseKey(h); - return MPR_ERR_WONT_FIT; - } - if (RegQueryValueEx(h, name, 0, &type, (uchar*) value, &size) != - ERROR_SUCCESS) { - mprFree(value); - RegCloseKey(h); - return MPR_ERR_CANT_READ; - } - - RegCloseKey(h); - *buf = value; - return 0; -} - -/******************************************************************************/ -/* - * Write a string registry value. Returns allocated memory in buf. - */ - -int mprWriteRegistry(MprCtx ctx, const char *key, const char *name, - const char *value) -{ - HKEY top, h, subHandle; - ulong disposition; - - mprAssert(key && *key); - mprAssert(name && *name); - mprAssert(value && *value); - - /* - * Get the registry hive - */ - if ((key = getHive(key, &top)) == 0) { - return MPR_ERR_CANT_ACCESS; - } - - if (name) { - /* - * Write a registry string value - */ - if (RegOpenKeyEx(top, key, 0, KEY_ALL_ACCESS, &h) != ERROR_SUCCESS) { - return MPR_ERR_CANT_ACCESS; - } - if (RegSetValueEx(h, name, 0, REG_SZ, value, strlen(value) + 1) - != ERROR_SUCCESS) { - RegCloseKey(h); - return MPR_ERR_CANT_READ; - } - - } else { - /* - * Create a new sub key - */ - if (RegOpenKeyEx(top, key, 0, KEY_CREATE_SUB_KEY, &h) != ERROR_SUCCESS){ - return MPR_ERR_CANT_ACCESS; - } - if (RegCreateKeyEx(h, name, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, NULL, &subHandle, &disposition) != ERROR_SUCCESS) { - return MPR_ERR_CANT_ACCESS; - } - RegCloseKey(subHandle); - } - RegCloseKey(h); - return 0; -} - -/******************************************************************************/ -/* - * Determine the registry hive by the first portion of the path. Return - * a pointer to the rest of key path after the hive portion. - */ - -static const char *getHive(const char *keyPath, HKEY *hive) -{ - char key[MPR_MAX_STRING], *cp; - int len; - - mprAssert(keyPath && *keyPath); - - *hive = 0; - - mprStrcpy(key, sizeof(key), keyPath); - key[sizeof(key) - 1] = '\0'; - - if (cp = strchr(key, '\\')) { - *cp++ = '\0'; - } - if (cp == 0 || *cp == '\0') { - return 0; - } - - if (!mprStrcmpAnyCase(key, "HKEY_LOCAL_MACHINE")) { - *hive = HKEY_LOCAL_MACHINE; - } else if (!mprStrcmpAnyCase(key, "HKEY_CURRENT_USER")) { - *hive = HKEY_CURRENT_USER; - } else if (!mprStrcmpAnyCase(key, "HKEY_USERS")) { - *hive = HKEY_USERS; - } else if (!mprStrcmpAnyCase(key, "HKEY_CLASSES_ROOT")) { - *hive = HKEY_CLASSES_ROOT; - } else { - return 0; - } - - if (*hive == 0) { - return 0; - } - len = strlen(key) + 1; - return keyPath + len; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c b/source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c deleted file mode 100644 index 74e59c9c73..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/WIN/mprTime.c +++ /dev/null @@ -1,192 +0,0 @@ -/** - * @file mprTime.c - * @brief Time handling for Windows - * @overview - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************* Includes ***********************************/ - -#include "mpr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/************************************ Code ************************************/ -/* - * Returns time in seconds and milliseconds. This is NOT time-of-day. - */ - -MprTime *mprGetTime(MprCtx ctx, MprTime *tp) -{ - FILETIME fileTime; - int64 now, base; - - GetSystemTimeAsFileTime(&fileTime); - - now = ((((int64) fileTime.dwHighDateTime) << BITS(uint)) + - ((int64) fileTime.dwLowDateTime)); - - /* - * Convert from 100-nanosec units to milliseconds - */ - now = (now / 10000); - - /* - * Adjust to be seconds since Jan 1 1970. Do this to be consistent with - * UNIX but not really required by the API definition. - */ - base = ((UINT64(365) * 86400 * (1970 - 1601)) * 1000); - now -= base; - tp->sec = (uint) (now / 1000); - tp->msec = (uint) (now % 1000); - -#if UNUSED -{ - static int64 start; - - if (start == 0) { - start = now; - } - if (now < start) { - mprLog(ctx, 0, "TIME WENT BACKWARDS"); - mprLog(ctx, 0, "start %Ld", start); - mprLog(ctx, 0, "now %Ld", now); - } - mprLog(ctx, 0, "getTime %Ld", now); - start = now; -} -#endif - - return tp; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of localtime - */ - -struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now) -{ - struct tm *tbuf; - mprGlobalLock(ctx); - tbuf = localtime(now); - *timep = *tbuf; - mprGlobalUnlock(ctx); - - return timep; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of gmtime - */ - -struct tm *mprGmtime(MprCtx ctx, time_t *now, struct tm *timep) -{ - struct tm *tbuf; - tbuf = gmtime(now); - *timep = *tbuf; - - return timep; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of ctime - */ - -int mprCtime(MprCtx ctx, char *buf, int bufsize, const time_t *timer) -{ - char *cp; - int len; - - mprAssert(buf); - - mprGlobalLock(ctx); - - cp = ctime(timer); - if ((int) strlen(cp) >= bufsize) { - mprStrcpy(buf, bufsize, "WONT FIT"); - mprAssert(0); - mprGlobalUnlock(ctx); - return MPR_ERR_WONT_FIT; - } - - len = mprStrcpy(buf, bufsize, cp); - if (buf[len - 1] == '\n') { - buf[len - 1] = '\0'; - } - - mprGlobalUnlock(ctx); - - return 0; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of asctime - */ - -int mprAsctime(MprCtx ctx, char *buf, int bufsize, const struct tm *timeptr) -{ - char *cp; - - mprAssert(buf); - mprGlobalLock(ctx); - cp = asctime(timeptr); - if ((int) strlen(cp) >= bufsize) { - mprAssert(0); - mprGlobalUnlock(ctx); - return MPR_ERR_WONT_FIT; - } - mprStrcpy(buf, bufsize, cp); - mprGlobalUnlock(ctx); - - return strlen(buf); -} - -/******************************************************************************/ - -#ifdef __cplusplus -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/files b/source4/lib/appweb/ejs-2.0/mpr/files deleted file mode 100644 index 290c9ce790..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/files +++ /dev/null @@ -1,14 +0,0 @@ -${BLD_OBJ_DIR}/mpr${BLD_OBJ} -${BLD_OBJ_DIR}/mprAlloc${BLD_OBJ} -${BLD_OBJ_DIR}/mprArray${BLD_OBJ} -${BLD_OBJ_DIR}/mprBuf${BLD_OBJ} -${BLD_OBJ_DIR}/mprFile${BLD_OBJ} -${BLD_OBJ_DIR}/mprGenFile${BLD_OBJ} -${BLD_OBJ_DIR}/mprGenTime${BLD_OBJ} -${BLD_OBJ_DIR}/mprLock${BLD_OBJ} -${BLD_OBJ_DIR}/mprLog${BLD_OBJ} -${BLD_OBJ_DIR}/mprPlatform${BLD_OBJ} -${BLD_OBJ_DIR}/mprPrintf${BLD_OBJ} -${BLD_OBJ_DIR}/mprString${BLD_OBJ} -${BLD_OBJ_DIR}/mprSymbol${BLD_OBJ} -${BLD_OBJ_DIR}/mprTime${BLD_OBJ} diff --git a/source4/lib/appweb/ejs-2.0/mpr/mpr.c b/source4/lib/appweb/ejs-2.0/mpr/mpr.c deleted file mode 100644 index 163b51eccf..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mpr.c +++ /dev/null @@ -1,340 +0,0 @@ -/** - * @file mpr.c - * @brief Mpr initialization - * @overview - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ -/* - * We need to use the underlying str(cpy) routines to implement our safe - * alternatives - */ -#if !DOXYGEN -#define UNSAFE_FUNCTIONS_OK 1 -#endif - -#include "mpr.h" - -/******************************************************************************/ -/* - * Initialize the MPR. Create the top level memory context. This routine is - * the first call an MPR application must do. If using MprServices, the - * creation of an Mpr object will call this routine. - */ - -MprApp *mprInit(MprAllocCback cback) -{ - return mprInitEx(cback, 0); -} - -/******************************************************************************/ -/* - * Add a shell parameter then do the regular init - */ - -MprApp *mprInitEx(MprAllocCback cback, void *shell) -{ - MprApp *app; - - app = (MprApp*) mprAllocInit(cback); - - mprAssert(app); - if (app == 0) { - return 0; - } - - app->name = mprStrdup(app, BLD_PRODUCT); - app->title = mprStrdup(app, BLD_NAME); - app->version = mprStrdup(app, BLD_VERSION); - - mprSetShell(app, shell); - - app->table = mprCreateSymbolTable(app, 0); - - if (mprStartFileServices(app) < 0) { - mprAllocTerm(app); - return 0; - } - -#if BLD_FEATURE_MULTITHREAD - mprInitThreads(app); -#endif - - /* - * See if any of the preceeding allocations failed - */ - if (mprGetAllocErrors(app) > 0) { - mprAllocTerm(app); - return 0; - } - - /* - * Mark all blocks allocated so far as required. They will then be - * omitted from leak reports. - */ - mprSetRequiredAlloc(app, 1); - - return app; -} - -/******************************************************************************/ -/* - * Terminate the MPR. If doStats is true, then output a memory allocation - * report. - */ - -void mprTerm(MprApp *app, bool doStats) -{ -#if BLD_FEATURE_ALLOC_STATS - if (doStats) { - mprPrintAllocReport(app, 1, "MPR Memory Allocation Report"); - } -#endif - -#if BLD_FEATURE_MULTITHREAD - mprTermThreads(app); -#endif - - mprStopFileServices(app); - -#if BLD_DEBUG - mprValidateAllocTree(app); -#endif - mprAllocTerm(app); -} - -/******************************************************************************/ - -bool mprIsExiting(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - if (app == 0) { - return 1; - } - return app->flags & MPR_APP_EXITING; -} - -/******************************************************************************/ - -int mprHasAllocError(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - if (app == 0) { - return 1; - } - - return app->flags & MPR_APP_ALLOC_ERROR; -} - -/******************************************************************************/ - -void mprSignalExit(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - app->flags |= MPR_APP_EXITING; -} - -/******************************************************************************/ - -void mprSignalAllocError(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - app->flags |= MPR_APP_ALLOC_ERROR; -} - -/******************************************************************************/ - -int mprSetAppName(MprCtx ctx, const char *name, const char *title, - const char *version) -{ - MprApp *app; - - app = mprGetApp(ctx); - - if (name) { - mprFree(app->name); - if ((app->name = mprStrdup(ctx, name)) == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - } - - if (title) { - mprFree(app->title); - if ((app->title = mprStrdup(ctx, title)) == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - } - - if (version) { - mprFree(app->version); - if ((app->version = mprStrdup(ctx, version)) == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - } - return 0; -} - -/******************************************************************************/ - -const char *mprGetAppName(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - return app->name; -} - -/******************************************************************************/ - -const char *mprGetAppTitle(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - return app->title; -} - -/******************************************************************************/ - -const char *mprGetAppVersion(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - return app->version; -} - -/******************************************************************************/ - -int mprSetKeyValue(MprCtx ctx, const char *key, void *ptr) -{ - MprApp *app; - - app = mprGetApp(ctx); - if (mprInsertSymbol(app->table, key, ptr) == 0) { - return MPR_ERR_CANT_WRITE; - } - return 0; -} - -/******************************************************************************/ - -int mprRemoveKeyValue(MprCtx ctx, const char *key) -{ - MprApp *app; - - app = mprGetApp(ctx); - return mprRemoveSymbol(app->table, key); -} - -/******************************************************************************/ - -void *mprGetKeyValue(MprCtx ctx, const char *key) -{ - MprApp *app; - - app = mprGetApp(ctx); - return mprLookupSymbol(app->table, key); -} - -/******************************************************************************/ - -bool mprGetDebugMode(MprCtx ctx) -{ - return mprGetApp(ctx)->debugMode; -} - -/******************************************************************************/ - -void mprSetDebugMode(MprCtx ctx, bool on) -{ - mprGetApp(ctx)->debugMode = on; -} - -/******************************************************************************/ - -void mprSetLogHandler(MprCtx ctx, MprLogHandler handler) -{ - mprGetApp(ctx)->logHandler = handler; -} - -/******************************************************************************/ - -MprLogHandler mprGetLogHandler(MprCtx ctx) -{ - return mprGetApp(ctx)->logHandler; -} - -#if UNUSED -/******************************************************************************/ - -void mprSetMprInstance(MprCtx ctx, void *mprInstance) -{ - mprGetApp(ctx)->mprInstance = mprInstance; -} - -/******************************************************************************/ - -void *mprGetMprInstance(MprCtx ctx) -{ - return mprGetApp(ctx)->mprInstance; -} - -#endif -/******************************************************************************/ - -const char *mprCopyright() -{ - return "Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved."; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mpr.h b/source4/lib/appweb/ejs-2.0/mpr/mpr.h deleted file mode 100644 index 67505a6e01..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mpr.h +++ /dev/null @@ -1,1027 +0,0 @@ -/* - * @file mpr.h - * @brief Header for the Mbedthis Portable Runtime (MPR) Base. - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/******************************* Documentation ********************************/ -/* - * See mpr.dox for additional documentation. - */ - -/******************************************************************************/ - -#ifndef _h_MPR -#define _h_MPR 1 - -/***********************************Includes **********************************/ - -#include "mprOs.h" - -/******************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/********************************** Constants *********************************/ - -#if BLD_FEATURE_SQUEEZE -#if BREW || DOXYGEN -/* - * Maximum length of a file path name. Reduced from the system maximum to - * save memory space. - */ -#define MPR_MAX_FNAME 64 /**< Reasonable filename size */ -#define MPR_MAX_PATH 64 /**< Reasonable path name size */ -#define MPR_DEFAULT_STACK (16 * 1024) /**< Default stack size */ -#else -#define MPR_MAX_FNAME 128 /**< Reasonable filename size */ -#define MPR_MAX_PATH 256 /**< Reasonable path name size */ -#define MPR_DEFAULT_STACK (32 * 1024) /**< Default stack size */ -#endif -/* - * Reasonable length of a file name used by the product. Use where you know - * the expected file name and it is certain to be less than this limit. - */ -#define MPR_DEFAULT_ALLOC 64 /**< Default small alloc size */ -#define MPR_DEFAULT_HASH_SIZE 23 /**< Default size of hash table */ -#define MPR_MAX_ARGC 32 /**< Reasonable max of args */ -#define MPR_MAX_STRING 512 /**< Maximum (stack) string size */ -#define MPR_MAX_LOG_STRING 512 /**< Maximum log message */ -#define MPR_MAX_URL 256 /**< Reasonable size of a URL */ -#define MPR_BUFSIZE 512 /**< Reasonable size for buffers */ -#define MPR_SLAB_STR_MAX 32 /**< Size of string slab blocks */ -#define MPR_SLAB_STR_INC 32 /**< Pre-allocate increment */ -#define MPR_SLAB_DEFAULT_INC 8 /**< Default pre-allocate inc */ -#define MPR_ARRAY_INCR 8 /**< Default array growth inc */ -#define MPR_BUF_INCR 1024 /**< Default array growth inc */ -#define MPR_MAX_BUF (1024*4096) /**< Default array growth inc */ - -#define MPR_BLK_HDR_SIZE ((sizeof(struct MprBlk) + 3) & ~3) - -#else -#define MPR_MAX_FNAME 256 -#define MPR_MAX_PATH 1024 -#define MPR_DEFAULT_ALLOC 256 -#define MPR_DEFAULT_HASH_SIZE 43 -#define MPR_DEFAULT_STACK (64 * 1024) -#define MPR_MAX_ARGC 128 -#define MPR_MAX_STRING 4096 -#define MPR_MAX_LOG_STRING 8192 -#define MPR_MAX_URL 1024 -#define MPR_BUFSIZE 1024 -#define MPR_SLAB_STR_MAX 32 -#define MPR_SLAB_STR_INC 64 -#define MPR_SLAB_DEFAULT_INC 16 -#define MPR_ARRAY_INCR 16 -#define MPR_BUF_INCR 1024 -#define MPR_MAX_BUF (1024*4096) - -#define MPR_BLK_HDR_SIZE ((sizeof(struct MprBlk) + 15) & ~15) -#endif - -/** - * Maximum size of a host name string - */ -#define MPR_MAX_IP_NAME 64 - -/** - * Maximum size of an IP address - */ -#define MPR_MAX_IP_ADDR 16 - -/** - * Maximum size of an IP address including port number - */ -#define MPR_MAX_IP_ADDR_PORT 32 - -#define MPR_MAX_SLAB 16 /* Slabs from 32-512 bytes */ - -#define MPR_MAX_TIME_SYNC (10 * 1000) /* Time sync adjustments */ - -/** - * @overview Memory context type - * @description Blocks of memory are allocated using a memory context - * as the parent with the \ref MprApp structure being the root of the - * tree. Any allocated memory block may serve as the memory context for - * subsequent memory allocations. Freeing a block via \ref mprFree will - * release the allocated block and all child blocks. - * @stability Prototype. - * @library libmpr. - * @see mprInit, mprAlloc, mprFree - */ -typedef const void *MprCtx; - -/* - * Allocated memory destructor type - */ -typedef int (*MprDestructor)(void *); - -/******************************** Error Codes *********************************/ - -/* - * Standard MPR return and error codes - */ - -#define MPR_ERR_OK (0) -/**< Success */ - -#define MPR_ERR_BASE (-200) -/**< Base error code */ - -#define MPR_ERR_GENERAL (MPR_ERR_BASE - 1) -/**< General error */ -#define MPR_ERR_ABORTED (MPR_ERR_BASE - 2) -/**< Action aborted */ -#define MPR_ERR_ALREADY_EXISTS (MPR_ERR_BASE - 3) -/**< Item already exists */ -#define MPR_ERR_BAD_ARGS (MPR_ERR_BASE - 4) -/**< Bad arguments or paramaeters */ -#define MPR_ERR_BAD_FORMAT (MPR_ERR_BASE - 5) -/**< Bad input format */ -#define MPR_ERR_BAD_HANDLE (MPR_ERR_BASE - 6) -#define MPR_ERR_BAD_STATE (MPR_ERR_BASE - 7) -/**< Module is in a bad state */ -#define MPR_ERR_BAD_SYNTAX (MPR_ERR_BASE - 8) -/**< Input has bad syntax */ -#define MPR_ERR_BAD_TYPE (MPR_ERR_BASE - 9) -#define MPR_ERR_BAD_VALUE (MPR_ERR_BASE - 10) -#define MPR_ERR_BUSY (MPR_ERR_BASE - 11) -#define MPR_ERR_CANT_ACCESS (MPR_ERR_BASE - 12) -/**< Can't access the file or resource */ -#define MPR_ERR_CANT_COMPLETE (MPR_ERR_BASE - 13) -#define MPR_ERR_CANT_CREATE (MPR_ERR_BASE - 14) -/**< Can't create the file or resource */ -#define MPR_ERR_CANT_INITIALIZE (MPR_ERR_BASE - 15) -#define MPR_ERR_CANT_OPEN (MPR_ERR_BASE - 16) -/**< Can't open the file or resource */ -#define MPR_ERR_CANT_READ (MPR_ERR_BASE - 17) -/**< Can't read from the file or resource */ -#define MPR_ERR_CANT_WRITE (MPR_ERR_BASE - 18) -/**< Can't write to the file or resource */ -#define MPR_ERR_DELETED (MPR_ERR_BASE - 19) -#define MPR_ERR_NETWORK (MPR_ERR_BASE - 20) -#define MPR_ERR_NOT_FOUND (MPR_ERR_BASE - 21) -#define MPR_ERR_NOT_INITIALIZED (MPR_ERR_BASE - 22) -/**< Module or resource is not initialized */ -#define MPR_ERR_NOT_READY (MPR_ERR_BASE - 23) -#define MPR_ERR_READ_ONLY (MPR_ERR_BASE - 24) -/**< The operation timed out */ -#define MPR_ERR_TIMEOUT (MPR_ERR_BASE - 25) -#define MPR_ERR_TOO_MANY (MPR_ERR_BASE - 26) -#define MPR_ERR_WONT_FIT (MPR_ERR_BASE - 27) -#define MPR_ERR_WOULD_BLOCK (MPR_ERR_BASE - 28) -#define MPR_ERR_CANT_ALLOCATE (MPR_ERR_BASE - 29) -// MOB -- rename NO_MEMORY -#define MPR_ERR_MEMORY (MPR_ERR_BASE - 30) -#define MPR_ERR_CANT_DELETE (MPR_ERR_BASE - 31) -#define MPR_ERR_MAX (MPR_ERR_BASE - 32) - -/* - * Standard logging trace levels are 0 to 9 with 0 being the most verbose. - * the These are ored with the error source and type flags. The MPR_LOG_MASK - * is used to extract the trace level from a flags word. We expect most apps - * to run with level 2 trace enabled. - */ -#define MPR_ERROR 1 /**< Hard error trace level */ -#define MPR_WARN 2 /**< Soft warning trace level */ -#define MPR_CONFIG 2 /**< Configuration settings trace level. */ -#define MPR_INFO 3 /**< Informational trace only */ -#define MPR_DEBUG 4 /**< Debug information trace level */ -#define MPR_VERBOSE 9 /**< Highest level of trace */ -#define MPR_LEVEL_MASK 0xf /**< Level mask */ - -/* - * Error source flags - */ -#define MPR_ERROR_SRC 0x10 /**< Originated from mprError */ -#define MPR_LOG_SRC 0x20 /**< Originated from mprLog */ -#define MPR_ASSERT_SRC 0x40 /**< Originated from mprAssert */ -#define MPR_FATAL_SRC 0x80 /**< Fatal error. Log and exit */ - -/* - * Log message type flags. Specify what kind of log / error message it is. - * Listener handlers examine this flag to determine if they should process - * the message.Assert messages are trapped when in DEV mode. Otherwise ignored. - */ -#define MPR_LOG_MSG 0x100 /**< Log trace message - not an error */ -#define MPR_ERROR_MSG 0x200 /**< General error */ -#define MPR_ASSERT_MSG 0x400 /**< Assert flags -- trap in debugger */ -#define MPR_USER_MSG 0x800 /**< User message */ - -/* - * Log output modifiers - */ -#define MPR_RAW 0x1000 /**< Raw trace output */ - -/* - * Error line number information. - */ -#define MPR_LINE(s) #s -#define MPR_LINE2(s) MPR_LINE(s) -#define MPR_LINE3 MPR_LINE2(__LINE__) -#define MPR_LOC __FILE__ ":" MPR_LINE3 - -/* - * Macros to pass file and line number information - * Use MPR_LOC_ARGS in normal user code. - * Use MPR_LOC_DEC in declarations. - * Use MPR_LOC_PASS in layered APIs to pass original line info down. - */ -#if BLD_FEATURE_ALLOC_LEAK_TRACK -#define MPR_LOC_ARGS(ctx) ctx, MPR_LOC -#define MPR_LOC_DEC(ctx, loc) MprCtx ctx, const char *loc -#define MPR_LOC_PASS(ctx, loc) ctx, loc -#else -#define MPR_LOC_ARGS(ctx) ctx -#define MPR_LOC_DEC(ctx, loc) MprCtx ctx -#define MPR_LOC_PASS(ctx, loc) ctx -#endif - -/******************************* Debug and Assert *****************************/ - -extern void mprBreakpoint(const char *loc, const char *msg); - -#if BLD_FEATURE_ASSERT - #define mprAssert(C) if (C) ; else mprStaticAssert(MPR_LOC, #C) -#else - #define mprAssert(C) if (1) ; else -#endif - -/********************************* Safe Strings *******************************/ -/* - * Unsafe functions that should not be used. Define UNSAFE_STRINGS_OK before - * including mpr.h if you really want to use these functions. A better approach - * is to undefine them just prior to using them in your C/C++ source file. - */ -#if BLD_FEATURE_SAFE_STRINGS - -#if BLD_FEATURE_PHP4_MODULE || BLD_FEATURE_PHP5_MODULE - #ifndef UNSAFE_FUNCTIONS_OK - #define UNSAFE_FUNCTIONS_OK 1 - #endif -#endif - -#ifndef UNSAFE_FUNCTIONS_OK - #define sprintf UseMprSprintfInstead - #define fprintf UseMprFprintfInstead - #define vsprintf UseMprVsprintfInstead - #define strtok UseMprStrTokInstead - #define gethostbyname UseMprGetHostByNameInstead - #define ctime UseMprCtimeInstead - #define asctime UseMprAsctimeInstead - #define localtime UseMprLocaltimeInstead - #define gmtime UseMprGmtimeInstead - #define malloc UseMprMallocInstead - #define free UseMprFreeInstead - #define realloc UseMprReallocInstead - #define strncpy UseMprStrcpyInstead - #define inet_ntoa UseMprInetToStrInstead - -#if !BREW - #define printf UseMprPrintfInstead -#endif - - #if FUTURE - #define strlen UseMprStrlenInstead - #define strcpy UseMprStrcpyInstead - #endif - -#endif /* UNSAFE_FUNCTIONS_OK */ -#endif /* BLD_FEATURE_SAFE_STRINGS */ - -/******************************************************************************/ - -struct MprBuf; -typedef int (*MprBufProc)(struct MprBuf* bp, void *arg); - -/** - * @overview Dynamic buffer structure - * @description MprBuf is a flexible, dynamic growable buffer structure. It - * utilizes a ring buffer mechanism and is suitable for high performance - * buffering in a variety of situations. - * @stability Prototype. - * @library libmpr. - * @see mprCreateBuf, mprFree, MprArray - */ -typedef struct MprBuf { - uchar *buf; /* Actual buffer for data */ - uchar *endbuf; /* Pointer one past the end of buffer */ - uchar *start; /* Pointer to next data char */ - uchar *end; /* Pointer one past the last data chr */ - int buflen; /* Current size of buffer */ - int maxsize; /* Max size the buffer can ever grow */ - int growBy; /* Next growth increment to use */ - MprBufProc refillProc; /* Auto-refill procedure */ - void *refillArg; /* Refill arg */ -} MprBuf; - -/** - * @overview File structure - * @description MprFile is the cross platform File I/O abstraction control - * structure. - * @stability Prototype. - * @library libmpr. - * @see mprOpen, mprClose, mprRead, mprWrite - */ -typedef struct MprFile -{ - MprBuf *buf; /* Buffer for I/O */ -#if BREW - IFile *fd; /* File handle */ -#else - int fd; -#endif -} MprFile; - -/** - * File information structure - * @overview File information structure - * @description MprFileInfo is the cross platform File information structure. - * @stability Prototype. - * @see mprGetFileInfo, mprOpen, mprClose, mprRead, mprWrite - */ -typedef struct MprFileInfo -{ - uint size; /* File length */ - uint ctime; /* Create time */ - uint mtime; /* Modified time */ - uint inode; /* Inode number */ - int isDir; /* Set if directory */ - int isReg; /* Set if a regular file */ -} MprFileInfo; - -/** - * @overview Mpr time structure. - * @description MprTime is the cross platform time abstraction structure. - * @stability Prototype. - * @library libmpr. - * @see mprGetTime - */ -typedef struct MprTime -{ - uint sec; /* Seconds */ - uint msec; /* Milliseconds */ -} MprTime; - - -/** - * @overview Generic array type - * @description The MprArray is a dynamic growable array suitable for storing - * pointers to arbitrary objects. - * @stability Prototype. - * @library libmpr. - * @see mprCreateItemArray, mprFree, MprBuf - */ -typedef struct MprArray -{ - int capacity; /* Current capacity of the array */ - int length; /* Count of used items */ - int incr; /* Growth increment */ - int maxSize; /* Maximum capacity */ - void **items; -} MprArray; - - -#if BLD_FEATURE_MULTITHREAD -/** - * @overview Multithreading lock control structure - * @description MprLock is used for multithread locking in multithreaded - * applications. - * @library libmpr. - * @see mprCreateLock, mprDestroyLock, mprLock, mprUnlock - */ -typedef struct -{ - #if WIN - CRITICAL_SECTION cs; /* O/S critical section */ - #endif - #if LINUX || MACOSX || SOLARIS - pthread_mutex_t cs; /* O/S critical section */ - #endif - #if VXWORKS - SEM_ID cs; /* Semaphore */ - #endif -} MprLock; -#endif - -/* - * Error and Logging callback - */ -typedef void (*MprLogHandler)(MPR_LOC_DEC(ctx, loc), int flags, - int level, const char *msg); - -/* - * Symbol table - * MOB -- rename hash - */ -typedef struct MprSymbol -{ - struct MprSymbol *next; /* Next symbol in hash chain */ - char *key; /* Symbol key */ - void *data; /* Pointer to symbol data */ - int bucket; /* Hash bucket index */ -} MprSymbol; - -typedef struct MprSymbolTable -{ - MprSymbol **buckets; - int hashSize; /* Size of the buckets array */ - int count; /* Number of symbols in the table */ -} MprSymbolTable; - - -/* - * Memory allocation error callback - */ -struct MprApp; -typedef int (*MprAllocCback)(struct MprApp *app, uint size, uint total, - bool granted); - - -/* - * Slab block pointer links - */ -typedef struct MprSlabBlock { - struct MprSlabBlock *next; -} MprSlabBlock; - - -#if BLD_FEATURE_ALLOC_STATS -/* - * Memory Slab Statistics - */ -typedef struct MprSlabStats { - uint allocCount; /* Number of allocated blocks */ - uint freeCount; /* Number of blocks on the slab freelist */ - uint peakAllocCount; /* Peak allocated */ - uint totalAllocCount; /* Total count of allocation calls */ - uint peakFreeCount; /* Peak on the free list */ - MprSlabBlock *next; -} MprSlabStats; -#endif - - -/* - * Slab control structure - */ -typedef struct MprSlab { - MprSlabBlock *next; - uint preAllocateIncr; /* Pre-allocation increment */ -#if BLD_FEATURE_ALLOC_STATS - MprSlabStats stats; -#endif -} MprSlab; - -/* - * Allocation stats (kept even in production code so we can detect memory - * allocation failures) - */ -typedef struct MprAllocStats -{ - uint bytesAllocated; /* Bytes currently allocated */ - uint peakAllocated; /* Peak bytes allocated */ - uint allocCount; /* Number of allocated blocks */ - uint redLine; /* Warn above this level */ - uint maxMemory; /* Max memory to allocate */ - uint errors; /* Allocation errors */ -} MprAllocStats; - -/* - * Memory allocation control - */ - -typedef struct MprAlloc { - MprSlab *slabs; /* Array[MPR_MAX_SLAB] of MprSlab */ - MprAllocCback cback; /* Memory allocation callback */ - MprAllocStats stats; /* Keep stats even in release */ - int inAllocException; /* Recursive protect */ -} MprAlloc; - - -/* - * MprApp State Flags - */ -#define MPR_APP_EXITING 0x1 /* App is exiting */ -#define MPR_APP_ALLOC_ERROR 0x2 /* App has allocation error */ - -/* MOB -- temporary */ -#define MPR_APP_NEED_GC 0x4 /* App needs GC */ - -/** - * @overview Primary MPR application control structure - * @description The MprApp structure stores critical application state - * information and is the root memory allocation context block. It is - * used as the MprCtx context for other memory allocations and is thus - * the ultimate parent of all allocated memory. - * \n\n - * The MprApp structure is allocated by the mprInit API. - */ -typedef struct MprApp -{ - uint magic; /* Corruption protection */ - MprFile *console; /* Stdout file */ - bool debugMode; /* Run in debug mode (no timers) */ - MprFile *error; /* Stderr file */ - int logLevel; /* Log trace level */ - MprFile *logFile; /* Log file */ - MprLogHandler logHandler; /* Current log handler callback */ - MprSymbolTable *table; - char *name; /* Product name */ - char *title; /* Product title */ - char *version; /* Product version */ - -#if BREW - uint classId; /* Brew class ID */ - IShell *shell; /* Brew shell object */ - IDisplay *display; /* Brew display object */ - IFileMgr *fileMgr; /* File manager */ - ITAPI *tapi; /* TAPI object */ - int displayHeight; /* Display height */ - int displayWidth; /* Display width */ - char *args; /* Command line args */ -#endif - - void *stackStart; /* Start of app stack */ - uint maxStack; /* Max stack size recorded */ - - MprAlloc alloc; /* Memory allocation data */ - int flags; /* App state flags */ - -#if BLD_FEATURE_MULTITHREAD - MprLock *globalLock; - MprLock *allocLock; -#endif -} MprApp; - - -/* - * String type. Minimum size is 8 words (32 bytes). - */ -#define MPR_MAX_INLINE_STR 24 - - -/* - * The block header structure for all allocated memory blocks (32 bytes) - * WARNING: Don't increase the size of this structure. It just fits into - * 32 bytes currently. Alignment requirements will double this size if you - * add one byte! - */ -typedef struct MprBlk -{ - MprApp *app; /* app is the top level alloc context */ - struct MprBlk *parent; /* Parent block */ - struct MprBlk *children; /* First child block */ - struct MprBlk *next; /* Next sibling */ - struct MprBlk *prev; /* Previous sibling */ - MprDestructor destructor; /* Destructor function (optional) */ - uint size; /* Size of block sans HDR_SIZE */ - uint flags; /* Allocation flags and magic number */ -#if BLD_FEATURE_ALLOC_LEAK_TRACK - const char *location; /* Allocating code (file + line) */ -#endif -} MprBlk; - -/******************************************************************************/ -/****************************** Internal Prototypes ***************************/ -/******************************************************************************/ - -extern void mprSignalAllocError(MprCtx ctx); - -/******************************************************************************/ -/********************************** Prototypes ********************************/ -/******************************************************************************/ - -extern MprApp *mprInit(MprAllocCback cback); -extern MprApp *mprInitEx(MprAllocCback cback, void *shell); -extern void mprTerm(MprApp *app, bool doStats); -extern void mprSignalExit(MprCtx ctx); -extern bool mprIsExiting(MprCtx ctx); -extern bool mprHasAllocError(MprCtx ctx); - -#if BLD_DEBUG && UNUSED -extern MprApp *mprGetApp(MprCtx ctx); -#else -#define mprGetApp(ctx) \ - (((MprBlk*) ((char*) ctx - MPR_BLK_HDR_SIZE))->app) -#endif - -/******************************************************************************/ - -extern int mprSetKeyValue(MprCtx ctx, const char *key, void *ptr); -/* MOB -- should this be delete or remove or unset */ -extern int mprRemoveKeyValue(MprCtx ctx, const char *key); -extern void *mprGetKeyValue(MprCtx ctx, const char *key); -/* MOB -- should be setAppName, getAppName */ -extern int mprSetAppName(MprCtx ctx, const char *name, const char *title, - const char *version); -extern const char *mprGetAppName(MprCtx ctx); -extern const char *mprGetAppTitle(MprCtx ctx); -extern const char *mprGetAppVersion(MprCtx ctx); - -/* - * File services - */ -extern void mprStopFileServices(MprCtx ctx); -extern int mprStartFileServices(MprCtx ctx); - -/* - * Item Array - */ -#define mprCreateItemArray(ctx, initialSize, maxSize) \ - mprCreateItemArrayInternal(MPR_LOC_ARGS(ctx), initialSize, \ - maxSize) - -extern MprArray *mprCreateItemArrayInternal(MPR_LOC_DEC(ctx, loc), - int initialSize, int maxSize); -/* MOB -- should be insert not add/delete or insert / remove */ -extern int mprAddItem(MprArray *array, void *item); -extern void mprClearItems(MprArray *array); -extern void mprClearAndFreeItems(MprArray *array); -extern int mprFindItem(MprArray *array, void *item); -extern void *mprGetFirstItem(MprArray *array, int *lastIndex); -extern void *mprGetItem(MprArray *array, int index); -extern int mprGetItemCapacity(MprArray *array); -extern int mprGetItemCount(MprArray *array); -extern void *mprGetNextItem(MprArray *array, int *lastIndex); -extern void *mprGetPrevItem(MprArray *array, int *lastIndex); -extern int mprRemoveItem(MprArray *array, void *item); -extern int mprRemoveItemByIndex(MprArray *array, int index); -extern int mprRemoveRangeOfItems(MprArray *array, int start, int end); - - -/* - * Printf replacements - */ -extern int mprSprintf(char *buf, int maxSize, const char *fmt, ...) - PRINTF_ATTRIBUTE(3,4); -extern int mprVsprintf(char *buf, int maxSize, const char *fmt, - va_list arg) PRINTF_ATTRIBUTE(3,0); -extern char *mprItoa(char *buf, int size, int value); -extern int mprAtoi(const char *str, int radix); - -extern int mprPrintf(MprCtx ctx, const char *fmt, ...) - PRINTF_ATTRIBUTE(2,3); -/* MOB -- NEED DOC */ -extern int mprErrorPrintf(MprCtx ctx, const char *fmt, ...) - PRINTF_ATTRIBUTE(2,3); -extern int mprStaticPrintf(MprCtx ctx, const char *fmt, ...) - PRINTF_ATTRIBUTE(2,3); -extern int mprPrintfError(MprCtx ctx, const char *fmt, ...) - PRINTF_ATTRIBUTE(2,3); -extern int mprFprintf(MprFile *file, const char *fmt, ...) - PRINTF_ATTRIBUTE(2,3); - -/* - * Safe string routines - */ -extern char *mprGetWordTok(char *buf, int bufsize, const char *str, - const char *delim, const char **tok); -extern int mprMemcpy(char *dest, int destMax, const char *src, - int nbytes); -extern int mprStrcat(char *dest, int max, const char *delim, - const char *src, ...); -extern int mprStrcpy(char *dest, int destMax, const char *src); - -extern int mprStrcmpAnyCase(const char *str1, const char *str2); -extern int mprStrcmpAnyCaseCount(const char *str1, const char *str2, - int len); -extern int mprStrlen(const char *src, int max); - -extern char *mprStrLower(char *str); -extern char *mprStrUpper(char *str); -extern char *mprStrTrim(char *str, const char *set); -extern char *mprStrTok(char *str, const char *delim, char **last); - -/* - * Symbol table - */ -extern MprSymbolTable *mprCreateSymbolTable(MprCtx ctx, int hashSize); -extern MprSymbol *mprGetFirstSymbol(MprSymbolTable *table); -extern MprSymbol *mprGetNextSymbol(MprSymbolTable *table, MprSymbol *last); -extern int mprGetSymbolCount(MprSymbolTable *table); -extern MprSymbol *mprInsertSymbol(MprSymbolTable *table, const char *key, - void *ptr); -extern void *mprLookupSymbol(MprSymbolTable *table, const char *key); -extern int mprRemoveSymbol(MprSymbolTable *table, const char *key); - -/* - * File I/O support - */ -extern void mprClose(MprFile *file); -extern int mprDelete(MprCtx ctx, const char *path); -extern int mprDeleteDir(MprCtx ctx, const char *path); -extern int mprGetFileInfo(MprCtx ctx, const char *path, MprFileInfo *info); -extern char *mprGets(MprFile *file, char *buf, uint size); -extern int mprMakeDir(MprCtx ctx, const char *path, int perms); -extern MprFile *mprOpen(MprCtx ctx, const char *path, int omode, int perms); -extern int mprPuts(MprFile *file, const char *buf, uint size); -extern int mprRead(MprFile *file, void *buf, uint size); -extern int mprSeek(MprFile *file, int seekType, long distance); -extern int mprWrite(MprFile *file, const void *buf, uint count); - -extern int mprMakeTempFileName(MprCtx ctx, char *buf, int bufsize, - const char *tmpDir); - - -/* - * Error handling and logging - */ -extern void mprSetLogHandler(MprCtx ctx, MprLogHandler handler); -extern MprLogHandler mprGetLogHandler(MprCtx ctx); - -extern void mprAssertError(MPR_LOC_DEC(ctx, loc), const char *msg); -extern void mprError(MPR_LOC_DEC(ctx, loc), - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -extern void mprFatalError(MPR_LOC_DEC(ctx, loc), - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -extern void mprLog(MprCtx ctx, int level, - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -extern void mprRawLog(MprCtx ctx, const char *fmt, ...); -extern void mprStaticAssert(const char *loc, const char *msg); -extern void mprStaticError(MPR_LOC_DEC(ctx, loc), - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -extern void mprUserError(MPR_LOC_DEC(ctx, loc), - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); - -/* - * Dynamic Buffering routines - */ -extern MprBuf *mprCreateBuf(MprCtx ctx, int initialSize, int maxSize); -extern char *mprStealBuf(MprCtx ctx, MprBuf *bp); -extern void mprAddNullToBuf(MprBuf *bp); -extern void mprAdjustBufStart(MprBuf *bp, int size); -extern void mprAdjustBufEnd(MprBuf *bp, int size); -extern void mprCopyBufDown(MprBuf *bp); -extern void mprFlushBuf(MprBuf *bp); -extern int mprGetCharFromBuf(MprBuf *bp); -extern int mprGetBlockFromBuf(MprBuf *bp, uchar *buf, int len); -extern int mprGetBufLength(MprBuf *bp); -extern int mprGetBufLinearSpace(MprBuf *bp); -extern int mprGetBufLinearData(MprBuf *bp); -extern char *mprGetBufOrigin(MprBuf *bp); -extern int mprGetBufSize(MprBuf *bp); -extern int mprGetBufSpace(MprBuf *bp); -extern char *mprGetBufStart(MprBuf *bp); -extern char *mprGetBufEnd(MprBuf *bp); -extern int mprInsertCharToBuf(MprBuf *bp, int c); -extern int mprLookAtNextCharInBuf(MprBuf *bp); -extern int mprLookAtLastCharInBuf(MprBuf *bp); -extern int mprPutCharToBuf(MprBuf *bp, int c); -extern int mprPutBlockToBuf(MprBuf *bp, const char *str, int size); -extern int mprPutIntToBuf(MprBuf *bp, int i); -extern int mprPutStringToBuf(MprBuf *bp, const char *str); -extern int mprPutFmtStringToBuf(MprBuf *bp, const char *fmt, ...); -extern int mprRefillBuf(MprBuf *bp); -extern void mprResetBufIfEmpty(MprBuf *bp); -extern void mprSetBufSize(MprBuf *bp, int initialSize, int maxSize); -extern MprBufProc mprGetBufRefillProc(MprBuf *bp); -extern void mprSetBufRefillProc(MprBuf *bp, MprBufProc fn, void *arg); - -/* - * General other xPlatform routines - */ -extern const char *mprGetBaseName(const char *name); -extern bool mprGetDebugMode(MprCtx ctx); -extern char *mprGetDirName(char *buf, int bufsize, const char *path); -extern char *mprGetFullPathName(char *buf, int buflen, const char *path); -extern int mprGetLogLevel(MprCtx ctx); -extern int mprGetOsError(); - - -extern int mprMakeArgv(MprCtx ctx, const char *prog, const char *cmd, - char ***argv, int *argc); -extern int mprMakeDirPath(MprCtx ctx, const char *path); -extern void mprSetDebugMode(MprCtx ctx, bool on); -extern void mprSetLogLevel(MprCtx ctx, int level); -extern void mprSleep(MprCtx ctx, int msec); -extern void mprSetShell(MprCtx ctx, void *shell); -extern void *mprGetShell(MprCtx ctx); -extern void mprSetClassId(MprCtx ctx, uint classId); -extern uint mprGetClassId(MprCtx ctx); - -#if BREW -extern void mprSetDisplay(MprCtx ctx, void *display); -extern void *mprGetDisplay(MprCtx ctx); -extern void mprSetFileMgr(MprCtx ctx, void *fileMgr); -extern void *mprGetFileMgr(MprCtx ctx); -#else -extern char *mprInetToStr(char *buf, int size, const struct in_addr in); -#endif - -/* - * Memory allocation - */ -extern MprApp *mprAllocInit(MprAllocCback cback); -extern void mprAllocTerm(MprApp *app); -extern void mprAllocAbort(); - -extern void *mprAllocBlock(MPR_LOC_DEC(ctx, loc), uint size); -extern void *mprAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size); -extern void *mprReallocBlock(MPR_LOC_DEC(ctx, loc), void *ptr, uint size); -extern int mprFree(void *ptr); -extern int mprStealAllocBlock(MPR_LOC_DEC(ctx, loc), const void *ptr); -extern void *mprMemdupInternal(MPR_LOC_DEC(ctx, loc), const void *ptr, - uint size); -extern char *mprStrndupInternal(MPR_LOC_DEC(ctx, loc), const char *str, - uint size); -extern char *mprStrdupInternal(MPR_LOC_DEC(ctx, loc), const char *str); - -extern void *mprSlabAllocBlock(MPR_LOC_DEC(ctx, loc), uint size, uint inc); -extern void *mprSlabAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size, - uint inc); - -extern uint mprGetAllocBlockSize(MprCtx ctx); -extern uint mprGetAllocBlockCount(MprCtx ctx); -extern uint mprGetAllocBlockMemory(MprCtx ctx); -extern void *mprGetAllocParent(MprCtx ctx); -extern uint mprGetAllocatedMemory(MprCtx ctx); -extern uint mprGetPeakAllocatedMemory(MprCtx ctx); -extern uint mprGetAllocatedSlabMemory(MprCtx ctx); -extern int mprIsAllocBlockValid(MprCtx ctx); -extern int mprStackCheck(MprCtx ctx); -extern int mprStackSize(MprCtx ctx); -extern int mprGetAllocErrors(MprCtx ctx); -extern void mprClearAllocErrors(MprCtx ctx); - -extern MprDestructor mprSetDestructor(MprCtx ctx, MprDestructor destructor); -extern MprAllocCback mprSetAllocCallback(MprApp *app, MprAllocCback cback); -extern void mprSetAllocLimits(MprApp *app, uint redLine, uint maxMemory); - -#if BLD_FEATURE_ALLOC_STATS -extern MprSlabStats *mprGetSlabAllocStats(MprApp *app, int slabIndex); -extern MprAllocStats *mprGetAllocStats(MprApp *app); -extern void mprPrintAllocReport(MprApp *app, bool doBlocks, - const char *msg); -#endif - -#if BLD_DEBUG -extern int mprPrintAllocBlocks(MprCtx ctx, int indent); -extern const char *mprGetAllocLocation(MprCtx ptr); -#endif - -extern int mprValidateBlock(MprCtx ctx); -extern int mprValidateAllocTree(MprCtx ptr); -extern void mprSetRequiredAlloc(MprCtx ptr, bool recurse); - -/* - * Sprintf style allocators - */ -extern int mprAllocSprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize, - const char *fmt, ...) PRINTF_ATTRIBUTE(5,6); -extern int mprAllocVsprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize, - const char *fmt, va_list arg) PRINTF_ATTRIBUTE(5,0); -extern int mprAllocMemcpy(MPR_LOC_DEC(ctx, loc), char **dest, int destMax, - const void *src, int nbytes); -extern int mprAllocStrcat(MPR_LOC_DEC(ctx, loc), char **dest, int max, - const char *delim, const char *src, ...); -extern int mprAllocStrcpy(MPR_LOC_DEC(ctx, loc), char **dest, int max, - const char *src); -extern int mprReallocStrcat(MPR_LOC_DEC(ctx, loc), char **dest, int max, - int existingLen, const char *delim, const char *src, ...); - -/* - * MACROS: These are the convenience macros to automatically supply file - * names and line numbers when debugging. - */ -#define mprNew(ctx) new(MPR_LOC_ARGS(ctx)) - -#define mprAlloc(ctx, size) mprAllocBlock(MPR_LOC_ARGS(ctx), size) - -#define mprAllocZeroed(ctx, size) mprAllocZeroedBlock(MPR_LOC_ARGS(ctx), size) - -#define mprSlabAlloc(ctx, size, inc) \ - ((type*) mprSlabAllocBlock(MPR_LOC_ARGS(ctx), size, inc)) - -#define mprSlabAllocZeroed(ctx, size, inc) \ - ((type*) mprSlabAllocBlock(MPR_LOC_ARGS(ctx), size, inc)) - -#define mprRealloc(ctx, ptr, size) mprReallocBlock(MPR_LOC_ARGS(ctx), ptr, size) - -#define mprMemdup(ctx, ptr, size) \ - mprMemdupInternal(MPR_LOC_ARGS(ctx), ptr, size) - -#define mprStrdup(ctx, str) mprStrdupInternal(MPR_LOC_ARGS(ctx), str) - -#define mprStrndup(ctx, str, size) mprStrndupDebug(MPR_LOC_ARGS(ctx), str, size) - -/* - * Allocate type macros - */ -#define mprAllocType(ctx, type) \ - ((type*) mprAllocBlock(MPR_LOC_ARGS(ctx), sizeof(type))) - -#define mprAllocTypeZeroed(ctx, type) \ - ((type*) mprAllocZeroedBlock(MPR_LOC_ARGS(ctx), sizeof(type))) - -#define mprSlabAllocType(ctx, type, inc) \ - ((type*) mprSlabAllocBlock(MPR_LOC_ARGS(ctx), sizeof(type), inc)) - -#define mprSlabAllocTypeZeroed(ctx, type, inc) \ - ((type*) mprSlabAllocZeroedBlock(MPR_LOC_ARGS(ctx), sizeof(type), \ - inc)) - -/* - * Multithread locking - */ -#if BLD_FEATURE_MULTITHREAD -extern void mprInitThreads(MprApp *app); -extern void mprTermThreads(MprApp *app); -extern MprLock *mprCreateLock(MprCtx ctx); -extern void mprDestroyLock(MprLock *lock); -extern void mprLock(MprLock *lock); -extern int mprTryLock(MprLock *lock); -extern void mprUnlock(MprLock *lock); -extern void mprGlobalLock(MprCtx ctx); -extern void mprGlobalUnlock(MprCtx ctx); -extern int mprGetCurrentThreadID(); -#else -/* - * Disable multithreading - */ -#define mprInitThreads(ctx, app) -#define mprTermThreads(app) -#define mprCreateLock(ctx) -#define mprDestroyLock(lock) -#define mprLock(lock) -#define mprTryLock(lock) -#define mprUnlock(lock) -#define mprGlobalLock(app) -#define mprGlobalUnlock(app) -#define mprGetCurrentThreadID() -#endif - -/* - * Time - */ -extern MprTime *mprGetTime(MprCtx ctx, MprTime *tp); -extern int mprGetTimeRemaining(MprCtx ctx, MprTime mark, uint timeout); -extern int mprGetElapsedTime(MprCtx ctx, MprTime mark); -extern int mprCompareTime(MprTime *t1, MprTime *t2); -extern uint mprSubtractTime(MprTime *t1, MprTime *t2); -extern void mprAddElapsedToTime(MprTime *time, uint elapsed); - -#if !BREW -extern int mprAsctime(MprCtx ctx, char *buf, int bufsize, - const struct tm *timeptr); -extern int mprCtime(MprCtx ctx, char *buf, int bufsize, - const time_t *timer); -extern struct tm *mprLocaltime(MprCtx ctx, struct tm *timep, time_t *now); -extern struct tm *mprGmtime(MprCtx ctx, time_t* now, struct tm *timep); -extern int mprRfcTime(MprCtx ctx, char *buf, int bufsize, - const struct tm *timep); -#endif /* !BREW */ - -/* - * Host name - */ -extern struct hostent* mprGetHostByName(MprCtx ctx, const char *name); - -#if WIN -extern int mprReadRegistry(MprCtx ctx, char **buf, int max, - const char *key, const char *val); -extern int mprWriteRegistry(MprCtx ctx, const char *key, const char *name, - const char *value); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _h_MPR */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c b/source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c deleted file mode 100644 index 6fcaa63a6c..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprAlloc.c +++ /dev/null @@ -1,1775 +0,0 @@ -/** - * @file mprAlloc.c - * @brief Memory Allocation - * @overview - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************* Includes ***********************************/ - -#define UNSAFE_FUNCTIONS_OK 1 - -#include "mpr.h" - -/******************************* Local Defines ********************************/ -/* - * Set to 1 to disable slab based allocations - */ -#define NO_SLAB 0 - -/* - * Validation mode is quite slow - */ -#define VALIDATE_ALLOC 0 -#if VALIDATE_ALLOC -#define VALIDATE_BLOCK(ptr) mprValidateBlock(ptr) -#else -#define VALIDATE_BLOCK(ptr) -#endif - -/* - * Align on 4 bytes if squeeze, Otherwize on 16 bytes. - */ -#define HDR_SIZE MPR_BLK_HDR_SIZE - -#define APP_MAGIC 0xa571cb80 -#define ALLOC_MAGIC 0xe814ecc0 - -/* - * This must be at least one word to ensure that the smallest allocation is - * 4 bytes. Slab allocations need at least one word to store their next ptr. - */ -#define ALLOC_ALIGN(x) (((x)+3)&~3) -#define GET_HDR(ptr) ((MprBlk*) (((char*) (ptr)) - HDR_SIZE)) -#define GET_PTR(bp) ((void*) (((char*) (bp)) + HDR_SIZE)) -#define VALID_HDR(bp) (((bp)->flags & ~0x3F) == ALLOC_MAGIC) -#define VALID_BLK(ptr) (VALID_HDR(GET_HDR(ptr))) - -/* - * In production releases, mprAssert will compile out (not be included) - * but CHECK_HDR will remain even in production builds. - */ -#define CHECK_HDR(bp) \ - if (1) { if (! VALID_HDR(bp)) { mprAllocAbort(); } } else - -/* - * Chunk the slabs into 32 byte increments. - * This allows for allocations up to 512 bytes via slabs and maximizes - * sharing of slab allocations. - * - * Index map: - * 0 == 32 bytes - * 1 == 64 bytes - * 2 == 96 bytes - * 3 == 128 bytes - * 4 == 160 bytes - * 5 == 192 bytes - * 6 == 224 bytes - * 7 == 256 bytes - * 8 == 288 bytes - * 9 == 320 bytes - * 10 == 352 bytes - * 11 == 384 bytes - * 12 == 416 bytes - * 13 == 448 bytes - * 14 == 480 bytes - * 15 == 512 bytes - */ -#define SLAB_ALIGN(size) ((size + 31) & ~31) -#define GET_SLAB(size) (size >> 6) - -/* - * Block flags - */ -#define ALLOC_FLAGS_FREE 0x1 /* Block is free */ -#define ALLOC_FLAGS_FREEING 0x2 /* Block is being freed */ -#define ALLOC_FLAGS_SLAB_BLOCK 0x4 /* Block was allocated from slab */ -#define ALLOC_FLAGS_REQUIRED 0x8 /* Block is required by alloc */ -#define ALLOC_FLAGS_KEEP 0x10 /* Keep block - don't mprFree */ -#define ALLOC_FLAGS_DONT_OS_FREE 0x20 /* Don't return mem to O/S */ -#define ALLOC_FLAGS_IS_SLAB 0x40 /* Block is a slab */ - -#if BLD_DEBUG && !BREW -/* - * Set this address to break when this address is allocated or freed. This is - * a block address (not a user ptr). - */ -static MprBlk *stopAlloc; -#endif - -#if !BREW -static MprCtx rootCtx; /* Root context if none supplied */ -#endif - -/***************************** Forward Declarations ***************************/ - -static int mprAllocException(MPR_LOC_DEC(ptr, loc), uint size, bool granted); -static void slabFree(MprBlk *bp); -static int growSlab(MPR_LOC_DEC(ctx, loc), MprSlab *slab, uint size, uint inc); - -/******************************************************************************/ -/* - * Put first in file so it is easy to locate in a debugger - */ - -void mprBreakpoint(const char *loc, const char *msg) -{ -} - -/******************************************************************************/ -#if (WIN || BREW_SIMULATOR) && BLD_DEBUG - -int crtReportHook(int type, char *msg, int *retval) -{ - printf("%s\n", msg); - *retval = 0; - return TRUE; -} - -#endif -/******************************************************************************/ -/* - * Initialize the memory subsystem - */ - -MprApp *mprAllocInit(MprAllocCback cback) -{ - MprAllocStats *stats; - MprApp *app; - MprSlab *slab; - MprBlk *bp, *sp; - int i; - - bp = malloc(sizeof(MprApp) + HDR_SIZE); - mprAssert(bp); - if (bp == 0) { - if (cback) { - (*cback)(0, sizeof(MprApp), 0, 0); - } - return 0; - } - memset(bp, 0, sizeof(MprApp) + HDR_SIZE); - - bp->parent = bp; - bp->size = sizeof(MprApp); - bp->flags = ALLOC_MAGIC; - bp->next = bp->prev = bp; - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - bp->location = MPR_LOC; -#endif - - app = (MprApp*) GET_PTR(bp); - app->magic = APP_MAGIC; - - app->alloc.cback = cback; - app->stackStart = (void*) &app; - - bp->app = app; - - app->alloc.slabs = mprAllocZeroedBlock(MPR_LOC_PASS(app, MPR_LOC), - sizeof(MprSlab) * MPR_MAX_SLAB); - if (app->alloc.slabs == 0) { - mprFree(app); - return 0; - } - - /* - * The slab control structures must not be freed. Set keep to safeguard - * against accidents. - */ - sp = GET_HDR(app->alloc.slabs); - sp->flags |= ALLOC_FLAGS_KEEP; - - for (i = 0; i < MPR_MAX_SLAB; i++) { - /* - * This is overriden by requestors calling slabAlloc - */ - slab = &app->alloc.slabs[i]; - slab->preAllocateIncr = MPR_SLAB_DEFAULT_INC; - } - - /* - * Keep aggregated stats even in production code - */ - stats = &app->alloc.stats; - stats->bytesAllocated += sizeof(MprApp); - if (stats->bytesAllocated > stats->peakAllocated) { - stats->peakAllocated = stats->bytesAllocated; - } - stats->allocCount++; - -#if !BREW - rootCtx = app; -#endif -#if (WIN || BREW_SIMULATOR) && BLD_DEBUG - _CrtSetReportHook(crtReportHook); -#endif - return app; -} - -/******************************************************************************/ -/* - * Terminate the alloc module - */ - -void mprAllocTerm(MprApp *app) -{ - MprSlab *slabs; - MprBlk *appBlk, *slabBlk; - - /* - * Must do a carefully ordered cleanup. Need to free all children blocks - * before freeing the slab memory. Save a local pointer to the slabs. - */ - slabs = app->alloc.slabs; - - /* - * Free the app and all children. Set DONT_OS_FREE to prevent free() being - * called on app itself. We need that so we can free the slabs below. - */ - appBlk = GET_HDR(app); - appBlk->flags |= ALLOC_FLAGS_DONT_OS_FREE; - mprFree(app); - - /* - * Slabs are initially marked don't free. We must preserve them while all - * other blocks are freed. Then we clear the don't free flag and free. - * Now we don't have an app structure which is used by mprFree. We must - * fake it. - */ - slabBlk = GET_HDR(slabs); - slabBlk->flags &= ~ALLOC_FLAGS_KEEP; - mprFree(slabs); - - /* - * Now we can finally free the memory for the app structure - */ - free(appBlk); -} - -/******************************************************************************/ -/* - * Allocate a block - */ - -void *mprAllocBlock(MPR_LOC_DEC(ctx, loc), uint size) -{ - MprAllocStats *stats; - MprBlk *bp, *parent; - MprApp *app; - int diff; - - mprAssert(size > 0); - - if (ctx == 0) { -#if BREW - mprAssert(ctx); - return 0; -#else - ctx = rootCtx; -#endif - } - if (size == 0) { - size = 1; - } - - mprAssert(VALID_BLK(ctx)); - parent = GET_HDR(ctx); - mprAssert(VALID_HDR(parent)); - - CHECK_HDR(parent); - - size = ALLOC_ALIGN(size); - - app = parent->app; - - stats = &app->alloc.stats; - - mprLock(app->allocLock); - - stats->bytesAllocated += size + HDR_SIZE; - if (stats->bytesAllocated > stats->peakAllocated) { - stats->peakAllocated = stats->bytesAllocated; - } - - /* - * Prevent allocation if over the maximum - */ - if (stats->maxMemory && stats->bytesAllocated > stats->maxMemory) { - stats->bytesAllocated -= (size + HDR_SIZE); - mprUnlock(app->allocLock); - if (mprAllocException(MPR_LOC_PASS(ctx, loc), size, 0) < 0) { - return 0; - } - mprLock(app->allocLock); - } - - if ((bp = malloc(size + HDR_SIZE)) == 0) { - mprAssert(bp); - stats->errors++; - mprUnlock(app->allocLock); - mprAllocException(MPR_LOC_PASS(ctx, loc), size, 0); - return 0; - } - -#if BLD_DEBUG - memset(bp, 0xf7, size + HDR_SIZE); -#endif - -#if BLD_DEBUG && !BREW - if (bp == stopAlloc) { - mprBreakpoint(MPR_LOC, "breakOnAddr"); - } -#endif - - /* - * Warn if allocation puts us over the red line - */ - if (stats->redLine && stats->bytesAllocated > stats->redLine) { - mprUnlock(app->allocLock); - if (mprAllocException(MPR_LOC_PASS(ctx, loc), size, 1) < 0) { - return 0; - } - mprLock(app->allocLock); - } - - bp->size = size; - bp->flags = ALLOC_MAGIC; - bp->destructor = 0; - - bp->parent = parent; - - if (parent->children == 0) { - parent->children = bp; - bp->next = bp->prev = bp; - - } else { - /* - * Append to the end of the list. Preserve alloc order - */ - bp->next = parent->children; - bp->prev = parent->children->prev; - parent->children->prev->next = bp; - parent->children->prev = bp; - } - - bp->children = 0; - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - bp->location = loc; -#endif - - bp->app = parent->app; - - VALIDATE_BLOCK(GET_PTR(bp)); - - stats->allocCount++; - - /* - * Monitor stack usage - */ - diff = (int) bp->app->stackStart - (int) &stats; - if (diff < 0) { - app->maxStack -= diff; - app->stackStart = (void*) &stats; - diff = 0; - } - - if ((uint) diff > app->maxStack) { - app->maxStack = diff; - } - mprUnlock(app->allocLock); - - return GET_PTR(bp); -} - -/******************************************************************************/ -/* - * Allocate and zero a block - */ - -void *mprAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size) -{ - void *newBlock; - - MprBlk *bp; - - bp = GET_HDR(ctx); - mprAssert(VALID_BLK(ctx)); - - newBlock = mprAllocBlock(MPR_LOC_PASS(ctx, loc), size); - if (newBlock) { - memset(newBlock, 0, size); - } - return newBlock; -} - -/******************************************************************************/ -/* - * Free a block of memory. Free all children recursively. - */ - -int mprFree(void *ptr) -{ - MprAllocStats *stats; - MprBlk *bp, *parent, *cp, *firstChild, *prev; - MprApp *app; - - if (ptr == 0) { - return 0; - } - - mprAssert(VALID_BLK(ptr)); - VALIDATE_BLOCK(ptr); - - bp = GET_HDR(ptr); - -#if BLD_DEBUG && !BREW - if (bp == stopAlloc) { - mprBreakpoint(MPR_LOC, "breakOnAddr"); - } -#endif - - mprAssert(bp); - mprAssert(VALID_HDR(bp)); - - CHECK_HDR(bp); - - /* - * Test if already freed - */ - mprAssert(! (bp->flags & ALLOC_FLAGS_FREE)); - if (bp->flags & ALLOC_FLAGS_FREE) { - return 0; - } - - /* - * Return if recursive freeing or this is a permanent block - */ - app = bp->app; - mprLock(app->allocLock); - if (bp->flags & (ALLOC_FLAGS_FREEING | ALLOC_FLAGS_KEEP)) { - mprUnlock(app->allocLock); - return 0; - } - bp->flags |= ALLOC_FLAGS_FREEING; - - - /* - * Call any destructors - */ - if (bp->destructor) { - mprUnlock(app->allocLock); - if ((bp->destructor)(ptr) < 0) { - return -1; - } - mprLock(app->allocLock); - bp->destructor = 0; - } - - /* - * Free the children. Free in reverse order so firstChild is preserved - * during the list scan as an end of list marker. - */ - if ((firstChild = bp->children) != 0) { - cp = firstChild->prev; - while (cp != firstChild) { - - mprAssert(VALID_HDR(cp)); - VALIDATE_BLOCK(GET_PTR(cp)); - - prev = cp->prev; - - /* - * FUTURE - OPT. Make this inline - */ - mprFree(GET_PTR(cp)); - - cp = prev; - } - - mprFree(GET_PTR(firstChild)); - - /* - * Just for clarity - */ - bp->children = 0; - } - - parent = bp->parent; - - mprAssert(VALID_HDR(parent)); - - /* - * Unlink from the parent - */ - if (parent->children == bp) { - if (bp->next == bp) { - parent->children = 0; - } else { - parent->children = bp->next; - } - } - - /* - * Remove from the sibling chain - */ - bp->prev->next = bp->next; - bp->next->prev = bp->prev; - - bp->flags |= ALLOC_FLAGS_FREE; - - /* - * Release the memory. If from a slab, return to the slab. Otherwise, - * return to the O/S. - */ - if (bp->flags & ALLOC_FLAGS_SLAB_BLOCK) { - slabFree(bp); - - } else { - mprAssert(bp); - - /* - * Update the stats - */ - stats = &bp->app->alloc.stats; - stats->bytesAllocated -= (bp->size + HDR_SIZE); - mprAssert(stats->bytesAllocated >= 0); - - stats->allocCount--; - mprAssert(stats->allocCount >= 0); - -#if BLD_DEBUG && !BREW - if (bp == stopAlloc) { - mprBreakpoint(MPR_LOC, "breakOnAddr"); - } -#endif - - /* - * Return to the O/S - */ - if (! (bp->flags & ALLOC_FLAGS_DONT_OS_FREE)) { - free(bp); - } - } - /* OPT */ - if (app != ptr) { - mprUnlock(app->allocLock); - } - - return 0; -} - -/******************************************************************************/ -/* - * Rallocate a block - */ - -void *mprReallocBlock(MPR_LOC_DEC(ctx, loc), void *ptr, uint size) -{ - MprBlk *bp, *newbp, *firstChild, *cp; - MprApp *app; - void *newPtr; - - mprAssert(VALID_BLK(ctx)); - mprAssert(size > 0); - - if (ptr == 0) { - return mprAllocBlock(MPR_LOC_PASS(ctx, loc), size); - } - - mprAssert(VALID_BLK(ptr)); - bp = GET_HDR(ptr); - mprAssert(bp); - mprAssert(VALID_HDR(bp)); - - CHECK_HDR(bp); - - if (size < bp->size) { - return ptr; - } - - newPtr = mprAllocBlock(MPR_LOC_PASS(ctx, loc), size); - if (newPtr == 0) { - bp->flags &= ~ALLOC_FLAGS_FREE; - free(bp); - return 0; - } - - newbp = GET_HDR(newPtr); - mprAssert(newbp->size >= size); - memcpy((char*) newbp + HDR_SIZE, (char*) bp + HDR_SIZE, bp->size); - mprAssert(newbp->size >= size); - - /* - * Fix the next / prev pointers - */ - app = bp->app; - mprLock(app->allocLock); - newbp->next->prev = newbp; - newbp->prev->next = newbp; - - /* - * Need to fix the parent pointer of all children - */ - if ((firstChild = newbp->children) != 0) { - cp = firstChild; - do { - cp->parent = newbp; - cp = cp->next; - } while (cp != firstChild); - } - - /* - * May need to set the children pointer of our parent - */ - if (newbp->parent->children == bp) { - newbp->parent->children = newbp; - } - - /* - * Free the original block - */ - mprFree(ptr); - - mprUnlock(app->allocLock); - - return GET_PTR(newbp); -} - -/******************************************************************************/ -/* - * Allocate a block from a slab - */ - -void *mprSlabAllocBlock(MPR_LOC_DEC(ctx, loc), uint size, uint inc) -{ - -#if NO_SLAB - return mprAllocBlock(MPR_LOC_PASS(ctx, loc), size); -#else - - MprBlk *parent, *bp; - MprSlabBlock *sb; - MprApp *app; - MprSlab *slab; - int slabIndex; - - if (ctx == 0) { - mprAssert(ctx); - return 0; - } - - mprAssert(size > 0); - mprAssert(VALID_BLK(ctx)); - - parent = GET_HDR(ctx); - mprAssert(VALID_HDR(parent)); - - CHECK_HDR(parent); - - size = SLAB_ALIGN(size); - - app = parent->app; - mprAssert(app); - - slabIndex = GET_SLAB(size); - - if (slabIndex < 0 || slabIndex >= MPR_MAX_SLAB) { - return mprAllocBlock(MPR_LOC_PASS(ctx, loc), size); - } - - /* - * Dequeue a block from the slab. "sb" will point to the user data - * portion of the block (i.e. after the MprBlk header). Slabs must be - * allocated off the "slabs" context to ensure they don't get freed - * until after all other blocks are freed. - */ - mprLock(app->allocLock); - slab = &app->alloc.slabs[slabIndex]; - if ((sb = slab->next) == 0) { - if (growSlab(MPR_LOC_ARGS(parent->app->alloc.slabs), - slab, size, inc) < 0) { - mprUnlock(app->allocLock); - return 0; - } - sb = slab->next; - } - mprAssert(sb); - - /* - * Dequeue the block - */ - slab->next = sb->next; - -#if BLD_FEATURE_ALLOC_STATS -{ - MprSlabStats *slabStats; - /* - * Update the slab stats - */ - slabStats = &slab->stats; - slabStats->totalAllocCount++; - slabStats->freeCount--; - slabStats->allocCount++; - if (slabStats->allocCount > slabStats->peakAllocCount) { - slabStats->peakAllocCount = slabStats->allocCount; - } -} -#endif /* BLD_FEATURE_ALLOC_STATS */ - - bp = GET_HDR(sb); - -#if BLD_DEBUG && !BREW - if (bp == stopAlloc) { - mprBreakpoint(MPR_LOC, "breakOnAddr"); - } -#endif - - bp->size = size; - bp->flags = ALLOC_MAGIC | ALLOC_FLAGS_SLAB_BLOCK; - bp->destructor = 0; - - bp->parent = parent; - - if (parent->children == 0) { - parent->children = bp; - bp->next = bp->prev = bp; - - } else { - /* - * Append to the end of the list. Preserve alloc order - */ - bp->next = parent->children; - bp->prev = parent->children->prev; - parent->children->prev->next = bp; - parent->children->prev = bp; - } - - bp->children = 0; - - bp->app = app; - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - bp->location = loc; -#endif - mprUnlock(app->allocLock); - - return GET_PTR(bp); -#endif -} - -/******************************************************************************/ -/* - * Return a block back to its slab - */ - -static void slabFree(MprBlk *bp) -{ - MprSlab *slab; - MprApp *app; - void *ptr; - int slabIndex; - - mprAssert(VALID_HDR(bp)); - - slabIndex = GET_SLAB(bp->size); - mprAssert(0 <= slabIndex && slabIndex < MPR_MAX_SLAB); - - if (0 <= slabIndex && slabIndex < MPR_MAX_SLAB) { - mprLock(bp->app->allocLock); - slab = &bp->app->alloc.slabs[slabIndex]; - app = bp->app; - -#if BLD_DEBUG - memset(bp, 0xfc, bp->size + HDR_SIZE); -#endif - - ptr = GET_PTR(bp); - ((MprSlabBlock*) ptr)->next = slab->next; - slab->next = ((MprSlabBlock*) ptr); - -#if BLD_FEATURE_ALLOC_STATS -{ - MprSlabStats *slabStats; - slabStats = &slab->stats; - - slabStats->freeCount++; - slabStats->allocCount--; - - if (slabStats->freeCount >= slabStats->peakFreeCount) { - slabStats->peakFreeCount = slabStats->freeCount; - } -} -#endif - mprUnlock(app->allocLock); - } -} - -/******************************************************************************/ -/* - * Grow the slab and return the next free block - * Must be called locked. - */ - -static int growSlab(MPR_LOC_DEC(ctx, loc), MprSlab *slab, uint size, uint inc) -{ - MprBlk *bp; - MprSlabBlock *sb; - int i, chunkSize, len; - - mprAssert(VALID_BLK(ctx)); - mprAssert(slab); - mprAssert(size > 0); - - /* - * Take the maximum requested by anyone - */ - slab->preAllocateIncr = max(slab->preAllocateIncr, inc); - - /* - * We allocate an array of blocks each of user "size" bytes. - */ - chunkSize = HDR_SIZE + size; - len = chunkSize * slab->preAllocateIncr; - bp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), len); - -#if BLD_DEBUG - memset(bp, 0xf1, len); -#endif - - if (bp == 0) { - mprAssert(0); - return MPR_ERR_MEMORY; - } - bp->flags |= ALLOC_FLAGS_IS_SLAB; - - /* - * We store the slab information in the user data portion - */ - sb = (MprSlabBlock*) GET_PTR(bp); - - - sb = (MprSlabBlock*) ((char*) sb + len - chunkSize); - for (i = slab->preAllocateIncr - 1; i >= 0; i--) { - sb->next = slab->next; - slab->next = sb; - sb = (MprSlabBlock*) ((char*) sb - chunkSize); - } - -#if BLD_FEATURE_ALLOC_STATS -{ - MprSlabStats *stats; - stats = &slab->stats; - stats->freeCount += slab->preAllocateIncr; - if (stats->freeCount > stats->peakFreeCount) { - stats->peakFreeCount = stats->freeCount; - } -} -#endif - - return 0; -} - -/******************************************************************************/ -/* - * Set the pre-allocate amount - */ - -int mprSetSlabPreAllocate(MprCtx ctx, int slabIndex, int preAllocateIncr) -{ - MprApp *app; - MprSlab *slab; - - mprAssert(VALID_BLK(ctx)); - mprAssert(0 <= slabIndex && slabIndex < MPR_MAX_SLAB); - mprAssert(preAllocateIncr > 0); - - if (0 <= slabIndex && slabIndex < MPR_MAX_SLAB) { - app = mprGetApp(ctx); - slab = &app->alloc.slabs[slabIndex]; - slab->preAllocateIncr = preAllocateIncr; - } else { - return MPR_ERR_BAD_ARGS; - } - return 0; -} - -/******************************************************************************/ - -void *mprSlabAllocZeroedBlock(MPR_LOC_DEC(ctx, loc), uint size, uint inc) -{ - void *newBlock; - - mprAssert(VALID_BLK(ctx)); - mprAssert(size > 0); - - newBlock = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), size, inc); - if (newBlock) { - memset(newBlock, 0, size); - } - return newBlock; -} - -/******************************************************************************/ -/* - * Internal strdup function. Will use the slab allocator for small strings - */ - -char *mprStrdupInternal(MPR_LOC_DEC(ctx, loc), const char *str) -{ - char *newp; - int len; - - mprAssert(VALID_BLK(ctx)); - - if (str == 0) { - str = ""; - } - - len = strlen(str) + 1; - - if (len < MPR_SLAB_STR_MAX) { - newp = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), MPR_SLAB_STR_MAX, - MPR_SLAB_STR_INC); - } else { - newp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), len); - } - - if (newp) { - memcpy(newp, str, len); - } - - return newp; -} - -/******************************************************************************/ -/* - * Internal strndup function. Will use the slab allocator for small strings - */ - -char *mprStrndupInternal(MPR_LOC_DEC(ctx, loc), const char *str, uint size) -{ - char *newp; - uint len; - - mprAssert(VALID_BLK(ctx)); - - if (str == 0) { - str = ""; - } - len = strlen(str) + 1; - len = min(len, size); - - if (len < MPR_SLAB_STR_MAX) { - newp = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), MPR_SLAB_STR_MAX, - MPR_SLAB_STR_INC); - } else { - newp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), len); - } - - if (newp) { - memcpy(newp, str, len); - } - - return newp; -} - -/******************************************************************************/ -/* - * Internal memcpy function. Will use the slab allocator for small strings - */ - -void *mprMemdupInternal(MPR_LOC_DEC(ctx, loc), const void *ptr, uint size) -{ - char *newp; - - mprAssert(VALID_BLK(ctx)); - - if (size < MPR_SLAB_STR_MAX) { - newp = mprSlabAllocBlock(MPR_LOC_PASS(ctx, loc), MPR_SLAB_STR_MAX, - MPR_SLAB_STR_INC); - } else { - newp = mprAllocBlock(MPR_LOC_PASS(ctx, loc), size); - } - - if (newp) { - memcpy(newp, ptr, size); - } - - return newp; -} - -/******************************************************************************/ -/* - * Steal a block from one context and insert in another - */ - -int mprStealAllocBlock(MPR_LOC_DEC(ctx, loc), const void *ptr) -{ - MprBlk *bp, *parent; - - if (ptr == 0) { - return 0; - } - - mprAssert(VALID_BLK(ctx)); - mprAssert(VALID_BLK(ptr)); - - bp = GET_HDR(ptr); - -#if BLD_DEBUG && !BREW - if (bp == stopAlloc) { - mprBreakpoint(MPR_LOC, "breakOnAddr"); - } -#endif - - mprAssert(bp); - mprAssert(VALID_HDR(bp)); - mprAssert(ptr != mprGetAllocParent(ptr)); - - CHECK_HDR(bp); - - mprAssert(bp->prev); - mprAssert(bp->prev->next); - mprAssert(bp->next); - mprAssert(bp->next->prev); - - parent = bp->parent; - mprAssert(VALID_HDR(parent)); - - mprLock(bp->app->allocLock); - if (parent->children == bp) { - if (bp->next == bp) { - parent->children = 0; - } else { - parent->children = bp->next; - } - } - - bp->prev->next = bp->next; - bp->next->prev = bp->prev; - - parent = GET_HDR(ctx); - mprAssert(VALID_HDR(parent)); - bp->parent = parent; - - if (parent->children == 0) { - parent->children = bp; - bp->next = bp->prev = bp; - - } else { - bp->next = parent->children; - bp->prev = parent->children->prev; - parent->children->prev->next = bp; - parent->children->prev = bp; - } - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - bp->location = loc; -#endif - - VALIDATE_BLOCK(GET_PTR(bp)); - - mprUnlock(bp->app->allocLock); - - return 0; -} - -/******************************************************************************/ - -void mprSetRequiredAlloc(MprCtx ptr, bool recurse) -{ - MprBlk *bp, *firstChild, *cp; - - bp = GET_HDR(ptr); - - bp->flags |= ALLOC_FLAGS_REQUIRED; - - if (recurse && (firstChild = bp->children) != 0) { - cp = firstChild; - do { - mprSetRequiredAlloc(GET_PTR(cp), recurse); - cp = cp->next; - } while (cp != firstChild); - } -} - -/******************************************************************************/ -/* - * Monitor stack usage. Return true if the stack has grown - */ - -int mprStackCheck(MprCtx ptr) -{ - MprApp *app; - int size; - - mprAssert(VALID_BLK(ptr)); - - app = mprGetApp(ptr); - - size = (int) app->stackStart - (int) &app; - if (size < 0) { - app->maxStack -= size; - app->stackStart = (void*) &app; - size = 0; - } - if ((uint) size > app->maxStack) { - app->maxStack = size; - return 1; - } - return 0; -} - -/******************************************************************************/ -/* - * Return the stack size - */ - -int mprStackSize(MprCtx ptr) -{ - MprApp *app; - - mprAssert(VALID_BLK(ptr)); - - app = mprGetApp(ptr); - return app->maxStack; -} - -/******************************************************************************/ - -static int mprAllocException(MPR_LOC_DEC(ctx, loc), uint size, bool granted) -{ - MprApp *app; - MprAlloc *alloc; - int rc; - - mprAssert(VALID_BLK(ctx)); - - app = mprGetApp(ctx); - alloc = &app->alloc; - - if (alloc->cback == 0) { - return 0; - } - - mprLock(app->allocLock); - if (alloc->inAllocException == 0) { - alloc->inAllocException = 1; - mprUnlock(app->allocLock); - - rc = (alloc->cback)(app, size, alloc->stats.bytesAllocated, granted); - - mprLock(app->allocLock); - app->alloc.inAllocException = 0; - mprUnlock(app->allocLock); - - return rc; - } - return 0; -} - -/******************************************************************************/ - -void mprSetAllocLimits(MprApp *app, uint redLine, uint maxMemory) -{ - app->alloc.stats.redLine = redLine; - app->alloc.stats.maxMemory = maxMemory; -} - -/******************************************************************************/ - -MprAllocCback mprSetAllocCallback(MprApp *app, MprAllocCback cback) -{ - MprAllocCback old; - - mprAssert(app); - mprAssert(VALID_BLK(app)); - - old = app->alloc.cback; - app->alloc.cback = cback; - return old; -} - -/******************************************************************************/ - -uint mprGetAllocBlockSize(MprCtx ptr) -{ - MprBlk *bp; - - mprAssert(VALID_BLK(ptr)); - - if (ptr == 0) { - return 0; - } - - bp = GET_HDR(ptr); - mprAssert(VALID_HDR(bp)); - - CHECK_HDR(bp); - - return bp->size; -} - -/******************************************************************************/ -/* - * Return the total block count used by a block including all children - */ - -uint mprGetAllocBlockCount(MprCtx ptr) -{ - MprBlk *bp, *firstChild, *cp; - uint count; - - mprAssert(VALID_BLK(ptr)); - - if (ptr == 0) { - return 0; - } - - bp = GET_HDR(ptr); - mprAssert(VALID_HDR(bp)); - - /* - * Add one for itself - */ - count = 1; - if ((firstChild = bp->children) != 0) { - cp = firstChild; - do { - count += mprGetAllocBlockCount(GET_PTR(cp)); - cp = cp->next; - } while (cp != firstChild); - } - return count; -} - -/******************************************************************************/ -/* - * Return the total of all memory allocated including slabs - */ - -uint mprGetAllocBlockMemory(MprCtx ptr) -{ - MprBlk *bp, *firstChild, *cp; - uint count; - - mprAssert(VALID_BLK(ptr)); - - if (ptr == 0) { - return 0; - } - - bp = GET_HDR(ptr); - mprAssert(VALID_HDR(bp)); - - count = bp->size + HDR_SIZE; - if ((firstChild = bp->children) != 0) { - cp = firstChild; - do { - count += mprGetAllocBlockMemory(GET_PTR(cp)); - cp = cp->next; - } while (cp != firstChild); - } - return count; -} - -/******************************************************************************/ -#if BLD_FEATURE_ALLOC_LEAK_TRACK - -const char *mprGetAllocLocation(MprCtx ptr) -{ - MprBlk *bp; - - if (ptr == 0) { - return 0; - } - mprAssert(VALID_BLK(ptr)); - - bp = GET_HDR(ptr); - mprAssert(VALID_HDR(bp)); - return bp->location; -} - -#endif -/******************************************************************************/ - -void *mprGetAllocParent(MprCtx ptr) -{ - MprBlk *bp; - - mprAssert(VALID_BLK(ptr)); - - if (ptr == 0) { - return 0; - } - - bp = GET_HDR(ptr); - mprAssert(VALID_HDR(bp)); - - CHECK_HDR(bp); - - return GET_PTR(bp->parent); -} - -/******************************************************************************/ - -MprAllocStats *mprGetAllocStats(MprApp *app) -{ - mprAssert(VALID_BLK(app)); - - return &app->alloc.stats; -} - -/******************************************************************************/ -#if BLD_FEATURE_ALLOC_STATS - -MprSlabStats *mprGetSlabAllocStats(MprApp *app, int slabIndex) -{ - MprSlab *slab; - - mprAssert(VALID_BLK(app)); - - if (0 <= slabIndex && slabIndex < MPR_MAX_SLAB) { - slab = &app->alloc.slabs[slabIndex]; - return &slab->stats; - } - - mprAssert(0 <= slabIndex && slabIndex < MPR_MAX_SLAB); - return 0; -} - -#endif /* BLD_FEATURE_ALLOC_STATS */ -/******************************************************************************/ -#if BLD_DEBUG - -int mprPrintAllocBlocks(MprCtx ptr, int indent) -{ - MprBlk *bp, *firstChild, *cp; - const char *location; - int subTotal, size, indentSpaces, code; - - subTotal = 0; - - bp = GET_HDR(ptr); - - if (! (bp->flags & ALLOC_FLAGS_REQUIRED)) { - size = bp->size + HDR_SIZE; - - /* - * Take one level off because we don't trace app - */ - indentSpaces = indent; - - if (bp->flags & ALLOC_FLAGS_REQUIRED) { - code = 'R'; - } else if (bp->flags & ALLOC_FLAGS_IS_SLAB) { - code = 'S'; - } else { - code = ' '; - } - -#if BLD_FEATURE_ALLOC_LEAK_TRACK - location = bp->location; -#else - location = ""; -#endif - mprLog(bp->app, 0, - "%c %.*s %-16s %.*s size %5d has %3d deps, total %6d", code, - indentSpaces, " ", - mprGetBaseName(location), - 8 - indent, " ", - size, - mprGetAllocBlockCount(GET_PTR(bp)), - mprGetAllocBlockMemory(GET_PTR(bp)) - /* (uint) bp */ - ); - - subTotal += size; - } - - if ((firstChild = bp->children) != 0) { - cp = firstChild; - do { - subTotal += mprPrintAllocBlocks(GET_PTR(cp), indent + 2); - cp = cp->next; - } while (cp != firstChild); - } - - return subTotal; -} - -#endif -/******************************************************************************/ -#if BLD_FEATURE_ALLOC_STATS -/* - * Print a memory allocation report that includes a list of allocated blocks - * and a statistics summary - */ - -void mprPrintAllocReport(MprApp *app, bool printBlocks, const char *msg) -{ - MprSlabStats *stats; - uint total; - int i, size; - - mprAssert(VALID_BLK(app)); - - if (msg) { - mprLog(app, 0, " "); - mprLog(app, 0, "%s", msg); - } - -#if BLD_DEBUG - /* - * Do block stats - */ - if (printBlocks) { - int sum; - mprLog(app, 0, " "); - sum = mprPrintAllocBlocks(app, 0); - if (sum) { - mprLog(app, 0, " Sum of blocks %d", sum); - } else { - mprLog(app, 0, " None"); - } - } -#endif - - /* - * Do Slab stats - */ - mprLog(app, 0, " "); - mprLog(app, 0, "MPR Slab Memory Stats"); - mprLog(app, 0, " "); - - mprLog(app, 0, - " Index Size Total Allocated Free PeakAlloc PeakFree TotalAlloc"); - - total = 0; - for (i = 0; i < MPR_MAX_SLAB; i++) { - stats = &app->alloc.slabs[i].stats; - size = 1 << (i + 5); - if (stats->totalAllocCount > 0) { - mprLog(app, 0, " %2d %6d %8d %9d %6d %9d %8d %10d", - i, size, size * (stats->allocCount + stats->freeCount), - stats->allocCount, stats->freeCount, - stats->peakAllocCount, stats->peakFreeCount, - stats->totalAllocCount); - total += size * (stats->allocCount + stats->freeCount); - } - } - mprLog(app, 0, " "); - mprLog(app, 0, "MPR Total Allocated Slab RAM: %10d", total); - mprLog(app, 0, "MPR Total Allocated RAM: %10d", - mprGetAllocatedMemory(app)); - mprLog(app, 0, "MPR Peak Allocated RAM: %10d", - mprGetPeakAllocatedMemory(app)); - mprLog(app, 0, " "); -} - -/******************************************************************************/ -/* - * Return the total memory allocated. - */ - -uint mprGetAllocatedMemory(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - - return app->alloc.stats.bytesAllocated; -} - -/******************************************************************************/ -/* - * Return the peak memory allocated. - */ - -uint mprGetPeakAllocatedMemory(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - - return app->alloc.stats.peakAllocated; -} - -/******************************************************************************/ -/* - * Return memory in the MPR slab. This excludes the EJS slabs - */ - -uint mprGetAllocatedSlabMemory(MprCtx ctx) -{ - MprApp *app; - MprSlabStats *stats; - uint total; - int i, size; - - app = mprGetApp(ctx); - - total = 0; - for (i = 0; i < MPR_MAX_SLAB; i++) { - stats = &app->alloc.slabs[i].stats; - size = 1 << (i + 5); - if (stats->totalAllocCount > 0) { - total += size * (stats->allocCount + stats->freeCount); - } - } - return total; -} - -#endif /* BLD_FEATURE_ALLOC_STATS */ -/******************************************************************************/ - -MprDestructor mprSetDestructor(MprCtx ptr, MprDestructor destructor) -{ - MprDestructor old; - MprBlk *bp; - - mprAssert(VALID_BLK(ptr)); - - if (ptr == 0) { - return 0; - } - - bp = GET_HDR(ptr); - - mprAssert(bp); - mprAssert(VALID_HDR(bp)); - mprAssert(ptr != mprGetAllocParent(ptr)); - - CHECK_HDR(bp); - - old = bp->destructor; - bp->destructor = destructor; - - return old; -} - -/******************************************************************************/ - -int mprIsAllocBlockValid(MprCtx ptr) -{ - MprBlk *bp; - - bp = GET_HDR(ptr); - return (bp && VALID_HDR(bp)); -} - -/******************************************************************************/ -#if VALIDATE_ALLOC -/* - * Exhaustive validation of the block and its children. Does not go recursive - * as it would be too slow. - */ - -int mprValidateBlock(MprCtx ptr) -{ - MprBlk *bp, *parent, *cp, *firstChild; - int count; - - mprAssert(ptr); - mprAssert(VALID_BLK(ptr)); - - bp = GET_HDR(ptr); - - mprAssert(bp); - mprAssert(VALID_HDR(bp)); - mprAssert(VALID_HDR(bp->parent)); - - if (ptr != bp->app) { - mprAssert(bp != bp->parent); - } - mprAssert(! (bp->flags & ALLOC_FLAGS_FREE)); - mprAssert(! (bp->flags & ALLOC_FLAGS_FREEING)); - - /* - * - */ - count = 0; - parent = bp->parent; - - if ((firstChild = bp->children) != 0) { - cp = firstChild; - mprAssert((int) cp != 0xfeefee); - do { - mprAssert(bp->next->prev == bp); - mprAssert(bp->prev->next == bp); - mprAssert(bp->prev->parent == parent); - mprAssert(bp->next->parent == parent); - - count++; - cp = cp->next; - - if (bp->next == bp) { - mprAssert(bp->prev == bp); - if (ptr != bp->app) { - mprAssert(parent->children == bp); - } - } - if (bp->prev == bp) { - mprAssert(bp->next == bp); - if (ptr != bp->app) { - mprAssert(parent->children == bp); - } - } - } while (cp != firstChild); - } - - return 0; -} - -#endif -/******************************************************************************/ -/* - * Validate a block and all children - */ - -int mprValidateAllocTree(MprCtx ptr) -{ -#if VALIDATE_ALLOC - MprBlk *bp, *cp, *firstChild; - - mprAssert(ptr); - mprAssert(VALID_BLK(ptr)); - - bp = GET_HDR(ptr); - - mprValidateBlock(GET_PTR(bp)); - - if ((firstChild = bp->children) != 0) { - cp = firstChild; - do { - mprValidateAllocTree(GET_PTR(cp)); - cp = cp->next; - } while (cp != firstChild); - } - -#endif - return 0; -} - -/******************************************************************************/ -#if UNUSED && FUTURE -/* - * Exhaustive validation of the block and its children. Does not go recursive - * as it would be too slow. - */ - -int mprValidateSlabs(MprApp *app) -{ - MprSlab *slab; - MprSlabStats *slabStats; - MprSlabBlock *sp; - int count, i; - - for (i = 0; i < MPR_MAX_SLAB; i++) { - slab = &app->alloc.slabs[i]; - slabStats = &slab->stats; - - count = 0; - for (sp = slab->next; sp; sp = sp->next) { - count++; - } - mprAssert(count == (int) slabStats->freeCount); - } - return 0; -} - -#endif -/******************************************************************************/ - -void mprAllocAbort() -{ -#if BREW - printf("Bad block header"); -#else - exit(255); -#endif -} - -/******************************************************************************/ -#undef mprGetApp -/* - * Get the root parent from any block (which is the MprApp structure) - */ - -MprApp *mprGetApp(MprCtx ptr) -{ - MprBlk *bp; - - mprAssert(ptr); - - bp = GET_HDR(ptr); - mprAssert(VALID_HDR(bp)); - - CHECK_HDR(bp); - - mprAssert(bp->app->magic == APP_MAGIC); - - return bp->app; -} - -/******************************************************************************/ - -int mprGetAllocErrors(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - return app->alloc.stats.errors; -} - -/******************************************************************************/ - -void mprClearAllocErrors(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - app->alloc.stats.errors = 0; -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprArray.c b/source4/lib/appweb/ejs-2.0/mpr/mprArray.c deleted file mode 100644 index 95b0a14450..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprArray.c +++ /dev/null @@ -1,385 +0,0 @@ -/** - * @file mprArray.c - * @brief Growable array structure - * @overview Simple growable array structure. - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "mpr.h" - -/******************************************************************************/ -/* - * Create a general growable array structure. Use mprFree to destroy. - */ - -MprArray *mprCreateItemArrayInternal(MPR_LOC_DEC(ctx, loc), int initialSize, - int maxSize) -{ - MprArray *array; - int size; - - mprAssert(initialSize <= maxSize); - - array = (MprArray*) mprSlabAllocZeroedBlock(MPR_LOC_PASS(ctx, loc), - sizeof(MprArray), 0); - if (array == 0) { - return 0; - } - - if (initialSize == 0) { - initialSize = MPR_ARRAY_INCR; - } - if (maxSize == 0) { - maxSize = MAXINT; - } - size = initialSize * sizeof(void*); - - array->items = (void**) mprSlabAllocBlock(MPR_LOC_PASS(array, loc), - size, 0); - - if (array->items == 0) { - mprFree(array); - return 0; - } - - array->capacity = initialSize; - array->maxSize = maxSize; - array->incr = min(initialSize * 2, (array->maxSize - array->length)); - array->length = 0; - - return array; -} - -/******************************************************************************/ -/* - * Add an item to the array - */ - -int mprAddItem(MprArray *array, void *item) -{ - int memsize, index, len; - - mprAssert(array); - mprAssert(array->capacity >= 0); - mprAssert(array->length >= 0); - - if (array->length < array->capacity) { - /* - * Room to fit in the current capacity - */ - index = array->length++; - array->items[index] = item; - return index; - } - mprAssert(array->length == array->capacity); - - /* - * Need to grow the array - */ - if (array->capacity >= array->maxSize) { - mprAssert(array->capacity < array->maxSize); - return MPR_ERR_TOO_MANY; - } - - len = array->capacity + array->incr; - memsize = len * sizeof(void*); - - /* - * Grow the array of items - */ - - array->items = (void**) mprRealloc(array, array->items, memsize); - - /* - * Zero the new portion - */ - memset(&array->items[array->capacity], 0, sizeof(void*) * array->incr); - array->capacity = len; - - array->incr = min(array->incr * 2, (array->maxSize - array->length)); - - index = array->length++; - array->items[index] = item; - - return index; -} - -/******************************************************************************/ -/* - * Remove an item from the array - */ - -int mprRemoveItem(MprArray *array, void *item) -{ - int index; - - mprAssert(array); - mprAssert(array->capacity > 0); - mprAssert(array->length > 0); - - index = mprFindItem(array, item); - if (index < 0) { - return index; - } - - return mprRemoveItemByIndex(array, index); -} - -/******************************************************************************/ -/* - * Remove an index from the array - */ - -int mprRemoveItemByIndex(MprArray *array, int index) -{ - void **items; - int i; - - mprAssert(array); - mprAssert(array->capacity > 0); - mprAssert(index >= 0 && index < array->capacity); - mprAssert(array->items[index] != 0); - mprAssert(array->length > 0); - - if (index < 0 || index >= array->length) { - return MPR_ERR_NOT_FOUND; - } - - /* - * Copy down to compress - */ - items = array->items; - for (i = index; i < (array->length - 1); i++) { - items[i] = items[i + 1]; - } - array->length--; - -#if BLD_DEBUG - if (array->length < array->capacity) { - items[array->length] = 0; - } -#endif - return 0; -} - -/******************************************************************************/ - -int mprRemoveRangeOfItems(MprArray *array, int start, int end) -{ - void **items; - int i, count; - - mprAssert(array); - mprAssert(array->capacity > 0); - mprAssert(array->length > 0); - mprAssert(start > end); - - if (start < 0 || start >= array->length) { - return MPR_ERR_NOT_FOUND; - } - if (end < 0 || end >= array->length) { - return MPR_ERR_NOT_FOUND; - } - if (start > end) { - return MPR_ERR_BAD_ARGS; - } - - /* - * Copy down to compress - */ - items = array->items; - count = end - start; - for (i = start; i < (array->length - count); i++) { - items[i] = items[i + count]; - } - array->length -= count; - -#if BLD_DEBUG - if (array->length < array->capacity) { - for (i = array->length; i < array->capacity; i++) { - items[i] = 0; - } - } -#endif - return 0; -} - -/******************************************************************************/ - -void *mprGetItem(MprArray *array, int index) -{ - mprAssert(array); - - if (index < 0 || index >= array->length) { - return 0; - } - return array->items[index]; -} - -/******************************************************************************/ - -void *mprGetFirstItem(MprArray *array, int *last) -{ - mprAssert(array); - mprAssert(last); - - if (array == 0) { - return 0; - } - - *last = 0; - - if (array->length == 0) { - return 0; - } - return array->items[0]; -} - -/******************************************************************************/ - -void *mprGetNextItem(MprArray *array, int *last) -{ - int index; - - mprAssert(array); - mprAssert(last); - mprAssert(*last >= 0); - - index = *last; - - if (++index < array->length) { - *last = index; - return array->items[index]; - } - return 0; -} - -/******************************************************************************/ - -void *mprGetPrevItem(MprArray *array, int *last) -{ - int index; - - mprAssert(array); - mprAssert(last); - mprAssert(*last >= 0); - - if (array == 0) { - return 0; - } - - index = *last; - - if (--index < array->length && index >= 0) { - *last = index; - return array->items[index]; - } - return 0; -} - -/******************************************************************************/ - -int mprGetItemCount(MprArray *array) -{ - mprAssert(array); - - if (array == 0) { - return 0; - } - - return array->length; -} - -/******************************************************************************/ - -int mprGetItemCapacity(MprArray *array) -{ - mprAssert(array); - - if (array == 0) { - return 0; - } - - return array->capacity; -} - -/******************************************************************************/ - -void mprClearAndFreeItems(MprArray *array) -{ - int i; - - mprAssert(array); - - for (i = 0; i < array->length; i++) { - mprFree(array->items[i]); - } -} - -/******************************************************************************/ - -void mprClearItems(MprArray *array) -{ - mprAssert(array); - - array->length = 0; -} - -/******************************************************************************/ - -int mprFindItem(MprArray *array, void *item) -{ - int i; - - mprAssert(array); - - for (i = 0; i < array->length; i++) { - if (array->items[i] == item) { - return i; - } - } - return MPR_ERR_NOT_FOUND; -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprBuf.c b/source4/lib/appweb/ejs-2.0/mpr/mprBuf.c deleted file mode 100644 index ba9888a9fc..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprBuf.c +++ /dev/null @@ -1,535 +0,0 @@ -/** - * @file mprBuf.c - * @brief Dynamic buffer module - * @overview - * @remarks - */ - -/******************************************************************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - - -/********************************** Includes **********************************/ - -#include "mpr.h" - -/**************************** Forward Declarations ****************************/ - -static int grow(MprBuf *bp); - -/*********************************** Code *************************************/ -/* - * Create a new buffer. "maxsize" is the limit to which the buffer can - * ever grow. -1 means no limit. The buffer can ever only fix maxsize-1 bytes. - * "initialSize" is used to define the amount to increase the size of the - * buffer each time if it becomes full. (Note: grow() will exponentially - * increase this number for performance.) - */ - -MprBuf *mprCreateBuf(MprCtx ctx, int initialSize, int maxSize) -{ - MprBuf *bp; - - if (initialSize <= 0) { - initialSize = MPR_DEFAULT_ALLOC; - } - bp = mprAllocTypeZeroed(ctx, MprBuf); - bp->growBy = MPR_BUFSIZE; - bp->maxsize = 0; - mprSetBufSize(bp, initialSize, maxSize); - return bp; -} - -/******************************************************************************/ -/* - * Set the initial buffer parameters and create the first buffer - */ - -void mprSetBufSize(MprBuf *bp, int initialSize, int max) -{ - mprAssert(initialSize > 0); - - if (max > 0 && initialSize > max) { - initialSize = max; - } - - if (bp->buf && bp->growBy > 0) { - mprFree(bp->buf); - } - - bp->buf = (uchar*) mprAlloc(bp, initialSize); - bp->growBy = initialSize; - bp->maxsize = max; - bp->buflen = initialSize; - bp->endbuf = &bp->buf[bp->buflen]; - bp->start = bp->buf; - bp->end = bp->buf; - *bp->start = '\0'; -} - -/******************************************************************************/ - -char *mprStealBuf(MprCtx ctx, MprBuf *bp) -{ - char *str; - - str = (char*) bp->start; - - mprStealAllocBlock(MPR_LOC_ARGS(ctx), bp->start); - - bp->start = bp->end = bp->buf = bp->endbuf = 0; - bp->buflen = 0; - - return str; -} - -/******************************************************************************/ - -void mprAddNullToBuf(MprBuf *bp) -{ - *((char*) bp->end) = (char) '\0'; -} - -/******************************************************************************/ - -void mprAdjustBufEnd(MprBuf *bp, int size) -{ - mprAssert(bp->buflen == (bp->endbuf - bp->buf)); - mprAssert(size < bp->buflen); - - bp->end += size; - if (bp->end >= bp->endbuf) { - bp->end -= bp->buflen; - } - if (bp->end < bp->buf) { - bp->end += bp->buflen; - } - - if (bp->end >= bp->endbuf) { - mprAssert(bp->end < bp->endbuf); - mprFlushBuf(bp); - } -} - -/******************************************************************************/ -/* - * Adjust the start pointer after a user copy - */ - -void mprAdjustBufStart(MprBuf *bp, int size) -{ - mprAssert(bp->buflen == (bp->endbuf - bp->buf)); - mprAssert(size < bp->buflen); - - bp->start += size; - while (bp->start >= bp->endbuf) { - bp->start -= bp->buflen; - } - while (bp->start < bp->buf) { - bp->start += bp->buflen; - } - - /* - * Flush the buffer if the start pointer is corrupted via a bad size - */ - if (bp->start >= bp->endbuf) { - mprAssert(bp->start < bp->endbuf); - mprFlushBuf(bp); - } -} - - -/******************************************************************************/ - -void mprFlushBuf(MprBuf *bp) -{ - bp->start = bp->buf; - bp->end = bp->buf; -} - -/******************************************************************************/ - -int mprGetCharFromBuf(MprBuf *bp) -{ - int c; - - if (bp->start == bp->end) { - return -1; - } - c = (uchar) *bp->start++; - if (bp->start >= bp->endbuf) { - bp->start = bp->buf; - } - return c; -} - -/******************************************************************************/ - -int mprGetBlockFromBuf(MprBuf *bp, uchar *buf, int size) -{ - int thisLen, bytesRead; - - mprAssert(buf); - mprAssert(size > 0); - mprAssert(bp->buflen == (bp->endbuf - bp->buf)); - - /* - * Get the max bytes in a straight copy - */ - bytesRead = 0; - while (size > 0) { - thisLen = mprGetBufLinearData(bp); - thisLen = min(thisLen, size); - if (thisLen <= 0) { - break; - } - - memcpy(buf, bp->start, thisLen); - buf += thisLen; - bp->start += thisLen; - size -= thisLen; - bytesRead += thisLen; - - if (bp->start >= bp->endbuf) { - bp->start = bp->buf; - } - } - return bytesRead; -} - -/******************************************************************************/ - -int mprGetBufLength(MprBuf *bp) -{ - if (bp->start > bp->end) { - return (bp->buflen + (bp->end - bp->start)); - } else { - return (bp->end - bp->start); - } -} - -/******************************************************************************/ - -int mprGetBufLinearData(MprBuf *bp) -{ - return min(mprGetBufLength(bp), (bp->endbuf - bp->start)); -} - -/******************************************************************************/ - -int mprGetBufLinearSpace(MprBuf *bp) -{ - int len = mprGetBufLength(bp); - int space = bp->buflen - len - 1; - return min((bp->endbuf - bp->end), space); -} - -/******************************************************************************/ - -int mprGetBufSize(MprBuf *bp) -{ - return bp->buflen; -} - -/******************************************************************************/ - -int mprGetBufSpace(MprBuf *bp) -{ - return bp->buflen - mprGetBufLength(bp) - 1; -} - -/******************************************************************************/ - -char *mprGetBufOrigin(MprBuf *bp) -{ - return (char*) bp->buf; -} - -/******************************************************************************/ - -char *mprGetBufStart(MprBuf *bp) -{ - return (char*) bp->start; -} - -/******************************************************************************/ - -char *mprGetBufEnd(MprBuf *bp) -{ - return (char*) bp->end; -} - -/******************************************************************************/ - -int mprInsertCharToBuf(MprBuf *bp, int c) -{ - char *cp; - int space; - - mprAssert(bp->buflen == (bp->endbuf - bp->buf)); - - space = bp->buflen - mprGetBufLength(bp) - 1; - if (space < (int) sizeof(char)) { - if (!grow(bp)) { - return -1; - } - } - if (bp->start <= bp->buf) { - bp->start = bp->endbuf; - } - cp = (char*) bp->start; - *--cp = (char) c; - bp->start = (uchar *) cp; - return 0; -} - -/******************************************************************************/ - -int mprLookAtNextCharInBuf(MprBuf *bp) -{ - if (bp->start == bp->end) { - return -1; - } - return *bp->start; -} - -/******************************************************************************/ - -int mprLookAtLastCharInBuf(MprBuf *bp) -{ - if (bp->start == bp->end) { - return -1; - } - return (bp->end == bp->buf) ? bp->endbuf[-1] : bp->end[-1]; -} - -/******************************************************************************/ - -int mprPutCharToBuf(MprBuf *bp, int c) -{ - char *cp; - int space; - - mprAssert(bp->buflen == (bp->endbuf - bp->buf)); - - space = bp->buflen - mprGetBufLength(bp) - 1; - if (space < (int) sizeof(char)) { - if (! grow(bp)) { - return -1; - } - } - - cp = (char*) bp->end; - *cp++ = (char) c; - bp->end = (uchar *) cp; - if (bp->end >= bp->endbuf) { - bp->end = bp->buf; - } - *((char*) bp->end) = (char) '\0'; - return 0; -} - -/******************************************************************************/ - -int mprPutBlockToBuf(MprBuf *bp, const char *str, int size) -{ - int thisLen, bytes, space; - - mprAssert(str); - mprAssert(size >= 0); - mprAssert(bp->buflen == (bp->endbuf - bp->buf)); - - /* - * Add the max we can in one copy - */ - bytes = 0; - while (size > 0) { - space = mprGetBufLinearSpace(bp); - thisLen = min(space, size); - if (thisLen <= 0) { - if (! grow(bp)) { - break; - } - space = mprGetBufLinearSpace(bp); - thisLen = min(space, size); - } - - memcpy(bp->end, str, thisLen); - str += thisLen; - bp->end += thisLen; - size -= thisLen; - bytes += thisLen; - - if (bp->end >= bp->endbuf) { - bp->end = bp->buf; - } - } - *((char*) bp->end) = (char) '\0'; - return bytes; -} - -/******************************************************************************/ - -int mprPutStringToBuf(MprBuf *bp, const char *str) -{ - return mprPutBlockToBuf(bp, str, strlen(str)); -} - -/******************************************************************************/ - -int mprPutFmtStringToBuf(MprBuf *bp, const char *fmt, ...) -{ - va_list ap; - char *buf; - int rc, len, space; - - va_start(ap, fmt); - space = mprGetBufLinearSpace(bp); - - /* - * Add max that the buffer can grow - */ - space += (bp->maxsize - bp->buflen - 1); - - len = mprAllocVsprintf(MPR_LOC_ARGS(bp), &buf, space, fmt, ap); - rc = mprPutBlockToBuf(bp, buf, len); - - mprFree(buf); - va_end(ap); - return rc; -} - -/******************************************************************************/ -/* - * Grow the buffer to fit new data. Return 1 if the buffer can grow. - * Grow using the growBy size specified when creating the buffer. - */ - -static int grow(MprBuf *bp) -{ - uchar *newbuf; - - if (bp->maxsize > 0 && bp->buflen >= bp->maxsize) { - return 0; - } - - newbuf = (uchar*) mprAlloc(bp, bp->buflen + bp->growBy); - if (bp->buf) { - memcpy(newbuf, bp->buf, bp->buflen); - mprFree(bp->buf); - } - - bp->buflen += bp->growBy; - bp->end = newbuf + (bp->end - bp->buf); - bp->start = newbuf + (bp->start - bp->buf); - bp->buf = newbuf; - bp->endbuf = &bp->buf[bp->buflen]; - - /* - * Increase growBy to reduce overhead - */ - bp->growBy *= 2; - if (bp->maxsize > 0 && (bp->buflen + bp->growBy) > bp->maxsize) { - bp->growBy = bp->maxsize - bp->buflen; - } - return 1; -} - -/******************************************************************************/ -/* - * Add a number to the buffer (always null terminated). - */ - -int mprPutIntToBuf(MprBuf *bp, int i) -{ - char numBuf[16]; - int rc; - - mprItoa(numBuf, sizeof(numBuf), i); - rc = mprPutStringToBuf(bp, numBuf); - *((char*) bp->end) = (char) '\0'; - - return rc; -} - -/******************************************************************************/ - -void mprCopyBufDown(MprBuf *bp) -{ - if (mprGetBufLength(bp) == 0) { - mprFlushBuf(bp); - return; - } - memmove(bp->buf, bp->start, (bp->end - bp->start)); - bp->end -= (bp->start - bp->buf); - bp->start = bp->buf; -} - -/******************************************************************************/ - -MprBufProc mprGetBufRefillProc(MprBuf *bp) -{ - return bp->refillProc; -} - -/******************************************************************************/ - -void mprSetBufRefillProc(MprBuf *bp, MprBufProc fn, void *arg) -{ - bp->refillProc = fn; - bp->refillArg = arg; -} - -/******************************************************************************/ - -int mprRefillBuf(MprBuf *bp) -{ - return (bp->refillProc) ? (bp->refillProc)(bp, bp->refillArg) : 0; -} - -/******************************************************************************/ - -void mprResetBufIfEmpty(MprBuf *bp) -{ - if (mprGetBufLength(bp) == 0) { - mprFlushBuf(bp); - } -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c b/source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c deleted file mode 100644 index 517e43853f..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprGenFile.c +++ /dev/null @@ -1,336 +0,0 @@ -/** - * @file mprGenFile.c - * @brief Generic File services - * @overview - * @remarks - * See OS/mprFile.c for the per O/S portions - */ - -/******************************************************************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "mpr.h" - -/****************************** Forward Declarations **************************/ -#if !BREW - -static int closeDestructor(void *data); - -/************************************ Code ************************************/ - -int mprStartFileServices(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - app->console = mprAllocTypeZeroed(ctx, MprFile); - app->error = mprAllocTypeZeroed(ctx, MprFile); - - /* - * We assume that STDOUT is 1 and STDERR is 2 - */ - app->console->fd = 1; - app->error->fd = 2; - - return 0; -} - -/******************************************************************************/ - -void mprStopFileServices(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - - mprFree(app->console); - app->console = 0; - mprFree(app->error); - app->error = 0; -} - -/******************************************************************************/ - -MprFile *mprOpen(MprCtx ctx, const char *path, int omode, int perms) -{ - MprFile *file; - - mprAssert(path && *path); - - file = mprAllocTypeZeroed(ctx, MprFile); - - file->fd = open(path, omode, perms); - if (file->fd < 0) { - mprFree(file); - return 0; - } - - mprSetDestructor(file, closeDestructor); - return file; -} - -/******************************************************************************/ - -static int closeDestructor(void *data) -{ - MprFile *file = (MprFile*) data; - - mprAssert(file); - - mprClose(file); - return 0; -} - -/******************************************************************************/ - -void mprClose(MprFile *file) -{ - mprAssert(file); - - if (file < 0) { - return; - } - - mprAssert(file->fd >= 0); - close(file->fd); - - mprSetDestructor(file, 0); - mprFree(file); -} - -/******************************************************************************/ - -int mprRead(MprFile *file, void *buf, uint size) -{ - mprAssert(file); - - if (file == 0) { - return MPR_ERR_BAD_HANDLE; - } - - return read(file->fd, buf, size); -} - -/******************************************************************************/ - -int mprWrite(MprFile *file, const void *buf, uint count) -{ - mprAssert(file); - - if (file == 0) { - return MPR_ERR_BAD_HANDLE; - } - - return write(file->fd, buf, count); -} - -/******************************************************************************/ - -int mprSeek(MprFile *file, int seekType, long distance) -{ - mprAssert(file); - - if (file == 0) { - return MPR_ERR_BAD_HANDLE; - } - - return lseek(file->fd, seekType, distance); -} - -/******************************************************************************/ - -int mprDelete(MprCtx ctx, const char *path) -{ - return unlink(path); -} - -/******************************************************************************/ - -int mprDeleteDir(MprCtx ctx, const char *path) -{ - return rmdir(path); -} - -#endif /* !BREW */ -/******************************************************************************/ - -char *mprGets(MprFile *file, char *buf, uint size) -{ - MprBuf *bp; - int count, len, c; - - mprAssert(file); - - if (file == 0) { - return 0; - } - - if (file->buf == 0) { - file->buf = mprCreateBuf(file, MPR_DEFAULT_ALLOC, MPR_MAX_STRING); - } - bp = file->buf; - - /* - * Must leave room for null - */ - count = 0; - while (--size > 0) { - if (mprGetBufLength(bp) == 0) { - mprFlushBuf(bp); - len = mprRead(file, mprGetBufEnd(bp), - mprGetBufLinearSpace(bp)); - if (len <= 0) { - return 0; - } - mprAdjustBufEnd(bp, len); - mprAddNullToBuf(bp); - } - if ((c = mprGetCharFromBuf(bp)) == '\n') { - buf[count] = '\0'; - return buf; - } - buf[count++] = c; - } - buf[count] = '\0'; - return buf; -} - -/******************************************************************************/ - -int mprPuts(MprFile *file, const char *writeBuf, uint count) -{ - MprBuf *bp; - char *buf; - int total, bytes, len; - - mprAssert(file); - - /* - * Buffer output and flush when full. - */ - if (file->buf == 0) { - file->buf = mprCreateBuf(file, MPR_BUFSIZE, 0); - if (file->buf == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - } - bp = file->buf; - - if (mprGetBufLength(bp) > 0 && mprGetBufSpace(bp) < (int) count) { - len = mprGetBufLength(bp); - if (mprWrite(file, mprGetBufStart(bp), len) != len) { - return MPR_ERR_CANT_WRITE; - } - mprFlushBuf(bp); - } - - total = 0; - buf = (char*) writeBuf; - - while (count > 0) { - bytes = mprPutBlockToBuf(bp, buf, count); - if (bytes <= 0) { - return MPR_ERR_CANT_ALLOCATE; - } - count -= bytes; - buf += bytes; - total += bytes; - mprAddNullToBuf(bp); - - if (count > 0) { - len = mprGetBufLength(bp); - if (mprWrite(file, mprGetBufStart(bp), len) != len) { - return MPR_ERR_CANT_WRITE; - } - mprFlushBuf(bp); - } - } - return total; -} - -/******************************************************************************/ - -int mprMakeTempFileName(MprCtx ctx, char *buf, int bufsize, const char *tempDir) -{ - MprFile *file; - MprTime now; - char *dir; - int seed, i; - - if (tempDir == 0) { -#if WIN - char *cp; - dir = mprStrdup(ctx, getenv("TEMP")); - for (cp = dir; *cp; cp++) { - if (*cp == '\\') { - *cp = '/'; - } - } -#else - dir = mprStrdup(ctx, "/tmp"); -#endif - } else { - dir = mprStrdup(ctx, tempDir); - } - - mprGetTime(ctx, &now); - seed = now.msec % 64000; - file = 0; - - for (i = 0; i < 128; i++) { - mprSprintf(buf, bufsize, "%s/MPR_%d_%d.tmp", dir, getpid(), seed++); - file = mprOpen(ctx, buf, O_CREAT | O_EXCL | O_BINARY, 0664); - if (file) { - break; - } - } - - if (file == 0) { - return MPR_ERR_CANT_CREATE; - } - - mprClose(file); - mprFree(dir); - - return 0; -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c b/source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c deleted file mode 100644 index 6b0ed97bbc..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprGenTime.c +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @file mprGenTime.c - * @brief Generic Time handling - * @overview - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************* Includes ***********************************/ - -#include "mpr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************/ -/* - * Return the number of milliseconds until the given timeout has expired. - */ - -int mprGetTimeRemaining(MprCtx ctx, MprTime mark, uint timeout) -{ - MprTime now; - uint diff; - - mprGetTime(ctx, &now); - diff = ((now.sec - mark.sec) * 1000) + (now.msec - mark.msec); - - if (diff < 0) { - /* - * Detect time going backwards - */ - mprAssert(diff >= 0); - diff = 0; - } - return (int) (timeout - diff); -} - -/******************************************************************************/ -/* - * Return the number of milliseconds until the given timeout has expired. - */ - -int mprGetElapsedTime(MprCtx ctx, MprTime mark) -{ - MprTime now; - - mprGetTime(ctx, &now); - return ((now.sec - mark.sec) * 1000) + (now.msec - mark.msec); -} - -/******************************************************************************/ - -void mprAddElapsedToTime(MprTime *time, uint elapsed) -{ - time->sec += elapsed / 1000; - time->msec += elapsed % 1000; - if (time->msec > 1000) { - time->msec -= 1000; - time->sec++; - } -} - -/******************************************************************************/ - -int mprCompareTime(MprTime *t1, MprTime *t2) -{ - if (t1->sec < t2->sec) { - return -1; - } else if (t1->sec == t2->sec) { - if (t1->msec < t2->msec) { - return -1; - } else if (t1->msec == t2->msec) { - return 0; - } - } - return 1; -} - -/******************************************************************************/ - -uint mprSubtractTime(MprTime *t1, MprTime *t2) -{ - return ((t1->sec - t2->sec) * 1000) + (t1->msec - t2->msec); -} - -/******************************************************************************/ -#if !BREW -/* - * Thread-safe RFC822 dates (Eg: "Fri, 07 Jan 2003 12:12:21 GMT") - */ - -int mprRfcTime(MprCtx ctx, char *buf, int bufsize, const struct tm *timep) -{ - char months[12][4] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", - "Oct", "Nov", "Dec" - }; - - char days[7][4] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; - - char *dayp, *monthp; - int year; - - if (bufsize < 30) { - return MPR_ERR_WONT_FIT; - } - dayp = &days[timep->tm_wday][0]; - *buf++ = *dayp++; - *buf++ = *dayp++; - *buf++ = *dayp++; - *buf++ = ','; - *buf++ = ' '; - - *buf++ = timep->tm_mday / 10 + '0'; - *buf++ = timep->tm_mday % 10 + '0'; - *buf++ = ' '; - - monthp = &months[timep->tm_mon][0]; - *buf++ = *monthp++; - *buf++ = *monthp++; - *buf++ = *monthp++; - *buf++ = ' '; - - year = 1900 + timep->tm_year; - /* This routine isn't y10k ready. */ - *buf++ = year / 1000 + '0'; - *buf++ = year % 1000 / 100 + '0'; - *buf++ = year % 100 / 10 + '0'; - *buf++ = year % 10 + '0'; - *buf++ = ' '; - - *buf++ = timep->tm_hour / 10 + '0'; - *buf++ = timep->tm_hour % 10 + '0'; - *buf++ = ':'; - *buf++ = timep->tm_min / 10 + '0'; - *buf++ = timep->tm_min % 10 + '0'; - *buf++ = ':'; - *buf++ = timep->tm_sec / 10 + '0'; - *buf++ = timep->tm_sec % 10 + '0'; - *buf++ = ' '; - - *buf++ = 'G'; - *buf++ = 'M'; - *buf++ = 'T'; - *buf++ = 0; - return 0; -} - -#endif -/******************************************************************************/ - -#ifdef __cplusplus -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprLock.c b/source4/lib/appweb/ejs-2.0/mpr/mprLock.c deleted file mode 100644 index df9ce276d4..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprLock.c +++ /dev/null @@ -1,266 +0,0 @@ -/** - * @file mprThread.c - * @brief Mbedthis Portable Runtime Base Thread Locking Support - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -#include "mpr.h" - -#if BLD_FEATURE_MULTITHREAD -/************************************ Code ************************************/ - -void mprInitThreads(MprApp *app) -{ - mprAssert(app); - - if (app->globalLock == 0) { - app->globalLock = mprCreateLock(app); - app->allocLock = mprCreateLock(app); - } -} - -/******************************************************************************/ - -void mprTermThreads(MprApp *app) -{ - mprAssert(app); - - if (app->globalLock) { - mprDestroyLock(app->globalLock); - app->globalLock = 0; - } - if (app->allocLock) { - MprLock *lock = app->allocLock; - app->allocLock = 0; - mprDestroyLock(lock); - } -} - -/******************************************************************************/ - -MprLock *mprCreateLock(MprCtx ctx) -{ - MprLock *lock; - - mprAssert(ctx); - - lock = mprAllocType(ctx, MprLock); - -#if BLD_HOST_UNIX - pthread_mutexattr_t attr; - - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); - pthread_mutex_init(&lock->cs, &attr); - pthread_mutexattr_destroy(&attr); -#elif WIN - InitializeCriticalSectionAndSpinCount(&lock->cs, 5000); -#elif VXWORKS - lock->cs = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | - SEM_INVERSION_SAFE); - if (lock->cs == 0) { - mprAssert(0); - mprFree(lock); - return 0; - } -#endif - return lock; -} - -/******************************************************************************/ -/* - * Destroy a lock. Must be locked on entrance. - */ - -void mprDestroyLock(MprLock *lock) -{ - mprAssert(lock); - if (lock == 0) { - return; - } - -#if BLD_HOST_UNIX - pthread_mutex_unlock(&lock->cs); - pthread_mutex_destroy(&lock->cs); -#elif WIN - DeleteCriticalSection(&lock->cs); -#elif VXWORKS - semDelete(lock->cs); -#endif - mprFree(lock); -} - -/******************************************************************************/ -/* - * Lock a mutex - */ - -void mprLock(MprLock *lock) -{ - /* - * OPT -- Do this just so we can allocate MprApp before we have created its - * lock. Should remove this test here and in mprUnlock. - */ - if (lock == 0) { - return; - } - -#if BLD_HOST_UNIX - pthread_mutex_lock(&lock->cs); -#elif WIN - EnterCriticalSection(&lock->cs); -#elif VXWORKS - semTake(lock->cs, WAIT_FOREVER); -#endif -} - -/******************************************************************************/ -/* - * Try to attain a lock. Do not block! - */ - -int mprTryLock(MprLock *lock) -{ - mprAssert(lock); - -#if BLD_HOST_UNIX - { - int err; - - if ((err = pthread_mutex_trylock(&lock->cs)) != 0) { - if (err == EBUSY) { - return MPR_ERR_BUSY; - } else { - return MPR_ERR_CANT_ACCESS; - } - } - return 0; - } -#elif WIN - if (TryEnterCriticalSection(&lock->cs) == 0) { - return MPR_ERR_BUSY; - } -#elif VXWORKS - { - int rc; - - rc = semTake(cs, NO_WAIT); - if (rc == -1) { - mprAssert(0); - } - if (rc == S_objLib_OBJ_UNAVAILABLE) { - return MPR_ERR_BUSY; - } else { - return MPR_ERR_CANT_ACCESS; - } - /* Success */ - return 0; - } -#endif - return 0; -} - -/******************************************************************************/ -/* - * Unlock. - */ - -void mprUnlock(MprLock *lock) -{ - if (lock == 0) { - return; - } - -#if BLD_HOST_UNIX - pthread_mutex_unlock(&lock->cs); -#elif WIN - LeaveCriticalSection(&lock->cs); -#elif VXWORKS - semGive(lock->cs); -#endif -} - -/******************************************************************************/ -/* - * Big global lock. Avoid using this. - */ - -void mprGlobalLock(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - mprAssert(app); - - if (app && app->globalLock) { - mprLock(app->globalLock); - } -} - -/******************************************************************************/ - -void mprGlobalUnlock(MprCtx ctx) -{ - MprApp *app; - - app = mprGetApp(ctx); - mprAssert(app); - - if (app && app->globalLock) { - mprUnlock(app->globalLock); - } -} - -/******************************************************************************/ - -int mprGetCurrentThreadID() -{ -#if BLD_HOST_UNIX - return (int) pthread_self(); -#elif WIN - return GetCurrentThreadId(); -#elif VXWORKS - return (int) pthread_self(); -#endif -} - -/******************************************************************************/ -#endif /* BLD_FEATURE_MULTITHREAD */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprLog.c b/source4/lib/appweb/ejs-2.0/mpr/mprLog.c deleted file mode 100644 index 1eb175ed95..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprLog.c +++ /dev/null @@ -1,602 +0,0 @@ -/** - * @file mprLog.c - * @brief Mbedthis Portable Runtime (MPR) Logging and error reporting. - * @remarks We always provide these routines. - */ - -/*********************************** License **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -#include "mpr.h" - -/****************************** Forward Declarations **************************/ - -static void defaultLogHandler(MPR_LOC_DEC(ctx, loc), int flags, - int level, const char *msg); -static void logOutput(MPR_LOC_DEC(ctx, loc), int flags, int level, - const char *msg); - -/************************************ Code ************************************/ - -void mprLog(MprCtx ctx, int level, const char *fmt, ...) -{ - va_list args; - char *buf; - - if (level > mprGetLogLevel(ctx)) { - return; - } - - va_start(args, fmt); - mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args); - va_end(args); - - logOutput(MPR_LOC_ARGS(ctx), MPR_LOG_SRC, level, buf); - - va_end(args); - mprFree(buf); -} - -/*****************************************************************************/ -/* - * Do raw output - */ - -void mprRawLog(MprCtx ctx, const char *fmt, ...) -{ - va_list args; - char *buf; - int len; - - va_start(args, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args); - va_end(args); - - logOutput(MPR_LOC_ARGS(ctx), MPR_RAW, 0, buf); - mprFree(buf); -} - -/*****************************************************************************/ -/* - * Handle an error - */ - -void mprError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...) -{ - va_list args; - char *buf; - int len; - - va_start(args, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args); - va_end(args); - - logOutput(MPR_LOC_PASS(ctx, loc), MPR_ERROR_MSG | MPR_ERROR_SRC, 0, buf); - - mprFree(buf); -} - -/*****************************************************************************/ -/* - * Handle an error that should be displayed to the user - */ - -void mprUserError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...) -{ - va_list args; - char *buf; - int len; - - va_start(args, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args); - va_end(args); - - logOutput(MPR_LOC_PASS(ctx, loc), MPR_USER_MSG | MPR_ERROR_SRC, 0, buf); - - mprFree(buf); -} - -/*****************************************************************************/ -/* - * Handle a fatal error. Forcibly shutdown the application. - */ - -void mprFatalError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...) -{ - va_list args; - char *buf; - int len; - - va_start(args, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, args); - va_end(args); - - logOutput(MPR_LOC_PASS(ctx, loc), MPR_USER_MSG | MPR_FATAL_SRC, 0, buf); - - mprFree(buf); - -#if BREW - mprSignalExit(ctx); -#else - exit(2); -#endif -} - -/*****************************************************************************/ -/* - * Handle a program assertion - */ - -void mprAssertError(MPR_LOC_DEC(ctx, loc), const char *msg) -{ - logOutput(MPR_LOC_PASS(ctx, loc), MPR_ASSERT_MSG | MPR_ASSERT_SRC, 0, msg); -} - -/*****************************************************************************/ -/* - * Handle an error - */ - -void mprStaticError(MPR_LOC_DEC(ctx, loc), const char *fmt, ...) -{ - va_list args; - int len; - char buf[MPR_MAX_STRING]; - - va_start(args, fmt); - len = mprVsprintf(buf, sizeof(buf), fmt, args); - va_end(args); - - logOutput(MPR_LOC_PASS(ctx, loc), MPR_ERROR_MSG | MPR_ERROR_SRC, 0, buf); -} - -/*****************************************************************************/ -/* - * Direct output to the standard output. Does not hook into the logging - * system and does not allocate memory. - */ - -void mprStaticAssert(const char *loc, const char *msg) -{ -#if BLD_DEBUG - char buf[MPR_MAX_STRING]; - int len; - - len = mprSprintf(buf, sizeof(buf), "Assertion %s, failed at %s\n", - msg, loc); - mprBreakpoint(loc, buf); - -#if BLD_HOST_UNIX - /* - * MOB -- but is stdout always okay to use - */ - write(1, buf, len); -#elif BREW || WIN - /* - * Only time we use printf. We can't get an alloc context so we have - * to use real print - */ -#if BREW && !BREW_SIMULATOR - printf(" MP: %s\n", buf); -#else - printf("%s\n", buf); -#endif - -#endif -#endif -} - -/*****************************************************************************/ - -int mprGetLogLevel(MprCtx ctx) -{ - return mprGetApp(ctx)->logLevel; -} - -/******************************************************************************/ - -void mprSetLogLevel(MprCtx ctx, int level) -{ - mprGetApp(ctx)->logLevel = level; -} - -/*****************************************************************************/ -/* - * Output a log message to the log handler - */ - -static void logOutput(MPR_LOC_DEC(ctx, loc), int flags, int level, - const char *msg) -{ - MprLogHandler handler; - - if (flags & (MPR_ERROR_SRC | MPR_FATAL_SRC | MPR_ASSERT_SRC)) { - mprBreakpoint(MPR_LOC, 0); - } - - mprAssert(ctx != 0); - handler = mprGetApp(ctx)->logHandler; - if (handler != 0) { - (handler)(MPR_LOC_PASS(ctx, loc), flags, level, msg); - return; - } - defaultLogHandler(MPR_LOC_PASS(ctx, loc), flags, level, msg); -} - -/*****************************************************************************/ -/* - * Default log output is just to the console - */ - -static void defaultLogHandler(MPR_LOC_DEC(ctx, loc), int flags, - int level, const char *msg) -{ - MprApp *app; - char *prefix; - - app = mprGetApp(ctx); - prefix = app->name; - - while (*msg == '\n') { - mprPrintf(ctx, "\n"); - msg++; - } - - if (flags & MPR_LOG_SRC) { -#if BREW && !BREW_SIMULATOR - mprPrintf(ctx, "%s\n", msg); -#else - mprPrintf(ctx, "%s: %d: %s\n", prefix, level, msg); -#endif - - } else if (flags & MPR_ERROR_SRC) { - /* - * Use static printing to avoid malloc when the messages are small. - * This is important for memory allocation errors. - */ - if (strlen(msg) < (MPR_MAX_STRING - 32)) { - mprStaticPrintf(ctx, "%s: Error: %s\n", prefix, msg); - } else { - mprPrintf(ctx, "%s: Error: %s\n", prefix, msg); - } - - } else if (flags & MPR_FATAL_SRC) { - mprPrintf(ctx, "%s: Fatal: %s\n", prefix, msg); - - } else if (flags & MPR_ASSERT_SRC) { -#if BLD_FEATURE_ALLOC_LEAK_TRACK - mprPrintf(ctx, "%s: Assertion %s, failed at %s\n", prefix, msg, loc); -#else - mprPrintf(ctx, "%s: Assertion %s, failed\n", prefix, msg); -#endif - - } else if (flags & MPR_RAW) { - mprPrintf(ctx, "%s", msg); - - } else { - return; - } -} - -/*****************************************************************************/ -/* - * Map the O/S error code to portable error codes. - */ - -int mprGetOsError() -{ -#if WIN - int rc; - rc = GetLastError(); - - /* - * Client has closed the pipe - */ - if (rc == ERROR_NO_DATA) { - return EPIPE; - } - return rc; -#endif -#if LINUX || VXWORKS || SOLARIS - return errno; -#endif -#if BREW - /* - * No such thing on Brew. Errors are per class - */ - return 0; -#endif -} - -/******************************************************************************/ -#if UNUSED - -const char *mprGetErrorMsg(int err) -{ - /* - * MPR error messages. Declare here so we don't have any globals. - */ - char *mprErrMessages[] = { - /* 0 MPR_ERR_OK */ "Success", - /* -201 MPR_ERR_GENERAL */ "General error", - /* -202 MPR_ERR_ABORTED */ "Aborted", - /* -203 MPR_ERR_ALREADY_EXISTS */ "Already exists", - /* -204 MPR_ERR_BAD_ARGS */ "Bad args", - /* -205 MPR_ERR_BAD_FORMAT */ "Bad format", - /* -206 MPR_ERR_BAD_HANDLE */ "Bad handle", - /* -207 MPR_ERR_BAD_STATE */ "Bad state", - /* -208 MPR_ERR_BAD_SYNTAX */ "Bad syntax", - /* -209 MPR_ERR_BAD_TYPE */ "Bad type", - /* -210 MPR_ERR_BAD_VALUE */ "Bad value", - /* -211 MPR_ERR_BUSY */ "Busy", - /* -212 MPR_ERR_CANT_ACCESS */ "Can't access", - /* -213 MPR_ERR_CANT_COMPLETE */ "Can't complete", - /* -214 MPR_ERR_CANT_CREATE */ "Can't create", - /* -215 MPR_ERR_CANT_INITIALIZE */ "Can't initialize", - /* -216 MPR_ERR_CANT_OPEN */ "Can't open", - /* -217 MPR_ERR_CANT_READ */ "Can't read", - /* -218 MPR_ERR_CANT_WRITE */ "Can't write", - /* -219 MPR_ERR_DELETED */ "Already deleted", - /* -220 MPR_ERR_NETWORK */ "Network error", - /* -221 MPR_ERR_NOT_FOUND */ "Not found", - /* -222 MPR_ERR_NOT_INITIALIZED */ "Not initialized", - /* -223 MPR_ERR_NOT_READY */ "Not ready", - /* -224 MPR_ERR_READ_ONLY */ "Read only", - /* -225 MPR_ERR_TIMEOUT */ "Timeout", - /* -226 MPR_ERR_TOO_MANY */ "Too many", - /* -227 MPR_ERR_WONT_FIT */ "Won't fit", - /* -228 MPR_ERR_WOULD_BLOCK */ "Would block", - /* -229 MPR_ERR_CANT_ALLOCATE */ "Can't allocate", - }; - int mprNumErr = sizeof(mprErrMessages) / sizeof(char*); - -/* - * Operating system error messages - */ -#if WIN -char *osErrMessages[] = -{ - /* 0 */ "No error", - /* 1 EPERM */ "Operation not permitted", - /* 2 ENOENT */ "No such file or directory", - /* 3 ESRCH */ "No such process", - /* 4 EINTR */ "Interrupted function call", - /* 5 EIO */ "I/O error", - /* 6 ENXIO */ "No such device or address", - /* 7 E2BIG */ "Arg list too long", - /* 8 ENOEXEC */ "Exec format error", - /* 9 EBADF */ "Bad file number", - /* 10 ECHILD */ "No child processes", - /* 11 EAGAIN */ "Try again", - /* 12 ENOMEM */ "Out of memory", - /* 13 EACCES */ "Permission denied", - /* 14 EFAULT */ "Bad address", - /* 15 ENOTBLK */ "Unknown error", - /* 16 EBUSY */ "Resource busy", - /* 17 EEXIST */ "File exists", - /* 18 EXDEV */ "Improper link", - /* 19 ENODEV */ "No such device", - /* 20 ENOTDIR */ "Not a directory", - /* 21 EISDIR */ "Is a directory", - /* 22 EINVAL */ "Invalid argument", - /* 23 ENFILE */ "Too many open files in system", - /* 24 EMFILE */ "Too many open files", - /* 25 ENOTTY */ "Inappropriate I/O control operation", - /* 26 ETXTBSY */ "Unknown error", - /* 27 EFBIG */ "File too large", - /* 28 ENOSPC */ "No space left on device", - /* 29 ESPIPE */ "Invalid seek", - /* 30 EROFS */ "Read-only file system", - /* 31 EMLINK */ "Too many links", - /* 32 EPIPE */ "Broken pipe", - /* 33 EDOM */ "Domain error", - /* 34 ERANGE */ "Result too large", - /* 35 EUCLEAN */ "Unknown error", - /* 36 EDEADLK */ "Resource deadlock would occur", - /* 37 UNKNOWN */ "Unknown error", - /* 38 ENAMETOOLONG */ "Filename too long", - /* 39 ENOLCK */ "No locks available", - /* 40 ENOSYS */ "Function not implemented", - /* 41 ENOTEMPTY */ "Directory not empty", - /* 42 EILSEQ */ "Illegal byte sequence", - /* 43 ENETDOWN */ "Network is down", - /* 44 ECONNRESET */ "Connection reset", - /* 45 ECONNREFUSED */ "Connection refused", - /* 46 EADDRINUSE */ "Address already in use" - -}; - -#else /* WIN */ - -char *osErrMessages[] = -{ - /* 0 */ "Success" - /* 1 EPERM */ "Operation not permitted" - /* 2 ENOENT */ "No such file or directory" - /* 3 ESRCH */ "No such process" - /* 4 EINTR */ "Interrupted system call" - /* 5 EIO */ "I/O error" - /* 6 ENXIO */ "No such device or address" - /* 7 E2BIG */ "Arg list too long" - /* 8 ENOEXEC */ "Exec format error" - /* 9 EBADF */ "Bad file number" - /* 10 ECHILD */ "No child processes" - /* 11 EAGAIN */ "Try again" - /* 12 ENOMEM */ "Out of memory" - /* 13 EACCES */ "Permission denied" - /* 14 EFAULT */ "Bad address" - /* 15 ENOTBLK */ "Block device required" - /* 16 EBUSY */ "Device or resource busy" - /* 17 EEXIST */ "File exists" - /* 18 EXDEV */ "Cross-device link" - /* 19 ENODEV */ "No such device" - /* 20 ENOTDIR */ "Not a directory" - /* 21 EISDIR */ "Is a directory" - /* 22 EINVAL */ "Invalid argument" - /* 23 ENFILE */ "File table overflow" - /* 24 EMFILE */ "Too many open files" - /* 25 ENOTTY */ "Not a typewriter" - /* 26 ETXTBSY */ "Text file busy" - /* 27 EFBIG */ "File too large" - /* 28 ENOSPC */ "No space left on device" - /* 29 ESPIPE */ "Illegal seek" - /* 30 EROFS */ "Read-only file system" - /* 31 EMLINK */ "Too many links" - /* 32 EPIPE */ "Broken pipe" - /* 33 EDOM */ "Math argument out of domain of func" - /* 34 ERANGE */ "Math result not representable" - /* 35 EDEADLK */ "Resource deadlock would occur" - /* 36 ENAMETOOLONG */ "File name too long" - /* 37 ENOLCK */ "No record locks available" - /* 38 ENOSYS */ "Function not implemented" - /* 39 ENOTEMPTY */ "Directory not empty" - /* 40 ELOOP */ "Too many symbolic links encountered" - /* 41 EWOULDBLOCK EAGAIN */"Operation would block" - /* 42 ENOMSG */ "No message of desired type" - /* 43 EIDRM */ "Identifier removed" - -#if !BLD_FEATURE_SQUEEZE - /* 44 ECHRNG */ "Channel number out of range" - /* 45 EL2NSYNC */ "Level 2 not synchronized" - /* 46 EL3HLT */ "Level 3 halted" - /* 47 EL3RST */ "Level 3 reset" - /* 48 ELNRNG */ "Link number out of range" - /* 49 EUNATCH */ "Protocol driver not attached" - /* 50 ENOCSI */ "No CSI structure available" - /* 51 EL2HLT */ "Level 2 halted" - /* 52 EBADE */ "Invalid exchange" - /* 53 EBADR */ "Invalid request descriptor" - /* 54 EXFULL */ "Exchange full" - /* 55 ENOANO */ "No anode" - /* 56 EBADRQC */ "Invalid request code" - /* 57 EBADSLT */ "Invalid slot" - /* 59 EBFONT */ "Bad font file format" - /* 60 ENOSTR */ "Device not a stream" - /* 61 ENODATA */ "No data available" - /* 62 ETIME */ "Timer expired" - /* 63 ENOSR */ "Out of streams resources" - /* 64 ENONET */ "Machine is not on the network" - /* 65 ENOPKG */ "Package not installed" - /* 66 EREMOTE */ "Object is remote" - /* 67 ENOLINK */ "Link has been severed" - /* 68 EADV */ "Advertise error" - /* 69 ESRMNT */ "Srmount error" - /* 70 ECOMM */ "Communication error on send" - /* 71 EPROTO */ "Protocol error" - /* 72 EMULTIHOP */ "Multihop attempted" - /* 73 EDOTDOT */ "RFS specific error" - /* 74 EBADMSG */ "Not a data message" - /* 75 EOVERFLOW */ "Value too large for defined data type" - /* 76 ENOTUNIQ */ "Name not unique on network" - /* 77 EBADFD */ "File descriptor in bad state" - /* 78 EREMCHG */ "Remote address changed" - /* 79 ELIBACC */ "Can not access a needed shared library" - /* 80 ELIBBAD */ "Accessing a corrupted shared library" - /* 81 ELIBSCN */ ".lib section in a.out corrupted" - /* 82 ELIBMAX */ "Linking in too many shared libraries" - /* 83 ELIBEXEC */ "Cannot exec a shared library directly" - /* 84 EILSEQ */ "Illegal byte sequence" - /* 85 ERESTART */ "Interrupted system call should be restarted" - /* 86 ESTRPIPE */ "Streams pipe error" - /* 87 EUSERS */ "Too many users" - /* 88 ENOTSOCK */ "Socket operation on non-socket" - /* 89 EDESTADDRREQ */ "Destination address required" - /* 90 EMSGSIZE */ "Message too long" - /* 91 EPROTOTYPE */ "Protocol wrong type for socket" - /* 92 ENOPROTOOPT */ "Protocol not available" - /* 93 EPROTONOSUPPORT */ "Protocol not supported" - /* 94 ESOCKTNOSUPPORT */ "Socket type not supported" - /* 95 EOPNOTSUPP */ "Operation not supported on transport endpoint" - /* 96 EPFNOSUPPORT */ "Protocol family not supported" - /* 97 EAFNOSUPPORT */ "Address family not supported by protocol" - /* 98 EADDRINUSE */ "Address already in use" - /* 99 EADDRNOTAVAIL */ "Cannot assign requested address" - /* 100 ENETDOWN */ "Network is down" - /* 101 ENETUNREACH */ "Network is unreachable" - /* 102 ENETRESET */ "Network dropped connection because of reset" - /* 103 ECONNABORTED */ "Software caused connection abort" - /* 104 ECONNRESET */ "Connection reset by peer" - /* 105 ENOBUFS */ "No buffer space available" - /* 106 EISCONN */ "Transport endpoint is already connected" - /* 107 ENOTCONN */ "Transport endpoint is not connected" - /* 108 ESHUTDOWN */ "Cannot send after transport endpoint shutdown" - /* 109 ETOOMANYREFS */ "Too many references: cannot splice" - /* 110 ETIMEDOUT */ "Connection timed out" - /* 111 ECONNREFUSED */ "Connection refused" - /* 112 EHOSTDOWN */ "Host is down" - /* 113 EHOSTUNREACH */ "No route to host" - /* 114 EALREADY */ "Operation already in progress" - /* 115 EINPROGRESS */ "Operation now in progress" - /* 116 ESTALE */ "Stale NFS file handle" - /* 117 EUCLEAN */ "Structure needs cleaning" - /* 118 ENOTNAM */ "Not a XENIX named type file" - /* 119 ENAVAIL */ "No XENIX semaphores available" - /* 120 EISNAM */ "Is a named type file" - /* 121 EREMOTEIO */ "Remote I/O error" - /* 122 EDQUOT */ "Quota exceeded" - /* 123 ENOMEDIUM */ "No medium found" - /* 124 EMEDIUMTYPE */ "Wrong medium type" -}; -#endif /* BLD_FEATURE_SQUEEZE */ -#endif /* WIN */ - - int osNumErr = sizeof(osErrMessages) / sizeof(char*); - - if (err < MPR_ERR_BASE) { - err = MPR_ERR_BASE - err; - if (err < 0 || err >= mprNumErr) { - return "Bad error code"; - } - return mprErrMessages[err]; - - } else { - /* - * Negative O/S error code. Map to a positive standard Posix error. - */ - err = -err; - if (err < 0 || err >= osNumErr) { - return "Bad O/S error code"; - } - return osErrMessages[err]; - } -} - -#endif -/*****************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprOs.h b/source4/lib/appweb/ejs-2.0/mpr/mprOs.h deleted file mode 100644 index bed4ca5979..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprOs.h +++ /dev/null @@ -1,707 +0,0 @@ -/* - * @file mprOs.h - * @brief Include O/S headers and smooth out per-O/S differences - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/******************************* Documentation ********************************/ - -/* - * This header is part of the Mbedthis Portable Runtime and aims to include - * all necessary O/S headers and to unify the constants and declarations - * required by Mbedthis products. It can be included by C or C++ programs. - */ - -/******************************************************************************/ - -#ifndef _h_MPR_OS_HDRS -#define _h_MPR_OS_HDRS 1 - -#include "buildConfig.h" - -/********************************* CPU Families *******************************/ -/* - * Porters, add your CPU families here and update configure code. - */ -#define MPR_CPU_UNKNOWN 0 -#define MPR_CPU_IX86 1 -#define MPR_CPU_PPC 2 -#define MPR_CPU_SPARC 3 -#define MPR_CPU_XSCALE 4 -#define MPR_CPU_ARM 5 -#define MPR_CPU_MIPS 6 -#define MPR_CPU_68K 7 -#define MPR_CPU_SIMNT 8 /* VxWorks NT simulator */ -#define MPR_CPU_SIMSPARC 9 /* VxWorks sparc simulator */ - -/********************************* O/S Includes *******************************/ - -#if LINUX || SOLARIS - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - -#if LINUX - #include -#endif - -#if SOLARIS - #include -#endif - -#if BLD_FEATURE_FLOATING_POINT - #define __USE_ISOC99 1 - #include - #include -#endif - -#endif /* LINUX || SOLARIS */ - -#if VXWORKS - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #if BLD_FEATURE_FLOATING_POINT - #include - #define __USE_ISOC99 1 - #include - #endif - - #include - #include - #include - #include - #include - #include - #include - #include - -#endif /* VXWORKS */ - -#if MACOSX - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif /* MACOSX */ - -#if WIN - /* - * We replace insecure functions with Mbedthis replacements - */ - #define _CRT_SECURE_NO_DEPRECATE 1 - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #if BLD_FEATURE_FLOATING_POINT - #include - #endif - #include - #include - #include - -#if BLD_DEBUG - #include -#endif - #include "mprUnix.h" -#endif /* WIN */ - -#if BREW - #if BLD_FEATURE_FLOATING_POINT - #warning "Floating point is not supported on Brew" - #endif - #if BLD_FEATURE_MULTITHREAD - #warning "Multithreading is not supported on Brew" - #endif - - #include "AEEModGen.h" - #include "AEEAppGen.h" - #include "BREWVersion.h" - - #if BREW_MAJ_VER == 2 - /* - * Fix for BREW 2.X - */ - #ifdef __GNUC__ - #define __inline extern __inline__ - #endif - #include "AEENet.h" - #undef __inline - #endif - - #include "AEE.h" - #include "AEEBitmap.h" - #include "AEEDisp.h" - #include "AEEFile.h" - #include "AEEHeap.h" - #include "AEEImageCtl.h" - #include "AEEMedia.h" - #include "AEEMediaUtil.h" - #include "AEEMimeTypes.h" - #include "AEEStdLib.h" - #include "AEEShell.h" - #include "AEESoundPlayer.h" - #include "AEEText.h" - #include "AEETransform.h" - #include "AEEWeb.h" - #if BREW_MAJ_VER >= 3 - #include "AEESMS.h" - #endif - #include "AEETAPI.h" - -#if 0 - #include "AEESound.h" - #include "AEEDb.h" - #include "AEEMenu.h" -#endif - -#endif /* BREW */ - -/******************************************************************************/ -/******************************* General Defines ******************************/ -/******************************************************************************/ - -#ifndef MAXINT -#if INT_MAX - #define MAXINT INT_MAX -#else - #define MAXINT 0x7fffffff -#endif -#endif - -#ifndef BITSPERBYTE -#define BITSPERBYTE (8 * sizeof(char)) -#endif - -#define BITS(type) (BITSPERBYTE * (int) sizeof(type)) - -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#define MPR_ARRAY_SIZE(type) (sizeof(type) / sizeof(type[0])) - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) && !DOXYGEN && BLD_FEATURE_ALLOC_LEAK_TRACK -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -typedef char *MprStr; /* Used for dynamic strings */ - -#ifdef __cplusplus -extern "C" { -#else -typedef int bool; -#endif - -/******************************************************************************/ -/******************************** Linux Defines *******************************/ -/******************************************************************************/ - -#if LINUX - typedef unsigned char uchar; - -#if BLD_FEATURE_INT64 - __extension__ typedef long long int int64; - __extension__ typedef unsigned long long int uint64; - #define INT64(x) (x##LL) - #define UINT64(x) (x##ULL) -#endif - - #define closesocket(x) close(x) - #define MPR_BINARY "" - #define MPR_TEXT "" - #define O_BINARY 0 - #define O_TEXT 0 - #define SOCKET_ERROR -1 - #define MPR_DLL_EXT ".so" - -#if BLD_FEATURE_FLOATING_POINT - #define MAX_FLOAT MAXFLOAT -#endif - -/* - * For some reason it is removed from fedora pthreads.h and only - * comes in for UNIX96 - */ -extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict - __attr, int *__restrict __kind) __THROW; -/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL, - PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or - PTHREAD_MUTEX_DEFAULT). */ -extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) - __THROW; - -#endif /* LINUX */ - -/******************************************************************************/ -/******************************* VxWorks Defines ******************************/ -/******************************************************************************/ - -#if VXWORKS - - typedef unsigned char uchar; - typedef unsigned int uint; - typedef unsigned long ulong; - - #define HAVE_SOCKLEN_T - typedef int socklen_t; - -#if BLD_FEATURE_INT64 - typedef long long int int64; - typedef unsigned long long int uint64; - #define INT64(x) (x##LL) - #define UINT64(x) (x##ULL) -#endif - - #define closesocket(x) close(x) - #define getpid() taskIdSelf() - #define MPR_BINARY "" - #define MPR_TEXT "" - #define O_BINARY 0 - #define O_TEXT 0 - #define SOCKET_ERROR -1 - #define MPR_DLL_EXT ".so" - -#if BLD_FEATURE_FLOATING_POINT - #define MAX_FLOAT FLT_MAX -#endif - - #undef R_OK - #define R_OK 4 - #undef W_OK - #define W_OK 2 - #undef X_OK - #define X_OK 1 - #undef F_OK - #define F_OK 0 - - #define MSG_NOSIGNAL 0 - - extern int access(char *path, int mode); - extern int sysClkRateGet(); - -#endif /* VXWORKS */ - -/******************************************************************************/ -/******************************** MacOsx Defines ******************************/ -/******************************************************************************/ -#if MACOSX - typedef unsigned long ulong; - typedef unsigned char uchar; - -#if BLD_FEATURE_INT64 - __extension__ typedef long long int int64; - __extension__ typedef unsigned long long int uint64; - #define INT64(x) (x##LL) - #define UINT64(x) (x##ULL) -#endif - - #define closesocket(x) close(x) - #define MPR_BINARY "" - #define MPR_TEXT "" - #define O_BINARY 0 - #define O_TEXT 0 - #define SOCKET_ERROR -1 - #define MPR_DLL_EXT ".dylib" - #define MSG_NOSIGNAL 0 - #define __WALL 0x40000000 - #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE - -#if BLD_FEATURE_FLOATING_POINT - #define MAX_FLOAT MAXFLOAT -#endif - -#endif /* MACOSX */ - -/******************************************************************************/ -/******************************* Windows Defines ******************************/ -/******************************************************************************/ - -#if WIN - typedef unsigned char uchar; - typedef unsigned int uint; - typedef unsigned long ulong; - typedef unsigned short ushort; - -/* - * We always define INT64 types on windows - */ -#if BLD_FEATURE_INT64 || 1 - typedef __int64 int64; - typedef unsigned __int64 uint64; - #define INT64(x) (x##i64) - #define UINT64(x) (x##Ui64) -#endif - - typedef int uid_t; - typedef void *handle; - typedef char *caddr_t; - typedef long pid_t; - typedef int gid_t; - typedef ushort mode_t; - typedef void *siginfo_t; - - #define HAVE_SOCKLEN_T - typedef int socklen_t; - - #undef R_OK - #define R_OK 4 - #undef W_OK - #define W_OK 2 - - /* - * On windows map X_OK to R_OK - */ - #undef X_OK - #define X_OK 4 - #undef F_OK - #define F_OK 0 - - #ifndef EADDRINUSE - #define EADDRINUSE 46 - #endif - #ifndef EWOULDBLOCK - #define EWOULDBLOCK EAGAIN - #endif - #ifndef ENETDOWN - #define ENETDOWN 43 - #endif - #ifndef ECONNRESET - #define ECONNRESET 44 - #endif - #ifndef ECONNREFUSED - #define ECONNREFUSED 45 - #endif - - #define MSG_NOSIGNAL 0 - #define MPR_BINARY "b" - #define MPR_TEXT "t" - -#if BLD_FEATURE_FLOATING_POINT - #define MAX_FLOAT DBL_MAX -#endif - -#ifndef FILE_FLAG_FIRST_PIPE_INSTANCE -#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 -#endif - - #define MPR_DLL_EXT ".dll" -#endif /* WIN */ - -/******************************************************************************/ -/****************************** Solaris Defines *******************************/ -/******************************************************************************/ - -#if SOLARIS - typedef unsigned char uchar; - -#if BLD_FEATURE_INT64 - typedef long long int int64; - typedef unsigned long long int uint64; - #define INT64(x) (x##LL) - #define UINT64(x) (x##ULL) -#endif - - #define closesocket(x) close(x) - #define MPR_BINARY "" - #define MPR_TEXT "" - #define O_BINARY 0 - #define O_TEXT 0 - #define SOCKET_ERROR -1 - #define MPR_DLL_EXT ".so" - #define MSG_NOSIGNAL 0 - #define INADDR_NONE ((in_addr_t) 0xffffffff) - #define __WALL 0 - #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE - -#if BLD_FEATURE_FLOATING_POINT - #define MAX_FLOAT MAXFLOAT -#endif - -#endif /* SOLARIS */ - -/******************************************************************************/ -/********************************* BREW Defines *******************************/ -/******************************************************************************/ - -#if BREW - typedef unsigned char uchar; - typedef unsigned int uint; - typedef unsigned long ulong; - typedef unsigned short ushort; - - typedef uint off_t; - typedef long pid_t; - -#if UNUSED - typedef int uid_t; - typedef void *handle; - typedef char *caddr_t; - typedef int gid_t; - typedef ushort mode_t; - typedef void *siginfo_t; - - #define HAVE_SOCKLEN_T - typedef int socklen_t; - - #ifndef EADDRINUSE - #define EADDRINUSE 46 - #endif - #ifndef EWOULDBLOCK - #define EWOULDBLOCK EAGAIN - #endif - #ifndef ENETDOWN - #define ENETDOWN 43 - #endif - #ifndef ECONNRESET - #define ECONNRESET 44 - #endif - #ifndef ECONNREFUSED - #define ECONNREFUSED 45 - #endif - - #define MSG_NOSIGNAL 0 - #define MPR_BINARY "b" - #define MPR_TEXT "t" - - #define MPR_DLL_EXT ".dll" -#endif - - #define O_RDONLY 0 - #define O_WRONLY 1 - #define O_RDWR 2 - #define O_CREAT 0x200 - #define O_TRUNC 0x400 - #define O_BINARY 0 - #define O_TEXT 0x20000 - #define O_EXCL 0x40000 - #define O_APPEND 0x80000 - - #define R_OK 4 - #define W_OK 2 - #define X_OK 1 - #define F_OK 0 - - #define SEEK_SET 0 - #define SEEK_CUR 1 - #define SEEK_END 2 - -#if UNUSED -struct stat { - uint st_size; -}; -#endif - -extern int getpid(); -extern int isalnum(int c); -extern int isalpha(int c); -extern int isdigit(int c); -extern int islower(int c); -extern int isupper(int c); -extern int isspace(int c); -extern int isxdigit(int c); - -extern uint strlen(const char *str); -extern char *strstr(const char *string, const char *strSet); -extern void *memset(const void *dest, int c, uint count); -extern void exit(int status); -extern char *strpbrk(const char *str, const char *set); -extern uint strspn(const char *str, const char *set); -extern int tolower(int c); -extern int toupper(int c); -extern void *memcpy(void *dest, const void *src, uint count); -extern void *memmove(void *dest, const void *src, uint count); - -extern int atoi(const char *str); -extern void free(void *ptr); -extern void *malloc(uint size); -extern void *realloc(void *ptr, uint size); -extern char *strcat(char *dest, const char *src); -extern char *strchr(const char *str, int c); -extern int strcmp(const char *s1, const char *s2); -extern int strncmp(const char *s1, const char *s2, uint count); -extern char *strcpy(char *dest, const char *src); -extern char *strncpy(char *dest, const char *src, uint count); -extern char *strrchr(const char *str, int c); - -#undef printf -#define printf DBGPRINTF - -#if BREW_SIMULATOR && BLD_DEBUG -extern _CRTIMP int __cdecl _CrtCheckMemory(void); -extern _CRTIMP int __cdecl _CrtSetReportHook(); -#endif - -#endif /* BREW */ - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif - -#endif /* _h_MPR_OS_HDRS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c b/source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c deleted file mode 100644 index 2d0951acfa..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprPrintf.c +++ /dev/null @@ -1,924 +0,0 @@ -/** - * @file mprPrintf.c - * @brief Printf routines safe for embedded programming - * @overview This module provides safe replacements for the standard - * printf formatting routines. - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ -/* - * We need to use the underlying str(cpy) routines to implement our safe - * alternatives - */ -#if !DOXYGEN -#define UNSAFE_FUNCTIONS_OK 1 -#endif - -#include "mpr.h" - -/*********************************** Defines **********************************/ -/* - * Class definitions - */ -#define CLASS_NORMAL 0 /* [All other] Normal characters */ -#define CLASS_PERCENT 1 /* [%] Begin format */ -#define CLASS_MODIFIER 2 /* [-+ #,] Modifiers */ -#define CLASS_ZERO 3 /* [0] Special modifier */ -#define CLASS_STAR 4 /* [*] Width supplied by arg */ -#define CLASS_DIGIT 5 /* [1-9] Field widths */ -#define CLASS_DOT 6 /* [.] Introduce precision */ -#define CLASS_BITS 7 /* [hlL] Length bits */ -#define CLASS_TYPE 8 /* [cdfinopsSuxX] Type specifiers */ - -#define STATE_NORMAL 0 /* Normal chars in format string */ -#define STATE_PERCENT 1 /* "%" */ -#define STATE_MODIFIER 2 /* Read flag */ -#define STATE_WIDTH 3 /* Width spec */ -#define STATE_DOT 4 /* "." */ -#define STATE_PRECISION 5 /* Precision spec */ -#define STATE_BITS 6 /* Size spec */ -#define STATE_TYPE 7 /* Data type */ -#define STATE_COUNT 8 - -/* - * Format: %[modifier][width][precision][bits][type] - * - * #define CLASS_MODIFIER 2 [-+ #,] Modifiers - * #define CLASS_BITS 7 [hlL] Length bits - */ - - -/* - * Flags - */ -#define SPRINTF_LEFT 0x1 /* Left align */ -#define SPRINTF_SIGN 0x2 /* Always sign the result */ -#define SPRINTF_LEAD_SPACE 0x4 /* put leading space for +ve numbers */ -#define SPRINTF_ALTERNATE 0x8 /* Alternate format */ -#define SPRINTF_LEAD_ZERO 0x10 /* Zero pad */ -#define SPRINTF_SHORT 0x20 /* 16-bit */ -#define SPRINTF_LONG 0x40 /* 32-bit */ -#if BLD_FEATURE_INT64 -#define SPRINTF_LONGLONG 0x80 /* 64-bit */ -#endif -#define SPRINTF_COMMA 0x100 /* Thousand comma separators */ -#define SPRINTF_UPPER_CASE 0x200 /* As the name says for numbers */ - -typedef struct Format { - uchar *buf; - uchar *endbuf; - uchar *start; - uchar *end; - int growBy; - int maxsize; - - int precision; - int radix; - int width; - int flags; - int len; -} Format; - -static int growBuf(MPR_LOC_DEC(ctx, loc), Format *fmt); - -#define BPUT(ctx, loc, fmt, c) \ - if (1) { \ - /* Less one to allow room for the null */ \ - if ((fmt)->end >= ((fmt)->endbuf - sizeof(char))) { \ - if (growBuf(MPR_LOC_PASS(ctx, loc), fmt)) { \ - *(fmt)->end++ = (c); \ - } \ - } else { \ - *(fmt)->end++ = (c); \ - } \ - } else - -#define BPUTNULL(ctx, loc, fmt) \ - if (1) { \ - if ((fmt)->end > (fmt)->endbuf) { \ - if (growBuf(MPR_LOC_PASS(ctx, loc), fmt)) { \ - *(fmt)->end = '\0'; \ - } \ - } else { \ - *(fmt)->end = '\0'; \ - } \ - } else - -/******************************************************************************/ - -#if BLD_FEATURE_INT64 -#define unum uint64 -#define num int64 -#else -#define unum uint -#define num int -#endif - -/***************************** Forward Declarations ***************************/ -#ifdef __cplusplus -extern "C" { -#endif - -static int getState(char c, int state); -static int mprSprintfCore(MPR_LOC_DEC(ctx, loc), char **s, - int maxsize, const char *fmt, va_list arg); -static void outNum(MPR_LOC_DEC(ctx, loc), Format *fmt, const char *prefix, - unum val); - -#if BLD_FEATURE_FLOATING_POINT -static void outFloat(MPR_LOC_DEC(ctx, loc), Format *fmt, char specChar, - double value); -#endif - -/******************************************************************************/ - -int mprPrintf(MprCtx ctx, const char *fmt, ...) -{ - va_list ap; - char *buf; - int len; - MprApp *app; - - /* No asserts here as this is used as part of assert reporting */ - - app = mprGetApp(ctx); - - va_start(ap, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, ap); - va_end(ap); - if (len >= 0 && app->console) { - len = mprWrite(app->console, buf, len); - } - mprFree(buf); - - return len; -} - -/******************************************************************************/ - -int mprErrorPrintf(MprCtx ctx, const char *fmt, ...) -{ - va_list ap; - char *buf; - int len; - MprApp *app; - - /* No asserts here as this is used as part of assert reporting */ - - app = mprGetApp(ctx); - - va_start(ap, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(ctx), &buf, 0, fmt, ap); - va_end(ap); - if (len >= 0 && app->error) { - len = mprWrite(app->error, buf, len); - } - mprFree(buf); - - return len; -} - -/******************************************************************************/ - -int mprFprintf(MprFile *file, const char *fmt, ...) -{ - va_list ap; - char *buf; - int len; - - if (file == 0) { - return MPR_ERR_BAD_HANDLE; - } - - va_start(ap, fmt); - len = mprAllocVsprintf(MPR_LOC_ARGS(file), &buf, 0, fmt, ap); - va_end(ap); - - if (len >= 0) { - len = mprWrite(file, buf, len); - } - mprFree(buf); - return len; -} - -/******************************************************************************/ -/* - * Printf with a static buffer. Used internally only. WILL NOT MALLOC. - */ - -int mprStaticPrintf(MprCtx ctx, const char *fmt, ...) -{ - va_list ap; - char buf[MPR_MAX_STRING]; - char *bufp; - int len; - MprApp *app; - - app = mprGetApp(ctx); - - va_start(ap, fmt); - bufp = buf; - len = mprSprintfCore(MPR_LOC_ARGS(0), &bufp, MPR_MAX_STRING, fmt, ap); - va_end(ap); - if (len >= 0) { - len = mprWrite(app->console, buf, len); - } - return len; -} - -/******************************************************************************/ - -int mprSprintf(char *buf, int n, const char *fmt, ...) -{ - va_list ap; - int result; - - mprAssert(buf); - mprAssert(fmt); - mprAssert(n > 0); - - va_start(ap, fmt); - result = mprSprintfCore(MPR_LOC_ARGS(0), &buf, n, fmt, ap); - va_end(ap); - return result; -} - -/******************************************************************************/ - -int mprVsprintf(char *buf, int n, const char *fmt, va_list arg) -{ - mprAssert(buf); - mprAssert(fmt); - mprAssert(n > 0); - - return mprSprintfCore(MPR_LOC_ARGS(0), &buf, n, fmt, arg); -} - -/******************************************************************************/ - -int mprAllocSprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize, - const char *fmt, ...) -{ - va_list ap; - int result; - - mprAssert(buf); - mprAssert(fmt); - - *buf = 0; - va_start(ap, fmt); - result = mprSprintfCore(MPR_LOC_PASS(ctx, loc), buf, maxSize, fmt, ap); - va_end(ap); - return result; -} - -/******************************************************************************/ - -int mprAllocVsprintf(MPR_LOC_DEC(ctx, loc), char **buf, int maxSize, - const char *fmt, va_list arg) -{ - mprAssert(buf); - mprAssert(fmt); - - *buf = 0; - return mprSprintfCore(MPR_LOC_PASS(ctx, loc), buf, maxSize, fmt, arg); -} - -/******************************************************************************/ - -static int getState(char c, int state) -{ - /* - * Declared here to remove all static / globals - * FUTURE OPT -- need to measure this. Could be slow on BREW. - */ - - char stateMap[] = { - /* STATES: Normal Percent Modifier Width Dot Prec Bits Type */ - /* CLASS 0 1 2 3 4 5 6 7 */ - /* Normal 0 */ 0, 0, 0, 0, 0, 0, 0, 0, - /* Percent 1 */ 1, 0, 1, 1, 1, 1, 1, 1, - /* Modifier 2 */ 0, 2, 2, 0, 0, 0, 0, 0, - /* Zero 3 */ 0, 2, 2, 3, 0, 5, 0, 0, - /* Star 4 */ 0, 3, 3, 0, 5, 0, 0, 0, - /* Digit 5 */ 0, 3, 3, 3, 5, 5, 0, 0, - /* Dot 6 */ 0, 4, 4, 4, 0, 0, 0, 0, - /* Bits 7 */ 0, 6, 6, 6, 6, 6, 6, 0, - /* Types 8 */ 0, 7, 7, 7, 7, 7, 7, 0, - }; - - /* - * Format: %[modifier][width][precision][bits][type] - */ - char classMap[] = { - /* 0 ' ' ! " # $ % & ' */ - 2, 0, 0, 2, 0, 1, 0, 0, - /* 07 ( ) * + , - . / */ - 0, 0, 4, 2, 2, 2, 6, 0, - /* 10 0 1 2 3 4 5 6 7 */ - 3, 5, 5, 5, 5, 5, 5, 5, - /* 17 8 9 : ; < = > ? */ - 5, 5, 0, 0, 0, 0, 0, 0, - /* 20 @ A B C D E F G */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 27 H I J K L M N O */ - 0, 0, 0, 0, 7, 0, 0, 0, - /* 30 P Q R S T U V W */ - 0, 0, 0, 8, 0, 0, 0, 0, - /* 37 X Y Z [ \ ] ^ _ */ - 8, 0, 0, 0, 0, 0, 0, 0, - /* 40 ' a b c d e f g */ - 0, 0, 0, 8, 8, 0, 8, 0, - /* 47 h i j k l m n o */ - 7, 8, 0, 0, 7, 0, 8, 8, - /* 50 p q r s t u v w */ - 8, 0, 0, 8, 0, 8, 0, 0, - /* 57 x y z */ - 8, 0, 0, - }; - - int chrClass; - - if (c < ' ' || c > 'z') { - chrClass = CLASS_NORMAL; - } else { - mprAssert((c - ' ') < (int) sizeof(classMap)); - chrClass = classMap[(c - ' ')]; - } - mprAssert((chrClass * STATE_COUNT + state) < (int) sizeof(stateMap)); - state = stateMap[chrClass * STATE_COUNT + state]; - return state; -} - -/******************************************************************************/ - -static int mprSprintfCore(MPR_LOC_DEC(ctx, loc), char **bufPtr, - int maxsize, const char *spec, va_list arg) -{ - Format fmt; - char *cp; - char c; - char *sValue; - num iValue; - unum uValue; - int count, i, len, state; - - mprAssert(bufPtr); - mprAssert(spec); - - if (*bufPtr != 0) { - mprAssert(maxsize > 0); - fmt.buf = (uchar*) *bufPtr; - fmt.endbuf = &fmt.buf[maxsize]; - fmt.growBy = 0; - } else { - if (maxsize <= 0) { - maxsize = MAXINT; - } - - len = min(MPR_DEFAULT_ALLOC, maxsize); - fmt.buf = (uchar*) mprAllocBlock(MPR_LOC_PASS(ctx, loc), len); - fmt.endbuf = &fmt.buf[len]; - fmt.growBy = MPR_DEFAULT_ALLOC * 2; - } - - fmt.maxsize = maxsize; - fmt.start = fmt.buf; - fmt.end = fmt.buf; - fmt.len = 0; - *fmt.start = '\0'; - - state = STATE_NORMAL; - - while ((c = *spec++) != '\0') { - state = getState(c, state); - - switch (state) { - case STATE_NORMAL: - BPUT(ctx, loc, &fmt, c); - break; - - case STATE_PERCENT: - fmt.precision = -1; - fmt.width = 0; - fmt.flags = 0; - break; - - case STATE_MODIFIER: - switch (c) { - case '+': - fmt.flags |= SPRINTF_SIGN; - break; - case '-': - fmt.flags |= SPRINTF_LEFT; - break; - case '#': - fmt.flags |= SPRINTF_ALTERNATE; - break; - case '0': - fmt.flags |= SPRINTF_LEAD_ZERO; - break; - case ' ': - fmt.flags |= SPRINTF_LEAD_SPACE; - break; - case ',': - fmt.flags |= SPRINTF_COMMA; - break; - } - break; - - case STATE_WIDTH: - if (c == '*') { - fmt.width = va_arg(arg, int); - if (fmt.width < 0) { - fmt.width = -fmt.width; - fmt.flags |= SPRINTF_LEFT; - } - } else { - while (isdigit((int)c)) { - fmt.width = fmt.width * 10 + (c - '0'); - c = *spec++; - } - spec--; - } - break; - - case STATE_DOT: - fmt.precision = 0; - fmt.flags &= ~SPRINTF_LEAD_ZERO; - break; - - case STATE_PRECISION: - if (c == '*') { - fmt.precision = va_arg(arg, int); - } else { - while (isdigit((int) c)) { - fmt.precision = fmt.precision * 10 + (c - '0'); - c = *spec++; - } - spec--; - } - break; - - case STATE_BITS: - switch (c) { -#if BLD_FEATURE_INT64 - case 'L': - fmt.flags |= SPRINTF_LONGLONG; /* 64 bit */ - break; -#endif - - case 'l': - fmt.flags |= SPRINTF_LONG; - break; - - case 'h': - fmt.flags |= SPRINTF_SHORT; - break; - } - break; - - case STATE_TYPE: - switch (c) { -#if BLD_FEATURE_FLOATING_POINT - case 'e': - case 'g': - case 'f': - fmt.radix = 10; - outFloat(MPR_LOC_PASS(ctx, loc), &fmt, c, - (double) va_arg(arg, double)); - break; -#endif - case 'c': - BPUT(ctx, loc, &fmt, (char) va_arg(arg, int)); - break; - - case 's': - case 'S': - sValue = va_arg(arg, char*); - if (sValue == 0) { - sValue = "null"; - len = strlen(sValue); - } else if (fmt.flags & SPRINTF_ALTERNATE) { - sValue++; - len = (int) *sValue; - } else if (fmt.precision >= 0) { - /* - * Can't use strlen(), the string may not have a null - */ - cp = sValue; - for (len = 0; len < fmt.precision; len++) { - if (*cp++ == '\0') { - break; - } - } - } else { - len = strlen(sValue); - } - if (!(fmt.flags & SPRINTF_LEFT)) { - for (i = len; i < fmt.width; i++) { - BPUT(ctx, loc, &fmt, (char) ' '); - } - } - for (i = 0; i < len && *sValue; i++) { - BPUT(ctx, loc, &fmt, *sValue++); - } - if (fmt.flags & SPRINTF_LEFT) { - for (i = len; i < fmt.width; i++) { - BPUT(ctx, loc, &fmt, (char) ' '); - } - } - break; - - case 'i': - ; - case 'd': - fmt.radix = 10; - if (fmt.flags & SPRINTF_SHORT) { - iValue = (short) va_arg(arg, int); - } else if (fmt.flags & SPRINTF_LONG) { - iValue = va_arg(arg, long); -#if BLD_FEATURE_INT64 - } else if (fmt.flags & SPRINTF_LONGLONG) { - iValue = va_arg(arg, num); -#endif - } else { - iValue = va_arg(arg, int); - } - if (iValue >= 0) { - if (fmt.flags & SPRINTF_LEAD_SPACE) { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, " ", iValue); - } else if (fmt.flags & SPRINTF_SIGN) { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, "+", iValue); - } else { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, iValue); - } - } else { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, "-", -iValue); - } - break; - - case 'X': - fmt.flags |= SPRINTF_UPPER_CASE; - /* Fall through */ - case 'o': - case 'x': - case 'u': - if (fmt.flags & SPRINTF_SHORT) { - uValue = (ushort) va_arg(arg, uint); - } else if (fmt.flags & SPRINTF_LONG) { - uValue = va_arg(arg, ulong); -#if BLD_FEATURE_INT64 - } else if (fmt.flags & SPRINTF_LONGLONG) { - uValue = va_arg(arg, unum); -#endif - } else { - uValue = va_arg(arg, uint); - } - if (c == 'u') { - fmt.radix = 10; - outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, uValue); - } else if (c == 'o') { - fmt.radix = 8; - if (fmt.flags & SPRINTF_ALTERNATE && uValue != 0) { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0", uValue); - } else { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, uValue); - } - } else { - fmt.radix = 16; - if (fmt.flags & SPRINTF_ALTERNATE && uValue != 0) { - if (c == 'X') { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0X", uValue); - } else { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0x", uValue); - } - } else { - outNum(MPR_LOC_PASS(ctx, loc), &fmt, 0, uValue); - } - } - break; - - case 'n': /* Count of chars seen thus far */ - if (fmt.flags & SPRINTF_SHORT) { - short *count = va_arg(arg, short*); - *count = fmt.end - fmt.start; - } else if (fmt.flags & SPRINTF_LONG) { - long *count = va_arg(arg, long*); - *count = fmt.end - fmt.start; - } else { - int *count = va_arg(arg, int *); - *count = fmt.end - fmt.start; - } - break; - - case 'p': /* Pointer */ -#if __WORDSIZE == 64 && BLD_FEATURE_INT64 - uValue = (unum) va_arg(arg, void*); -#else - uValue = (uint) (int) va_arg(arg, void*); -#endif - fmt.radix = 16; - outNum(MPR_LOC_PASS(ctx, loc), &fmt, "0x", uValue); - break; - - default: - BPUT(ctx, loc, &fmt, c); - } - } - } - BPUTNULL(ctx, loc, &fmt); - - count = fmt.end - fmt.start; - if (*bufPtr == 0) { - *bufPtr = (char*) fmt.buf; - } - return count; -} - -/******************************************************************************/ -/* - * Output a number according to the given format. If BLD_FEATURE_INT64 is - * defined, then uses 64 bits universally. Slower but smaller code. - */ - -static void outNum(MPR_LOC_DEC(ctx, loc), Format *fmt, const char *prefix, - unum value) -{ - char numBuf[64]; - char *cp; - char *endp; - char c; - int letter, len, leadingZeros, i, fill; - - endp = &numBuf[sizeof(numBuf) - 1]; - *endp = '\0'; - cp = endp; - - /* - * Convert to ascii - */ - if (fmt->radix == 16) { - do { - letter = (int) (value % fmt->radix); - if (letter > 9) { - if (fmt->flags & SPRINTF_UPPER_CASE) { - letter = 'A' + letter - 10; - } else { - letter = 'a' + letter - 10; - } - } else { - letter += '0'; - } - *--cp = letter; - value /= fmt->radix; - } while (value > 0); - - } else if (fmt->flags & SPRINTF_COMMA) { - i = 1; - do { - *--cp = '0' + (int) (value % fmt->radix); - value /= fmt->radix; - if ((i++ % 3) == 0 && value > 0) { - *--cp = ','; - } - } while (value > 0); - } else { - do { - *--cp = '0' + (int) (value % fmt->radix); - value /= fmt->radix; - } while (value > 0); - } - - len = endp - cp; - fill = fmt->width - len; - - if (prefix != 0) { - fill -= strlen(prefix); - } - leadingZeros = (fmt->precision > len) ? fmt->precision - len : 0; - fill -= leadingZeros; - - if (!(fmt->flags & SPRINTF_LEFT)) { - c = (fmt->flags & SPRINTF_LEAD_ZERO) ? '0': ' '; - for (i = 0; i < fill; i++) { - BPUT(ctx, loc, fmt, c); - } - } - if (prefix != 0) { - while (*prefix) { - BPUT(ctx, loc, fmt, *prefix++); - } - } - for (i = 0; i < leadingZeros; i++) { - BPUT(ctx, loc, fmt, '0'); - } - while (*cp) { - BPUT(ctx, loc, fmt, *cp); - cp++; - } - if (fmt->flags & SPRINTF_LEFT) { - for (i = 0; i < fill; i++) { - BPUT(ctx, loc, fmt, ' '); - } - } -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Output a floating point number - */ - -static void outFloat(MPR_LOC_DEC(ctx, loc), Format *fmt, char specChar, - double value) -{ - char *cp; -#if FUTURE - char numBuf[64]; - char *endp; - char c; - int letter, len, leadingZeros, i, fill, width, precision; - - endp = &numBuf[sizeof(numBuf) - 1]; - *endp = '\0'; - - precision = fmt->precision; - if (precision < 0) { - precision = 6; - } else if (precision > (sizeof(numBuf) - 1)) { - precision = (sizeof(numBuf) - 1); - } - width = min(fmt->width, sizeof(numBuf) - 1); - - if (__isnanl(value)) { - "nan" - } else if (__isinfl(value)) { - "infinity" - } else if (value < 0) { - prefix = "-"; - } else if (fmt.flags & SPRINTF_LEAD_SPACE) { - prefix = " "; - } else if (fmt.flags & SPRINTF_SIGN) { - prefix = "+"; - } - - - /* - * Do the exponent part - */ - cp = &numBuf[sizeof(numBuf) - precision]; - for (i = 0; i < precision; i++) { - *cp++ = '0' + (int) (value % fmt->radix); - value /= fmt->radix; - } - - /* - * Do the decimal part - */ - if (fmt->flags & SPRINTF_COMMA) { - i = 1; - do { - *--cp = '0' + (int) (value % fmt->radix); - value /= fmt->radix; - if ((i++ % 3) == 0 && value > 0) { - *--cp = ','; - } - } while (value >= 1.0); - - } else { - do { - *--cp = '0' + (int) (value % fmt->radix); - value /= fmt->radix; - } while (value > 1.0); - } - - len = endp - cp; - fill = fmt->width - len; - - if (prefix != 0) { - fill -= strlen(prefix); - } - - leadingZeros = (fmt->precision > len) ? fmt->precision - len : 0; - fill -= leadingZeros; - - if (!(fmt->flags & SPRINTF_LEFT)) { - c = (fmt->flags & SPRINTF_LEAD_ZERO) ? '0': ' '; - for (i = 0; i < fill; i++) { - BPUT(ctx, loc, fmt, c); - } - } - if (prefix != 0) { - BPUT(ctx, loc, fmt, prefix); - } - for (i = 0; i < leadingZeros; i++) { - BPUT(ctx, loc, fmt, '0'); - } - BPUT(ctx, loc, fmt, cp); - if (fmt->flags & SPRINTF_LEFT) { - for (i = 0; i < fill; i++) { - BPUT(ctx, loc, fmt, ' '); - } - } -#else - char numBuf[64]; - if (specChar == 'f') { - sprintf(numBuf, "%*.*f", fmt->width, fmt->precision, value); - } else if (specChar == 'g') { - sprintf(numBuf, "%*.*g", fmt->width, fmt->precision, value); - } else if (specChar == 'e') { - sprintf(numBuf, "%*.*e", fmt->width, fmt->precision, value); - } - for (cp = numBuf; *cp; cp++) { - BPUT(ctx, loc, fmt, *cp); - } -#endif -} - -#endif /* BLD_FEATURE_FLOATING_POINT */ -/******************************************************************************/ -/* - * Grow the buffer to fit new data. Return 1 if the buffer can grow. - * Grow using the growBy size specified when creating the buffer. - */ - -static int growBuf(MPR_LOC_DEC(ctx, loc), Format *fmt) -{ - uchar *newbuf; - int buflen; - - buflen = fmt->endbuf - fmt->buf; - if (fmt->maxsize >= 0 && buflen >= fmt->maxsize) { - return 0; - } - if (fmt->growBy < 0) { - /* - * User supplied buffer - */ - return 0; - } - - newbuf = (uchar*) mprAlloc(ctx, buflen + fmt->growBy); - if (fmt->buf) { - memcpy(newbuf, fmt->buf, buflen); - mprFree(fmt->buf); - } - - buflen += fmt->growBy; - fmt->end = newbuf + (fmt->end - fmt->buf); - fmt->start = newbuf + (fmt->start - fmt->buf); - fmt->buf = newbuf; - fmt->endbuf = &fmt->buf[buflen]; - - /* - * Increase growBy to reduce overhead - */ - if ((buflen + (fmt->growBy * 2)) < fmt->maxsize) { - fmt->growBy *= 2; - } - return 1; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprString.c b/source4/lib/appweb/ejs-2.0/mpr/mprString.c deleted file mode 100644 index d39fc8b746..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprString.c +++ /dev/null @@ -1,733 +0,0 @@ -/** - * @file mprString.c - * @brief String routines safe for embedded programming - * @overview This module provides safe replacements for the standard - * string library. - * @remarks Most routines in this file are not thread-safe. It is the callers - * responsibility to perform all thread synchronization. - */ - -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -#include "mpr.h" - -/********************************** Includes **********************************/ -/* - * We need to use the underlying str(cpy) routines to implement our safe - * alternatives - */ -#if !DOXYGEN -#define UNSAFE_FUNCTIONS_OK 1 -#endif - -/******************************************************************************/ -/**************************** Safe String Handling ****************************/ -/******************************************************************************/ - -int mprStrcpy(char *dest, int destMax, const char *src) -{ - int len; - - mprAssert(dest); - mprAssert(destMax >= 0); - mprAssert(src); - - len = strlen(src); - if (destMax > 0 && len >= destMax && len > 0) { - return MPR_ERR_WONT_FIT; - } - if (len > 0) { - memcpy(dest, src, len); - dest[len] = '\0'; - } else { - *dest = '\0'; - len = 0; - } - return len; -} - -/******************************************************************************/ - -int mprAllocStrcpy(MPR_LOC_DEC(ctx, loc), char **dest, int destMax, - const char *src) -{ - int len; - - mprAssert(dest); - mprAssert(destMax >= 0); - mprAssert(src); - - len = strlen(src); - if (destMax > 0 && len >= destMax) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - if (len > 0) { - *dest = (char*) mprAllocBlock(MPR_LOC_PASS(ctx, loc), len); - memcpy(*dest, src, len); - (*dest)[len] = '\0'; - } else { - *dest = (char*) mprAlloc(ctx, 1); - *dest = '\0'; - len = 0; - } - return len; -} - -/******************************************************************************/ - -int mprMemcpy(char *dest, int destMax, const char *src, int nbytes) -{ - mprAssert(dest); - mprAssert(destMax <= 0 || destMax >= nbytes); - mprAssert(src); - mprAssert(nbytes >= 0); - - if (destMax > 0 && nbytes > destMax) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - if (nbytes > 0) { - memcpy(dest, src, nbytes); - return nbytes; - } else { - return 0; - } -} - -/******************************************************************************/ - -int mprAllocMemcpy(MPR_LOC_DEC(ctx, loc), char **dest, int destMax, - const void *src, int nbytes) -{ - mprAssert(dest); - mprAssert(src); - mprAssert(nbytes > 0); - mprAssert(destMax <= 0 || destMax >= nbytes); - - if (destMax > 0 && nbytes > destMax) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - if (nbytes > 0) { - *dest = (char*) mprAllocBlock(MPR_LOC_PASS(ctx,loc), nbytes); - if (*dest == 0) { - return MPR_ERR_MEMORY; - } - memcpy(*dest, src, nbytes); - } else { - *dest = (char*) mprAlloc(ctx, 1); - } - return nbytes; -} - -/******************************************************************************/ - -static int mprCoreStrcat(MPR_LOC_DEC(ctx, loc), char **destp, int destMax, - int existingLen, const char *delim, const char *src, va_list args) -{ - va_list ap; - char *dest, *str, *dp; - int sepLen, addBytes, required; - - mprAssert(destp); - mprAssert(destMax >= 0); - mprAssert(src); - - dest = *destp; - sepLen = (delim) ? strlen(delim) : 0; - -#ifdef __va_copy - __va_copy(ap, args); -#else - ap = args; -#endif - addBytes = 0; - if (existingLen > 0) { - addBytes += sepLen; - } - str = (char*) src; - - while (str) { - addBytes += strlen(str); - str = va_arg(ap, char*); - if (str) { - addBytes += sepLen; - } - } - - required = existingLen + addBytes + 1; - if (destMax > 0 && required >= destMax) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - - if (ctx != 0) { - if (dest == 0) { - dest = (char*) mprAllocBlock(MPR_LOC_PASS(ctx, loc), required); - } else { - dest = (char*) mprReallocBlock(MPR_LOC_PASS(ctx, loc), dest, - required); - } - } else { - dest = (char*) *destp; - } - - dp = &dest[existingLen]; - if (delim && existingLen > 0) { - strcpy(dp, delim); - dp += sepLen; - } - - if (addBytes > 0) { -#ifdef __va_copy - __va_copy(ap, args); -#else - ap = args; -#endif - str = (char*) src; - while (str) { - strcpy(dp, str); - dp += strlen(str); - str = va_arg(ap, char*); - if (delim && str) { - strcpy(dp, delim); - dp += sepLen; - } - } - } else if (dest == 0) { - dest = (char*) mprAlloc(ctx, 1); - } - *dp = '\0'; - - *destp = dest; - mprAssert(dp < &dest[required]); - return required - 1; -} - -/***************************************************************************** - Note that this VARARGS function must be NULL (not 0, this must be a - pointer) terminated -*/ -int mprStrcat(char *dest, int destMax, const char *delim, const char *src, ...) -{ - va_list ap; - int rc; - - mprAssert(dest); - mprAssert(src); - - va_start(ap, src); - rc = mprCoreStrcat(MPR_LOC_ARGS(0), &dest, destMax, strlen(dest), - delim, src, ap); - va_end(ap); - return rc; -} - -/***************************************************************************** - Note that this VARARGS function must be NULL (not 0, this must be a - pointer) terminated -*/ -int mprAllocStrcat(MPR_LOC_DEC(ctx, loc), char **destp, int destMax, - const char *delim, const char *src, ...) -{ - va_list ap; - int rc; - - mprAssert(destp); - mprAssert(src); - - *destp = 0; - va_start(ap, src); - rc = mprCoreStrcat(MPR_LOC_PASS(ctx, loc), destp, destMax, 0, delim, - src, ap); - va_end(ap); - return rc; -} - -/***************************************************************************** - Note that this VARARGS function must be NULL (not 0, this must be a - pointer) terminated -*/ -int mprReallocStrcat(MPR_LOC_DEC(ctx, loc), char **destp, int destMax, - int existingLen, const char *delim, const char *src,...) -{ - va_list ap; - int rc; - - va_start(ap, src); - rc = mprCoreStrcat(MPR_LOC_PASS(ctx, loc), destp, destMax, existingLen, - delim, src, ap); - va_end(ap); - return rc; -} - -/******************************************************************************/ - -int mprStrlen(const char *src, int max) -{ - int len; - - len = strlen(src); - if (len >= max) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - return len; -} - -/******************************************************************************/ - -char *mprStrTrim(char *str, const char *set) -{ - int len, i; - - if (str == 0 || set == 0) { - return str; - } - - i = strspn(str, set); - str += i; - - len = strlen(str); - while (strspn(&str[len - 1], set) > 0) { - str[len - 1] = '\0'; - len--; - } - return str; -} - -/******************************************************************************/ -/* - * Map a string to lower case (overwrites original string) - */ - -char *mprStrLower(char *str) -{ - char *cp; - - mprAssert(str); - - if (str == 0) { - return 0; - } - - for (cp = str; *cp; cp++) { - if (isupper(*cp)) { - *cp = (char) tolower(*cp); - } - } - return str; -} - -/******************************************************************************/ -/* - * Map a string to upper case (overwrites buffer) - */ - -char *mprStrUpper(char *str) -{ - char *cp; - - mprAssert(str); - if (str == 0) { - return 0; - } - - for (cp = str; *cp; cp++) { - if (islower(*cp)) { - *cp = (char) toupper(*cp); - } - } - return str; -} - -/******************************************************************************/ -/* - * Case insensitive string comparison. Stop at the end of str1. - */ - -int mprStrcmpAnyCase(const char *str1, const char *str2) -{ - int rc; - - if (str1 == 0 || str2 == 0) { - return -1; - } - if (str1 == str2) { - return 0; - } - - for (rc = 0; *str1 && rc == 0; str1++, str2++) { - rc = tolower(*str1) - tolower(*str2); - } - if (*str2) { - return -1; - } - return rc; -} - -/******************************************************************************/ -/* - * Case insensitive string comparison. Limited by length - */ - -int mprStrcmpAnyCaseCount(const char *str1, const char *str2, int len) -{ - int rc; - - if (str1 == 0 || str2 == 0) { - return -1; - } - if (str1 == str2) { - return 0; - } - - for (rc = 0; len-- > 0 && *str1 && rc == 0; str1++, str2++) { - rc = tolower(*str1) - tolower(*str2); - } - return rc; -} - -/******************************************************************************/ -/* - * Return the last portion of a pathname - */ - -const char *mprGetBaseName(const char *name) -{ - char *cp; - - cp = strrchr(name, '/'); - - if (cp == 0) { - cp = strrchr(name, '\\'); - if (cp == 0) { - return name; - } - } - if (cp == name) { - if (cp[1] == '\0') { - return name; - } - } else { - if (cp[1] == '\0') { - return ""; - } - } - return &cp[1]; -} - -/******************************************************************************/ -/* - * Return the directory portion of a pathname into the users buffer. - */ - -char *mprGetDirName(char *buf, int bufsize, const char *path) -{ - char *cp; - int dlen; - - mprAssert(path); - mprAssert(buf); - mprAssert(bufsize > 0); - - cp = strrchr(path, '/'); - if (cp == 0) { -#if WIN - cp = strrchr(path, '\\'); - if (cp == 0) -#endif - { - buf[0] = '\0'; - return buf; - } - } - - if (cp == path && cp[1] == '\0') { - strcpy(buf, "."); - return buf; - } - - dlen = cp - path; - if (dlen < bufsize) { - if (dlen == 0) { - dlen++; - } - mprMemcpy(buf, bufsize, path, dlen); - buf[dlen] = '\0'; - return buf; - } - return 0; -} - -/******************************************************************************/ -/* - * Thread-safe wrapping of strtok. Note "str" is modifed as per strtok() - */ - -char *mprStrTok(char *str, const char *delim, char **last) -{ - char *start, *end; - int i; - - start = str ? str : *last; - - if (start == 0) { - return 0; - } - - i = strspn(start, delim); - start += i; - if (*start == '\0') { - *last = 0; - return 0; - } - end = strpbrk(start, delim); - if (end) { - *end++ = '\0'; - i = strspn(end, delim); - end += i; - } - *last = end; - return start; -} - -/******************************************************************************/ -/* - * Split the buffer into word tokens - */ - -char *mprGetWordTok(char *buf, int bufsize, const char *str, const char *delim, - const char **tok) -{ - const char *start, *end; - int i, len; - - start = str ? str : *tok; - - if (start == 0) { - return 0; - } - - i = strspn(start, delim); - start += i; - if (*start =='\0') { - *tok = 0; - return 0; - } - end = strpbrk(start, delim); - if (end) { - len = min(end - start, bufsize - 1); - mprMemcpy(buf, bufsize, start, len); - buf[len] = '\0'; - } else { - if (mprStrcpy(buf, bufsize, start) < 0) { - buf[bufsize - 1] = '\0'; - return 0; - } - buf[bufsize - 1] = '\0'; - } - *tok = end; - return buf; -} - -/******************************************************************************/ -/* - * Format a number as a string. - */ - -char *mprItoa(char *buf, int size, int value) -{ - char numBuf[16]; - char *cp, *dp, *endp; - int negative; - - cp = &numBuf[sizeof(numBuf)]; - *--cp = '\0'; - - if (value < 0) { - negative = 1; - value = -value; - size--; - } else { - negative = 0; - } - - do { - *--cp = '0' + (value % 10); - value /= 10; - } while (value > 0); - - if (negative) { - *--cp = '-'; - } - - dp = buf; - endp = &buf[size]; - while (dp < endp && *cp) { - *dp++ = *cp++; - } - *dp++ = '\0'; - return buf; -} - -/******************************************************************************/ -/* - * Parse an ascii number. Supports radix 10 or 16. - */ - -int mprAtoi(const char *str, int radix) -{ - int c, val, negative; - - mprAssert(radix == 10 || radix == 16); - - if (str == 0) { - return 0; - } - - val = 0; - if (radix == 10 && *str == '-') { - negative = 1; - str++; - } else { - negative = 0; - } - - if (radix == 10) { - while (*str && isdigit(*str)) { - val = (val * radix) + *str - '0'; - str++; - } - } else if (radix == 16) { - if (*str == '0' && tolower(str[1]) == 'x') { - str += 2; - } - while (*str) { - c = tolower(*str); - if (isdigit(c)) { - val = (val * radix) + c - '0'; - } else if (c >= 'a' && c <= 'f') { - val = (val * radix) + c - 'a' + 10; - } else { - break; - } - str++; - } - } - - return (negative) ? -val: val; -} - -/******************************************************************************/ -/* - * Make an argv array. Caller must free by calling mprFree(argv) to free - * everything. - */ - -int mprMakeArgv(MprCtx ctx, const char *program, const char *cmd, - char ***argvp, int *argcp) -{ - char *cp, **argv, *buf, *args; - int size, argc; - - /* - * Allocate one buffer for argv and the actual args themselves - */ - size = strlen(cmd) + 1; - - buf = (char*) mprAlloc(ctx, (MPR_MAX_ARGC * sizeof(char*)) + size); - if (buf == 0) { - return MPR_ERR_MEMORY; - } - - args = &buf[MPR_MAX_ARGC * sizeof(char*)]; - strcpy(args, cmd); - argv = (char**) buf; - - argc = 0; - if (program) { - argv[argc++] = (char*) mprStrdup(ctx, program); - } - - for (cp = args; cp && *cp != '\0'; argc++) { - if (argc >= MPR_MAX_ARGC) { - mprAssert(argc < MPR_MAX_ARGC); - mprFree(buf); - *argvp = 0; - if (argcp) { - *argcp = 0; - } - return MPR_ERR_TOO_MANY; - } - while (isspace(*cp)) { - cp++; - } - if (*cp == '\0') { - break; - } - if (*cp == '"') { - cp++; - argv[argc] = cp; - while ((*cp != '\0') && (*cp != '"')) { - cp++; - } - } else { - argv[argc] = cp; - while (*cp != '\0' && !isspace(*cp)) { - cp++; - } - } - if (*cp != '\0') { - *cp++ = '\0'; - } - } - argv[argc] = 0; - - if (argcp) { - *argcp = argc; - } - *argvp = argv; - - return argc; -} - -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c b/source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c deleted file mode 100644 index 11ac278db4..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprSymbol.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * @file mprSym.cpp - * @brief Fast hashing symbol table lookup module - * @overview This symbol table uses a fast key lookup mechanism. Keys are - * strings and the value entries are arbitrary pointers. The keys are - * hashed into a series of buckets which then have a chain of hash - * entries using the standard doubly linked list classes (List/Link). - * The chain in in collating sequence so search time through the chain - * is on average (N/hashSize)/2. - * @remarks This module is not thread-safe. It is the callers responsibility - * to perform all thread synchronization. - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http: *www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http: *www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "mpr.h" - -/**************************** Forward Declarations ****************************/ - -static int hashIndex(const char *key, int size); -static MprSymbol *lookupInner(int *bucketIndex, MprSymbol **prevSp, - MprSymbolTable *table, const char *key); - -/*********************************** Code *************************************/ -/* - * Create a new symbol table of a given size. Caller should provide a size - * that is a prime number for the greatest efficiency. Caller should use - * mprFree to free the symbol table. - */ - -MprSymbolTable *mprCreateSymbolTable(MprCtx ctx, int hashSize) -{ - MprSymbolTable *table; - - table = mprAllocTypeZeroed(ctx, MprSymbolTable); - if (table == 0) { - return 0; - } - - if (hashSize < MPR_DEFAULT_HASH_SIZE) { - hashSize = MPR_DEFAULT_HASH_SIZE; - } - table->hashSize = hashSize; - - table->count = 0; - table->hashSize = hashSize; - table->buckets = mprAllocZeroedBlock(MPR_LOC_ARGS(table), - sizeof(MprSymbol*) * hashSize); - - if (table->buckets == 0) { - mprFree(table); - return 0; - } - - return table; -} - -/******************************************************************************/ -/* - * Insert an entry into the symbol table. If the entry already exists, update - * its value. Order of insertion is not preserved. - */ - -MprSymbol *mprInsertSymbol(MprSymbolTable *table, const char *key, void *ptr) -{ - MprSymbol *sp, *prevSp; - int index; - - sp = lookupInner(&index, &prevSp, table, key); - - if (sp != 0) { - /* - * Already exists. Just update the data. - */ - sp->data = ptr; - return sp; - } - - /* - * New entry - */ - sp = mprAllocTypeZeroed(table, MprSymbol); - if (sp == 0) { - return 0; - } - - sp->data = ptr; - sp->key = mprStrdup(sp, key); - sp->bucket = index; - - sp->next = table->buckets[index]; - table->buckets[index] = sp; - - table->count++; - return sp; -} - -/******************************************************************************/ -/* - * Remove an entry from the table - */ - -int mprRemoveSymbol(MprSymbolTable *table, const char *key) -{ - MprSymbol *sp, *prevSp; - int index; - - if ((sp = lookupInner(&index, &prevSp, table, key)) == 0) { - return MPR_ERR_NOT_FOUND; - } - - if (prevSp) { - prevSp->next = sp->next; - } else { - table->buckets[index] = sp->next; - } - table->count--; - - mprFree(sp); - return 0; -} - -/******************************************************************************/ -/* - * Lookup a key and return the hash entry - */ - -void *mprLookupSymbol(MprSymbolTable *table, const char *key) -{ - MprSymbol *sp; - - mprAssert(key); - - sp = lookupInner(0, 0, table, key); - if (sp == 0) { - return 0; - } - return sp->data; -} - -/******************************************************************************/ - -static MprSymbol *lookupInner(int *bucketIndex, MprSymbol **prevSp, - MprSymbolTable *table, const char *key) -{ - MprSymbol *sp, *prev; - int index, rc; - - mprAssert(key); - - index = hashIndex(key, table->hashSize); - if (bucketIndex) { - *bucketIndex = index; - } - - sp = table->buckets[index]; - prev = 0; - - while (sp) { - rc = strcmp(sp->key, key); - if (rc == 0) { - if (prevSp) { - *prevSp = prev; - } - return sp; - } - prev = sp; - mprAssert(sp != sp->next); - sp = sp->next; - } - return 0; -} - -/******************************************************************************/ - -int mprGetSymbolCount(MprSymbolTable *table) -{ - return table->count; -} - -/******************************************************************************/ -/* - * Return the first entry in the table. - */ - -MprSymbol *mprGetFirstSymTab(MprSymbolTable *table) -{ - MprSymbol *sp; - int i; - - mprAssert(table); - - for (i = 0; i < table->hashSize; i++) { - if ((sp = (MprSymbol*) table->buckets[i]) != 0) { - return sp; - } - } - return 0; -} - -/******************************************************************************/ -/* - * Return the next entry in the table - */ - -MprSymbol *mprGetNextSymTab(MprSymbolTable *table, MprSymbol *last) -{ - MprSymbol *sp; - int i; - - mprAssert(table); - - if (last->next) { - return last->next; - } - - for (i = last->bucket + 1; i < table->hashSize; i++) { - if ((sp = (MprSymbol*) table->buckets[i]) != 0) { - return sp; - } - } - return 0; -} - -/******************************************************************************/ -/* - * Hash the key to produce a hash index. - */ - -static int hashIndex(const char *key, int size) -{ - uint sum; - - sum = 0; - while (*key) { - sum += (sum * 33) + *key++; - } - - return sum % size; -} - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs-2.0/mpr/mprUnix.h b/source4/lib/appweb/ejs-2.0/mpr/mprUnix.h deleted file mode 100644 index fbbe29ae9c..0000000000 --- a/source4/lib/appweb/ejs-2.0/mpr/mprUnix.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * @file mprUnix.h - * @brief Make windows a bit more unix like - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2006. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/******************************* Documentation ********************************/ - -/* - * This header is part of the Mbedthis Portable Runtime and aims to include - * all necessary O/S headers and to unify the constants and declarations - * required by Mbedthis products. It can be included by C or C++ programs. - */ - -/******************************************************************************/ - -#ifndef _h_MPR_UNIX -#define _h_MPR_UNIX 1 - -/******************************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Define BLD_NO_POSIX_REMAP if these defines mess with your app - */ -#if WIN && !BLD_NO_POSIX_REMAP -/* - * MOB -- clashes with ATL - */ -#define access _access -#define close _close -#define fileno _fileno -#define fstat _fstat -#define getpid _getpid -#define open _open -#define putenv _putenv -#define read _read -#define stat _stat -#define umask _umask -#define unlink _unlink -#define write _write -#define strdup _strdup -#define lseek _lseek -#define getcwd _getcwd -#define chdir _chdir - -#define mkdir(a,b) _mkdir(a) -#define rmdir(a) _rmdir(a) - -#define R_OK 4 -#define W_OK 2 -#define MPR_TEXT "t" - -extern void srand48(long); -extern long lrand48(void); -extern long ulimit(int, ...); -extern long nap(long); -extern int getuid(void); -extern int geteuid(void); -#endif - - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif - -#endif /* _h_MPR_UNIX */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs/config.h b/source4/lib/appweb/ejs/config.h deleted file mode 100644 index 8c06d28147..0000000000 --- a/source4/lib/appweb/ejs/config.h +++ /dev/null @@ -1,141 +0,0 @@ -#define BLD_PRODUCT "Samba4" -#define BLD_NAME "Samba4 WEB Applications" -#define BLD_VERSION "4" -#define BLD_NUMBER "1" -#define BLD_TYPE "DEBUG" -#define BLD_DEFAULTS "normal" -#define BLD_PACKAGES "" -#define BLD_APPWEB_CONFIG "normal.conf" -#define BLD_APPWEB 0 -#define BLD_COMPANY "Mbedthis" -#define BLD_DEBUG 0 -#define BLD_DIRS "bootstrap include obj bin mpr ejs esp http doc appWeb appWebSamples images" -#define BLD_HTTP_PORT 7777 -#define BLD_LIB_VERSION "1.0.0" -#define BLD_SSL_PORT 4443 -#define BLD_CLEAN_INSTALL "0" -#define BLD_LICENSE "gpl" -#define BLD_HOST_SYSTEM "i686-pc-linux-gnu" -#define BLD_BUILD_SYSTEM "i686-pc-linux-gnu" -#define BLD_HOST_OS "LINUX" -#define BLD_HOST_CPU_ARCH MPR_CPU_IX86 -#define BLD_HOST_CPU "i686" -#define BLD_HOST_UNIX 1 -#define BLD_BUILD_OS "LINUX" -#define BLD_BUILD_CPU_ARCH MPR_CPU_IX86 -#define BLD_BUILD_CPU i686 -#define BLD_BUILD_UNIX 1 -#define BLD_ROOT_PREFIX "/" -#define BLD_FEATURE_ACCESS_LOG 0 -#define BLD_FEATURE_ADMIN_MODULE 0 -#define BLD_FEATURE_ASPNET_MODULE 0 -#define BLD_FEATURE_ASSERT 1 -#define BLD_FEATURE_AUTH_MODULE 0 -#define BLD_FEATURE_C_API_MODULE 1 -#define BLD_FEATURE_C_API_CLIENT 0 -#define BLD_FEATURE_CGI_MODULE 0 -#define BLD_FEATURE_COMPAT_MODULE 0 -#define BLD_FEATURE_CONFIG_PARSE 0 -#define BLD_FEATURE_CONFIG_SAVE 0 -#define BLD_FEATURE_COOKIE 0 -#define BLD_FEATURE_COPY_MODULE 0 -#define BLD_FEATURE_DIGEST 0 -#define BLD_FEATURE_DLL 0 -#define BLD_FEATURE_EGI_MODULE 0 -#define BLD_FEATURE_EJS 1 -#define BLD_FEATURE_ESP_MODULE 1 -#define BLD_FEATURE_EVAL_PERIOD 30 -#define BLD_FEATURE_FLOATING_POINT 1 -#define BLD_FEATURE_IF_MODIFIED 0 -#define BLD_FEATURE_INT64 1 -#define BLD_FEATURE_KEEP_ALIVE 0 -#define BLD_FEATURE_LEGACY_API 0 -#define BLD_FEATURE_LIB_STDCPP 0 -#define BLD_FEATURE_LICENSE 0 -#define BLD_FEATURE_LOG 0 -#define BLD_FEATURE_MULTITHREAD 0 -#define BLD_FEATURE_MALLOC 0 -#define BLD_FEATURE_MALLOC_STATS 0 -#define BLD_FEATURE_MALLOC_LEAK 0 -#define BLD_FEATURE_MALLOC_HOOK 0 -#define BLD_FEATURE_NUM_TYPE int64_t -#define BLD_FEATURE_NUM_TYPE_ID MPR_TYPE_INT64 -#define BLD_FEATURE_ROMFS 0 -#define BLD_FEATURE_RUN_AS_SERVICE 0 -#define BLD_FEATURE_SAFE_STRINGS 0 -#define BLD_FEATURE_SAMPLES 0 -#define BLD_FEATURE_SESSION 1 -#define BLD_FEATURE_SHARED 0 -#define BLD_FEATURE_SQUEEZE 0 -#define BLD_FEATURE_SSL_MODULE 0 -#define BLD_FEATURE_STATIC 1 -#define BLD_FEATURE_STATIC_LINK_LIBC 0 -#define BLD_FEATURE_TEST 0 -#define BLD_FEATURE_UPLOAD_MODULE 0 -#define BLD_FEATURE_XDB_MODULE 0 -#define BLD_FEATURE_ADMIN_MODULE_BUILTIN 0 -#define BLD_FEATURE_ASPNET_MODULE_BUILTIN 0 -#define BLD_FEATURE_AUTH_MODULE_BUILTIN 0 -#define BLD_FEATURE_C_API_MODULE_BUILTIN 0 -#define BLD_FEATURE_CGI_MODULE_BUILTIN 0 -#define BLD_FEATURE_COMPAT_MODULE_BUILTIN 0 -#define BLD_FEATURE_COPY_MODULE_BUILTIN 0 -#define BLD_FEATURE_EGI_MODULE_BUILTIN 0 -#define BLD_FEATURE_ESP_MODULE_BUILTIN 0 -#define BLD_FEATURE_SSL_MODULE_BUILTIN 0 -#define BLD_FEATURE_UPLOAD_MODULE_BUILTIN 0 -#define BLD_FEATURE_XDB_MODULE_BUILTIN 0 -#define BLD_FEATURE_ADMIN_MODULE_LOADABLE 0 -#define BLD_FEATURE_ASPNET_MODULE_LOADABLE 0 -#define BLD_FEATURE_AUTH_MODULE_LOADABLE 0 -#define BLD_FEATURE_C_API_MODULE_LOADABLE 0 -#define BLD_FEATURE_CGI_MODULE_LOADABLE 0 -#define BLD_FEATURE_COMPAT_MODULE_LOADABLE 0 -#define BLD_FEATURE_COPY_MODULE_LOADABLE 0 -#define BLD_FEATURE_EGI_MODULE_LOADABLE 0 -#define BLD_FEATURE_ESP_MODULE_LOADABLE 0 -#define BLD_FEATURE_SSL_MODULE_LOADABLE 0 -#define BLD_FEATURE_UPLOAD_MODULE_LOADABLE 0 -#define BLD_FEATURE_XDB_MODULE_LOADABLE 0 -#define BLD_AR_FOR_BUILD "ar" -#define BLD_CC_FOR_BUILD "cc" -#define BLD_CSC_FOR_BUILD "" -#define BLD_JAVAC_FOR_BUILD "" -#define BLD_LD_FOR_BUILD "ld" -#define BLD_RANLIB_FOR_BUILD "" -#define BLD_NM_FOR_BUILD "nm" -#define BLD_CFLAGS_FOR_BUILD "" -#define BLD_IFLAGS_FOR_BUILD "" -#define BLD_LDFLAGS_FOR_BUILD "" -#define BLD_ARCHIVE_FOR_BUILD ".a" -#define BLD_EXE_FOR_BUILD "" -#define BLD_OBJ_FOR_BUILD ".o" -#define BLD_PIOBJ_FOR_BUILD ".lo" -#define BLD_CLASS_FOR_BUILD ".class" -#define BLD_SHLIB_FOR_BUILD "" -#define BLD_SHOBJ_FOR_BUILD ".so" -#define BLD_AR_FOR_HOST "ar" -#define BLD_CC_FOR_HOST "cc" -#define BLD_CSC_FOR_HOST "csc" -#define BLD_JAVAC_FOR_HOST "javac" -#define BLD_LD_FOR_HOST "ld" -#define BLD_RANLIB_FOR_HOST "true" -#define BLD_NM_FOR_HOST "nm" -#define BLD_CFLAGS_FOR_HOST "" -#define BLD_IFLAGS_FOR_HOST "" -#define BLD_LDFLAGS_FOR_HOST "" -#define BLD_ARCHIVE_FOR_HOST ".a" -#define BLD_EXE_FOR_HOST "" -#define BLD_OBJ_FOR_HOST ".o" -#define BLD_PIOBJ_FOR_HOST ".lo" -#define BLD_CLASS_FOR_HOST ".class" -#define BLD_SHLIB_FOR_HOST "" -#define BLD_SHOBJ_FOR_HOST ".so" -#define BLD_TOOLS_DIR "${BLD_TOP}/bin" -#define BLD_BIN_DIR "${BLD_TOP}/bin" -#define BLD_INC_DIR "/usr/include/${BLD_PRODUCT}" -#define BLD_EXP_OBJ_DIR "${BLD_TOP}/obj" - -#ifndef MAX_FLOAT -#define MAX_FLOAT 3.40282347e+38F -#endif diff --git a/source4/lib/appweb/ejs/ejs.h b/source4/lib/appweb/ejs/ejs.h deleted file mode 100644 index c7b0c54d8e..0000000000 --- a/source4/lib/appweb/ejs/ejs.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * @file ejs.h - * @brief Primary Embedded Javascript (ECMAScript) header. - * @overview This Embedded Javascript (EJS) header defines the - * public API. This API should only be used by those directly - * using EJS without using Embedded Server Pages (ESP). ESP - * wraps all relevant APIs to expose a single consistent API. - * \n\n - * This API requires the mpr/var.h facilities to create and - * manage objects and properties. - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#ifndef _h_EJS -#define _h_EJS 1 - -#include "lib/appweb/mpr/miniMpr.h" -#include "lib/appweb/mpr/var.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/********************************* Prototypes *********************************/ - -typedef MprVarHandle EjsId; -typedef MprVarHandle EjsHandle; - -/* - * Multithreaded lock routines - */ -typedef void (*EjsLock)(void *lockData); -typedef void (*EjsUnlock)(void *lockData); - -/********************************* Prototypes *********************************/ -/* - * Module management - */ -extern int ejsOpen(EjsLock lock, EjsUnlock unlock, void *lockData); -extern void ejsClose(void); -extern EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle); -extern void ejsCloseEngine(EjsId eid); - -void *ejs_save_state(void); -void ejs_restore_state(void *ptr); - -/* - * Evaluation functions - */ -extern int ejsEvalFile(EjsId eid, char *path, MprVar *result, char **emsg); -extern int ejsEvalScript(EjsId eid, char *script, MprVar *result, - char **emsg); -extern int ejsRunFunction(int eid, MprVar *obj, const char *functionName, - MprArray *args); - -/* - * Composite variable get / set routines. Can also use the MPR property - * routines on an object variable. - */ -extern MprVar ejsCreateObj(const char *name, int hashSize); -extern MprVar ejsCreateArray(const char *name, int hashSize); -extern bool ejsDestroyVar(MprVar *obj); -extern int ejsCopyVar(EjsId eid, const char *var, MprVar *value, - bool copyRef); -extern int ejsReadVar(EjsId eid, const char *var, MprVar *value); -extern int ejsWriteVar(EjsId eid, const char *var, MprVar *value); -extern int ejsWriteVarValue(EjsId eid, const char *var, MprVar value); -extern int ejsDeleteVar(EjsId eid, const char *var); - -extern MprVar *ejsGetLocalObject(EjsId eid); -extern MprVar *ejsGetGlobalObject(EjsId eid); - -/* - * Function routines - */ -extern void ejsDefineFunction(EjsId eid, const char *functionName, - char *args, char *body); -extern void ejsDefineCFunction(EjsId eid, const char *functionName, - MprCFunction fn, void *thisPtr, int flags); -extern void ejsDefineStringCFunction(EjsId eid, const char *functionName, - MprStringCFunction fn, void *thisPtr, int flags); -extern void *ejsGetThisPtr(EjsId eid); -extern MprVar *ejsGetReturnValue(EjsId eid); -extern int ejsGetLineNumber(EjsId eid); -extern int ejsParseArgs(int argc, char **argv, char *fmt, ...); -extern void ejsSetErrorMsg(EjsId eid, const char* fmt, ...) - PRINTF_ATTRIBUTE(2,3); -extern void ejsSetReturnValue(EjsId eid, MprVar value); -extern void ejsSetReturnString(EjsId eid, const char *str); - -#ifdef __cplusplus -} -#endif -#endif /* _h_EJS */ - -/*****************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs/ejsInternal.h b/source4/lib/appweb/ejs/ejsInternal.h deleted file mode 100644 index 8b66dafdca..0000000000 --- a/source4/lib/appweb/ejs/ejsInternal.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * @file ejsInternal.h - * @brief Private header for Embedded Javascript (ECMAScript) - * @overview This Embedded Javascript header defines the private Embedded - * Javascript internal structures. - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************* Includes ***********************************/ - -#ifndef _h_EJS_INTERNAL -#define _h_EJS_INTERNAL 1 - -#include "ejs.h" - -/********************************** Defines ***********************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Constants - */ - -#if BLD_FEATURE_SQUEEZE - #define EJS_PARSE_INCR 256 /* Growth factor */ - #define EJS_MAX_RECURSE 25 /* Sanity for maximum recursion */ - #define EJS_MAX_ID 128 /* Maximum ID length */ - #define EJS_OBJ_HASH_SIZE 13 /* Object hash table size */ - #define EJS_SMALL_OBJ_HASH_SIZE 11 /* Small object hash size */ - #define EJS_LIST_INCR 8 /* Growth increment for lists */ -#else - #define EJS_PARSE_INCR 1024 /* Growth factor */ - #define EJS_MAX_RECURSE 100 /* Sanity for maximum recursion */ - #define EJS_MAX_ID 256 /* Maximum ID length */ - #define EJS_OBJ_HASH_SIZE 29 /* Object hash table size */ - #define EJS_SMALL_OBJ_HASH_SIZE 11 /* Small object hash size */ - #define EJS_LIST_INCR 16 /* Growth increment for lists */ -#endif -#define EJS_TOKEN_STACK 4 /* Put back token stack */ - -/* - * Lexical analyser tokens - */ -#define EJS_TOK_ERR -1 /* Any error */ -#define EJS_TOK_LPAREN 1 /* ( */ -#define EJS_TOK_RPAREN 2 /* ) */ -#define EJS_TOK_IF 3 /* if */ -#define EJS_TOK_ELSE 4 /* else */ -#define EJS_TOK_LBRACE 5 /* { */ -#define EJS_TOK_RBRACE 6 /* } */ -#define EJS_TOK_LOGICAL 7 /* ||, &&, ! */ -#define EJS_TOK_EXPR 8 /* +, -, /, % */ -#define EJS_TOK_SEMI 9 /* ; */ -#define EJS_TOK_LITERAL 10 /* literal string */ -#define EJS_TOK_FUNCTION_NAME 11 /* functionName */ -#define EJS_TOK_NEWLINE 12 /* newline white space */ -#define EJS_TOK_ID 13 /* Identifier */ -#define EJS_TOK_EOF 14 /* End of script */ -#define EJS_TOK_COMMA 15 /* Comma */ -#define EJS_TOK_VAR 16 /* var */ -#define EJS_TOK_ASSIGNMENT 17 /* = */ -#define EJS_TOK_FOR 18 /* for */ -#define EJS_TOK_INC_DEC 19 /* ++, -- */ -#define EJS_TOK_RETURN 20 /* return */ -#define EJS_TOK_PERIOD 21 /* . */ -#define EJS_TOK_LBRACKET 22 /* [ */ -#define EJS_TOK_RBRACKET 23 /* ] */ -#define EJS_TOK_NEW 24 /* new */ -#define EJS_TOK_DELETE 25 /* delete */ -#define EJS_TOK_IN 26 /* in */ -#define EJS_TOK_FUNCTION 27 /* function */ -#define EJS_TOK_NUMBER 28 /* Number */ - -/* - * Expression operators - */ -#define EJS_EXPR_LESS 1 /* < */ -#define EJS_EXPR_LESSEQ 2 /* <= */ -#define EJS_EXPR_GREATER 3 /* > */ -#define EJS_EXPR_GREATEREQ 4 /* >= */ -#define EJS_EXPR_EQ 5 /* == */ -#define EJS_EXPR_NOTEQ 6 /* != */ -#define EJS_EXPR_PLUS 7 /* + */ -#define EJS_EXPR_MINUS 8 /* - */ -#define EJS_EXPR_DIV 9 /* / */ -#define EJS_EXPR_MOD 10 /* % */ -#define EJS_EXPR_LSHIFT 11 /* << */ -#define EJS_EXPR_RSHIFT 12 /* >> */ -#define EJS_EXPR_MUL 13 /* * */ -#define EJS_EXPR_ASSIGNMENT 14 /* = */ -#define EJS_EXPR_INC 15 /* ++ */ -#define EJS_EXPR_DEC 16 /* -- */ -#define EJS_EXPR_BOOL_COMP 17 /* ! */ - -/* - * Conditional operators - */ -#define EJS_COND_AND 1 /* && */ -#define EJS_COND_OR 2 /* || */ -#define EJS_COND_NOT 3 /* ! */ - -/* - * States - */ -#define EJS_STATE_ERR -1 /* Error state */ -#define EJS_STATE_EOF 1 /* End of file */ -#define EJS_STATE_COND 2 /* Parsing a "(conditional)" stmt */ -#define EJS_STATE_COND_DONE 3 -#define EJS_STATE_RELEXP 4 /* Parsing a relational expr */ -#define EJS_STATE_RELEXP_DONE 5 -#define EJS_STATE_EXPR 6 /* Parsing an expression */ -#define EJS_STATE_EXPR_DONE 7 -#define EJS_STATE_STMT 8 /* Parsing General statement */ -#define EJS_STATE_STMT_DONE 9 -#define EJS_STATE_STMT_BLOCK_DONE 10 /* End of block "}" */ -#define EJS_STATE_ARG_LIST 11 /* Function arg list */ -#define EJS_STATE_ARG_LIST_DONE 12 -#define EJS_STATE_DEC_LIST 16 /* Declaration list */ -#define EJS_STATE_DEC_LIST_DONE 17 -#define EJS_STATE_DEC 18 /* Declaration statement */ -#define EJS_STATE_DEC_DONE 19 -#define EJS_STATE_RET 20 /* Return statement */ - -#define EJS_STATE_BEGIN EJS_STATE_STMT - -/* - * General parsing flags. - */ -#define EJS_FLAGS_EXE 0x1 /* Execute statements */ -#define EJS_FLAGS_LOCAL 0x2 /* Get local vars only */ -#define EJS_FLAGS_GLOBAL 0x4 /* Get global vars only */ -#define EJS_FLAGS_CREATE 0x8 /* Create var */ -#define EJS_FLAGS_ASSIGNMENT 0x10 /* In assignment stmt */ -#define EJS_FLAGS_DELETE 0x20 /* Deleting a variable */ -#define EJS_FLAGS_FOREACH 0x40 /* In foreach */ -#define EJS_FLAGS_NEW 0x80 /* In a new stmt() */ -#define EJS_FLAGS_EXIT 0x100 /* Must exit */ - -/* - * Putback token - */ - -typedef struct EjsToken { - char *token; /* Token string */ - int id; /* Token ID */ -} EjsToken; - -/* - * EJ evaluation block structure - */ -typedef struct ejEval { - EjsToken putBack[EJS_TOKEN_STACK]; /* Put back token stack */ - int putBackIndex; /* Top of stack index */ - MprStr line; /* Current line */ - int lineLength; /* Current line length */ - int lineNumber; /* Parse line number */ - int lineColumn; /* Column in line */ - MprStr script; /* Input script for parsing */ - char *scriptServp; /* Next token in the script */ - int scriptSize; /* Length of script */ - MprStr tokbuf; /* Current token */ - char *tokEndp; /* Pointer past end of token */ - char *tokServp; /* Pointer to next token char */ - int tokSize; /* Size of token buffer */ - struct ejEval *next; /* used for backtraces */ - const char *procName; /* gives name in backtrace */ -} EjsInput; - -/* - * Function call structure - */ -typedef struct { - MprArray *args; /* Args for function */ - MprVar *fn; /* Function definition */ - char *procName; /* Function name */ -} EjsProc; - -/* - * Per EJS structure - */ -typedef struct ej { - EjsHandle altHandle; /* alternate callback handle */ - MprVar *currentObj; /* Ptr to current object */ - MprVar *currentProperty; /* Ptr to current property */ - EjsId eid; /* Halloc handle */ - char *error; /* Error message */ - int exitStatus; /* Status to exit() */ - int flags; /* Flags */ - MprArray *frames; /* List of variable frames */ - MprVar *global; /* Global object */ - EjsInput *input; /* Input evaluation block */ - MprVar *local; /* Local object */ - EjsHandle primaryHandle; /* primary callback handle */ - EjsProc *proc; /* Current function */ - MprVar result; /* Variable result */ - void *thisPtr; /* C++ ptr for functions */ - int tid; /* Current token id */ - char *token; /* Pointer to token string */ - MprVar tokenNumber; /* Parsed number */ -} Ejs; - -typedef int EjsBlock; /* Scope block id */ - -/* - * Function callback when using Alternate handles. - */ -typedef int (*EjsAltStringCFunction)(EjsHandle userHandle, EjsHandle altHandle, - int argc, char **argv); -typedef int (*EjsAltCFunction)(EjsHandle userHandle, EjsHandle altHandle, - int argc, MprVar **argv); - -/******************************** Prototypes **********************************/ -/* - * Ejs Lex - */ -extern int ejsLexOpenScript(Ejs* ep, char *script); -extern void ejsLexCloseScript(Ejs* ep); -extern int ejsInitInputState(EjsInput *ip); -extern void ejsLexSaveInputState(Ejs* ep, EjsInput* state); -extern void ejsLexFreeInputState(Ejs* ep, EjsInput* state); -extern void ejsLexRestoreInputState(Ejs* ep, EjsInput* state); -extern int ejsLexGetToken(Ejs* ep, int state); -extern void ejsLexPutbackToken(Ejs* ep, int tid, char *string); - -/* - * Parsing - */ -extern MprVar *ejsFindObj(Ejs *ep, int state, const char *property, - int flags); -extern MprVar *ejsFindProperty(Ejs *ep, int state, MprVar *obj, - char *property, int flags); -extern int ejsGetVarCore(Ejs *ep, const char *var, MprVar **obj, - MprVar **varValue, int flags); -extern int ejsParse(Ejs *ep, int state, int flags); -extern Ejs *ejsPtr(EjsId eid); -extern void ejsSetExitStatus(int eid, int status); -extern void ejsSetFlags(int orFlags, int andFlags); - -/* - * Create variable scope blocks - */ -extern EjsBlock ejsOpenBlock(EjsId eid); -extern int ejsCloseBlock(EjsId eid, EjsBlock vid); -extern int ejsEvalBlock(EjsId eid, char *script, MprVar *v, char **err); -extern int ejsDefineStandardProperties(MprVar *objVar); - -/* - * Error handling - */ -extern void ejsError(Ejs *ep, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); - -#ifdef __cplusplus -} -#endif -#endif /* _h_EJS_INTERNAL */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs/ejsLex.c b/source4/lib/appweb/ejs/ejsLex.c deleted file mode 100644 index b9a363cfc9..0000000000 --- a/source4/lib/appweb/ejs/ejsLex.c +++ /dev/null @@ -1,923 +0,0 @@ -/* - * @file ejsLex.c - * @brief EJS Lexical Analyser - * @overview EJS lexical analyser. This implementes a lexical analyser - * for a subset of the JavaScript language. - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejsInternal.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ - -static int getLexicalToken(Ejs *ep, int state); -static int tokenAddChar(Ejs *ep, int c); -static int inputGetc(Ejs *ep); -static void inputPutback(Ejs *ep, int c); -static int charConvert(Ejs *ep, int base, int maxDig); - -/************************************* Code ***********************************/ -/* - * Open a new input script - */ - -int ejsLexOpenScript(Ejs *ep, char *script) -{ - EjsInput *ip; - - mprAssert(ep); - mprAssert(script); - - if ((ip = mprMalloc(sizeof(EjsInput))) == NULL) { - return -1; - } - memset(ip, 0, sizeof(*ip)); - ip->next = ep->input; - ep->input = ip; - ip->procName = ep->proc?ep->proc->procName:NULL; - -/* - * Create the parse token buffer and script buffer - */ - ip->tokbuf = mprMalloc(EJS_PARSE_INCR); - ip->tokSize = EJS_PARSE_INCR; - ip->tokServp = ip->tokbuf; - ip->tokEndp = ip->tokbuf; - - ip->script = mprStrdup(script); - ip->scriptSize = strlen(script); - ip->scriptServp = ip->script; - - ip->lineNumber = 1; - ip->lineLength = 0; - ip->lineColumn = 0; - ip->line = NULL; - - ip->putBackIndex = -1; - - return 0; -} - -/******************************************************************************/ -/* - * Close the input script - */ - -void ejsLexCloseScript(Ejs *ep) -{ - EjsInput *ip; - int i; - - mprAssert(ep); - - ip = ep->input; - mprAssert(ip); - ep->input = ip->next; - - for (i = 0; i < EJS_TOKEN_STACK; i++) { - mprFree(ip->putBack[i].token); - ip->putBack[i].token = 0; - } - - mprFree(ip->line); - mprFree(ip->tokbuf); - mprFree(ip->script); - - mprFree(ip); -} - -/******************************************************************************/ -/* - * Initialize an input state structure - */ - -int ejsInitInputState(EjsInput *ip) -{ - mprAssert(ip); - - memset(ip, 0, sizeof(*ip)); - ip->putBackIndex = -1; - - return 0; -} -/******************************************************************************/ -/* - * Save the input state - */ - -void ejsLexSaveInputState(Ejs *ep, EjsInput *state) -{ - EjsInput *ip; - int i; - - mprAssert(ep); - - ip = ep->input; - mprAssert(ip); - - *state = *ip; - - for (i = 0; i < ip->putBackIndex; i++) { - state->putBack[i].token = mprStrdup(ip->putBack[i].token); - state->putBack[i].id = ip->putBack[i].id; - } - for (; i < EJS_TOKEN_STACK; i++) { - state->putBack[i].token = 0; - } - - state->line = mprMalloc(ip->lineLength); - mprStrcpy(state->line, ip->lineLength, ip->line); - - state->lineColumn = ip->lineColumn; - state->lineNumber = ip->lineNumber; - state->lineLength = ip->lineLength; -} - -/******************************************************************************/ -/* - * Restore the input state - */ - -void ejsLexRestoreInputState(Ejs *ep, EjsInput *state) -{ - EjsInput *ip; - int i; - - mprAssert(ep); - mprAssert(state); - - ip = ep->input; - mprAssert(ip); - - ip->tokbuf = state->tokbuf; - ip->tokServp = state->tokServp; - ip->tokEndp = state->tokEndp; - ip->tokSize = state->tokSize; - - ip->script = state->script; - ip->scriptServp = state->scriptServp; - ip->scriptSize = state->scriptSize; - - ip->putBackIndex = state->putBackIndex; - for (i = 0; i < ip->putBackIndex; i++) { - mprFree(ip->putBack[i].token); - ip->putBack[i].id = state->putBack[i].id; - ip->putBack[i].token = mprStrdup(state->putBack[i].token); - } - - mprFree(ip->line); - ip->line = mprMalloc(state->lineLength); - mprStrcpy(ip->line, state->lineLength, state->line); - - ip->lineColumn = state->lineColumn; - ip->lineNumber = state->lineNumber; - ip->lineLength = state->lineLength; -} - -/******************************************************************************/ -/* - * Free a saved input state - */ - -void ejsLexFreeInputState(Ejs *ep, EjsInput *state) -{ - int i; - - mprAssert(ep); - mprAssert(state); - - for (i = 0; i < EJS_TOKEN_STACK; i++) { - mprFree(state->putBack[i].token); - } - state->putBackIndex = -1; - mprFree(state->line); - state->lineLength = 0; - state->lineColumn = 0; -} - -/******************************************************************************/ -/* - * Get the next EJS token - */ - -int ejsLexGetToken(Ejs *ep, int state) -{ - mprAssert(ep); - - ep->tid = getLexicalToken(ep, state); - return ep->tid; -} - -/******************************************************************************/ - -/* - * Check for reserved words "if", "else", "var", "for", "foreach", - * "delete", "function", and "return". "new", "in" and "function" - * done below. "true", "false", "null", "undefined" are handled - * as global objects. - * - * Other reserved words not supported: - * "break", "case", "catch", "continue", "default", "do", - * "finally", "instanceof", "switch", "this", "throw", "try", - * "typeof", "while", "with" - * - * ECMA extensions reserved words (not supported): - * "abstract", "boolean", "byte", "char", "class", "const", - * "debugger", "double", "enum", "export", "extends", - * "final", "float", "goto", "implements", "import", "int", - * "interface", "long", "native", "package", "private", - * "protected", "public", "short", "static", "super", - * "synchronized", "throws", "transient", "volatile" - */ - -static int checkReservedWord(Ejs *ep, int state, int c, int tid) -{ - if (state == EJS_STATE_STMT) { - if (strcmp(ep->token, "if") == 0) { - inputPutback(ep, c); - return EJS_TOK_IF; - } else if (strcmp(ep->token, "else") == 0) { - inputPutback(ep, c); - return EJS_TOK_ELSE; - } else if (strcmp(ep->token, "var") == 0) { - inputPutback(ep, c); - return EJS_TOK_VAR; - } else if (strcmp(ep->token, "for") == 0) { - inputPutback(ep, c); - return EJS_TOK_FOR; - } else if (strcmp(ep->token, "delete") == 0) { - inputPutback(ep, c); - return EJS_TOK_DELETE; - } else if (strcmp(ep->token, "function") == 0) { - inputPutback(ep, c); - return EJS_TOK_FUNCTION; - } else if (strcmp(ep->token, "return") == 0) { - if ((c == ';') || (c == '(')) { - inputPutback(ep, c); - } - return EJS_TOK_RETURN; - } - } else if (state == EJS_STATE_EXPR) { - if (strcmp(ep->token, "new") == 0) { - inputPutback(ep, c); - return EJS_TOK_NEW; - } else if (strcmp(ep->token, "in") == 0) { - inputPutback(ep, c); - return EJS_TOK_IN; - } else if (strcmp(ep->token, "function") == 0) { - inputPutback(ep, c); - return EJS_TOK_FUNCTION; - } - } - return tid; -} - -/******************************************************************************/ -/* - * Get the next EJS token - */ - -static int getLexicalToken(Ejs *ep, int state) -{ - MprType type; - EjsInput *ip; - int done, tid, c, quote, style, idx; - - mprAssert(ep); - ip = ep->input; - mprAssert(ip); - - ep->tid = -1; - tid = -1; - type = BLD_FEATURE_NUM_TYPE_ID; - - /* - * Use a putback tokens first. Don't free strings as caller needs access. - */ - if (ip->putBackIndex >= 0) { - idx = ip->putBackIndex; - tid = ip->putBack[idx].id; - ep->token = (char*) ip->putBack[idx].token; - tid = checkReservedWord(ep, state, 0, tid); - ip->putBackIndex--; - return tid; - } - ep->token = ip->tokServp = ip->tokEndp = ip->tokbuf; - *ip->tokServp = '\0'; - - if ((c = inputGetc(ep)) < 0) { - return EJS_TOK_EOF; - } - - /* - * Main lexical analyser - */ - for (done = 0; !done; ) { - switch (c) { - case -1: - return EJS_TOK_EOF; - - case ' ': - case '\t': - case '\r': - do { - if ((c = inputGetc(ep)) < 0) - break; - } while (c == ' ' || c == '\t' || c == '\r'); - break; - - case '\n': - return EJS_TOK_NEWLINE; - - case '(': - tokenAddChar(ep, c); - return EJS_TOK_LPAREN; - - case ')': - tokenAddChar(ep, c); - return EJS_TOK_RPAREN; - - case '[': - tokenAddChar(ep, c); - return EJS_TOK_LBRACKET; - - case ']': - tokenAddChar(ep, c); - return EJS_TOK_RBRACKET; - - case '.': - tokenAddChar(ep, c); - return EJS_TOK_PERIOD; - - case '{': - tokenAddChar(ep, c); - return EJS_TOK_LBRACE; - - case '}': - tokenAddChar(ep, c); - return EJS_TOK_RBRACE; - - case '+': - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c != '+' ) { - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_PLUS); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_INC); - return EJS_TOK_INC_DEC; - - case '-': - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c != '-' ) { - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_MINUS); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_DEC); - return EJS_TOK_INC_DEC; - - case '*': - tokenAddChar(ep, EJS_EXPR_MUL); - return EJS_TOK_EXPR; - - case '%': - tokenAddChar(ep, EJS_EXPR_MOD); - return EJS_TOK_EXPR; - - case '/': - /* - * Handle the division operator and comments - */ - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c != '*' && c != '/') { - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_DIV); - return EJS_TOK_EXPR; - } - style = c; - /* - * Eat comments. Both C and C++ comment styles are supported. - */ - while (1) { - if ((c = inputGetc(ep)) < 0) { - if (style == '/') { - return EJS_TOK_EOF; - } - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c == '\n' && style == '/') { - break; - } else if (c == '*') { - c = inputGetc(ep); - if (style == '/') { - if (c == '\n') { - break; - } - } else { - if (c == '/') { - break; - } - } - } - } - /* - * Continue looking for a token, so get the next character - */ - if ((c = inputGetc(ep)) < 0) { - return EJS_TOK_EOF; - } - break; - - case '<': /* < and <= */ - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c == '<') { - tokenAddChar(ep, EJS_EXPR_LSHIFT); - return EJS_TOK_EXPR; - } else if (c == '=') { - tokenAddChar(ep, EJS_EXPR_LESSEQ); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_LESS); - inputPutback(ep, c); - return EJS_TOK_EXPR; - - case '>': /* > and >= */ - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c == '>') { - tokenAddChar(ep, EJS_EXPR_RSHIFT); - return EJS_TOK_EXPR; - } else if (c == '=') { - tokenAddChar(ep, EJS_EXPR_GREATEREQ); - return EJS_TOK_EXPR; - } - tokenAddChar(ep, EJS_EXPR_GREATER); - inputPutback(ep, c); - return EJS_TOK_EXPR; - - case '=': /* "==" */ - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c == '=') { - tokenAddChar(ep, EJS_EXPR_EQ); - return EJS_TOK_EXPR; - } - inputPutback(ep, c); - return EJS_TOK_ASSIGNMENT; - - case '!': /* "!=" or "!"*/ - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - if (c == '=') { - tokenAddChar(ep, EJS_EXPR_NOTEQ); - return EJS_TOK_EXPR; - } - inputPutback(ep, c); - tokenAddChar(ep, EJS_EXPR_BOOL_COMP); - return EJS_TOK_EXPR; - - case ';': - tokenAddChar(ep, c); - return EJS_TOK_SEMI; - - case ',': - tokenAddChar(ep, c); - return EJS_TOK_COMMA; - - case '|': /* "||" */ - if ((c = inputGetc(ep)) < 0 || c != '|') { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - tokenAddChar(ep, EJS_COND_OR); - return EJS_TOK_LOGICAL; - - case '&': /* "&&" */ - if ((c = inputGetc(ep)) < 0 || c != '&') { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - tokenAddChar(ep, EJS_COND_AND); - return EJS_TOK_LOGICAL; - - case '\"': /* String quote */ - case '\'': - quote = c; - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Syntax Error"); - return EJS_TOK_ERR; - } - - while (c != quote) { - /* - * Check for escape sequence characters - */ - if (c == '\\') { - c = inputGetc(ep); - - if (isdigit(c)) { - /* - * Octal support, \101 maps to 65 = 'A'. Put first - * char back so converter will work properly. - */ - inputPutback(ep, c); - c = charConvert(ep, 8, 3); - - } else { - switch (c) { - case 'n': - c = '\n'; break; - case 'b': - c = '\b'; break; - case 'f': - c = '\f'; break; - case 'r': - c = '\r'; break; - case 't': - c = '\t'; break; - case 'x': - /* - * Hex support, \x41 maps to 65 = 'A' - */ - c = charConvert(ep, 16, 2); - break; - case 'u': - /* - * Unicode support, \x0401 maps to 65 = 'A' - */ - c = charConvert(ep, 16, 2); - c = c*16 + charConvert(ep, 16, 2); - - break; - case '\'': - case '\"': - case '\\': - break; - default: - ejsError(ep, "Invalid Escape Sequence"); - return EJS_TOK_ERR; - } - } - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - } else { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - } - if ((c = inputGetc(ep)) < 0) { - ejsError(ep, "Unmatched Quote"); - return EJS_TOK_ERR; - } - } - return EJS_TOK_LITERAL; - - case '0': - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - if (tolower(c) == 'x') { - do { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - } while (isdigit(c) || (tolower(c) >= 'a' && tolower(c) <= 'f')); - - mprDestroyVar(&ep->tokenNumber); - ep->tokenNumber = mprParseVar(ep->token, type); - inputPutback(ep, c); - return EJS_TOK_NUMBER; - } - if (! isdigit(c)) { -#if BLD_FEATURE_FLOATING_POINT - if (c == '.' || tolower(c) == 'e' || c == '+' || c == '-') { - /* Fall through */ - type = MPR_TYPE_FLOAT; - } else -#endif - { - mprDestroyVar(&ep->tokenNumber); - ep->tokenNumber = mprParseVar(ep->token, type); - inputPutback(ep, c); - return EJS_TOK_NUMBER; - } - } - /* Fall through to get more digits */ - - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - do { - if (tokenAddChar(ep, c) < 0) { - return EJS_TOK_ERR; - } - if ((c = inputGetc(ep)) < 0) { - break; - } -#if BLD_FEATURE_FLOATING_POINT - if (c == '.' || tolower(c) == 'e' || tolower(c) == 'f') { - type = MPR_TYPE_FLOAT; - } - } while (isdigit(c) || c == '.' || tolower(c) == 'e' || tolower(c) == 'f' || - ((type == MPR_TYPE_FLOAT) && (c == '+' || c == '-'))); -#else - } while (isdigit(c)); -#endif - - mprDestroyVar(&ep->tokenNumber); - ep->tokenNumber = mprParseVar(ep->token, type); - inputPutback(ep, c); - return EJS_TOK_NUMBER; - - default: - /* - * Identifiers or a function names - */ - while (1) { - if (c == '\\') { - if ((c = inputGetc(ep)) < 0) { - break; - } - if (c == '\n' || c == '\r') { - break; - } - } else if (tokenAddChar(ep, c) < 0) { - break; - } - if ((c = inputGetc(ep)) < 0) { - break; - } - if (!isalnum(c) && c != '$' && c != '_' && c != '\\') { - break; - } - } - if (*ep->token == '\0') { - c = inputGetc(ep); - break; - } - if (! isalpha((int) *ep->token) && *ep->token != '$' && - *ep->token != '_') { - ejsError(ep, "Invalid identifier %s", ep->token); - return EJS_TOK_ERR; - } - - tid = checkReservedWord(ep, state, c, EJS_TOK_ID); - if (tid != EJS_TOK_ID) { - return tid; - } - - /* - * Skip white space after token to find out whether this is - * a function or not. - */ - while (c == ' ' || c == '\t' || c == '\r' || c == '\n') { - if ((c = inputGetc(ep)) < 0) - break; - } - - tid = EJS_TOK_ID; - done++; - } - } - - /* - * Putback the last extra character for next time - */ - inputPutback(ep, c); - return tid; -} - -/******************************************************************************/ -/* - * Convert a hex or octal character back to binary, return original char if - * not a hex digit - */ - -static int charConvert(Ejs *ep, int base, int maxDig) -{ - int i, c, lval, convChar; - - lval = 0; - for (i = 0; i < maxDig; i++) { - if ((c = inputGetc(ep)) < 0) { - break; - } - /* - * Initialize to out of range value - */ - convChar = base; - if (isdigit(c)) { - convChar = c - '0'; - } else if (c >= 'a' && c <= 'f') { - convChar = c - 'a' + 10; - } else if (c >= 'A' && c <= 'F') { - convChar = c - 'A' + 10; - } - /* - * If unexpected character then return it to buffer. - */ - if (convChar >= base) { - inputPutback(ep, c); - break; - } - lval = (lval * base) + convChar; - } - return lval; -} - -/******************************************************************************/ -/* - * Putback the last token read. Accept at most one push back token. - */ - -void ejsLexPutbackToken(Ejs *ep, int tid, char *string) -{ - EjsInput *ip; - int idx; - - mprAssert(ep); - ip = ep->input; - mprAssert(ip); - - ip->putBackIndex += 1; - idx = ip->putBackIndex; - ip->putBack[idx].id = tid; - - if (ip->putBack[idx].token) { - if (ip->putBack[idx].token == string) { - return; - } - mprFree(ip->putBack[idx].token); - } - ip->putBack[idx].token = mprStrdup(string); -} - -/******************************************************************************/ -/* - * Add a character to the token buffer - */ - -static int tokenAddChar(Ejs *ep, int c) -{ - EjsInput *ip; - uchar *oldbuf; - - mprAssert(ep); - ip = ep->input; - mprAssert(ip); - - if (ip->tokEndp >= &ip->tokbuf[ip->tokSize - 1]) { - ip->tokSize += EJS_PARSE_INCR; - oldbuf = ip->tokbuf; - ip->tokbuf = mprRealloc(ip->tokbuf, ip->tokSize); - if (ip->tokbuf == 0) { - ejsError(ep, "Token too big"); - return -1; - } - ip->tokEndp += (int) ((uchar*) ip->tokbuf - oldbuf); - ip->tokServp += (int) ((uchar*) ip->tokbuf - oldbuf); - ep->token += (int) ((uchar*) ip->tokbuf - oldbuf); - } - *ip->tokEndp++ = c; - *ip->tokEndp = '\0'; - - return 0; -} - -/******************************************************************************/ -/* - * Get another input character - */ - -static int inputGetc(Ejs *ep) -{ - EjsInput *ip; - int c; - - mprAssert(ep); - ip = ep->input; - - if (ip->scriptSize <= 0) { - return -1; - } - - c = (uchar) (*ip->scriptServp++); - ip->scriptSize--; - - /* - * For debugging, accumulate the line number and the currenly parsed line - */ - if (c == '\n') { -#if BLD_DEBUG && 0 - if (ip->lineColumn > 0) { - printf("PARSED: %s\n", ip->line); - } -#endif - ip->lineNumber++; - ip->lineColumn = 0; - } else { - if ((ip->lineColumn + 2) >= ip->lineLength) { - ip->lineLength += 80; - ip->line = mprRealloc(ip->line, ip->lineLength * sizeof(char)); - } - ip->line[ip->lineColumn++] = c; - ip->line[ip->lineColumn] = '\0'; - } - return c; -} - -/******************************************************************************/ -/* - * Putback a character onto the input queue - */ - -static void inputPutback(Ejs *ep, int c) -{ - EjsInput *ip; - - mprAssert(ep); - - if (c != 0) { - ip = ep->input; - *--ip->scriptServp = c; - ip->scriptSize++; - ip->lineColumn--; - ip->line[ip->lineColumn] = '\0'; - } -} - -/******************************************************************************/ - -#else -void ejsLexDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs/ejsLib.c b/source4/lib/appweb/ejs/ejsLib.c deleted file mode 100644 index 67d0a4e760..0000000000 --- a/source4/lib/appweb/ejs/ejsLib.c +++ /dev/null @@ -1,1090 +0,0 @@ -/* - * @file ejs.c - * @brief Embedded JavaScript (EJS) - * @overview Main module interface logic. - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejsInternal.h" - -#if BLD_FEATURE_EJS - -/********************************** Local Data ********************************/ - -/* - * These fields must be locked before any access when multithreaded - */ -static MprVar master; /* Master object */ -static MprArray *ejsList; /* List of ej handles */ - -#if BLD_FEATURE_MULTITHREAD -static EjsLock lock; -static EjsUnlock unlock; -static void *lockData; -#define ejsLock() if (lock) { (lock)(lockData); } else -#define ejsUnlock() if (unlock) { (unlock)(lockData); } else -#else -#define ejsLock() -#define ejsUnlock() -#endif - - -/* - save/restore global ejs state - used to cope with simultaneous ejs requests - this is a workaround for the use of global variables in ejs -*/ -struct ejs_state_ctx { - MprVar master; - MprArray *ejsList; -}; - -void *ejs_save_state(void) -{ - struct ejs_state_ctx *ctx = talloc(talloc_autofree_context(), struct ejs_state_ctx); - ctx->master = master; - ctx->ejsList = ejsList; - return ctx; -} - -void ejs_restore_state(void *ptr) -{ - struct ejs_state_ctx *ctx = talloc_get_type(ptr, struct ejs_state_ctx); - master = ctx->master; - ejsList = ctx->ejsList; - talloc_free(ctx); -} - - -/****************************** Forward Declarations **************************/ - -static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen); - -/************************************* Code ***********************************/ -/* - * Initialize the EJ subsystem - */ - -int ejsOpen(EjsLock lockFn, EjsUnlock unlockFn, void *data) -{ - MprVar *np; - -#if BLD_FEATURE_MULTITHREAD - if (lockFn) { - lock = lockFn; - unlock = unlockFn; - lockData = data; - } -#endif - ejsLock(); - - /* - * Master is the top level object (above global). It is used to clone its - * contents into the global scope for each. This is never visible to the - * user, so don't use ejsCreateObj(). - */ - master = mprCreateObjVar("master", EJS_SMALL_OBJ_HASH_SIZE); - if (master.type == MPR_TYPE_UNDEFINED) { - ejsUnlock(); - return MPR_ERR_CANT_ALLOCATE; - } - - ejsList = mprCreateArray(); - ejsDefineStandardProperties(&master); - - /* - * Make these objects immutable - */ - np = mprGetFirstProperty(&master, MPR_ENUM_FUNCTIONS | MPR_ENUM_DATA); - while (np) { - mprSetVarReadonly(np, 1); - np = mprGetNextProperty(&master, np, MPR_ENUM_FUNCTIONS | - MPR_ENUM_DATA); - } - ejsUnlock(); - return 0; -} - -/******************************************************************************/ - -void ejsClose() -{ - ejsLock(); - mprDestroyArray(ejsList); - mprDestroyVar(&master); - ejsUnlock(); -} - -/******************************************************************************/ -/* - * Create and initialize an EJS engine - */ - -EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle) -{ - MprVar *np; - Ejs *ep; - - ep = (Ejs *)mprMalloc(sizeof(Ejs)); - if (ep == 0) { - return (EjsId) -1; - } - memset(ep, 0, sizeof(Ejs)); - - ejsLock(); - ep->eid = (EjsId) mprAddToArray(ejsList, ep); - ejsUnlock(); - - /* - * Create array of local variable frames - */ - ep->frames = mprCreateArray(); - if (ep->frames == 0) { - ejsCloseEngine(ep->eid); - return (EjsId) -1; - } - ep->primaryHandle = primaryHandle; - ep->altHandle = altHandle; - - /* - * Create first frame: global variables - */ - ep->global = (MprVar*) mprMalloc(sizeof(MprVar)); - *ep->global = ejsCreateObj("global", EJS_OBJ_HASH_SIZE); - if (ep->global->type == MPR_TYPE_UNDEFINED) { - ejsCloseEngine(ep->eid); - return (EjsId) -1; - } - mprAddToArray(ep->frames, ep->global); - - /* - * Create first local variable frame - */ - ep->local = (MprVar*) mprMalloc(sizeof(MprVar)); - *ep->local = ejsCreateObj("local", EJS_OBJ_HASH_SIZE); - if (ep->local->type == MPR_TYPE_UNDEFINED) { - ejsCloseEngine(ep->eid); - return (EjsId) -1; - } - mprAddToArray(ep->frames, ep->local); - - /* - * Clone all master variables into the global frame. This does a - * reference copy. - * - * ejsDefineStandardProperties(ep->global); - */ - np = mprGetFirstProperty(&master, MPR_ENUM_FUNCTIONS | MPR_ENUM_DATA); - while (np) { - mprCreateProperty(ep->global, np->name, np); - np = mprGetNextProperty(&master, np, MPR_ENUM_FUNCTIONS | - MPR_ENUM_DATA); - } - - mprCreateProperty(ep->global, "global", ep->global); - mprCreateProperty(ep->global, "this", ep->global); - mprCreateProperty(ep->local, "local", ep->local); - - return ep->eid; -} - -/******************************************************************************/ -/* - * Close an EJS instance - */ - -void ejsCloseEngine(EjsId eid) -{ - Ejs *ep; - MprVar *vp; - void **handles; - int i; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return; - } - - mprFree(ep->error); - mprDestroyVar(&ep->result); - mprDestroyVar(&ep->tokenNumber); - - if (ep->local) { - mprDeleteProperty(ep->local, "local"); - } - mprDeleteProperty(ep->global, "this"); - mprDeleteProperty(ep->global, "global"); - - handles = ep->frames->handles; - for (i = 0; i < ep->frames->max; i++) { - vp = handles[i]; - if (vp) { -#if BLD_DEBUG - if (vp->type == MPR_TYPE_OBJECT && vp->properties->refCount > 1) { - mprLog(7, "ejsCloseEngine: %s has ref count %d\n", - vp->name, vp->properties->refCount); - } -#endif - mprDestroyVar(vp); - mprFree(vp); - mprRemoveFromArray(ep->frames, i); - } - } - mprDestroyArray(ep->frames); - - ejsLock(); - mprRemoveFromArray(ejsList, (int) ep->eid); - ejsUnlock(); - - mprFree(ep); -} - -/******************************************************************************/ -/* - * Evaluate an EJS script file - */ - -int ejsEvalFile(EjsId eid, char *path, MprVar *result, char **emsg) -{ - struct stat sbuf; - Ejs *ep; - char *script; - int rc, fd; - - mprAssert(path && *path); - - if (emsg) { - *emsg = NULL; - } - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - goto error; - } - - if ((fd = open(path, O_RDONLY | O_BINARY, 0666)) < 0) { - ejsError(ep, "Can't open %s\n", path); - goto error; - } - - if (stat(path, &sbuf) < 0) { - close(fd); - ejsError(ep, "Cant stat %s", path); - goto error; - } - - if ((script = (char*) mprMalloc(sbuf.st_size + 1)) == NULL) { - close(fd); - ejsError(ep, "Cant malloc %d", (int) sbuf.st_size); - goto error; - } - - if (read(fd, script, sbuf.st_size) != (int) sbuf.st_size) { - close(fd); - mprFree(script); - ejsError(ep, "Error reading %s", path); - goto error; - } - - script[sbuf.st_size] = '\0'; - close(fd); - - rc = ejsEvalBlock(eid, script, result, emsg); - mprFree(script); - - return rc; - -/* - * Error return - */ -error: - if(emsg) - *emsg = mprStrdup(ep->error); - return -1; -} - -/******************************************************************************/ -/* - * Create a new variable scope block. This pushes the old local frame down - * the stack and creates a new local variables frame. - */ - -int ejsOpenBlock(EjsId eid) -{ - Ejs *ep; - - if((ep = ejsPtr(eid)) == NULL) { - return -1; - } - - ep->local = (MprVar*) mprMalloc(sizeof(MprVar)); - *ep->local = ejsCreateObj("localBlock", EJS_OBJ_HASH_SIZE); - - mprCreateProperty(ep->local, "local", ep->local); - - return mprAddToArray(ep->frames, ep->local); -} - -/******************************************************************************/ -/* - * Close a variable scope block opened via ejsOpenBlock. Pop back the old - * local variables frame. - */ - -int ejsCloseBlock(EjsId eid, int fid) -{ - Ejs *ep; - - if((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - - /* - * Must remove self-references before destroying "local" - */ - mprDeleteProperty(ep->local, "local"); - - mprDestroyVar(ep->local); - mprFree(ep->local); - - mprRemoveFromArray(ep->frames, fid); - ep->local = (MprVar*) ep->frames->handles[ep->frames->used - 1]; - - return 0; -} - -/******************************************************************************/ -/* - * Create a new variable scope block and evaluate a script. All frames - * created during this context will be automatically deleted when complete. - * vp and emsg are optional. i.e. created local variables will be discarded - * when this routine returns. - */ - -int ejsEvalBlock(EjsId eid, char *script, MprVar *vp, char **emsg) -{ - int rc, fid; - - mprAssert(script); - - fid = ejsOpenBlock(eid); - rc = ejsEvalScript(eid, script, vp, emsg); - ejsCloseBlock(eid, fid); - - return rc; -} - -/******************************************************************************/ -/* - * Parse and evaluate a EJS. Return the result in *vp. The result is "owned" - * by EJ and the caller must not free it. Returns -1 on errors and zero - * for success. On errors, emsg will be set to the reason. The caller must - * free emsg. - */ - -int ejsEvalScript(EjsId eid, char *script, MprVar *vp, char **emsg) -{ - Ejs *ep; - int state; - void *endlessLoopTest; - int loopCounter; - - if (emsg) { - *emsg = NULL; - } - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - - mprDestroyVar(&ep->result); - - if (script == 0) { - return 0; - } - - /* - * Allocate a new evaluation block, and save the old one - */ - ejsLexOpenScript(ep, script); - - /* - * Do the actual parsing and evaluation - */ - loopCounter = 0; - endlessLoopTest = NULL; - ep->exitStatus = 0; - - do { - state = ejsParse(ep, EJS_STATE_BEGIN, EJS_FLAGS_EXE); - - if (state == EJS_STATE_RET) { - state = EJS_STATE_EOF; - } - /* - * Stuck parser and endless recursion protection. - */ - if (endlessLoopTest == ep->input->scriptServp) { - if (loopCounter++ > 10) { - state = EJS_STATE_ERR; - ejsError(ep, "Syntax error"); - } - } else { - endlessLoopTest = ep->input->scriptServp; - loopCounter = 0; - } - } while (state != EJS_STATE_EOF && state != EJS_STATE_ERR); - - ejsLexCloseScript(ep); - - /* - * Return any error string to the user - */ - if (state == EJS_STATE_ERR && emsg) { - *emsg = mprStrdup(ep->error); - } - - if (state == EJS_STATE_ERR) { - return -1; - } - - if (vp) { - *vp = ep->result; - } - - return ep->exitStatus; -} - -/******************************************************************************/ -/* - * Core error handling - */ - -static void ejsErrorCore(Ejs* ep, const char *fmt, va_list args) - PRINTF_ATTRIBUTE(2, 0); - -static void ejsErrorCore(Ejs* ep, const char *fmt, va_list args) -{ - EjsInput *ip; - char *errbuf, *msgbuf; - int frame = 0; - - mprAssert(ep); - - msgbuf = NULL; - mprAllocVsprintf(&msgbuf, MPR_MAX_STRING, fmt, args); - - ip = ep->input; - mprAllocSprintf(&errbuf, MPR_MAX_STRING, "%s\nBacktrace:\n", msgbuf); - - /* form a backtrace */ - while (ip) { - char *msg2, *ebuf2; - mprAllocSprintf(&msg2, MPR_MAX_STRING, - "\t[%2d] %20s:%-4d -> %s\n", - frame++, ip->procName?ip->procName:"", ip->lineNumber, ip->line); - ebuf2 = mprRealloc(errbuf, strlen(errbuf) + strlen(msg2) + 1); - if (ebuf2 == NULL) break; - errbuf = ebuf2; - memcpy(errbuf+strlen(errbuf), msg2, strlen(msg2)+1); - mprFree(msg2); - ip = ip->next; - } - mprFree(ep->error); - ep->error = errbuf; - mprFree(msgbuf); -} - -/******************************************************************************/ -/* - * Internal use function to set the error message - */ - -void ejsError(Ejs* ep, const char* fmt, ...) -{ - va_list args; - - va_start(args, fmt); - ejsErrorCore(ep, fmt, args); - va_end(args); -} - -/******************************************************************************/ -/* - * Public routine to set the error message - */ - -void ejsSetErrorMsg(EjsId eid, const char* fmt, ...) -{ - va_list args; - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return; - } - va_start(args, fmt); - ejsErrorCore(ep, fmt, args); - va_end(args); -} - -/******************************************************************************/ -/* - * Get the current line number - */ - -int ejsGetLineNumber(EjsId eid) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - return ep->input->lineNumber; -} - -/******************************************************************************/ -/* - * Return the local object - */ - -MprVar *ejsGetLocalObject(EjsId eid) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return 0; - } - return ep->local; -} - -/******************************************************************************/ -/* - * Return the global object - */ - -MprVar *ejsGetGlobalObject(EjsId eid) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return 0; - } - return ep->global; -} - -/******************************************************************************/ -/* - * Copy the value of an object property. Return value is in "value". - * If deepCopy is true, copy all object/strings. Otherwise, object reference - * counts are incremented. Callers must always call mprDestroyVar on the - * return value to prevent leaks. - * - * Returns: -1 on errors or if the variable is not found. - */ - -int ejsCopyVar(EjsId eid, const char *var, MprVar *value, bool deepCopy) -{ - Ejs *ep; - MprVar *vp; - - mprAssert(var && *var); - mprAssert(value); - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - - if (ejsGetVarCore(ep, var, 0, &vp, 0) < 0) { - return -1; - } - - return mprCopyProperty(value, vp, deepCopy); -} - -/******************************************************************************/ -/* - * Return the value of an object property. Return value is in "value". - * Objects and strings are not copied and reference counts are not modified. - * Callers should NOT call mprDestroyVar. Returns: -1 on errors or if the - * variable is not found. - */ - -int ejsReadVar(EjsId eid, const char *var, MprVar *value) -{ - Ejs *ep; - MprVar *vp; - - mprAssert(var && *var); - mprAssert(value); - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - - if (ejsGetVarCore(ep, var, 0, &vp, 0) < 0) { - return -1; - } - - return mprReadProperty(vp, value); -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. - */ - -int ejsWriteVar(EjsId eid, const char *var, MprVar *value) -{ - Ejs *ep; - MprVar *vp; - - mprAssert(var && *var); - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - - if (ejsGetVarCore(ep, var, 0, &vp, EJS_FLAGS_CREATE) < 0) { - return -1; - } - mprAssert(vp); - - /* - * Only copy the value. Don't overwrite the object's name - */ - mprWriteProperty(vp, value); - - return 0; -} - -/******************************************************************************/ -/* - * Set a variable that may be an arbitrarily complex object or array reference. - * Will always define in the top most variable frame. - */ - -int ejsWriteVarValue(EjsId eid, const char *var, MprVar value) -{ - return ejsWriteVar(eid, var, &value); -} - -/******************************************************************************/ -/* - * Delete a variable - */ - -int ejsDeleteVar(EjsId eid, const char *var) -{ - Ejs *ep; - MprVar *vp; - MprVar *obj; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return -1; - } - if (ejsGetVarCore(ep, var, &obj, &vp, 0) < 0) { - return -1; - } - mprDeleteProperty(obj, vp->name); - return 0; -} - -/******************************************************************************/ -/* - * Set the expression return value - */ - -void ejsSetReturnValue(EjsId eid, MprVar value) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return; - } - mprCopyVar(&ep->result, &value, MPR_SHALLOW_COPY); -} - -/******************************************************************************/ -/* - * Set the expression return value to a string value - */ - -void ejsSetReturnString(EjsId eid, const char *str) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return; - } - mprCopyVarValue(&ep->result, mprCreateStringVar(str, 0), MPR_SHALLOW_COPY); -} - -/******************************************************************************/ -/* - * Get the expression return value - */ - -MprVar *ejsGetReturnValue(EjsId eid) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return 0; - } - return &ep->result; -} - -/******************************************************************************/ -/* - * Define a C function. If eid < 0, then update the master object with this - * function. NOTE: in this case, functionName must be simple without any "." or - * "[]" elements. If eid >= 0, add to the specified script engine. In this - * case, functionName can be an arbitrary object reference and can contain "." - * or "[]". - */ - -void ejsDefineCFunction(EjsId eid, const char *functionName, MprCFunction fn, - void *thisPtr, int flags) -{ - if (eid < 0) { - ejsLock(); - mprCreatePropertyValue(&master, functionName, - mprCreateCFunctionVar(fn, thisPtr, flags)); - ejsUnlock(); - } else { - ejsWriteVarValue(eid, functionName, - mprCreateCFunctionVar(fn, thisPtr, flags)); - } -} - -/******************************************************************************/ -/* - * Define a C function with String arguments - */ - -void ejsDefineStringCFunction(EjsId eid, const char *functionName, - MprStringCFunction fn, void *thisPtr, int flags) -{ - if (eid < 0) { - ejsLock(); - mprCreatePropertyValue(&master, functionName, - mprCreateStringCFunctionVar(fn, thisPtr, flags)); - ejsUnlock(); - } else { - ejsWriteVarValue(eid, functionName, - mprCreateStringCFunctionVar(fn, thisPtr, flags)); - } -} - -/******************************************************************************/ -/* - * Define a JavaScript function. Args should be comma separated. - * Body should not contain braces. - */ - -void ejsDefineFunction(EjsId eid, const char *functionName, char *args, - char *body) -{ - MprVar v; - - v = mprCreateFunctionVar(args, body, 0); - if (eid < 0) { - ejsLock(); - mprCreateProperty(&master, functionName, &v); - ejsUnlock(); - } else { - ejsWriteVar(eid, functionName, &v); - } - mprDestroyVar(&v); -} - -/******************************************************************************/ - -void *ejsGetThisPtr(EjsId eid) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return 0; - } - return ep->thisPtr; -} - -/******************************************************************************/ -/* - * Find a variable given a variable name and return the parent object and - * the variable itself, the variable . This routine supports variable names - * that may be objects or arrays but may NOT have expressions in the array - * indicies. Returns -1 on errors or if the variable is not found. - */ - -int ejsGetVarCore(Ejs *ep, const char *vname, MprVar **obj, - MprVar **varValue, int flags) -{ - MprVar *currentObj; - MprVar *currentVar; - char tokBuf[EJS_MAX_ID]; - char *propertyName, *token, *next, *cp, *varName; - - if (obj) { - *obj = 0; - } - if (varValue) { - *varValue = 0; - } - currentObj = ejsFindObj(ep, 0, vname, flags); - currentVar = 0; - propertyName = 0; - - next = varName = mprStrdup(vname); - - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - - while (currentObj != 0 && token != 0 && *token) { - - if (*token == '[') { - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - - propertyName = token; - if (*propertyName == '\"') { - propertyName++; - if ((cp = strchr(propertyName, '\"')) != 0) { - *cp = '\0'; - } - } else if (*propertyName == '\'') { - propertyName++; - if ((cp = strchr(propertyName, '\'')) != 0) { - *cp = '\0'; - } - } - - currentObj = currentVar; - currentVar = ejsFindProperty(ep, 0, currentObj, propertyName, 0); - - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - if (*token != ']') { - mprFree(varName); - return -1; - } - - } else if (*token == '.') { - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - if (!isalpha((int) token[0]) && - token[0] != '_' && token[0] != '$') { - mprFree(varName); - return -1; - } - - propertyName = token; - currentObj = currentVar; - currentVar = ejsFindProperty(ep, 0, currentObj, token, 0); - - } else { - currentVar = ejsFindProperty(ep, 0, currentObj, token, 0); - } - token = getNextVarToken(&next, tokBuf, sizeof(tokBuf)); - } - mprFree(varName); - - if (currentVar == 0 && currentObj >= 0 && flags & EJS_FLAGS_CREATE) { - currentVar = mprCreatePropertyValue(currentObj, propertyName, - mprCreateUndefinedVar()); - } - if (obj) { - *obj = currentObj; - } - - /* - * Don't use mprCopyVar as it will copy the data - */ - if (varValue) { - *varValue = currentVar; - } - return currentVar ? 0 : -1; -} - -/******************************************************************************/ -/* - * Get the next token as part of a variable specification. This will return - * a pointer to the next token and will return a pointer to the next token - * (after this one) in "next". The tokBuf holds the parsed token. - */ -static char *getNextVarToken(char **next, char *tokBuf, int tokBufLen) -{ - char *start, *cp; - int len; - - start = *next; - while (isspace((int) *start) || *start == '\n' || *start == '\r') { - start++; - } - cp = start; - - if (*cp == '.' || *cp == '[' || *cp == ']') { - cp++; - } else { - while (*cp && *cp != '.' && *cp != '[' && *cp != ']' && - !isspace((int) *cp) && *cp != '\n' && *cp != '\r') { - cp++; - } - } - len = mprMemcpy(tokBuf, tokBufLen - 1, start, cp - start); - tokBuf[len] = '\0'; - - *next = cp; - return tokBuf; -} - -/******************************************************************************/ -/* - * Get the EJS structure pointer - */ - -Ejs *ejsPtr(EjsId eid) -{ - Ejs *handle; - int intId; - - intId = (int) eid; - - ejsLock(); - mprAssert(0 <= intId && intId < ejsList->max); - - if (intId < 0 || intId >= ejsList->max || ejsList->handles[intId] == NULL) { - mprAssert(0); - ejsUnlock(); - return NULL; - } - handle = ejsList->handles[intId]; - ejsUnlock(); - return handle; -} - -/******************************************************************************/ -/* - * Utility routine to crack JavaScript arguments. Return the number of args - * seen. This routine only supports %s and %d type args. - * - * Typical usage: - * - * if (ejsParseArgs(argc, argv, "%s %d", &name, &age) < 2) { - * mprError("Insufficient args\n"); - * return -1; - * } - */ - -int ejsParseArgs(int argc, char **argv, char *fmt, ...) -{ - va_list vargs; - bool *bp; - char *cp, **sp, *s; - int *ip, argn; - - va_start(vargs, fmt); - - if (argv == 0) { - return 0; - } - - for (argn = 0, cp = fmt; cp && *cp && argn < argc && argv[argn]; ) { - if (*cp++ != '%') { - continue; - } - - s = argv[argn]; - switch (*cp) { - case 'b': - bp = va_arg(vargs, bool*); - if (bp) { - if (strcmp(s, "true") == 0 || s[0] == '1') { - *bp = 1; - } else { - *bp = 0; - } - } else { - *bp = 0; - } - break; - - case 'd': - ip = va_arg(vargs, int*); - *ip = atoi(s); - break; - - case 's': - sp = va_arg(vargs, char**); - *sp = s; - break; - - default: - mprAssert(0); - } - argn++; - } - - va_end(vargs); - return argn; -} - -/******************************************************************************/ - -#else -void ejsDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/******************************************************************************/ -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs/ejsParser.c b/source4/lib/appweb/ejs/ejsParser.c deleted file mode 100644 index da922a5728..0000000000 --- a/source4/lib/appweb/ejs/ejsParser.c +++ /dev/null @@ -1,2436 +0,0 @@ -/* - * @file ejsParser.c - * @brief EJS Parser and Execution - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/********************************** Includes **********************************/ - -#include "ejsInternal.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ - -static void appendValue(MprVar *v1, MprVar *v2); -static int evalCond(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs); -static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs); -#if BLD_FEATURE_FLOATING_POINT -static int evalFloatExpr(Ejs *ep, double l, int rel, double r); -#endif -static int evalBoolExpr(Ejs *ep, bool l, int rel, bool r); -static int evalPtrExpr(Ejs *ep, void *l, int rel, void *r); -static int evalNumericExpr(Ejs *ep, MprNum l, int rel, MprNum r); -static int evalStringExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs); -static int evalFunction(Ejs *ep, MprVar *obj, int flags); -static void freeProc(EjsProc *proc); -static int parseArgs(Ejs *ep, int state, int flags); -static int parseAssignment(Ejs *ep, int state, int flags, char *id, - char *fullName); -static int parseCond(Ejs *ep, int state, int flags); -static int parseDeclaration(Ejs *ep, int state, int flags); -static int parseExpr(Ejs *ep, int state, int flags); -static int parseFor(Ejs *ep, int state, int flags); -static int parseForIn(Ejs *ep, int state, int flags); -static int parseFunctionDec(Ejs *ep, int state, int flags); -static int parseFunction(Ejs *ep, int state, int flags, char *id); -static int parseId(Ejs *ep, int state, int flags, char **id, - char **fullName, int *fullNameLen, int *done); -static int parseInc(Ejs *ep, int state, int flags); -static int parseIf(Ejs *ep, int state, int flags, int *done); -static int parseStmt(Ejs *ep, int state, int flags); -static void removeNewlines(Ejs *ep, int state); -static void updateResult(Ejs *ep, int state, int flags, MprVar *vp); - -/************************************* Code ***********************************/ -/* - * Recursive descent parser for EJS - */ - -int ejsParse(Ejs *ep, int state, int flags) -{ - mprAssert(ep); - - switch (state) { - /* - * Any statement, function arguments or conditional expressions - */ - case EJS_STATE_STMT: - if ((state = parseStmt(ep, state, flags)) != EJS_STATE_STMT_DONE && - state != EJS_STATE_EOF && state != EJS_STATE_STMT_BLOCK_DONE && - state != EJS_STATE_RET) { - state = EJS_STATE_ERR; - } - break; - - case EJS_STATE_DEC: - if ((state = parseStmt(ep, state, flags)) != EJS_STATE_DEC_DONE && - state != EJS_STATE_EOF) { - state = EJS_STATE_ERR; - } - break; - - case EJS_STATE_EXPR: - if ((state = parseStmt(ep, state, flags)) != EJS_STATE_EXPR_DONE && - state != EJS_STATE_EOF) { - state = EJS_STATE_ERR; - } - break; - - /* - * Variable declaration list - */ - case EJS_STATE_DEC_LIST: - state = parseDeclaration(ep, state, flags); - break; - - /* - * Function argument string - */ - case EJS_STATE_ARG_LIST: - state = parseArgs(ep, state, flags); - break; - - /* - * Logical condition list (relational operations separated by &&, ||) - */ - case EJS_STATE_COND: - state = parseCond(ep, state, flags); - break; - - /* - * Expression list - */ - case EJS_STATE_RELEXP: - state = parseExpr(ep, state, flags); - break; - } - - if (state == EJS_STATE_ERR && ep->error == NULL) { - ejsError(ep, "Syntax error"); - } - return state; -} - -/******************************************************************************/ -/* - * Parse any statement including functions and simple relational operations - */ - -static int parseStmt(Ejs *ep, int state, int flags) -{ - EjsProc *saveProc; - MprVar *vp, *saveObj; - char *id, *fullName, *initToken; - int done, expectSemi, tid, fullNameLen, rel; - int initId; - - mprAssert(ep); - - expectSemi = 0; - saveProc = NULL; - id = 0; - fullName = 0; - fullNameLen = 0; - - ep->currentObj = 0; - ep->currentProperty = 0; - - for (done = 0; !done && state != EJS_STATE_ERR; ) { - tid = ejsLexGetToken(ep, state); - - switch (tid) { - default: - ejsLexPutbackToken(ep, EJS_TOK_EXPR, ep->token); - done++; - break; - - case EJS_TOK_EXPR: - rel = (int) *ep->token; - if (state == EJS_STATE_EXPR) { - ejsLexPutbackToken(ep, EJS_TOK_EXPR, ep->token); - } - done++; - break; - - case EJS_TOK_LOGICAL: - ejsLexPutbackToken(ep, tid, ep->token); - done++; - break; - - case EJS_TOK_ERR: - state = EJS_STATE_ERR; - done++; - break; - - case EJS_TOK_EOF: - state = EJS_STATE_EOF; - done++; - break; - - case EJS_TOK_NEWLINE: - break; - - case EJS_TOK_SEMI: - /* - * This case is when we discover no statement and just a lone ';' - */ - if (state != EJS_STATE_STMT) { - ejsLexPutbackToken(ep, tid, ep->token); - } - done++; - break; - - case EJS_TOK_PERIOD: - if (flags & EJS_FLAGS_EXE) { - if (ep->currentProperty == 0) { - ejsError(ep, "Undefined object \"%s\"\n", id); - goto error; - } - } - ep->currentObj = ep->currentProperty; - - if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) { - ejsError(ep, "Bad property after '.': %s\n", ep->token); - goto error; - } - mprFree(id); - id = mprStrdup(ep->token); - - vp = ejsFindProperty(ep, state, ep->currentObj, id, flags); - updateResult(ep, state, flags, vp); - -#if BLD_DEBUG - fullNameLen = mprReallocStrcat(&fullName, MPR_MAX_VAR, fullNameLen, - 0, ".", NULL); -#endif - - ep->currentProperty = vp; - ejsLexPutbackToken(ep, tid, ep->token); - break; - - case EJS_TOK_LBRACKET: - ep->currentObj = ep->currentProperty; - saveObj = ep->currentObj; - if (ejsParse(ep, EJS_STATE_RELEXP, flags) != EJS_STATE_RELEXP_DONE){ - goto error; - } - ep->currentObj = saveObj; - - mprFree(id); - mprVarToString(&id, MPR_MAX_STRING, 0, &ep->result); - - if (id[0] == '\0') { - if (flags & EJS_FLAGS_EXE) { - ejsError(ep, - "[] expression evaluates to the empty string\n"); - goto error; - } - } else { - vp = ejsFindProperty(ep, state, ep->currentObj, id, flags); - ep->currentProperty = vp; - updateResult(ep, state, flags, vp); - } - -#if BLD_DEBUG - if (id[0] && strlen(id) < (MPR_MAX_VAR / 2)) { - /* - * If not executing yet, id may not be known - */ - fullNameLen = mprReallocStrcat(&fullName, MPR_MAX_VAR, - fullNameLen, 0, "[", id, "]", NULL); - } -#endif - - if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_RBRACKET) { - ejsError(ep, "Missing ']'\n"); - goto error; - } - break; - - case EJS_TOK_ID: - state = parseId(ep, state, flags, &id, &fullName, &fullNameLen, - &done); - if (done && state == EJS_STATE_STMT) { - expectSemi++; - } - break; - - case EJS_TOK_ASSIGNMENT: - state = parseAssignment(ep, state, flags, id, fullName); - if (state == EJS_STATE_STMT) { - expectSemi++; - done++; - } - break; - - case EJS_TOK_INC_DEC: - state = parseInc(ep, state, flags); - if (state == EJS_STATE_STMT) { - expectSemi++; - } - break; - - case EJS_TOK_NEW: - if (ejsParse(ep, EJS_STATE_EXPR, flags | EJS_FLAGS_NEW) - != EJS_STATE_EXPR_DONE) { - goto error; - } - break; - - case EJS_TOK_DELETE: - if (ejsParse(ep, EJS_STATE_EXPR, - flags | EJS_FLAGS_DELETE) != EJS_STATE_EXPR_DONE) { - goto error; - } - if (flags & EJS_FLAGS_EXE) { - mprDeleteProperty(ep->currentObj, ep->currentProperty->name); - } - done++; - break; - - case EJS_TOK_FUNCTION: - state = parseFunctionDec(ep, state, flags); - done++; - break; - - case EJS_TOK_LITERAL: - /* - * Set the result to the string literal - */ - mprCopyVarValue(&ep->result, mprCreateStringVar(ep->token, 0), - MPR_SHALLOW_COPY); - if (state == EJS_STATE_STMT) { - expectSemi++; - } - done++; - break; - - case EJS_TOK_NUMBER: - /* - * Set the result to the parsed number - */ - mprCopyVar(&ep->result, &ep->tokenNumber, 0); - if (state == EJS_STATE_STMT) { - expectSemi++; - } - done++; - break; - - case EJS_TOK_FUNCTION_NAME: - state = parseFunction(ep, state, flags, id); - if (state == EJS_STATE_STMT) { - expectSemi++; - } - if (ep->flags & EJS_FLAGS_EXIT) { - state = EJS_STATE_RET; - } - done++; - break; - - case EJS_TOK_IF: - state = parseIf(ep, state, flags, &done); - if (state == EJS_STATE_RET) { - goto doneParse; - } - break; - - case EJS_TOK_FOR: - if (state != EJS_STATE_STMT) { - goto error; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_LPAREN) { - goto error; - } - /* - * Need to peek 2-3 tokens ahead and see if this is a - * for ([var] x in set) - * or - * for (init ; whileCond; incr) - */ - initId = ejsLexGetToken(ep, EJS_STATE_EXPR); - if (initId == EJS_TOK_ID && strcmp(ep->token, "var") == 0) { - /* Simply eat var tokens */ - initId = ejsLexGetToken(ep, EJS_STATE_EXPR); - } - initToken = mprStrdup(ep->token); - - tid = ejsLexGetToken(ep, EJS_STATE_EXPR); - - ejsLexPutbackToken(ep, tid, ep->token); - ejsLexPutbackToken(ep, initId, initToken); - mprFree(initToken); - - if (tid == EJS_TOK_IN) { - if ((state = parseForIn(ep, state, flags)) < 0) { - goto error; - } - } else { - if ((state = parseFor(ep, state, flags)) < 0) { - goto error; - } - } - done++; - break; - - case EJS_TOK_VAR: - if (ejsParse(ep, EJS_STATE_DEC_LIST, flags) - != EJS_STATE_DEC_LIST_DONE) { - goto error; - } - done++; - break; - - case EJS_TOK_COMMA: - ejsLexPutbackToken(ep, tid, ep->token); - done++; - break; - - case EJS_TOK_LPAREN: - if (state == EJS_STATE_EXPR) { - if (ejsParse(ep, EJS_STATE_RELEXP, flags) - != EJS_STATE_RELEXP_DONE) { - goto error; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - goto error; - } - } - done++; - break; - - case EJS_TOK_RPAREN: - ejsLexPutbackToken(ep, tid, ep->token); - done++; - break; - - case EJS_TOK_LBRACE: - /* - * This handles any code in braces except "if () {} else {}" - */ - if (state != EJS_STATE_STMT) { - goto error; - } - - /* - * Parse will return EJS_STATE_STMT_BLOCK_DONE when the RBRACE - * is seen. - */ - do { - state = ejsParse(ep, EJS_STATE_STMT, flags); - } while (state == EJS_STATE_STMT_DONE); - - if (state != EJS_STATE_RET) { - if (ejsLexGetToken(ep, state) != EJS_TOK_RBRACE) { - goto error; - } - state = EJS_STATE_STMT_DONE; - } - done++; - break; - - case EJS_TOK_RBRACE: - if (state == EJS_STATE_STMT) { - ejsLexPutbackToken(ep, tid, ep->token); - state = EJS_STATE_STMT_BLOCK_DONE; - done++; - break; - } - goto error; - - case EJS_TOK_RETURN: - if (ejsParse(ep, EJS_STATE_RELEXP, flags) - != EJS_STATE_RELEXP_DONE) { - goto error; - } - if (flags & EJS_FLAGS_EXE) { - while (ejsLexGetToken(ep, state) != EJS_TOK_EOF) { - ; - } - state = EJS_STATE_RET; - done++; - } - break; - } - } - - if (expectSemi) { - tid = ejsLexGetToken(ep, state); - if (tid != EJS_TOK_SEMI && tid != EJS_TOK_NEWLINE && - tid != EJS_TOK_EOF) { - goto error; - } - - /* - * Skip newline after semi-colon - */ - removeNewlines(ep, state); - } - -/* - * Free resources and return the correct status - */ -doneParse: - mprFree(id); - mprFree(fullName); - - /* - * Advance the state - */ - switch (state) { - case EJS_STATE_STMT: - return EJS_STATE_STMT_DONE; - - case EJS_STATE_DEC: - return EJS_STATE_DEC_DONE; - - case EJS_STATE_EXPR: - return EJS_STATE_EXPR_DONE; - - case EJS_STATE_STMT_DONE: - case EJS_STATE_STMT_BLOCK_DONE: - case EJS_STATE_EOF: - case EJS_STATE_RET: - return state; - - default: - return EJS_STATE_ERR; - } - -/* - * Common error exit - */ -error: - state = EJS_STATE_ERR; - goto doneParse; -} - -/******************************************************************************/ -/* - * Parse function arguments - */ - -static int parseArgs(Ejs *ep, int state, int flags) -{ - int tid; - - mprAssert(ep); - - do { - /* - * Peek and see if there are no args - */ - tid = ejsLexGetToken(ep, state); - ejsLexPutbackToken(ep, tid, ep->token); - if (tid == EJS_TOK_RPAREN) { - break; - } - - state = ejsParse(ep, EJS_STATE_RELEXP, flags); - if (state == EJS_STATE_EOF || state == EJS_STATE_ERR) { - return state; - } - if (state == EJS_STATE_RELEXP_DONE) { - if (flags & EJS_FLAGS_EXE) { - mprAssert(ep->proc->args); - mprAddToArray(ep->proc->args, - mprDupVar(&ep->result, MPR_SHALLOW_COPY)); - } - } - /* - * Peek at the next token, continue if more args (ie. comma seen) - */ - tid = ejsLexGetToken(ep, state); - if (tid != EJS_TOK_COMMA) { - ejsLexPutbackToken(ep, tid, ep->token); - } - } while (tid == EJS_TOK_COMMA); - - if (tid != EJS_TOK_RPAREN && state != EJS_STATE_RELEXP_DONE) { - return EJS_STATE_ERR; - } - return EJS_STATE_ARG_LIST_DONE; -} - -/******************************************************************************/ -/* - * Parse an assignment statement - */ - -static int parseAssignment(Ejs *ep, int state, int flags, char *id, - char *fullName) -{ - MprVar *vp, *saveProperty, *saveObj; - - if (id == 0) { - return -1; - } - - saveObj = ep->currentObj; - saveProperty = ep->currentProperty; - if (ejsParse(ep, EJS_STATE_RELEXP, flags | EJS_FLAGS_ASSIGNMENT) - != EJS_STATE_RELEXP_DONE) { - return -1; - } - ep->currentObj = saveObj; - ep->currentProperty = saveProperty; - - if (! (flags & EJS_FLAGS_EXE)) { - return state; - } - - if (ep->currentProperty) { - /* - * Update the variable. Update the property name if not - * yet defined. - */ - if (ep->currentProperty->name == 0 || - ep->currentProperty->name[0] == '\0') { - mprSetVarName(ep->currentProperty, id); - } - if (mprWriteProperty(ep->currentProperty, &ep->result) < 0){ - ejsError(ep, "Can't write to variable\n"); - return -1; - } - - } else { - /* - * Create the variable - */ - if (ep->currentObj) { - if (ep->currentObj->type != MPR_TYPE_OBJECT) { - if (strcmp(ep->currentObj->name, "session") == 0) { - ejsError(ep, "Variable \"%s\" is not an array or object." - "If using ESP, you need useSession(); in your page.", - ep->currentObj->name); - } else { - ejsError(ep, "Variable \"%s\" is not an array or object", - ep->currentObj->name); - } - return -1; - } - vp = mprCreateProperty(ep->currentObj, id, &ep->result); - - } else { - /* - * Standard says: "var x" means declare locally. - * "x = 2" means declare globally if x is undefined. - */ - if (state == EJS_STATE_DEC) { - vp = mprCreateProperty(ep->local, id, &ep->result); - } else { - vp = mprCreateProperty(ep->global, id, &ep->result); - } - } -#if BLD_DEBUG - mprSetVarFullName(vp, fullName); -#endif - } - return state; -} - -/******************************************************************************/ -/* - * Parse conditional expression (relational ops separated by ||, &&) - */ - -static int parseCond(Ejs *ep, int state, int flags) -{ - MprVar lhs, rhs; - int tid, operator; - - mprAssert(ep); - - mprDestroyVar(&ep->result); - rhs = lhs = mprCreateUndefinedVar(); - operator = 0; - - do { - /* - * Recurse to handle one side of a conditional. Accumulate the - * left hand side and the final result in ep->result. - */ - state = ejsParse(ep, EJS_STATE_RELEXP, flags); - if (state != EJS_STATE_RELEXP_DONE) { - state = EJS_STATE_ERR; - break; - } - - if (operator > 0) { - mprCopyVar(&rhs, &ep->result, MPR_SHALLOW_COPY); - if (evalCond(ep, &lhs, operator, &rhs) < 0) { - state = EJS_STATE_ERR; - break; - } - } - mprCopyVar(&lhs, &ep->result, MPR_SHALLOW_COPY); - - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_LOGICAL) { - operator = (int) *ep->token; - - } else if (tid == EJS_TOK_RPAREN || tid == EJS_TOK_SEMI) { - ejsLexPutbackToken(ep, tid, ep->token); - state = EJS_STATE_COND_DONE; - break; - - } else { - ejsLexPutbackToken(ep, tid, ep->token); - } - tid = (state == EJS_STATE_RELEXP_DONE); - - } while (state == EJS_STATE_RELEXP_DONE); - - mprDestroyVar(&lhs); - mprDestroyVar(&rhs); - return state; -} - -/******************************************************************************/ -/* - * Parse variable declaration list. Declarations can be of the following forms: - * var x; - * var x, y, z; - * var x = 1 + 2 / 3, y = 2 + 4; - * - * We set the variable to NULL if there is no associated assignment. - */ - -static int parseDeclaration(Ejs *ep, int state, int flags) -{ - int tid; - - mprAssert(ep); - - do { - if ((tid = ejsLexGetToken(ep, state)) != EJS_TOK_ID) { - return EJS_STATE_ERR; - } - ejsLexPutbackToken(ep, tid, ep->token); - - /* - * Parse the entire assignment or simple identifier declaration - */ - if (ejsParse(ep, EJS_STATE_DEC, flags) != EJS_STATE_DEC_DONE) { - return EJS_STATE_ERR; - } - - /* - * Peek at the next token, continue if comma seen - */ - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_SEMI) { - return EJS_STATE_DEC_LIST_DONE; - } else if (tid != EJS_TOK_COMMA) { - return EJS_STATE_ERR; - } - } while (tid == EJS_TOK_COMMA); - - if (tid != EJS_TOK_SEMI) { - return EJS_STATE_ERR; - } - return EJS_STATE_DEC_LIST_DONE; -} - -/******************************************************************************/ -/* - * Parse expression (leftHandSide operator rightHandSide) - */ - -static int parseExpr(Ejs *ep, int state, int flags) -{ - MprVar lhs, rhs; - int rel, tid; - - mprAssert(ep); - - mprDestroyVar(&ep->result); - rhs = lhs = mprCreateUndefinedVar(); - rel = 0; - tid = 0; - - do { - /* - * This loop will handle an entire expression list. We call parse - * to evalutate each term which returns the result in ep->result. - */ - if (tid == EJS_TOK_LOGICAL) { - state = ejsParse(ep, EJS_STATE_RELEXP, flags); - if (state != EJS_STATE_RELEXP_DONE) { - state = EJS_STATE_ERR; - break; - } - } else { - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_EXPR && (int) *ep->token == EJS_EXPR_MINUS) { - lhs = mprCreateIntegerVar(0); - rel = (int) *ep->token; - } else { - ejsLexPutbackToken(ep, tid, ep->token); - } - - state = ejsParse(ep, EJS_STATE_EXPR, flags); - if (state != EJS_STATE_EXPR_DONE) { - state = EJS_STATE_ERR; - break; - } - } - - if (rel > 0) { - mprCopyVar(&rhs, &ep->result, MPR_SHALLOW_COPY); - if (tid == EJS_TOK_LOGICAL) { - if (evalCond(ep, &lhs, rel, &rhs) < 0) { - state = EJS_STATE_ERR; - break; - } - } else { - if (evalExpr(ep, &lhs, rel, &rhs) < 0) { - state = EJS_STATE_ERR; - break; - } - } - } - mprCopyVar(&lhs, &ep->result, MPR_SHALLOW_COPY); - - if ((tid = ejsLexGetToken(ep, state)) == EJS_TOK_EXPR || - tid == EJS_TOK_INC_DEC || tid == EJS_TOK_LOGICAL) { - rel = (int) *ep->token; - - } else { - ejsLexPutbackToken(ep, tid, ep->token); - state = EJS_STATE_RELEXP_DONE; - } - - } while (state == EJS_STATE_EXPR_DONE); - - mprDestroyVar(&lhs); - mprDestroyVar(&rhs); - - return state; -} - -/******************************************************************************/ -/* - * Parse the "for ... in" statement. Format for the statement is: - * - * for (var in expr) { - * body; - * } - */ - -static int parseForIn(Ejs *ep, int state, int flags) -{ - EjsInput endScript, bodyScript; - MprVar *iteratorVar, *setVar, *vp, v; - int forFlags, tid; - - mprAssert(ep); - - tid = ejsLexGetToken(ep, state); - if (tid != EJS_TOK_ID) { - return -1; - } - ejsLexPutbackToken(ep, tid, ep->token); - - if (ejsParse(ep, EJS_STATE_EXPR, EJS_FLAGS_FOREACH | EJS_FLAGS_EXE) - != EJS_STATE_EXPR_DONE) { - return -1; - } - if (ep->currentProperty == 0) { - return -1; - } - iteratorVar = ep->currentProperty; - - if (ejsLexGetToken(ep, state) != EJS_TOK_IN) { - return -1; - } - - /* - * Get the set - */ - tid = ejsLexGetToken(ep, state); - if (tid != EJS_TOK_ID) { - return -1; - } - ejsLexPutbackToken(ep, tid, ep->token); - - if (ejsParse(ep, EJS_STATE_EXPR, flags) != EJS_STATE_EXPR_DONE) { - return -1; - } - if (ep->currentProperty == 0 && flags & EJS_FLAGS_EXE) { - return -1; - } - setVar = ep->currentProperty; - - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - return -1; - } - - /* - * Parse the body and remember the end of the body script - */ - forFlags = flags & ~EJS_FLAGS_EXE; - ejsLexSaveInputState(ep, &bodyScript); - if (ejsParse(ep, EJS_STATE_STMT, forFlags) != EJS_STATE_STMT_DONE) { - ejsLexFreeInputState(ep, &bodyScript); - return -1; - } - ejsInitInputState(&endScript); - ejsLexSaveInputState(ep, &endScript); - - /* - * Now actually do the for loop. - */ - if (flags & EJS_FLAGS_EXE) { - if (setVar->type == MPR_TYPE_OBJECT) { - vp = mprGetFirstProperty(setVar, MPR_ENUM_DATA); - while (vp) { - if (strcmp(vp->name, "length") != 0) { - v = mprCreateStringVar(vp->name, 0); - if (mprWriteProperty(iteratorVar, &v) < 0) { - ejsError(ep, "Can't write to variable\n"); - ejsLexFreeInputState(ep, &bodyScript); - ejsLexFreeInputState(ep, &endScript); - return -1; - } - - ejsLexRestoreInputState(ep, &bodyScript); - switch (ejsParse(ep, EJS_STATE_STMT, flags)) { - case EJS_STATE_RET: - return EJS_STATE_RET; - case EJS_STATE_STMT_DONE: - break; - default: - ejsLexFreeInputState(ep, &endScript); - ejsLexFreeInputState(ep, &bodyScript); - return -1; - } - } - vp = mprGetNextProperty(setVar, vp, MPR_ENUM_DATA); - } - } else { - ejsError(ep, "Variable \"%s\" is not an array or object", - setVar->name); - ejsLexFreeInputState(ep, &endScript); - ejsLexFreeInputState(ep, &bodyScript); - return -1; - } - } - ejsLexRestoreInputState(ep, &endScript); - - ejsLexFreeInputState(ep, &endScript); - ejsLexFreeInputState(ep, &bodyScript); - - return state; -} - -/******************************************************************************/ -/* - * Parse the for statement. Format for the expression is: - * - * for (initial; condition; incr) { - * body; - * } - */ - -static int parseFor(Ejs *ep, int state, int flags) -{ - EjsInput condScript, endScript, bodyScript, incrScript; - int forFlags, cond; - - ejsInitInputState(&endScript); - ejsInitInputState(&bodyScript); - ejsInitInputState(&incrScript); - ejsInitInputState(&condScript); - - mprAssert(ep); - - /* - * Evaluate the for loop initialization statement - */ - if (ejsParse(ep, EJS_STATE_EXPR, flags) != EJS_STATE_EXPR_DONE) { - return -1; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_SEMI) { - return -1; - } - - /* - * The first time through, we save the current input context just prior - * to each step: prior to the conditional, the loop increment and - * the loop body. - */ - ejsLexSaveInputState(ep, &condScript); - if (ejsParse(ep, EJS_STATE_COND, flags) != EJS_STATE_COND_DONE) { - goto error; - } - cond = (ep->result.boolean != 0); - - if (ejsLexGetToken(ep, state) != EJS_TOK_SEMI) { - goto error; - } - - /* - * Don't execute the loop increment statement or the body - * first time. - */ - forFlags = flags & ~EJS_FLAGS_EXE; - ejsLexSaveInputState(ep, &incrScript); - if (ejsParse(ep, EJS_STATE_EXPR, forFlags) != EJS_STATE_EXPR_DONE) { - goto error; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - goto error; - } - - /* - * Parse the body and remember the end of the body script - */ - ejsLexSaveInputState(ep, &bodyScript); - if (ejsParse(ep, EJS_STATE_STMT, forFlags) != EJS_STATE_STMT_DONE) { - goto error; - } - ejsLexSaveInputState(ep, &endScript); - - /* - * Now actually do the for loop. Note loop has been rotated - */ - while (cond && (flags & EJS_FLAGS_EXE)) { - /* - * Evaluate the body - */ - ejsLexRestoreInputState(ep, &bodyScript); - - switch (ejsParse(ep, EJS_STATE_STMT, flags)) { - case EJS_STATE_RET: - return EJS_STATE_RET; - case EJS_STATE_STMT_DONE: - break; - default: - goto error; - } - /* - * Evaluate the increment script - */ - ejsLexRestoreInputState(ep, &incrScript); - if (ejsParse(ep, EJS_STATE_EXPR, flags) != EJS_STATE_EXPR_DONE){ - goto error; - } - /* - * Evaluate the condition - */ - ejsLexRestoreInputState(ep, &condScript); - if (ejsParse(ep, EJS_STATE_COND, flags) != EJS_STATE_COND_DONE) { - goto error; - } - mprAssert(ep->result.type == MPR_TYPE_BOOL); - cond = (ep->result.boolean != 0); - } - - ejsLexRestoreInputState(ep, &endScript); - -done: - ejsLexFreeInputState(ep, &condScript); - ejsLexFreeInputState(ep, &incrScript); - ejsLexFreeInputState(ep, &endScript); - ejsLexFreeInputState(ep, &bodyScript); - return state; - -error: - state = EJS_STATE_ERR; - goto done; -} - -/******************************************************************************/ -/* - * Parse a function declaration - */ - -static int parseFunctionDec(Ejs *ep, int state, int flags) -{ - EjsInput endScript, bodyScript; - MprVar v, *currentObj, *vp; - char *procName; - int len, tid, bodyFlags; - - mprAssert(ep); - mprAssert(ejsPtr(ep->eid)); - - /* - * function (arg, arg, arg) { body }; - * function name(arg, arg, arg) { body }; - */ - - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_ID) { - procName = mprStrdup(ep->token); - tid = ejsLexGetToken(ep, state); - } else { - procName = 0; - } - if (tid != EJS_TOK_LPAREN) { - mprFree(procName); - return EJS_STATE_ERR; - } - - /* - * Hand craft the function value structure. - */ - v = mprCreateFunctionVar(0, 0, 0); - tid = ejsLexGetToken(ep, state); - while (tid == EJS_TOK_ID) { - mprAddToArray(v.function.args, mprStrdup(ep->token)); - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_RPAREN || tid != EJS_TOK_COMMA) { - break; - } - tid = ejsLexGetToken(ep, state); - } - if (tid != EJS_TOK_RPAREN) { - mprFree(procName); - mprDestroyVar(&v); - return EJS_STATE_ERR; - } - - /* Allow new lines before opening brace */ - do { - tid = ejsLexGetToken(ep, state); - } while (tid == EJS_TOK_NEWLINE); - - if (tid != EJS_TOK_LBRACE) { - mprFree(procName); - mprDestroyVar(&v); - return EJS_STATE_ERR; - } - - /* - * Register the function name early to allow for recursive - * function calls (see note in ECMA standard, page 71) - */ - if (!(flags & EJS_FLAGS_ASSIGNMENT)) { - currentObj = ejsFindObj(ep, 0, procName, flags); - vp = mprSetProperty(currentObj, procName, &v); - } - - /* - * Parse the function body. Turn execute off. - */ - bodyFlags = flags & ~EJS_FLAGS_EXE; - ejsLexSaveInputState(ep, &bodyScript); - - do { - state = ejsParse(ep, EJS_STATE_STMT, bodyFlags); - } while (state == EJS_STATE_STMT_DONE); - - tid = ejsLexGetToken(ep, state); - if (state != EJS_STATE_STMT_BLOCK_DONE || tid != EJS_TOK_RBRACE) { - mprFree(procName); - mprDestroyVar(&v); - ejsLexFreeInputState(ep, &bodyScript); - return EJS_STATE_ERR; - } - ejsLexSaveInputState(ep, &endScript); - - /* - * Save the function body between the starting and ending parse positions. - * Overwrite the trailing '}' with a null. - */ - len = endScript.scriptServp - bodyScript.scriptServp; - v.function.body = mprMalloc(len + 1); - memcpy(v.function.body, bodyScript.scriptServp, len); - - if (len <= 0) { - v.function.body[0] = '\0'; - } else { - v.function.body[len - 1] = '\0'; - } - ejsLexFreeInputState(ep, &bodyScript); - ejsLexFreeInputState(ep, &endScript); - - /* - * If we are in an assignment, don't register the function name, rather - * return the function structure in the parser result. - */ - if (flags & EJS_FLAGS_ASSIGNMENT) { - mprCopyVar(&ep->result, &v, MPR_SHALLOW_COPY); - } else { - currentObj = ejsFindObj(ep, 0, procName, flags); - vp = mprSetProperty(currentObj, procName, &v); - } - - mprFree(procName); - mprDestroyVar(&v); - - return EJS_STATE_STMT; -} - -/******************************************************************************/ -/* - * Parse a function name and invoke the function - */ - -static int parseFunction(Ejs *ep, int state, int flags, char *id) -{ - EjsProc proc, *saveProc; - MprVar *saveObj; - - /* - * Must save any current ep->proc value for the current stack frame - * to allow for recursive function calls. - */ - saveProc = (ep->proc) ? ep->proc: 0; - - memset(&proc, 0, sizeof(EjsProc)); - proc.procName = mprStrdup(id); - proc.fn = ep->currentProperty; - proc.args = mprCreateArray(); - ep->proc = &proc; - - mprDestroyVar(&ep->result); - - saveObj = ep->currentObj; - if (ejsParse(ep, EJS_STATE_ARG_LIST, flags) != EJS_STATE_ARG_LIST_DONE) { - freeProc(&proc); - ep->proc = saveProc; - return -1; - } - ep->currentObj = saveObj; - - /* - * Evaluate the function if required - */ - if (flags & EJS_FLAGS_EXE) { - if (evalFunction(ep, ep->currentObj, flags) < 0) { - freeProc(&proc); - ep->proc = saveProc; - return -1; - } - } - - freeProc(&proc); - ep->proc = saveProc; - - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - return -1; - } - return state; -} - -/******************************************************************************/ -/* - * Parse an identifier. This is a segment of a fully qualified variable. - * May come here for an initial identifier or for property names - * after a "." or "[...]". - */ - -static int parseId(Ejs *ep, int state, int flags, char **id, char **fullName, - int *fullNameLen, int *done) -{ - int tid; - - mprFree(*id); - *id = mprStrdup(ep->token); -#if BLD_DEBUG - *fullNameLen = mprReallocStrcat(fullName, MPR_MAX_VAR, *fullNameLen, - 0, *id, NULL); -#endif - if (ep->currentObj == 0) { - ep->currentObj = ejsFindObj(ep, state, *id, flags); - } - - /* - * Find the referenced variable and store it in currentProperty. - */ - ep->currentProperty = ejsFindProperty(ep, state, ep->currentObj, - *id, flags); - updateResult(ep, state, flags, ep->currentProperty); - -#if BLD_DEBUG - if (ep->currentProperty && (ep->currentProperty->name == 0 || - ep->currentProperty->name[0] == '\0')) { - mprSetVarName(ep->currentProperty, *id); - } -#endif - - tid = ejsLexGetToken(ep, state); - if (tid == EJS_TOK_LPAREN) { - if (ep->currentProperty == 0 && (flags & EJS_FLAGS_EXE)) { - ejsError(ep, "Function name not defined \"%s\"\n", *id); - return -1; - } - ejsLexPutbackToken(ep, EJS_TOK_FUNCTION_NAME, ep->token); - return state; - } - - if (tid == EJS_TOK_PERIOD || tid == EJS_TOK_LBRACKET || - tid == EJS_TOK_ASSIGNMENT || tid == EJS_TOK_INC_DEC) { - ejsLexPutbackToken(ep, tid, ep->token); - return state; - } - - /* - * Only come here for variable access and declarations. - * Assignment handled elsewhere. - */ - if (flags & EJS_FLAGS_EXE) { - if (state == EJS_STATE_DEC) { - /* - * Declare a variable. Standard allows: var x ; var x ; - */ -#if DISABLED - if (ep->currentProperty != 0) { - ejsError(ep, "Variable already defined \"%s\"\n", *id); - return -1; - } -#endif - /* - * Create or overwrite if it already exists - */ - mprSetPropertyValue(ep->currentObj, *id, - mprCreateUndefinedVar()); - ep->currentProperty = 0; - mprDestroyVar(&ep->result); - - } else if (flags & EJS_FLAGS_FOREACH) { - if (ep->currentProperty == 0) { - ep->currentProperty = - mprCreatePropertyValue(ep->currentObj, *id, - mprCreateUndefinedVar()); - } - - } else { - if (ep->currentProperty == 0) { - if (ep->currentObj == ep->global || - ep->currentObj == ep->local) { - ejsError(ep, "Undefined variable \"%s\"\n", *id); - return -1; - } - ep->currentProperty = mprCreatePropertyValue(ep->currentObj, - *id, mprCreateUndefinedVar()); - } - } - } - ejsLexPutbackToken(ep, tid, ep->token); - if (tid == EJS_TOK_RBRACKET || tid == EJS_TOK_COMMA || - tid == EJS_TOK_IN) { - *done = 1; - } - return state; -} - -/******************************************************************************/ -/* - * Parse an "if" statement - */ - -static int parseIf(Ejs *ep, int state, int flags, int *done) -{ - bool ifResult; - int thenFlags, elseFlags, tid; - - if (state != EJS_STATE_STMT) { - return -1; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_LPAREN) { - return -1; - } - - /* - * Evaluate the entire condition list "(condition)" - */ - if (ejsParse(ep, EJS_STATE_COND, flags) != EJS_STATE_COND_DONE) { - return -1; - } - if (ejsLexGetToken(ep, state) != EJS_TOK_RPAREN) { - return -1; - } - - /* - * This is the "then" case. We need to always parse both cases and - * execute only the relevant case. - */ - ifResult = mprVarToBool(&ep->result); - if (ifResult) { - thenFlags = flags; - elseFlags = flags & ~EJS_FLAGS_EXE; - } else { - thenFlags = flags & ~EJS_FLAGS_EXE; - elseFlags = flags; - } - - /* - * Process the "then" case. - */ - switch (ejsParse(ep, EJS_STATE_STMT, thenFlags)) { - case EJS_STATE_RET: - state = EJS_STATE_RET; - return state; - case EJS_STATE_STMT_DONE: - break; - default: - return -1; - } - - /* - * Check to see if there is an "else" case - */ - removeNewlines(ep, state); - tid = ejsLexGetToken(ep, state); - if (tid != EJS_TOK_ELSE) { - ejsLexPutbackToken(ep, tid, ep->token); - *done = 1; - return state; - } - - /* - * Process the "else" case. - */ - switch (ejsParse(ep, EJS_STATE_STMT, elseFlags)) { - case EJS_STATE_RET: - state = EJS_STATE_RET; - return state; - case EJS_STATE_STMT_DONE: - break; - default: - return -1; - } - *done = 1; - return state; -} - -/******************************************************************************/ -/* - * Parse an "++" or "--" statement - */ - -static int parseInc(Ejs *ep, int state, int flags) -{ - MprVar one; - - if (! (flags & EJS_FLAGS_EXE)) { - return state; - } - - if (ep->currentProperty == 0) { - ejsError(ep, "Undefined variable \"%s\"\n", ep->token); - return -1; - } - one = mprCreateIntegerVar(1); - if (evalExpr(ep, ep->currentProperty, (int) *ep->token, - &one) < 0) { - return -1; - } - if (mprWriteProperty(ep->currentProperty, &ep->result) < 0) { - ejsError(ep, "Can't write to variable\n"); - return -1; - } - return state; -} - -/******************************************************************************/ -/* - * Evaluate a condition. Implements &&, ||, !. Returns with a boolean result - * in ep->result. Returns -1 on errors, zero if successful. - */ - -static int evalCond(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs) -{ - bool l, r, lval; - - mprAssert(rel > 0); - - l = mprVarToBool(lhs); - r = mprVarToBool(rhs); - - switch (rel) { - case EJS_COND_AND: - lval = l && r; - break; - case EJS_COND_OR: - lval = l || r; - break; - default: - ejsError(ep, "Bad operator %d", rel); - return -1; - } - - mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0); - return 0; -} - - -/* - return true if this string is a valid number -*/ -static int string_is_number(const char *s) -{ - char *endptr = NULL; - if (s == NULL || *s == 0) { - return 0; - } - strtod(s, &endptr); - if (endptr != NULL && *endptr == 0) { - return 1; - } - return 0; -} - -/******************************************************************************/ -/* - * Evaluate an operation. Returns with the result in ep->result. Returns -1 - * on errors, otherwise zero is returned. - */ - -static int evalExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs) -{ - char *str; - MprNum lval, num; - int rc; - - mprAssert(rel > 0); - str = 0; - lval = 0; - - /* - * Type conversion. This is tricky and must be according to the standard. - * Only numbers (including floats) and strings can be compared. All other - * types are first converted to numbers by preference and if that fails, - * to strings. - * - * First convert objects to comparable types. The "===" operator will - * test the sameness of object references. Here, we coerce to comparable - * types first. - */ - if (lhs->type == MPR_TYPE_OBJECT) { - if (ejsRunFunction(ep->eid, lhs, "toValue", 0) == 0) { - mprCopyVar(lhs, &ep->result, MPR_SHALLOW_COPY); - } else { - if (ejsRunFunction(ep->eid, lhs, "toString", 0) == 0) { - mprCopyVar(lhs, &ep->result, MPR_SHALLOW_COPY); - } - } - /* Nothing more can be done */ - } - - if (rhs->type == MPR_TYPE_OBJECT) { - if (ejsRunFunction(ep->eid, rhs, "toValue", 0) == 0) { - mprCopyVar(rhs, &ep->result, MPR_SHALLOW_COPY); - } else { - if (ejsRunFunction(ep->eid, rhs, "toString", 0) == 0) { - mprCopyVar(rhs, &ep->result, MPR_SHALLOW_COPY); - } - } - /* Nothing more can be done */ - } - - /* undefined and null are special, in that they don't get promoted when - comparing */ - if (rel == EJS_EXPR_EQ || rel == EJS_EXPR_NOTEQ) { - if (lhs->type == MPR_TYPE_UNDEFINED || rhs->type == MPR_TYPE_UNDEFINED) { - return evalBoolExpr(ep, - lhs->type == MPR_TYPE_UNDEFINED, - rel, - rhs->type == MPR_TYPE_UNDEFINED); - } - - if (lhs->type == MPR_TYPE_NULL || rhs->type == MPR_TYPE_NULL) { - return evalBoolExpr(ep, - lhs->type == MPR_TYPE_NULL, - rel, - rhs->type == MPR_TYPE_NULL); - } - } - - /* - * From here on, lhs and rhs may contain allocated data (strings), so - * we must always destroy before overwriting. - */ - - /* - * Only allow a few bool operations. Otherwise convert to number. - */ - if (lhs->type == MPR_TYPE_BOOL && rhs->type == MPR_TYPE_BOOL && - (rel != EJS_EXPR_EQ && rel != EJS_EXPR_NOTEQ && - rel != EJS_EXPR_BOOL_COMP)) { - num = mprVarToNumber(lhs); - mprDestroyVar(lhs); - *lhs = mprCreateNumberVar(num); - } - - /* - * Types do not match, so try to coerce the right operand to match the left - * But first, try to convert a left operand that is a numeric stored as a - * string, into a numeric. - */ - if (lhs->type != rhs->type) { - if (lhs->type == MPR_TYPE_STRING) { - if (string_is_number(lhs->string)) { - num = mprVarToNumber(lhs); - lhs->allocatedVar = 0; - mprDestroyVar(lhs); - *lhs = mprCreateNumberVar(num); - /* Examine further below */ - - } else { - /* - * Convert the RHS to a string - */ - mprVarToString(&str, MPR_MAX_STRING, 0, rhs); - rhs->allocatedVar = 0; - mprDestroyVar(rhs); - *rhs = mprCreateStringVar(str, 1); - mprFree(str); - } - -#if BLD_FEATURE_FLOATING_POINT - } else if (lhs->type == MPR_TYPE_FLOAT) { - /* - * Convert rhs to floating - */ - double f = mprVarToFloat(rhs); - mprDestroyVar(rhs); - *rhs = mprCreateFloatVar(f); - -#endif -#if BLD_FEATURE_INT64 - } else if (lhs->type == MPR_TYPE_INT64) { - /* - * Convert the rhs to 64 bit - */ - int64 n = mprVarToInteger64(rhs); - mprDestroyVar(rhs); - *rhs = mprCreateInteger64Var(n); -#endif - } else if (lhs->type == MPR_TYPE_BOOL || lhs->type == MPR_TYPE_INT) { - - if (rhs->type == MPR_TYPE_STRING) { - /* - * Convert to lhs to a string - */ - mprVarToString(&str, MPR_MAX_STRING, 0, lhs); - mprDestroyVar(lhs); - *lhs = mprCreateStringVar(str, 1); - mprFree(str); - -#if BLD_FEATURE_FLOATING_POINT - } else if (rhs->type == MPR_TYPE_FLOAT) { - /* - * Convert lhs to floating - */ - double f = mprVarToFloat(lhs); - mprDestroyVar(lhs); - *lhs = mprCreateFloatVar(f); -#endif - - } else { - /* - * Convert both operands to numbers - */ - num = mprVarToNumber(lhs); - mprDestroyVar(lhs); - *lhs = mprCreateNumberVar(num); - - num = mprVarToNumber(rhs); - mprDestroyVar(rhs); - *rhs = mprCreateNumberVar(num); - } - } - } - - /* - * We have failed to coerce the types to be the same. Special case here - * for undefined and null. We need to allow comparisions against these - * special values. - */ - if (lhs->type == MPR_TYPE_UNDEFINED || lhs->type == MPR_TYPE_NULL) { - switch (rel) { - case EJS_EXPR_EQ: - lval = lhs->type == rhs->type; - break; - case EJS_EXPR_NOTEQ: - lval = lhs->type != rhs->type; - break; - case EJS_EXPR_BOOL_COMP: - lval = ! mprVarToBool(rhs); - break; - default: - lval = 0; - } - mprCopyVarValue(&ep->result, mprCreateBoolVar((bool) lval), 0); - return 0; - } - - /* - * Types are the same here - */ - switch (lhs->type) { - default: - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - /* Should be handled above */ - mprAssert(0); - return 0; - - case MPR_TYPE_STRING_CFUNCTION: - case MPR_TYPE_CFUNCTION: - case MPR_TYPE_FUNCTION: - case MPR_TYPE_OBJECT: - mprCopyVarValue(&ep->result, mprCreateBoolVar(0), 0); - return 0; - - case MPR_TYPE_PTR: - rc = evalPtrExpr(ep, lhs->ptr, rel, rhs->ptr); - break; - - case MPR_TYPE_BOOL: - rc = evalBoolExpr(ep, lhs->boolean, rel, rhs->boolean); - break; - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - rc = evalFloatExpr(ep, lhs->floating, rel, rhs->floating); - break; -#endif - - case MPR_TYPE_INT: - rc = evalNumericExpr(ep, (MprNum) lhs->integer, rel, - (MprNum) rhs->integer); - break; - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - rc = evalNumericExpr(ep, (MprNum) lhs->integer64, rel, - (MprNum) rhs->integer64); - break; -#endif - - case MPR_TYPE_STRING: - rc = evalStringExpr(ep, lhs, rel, rhs); - } - return rc; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Expressions with floating operands - */ - -static int evalFloatExpr(Ejs *ep, double l, int rel, double r) -{ - double lval; - bool logical; - - lval = 0; - logical = 0; - - switch (rel) { - case EJS_EXPR_PLUS: - lval = l + r; - break; - case EJS_EXPR_INC: - lval = l + 1; - break; - case EJS_EXPR_MINUS: - lval = l - r; - break; - case EJS_EXPR_DEC: - lval = l - 1; - break; - case EJS_EXPR_MUL: - lval = l * r; - break; - case EJS_EXPR_DIV: - lval = l / r; - break; - default: - logical++; - break; - } - - /* - * Logical operators - */ - if (logical) { - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_LESS: - lval = (l < r) ? 1 : 0; - break; - case EJS_EXPR_LESSEQ: - lval = (l <= r) ? 1 : 0; - break; - case EJS_EXPR_GREATER: - lval = (l > r) ? 1 : 0; - break; - case EJS_EXPR_GREATEREQ: - lval = (l >= r) ? 1 : 0; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == 0) ? 1 : 0; - break; - default: - ejsError(ep, "Bad operator %d", rel); - return -1; - } - mprCopyVarValue(&ep->result, mprCreateBoolVar(lval != 0), 0); - - } else { - mprCopyVarValue(&ep->result, mprCreateFloatVar(lval), 0); - } - return 0; -} - -#endif /* BLD_FEATURE_FLOATING_POINT */ -/******************************************************************************/ -/* - * Expressions with boolean operands - */ - -static int evalBoolExpr(Ejs *ep, bool l, int rel, bool r) -{ - bool lval; - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == 0) ? 1 : 0; - break; - default: - ejsError(ep, "Bad operator %d", rel); - return -1; - } - mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0); - return 0; -} - -static int evalPtrExpr(Ejs *ep, void *l, int rel, void *r) -{ - bool lval; - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == NULL) ? 1 : 0; - break; - default: - ejsError(ep, "Bad operator %d", rel); - return -1; - } - mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0); - return 0; -} - -/******************************************************************************/ -/* - * Expressions with numeric operands - */ - -static int evalNumericExpr(Ejs *ep, MprNum l, int rel, MprNum r) -{ - MprNum lval; - bool logical; - - lval = 0; - logical = 0; - - switch (rel) { - case EJS_EXPR_PLUS: - lval = l + r; - break; - case EJS_EXPR_INC: - lval = l + 1; - break; - case EJS_EXPR_MINUS: - lval = l - r; - break; - case EJS_EXPR_DEC: - lval = l - 1; - break; - case EJS_EXPR_MUL: - lval = l * r; - break; - case EJS_EXPR_DIV: - if (r != 0) { - lval = l / r; - } else { - ejsError(ep, "Divide by zero"); - return -1; - } - break; - case EJS_EXPR_MOD: - if (r != 0) { - lval = l % r; - } else { - ejsError(ep, "Modulo zero"); - return -1; - } - break; - case EJS_EXPR_LSHIFT: - lval = l << r; - break; - case EJS_EXPR_RSHIFT: - lval = l >> r; - break; - - default: - logical++; - break; - } - - /* - * Logical operators - */ - if (logical) { - - switch (rel) { - case EJS_EXPR_EQ: - lval = l == r; - break; - case EJS_EXPR_NOTEQ: - lval = l != r; - break; - case EJS_EXPR_LESS: - lval = (l < r) ? 1 : 0; - break; - case EJS_EXPR_LESSEQ: - lval = (l <= r) ? 1 : 0; - break; - case EJS_EXPR_GREATER: - lval = (l > r) ? 1 : 0; - break; - case EJS_EXPR_GREATEREQ: - lval = (l >= r) ? 1 : 0; - break; - case EJS_EXPR_BOOL_COMP: - lval = (r == 0) ? 1 : 0; - break; - default: - ejsError(ep, "Bad operator %d", rel); - return -1; - } - mprCopyVarValue(&ep->result, mprCreateBoolVar(lval != 0), 0); - - } else { - mprCopyVarValue(&ep->result, mprCreateNumberVar(lval), 0); - } - return 0; -} - -/******************************************************************************/ -/* - * Expressions with string operands - */ - -static int evalStringExpr(Ejs *ep, MprVar *lhs, int rel, MprVar *rhs) -{ - int lval; - - mprAssert(ep); - mprAssert(lhs); - mprAssert(rhs); - - switch (rel) { - case EJS_EXPR_LESS: - lval = strcmp(lhs->string, rhs->string) < 0; - break; - case EJS_EXPR_LESSEQ: - lval = strcmp(lhs->string, rhs->string) <= 0; - break; - case EJS_EXPR_GREATER: - lval = strcmp(lhs->string, rhs->string) > 0; - break; - case EJS_EXPR_GREATEREQ: - lval = strcmp(lhs->string, rhs->string) >= 0; - break; - case EJS_EXPR_EQ: - lval = strcmp(lhs->string, rhs->string) == 0; - break; - case EJS_EXPR_NOTEQ: - lval = strcmp(lhs->string, rhs->string) != 0; - break; - case EJS_EXPR_PLUS: - /* - * This differs from all the above operations. We append rhs to lhs. - */ - mprDestroyVar(&ep->result); - appendValue(&ep->result, lhs); - appendValue(&ep->result, rhs); - return 0; - - case EJS_EXPR_INC: - case EJS_EXPR_DEC: - case EJS_EXPR_MINUS: - case EJS_EXPR_DIV: - case EJS_EXPR_MOD: - case EJS_EXPR_LSHIFT: - case EJS_EXPR_RSHIFT: - default: - ejsError(ep, "Bad operator"); - return -1; - } - - mprCopyVarValue(&ep->result, mprCreateBoolVar(lval), 0); - return 0; -} - -/******************************************************************************/ -/* - * Evaluate a function. obj is set to the current object if a function is being - * run. - */ - -static int evalFunction(Ejs *ep, MprVar *obj, int flags) -{ - EjsProc *proc; - MprVar arguments, callee, thisObject, *prototype, **argValues; - MprArray *formalArgs, *actualArgs; - char buf[16], **argNames, **argBuf; - int i, rc, fid; - - mprAssert(ep); - mprAssert(ejsPtr(ep->eid)); - - rc = -1; - proc = ep->proc; - prototype = proc->fn; - actualArgs = proc->args; - argValues = (MprVar**) actualArgs->handles; - - /* - * Create a new variable stack frame. ie. new local variables. - */ - fid = ejsOpenBlock(ep->eid); - - if (flags & EJS_FLAGS_NEW) { - /* - * Create a new bare object and pass it into the constructor as the - * "this" local variable. - */ - thisObject = ejsCreateObj("this", EJS_OBJ_HASH_SIZE); - mprCreatePropertyValue(ep->local, "this", thisObject); - - } else if (obj) { - mprCreateProperty(ep->local, "this", obj); - } - - switch (prototype->type) { - default: - mprAssert(0); - break; - - case MPR_TYPE_STRING_CFUNCTION: - if (actualArgs->used > 0) { - argBuf = mprMalloc((1+actualArgs->used) * sizeof(char*)); - for (i = 0; i < actualArgs->used; i++) { - mprVarToString(&argBuf[i], MPR_MAX_STRING, 0, argValues[i]); - } - argBuf[i] = NULL; - } else { - argBuf = 0; - } - - /* - * Call the function depending on the various handle flags - */ - ep->thisPtr = prototype->cFunctionWithStrings.thisPtr; - if (prototype->flags & MPR_VAR_ALT_HANDLE) { - rc = ((EjsAltStringCFunction) prototype->cFunctionWithStrings.fn) - (ep->eid, ep->altHandle, actualArgs->used, argBuf); - } else if (prototype->flags & MPR_VAR_SCRIPT_HANDLE) { - rc = (prototype->cFunctionWithStrings.fn)(ep->eid, - actualArgs->used, argBuf); - } else { - rc = (prototype->cFunctionWithStrings.fn)(ep->primaryHandle, - actualArgs->used, argBuf); - } - - if (actualArgs->used > 0) { - for (i = 0; i < actualArgs->used; i++) { - mprFree(argBuf[i]); - } - mprFree(argBuf); - } - ep->thisPtr = 0; - break; - - case MPR_TYPE_CFUNCTION: - /* - * Call the function depending on the various handle flags - */ - ep->thisPtr = prototype->cFunction.thisPtr; - if (prototype->flags & MPR_VAR_ALT_HANDLE) { - rc = ((EjsAltCFunction) prototype->cFunction.fn) - (ep->eid, ep->altHandle, actualArgs->used, argValues); - } else if (prototype->flags & MPR_VAR_SCRIPT_HANDLE) { - rc = (prototype->cFunction.fn)(ep->eid, actualArgs->used, - argValues); - } else { - rc = (prototype->cFunction.fn)(ep->primaryHandle, - actualArgs->used, argValues); - } - ep->thisPtr = 0; - break; - - case MPR_TYPE_FUNCTION: - - formalArgs = prototype->function.args; - argNames = (char**) formalArgs->handles; - - if (formalArgs->used > actualArgs->used) { - ejsError(ep, "Bad number of args. Should be %d", - formalArgs->used); - return -1; - } - - /* - * Create the arguments and callee variables - */ - arguments = ejsCreateObj("arguments", EJS_SMALL_OBJ_HASH_SIZE); - callee = ejsCreateObj("callee", EJS_SMALL_OBJ_HASH_SIZE); - - /* - * Overwrite the length property - */ - mprCreatePropertyValue(&arguments, "length", - mprCreateIntegerVar(actualArgs->used)); - mprCreatePropertyValue(&callee, "length", - mprCreateIntegerVar(formalArgs->used)); - - /* - * Define all the agruments to be set to the actual parameters - */ - for (i = 0; i < formalArgs->used; i++) { - mprCreateProperty(ep->local, argNames[i], argValues[i]); - } - for (i = 0; i < actualArgs->used; i++) { - mprItoa(i, buf, sizeof(buf)); - mprCreateProperty(&arguments, buf, argValues[i]); - } - - mprCreateProperty(&arguments, "callee", &callee); - mprCreateProperty(ep->local, "arguments", &arguments); - - /* - * Can destroy our variables here as they are now referenced via - * "local" - */ - mprDestroyVar(&callee); - mprDestroyVar(&arguments); - - /* - * Actually run the function - */ - rc = ejsEvalScript(ep->eid, prototype->function.body, 0, 0); - break; - } - - ejsCloseBlock(ep->eid, fid); - - /* - * New statements return the newly created object as the result of the - * command - */ - if (flags & EJS_FLAGS_NEW) { - mprDestroyVar(&ep->result); - /* - * Don't copy, we want to assign the actual object into result. - * (mprCopyVar would inc the refCount to 2). - */ - ep->result = thisObject; - } - return rc; -} - -/******************************************************************************/ -/* - * Run a function - */ - -int ejsRunFunction(int eid, MprVar *obj, const char *functionName, - MprArray *args) -{ - EjsProc proc, *saveProc; - Ejs *ep; - int rc; - - mprAssert(obj); - mprAssert(functionName && *functionName); - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return MPR_ERR_NOT_FOUND; - } - saveProc = ep->proc; - ep->proc = &proc; - - memset(&proc, 0, sizeof(EjsProc)); - mprDestroyVar(&ep->result); - - proc.fn = mprGetProperty(obj, functionName, 0); - if (proc.fn == 0 || proc.fn->type == MPR_TYPE_UNDEFINED) { - ep->proc = saveProc; - return MPR_ERR_NOT_FOUND; - } - proc.procName = mprStrdup(functionName); - if (args == 0) { - proc.args = mprCreateArray(); - rc = evalFunction(ep, obj, 0); - } else { - proc.args = args; - rc = evalFunction(ep, obj, 0); - proc.args = 0; - } - - freeProc(&proc); - ep->proc = saveProc; - - return rc; -} - -/******************************************************************************/ -/* - * Find which object contains the property given the current context. - * Only used for top level properties. - */ - -MprVar *ejsFindObj(Ejs *ep, int state, const char *property, int flags) -{ - MprVar *obj; - - mprAssert(ep); - mprAssert(property && *property); - - if (flags & EJS_FLAGS_GLOBAL) { - obj = ep->global; - - } else if (state == EJS_STATE_DEC || flags & EJS_FLAGS_LOCAL) { - obj = ep->local; - - } else { - /* First look local, then look global */ - if (mprGetProperty(ep->local, property, 0)) { - obj = ep->local; - } else { - obj = ep->global; - } - } - return obj; -} - -/******************************************************************************/ -/* - * Find an object property given a object and a property name. We - * intelligently look in the local and global namespaces depending on - * our state. If not found in local or global, try base classes for function - * names only. Returns the property or NULL. - */ - -MprVar *ejsFindProperty(Ejs *ep, int state, MprVar *obj, char *property, - int flags) -{ - MprVar *vp; - - mprAssert(ep); - if (flags & EJS_FLAGS_EXE) { - mprAssert(property && *property); - } - - if (obj != 0) { -#if FUTURE && MB - op = obj; - do { - vp = mprGetProperty(op, property, 0); - if (vp != 0) { - if (op != obj && mprVarIsFunction(vp->type)) { - } - break; - } - op = op->baseObj; - } while (op); -#endif - vp = mprGetProperty(obj, property, 0); - - } else { - if (state == EJS_STATE_DEC) { - vp = mprGetProperty(ep->local, property, 0); - - } else { - /* Look local first, then global */ - vp = mprGetProperty(ep->local, property, 0); - if (vp == NULL) { - vp = mprGetProperty(ep->global, property, 0); - } - } - } - return vp; -} - -/******************************************************************************/ -/* - * Update result - */ - -static void updateResult(Ejs *ep, int state, int flags, MprVar *vp) -{ - if (flags & EJS_FLAGS_EXE && state != EJS_STATE_DEC) { - mprDestroyVar(&ep->result); - if (vp) { - mprCopyProperty(&ep->result, vp, MPR_SHALLOW_COPY); - } - } -} - -/******************************************************************************/ -/* - * Append to the pointer value - */ - -static void appendValue(MprVar *dest, MprVar *src) -{ - char *value, *oldBuf, *buf; - int len, oldLen; - - mprAssert(dest); - - mprVarToString(&value, MPR_MAX_STRING, 0, src); - - if (mprVarIsValid(dest)) { - len = strlen(value); - oldBuf = dest->string; - oldLen = strlen(oldBuf); - buf = mprRealloc(oldBuf, (len + oldLen + 1) * sizeof(char)); - dest->string = buf; - strcpy(&buf[oldLen], value); - - } else { - *dest = mprCreateStringVar(value, 1); - } - mprFree(value); -} - -/******************************************************************************/ -/* - * Exit with status - */ - -void ejsSetExitStatus(int eid, int status) -{ - Ejs *ep; - - if ((ep = ejsPtr(eid)) == NULL) { - mprAssert(ep); - return; - } - ep->exitStatus = status; - ep->flags |= EJS_FLAGS_EXIT; -} - -/******************************************************************************/ -/* - * Free an argument list - */ - -static void freeProc(EjsProc *proc) -{ - MprVar **argValues; - int i; - - if (proc->args) { - argValues = (MprVar**) proc->args->handles; - - for (i = 0; i < proc->args->max; i++) { - if (argValues[i]) { - mprDestroyVar(argValues[i]); - mprFree(argValues[i]); - mprRemoveFromArray(proc->args, i); - } - } - - mprDestroyArray(proc->args); - } - - if (proc->procName) { - mprFree(proc->procName); - proc->procName = NULL; - } -} - -/******************************************************************************/ -/* - * This function removes any new lines. Used for else cases, etc. - */ - -static void removeNewlines(Ejs *ep, int state) -{ - int tid; - - do { - tid = ejsLexGetToken(ep, state); - } while (tid == EJS_TOK_NEWLINE); - - ejsLexPutbackToken(ep, tid, ep->token); -} - -/******************************************************************************/ - -#else -void ejsParserDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/ejs/ejsProcs.c b/source4/lib/appweb/ejs/ejsProcs.c deleted file mode 100644 index 43fff4a40b..0000000000 --- a/source4/lib/appweb/ejs/ejsProcs.c +++ /dev/null @@ -1,704 +0,0 @@ -/* - * @file ejsProc.c - * @brief EJS support functions - */ -/********************************* Copyright **********************************/ -/* - * @copy default.g - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "ejsInternal.h" - -#if BLD_FEATURE_EJS - -/****************************** Forward Declarations **************************/ -/* - * Object constructors - */ -static int objectConsProc(EjsHandle eid, int argc, MprVar **argv); -static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv); -static int booleanConsProc(EjsHandle eid, int argc, MprVar **agv); -static int numberConsProc(EjsHandle eid, int argc, MprVar **argv); -static int stringConsProc(EjsHandle eid, int argc, MprVar **argv); - -/* - * Core functions - */ -static int toStringProc(EjsHandle eid, int argc, MprVar **argv); -static int valueOfProc(EjsHandle eid, int argc, MprVar **argv); - -/* - * Triggers - */ -static MprVarTriggerStatus lengthTrigger(MprVarTriggerOp op, - MprProperties *parentProperties, MprVar *prop, MprVar *newValue, - int copyRef); - -/******************************************************************************/ -/* - * Routine to create the base common to all object types - */ - -MprVar ejsCreateObj(const char *name, int hashSize) -{ - MprVar o; - - o = mprCreateObjVar(name, hashSize); - if (o.type == MPR_TYPE_UNDEFINED) { - mprAssert(0); - return o; - } - - mprCreatePropertyValue(&o, "toString", - mprCreateCFunctionVar(toStringProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(&o, "valueOf", - mprCreateCFunctionVar(valueOfProc, 0, MPR_VAR_SCRIPT_HANDLE)); - return o; -} - -/******************************************************************************/ -/* - * Routine to destroy a variable - */ - -bool ejsDestroyVar(MprVar *obj) -{ - return mprDestroyVar(obj); -} - -/******************************************************************************/ -/* - * Routine to create the base array type - */ - -MprVar ejsCreateArray(const char *name, int size) -{ - MprVar obj, *lp, undef; - char idx[16]; - int i; - - /* Sanity limit for size of hash table */ - - obj = ejsCreateObj(name, max(size, 503)); - if (obj.type == MPR_TYPE_UNDEFINED) { - mprAssert(0); - return obj; - } - - undef = mprCreateUndefinedVar(); - for (i = 0; i < size; i++) { - mprItoa(i, idx, sizeof(idx)); - mprCreateProperty(&obj, idx, &undef); - } - - lp = mprCreatePropertyValue(&obj, "length", mprCreateIntegerVar(size)); - mprAssert(lp); - - mprSetVarReadonly(lp, 1); - mprAddVarTrigger(lp, lengthTrigger); - - return obj; -} - -/******************************************************************************/ -/******************************** Constructors ********************************/ -/******************************************************************************/ -/* - * Object constructor. Nothing really done here. For future expansion. - */ - -static int objectConsProc(EjsHandle eid, int argc, MprVar **argv) -{ -#if XX_UNUSED_XX - MprVar *obj; - Ejs *ep; - - if((ep = ejsPtr(eid)) == NULL) { - return -1; - } - - obj = mprGetProperty(ep->local, "this", 0); - mprAssert(obj); -#endif - return 0; -} - -/******************************************************************************/ -/* - * Array constructor - */ - -static int arrayConsProc(EjsHandle eid, int argc, MprVar **argv) -{ - MprVar *obj, *lp, undef; - Ejs *ep; - char idx[16]; - int i, max; - - objectConsProc(eid, argc, argv); - - if((ep = ejsPtr(eid)) == NULL) { - return -1; - } - obj = mprGetProperty(ep->local, "this", 0); - mprAssert(obj); - - - if (argc == 1 && mprVarIsNumber(argv[0]->type)) { - /* - * x = new Array(size); - */ - undef = mprCreateUndefinedVar(); - max = (int) mprVarToInteger(argv[0]); - for (i = 0; i < max; i++) { - mprItoa(i, idx, sizeof(idx)); - mprCreateProperty(obj, idx, &undef); - } - } else { - /* - * x = new Array(element0, element1, ..., elementN): - */ - max = argc; - for (i = 0; i < max; i++) { - mprItoa(i, idx, sizeof(idx)); - mprCreateProperty(obj, idx, argv[i]); - } - } - - lp = mprCreatePropertyValue(obj, "length", mprCreateIntegerVar(max)); - mprAssert(lp); - - mprSetVarReadonly(lp, 1); - mprAddVarTrigger(lp, lengthTrigger); - - return 0; -} - -/******************************************************************************/ -/* - * Boolean constructor - */ - -static int booleanConsProc(EjsHandle eid, int argc, MprVar **argv) -{ - objectConsProc(eid, argc, argv); - return 0; -} - -/******************************************************************************/ -#if FUTURE -/* - * Date constructor - */ - -static int dateConsProc(EjsHandle eid, int argc, MprVar **argv) -{ - objectConsProc(eid, argc, argv); - return 0; -} - -#endif -/******************************************************************************/ -/* - * Number constructor - */ - -static int numberConsProc(EjsHandle eid, int argc, MprVar **argv) -{ - objectConsProc(eid, argc, argv); - return 0; -} - -/******************************************************************************/ -/* - * String constructor - */ - -static int stringConsProc(EjsHandle eid, int argc, MprVar **argv) -{ - objectConsProc(eid, argc, argv); - return 0; -} - -/******************************************************************************/ -/********************************** Functions *********************************/ -/******************************************************************************/ - -static int toStringProc(EjsHandle eid, int argc, MprVar **argv) -{ - MprVar *obj; - Ejs *ep; - char *buf; - int radix; - - if (argc == 0) { - radix = 10; - - } else if (argc == 1) { - radix = (int) mprVarToInteger(argv[0]); - - } else { - mprAssert(0); - return -1; - } - - if((ep = ejsPtr(eid)) == NULL) { - return -1; - } - - obj = mprGetProperty(ep->local, "this", 0); - mprAssert(obj); - - mprVarToString(&buf, MPR_MAX_STRING, 0, obj); - mprCopyVarValue(&ep->result, mprCreateStringVar(buf, 0), MPR_SHALLOW_COPY); - mprFree(buf); - - return 0; -} - -/******************************************************************************/ - -static int valueOfProc(EjsHandle eid, int argc, MprVar **argv) -{ - MprVar *obj; - Ejs *ep; - - if (argc != 0) { - mprAssert(0); - return -1; - } - - if((ep = ejsPtr(eid)) == NULL) { - return -1; - } - - obj = mprGetProperty(ep->local, "this", 0); - mprAssert(obj); - - switch (obj->type) { - default: - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - case MPR_TYPE_CFUNCTION: - case MPR_TYPE_OBJECT: - case MPR_TYPE_FUNCTION: - case MPR_TYPE_STRING_CFUNCTION: - case MPR_TYPE_PTR: - mprCopyVar(&ep->result, obj, MPR_SHALLOW_COPY); - break; - - case MPR_TYPE_STRING: - mprCopyVarValue(&ep->result, mprCreateIntegerVar(atoi(obj->string)), 0); - break; - - case MPR_TYPE_BOOL: - case MPR_TYPE_INT: -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: -#endif -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: -#endif - mprCopyVar(&ep->result, obj, 0); - break; - } - return 0; -} - -/******************************************************************************/ -/* - * Var access trigger on the Array.length property. Return the count of - * enumerable properties (don't count functions). - */ - -static MprVarTriggerStatus lengthTrigger(MprVarTriggerOp op, - MprProperties *parentProperties, MprVar *prop, MprVar *newValue, - int copyRef) -{ - switch (op) { - case MPR_VAR_READ: - /* - * Subtract one for the length property - * FUTURE -- need an API to access parentProperties - * FUTURE -- contradiction to be read-only yet allow USE_NEW_VALUE. - * API needs finer control. - */ - *newValue = mprCreateIntegerVar(parentProperties->numDataItems - 1); - return MPR_TRIGGER_USE_NEW_VALUE; - - case MPR_VAR_WRITE: - return MPR_TRIGGER_ABORT; - - case MPR_VAR_CREATE_PROPERTY: - case MPR_VAR_DELETE_PROPERTY: - case MPR_VAR_DELETE: - default: - break; - } - return MPR_TRIGGER_PROCEED; -} - -/******************************************************************************/ -/**************************** Extension Functions *****************************/ -/******************************************************************************/ -/* - * Assert - */ - -static int assertProc(EjsHandle eid, int argc, MprVar **argv) -{ - bool b; - - if (argc < 1) { - ejsSetErrorMsg(eid, "usage: assert(condition)\n"); - return -1; - } - b = mprVarToBool(argv[0]); - if (b == 0) { - ejsSetErrorMsg(eid, "Assertion failure\n"); - return -1; - } - ejsSetReturnValue(eid, mprCreateBoolVar(b)); - return 0; -} - -/******************************************************************************/ -/* - * Exit - */ - -static int exitProc(EjsHandle eid, int argc, MprVar **argv) -{ - int status; - - if (argc < 1) { - ejsSetErrorMsg(eid, "usage: exit(status)\n"); - return -1; - } - status = (int) mprVarToInteger(argv[0]); - ejsSetExitStatus(eid, status); - - ejsSetReturnValue(eid, mprCreateStringVar("", 0)); - return 0; -} - -/******************************************************************************/ - -static void printVar(MprVar *vp, int recurseCount, int indent) -{ - MprVar *np; - char *buf; - int i; - - if (recurseCount > 5) { - write(1, "Skipping - recursion too deep\n", 29); - return; - } - - for (i = 0; i < indent; i++) { - write(1, " ", 2); - } - - if (vp->type == MPR_TYPE_OBJECT) { - if (vp->name) { - write(1, vp->name, strlen(vp->name)); - } else { - write(1, "unknown", 7); - } - write(1, ": {\n", 4); - np = mprGetFirstProperty(vp, MPR_ENUM_DATA); - while (np) { - if (strcmp(np->name, "local") == 0 || - strcmp(np->name, "global") == 0 || - strcmp(np->name, "this") == 0) { - np = mprGetNextProperty(vp, np, MPR_ENUM_DATA); - continue; - } - printVar(np, recurseCount + 1, indent + 1); - np = mprGetNextProperty(vp, np, MPR_ENUM_DATA); - if (np) { - write(1, ",\n", 2); - } - } - write(1, "\n", 1); - for (i = 0; i < indent; i++) { - write(1, " ", 2); - } - write(1, "}", 1); - - } else { - if (vp->name) { - write(1, vp->name, strlen(vp->name)); - } else { - write(1, "unknown", 7); - } - write(1, ": ", 2); - - /* FUTURE -- other types ? */ - mprVarToString(&buf, MPR_MAX_STRING, 0, vp); - if (vp->type == MPR_TYPE_STRING) { - write(1, "\"", 1); - } - write(1, buf, strlen(buf)); - if (vp->type == MPR_TYPE_STRING) { - write(1, "\"", 1); - } - mprFree(buf); - } -} - -/******************************************************************************/ -/* - * Print the args to stdout - */ - -static int printVarsProc(EjsHandle eid, int argc, MprVar **argv) -{ - MprVar *vp; - char *buf; - int i; - - for (i = 0; i < argc; i++) { - vp = argv[i]; - switch (vp->type) { - case MPR_TYPE_OBJECT: - printVar(vp, 0, 0); - break; - default: - mprVarToString(&buf, MPR_MAX_STRING, 0, vp); - write(1, buf, strlen(buf)); - mprFree(buf); - break; - } - } - write(1, "\n", 1); - - ejsSetReturnValue(eid, mprCreateStringVar("", 0)); - return 0; -} - -/******************************************************************************/ -/* - * Print the args to stdout - */ - -static int printProc(EjsHandle eid, int argc, MprVar **argv) -{ - char *buf; - int i; - - for (i = 0; i < argc; i++) { - mprVarToString(&buf, MPR_MAX_STRING, 0, argv[i]); - write(1, buf, strlen(buf)); - mprFree(buf); - } - return 0; -} - -/******************************************************************************/ -/* - * println - */ - -static int printlnProc(EjsHandle eid, int argc, MprVar **argv) -{ - printProc(eid, argc, argv); - write(1, "\n", 1); - return 0; -} - -/******************************************************************************/ -/* - * Trace - */ - -static int traceProc(EjsHandle eid, int argc, char **argv) -{ - if (argc == 1) { - mprLog(0, "%s", argv[0]); - - } else if (argc == 2) { - mprLog(atoi(argv[0]), "%s", argv[1]); - - } else { - ejsSetErrorMsg(eid, "Usage: trace([level], message)"); - return -1; - } - ejsSetReturnString(eid, ""); - return 0; -} - -/******************************************************************************/ -/* - * Return the object reference count - */ - -static int refCountProc(EjsHandle eid, int argc, MprVar **argv) -{ - MprVar *vp; - int count; - - vp = argv[0]; - if (vp->type == MPR_TYPE_OBJECT) { - count = mprGetVarRefCount(vp); - ejsSetReturnValue(eid, mprCreateIntegerVar(count)); - } else { - ejsSetReturnValue(eid, mprCreateIntegerVar(0)); - } - - return 0; -} - -/******************************************************************************/ -/* - * Evaluate a sub-script. It is evaluated in the same variable scope as - * the calling script / function. - */ - -static int evalScriptProc(EjsHandle eid, int argc, MprVar **argv) -{ - MprVar *arg; - char *emsg; - int i; - - ejsSetReturnValue(eid, mprCreateUndefinedVar()); - - for (i = 0; i < argc; i++) { - arg = argv[i]; - if (arg->type != MPR_TYPE_STRING) { - continue; - } - if (ejsEvalScript(eid, arg->string, 0, &emsg) < 0) { - ejsSetErrorMsg(eid, "%s", emsg); - mprFree(emsg); - return -1; - } - } - /* - * Return with the value of the last expression - */ - return 0; -} - -/******************************************************************************/ -/******************************************************************************/ -/******************************************************************************/ -/* - * Define the standard properties and functions inherited by all script engines. - */ - -int ejsDefineStandardProperties(MprVar *obj) -{ -#if BLD_FEATURE_FLOATING_POINT - double d = 0.0; - - /* FUTURE - this generates warnings on some systems. This is okay. */ - - mprCreatePropertyValue(obj, "NaN", mprCreateFloatVar(0.0 / d)); - d = MAX_FLOAT; - mprCreatePropertyValue(obj, "Infinity", mprCreateFloatVar(d * d)); -#endif - mprCreatePropertyValue(obj, "null", mprCreateNullVar()); - mprCreatePropertyValue(obj, "undefined", mprCreateUndefinedVar()); - mprCreatePropertyValue(obj, "true", mprCreateBoolVar(1)); - mprCreatePropertyValue(obj, "false", mprCreateBoolVar(0)); - mprCreatePropertyValue(obj, "NULL", mprCreatePtrVar(NULL)); - -#if BLD_FEATURE_LEGACY_API - /* - * DEPRECATED: 2.0. - * So that ESP/ASP can ignore "language=javascript" statements - */ - mprCreatePropertyValue(obj, "javascript", mprCreateIntegerVar(0)); -#endif - - /* - * Extension functions - */ - mprCreatePropertyValue(obj, "assert", - mprCreateCFunctionVar(assertProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "eval", - mprCreateCFunctionVar(evalScriptProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "exit", - mprCreateCFunctionVar(exitProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "refCount", - mprCreateCFunctionVar(refCountProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "print", - mprCreateCFunctionVar(printProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "println", - mprCreateCFunctionVar(printlnProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "printVars", - mprCreateCFunctionVar(printVarsProc,0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "trace", - mprCreateStringCFunctionVar(traceProc, 0, MPR_VAR_SCRIPT_HANDLE)); - - /* - * Constructors - */ - mprCreatePropertyValue(obj, "Array", - mprCreateCFunctionVar(arrayConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "Boolean", - mprCreateCFunctionVar(booleanConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "Object", - mprCreateCFunctionVar(objectConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "Number", - mprCreateCFunctionVar(numberConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - mprCreatePropertyValue(obj, "String", - mprCreateCFunctionVar(stringConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - - /* mprCreatePropertyValue(obj, "Date", - * mprCreateCFunctionVar(dateConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - * mprCreatePropertyValue(obj, "Regexp", - * mprCreateCFunctionVar(regexpConsProc, 0, MPR_VAR_SCRIPT_HANDLE)); - */ - - /* - * Can we use on var x = "string text"; - */ - return 0; -} - -/******************************************************************************/ - -#else -void ejsProcsDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_EJS */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/esp/esp.c b/source4/lib/appweb/esp/esp.c deleted file mode 100644 index 3e47503edf..0000000000 --- a/source4/lib/appweb/esp/esp.c +++ /dev/null @@ -1,1042 +0,0 @@ -/* - * @file esp.c - * @brief Embedded Server Pages (ESP) core processing. - * @overview Embedded Server Pages provides an efficient way to generate - * dynamic pages using server-side Javascript. This code provides - * core processing, and should be called by an associated web - * server URL handler. - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "esp.h" - -#if BLD_FEATURE_ESP_MODULE - -/*********************************** Locals ***********************************/ -/* - * Master ESP control interface with the web server - */ - -static const Esp *esp; - -/***************************** Forward Declarations ***************************/ - -static int buildScript(EspRequest *ep, char **jsBuf, char *input, char - **errMsg); - -/************************************ Code ************************************/ -/* - * Called at server initialization - */ - -int espOpen(const Esp *control) -{ - mprAssert(control); - -#if BLD_FEATURE_MULTITHREAD - ejsOpen(control->lock, control->unlock, control->lockData); -#else - ejsOpen(0, 0, 0); -#endif - - /* - * Register the standard procedures - */ - espRegisterProcs(); - - /* - * Just for brain dead systems that don't zero global memory - */ - esp = control; - return 0; -} - -/******************************************************************************/ -/* - * Called at server termination - */ - -void espClose() -{ - ejsClose(); -} - -/******************************************************************************/ -/* - * Create for new ESP request. Assumed that this is called after all the - * HTTP headers have been read but before POST data has been read. It is - * expected that any session cookies have been read and that "variables" - * contains references to all the environment objects including "session". - * requestHandle is the web server request handle. - */ - -EspRequest *espCreateRequest(EspHandle webServerRequestHandle, char *uri, - MprVar *variables) -{ - EspRequest *ep; - MprVar *global; -#if BLD_FEATURE_LEGACY_API - MprVar *np; - char keyBuf[ESP_MAX_HEADER]; - int i; -#endif - - mprAssert(variables); - - ep = mprMalloc(sizeof(EspRequest)); - if (ep == 0) { - return 0; - } - memset(ep, 0, sizeof(EspRequest)); - ep->requestHandle = webServerRequestHandle; - ep->esp = esp; - ep->uri = mprStrdup(uri); - ep->docPath = 0; - ep->variables = variables; - - /* - * The handle passed to ejsOpenEngine is passed to every C function - * called by JavaScript. - */ - ep->eid = ejsOpenEngine((EjsHandle) ep, (EjsHandle) webServerRequestHandle); - if (ep->eid < 0) { - mprFree(ep); - return 0; - } - - /* - * All these copies and SetProperties will only copy references - * They will increments the object ref counts. - */ - mprCopyVar(&variables[ESP_GLOBAL_OBJ], ejsGetGlobalObject(ep->eid), - MPR_SHALLOW_COPY); - mprCopyVar(&variables[ESP_LOCAL_OBJ], ejsGetLocalObject(ep->eid), - MPR_SHALLOW_COPY); - - global = &variables[ESP_GLOBAL_OBJ]; - mprCreateProperty(global, "application", &variables[ESP_APPLICATION_OBJ]); - mprCreateProperty(global, "cookies", &variables[ESP_COOKIES_OBJ]); - mprCreateProperty(global, "files", &variables[ESP_FILES_OBJ]); - mprCreateProperty(global, "form", &variables[ESP_FORM_OBJ]); - mprCreateProperty(global, "headers", &variables[ESP_HEADERS_OBJ]); - mprCreateProperty(global, "request", &variables[ESP_REQUEST_OBJ]); - - /* - * FUTURE -- could server be shared across all requests for a given host - * and be made read-only. - */ - mprCreateProperty(global, "server", &variables[ESP_SERVER_OBJ]); - -#if BLD_FEATURE_SESSION - mprCreateProperty(global, "session", &variables[ESP_SESSION_OBJ]); -#endif - -#if BLD_FEATURE_LEGACY_API - /* - * DEPRECATED: 2.0 - * Define variables as globals. headers[] are prefixed with "HTTP_". - * NOTE: MaRequest::setVar does not copy into globals, whereas espSetVar - * does if legacy_api is defined. So variables pre-defined by MaRequest - * must be copied here into globals[]. - * - * NOTE: if a variable is in session[] and in form[], the form[] will - * override being later in the variables[] list. Use mprSetProperty - * instead of mprCreateProperty to cover for this case. - */ - for (i = 0; i < ESP_OBJ_MAX; i++) { - if (i == ESP_GLOBAL_OBJ || i == ESP_LOCAL_OBJ) { - continue; - } - if (variables[i].type != MPR_TYPE_OBJECT) { - continue; - } - np = mprGetFirstProperty(&variables[i], MPR_ENUM_DATA); - while (np) { - if (i == ESP_HEADERS_OBJ) { - mprSprintf(keyBuf, sizeof(keyBuf) - 1, "HTTP_%s", np->name); - mprSetProperty(global, keyBuf, np); - } else { - mprSetProperty(global, np->name, np); - } - np = mprGetNextProperty(&variables[i], np, MPR_ENUM_DATA); - } - } -#endif - return ep; -} - -/******************************************************************************/ - -void espDestroyRequest(EspRequest *ep) -{ - mprAssert(ep); - mprAssert(ep->eid >= 0); - - mprFree(ep->uri); - mprFree(ep->docPath); - ejsCloseEngine(ep->eid); - mprFree(ep); -} - -/******************************************************************************/ -/* - * The callback function will be called: - * - * (fn)(EjsId eid, EspRequest *ep, argc, argv); - * - * Callers can get their web server handle by calling: - * - * rq = (requiredCast) espGetHandle(ep); - */ - -void espDefineCFunction(EspRequest *ep, const char *functionName, EspCFunction fn, - void *thisPtr) -{ - mprAssert(functionName && *functionName); - mprAssert(fn); - - if (ep) { - ejsDefineCFunction(ep->eid, functionName, (MprCFunction) fn, - thisPtr, 0); - } else { - ejsDefineCFunction(-1, functionName, (MprCFunction) fn, thisPtr, 0); - } -} - -/******************************************************************************/ - -void espDefineStringCFunction(EspRequest *ep, const char *functionName, - EspStringCFunction fn, void *thisPtr) -{ - mprAssert(functionName && *functionName); - mprAssert(fn); - - if (ep) { - ejsDefineStringCFunction(ep->eid, functionName, (MprStringCFunction) fn, - thisPtr, 0); - } else { - ejsDefineStringCFunction(-1, functionName, (MprStringCFunction) fn, - thisPtr, 0); - } -} - -/******************************************************************************/ - -void *espGetRequestHandle(EspRequest *ep) -{ - return ep->requestHandle; -} - -/******************************************************************************/ - -EjsId espGetScriptHandle(EspRequest *ep) -{ - return ep->eid; -} - -/******************************************************************************/ - -char *espGetStringVar(EspRequest *ep, EspEnvType oType, char *var, - char *defaultValue) -{ - MprVar value; - - if (espGetVar(ep, oType, var, &value) < 0 || - value.type != MPR_TYPE_STRING) { - return defaultValue; - } - return value.string; -} - -/******************************************************************************/ - -int espGetVar(EspRequest *ep, EspEnvType oType, char *var, MprVar *value) -{ - MprVar *vp; - - mprAssert(ep); - mprAssert(var); - - vp = mprGetProperty(&ep->variables[oType], var, 0); - if (vp == 0) { - return -1; - } - *value = *vp; - return 0; -} - -/******************************************************************************/ -/* - * Process the ESP page. docBuf holds the page already. We expect that - * ep->variables holds all the pertinent environment variables. - */ - -int espProcessRequest(EspRequest *ep, const char *docPath, char *docBuf, - char **errMsg) -{ - char *jsBuf; - - mprAssert(ep); - - ep->docPath = mprStrdup(docPath); - - jsBuf = 0; - if (buildScript(ep, &jsBuf, docBuf, errMsg) < 0) { - return MPR_ERR_CANT_COMPLETE; - } - - if (jsBuf) { - mprLog(7, "esp: script is:\n%s\n", jsBuf); - - /* - * Now evaluate the entire escript - * MOB could cache the script - */ - if (ejsEvalScript(ep->eid, jsBuf, 0, errMsg) < 0) { - return MPR_ERR_ABORTED; - } - - mprFree(jsBuf); - } - return 0; -} - -/******************************************************************************/ - -void espRedirect(EspRequest *ep, int code, char *url) -{ - mprAssert(ep); - mprAssert(url); - - ep->esp->redirect(ep->requestHandle, code, url); -} - -/******************************************************************************/ - -void espError(EspRequest *ep, const char *fmt, ...) -{ - va_list args; - char *buf; - - mprAssert(ep); - mprAssert(fmt); - - va_start(args, fmt); - mprAllocVsprintf(&buf, MPR_MAX_HEAP_SIZE, fmt, args); - ejsSetErrorMsg(ep->eid, "%s", buf); - mprFree(buf); - va_end(args); -} - -/******************************************************************************/ - -void espSetHeader(EspRequest *ep, char *header, bool allowMultiple) -{ - mprAssert(ep); - - ep->esp->setHeader(ep->requestHandle, header, allowMultiple); -} - -/******************************************************************************/ -/* - * Caller does not need to destroy the var - */ - -MprVar *espGetResult(EspRequest *ep) -{ - mprAssert(ep); - - return ejsGetReturnValue(ep->eid); -} - -/******************************************************************************/ - -void espSetReturn(EspRequest *ep, MprVar value) -{ - mprAssert(ep); - - ejsSetReturnValue(ep->eid, value); -} - -/******************************************************************************/ - -void espSetReturnString(EspRequest *ep, const char *str) -{ - mprAssert(ep); - - ejsSetReturnValue(ep->eid, mprCreateStringVar(str, 0)); -} - -/******************************************************************************/ - -void espSetResponseCode(EspRequest *ep, int code) -{ - mprAssert(ep); - - ep->esp->setResponseCode(ep->requestHandle, code); -} - -/******************************************************************************/ - -void espSetVar(EspRequest *ep, EspEnvType oType, char *var, MprVar value) -{ - mprCreatePropertyValue(&ep->variables[oType], var, value); -} - -/******************************************************************************/ - -void espSetStringVar(EspRequest *ep, EspEnvType oType, - const char *var, const char *value) -{ - /* - * Will create or update if already existing - */ - mprCreatePropertyValue(&ep->variables[oType], var, - mprCreateStringVar(value, 0)); -} - -/******************************************************************************/ - -int espUnsetVar(EspRequest *ep, EspEnvType oType, char *var) -{ - return mprDeleteProperty(&ep->variables[oType], var); -} - -/******************************************************************************/ - -int espWrite(EspRequest *ep, char *buf, int size) -{ - mprAssert(ep); - mprAssert(buf); - mprAssert(size >= 0); - - return ep->esp->writeBlock(ep->requestHandle, buf, size); -} - -/******************************************************************************/ - -int espWriteString(EspRequest *ep, char *buf) -{ - mprAssert(ep); - mprAssert(buf); - - return ep->esp->writeBlock(ep->requestHandle, buf, strlen(buf)); -} - -/******************************************************************************/ - -int espWriteFmt(EspRequest *ep, char *fmt, ...) -{ - va_list args; - char *buf; - int rc, len; - - mprAssert(ep); - mprAssert(fmt); - - va_start(args, fmt); - len = mprAllocVsprintf(&buf, MPR_MAX_HEAP_SIZE, fmt, args); - rc = ep->esp->writeBlock(ep->requestHandle, buf, len); - mprFree(buf); - va_end(args); - return rc; -} - -/******************************************************************************/ -/******************************************************************************/ -/******************************************************************************/ -/* - * Get a javascript identifier. Must allow x.y['abc'] or x.y["abc"]. - * Must be careful about quoting and only allow quotes inside []. - */ - -static int getIdentifier(EspParse *parse) -{ - int atQuote, prevC, c; - - mprAssert(parse); - - atQuote = 0; - prevC = 0; - c = *parse->inp++; - - while (isalnum(c) || c == '_' || c == '.' || c == '[' || - c == ']' || c == '\'' || c == '\"') { - if (c == '\'' || c == '\"') { - if (c == atQuote) { - atQuote = 0; - } else if (prevC == '[') { - atQuote = c; - } else { - break; - } - } - if (parse->tokp >= parse->endp) { - parse->token = (char*) mprRealloc(parse->token, - parse->tokLen + ESP_TOK_INCR); - if (parse->token == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - parse->token[parse->tokLen] = '\0'; - parse->tokLen += ESP_TOK_INCR; - parse->endp = &parse->token[parse->tokLen - 1]; - } - *parse->tokp++ = c; - prevC = c; - c = *parse->inp++; - } - - parse->inp--; - *parse->tokp = '\0'; - - return 0; -} - -/******************************************************************************/ -/* - * Get the next ESP input token. input points to the next input token. - * parse->token will hold the parsed token. The function returns the token id. - */ - -static int getEspToken(int state, EspParse *parse) -{ - char *cp; - int tid, done, c, quoted; - - tid = ESP_TOK_LITERAL; - parse->tokp = parse->token; - parse->tokp[0] = '\0'; - quoted = 0; - - c = *parse->inp++; - for (done = 0; !done; c = *parse->inp++) { - - /* - * Get room for more characters in the token buffer - */ - if (parse->tokp >= parse->endp) { - parse->token = (char*) mprRealloc(parse->token, - parse->tokLen + ESP_TOK_INCR); - if (parse->token == 0) { - return ESP_TOK_ERR; - } - parse->token[parse->tokLen] = '\0'; - parse->tokp = &parse->token[parse->tokLen - 1]; - parse->tokLen += ESP_TOK_INCR; - parse->endp = &parse->token[parse->tokLen - 1]; - } - - switch (c) { - case 0: - if (*parse->token) { - done++; - parse->inp--; - break; - } - return ESP_TOK_EOF; - - default: - if (c == '\"' && state != ESP_STATE_IN_ESP_TAG) { - *parse->tokp++ = '\\'; - } - *parse->tokp++ = c; - quoted = 0; - break; - - case '\\': - quoted = 1; - *parse->tokp++ = c; - break; - - case '@': - if (*parse->inp == '@' && state != ESP_STATE_IN_ESP_TAG) { - if (quoted) { - parse->tokp--; - quoted = 0; - } else { - if (*parse->token) { - parse->inp--; - } else { - parse->inp++; - tid = ESP_TOK_ATAT; - if (getIdentifier(parse) < 0) { - return ESP_TOK_ERR; - } - } - done++; - break; - } - } - *parse->tokp++ = c; - break; - - case '<': - if (*parse->inp == '%' && state != ESP_STATE_IN_ESP_TAG) { - if (quoted) { - parse->tokp--; - quoted = 0; - *parse->tokp++ = c; - break; - } - if (*parse->token) { - parse->inp--; - done++; - break; - } - parse->inp++; - while (isspace((int) *parse->inp)) { - parse->inp++; - } - if (*parse->inp == '=') { - parse->inp++; - while (isspace((int) *parse->inp)) { - parse->inp++; - } - tid = ESP_TOK_EQUALS; - if (getIdentifier(parse) < 0) { - return ESP_TOK_ERR; - } - done++; - break; - } - if (*parse->inp == 'i' && - strncmp(parse->inp, "include", 7) == 0 && - isspace((int) parse->inp[7])) { - tid = ESP_TOK_INCLUDE; - parse->inp += 7; - while (isspace((int) *parse->inp)) { - parse->inp++; - } - while (*parse->inp && !isspace((int) *parse->inp) && - *parse->inp != '%' && parse->tokp < parse->endp) { - *parse->tokp++ = *parse->inp++; - } - *parse->tokp = '\0'; - if (parse->token[0] == '"') { - parse->tokp = parse->token; - for (cp = &parse->token[1]; *cp; ) { - *parse->tokp++ = *cp++; - } - if (cp[-1] == '"') { - parse->tokp--; - } - *parse->tokp = '\0'; - } - - } else { - tid = ESP_TOK_START_ESP; - } - done++; - break; - } - *parse->tokp++ = c; - break; - - case '%': - if (*parse->inp == '>' && state == ESP_STATE_IN_ESP_TAG) { - if (quoted) { - parse->tokp--; - quoted = 0; - } else { - if (*parse->token) { - parse->inp--; - } else { - tid = ESP_TOK_END_ESP; - parse->inp++; - } - done++; - break; - } - } - *parse->tokp++ = c; - break; - } - } - - *parse->tokp = '\0'; - parse->inp--; - return tid; -} - -/******************************************************************************/ -/* - * Convert an ESP page into a JavaScript. We also expand include files. - */ - -static int buildScript(EspRequest *ep, char **jsBuf, char *input, char **errMsg) -{ - EspParse parse; - char path[MPR_MAX_FNAME], dir[MPR_MAX_FNAME], incPath[MPR_MAX_FNAME]; - char *incBuf, *incText; - int state, tid, len, rc, maxScriptSize, incSize; - - mprAssert(ep); - mprAssert(jsBuf); - mprAssert(input); - - rc = 0; - len = 0; - state = ESP_STATE_BEGIN; - if (errMsg) { - *errMsg = 0; - } - - memset(&parse, 0, sizeof(parse)); - parse.token = (char*) mprMalloc(ESP_TOK_INCR); - if (parse.token == 0) { - return MPR_ERR_CANT_ALLOCATE; - } - parse.token[0] = '\0'; - parse.tokLen = ESP_TOK_INCR; - parse.endp = &parse.token[parse.tokLen - 1]; - parse.tokp = parse.token; - parse.inBuf = input; - parse.inp = parse.inBuf; - - maxScriptSize = esp->maxScriptSize; - - tid = getEspToken(state, &parse); - while (tid != ESP_TOK_EOF && len >= 0) { - - switch (tid) { - default: - case ESP_TOK_ERR: - mprFree(parse.token); - return MPR_ERR_BAD_SYNTAX; - - case ESP_TOK_LITERAL: - len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0, - "write(\"", parse.token, "\");\n", NULL); - break; - - case ESP_TOK_ATAT: - /* - * Trick to get undefined variables to evaluate to "". - * Catenate with "" to cause toString to run. - */ - len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0, - "write(\"\" + ", parse.token, ");\n", NULL); - break; - - case ESP_TOK_EQUALS: - len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0, - "write(\"\" + ", parse.token, ");\n", NULL); - state = ESP_STATE_IN_ESP_TAG; - break; - - case ESP_TOK_START_ESP: - state = ESP_STATE_IN_ESP_TAG; - tid = getEspToken(state, &parse); - while (tid != ESP_TOK_EOF && tid != ESP_TOK_EOF && - tid != ESP_TOK_END_ESP && len >= 0) { - len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0, - parse.token, NULL); - tid = getEspToken(state, &parse); - } - state = ESP_STATE_BEGIN; - break; - - case ESP_TOK_END_ESP: - state = ESP_STATE_BEGIN; - break; - - case ESP_TOK_INCLUDE: - if (parse.token[0] == '/') { - mprStrcpy(incPath, sizeof(incPath), parse.token); - } else { - mprGetDirName(dir, sizeof(dir), ep->uri); - mprSprintf(incPath, sizeof(incPath), "%s/%s", - dir, parse.token); - } - if (esp->mapToStorage(ep->requestHandle, path, sizeof(path), - incPath, 0) < 0) { - mprAllocSprintf(errMsg, MPR_MAX_STRING, - "Can't find include file: %s", path); - rc = MPR_ERR_CANT_OPEN; - break; - } - if (esp->readFile(ep->requestHandle, &incText, &incSize, path) < 0){ - mprAllocSprintf(errMsg, MPR_MAX_STRING, - "Can't read include file: %s", path); - rc = MPR_ERR_CANT_READ; - break; - } - incText[incSize] = '\0'; - - /* - * Recurse and process the include script - */ - incBuf = 0; - if ((rc = buildScript(ep, &incBuf, incText, errMsg)) < 0) { - mprFree(incText); - mprFree(parse.token); - return rc; - } - - len = mprReallocStrcat(jsBuf, maxScriptSize, len, 0, incBuf, NULL); - mprFree(incText); - mprFree(incBuf); - state = ESP_STATE_IN_ESP_TAG; - break; - } - tid = getEspToken(state, &parse); - } - mprFree(parse.token); - if (len < 0) { - mprAllocSprintf(errMsg, MPR_MAX_STRING, - "Script token is too big in %s.\nConfigured maximum is %d.", - path, maxScriptSize); - return MPR_ERR_WONT_FIT; - } - return rc; -} - -/******************************************************************************/ -/******************************* Wrapped Routines *****************************/ -/******************************************************************************/ - -int espCopyVar(EspRequest *ep, char *var, MprVar *value, int copyDepth) -{ - return ejsCopyVar(ep->eid, var, value, copyDepth); -} - -/******************************************************************************/ - -MprVar espCreateObjVar(char *name, int hashSize) -{ - return ejsCreateObj(name, hashSize); -} - -/******************************************************************************/ - -MprVar espCreateArrayVar(char *name, int size) -{ - return ejsCreateArray(name, size); -} - -/******************************************************************************/ - -bool espDestroyVar(MprVar *obj) -{ - return ejsDestroyVar(obj); -} - -/******************************************************************************/ - -MprVar *espCreateProperty(MprVar *obj, char *property, MprVar *newValue) -{ - return mprCreateProperty(obj, property, newValue); -} - -/******************************************************************************/ - -MprVar *espCreatePropertyValue(MprVar *obj, char *property, MprVar newValue) -{ - return mprCreatePropertyValue(obj, property, newValue); -} - -/******************************************************************************/ - -void espDefineFunction(EspRequest *ep, const char *functionName, char *args, char *body) -{ - ejsDefineFunction(ep->eid, functionName, args, body); -} - -/******************************************************************************/ - -int espDeleteProperty(MprVar *obj, char *property) -{ - return mprDeleteProperty(obj, property); -} - -/******************************************************************************/ - -int espDeleteVar(EspRequest *ep, char *var) -{ - return ejsDeleteVar(ep->eid, var); -} - -/******************************************************************************/ -int espEvalFile(EspRequest *ep, char *path, MprVar *result, char **emsg) -{ - return ejsEvalFile(ep->eid, path, result, emsg); -} - -/******************************************************************************/ - -int espEvalScript(EspRequest *ep, char *script, MprVar *result, char **emsg) -{ - return ejsEvalScript(ep->eid, script, result, emsg); -} - -/******************************************************************************/ - -int espGetPropertyCount(MprVar *obj, int includeFlags) -{ - if (obj->type != MPR_TYPE_OBJECT) { - return MPR_ERR_BAD_STATE; - } - return mprGetPropertyCount(obj, includeFlags); -} - -/******************************************************************************/ - -MprVar *espGetFirstProperty(MprVar *obj, int includeFlags) -{ - return mprGetFirstProperty(obj, includeFlags); -} - -/******************************************************************************/ - -MprVar *espGetGlobalObject(EspRequest *ep) -{ - return ejsGetGlobalObject(ep->eid); -} - -/******************************************************************************/ - -MprVar *espGetLocalObject(EspRequest *ep) -{ - return ejsGetLocalObject(ep->eid); -} - -/******************************************************************************/ - -MprVar *espGetNextProperty(MprVar *obj, MprVar *currentProperty, - int includeFlags) -{ - return mprGetNextProperty(obj, currentProperty, includeFlags); -} - -/******************************************************************************/ - -MprVar *espGetProperty(MprVar *obj, char *property, MprVar *value) -{ - return mprGetProperty(obj, property, value); -} - -/******************************************************************************/ - -void *espGetThisPtr(EspRequest *ep) -{ - return ejsGetThisPtr(ep->eid); -} - -/******************************************************************************/ -#if XX_UNUSED_XX - -int espReadProperty(MprVar *dest, MprVar *prop) -{ - mprAssert(prop); - mprAssert(dest); - - *dest = *prop; - return 0; -} - -#endif -/******************************************************************************/ - -int espReadVar(EspRequest *ep, char *var, MprVar *value) -{ - return ejsReadVar(ep->eid, var, value); -} - -/******************************************************************************/ - -int espRunFunction(EspRequest *ep, MprVar *obj, char *functionName, - MprArray *args) -{ - return ejsRunFunction(ep->eid, obj, functionName, args); -} - -/******************************************************************************/ - -MprVar *espSetProperty(MprVar *obj, char *property, MprVar *newValue) -{ - return mprSetProperty(obj, property, newValue); -} - -/******************************************************************************/ - -MprVar *espSetPropertyValue(MprVar *obj, char *property, MprVar newValue) -{ - return mprSetPropertyValue(obj, property, newValue); -} - -/******************************************************************************/ - -int espWriteVar(EspRequest *ep, char *var, MprVar *value) -{ - return ejsWriteVar(ep->eid, var, value); -} - -/******************************************************************************/ - -int espWriteVarValue(EspRequest *ep, char *var, MprVar value) -{ - return ejsWriteVarValue(ep->eid, var, value); -} - -/******************************************************************************/ -#if XX_UNUSED_XX - -int espWriteProperty(MprVar *prop, MprVar *newValue) -{ - return mprWriteProperty(prop, newValue); -} - -/******************************************************************************/ - -int espWritePropertyValue(MprVar *prop, MprVar newValue) -{ - return mprWritePropertyValue(prop, newValue); -} - -#endif -/******************************************************************************/ - -#else /* !BLD_FEATURE_ESP_MODULE */ -void espDummy() {} - -/******************************************************************************/ -#endif /* BLD_FEATURE_ESP_MODULE */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/esp/esp.h b/source4/lib/appweb/esp/esp.h deleted file mode 100644 index 3d9b7bf8dc..0000000000 --- a/source4/lib/appweb/esp/esp.h +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @file esp.h - * @brief Header for Embedded Server Pages (ESP) - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#ifndef _h_ESP_h -#define _h_ESP_h 1 - -#include "lib/appweb/ejs/ejs.h" -#include "lib/appweb/esp/espEnv.h" -#include "lib/appweb/mpr/var.h" -#include "lib/appweb/mpr/miniMpr.h" - -/*********************************** Defines **********************************/ - -#if BLD_FEATURE_SQUEEZE -#define ESP_TOK_INCR 1024 -#define ESP_MAX_HEADER 1024 -#else -#define ESP_TOK_INCR 4096 -#define ESP_MAX_HEADER 4096 -#endif - -/* - * ESP lexical analyser tokens - */ -#define ESP_TOK_ERR -1 /* Any input error */ -#define ESP_TOK_EOF 0 /* End of file */ -#define ESP_TOK_START_ESP 1 /* <% */ -#define ESP_TOK_END_ESP 2 /* %> */ -#define ESP_TOK_ATAT 3 /* @@var */ -#define ESP_TOK_LITERAL 4 /* literal HTML */ -#define ESP_TOK_INCLUDE 5 /* include file.esp */ -#define ESP_TOK_EQUALS 6 /* = var */ - -/* - * ESP parser states - */ -#define ESP_STATE_BEGIN 1 /* Starting state */ -#define ESP_STATE_IN_ESP_TAG 2 /* Inside a <% %> group */ - -/*********************************** Types ************************************/ - -typedef void* EspHandle; /* Opaque Web server handle type */ - -/* - * Per request control block - */ -typedef struct EspRequest { - MprStr docPath; /* Physical path for ESP page */ - EjsId eid; /* EJS instance handle */ - const struct Esp *esp; /* Pointer to ESP control block */ - EspHandle requestHandle; /* Per request web server handle */ - MprStr uri; /* Request URI */ - MprVar *variables; /* Pointer to variables */ -} EspRequest; - -/* - * Master ESP control block. This defines the function callbacks for a - * web server handler to implement. ESP will call these functions as - * required. - */ -typedef struct Esp { - int maxScriptSize; - void (*createSession)(EspHandle handle, int timeout); - void (*destroySession)(EspHandle handle); - const char *(*getSessionId)(EspHandle handle); - int (*mapToStorage)(EspHandle handle, char *path, int len, const char *uri, - int flags); - int (*readFile)(EspHandle handle, char **buf, int *len, const char *path); - void (*redirect)(EspHandle handle, int code, char *url); - void (*setCookie)(EspHandle handle, const char *name, const char *value, - int lifetime, const char *path, bool secure); - void (*setHeader)(EspHandle handle, const char *value, bool allowMultiple); - void (*setResponseCode)(EspHandle handle, int code); - int (*writeBlock)(EspHandle handle, const char *buf, int size); - int (*writeFmt)(EspHandle handle, char *fmt, ...); -#if BLD_FEATURE_MULTITHREAD - void (*lock)(void *lockData); - void (*unlock)(void *lockData); - void *lockData; -#endif -} Esp; - - -/* - * ESP parse context - */ -typedef struct { - char *inBuf; /* Input data to parse */ - char *inp; /* Next character for input */ - char *endp; /* End of storage (allow for null) */ - char *tokp; /* Pointer to current parsed token */ - char *token; /* Storage buffer for token */ - int tokLen; /* Length of buffer */ -} EspParse; - - -/******************************** Private APIs ********************************/ - -extern void espRegisterProcs(void); - -/******************************** Published API *******************************/ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Function callback signatures - */ -typedef int (*EspCFunction)(EspRequest *ep, int argc, - struct MprVar **argv); -typedef int (*EspStringCFunction)(EspRequest *ep, int argc, - char **argv); - -/* - * APIs for those hosting the ESP module - */ -extern int espOpen(const Esp *control); -extern void espClose(void); -extern EspRequest *espCreateRequest(EspHandle webServerRequestHandle, - char *uri, MprVar *envObj); -extern void espDestroyRequest(EspRequest *ep); -extern int espProcessRequest(EspRequest *ep, const char *docPath, - char *docBuf, char **errMsg); - -/* - * Method invocation - */ -extern void espDefineCFunction(EspRequest *ep, const char *functionName, - EspCFunction fn, void *thisPtr); -extern void espDefineFunction(EspRequest *ep, const char *functionName, - char *args, char *body); -extern void espDefineStringCFunction(EspRequest *ep, - const char *functionName, EspStringCFunction fn, - void *thisPtr); -extern int espRunFunction(EspRequest *ep, MprVar *obj, - char *functionName, MprArray *args); -extern void espSetResponseCode(EspRequest *ep, int code); -extern void espSetReturn(EspRequest *ep, MprVar value); -extern void *espGetThisPtr(EspRequest *ep); - -/* - * Utility routines to use in C methods - */ -extern void espError(EspRequest *ep, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -extern int espEvalFile(EspRequest *ep, char *path, MprVar *result, - char **emsg); -extern int espEvalScript(EspRequest *ep, char *script, MprVar *result, - char **emsg); -extern MprVar *espGetLocalObject(EspRequest *ep); -extern MprVar *espGetGlobalObject(EspRequest *ep); -extern EspHandle espGetRequestHandle(EspRequest *ep); -extern MprVar *espGetResult(EspRequest *ep); -extern EjsId espGetScriptHandle(EspRequest *ep); -extern void espRedirect(EspRequest *ep, int code, char *url); -extern void espSetHeader(EspRequest *ep, char *header, - bool allowMultiple); -extern void espSetReturnString(EspRequest *ep, const char *str); -extern int espWrite(EspRequest *ep, char *buf, int size); -extern int espWriteString(EspRequest *ep, char *buf); -extern int espWriteFmt(EspRequest *ep, char *fmt, ...) PRINTF_ATTRIBUTE(2,3); - -/* - * ESP array[] variable access (set will update/create) - */ -extern int espGetVar(EspRequest *ep, EspEnvType oType, char *var, - MprVar *value); -extern char *espGetStringVar(EspRequest *ep, EspEnvType oType, - char *var, char *defaultValue); -extern void espSetVar(EspRequest *ep, EspEnvType oType, char *var, - MprVar value); -extern void espSetStringVar(EspRequest *ep, EspEnvType oType, - const char *var, const char *value); -extern int espUnsetVar(EspRequest *ep, EspEnvType oType, char *var); - -/* - * Object creation and management - */ -extern MprVar espCreateObjVar(char *name, int hashSize); -extern MprVar espCreateArrayVar(char *name, int size); -extern bool espDestroyVar(MprVar *var); -extern MprVar *espCreateProperty(MprVar *obj, char *property, - MprVar *newValue); -extern MprVar *espCreatePropertyValue(MprVar *obj, char *property, - MprVar newValue); -extern int espDeleteProperty(MprVar *obj, char *property); - -/* - * JavaScript variable management. Set will create/update a property. - * All return a property reference. GetProperty will optionally return the - * property in value. - */ -extern MprVar *espGetProperty(MprVar *obj, char *property, - MprVar *value); -extern MprVar *espSetProperty(MprVar *obj, char *property, - MprVar *newValue); -extern MprVar *espSetPropertyValue(MprVar *obj, char *property, - MprVar newValue); - -#if 0 -/* - * Low-level direct read and write of properties. - * FUTURE: -- Read is not (dest, src). MUST WARN IN DOC ABOUT COPY/READ - * Will still cause triggers to run. - */ -extern int espReadProperty(MprVar *dest, MprVar *prop); -extern int espWriteProperty(MprVar *prop, MprVar *newValue); -extern int espWritePropertyValue(MprVar *prop, MprVar newValue); -#endif - - -/* - * Access JavaScript variables by their full name. Can use "." or "[]". For - * example: "global.request['REQUEST_URI']" - * For Read/write, the variables must exist. - */ -extern int espCopyVar(EspRequest *ep, char *var, MprVar *value, - int copyDepth); -extern int espDeleteVar(EspRequest *ep, char *var); -extern int espReadVar(EspRequest *ep, char *var, MprVar *value); -extern int espWriteVar(EspRequest *ep, char *var, MprVar *value); -extern int espWriteVarValue(EspRequest *ep, char *var, MprVar value); - -/* - * Object property enumeration - */ -extern MprVar *espGetFirstProperty(MprVar *obj, int includeFlags); -extern MprVar *espGetNextProperty(MprVar *obj, MprVar *currentProperty, - int includeFlags); -extern int espGetPropertyCount(MprVar *obj, int includeFlags); - -#ifdef __cplusplus -} -#endif -/******************************************************************************/ -#endif /* _h_ESP_h */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/esp/espEnv.h b/source4/lib/appweb/esp/espEnv.h deleted file mode 100644 index a3c9d9f5c7..0000000000 --- a/source4/lib/appweb/esp/espEnv.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * @file espEnv.h - * @brief ESP Environment Variables - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/******************************************************************************/ - -#ifndef _h_ESP_ENV_h -#define _h_ESP_ENV_h 1 - -/* - * @brief Scripting environment variable array types - */ -typedef enum EspEnvType { - ESP_UNDEFINED_OBJ = -1, - - /** - * Elements for server[]: - * DOCUMENT_ROOT GATEWAY_INTERFACE SERVER_ADDR SERVER_PORT SERVER_NAME - * SERVER_PROTOCOL SERVER_SOFTWARE SERVER_URL UPLOAD_DIR - * FUTURE: SERVER_ADMIN - * FUTURE: this could be shared across all hosts and be made read-only. - */ - ESP_SERVER_OBJ = 0, /*! server[] data */ - - /** - * Elements for session[]: are user defined - */ - ESP_SESSION_OBJ = 1, /*! session[] data */ - - /** - * Elements for request[]: - * AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE QUERY_STRING PATH_INFO - * PATH_TRANSLATED REMOTE_ADDR REMOTE_HOST REMOTE_USER REQUEST_METHOD - * REQUEST_URI SCRIPT_FILENAME SCRIPT_NAME - * FUTURE: FILEPATH_INFO REDIRECT_URL SELF REMOTE_PORT AUTH_USER - * AUTH_GROUP AUTH_ACL - */ - ESP_REQUEST_OBJ = 2, /*! request[] data */ - - /** - * Elements for headers[]: - * HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_CONNECTION HTTP_HOST - * HTTP_REFERER HTTP_USER_AGENT and any other custom headers - */ - ESP_HEADERS_OBJ = 3, /*! header [] data */ - - /** - * Elements for cookies[]: are defined by the HTTP request - */ - ESP_COOKIES_OBJ = 4, /*! cookies[] data */ - - /** - * Elements for files[]: are defined by the HTTP request - * CLIENT_FILENAME CONTENT_TYPE FILENAME SIZE - */ - ESP_FILES_OBJ = 5, /*! files[] data */ - - /** - * Elements for form[]: are defined by the HTTP request - */ - ESP_FORM_OBJ = 6, /*! form[] data */ - - /** - * Elements for application[]: are user defined - */ - ESP_APPLICATION_OBJ = 7, /*! application[] data */ - - /** - * Elements for global[]: are defined by ESP/EJS - */ - ESP_GLOBAL_OBJ = 8, /*! global [] data */ - - /* - * Elements for local[]: are defined by ESP/EJS - */ - ESP_LOCAL_OBJ = 9, /*! local [] data */ -} EspEnvType; - -#define ESP_OBJ_MAX 10 /* Total objects */ - -#if BLD_SQUEEZE -#define ESP_HASH_SIZE 19 /* Size of hash tables */ -#else -#define ESP_HASH_SIZE 37 -#endif - -/******************************************************************************/ -#endif /* _h_ESP_ENV_h */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/esp/espProcs.c b/source4/lib/appweb/esp/espProcs.c deleted file mode 100644 index 7b5dfe680e..0000000000 --- a/source4/lib/appweb/esp/espProcs.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * @file espProcs.c - * @brief Embedded Server Pages (ESP) Procedures. - * @overview These ESP procedures can be used in ESP pages for common tasks. - */ -/********************************* Copyright **********************************/ -/* - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -/********************************** Includes **********************************/ - -#include "esp.h" - -/************************************ Code ************************************/ -#if BLD_FEATURE_ESP_MODULE -#if BLD_FEATURE_SESSION -/* - * destroySession - */ - -static int destroySessionProc(EspRequest *ep, int argc, char **argv) -{ - ep->esp->destroySession(ep->requestHandle); - return 0; -} - -#endif /* BLD_FEATURE_SESSION */ - -/******************************************************************************/ -/* - * include - * - * This includes javascript libraries. For example: - * - * <% include("file", ...); %> - * - * Don't confuse with ESP includes: - * - * <% include file.esp %> - * - * Filenames are relative to the base document including the file. - * FUTURE -- move back to EJS. Only here now because we need ep->readFile. - */ - -static int includeProc(EspRequest *ep, int argc, char **argv) -{ - const Esp *esp; - char path[MPR_MAX_FNAME], dir[MPR_MAX_FNAME]; - char *emsg=NULL, *buf; - int size, i; - - esp = ep->esp; - mprAssert(argv); - for (i = 0; i < argc; i++) { - const char *extension; - - if (argv[i][0] != '/') { - mprGetDirName(dir, sizeof(dir), ep->docPath); - mprSprintf(path, sizeof(path), "%s/%s", dir, argv[i]); - } else { - mprSprintf(path, sizeof(path), "%s", argv[i]); - } - - if (esp->readFile(ep->requestHandle, &buf, &size, path) < 0) { - espError(ep, "Can't read include file: %s", path); - return MPR_ERR_CANT_ACCESS; - } - buf[size] = '\0'; - - extension = strrchr(argv[i], '.'); - - /* - * Allow nested inclusion of ESP requests - */ - if (extension && mprStrCmpAnyCase(extension, ".esp") == 0) { - if (espProcessRequest(ep, path, buf, &emsg) != 0) { - espError(ep, "Cant evaluate script - %s", emsg?emsg:""); - mprFree(buf); - return -1; - } - } else { - if (ejsEvalScript(espGetScriptHandle(ep), buf, 0, &emsg) < 0) { - espError(ep, "Cant evaluate script - %s", emsg?emsg:""); - mprFree(buf); - return -1; - } - } - mprFree(buf); - } - return 0; -} - -/******************************************************************************/ -/* - * redirect - * - * This implemements <% redirect(url, code); %> command. The redirection - * code is optional. - */ - -static int redirectProc(EspRequest *ep, int argc, char **argv) -{ - char *url; - int code; - - if (argc < 1) { - espError(ep, "Bad args"); - return MPR_ERR_BAD_ARGS; - } - url = argv[0]; - if (argc == 2) { - code = atoi(argv[1]); - } else { - code = 302; - } - espRedirect(ep, code, url); - return 0; -} - -/******************************************************************************/ -#if BLD_FEATURE_SESSION -/* - * useSession - */ - -static int useSessionProc(EspRequest *ep, int argc, char **argv) -{ - int timeout; - - if (argc > 1) { - espError(ep, "Bad args"); - return MPR_ERR_BAD_ARGS; - - } else if (argc == 1) { - timeout = atoi(argv[0]); - } else { - timeout = 0; - } - - ep->esp->createSession(ep->requestHandle, timeout); - espSetReturnString(ep, ep->esp->getSessionId(ep->requestHandle)); - return 0; -} - -#endif /* BLD_FEATURE_SESSION */ -/******************************************************************************/ -/* - * setHeader - * - * This implemements <% setHeader("key: value", allowMultiple); %> command. - */ - -static int setHeaderProc(EspRequest *ep, int argc, char **argv) -{ - mprAssert(argv); - if (argc != 2) { - espError(ep, "Bad args"); - return MPR_ERR_BAD_ARGS; - } - ep->esp->setHeader(ep->requestHandle, argv[0], atoi(argv[1])); - return 0; -} - -/******************************************************************************/ -/* - * write - * - * This implemements <% write("text"); %> command. - */ - -static int writeProc(EspRequest *ep, int argc, char **argv) -{ - char *s; - int i, len; - - mprAssert(argv); - for (i = 0; i < argc; i++) { - s = argv[i]; - len = strlen(s); - if (len > 0) { - if (espWrite(ep, s, len) != len) { - espError(ep, "Can't write to client"); - return -1; - } - } - } - return 0; -} - -/******************************************************************************/ - -void espRegisterProcs() -{ - espDefineStringCFunction(0, "write", writeProc, 0); - espDefineStringCFunction(0, "setHeader", setHeaderProc, 0); - espDefineStringCFunction(0, "redirect", redirectProc, 0); - espDefineStringCFunction(0, "include", includeProc, 0); - -#if BLD_FEATURE_SESSION - /* - * Create and use are synonomous - */ - espDefineStringCFunction(0, "useSession", useSessionProc, 0); - espDefineStringCFunction(0, "createSession", useSessionProc, 0); - espDefineStringCFunction(0, "destroySession", destroySessionProc, 0); -#endif -} - -/******************************************************************************/ - -#else -void mprEspControlsDummy() {} - -#endif /* BLD_FEATURE_ESP_MODULE */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/mpr/miniMpr.c b/source4/lib/appweb/mpr/miniMpr.c deleted file mode 100644 index 381815eb23..0000000000 --- a/source4/lib/appweb/mpr/miniMpr.c +++ /dev/null @@ -1,522 +0,0 @@ -/* - * @file miniMpr.cpp - * @brief Mini Mbedthis Portable Runtime (MPR) - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -#include "miniMpr.h" -#include "param/param.h" -#include "lib/events/events.h" - -/************************************ Code ************************************/ -#if !BLD_APPWEB -#if !BLD_GOAHEAD_WEBSERVER - -static void *mpr_ctx; - -/* set the memory context to be used for all ejs variables */ -void mprSetCtx(TALLOC_CTX *ctx) -{ - mpr_ctx = ctx; -} - -/* return the memory context being used for all ejs variables */ -void *mprMemCtx(void) -{ - return mpr_ctx; -} - -struct event_context *mprEventCtx(void) -{ - return event_context_find(mprMemCtx()); -} - -/* return the loadparm context being used for all ejs variables */ -struct loadparm_context *mprLpCtx(void) -{ - return global_loadparm; -} - -void mprFree(void *ptr) -{ - talloc_free(ptr); -} - -void *mprMalloc(uint size) -{ - return talloc_size(mpr_ctx, size); -} - -/******************************************************************************/ - -void *mprRealloc(void *ptr, uint size) -{ - return talloc_realloc_size(mpr_ctx, ptr, size); -} - -/******************************************************************************/ - -char *mprStrdup(const char *str) -{ - if (str == 0) { - str = ""; - } - return talloc_strdup(mpr_ctx, str); -} - -/*****************************************************************************/ - -int mprAllocSprintf(char **msgbuf, int maxSize, const char *fmt, ...) -{ - va_list args; - char *buf; - int count; - - va_start(args, fmt); - buf = mprMalloc(maxSize + 1); - count = mtVsprintf(buf, maxSize, fmt, args); - *msgbuf = buf; - va_end(args); - return count; -} - -/*****************************************************************************/ - -int mprAllocVsprintf(char **msgbuf, int maxSize, const char *fmt, va_list args) -{ - char *buf; - int count; - - buf = mprMalloc(maxSize + 1); - count = mtVsprintf(buf, maxSize, fmt, args); - *msgbuf = buf; - return count; -} - - -/*****************************************************************************/ -/* - * Format a number as a string. FUTURE -- reverse args to be standard. - * ie. mprItoa(char *userBuf, int bufsize, int value); - */ - -char *mprItoa(int value, char *buf, int width) -{ - char numBuf[16]; - char *cp, *dp, *endp; - int negative; - - cp = &numBuf[sizeof(numBuf)]; - *--cp = '\0'; - - if (value < 0) { - negative = 1; - value = -value; - width--; - } else { - negative = 0; - } - - do { - *--cp = '0' + (value % 10); - value /= 10; - } while (value > 0); - - if (negative) { - *--cp = '-'; - } - - dp = buf; - endp = &buf[width]; - while (dp < endp && *cp) { - *dp++ = *cp++; - } - *dp++ = '\0'; - return buf; -} - -/*****************************************************************************/ - -void mprLog(int level, const char *fmt, ...) -{ - va_list args; - char *buf; - - if (DEBUGLVL(level)) { - va_start(args, fmt); - mprAllocVsprintf(&buf, MPR_MAX_STRING, fmt, args); - va_end(args); - DEBUG(level, ("mprLog: %s", buf)); - mprFree(buf); - } -} - -/*****************************************************************************/ - -void mprBreakpoint(const char *file, int line, const char *cond) -{ - char *buf; - mprAllocSprintf(&buf, MPR_MAX_STRING, "esp exception - ASSERT at %s:%d, %s\n", - file, line, cond); - ejs_exception(buf); -} - -#endif /* !BLD_GOAHEAD_WEBSERVER */ -/*****************************************************************************/ -/* - * Create a general growable array structure - */ - -MprArray *mprCreateArray() -{ - MprArray *array; - int size; - - array = (MprArray*) mprMalloc(sizeof(MprArray)); - if (array == 0) { - return 0; - } - memset(array, 0, sizeof(MprArray)); - - size = MPR_ARRAY_INCR * sizeof(void*); - array->handles = (void**) mprMalloc(size); - if (array->handles == 0) { - mprFree(array); - return 0; - } - memset(array->handles, 0, size); - array->max = MPR_ARRAY_INCR; - array->used = 0; - return array; -} - -/*****************************************************************************/ -/* - * Dispose of the array. Callers responsibility to dispose of handle entries. - */ - -void mprDestroyArray(MprArray *array) -{ - mprAssert(array); - mprAssert(array->max >= 0); - mprAssert(array->used >= 0); - - mprFree(array->handles); - mprFree(array); -} - -/*****************************************************************************/ -/* - * Add an item to the array - */ - -int mprAddToArray(MprArray *array, void *item) -{ - int memsize, idx, len; - - mprAssert(array); - mprAssert(array->max >= 0); - mprAssert(array->used >= 0); - - if (array->used < array->max) { - idx = array->used++; - mprAssert(idx >= 0 && idx < array->max); - mprAssert(array->handles[idx] == 0); - array->handles[idx] = item; - return idx; - } - - for (idx = array->used; idx < array->max; idx++) { - if (array->handles[idx] == 0) { - array->used++; - mprAssert(array->handles[idx] == 0); - array->handles[idx] = item; - return idx; - } - } - - len = array->max + MPR_ARRAY_INCR; - memsize = len * sizeof(void*); - array->handles = (void**) mprRealloc((void*) array->handles, memsize); - if (array->handles == NULL) { - return -1; - } - memset(&array->handles[array->max], 0, sizeof(void*) * MPR_ARRAY_INCR); - array->max = len; - array->used++; - - mprAssert(idx >= 0 && idx < array->max); - mprAssert(array->handles[idx] == 0); - - array->handles[idx] = item; - return idx; -} - -/*****************************************************************************/ -/* - * Remove from the array - */ - -int mprRemoveFromArray(MprArray *array, int idx) -{ - mprAssert(array); - mprAssert(array->max > 0); - mprAssert(idx >= 0 && idx < array->max); - mprAssert(array->handles[idx] != 0); - mprAssert(array->used > 0); - - array->handles[idx] = 0; - return --array->used; -} - -/*****************************************************************************/ -/* - * Thread-safe wrapping of strtok. Note "str" is modifed as per strtok() - */ - -char *mprStrTok(char *str, const char *delim, char **tok) -{ - char *start, *end; - int i; - - start = str ? str : *tok; - - if (start == 0) { - return 0; - } - - i = strspn(start, delim); - start += i; - if (*start == '\0') { - *tok = 0; - return 0; - } - end = strpbrk(start, delim); - if (end) { - *end++ = '\0'; - i = strspn(end, delim); - end += i; - } - *tok = end; - return start; -} - -/*****************************************************************************/ - -static int mprCoreStrcat(int alloc, char **destp, int destMax, int existingLen, - const char *delim, const char *src, va_list args) -{ - va_list ap; - char *dest, *dp; - const char *str; - int sepLen, addBytes, required; - - mprAssert(destp); - mprAssert(destMax > 0); - mprAssert(src); - - dest = *destp; - sepLen = (delim) ? strlen(delim) : 0; - - va_copy(ap, args); - addBytes = 0; - str = src; - while (str) { - addBytes += strlen(str) + sepLen; - str = va_arg(ap, const char*); - } - va_end(ap); - - if (existingLen > 0) { - addBytes += sepLen; - } - required = existingLen + addBytes + 1; - if (required >= destMax) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - - if (alloc) { - if (dest == 0) { - dest = (char*) mprMalloc(required); - } else { - dest = (char*) mprRealloc(dest, required); - } - } else { - dest = (char*) *destp; - } - - dp = &dest[existingLen]; - if (delim) { - strcpy(dp, delim); - dp += sepLen; - } - - if (addBytes > 0) { - va_copy(ap, args); - str = src; - while (str) { - strcpy(dp, str); - dp += strlen(str); - str = va_arg(ap, char*); - if (delim && str) { - strcpy(dp, delim); - dp += sepLen; - } - } - va_end(ap); - } else if (dest == 0) { - dest = (char*) mprMalloc(1); - } - *dp = '\0'; - - *destp = dest; - mprAssert(dp < &dest[required]); - return required - 1; -} - -/***************************************************************************** - Note that this VARARGS function must be NULL (not 0, this must be a - pointer) terminated -*/ - -int mprReallocStrcat(char **destp, int destMax, int existingLen, - const char *delim, const char *src,...) -{ - va_list ap; - int rc; - - va_start(ap, src); - rc = mprCoreStrcat(1, destp, destMax, existingLen, delim, src, ap); - va_end(ap); - return rc; -} - -/*****************************************************************************/ -/* - * Return the directory portion of a pathname into the users buffer. - */ - -int mprGetDirName(char *buf, int bufsize, char *path) -{ - char *cp; - int dlen; - - mprAssert(path); - mprAssert(buf); - mprAssert(bufsize > 0); - - cp = strrchr(path, '/'); - if (cp == 0) { -#if WIN - cp = strrchr(path, '\\'); - if (cp == 0) -#endif - { - buf[0] = '\0'; - return 0; - } - } - - if (cp == path && cp[1] == '\0') { - strcpy(buf, "."); - return 0; - } - - dlen = cp - path; - if (dlen < bufsize) { - if (dlen == 0) { - dlen++; - } - mprMemcpy(buf, bufsize, path, dlen); - buf[dlen] = '\0'; - return 0; - } - return MPR_ERR_WONT_FIT; -} - -/*****************************************************************************/ - -int mprStrcpy(char *dest, int destMax, const char *src) -{ - int len; - - mprAssert(dest); - mprAssert(destMax > 0); - mprAssert(src); - - len = strlen(src); - if (len >= destMax && len > 0) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - if (len > 0) { - memcpy(dest, src, len); - dest[len] = '\0'; - } else { - *dest = '\0'; - len = 0; - } - return len; -} - -/*****************************************************************************/ - -int mprMemcpy(char *dest, int destMax, const char *src, int nbytes) -{ - mprAssert(dest); - mprAssert(destMax > nbytes); - mprAssert(src); - mprAssert(nbytes > 0); - - if (nbytes > destMax) { - mprAssert(0); - return MPR_ERR_WONT_FIT; - } - if (nbytes > 0) { - memcpy(dest, src, nbytes); - return nbytes; - } else { - return 0; - } -} - -/*****************************************************************************/ -#else -void miniMprDummy() {} -#endif // !BLD_APPWEB && !BLD_GOAHEAD_WEBSERVER - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/mpr/miniMpr.h b/source4/lib/appweb/mpr/miniMpr.h deleted file mode 100644 index 2b8ff0af6a..0000000000 --- a/source4/lib/appweb/mpr/miniMpr.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * @file miniMpr.h - * @brief Mini Mbedthis Portable Runtime (MPR) Environment. - * @copy default - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ -#ifndef _h_MINI_MPR -#define _h_MINI_MPR 1 - -/********************************** Includes **********************************/ -/* - * Find out about our configuration - */ -#ifndef _INCLUDES_H - #include "includes.h" -#endif - -/* allow this library to use strcpy() */ -#undef strcpy - #include "lib/appweb/ejs/config.h" - -#if BLD_APPWEB - /* - * If building within AppWeb, use the full MPR - */ - #include "mpr.h" -#else - - #include - #include - #include - #include - #include - #include - #include - -#if !WIN - #include -#endif - -#if CE - #include - #include "CE/wincompat.h" -#endif - -#if LYNX - #include -#endif - -#if QNX4 - #include -#endif -#ifdef HAVE_MATH_H - #include -#endif -/********************************** Defines ***********************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -#if BLD_FEATURE_SQUEEZE -/* - * Reasonable length of a file path name to use in most cases where you know - * the expected file name and it is certain to be less than this limit. - */ -#define MPR_MAX_FNAME 128 -#define MPR_MAX_STRING 512 -#define MPR_DEFAULT_HASH_SIZE 23 /* Default size of hash table index */ -#define MPR_MAX_HEAP_SIZE (32 * 1024) -#else -#define MPR_MAX_FNAME 256 -#define MPR_MAX_STRING 4096 -#define MPR_DEFAULT_HASH_SIZE 43 /* Default size of hash table index */ -#define MPR_MAX_HEAP_SIZE (64 * 1024) -#endif - -/* - * Useful for debugging - */ -#define MPR_L __FILE__, __LINE__ - -#if BLD_FEATURE_ASSERT -#define mprAssert(C) \ - if (C) ; else mprBreakpoint(__FILE__, __LINE__, #C) -#else - #define mprAssert(C) if (1) ; else -#endif - -/* - * Standard MPR return and error codes - */ -#define MPR_ERR_BASE (-200) /* Error code */ -#define MPR_ERR_GENERAL (MPR_ERR_BASE - 1) /* Error code */ -#define MPR_ERR_ABORTED (MPR_ERR_BASE - 2) /* Error code */ -#define MPR_ERR_ALREADY_EXISTS (MPR_ERR_BASE - 3) /* Error code */ -#define MPR_ERR_BAD_ARGS (MPR_ERR_BASE - 4) /* Error code */ -#define MPR_ERR_BAD_FORMAT (MPR_ERR_BASE - 5) /* Error code */ -#define MPR_ERR_BAD_HANDLE (MPR_ERR_BASE - 6) /* Error code */ -#define MPR_ERR_BAD_STATE (MPR_ERR_BASE - 7) /* Error code */ -#define MPR_ERR_BAD_SYNTAX (MPR_ERR_BASE - 8) /* Error code */ -#define MPR_ERR_BAD_TYPE (MPR_ERR_BASE - 9) /* Error code */ -#define MPR_ERR_BAD_VALUE (MPR_ERR_BASE - 10) /* Error code */ -#define MPR_ERR_BUSY (MPR_ERR_BASE - 11) /* Error code */ -#define MPR_ERR_CANT_ACCESS (MPR_ERR_BASE - 12) /* Error code */ -#define MPR_ERR_CANT_COMPLETE (MPR_ERR_BASE - 13) /* Error code */ -#define MPR_ERR_CANT_CREATE (MPR_ERR_BASE - 14) /* Error code */ -#define MPR_ERR_CANT_INITIALIZE (MPR_ERR_BASE - 15) /* Error code */ -#define MPR_ERR_CANT_OPEN (MPR_ERR_BASE - 16) /* Error code */ -#define MPR_ERR_CANT_READ (MPR_ERR_BASE - 17) /* Error code */ -#define MPR_ERR_CANT_WRITE (MPR_ERR_BASE - 18) /* Error code */ -#define MPR_ERR_DELETED (MPR_ERR_BASE - 19) /* Error code */ -#define MPR_ERR_NETWORK (MPR_ERR_BASE - 20) /* Error code */ -#define MPR_ERR_NOT_FOUND (MPR_ERR_BASE - 21) /* Error code */ -#define MPR_ERR_NOT_INITIALIZED (MPR_ERR_BASE - 22) /* Error code */ -#define MPR_ERR_NOT_READY (MPR_ERR_BASE - 23) /* Error code */ -#define MPR_ERR_READ_ONLY (MPR_ERR_BASE - 24) /* Error code */ -#define MPR_ERR_TIMEOUT (MPR_ERR_BASE - 25) /* Error code */ -#define MPR_ERR_TOO_MANY (MPR_ERR_BASE - 26) /* Error code */ -#define MPR_ERR_WONT_FIT (MPR_ERR_BASE - 27) /* Error code */ -#define MPR_ERR_WOULD_BLOCK (MPR_ERR_BASE - 28) /* Error code */ -#define MPR_ERR_CANT_ALLOCATE (MPR_ERR_BASE - 29) /* Error code */ -#define MPR_ERR_MAX (MPR_ERR_BASE - 30) /* Error code */ - -/* - * Standard error severity and trace levels. These are ored with the error - * severities below. The MPR_LOG_MASK is used to extract the trace level - * from a flags word. We expect most apps to run with level 2 trace. - */ -#define MPR_FATAL 0 /* Fatal error. Cant continue. */ -#define MPR_ERROR 1 /* Hard error */ -#define MPR_WARN 2 /* Soft warning */ -#define MPR_CONFIG 2 /* Essential configuration settings */ -#define MPR_INFO 3 /* Informational only */ -#define MPR_DEBUG 4 /* Debug information */ -#define MPR_VERBOSE 9 /* Highest level of trace */ -#define MPR_LOG_MASK 0xf /* Level mask */ - -/* - * Error flags. Specify where the error should be sent to. Note that the - * product.xml setting "headless" will modify how errors are reported. - * Assert errors are trapped when in DEV mode. Otherwise ignored. - */ -#define MPR_TRAP 0x10 /* Assert error -- trap in debugger */ -#define MPR_LOG 0x20 /* Log the error in the O/S event log */ -#define MPR_USER 0x40 /* Display to the user */ -#define MPR_ALERT 0x80 /* Send a management alert */ -#define MPR_TRACE 0x100 /* Trace */ - -/* - * Error format flags - */ -#define MPR_RAW 0x200 /* Raw trace output */ - -/* - * Error line number information - */ -#define MPR_L __FILE__, __LINE__ - -typedef char* MprStr; - -#ifndef __cplusplus -typedef unsigned char uchar; -#endif - -/* - * Porters: put other operating system type defines here - */ -#if WIN - typedef unsigned int uint; - typedef __int64 int64; - typedef unsigned __int64 uint64; -#else -#define O_BINARY 0 -#ifndef uint - #define uint unsigned -#endif - #define int64 int64_t - #define uint64 uint64_t -#endif - -/* - * Flexible array data type - */ -typedef struct { - int max; /* Size of the handles array */ - int used; /* Count of used entries in handles */ - void **handles; -} MprArray; - -#if BLD_FEATURE_SQUEEZE -#define MPR_ARRAY_INCR 8 -#else -#define MPR_ARRAY_INCR 16 -#endif - -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -/********************************* Prototypes *********************************/ -/* - * If running in the GoAhead WebServer, map some MPR routines to WebServer - * equivalents. - */ - -#if BLD_GOAHEAD_WEBSERVER -#include "uemf.h" -#define mprMalloc(size) balloc(B_L, size) -#define mprFree(ptr) bfreeSafe(B_L, ptr) -#define mprRealloc(ptr, size) brealloc(B_L, ptr, size) -#define mprStrdup(ptr) bstrdup(B_L, ptr) -#define mprAllocSprintf fmtAlloc -#define mprAllocVsprintf fmtValloc -#define mprSprintf fmtStatic -#define mprItoa stritoa -#define mprLog trace -#define mprBreakpoint(file, line, cond) \ - error(file, line, E_BLD_FEATURE_ASSERT, T("%s"), cond) - -#else /* !BLD_GOAHEAD_WEBSERVER */ -/* #define mprMalloc malloc */ -#define mprSprintf snprintf -#define mtVsprintf vsnprintf -extern void *mprMalloc(uint size); -extern void *mprRealloc(void *ptr, uint size); -extern void mprFree(void *ptr); -extern char *mprStrdup(const char *str); -extern int mprAllocVsprintf(char **msgbuf, int maxSize, const char *fmt, - va_list args) PRINTF_ATTRIBUTE(3,0); -extern int mprAllocSprintf(char **msgbuf, int maxSize, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -extern char *mprItoa(int num, char *buf, int width); -extern void mprLog(int level, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -extern void mprBreakpoint(const char *file, int line, const char *msg) _NORETURN_; -#endif /* BLD_GOAHEAD_WEBSERVER */ - -extern MprArray *mprCreateArray(void); -extern void mprDestroyArray(MprArray *array); -extern int mprAddToArray(MprArray *array, void *item); -extern int mprRemoveFromArray(MprArray *array, int idx); -extern char *mprStrTok(char *str, const char *delim, char **tok); - -extern int mprGetDirName(char *buf, int bufsize, char *path); -extern int mprReallocStrcat(char **dest, int max, int existingLen, - const char *delim, const char *src, ...); -extern int mprStrcpy(char *dest, int destMax, const char *src); -extern int mprMemcpy(char *dest, int destMax, const char *src, int nbytes); - -extern void mprSetCtx(void *ctx); -extern void *mprMemCtx(void); -struct loadparm_context; -extern struct loadparm_context *mprLpCtx(void); -struct event_context; -extern struct event_context *mprEventCtx(void); - -/* This function needs to be provided by anyone using ejs */ -void ejs_exception(const char *reason); - -#define mprStrCmpAnyCase(s1, s2) strcasecmp_m(s1, s2) - -#ifdef __cplusplus -} -#endif -#endif /* !BLD_APPWEB */ -#endif /* _h_MINI_MPR */ - -/*****************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/mpr/var.c b/source4/lib/appweb/mpr/var.c deleted file mode 100644 index e73da773ea..0000000000 --- a/source4/lib/appweb/mpr/var.c +++ /dev/null @@ -1,2215 +0,0 @@ -/* - * @file var.c - * @brief MPR Universal Variable Type - * @overview - * - * @copy default.m - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/******************************* Documentation ********************************/ - -/* - * This module is NOT multithreaded. - * - * Properties are variables that are stored in an object type variable. - * Properties can be primitive data types, other objects or functions. - * Properties are indexed by a character name. - */ - -/********************************** Includes **********************************/ - -#include "var.h" - -/*********************************** Locals ***********************************/ -#if VAR_DEBUG - -static MprProperties objectList; /* Dummy head of objects list */ -static int objectCount = -1; /* Count of objects */ - -#endif -/***************************** Forward Declarations ***************************/ - -static int adjustRefCount(MprProperties *pp, int adj); -static int adjustVarRefCount(MprVar *vp, int adj); -static MprVar *allocProperty(const char *propertyName); -static void copyVarCore(MprVar *dest, MprVar *src, int copyDepth); -static MprProperties - *createProperties(const char *name, int hashSize); -static bool freeVar(MprVar *vp, int force); -static bool freeVarStorage(MprVar *vp, int force); -static MprVar *getObjChain(MprProperties *pp, const char *property); -static int hash(MprProperties *pp, const char *property); -static bool releaseProperties(MprProperties *pp, int force); - -/*********************************** Code *************************************/ -/* - * Destroy a variable and all referenced variables. Release any referenced - * object regardless of whether other users still have references. Be VERY - * careful using this routine. - * - * Return TRUE if the underlying data is freed. Objects may not be freed if - * there are other users of the object. - */ - -bool mprDestroyAllVars(MprVar *vp) -{ - mprAssert(vp); - - if (vp->trigger) { - if ((vp->trigger)(MPR_VAR_DELETE, vp->parentProperties, vp, 0, 0) - == MPR_TRIGGER_ABORT) { - return 0; - } - } - - /* - * Free the actual value. If this var refers to an object, we will - * recurse through all the properties freeing all vars. - */ - return freeVar(vp, 1); -} - -/******************************************************************************/ -/* - * Destroy a variable. Release any referenced object (destroy if no other - * users are referencing). - * - * Return TRUE if the underlying data is freed. Objects may not be freed if - * there are other users of the object. - */ - -bool mprDestroyVar(MprVar *vp) -{ - mprAssert(vp); - - if (vp->trigger) { - if ((vp->trigger)(MPR_VAR_DELETE, vp->parentProperties, vp, 0, 0) - == MPR_TRIGGER_ABORT) { - return 0; - } - } - - /* - * Free the actual value. If this var refers to an object, we will - * recurse through all the properties freeing all that have no other - * references. - */ - return freeVar(vp, 0); -} - -/******************************************************************************/ -/* - * Free the value in a variable for primitive types. Release objects. - * - * Return TRUE if the underlying data is freed. Objects may not be freed if - * there are other users of the object. - */ - -static bool freeVar(MprVar *vp, int force) -{ - bool freed; - - mprAssert(vp); - - freed = freeVarStorage(vp, force); - - mprFree(vp->name); - mprFree(vp->fullName); - - if (vp->allocatedVar) { - mprFree(vp); - } else { - vp->name = 0; - vp->fullName = 0; - vp->type = MPR_TYPE_UNDEFINED; - } - return freed; -} - -/******************************************************************************/ -/* - * Free the value in a variable for primitive types. Release objects. - * - * Return TRUE if the underlying data is freed. Objects may not be freed if - * there are other users of the object. - */ - -static bool freeVarStorage(MprVar *vp, int force) -{ - MprArray *argList; - bool freed; - int i; - - freed = 1; - mprAssert(vp); - - switch (vp->type) { - default: - break; - - case MPR_TYPE_STRING: - if (vp->allocatedData && vp->string != 0) { - mprFree(vp->string); - vp->string = 0; - vp->allocatedData = 0; - } - break; - - case MPR_TYPE_PTR: - if (vp->allocatedData) { - vp->allocatedData = 0; - mprFree(vp->ptr); - } - break; - - case MPR_TYPE_OBJECT: -#if VAR_DEBUG - /* - * Recurse through all properties and release / delete. Release the - * properties hash table. - */ - if (vp->properties->refCount > 1) { - mprLog(7, "freeVar: ACT \"%s\", 0x%x, ref %d, force %d\n", - vp->name, vp->properties, vp->properties->refCount, force); - } else { - mprLog(7, "freeVar: DEL \"%s\", 0x%x, ref %d, force %d\n", - vp->name, vp->properties, vp->properties->refCount, force); - } -#endif - if (vp->allocatedData) { - freed = releaseProperties(vp->properties, force); - } - vp->properties = 0; - break; - - case MPR_TYPE_FUNCTION: - if (vp->allocatedData) { - argList = vp->function.args; - for (i = 0; i < argList->max; i++) { - if (argList->handles[i] != 0) { - mprFree(argList->handles[i]); - } - } - mprDestroyArray(argList); - vp->function.args = 0; - mprFree(vp->function.body); - vp->function.body = 0; - } - break; - } - - vp->type = MPR_TYPE_UNDEFINED; - return freed; -} - -/******************************************************************************/ -/* - * Adjust the object reference count and return the currrent count of - * users. - */ - -static int adjustVarRefCount(MprVar *vp, int adj) -{ - mprAssert(vp); - - if (vp->type != MPR_TYPE_OBJECT) { - mprAssert(vp->type == MPR_TYPE_OBJECT); - return 0; - } - return adjustRefCount(vp->properties, adj); -} - -/******************************************************************************/ -/* - * Get the object reference count - */ - -int mprGetVarRefCount(MprVar *vp) -{ - mprAssert(vp); - - if (vp->type != MPR_TYPE_OBJECT) { - mprAssert(vp->type == MPR_TYPE_OBJECT); - return 0; - } - return adjustRefCount(vp->properties, 0); -} - -/******************************************************************************/ -/* - * Update the variable's name - */ - -void mprSetVarName(MprVar *vp, char *name) -{ - mprAssert(vp); - - mprFree(vp->name); - vp->name = mprStrdup(name); -} - -/******************************************************************************/ -/* - * Append to the variable's full name - */ - -void mprSetVarFullName(MprVar *vp, char *name) -{ -#if VAR_DEBUG - mprAssert(vp); - - mprFree(vp->fullName); - vp->fullName = mprStrdup(name); - if (vp->type == MPR_TYPE_OBJECT) { - if (strcmp(vp->properties->name, "this") == 0) { - mprStrcpy(vp->properties->name, sizeof(vp->properties->name), name); - } - } -#endif -} - -/******************************************************************************/ -/* - * Make a var impervious to recursive forced deletes. - */ - -void mprSetVarDeleteProtect(MprVar *vp, int deleteProtect) -{ - mprAssert(vp); - - if (vp->type == MPR_TYPE_OBJECT && vp->properties) { - vp->properties->deleteProtect = deleteProtect; - } -} - -/******************************************************************************/ -/* - * Make a variable readonly. Can still be deleted. - */ - -void mprSetVarReadonly(MprVar *vp, int readonly) -{ - mprAssert(vp); - - vp->readonly = readonly; -} - -/******************************************************************************/ - -MprVarTrigger mprAddVarTrigger(MprVar *vp, MprVarTrigger fn) -{ - MprVarTrigger oldTrigger; - - mprAssert(vp); - mprAssert(fn); - - oldTrigger = vp->trigger; - vp->trigger = fn; - return oldTrigger; -} - -/******************************************************************************/ - -MprType mprGetVarType(MprVar *vp) -{ - mprAssert(vp); - - return vp->type; -} - -/******************************************************************************/ -/********************************** Properties ********************************/ -/******************************************************************************/ -/* - * Create a property in an object with a defined value. If the property - * already exists in the object, then just write its value. - */ - -MprVar *mprCreateProperty(MprVar *obj, const char *propertyName, - MprVar *newValue) -{ - MprVar *prop, *last; - int bucketIndex; - - mprAssert(obj); - mprAssert(propertyName && *propertyName); - - if (obj->type != MPR_TYPE_OBJECT) { - mprAssert(obj->type == MPR_TYPE_OBJECT); - return 0; - } - - /* - * See if property already exists and locate the bucket to hold the - * property reference. - */ - last = 0; - bucketIndex = hash(obj->properties, propertyName); - prop = obj->properties->buckets[bucketIndex]; - - /* - * Find the property in the hash chain if it exists - */ - for (last = 0; prop; last = prop, prop = prop->forw) { - if (prop->name[0] == propertyName[0] && - strcmp(prop->name, propertyName) == 0) { - break; - } - } - - if (prop) { - /* FUTURE -- remove. Just for debug. */ - mprAssert(prop == 0); - mprLog(0, "Attempting to create property %s in object %s\n", - propertyName, obj->name); - return 0; - } - - if (obj->trigger) { - if ((obj->trigger)(MPR_VAR_CREATE_PROPERTY, obj->properties, prop, - newValue, 0) == MPR_TRIGGER_ABORT) { - return 0; - } - } - - /* - * Create a new property - */ - prop = allocProperty(propertyName); - if (prop == 0) { - mprAssert(prop); - return 0; - } - - copyVarCore(prop, newValue, MPR_SHALLOW_COPY); - - prop->bucketIndex = bucketIndex; - if (last) { - last->forw = prop; - } else { - obj->properties->buckets[bucketIndex] = prop; - } - prop->parentProperties = obj->properties; - - /* - * Update the item counts - */ - obj->properties->numItems++; - if (! mprVarIsFunction(prop->type)) { - obj->properties->numDataItems++; - } - - return prop; -} - -/******************************************************************************/ -/* - * Create a property in an object with a defined value. If the property - * already exists in the object, then just write its value. Same as - * mprCreateProperty except that the new value is passed by value rather than - * by pointer. - */ - -MprVar *mprCreatePropertyValue(MprVar *obj, const char *propertyName, - MprVar newValue) -{ - return mprCreateProperty(obj, propertyName, &newValue); -} - -/******************************************************************************/ -/* - * Create a new property - */ - -static MprVar *allocProperty(const char *propertyName) -{ - MprVar *prop; - - prop = (MprVar*) mprMalloc(sizeof(MprVar)); - if (prop == 0) { - mprAssert(prop); - return 0; - } - memset(prop, 0, sizeof(MprVar)); - prop->allocatedVar = 1; - prop->name = mprStrdup(propertyName); - prop->forw = (MprVar*) 0; - - return prop; -} - -/******************************************************************************/ -/* - * Update a property in an object with a defined value. Create the property - * if it doesn not already exist. - */ - -MprVar *mprSetProperty(MprVar *obj, const char *propertyName, MprVar *newValue) -{ - MprVar *prop, triggerValue; - int rc; - - mprAssert(obj); - mprAssert(propertyName && *propertyName); - mprAssert(obj->type == MPR_TYPE_OBJECT); - - if (obj->type != MPR_TYPE_OBJECT) { - mprAssert(0); - return 0; - } - - prop = mprGetProperty(obj, propertyName, 0); - if (prop == 0) { - return mprCreateProperty(obj, propertyName, newValue); - } - - if (obj->trigger) { - /* - * Call the trigger before the update and pass it the new value. - */ - triggerValue = *newValue; - triggerValue.allocatedVar = 0; - triggerValue.allocatedData = 0; - rc = (obj->trigger)(MPR_VAR_WRITE, obj->properties, obj, - &triggerValue, 0); - if (rc == MPR_TRIGGER_ABORT) { - return 0; - - } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) { - /* - * Trigger must copy to triggerValue a variable that is not - * a structure copy of the existing data. - */ - copyVarCore(prop, &triggerValue, MPR_SHALLOW_COPY); - mprDestroyVar(&triggerValue); - return prop; - } - } - copyVarCore(prop, newValue, MPR_SHALLOW_COPY); - return prop; -} - -/******************************************************************************/ -/* - * Update a property in an object with a defined value. Create the property - * if it does not already exist. Same as mprSetProperty except that the - * new value is passed by value rather than by pointer. - */ - -MprVar *mprSetPropertyValue(MprVar *obj, const char *propertyName, - MprVar newValue) -{ - return mprSetProperty(obj, propertyName, &newValue); -} - -/******************************************************************************/ -/* - * Delete a property from this object - */ - -int mprDeleteProperty(MprVar *obj, const char *property) -{ - MprVar *prop, *last; - char *cp; - int bucketIndex; - - mprAssert(obj); - mprAssert(property && *property); - mprAssert(obj->type == MPR_TYPE_OBJECT); - - if (obj->type != MPR_TYPE_OBJECT) { - mprAssert(obj->type == MPR_TYPE_OBJECT); - return 0; - } - - last = 0; - bucketIndex = hash(obj->properties, property); - if ((prop = obj->properties->buckets[bucketIndex]) != 0) { - for ( ; prop; prop = prop->forw) { - cp = prop->name; - if (cp[0] == property[0] && strcmp(cp, property) == 0) { - break; - } - last = prop; - } - } - if (prop == (MprVar*) 0) { - mprAssert(prop); - return MPR_ERR_NOT_FOUND; - } - if (prop->readonly) { - mprAssert(! prop->readonly); - return MPR_ERR_READ_ONLY; - } - - if (obj->trigger) { - if ((obj->trigger)(MPR_VAR_DELETE_PROPERTY, obj->properties, prop, 0, 0) - == MPR_TRIGGER_ABORT) { - return MPR_ERR_ABORTED; - } - } - - if (last) { - last->forw = prop->forw; - } else { - obj->properties->buckets[bucketIndex] = prop->forw; - } - - obj->properties->numItems--; - if (! mprVarIsFunction(prop->type)) { - obj->properties->numDataItems--; - } - - mprDestroyVar(prop); - - return 0; -} - -/******************************************************************************/ -/* - * Find a property in an object and return a pointer to it. If a value arg - * is supplied, then copy the data into the var. - */ - -MprVar *mprGetProperty(MprVar *obj, const char *property, MprVar *value) -{ - MprVar *prop, triggerValue; - int rc; - - if (obj == 0 || obj->type != MPR_TYPE_OBJECT || property == 0 || - *property == '\0') { - if (value) { - value->type = MPR_TYPE_UNDEFINED; - } - return 0; - } - - for (prop = getObjChain(obj->properties, property); prop; - prop = prop->forw) { - if (prop->name && - prop->name[0] == property[0] && strcmp(prop->name, property) == 0) { - break; - } - } - if (prop == 0) { - if (value) { - value->type = MPR_TYPE_UNDEFINED; - } - return 0; - } - if (value) { - if (prop->trigger) { - triggerValue = *prop; - triggerValue.allocatedVar = 0; - triggerValue.allocatedData = 0; - /* - * Pass the trigger the current read value and may receive - * a new value. - */ - rc = (prop->trigger)(MPR_VAR_READ, prop->parentProperties, prop, - &triggerValue, 0); - if (rc == MPR_TRIGGER_ABORT) { - if (value) { - value->type = MPR_TYPE_UNDEFINED; - } - return 0; - - } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) { - copyVarCore(prop, &triggerValue, MPR_SHALLOW_COPY); - mprDestroyVar(&triggerValue); - } - } - /* - * Clone. No copy. - */ - *value = *prop; - } - return prop; -} - -/******************************************************************************/ -/* - * Read a properties value. This returns the property's value. It does not - * copy object/string data but returns a pointer directly into the variable. - * The caller does not and should not call mprDestroy on the returned value. - * If value is null, just read the property and run triggers. - */ - -int mprReadProperty(MprVar *prop, MprVar *value) -{ - MprVar triggerValue; - int rc; - - mprAssert(prop); - - if (prop->trigger) { - triggerValue = *prop; - triggerValue.allocatedVar = 0; - triggerValue.allocatedData = 0; - rc = (prop->trigger)(MPR_VAR_READ, prop->parentProperties, prop, - &triggerValue, 0); - - if (rc == MPR_TRIGGER_ABORT) { - return MPR_ERR_ABORTED; - - } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) { - copyVarCore(prop, &triggerValue, MPR_SHALLOW_COPY); - mprDestroyVar(&triggerValue); - return 0; - } - } - if (value) { - *value = *prop; - - /* - * Just so that if the user calls mprDestroyVar on value, it will do no - * harm. - */ - value->allocatedVar = 0; - value->allocatedData = 0; - } - return 0; -} - -/******************************************************************************/ -/* - * Read a properties value. This returns a copy of the property variable. - * However, if the property is an object or string, it returns a copy of the - * reference to the underlying data. If copyDepth is set to MPR_DEEP_COPY, - * then the underlying objects and strings data will be copied as well. If - * copyDepth is set to MPR_SHALLOW_COPY, then only strings will be copied. If - * it is set to MPR_NO_COPY, then no data will be copied. In all cases, the - * user must call mprDestroyVar to free resources. This routine will run any - * registered triggers which may modify the value the user receives (without - * updating the properties real value). - * - * WARNING: the args are reversed to most other APIs. This conforms to the - * strcpy(dest, src) standard instead. - */ - -int mprCopyProperty(MprVar *dest, MprVar *prop, int copyDepth) -{ - MprVar triggerValue; - int rc; - - mprAssert(prop); - mprAssert(dest); - - if (prop->trigger) { - triggerValue = *prop; - triggerValue.allocatedVar = 0; - triggerValue.allocatedData = 0; - rc = (prop->trigger)(MPR_VAR_READ, prop->parentProperties, prop, - &triggerValue, copyDepth); - - if (rc == MPR_TRIGGER_ABORT) { - return MPR_ERR_ABORTED; - - } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) { - copyVarCore(dest, &triggerValue, MPR_SHALLOW_COPY); - mprDestroyVar(&triggerValue); - return 0; - } - } - mprCopyVar(dest, prop, copyDepth); - return 0; -} - -/******************************************************************************/ -/* - * Write a new value into an existing property in an object. - */ - -int mprWriteProperty(MprVar *vp, MprVar *value) -{ - MprVar triggerValue; - int rc; - - mprAssert(vp); - mprAssert(value); - - if (vp->readonly) { - return MPR_ERR_READ_ONLY; - } - - if (vp->trigger) { - triggerValue = *value; - - rc = (vp->trigger)(MPR_VAR_WRITE, vp->parentProperties, vp, - &triggerValue, 0); - - if (rc == MPR_TRIGGER_ABORT) { - return MPR_ERR_ABORTED; - - } else if (rc == MPR_TRIGGER_USE_NEW_VALUE) { - copyVarCore(vp, &triggerValue, MPR_SHALLOW_COPY); - mprDestroyVar(&triggerValue); - return 0; - } - /* Fall through */ - } - - copyVarCore(vp, value, MPR_SHALLOW_COPY); - return 0; -} - -/******************************************************************************/ -/* - * Write a new value into an existing property in an object. - */ - -int mprWritePropertyValue(MprVar *vp, MprVar value) -{ - mprAssert(vp); - - return mprWriteProperty(vp, &value); -} - -/******************************************************************************/ -/* - * Get the count of properties. - */ - -int mprGetPropertyCount(MprVar *vp, int includeFlags) -{ - mprAssert(vp); - - if (vp->type != MPR_TYPE_OBJECT) { - return 0; - } - if (includeFlags == MPR_ENUM_DATA) { - return vp->properties->numDataItems; - } else { - return vp->properties->numItems; - } -} - -/******************************************************************************/ -/* - * Get the first property in an object. Used for walking all properties in an - * object. - */ - -MprVar *mprGetFirstProperty(MprVar *obj, int includeFlags) -{ - MprVar *prop; - int i; - - mprAssert(obj); - mprAssert(obj->type == MPR_TYPE_OBJECT); - - if (obj->type != MPR_TYPE_OBJECT) { - mprAssert(obj->type == MPR_TYPE_OBJECT); - return 0; - } - - for (i = 0; i < (int) obj->properties->hashSize; i++) { - for (prop = obj->properties->buckets[i]; prop; prop = prop->forw) { - if (prop) { - if (mprVarIsFunction(prop->type)) { - if (!(includeFlags & MPR_ENUM_FUNCTIONS)) { - continue; - } - } else { - if (!(includeFlags & MPR_ENUM_DATA)) { - continue; - } - } - return prop; - } - break; - } - } - return 0; -} - -/******************************************************************************/ -/* - * Get the next property in sequence. - */ - -MprVar *mprGetNextProperty(MprVar *obj, MprVar *last, int includeFlags) -{ - MprProperties *properties; - int i; - - mprAssert(obj); - mprAssert(obj->type == MPR_TYPE_OBJECT); - - if (obj->type != MPR_TYPE_OBJECT) { - mprAssert(obj->type == MPR_TYPE_OBJECT); - return 0; - } - properties = obj->properties; - - if (last->forw) { - return last->forw; - } - - for (i = last->bucketIndex + 1; i < (int) properties->hashSize; i++) { - for (last = properties->buckets[i]; last; last = last->forw) { - if (mprVarIsFunction(last->type)) { - if (!(includeFlags & MPR_ENUM_FUNCTIONS)) { - continue; - } - } else { - if (!(includeFlags & MPR_ENUM_DATA)) { - continue; - } - } - return last; - } - } - return 0; -} - -/******************************************************************************/ -/************************** Internal Support Routines *************************/ -/******************************************************************************/ -/* - * Create an hash table to hold and index properties. Properties are just - * variables which may contain primitive data types, functions or other - * objects. The hash table is the essence of an object. HashSize specifies - * the size of the hash table to use and should be a prime number. - */ - -static MprProperties *createProperties(const char *name, int hashSize) -{ - MprProperties *pp; - - if (hashSize < 7) { - hashSize = 7; - } - if ((pp = (MprProperties*) mprMalloc(sizeof(MprProperties))) == NULL) { - mprAssert(0); - return 0; - } - mprAssert(pp); - memset(pp, 0, sizeof(MprProperties)); - - pp->numItems = 0; - pp->numDataItems = 0; - pp->hashSize = hashSize; - pp->buckets = (MprVar**) mprMalloc(pp->hashSize * sizeof(MprVar*)); - mprAssert(pp->buckets); - memset(pp->buckets, 0, pp->hashSize * sizeof(MprVar*)); - pp->refCount = 1; - -#if VAR_DEBUG - if (objectCount == -1) { - objectCount = 0; - objectList.next = objectList.prev = &objectList; - } - - mprStrcpy(pp->name, sizeof(pp->name), name); - pp->next = &objectList; - pp->prev = objectList.prev; - objectList.prev->next = pp; - objectList.prev = pp; - objectCount++; -#endif - return pp; -} - -/******************************************************************************/ -/* - * Release an object's properties hash table. If this is the last person - * using it, free it. Return TRUE if the object is released. - */ - -static bool releaseProperties(MprProperties *obj, int force) -{ - MprProperties *pp; - MprVar *prop, *forw; - int i; - - mprAssert(obj); - mprAssert(obj->refCount > 0); - -#if VAR_DEBUG - /* - * Debug sanity check - */ - mprAssert(obj->refCount < 20); -#endif - - if (--obj->refCount > 0 && !force) { - return 0; - } - -#if VAR_DEBUG - mprAssert(obj->prev); - mprAssert(obj->next); - mprAssert(obj->next->prev); - mprAssert(obj->prev->next); - obj->next->prev = obj->prev; - obj->prev->next = obj->next; - objectCount--; -#endif - - for (i = 0; i < (int) obj->hashSize; i++) { - for (prop = obj->buckets[i]; prop; prop = forw) { - forw = prop->forw; - if (prop->type == MPR_TYPE_OBJECT) { - - if (prop->properties == obj) { - /* Self reference */ - continue; - } - pp = prop->properties; - if (pp->visited) { - continue; - } - - pp->visited = 1; - if (! freeVar(prop, pp->deleteProtect ? 0 : force)) { - pp->visited = 0; - } - - } else { - freeVar(prop, force); - } - } - } - - mprFree((void*) obj->buckets); - mprFree((void*) obj); - - return 1; -} - -/******************************************************************************/ -/* - * Adjust the reference count - */ - -static int adjustRefCount(MprProperties *pp, int adj) -{ - mprAssert(pp); - - /* - * Debug sanity check - */ - mprAssert(pp->refCount < 20); - - return pp->refCount += adj; -} - -/******************************************************************************/ -#if VAR_DEBUG -/* - * Print objects held - */ - -void mprPrintObjects(char *msg) -{ - MprProperties *pp, *np; - MprVar *prop, *forw; - char *buf; - int i; - - mprLog(7, "%s: Object Store. %d objects.\n", msg, objectCount); - pp = objectList.next; - while (pp != &objectList) { - mprLog(7, "%s: 0x%x, refCount %d, properties %d\n", - pp->name, pp, pp->refCount, pp->numItems); - for (i = 0; i < (int) pp->hashSize; i++) { - for (prop = pp->buckets[i]; prop; prop = forw) { - forw = prop->forw; - if (prop->properties == pp) { - /* Self reference */ - continue; - } - mprVarToString(&buf, MPR_MAX_STRING, 0, prop); - if (prop->type == MPR_TYPE_OBJECT) { - np = objectList.next; - while (np != &objectList) { - if (prop->properties == np) { - break; - } - np = np->next; - } - if (prop->properties == np) { - mprLog(7, " %s: OBJECT 0x%x, <%s>\n", - prop->name, prop->properties, prop->fullName); - } else { - mprLog(7, " %s: OBJECT NOT FOUND, %s <%s>\n", - prop->name, buf, prop->fullName); - } - } else { - mprLog(7, " %s: <%s> = %s\n", prop->name, - prop->fullName, buf); - } - mprFree(buf); - } - } - pp = pp->next; - } -} - -/******************************************************************************/ - -void mprPrintObjRefCount(MprVar *vp) -{ - mprLog(7, "OBJECT 0x%x, refCount %d\n", vp->properties, - vp->properties->refCount); -} - -#endif -/******************************************************************************/ -/* - * Get the bucket chain containing a property. - */ - -static MprVar *getObjChain(MprProperties *obj, const char *property) -{ - mprAssert(obj); - - return obj->buckets[hash(obj, property)]; -} - -/******************************************************************************/ -/* - * Fast hash. The history of this algorithm is part of lost computer science - * folk lore. - */ - -static int hash(MprProperties *pp, const char *property) -{ - uint sum; - - mprAssert(pp); - mprAssert(property); - - sum = 0; - while (*property) { - sum += (sum * 33) + *property++; - } - - return sum % pp->hashSize; -} - -/******************************************************************************/ -/*********************************** Constructors *****************************/ -/******************************************************************************/ -/* - * Initialize an undefined value. - */ - -MprVar mprCreateUndefinedVar() -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_UNDEFINED; - return v; -} - -/******************************************************************************/ -/* - * Initialize an null value. - */ - -MprVar mprCreateNullVar() -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_NULL; - return v; -} - -/******************************************************************************/ - -MprVar mprCreateBoolVar(bool value) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_BOOL; - v.boolean = value; - return v; -} - -/******************************************************************************/ -/* - * Initialize a C function. - */ - -MprVar mprCreateCFunctionVar(MprCFunction fn, void *thisPtr, int flags) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_CFUNCTION; - v.cFunction.fn = fn; - v.cFunction.thisPtr = thisPtr; - v.flags = flags; - - return v; -} - -/******************************************************************************/ -/* - * Initialize a C function. - */ - -MprVar mprCreateStringCFunctionVar(MprStringCFunction fn, void *thisPtr, - int flags) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_STRING_CFUNCTION; - v.cFunctionWithStrings.fn = fn; - v.cFunctionWithStrings.thisPtr = thisPtr; - v.flags = flags; - - return v; -} - -/******************************************************************************/ -/* - * Initialize an opaque pointer. - */ - -MprVar mprCreatePtrVar(void *ptr) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_PTR; - v.ptr = ptr; - - return v; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Initialize a floating value. - */ - -MprVar mprCreateFloatVar(double value) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_FLOAT; - v.floating = value; - return v; -} - -#endif -/******************************************************************************/ -/* - * Initialize an integer value. - */ - -MprVar mprCreateIntegerVar(int value) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_INT; - v.integer = value; - return v; -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 -/* - * Initialize a 64-bit integer value. - */ - -MprVar mprCreateInteger64Var(int64 value) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_INT64; - v.integer64 = value; - return v; -} - -#endif /* BLD_FEATURE_INT64 */ -/******************************************************************************/ -/* - * Initialize an number variable. Type is defined by configure. - */ - -MprVar mprCreateNumberVar(MprNum value) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = BLD_FEATURE_NUM_TYPE_ID; -#if BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_INT64 - v.integer64 = value; -#elif BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_FLOAT - v.float = value; -#else - v.integer = value; -#endif - return v; -} - -/******************************************************************************/ -/* - * Initialize a (bare) JavaScript function. args and body can be null. - */ - -MprVar mprCreateFunctionVar(char *args, char *body, int flags) -{ - MprVar v; - char *cp, *arg, *last; - int aid; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_FUNCTION; - v.flags = flags; - - v.function.args = mprCreateArray(); - - if (args) { - args = mprStrdup(args); - arg = mprStrTok(args, ",", &last); - while (arg) { - while (isspace((int) *arg)) - arg++; - for (cp = &arg[strlen(arg) - 1]; cp > arg; cp--) { - if (!isspace((int) *cp)) { - break; - } - } - cp[1] = '\0'; - - aid = mprAddToArray(v.function.args, mprStrdup(arg)); - arg = mprStrTok(0, ",", &last); - } - mprFree(args); - } - - if (body) { - v.function.body = mprStrdup(body); - } - v.allocatedData = 1; - return v; -} - -/******************************************************************************/ -/* - * Initialize an object variable. Return type == MPR_TYPE_UNDEFINED if the - * memory allocation for the properties table failed. - */ - -MprVar mprCreateObjVar(const char *name, int hashSize) -{ - MprVar v; - - mprAssert(name && *name); - - memset(&v, 0x0, sizeof(MprVar)); - v.type = MPR_TYPE_OBJECT; - if (hashSize <= 0) { - hashSize = MPR_DEFAULT_HASH_SIZE; - } - v.properties = createProperties(name, hashSize); - if (v.properties == 0) { - /* Indicate failed memory allocation */ - v.type = MPR_TYPE_UNDEFINED; - } - v.allocatedData = 1; - v.name = mprStrdup(name); - mprLog(7, "mprCreateObjVar %s, 0x%p\n", name, v.properties); - return v; -} - -/******************************************************************************/ -/* - * Initialize a string value. - */ - -MprVar mprCreateStringVar(const char *value, bool allocate) -{ - MprVar v; - - memset(&v, 0x0, sizeof(v)); - v.type = MPR_TYPE_STRING; - if (value == 0) { - v.string = (char*) ""; - } else if (allocate) { - v.string = mprStrdup(value); - v.allocatedData = 1; - } else { - v.string = (char*) value; - } - return v; -} - -/******************************************************************************/ -/* - * Copy an objects core value (only). This preserves the destination object's - * name. This implements copy by reference for objects and copy by value for - * strings and other types. Caller must free dest prior to calling. - */ - -static void copyVarCore(MprVar *dest, MprVar *src, int copyDepth) -{ - MprVarTrigger saveTrigger; - MprVar *srcProp, *destProp, *last; - char **srcArgs; - int i; - - mprAssert(dest); - mprAssert(src); - - if (dest == src) { - return; - } - - /* - * FUTURE: we should allow read-only triggers where the value is never - * stored in the object. Currently, triggers override the readonly - * status. - */ - - if (dest->type != MPR_TYPE_UNDEFINED && dest->readonly && !dest->trigger) { - mprAssert(0); - return; - } - - if (dest->type != MPR_TYPE_UNDEFINED) { - saveTrigger = dest->trigger; - freeVarStorage(dest, 0); - } else { - saveTrigger = 0; - } - - switch (src->type) { - default: - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - break; - - case MPR_TYPE_BOOL: - dest->boolean = src->boolean; - break; - - case MPR_TYPE_PTR: - /* we have to reference here so talloc structures survive a - copy */ - if (src->allocatedData) { - dest->ptr = talloc_reference(mprMemCtx(), src->ptr); - dest->allocatedData = 1; - } else { - dest->ptr = src->ptr; - } - break; - - case MPR_TYPE_STRING_CFUNCTION: - dest->cFunctionWithStrings = src->cFunctionWithStrings; - break; - - case MPR_TYPE_CFUNCTION: - dest->cFunction = src->cFunction; - break; - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - dest->floating = src->floating; - break; -#endif - - case MPR_TYPE_INT: - dest->integer = src->integer; - break; - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - dest->integer64 = src->integer64; - break; -#endif - - case MPR_TYPE_OBJECT: - if (copyDepth == MPR_DEEP_COPY) { - - dest->properties = createProperties(src->name, - src->properties->hashSize); - dest->allocatedData = 1; - - for (i = 0; i < (int) src->properties->hashSize; i++) { - last = 0; - for (srcProp = src->properties->buckets[i]; srcProp; - srcProp = srcProp->forw) { - if (srcProp->visited) { - continue; - } - destProp = allocProperty(srcProp->name); - if (destProp == 0) { - mprAssert(destProp); - return; - } - - destProp->bucketIndex = i; - if (last) { - last->forw = destProp; - } else { - dest->properties->buckets[i] = destProp; - } - destProp->parentProperties = dest->properties; - - /* - * Recursively copy the object - */ - srcProp->visited = 1; - copyVarCore(destProp, srcProp, copyDepth); - srcProp->visited = 0; - last = destProp; - } - } - dest->properties->numItems = src->properties->numItems; - dest->properties->numDataItems = src->properties->numDataItems; - dest->allocatedData = 1; - - } else if (copyDepth == MPR_SHALLOW_COPY) { - dest->properties = src->properties; - adjustVarRefCount(src, 1); - dest->allocatedData = 1; - - } else { - dest->properties = src->properties; - dest->allocatedData = 0; - } - break; - - case MPR_TYPE_FUNCTION: - if (copyDepth != MPR_NO_COPY) { - dest->function.args = mprCreateArray(); - srcArgs = (char**) src->function.args->handles; - for (i = 0; i < src->function.args->max; i++) { - if (srcArgs[i]) { - mprAddToArray(dest->function.args, mprStrdup(srcArgs[i])); - } - } - dest->function.body = mprStrdup(src->function.body); - dest->allocatedData = 1; - } else { - dest->function.args = src->function.args; - dest->function.body = src->function.body; - dest->allocatedData = 0; - } - break; - - case MPR_TYPE_STRING: - if (src->string && copyDepth != MPR_NO_COPY) { - dest->string = mprStrdup(src->string); - dest->allocatedData = 1; - } else { - dest->string = src->string; - dest->allocatedData = 0; - } - break; - } - - dest->type = src->type; - dest->flags = src->flags; - dest->trigger = saveTrigger; - - /* - * Just for safety - */ - dest->spare = 0; -} - -/******************************************************************************/ -/* - * Copy an entire object including name. - */ - -void mprCopyVar(MprVar *dest, MprVar *src, int copyDepth) -{ - mprAssert(dest); - mprAssert(src); - - copyVarCore(dest, src, copyDepth); - - mprFree(dest->name); - dest->name = mprStrdup(src->name); - -#if VAR_DEBUG - if (src->type == MPR_TYPE_OBJECT) { - - mprFree(dest->fullName); - dest->fullName = mprStrdup(src->fullName); - - mprLog(7, "mprCopyVar: object \"%s\", FDQ \"%s\" 0x%x, refCount %d\n", - dest->name, dest->fullName, dest->properties, - dest->properties->refCount); - } -#endif -} - -/******************************************************************************/ -/* - * Copy an entire object including name. - */ - -void mprCopyVarValue(MprVar *dest, MprVar src, int copyDepth) -{ - mprAssert(dest); - - mprCopyVar(dest, &src, copyDepth); -} - -/******************************************************************************/ -/* - * Copy an object. This implements copy by reference for objects and copy by - * value for strings and other types. Caller must free dest prior to calling. - */ - -MprVar *mprDupVar(MprVar *src, int copyDepth) -{ - MprVar *dest; - - mprAssert(src); - - dest = (MprVar*) mprMalloc(sizeof(MprVar)); - memset(dest, 0, sizeof(MprVar)); - - mprCopyVar(dest, src, copyDepth); - return dest; -} - -/******************************************************************************/ -/* - * Convert a value to a text based representation of its value - * FUTURE -- conver this to use the format string in all cases. Allow - * arbitrary format strings. - */ - -void mprVarToString(char** out, int size, char *fmt, MprVar *obj) -{ - char *src; - - mprAssert(out); - - *out = NULL; - - if (obj->trigger) { - mprReadProperty(obj, 0); - } - - switch (obj->type) { - case MPR_TYPE_UNDEFINED: - /* FUTURE -- spec says convert to "undefined" */ - *out = mprStrdup(""); - break; - - case MPR_TYPE_NULL: - *out = mprStrdup("null"); - break; - - case MPR_TYPE_PTR: - mprAllocSprintf(out, size, "[Opaque Pointer %p]", obj->ptr); - break; - - case MPR_TYPE_BOOL: - if (obj->boolean) { - *out = mprStrdup("true"); - } else { - *out = mprStrdup("false"); - } - break; - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - if (fmt == NULL || *fmt == '\0') { - mprAllocSprintf(out, size, "%f", obj->floating); - } else { - mprAllocSprintf(out, size, fmt, obj->floating); - } - break; -#endif - - case MPR_TYPE_INT: - if (fmt == NULL || *fmt == '\0') { - mprAllocSprintf(out, size, "%d", obj->integer); - } else { - mprAllocSprintf(out, size, fmt, obj->integer); - } - break; - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - if (fmt == NULL || *fmt == '\0') { -#if BLD_GOAHEAD_WEBSERVER - mprAllocSprintf(out, size, "%d", (int) obj->integer64); -#else - mprAllocSprintf(out, size, "%lld", (long long)obj->integer64); -#endif - } else { - mprAllocSprintf(out, size, fmt, obj->integer64); - } - break; -#endif - - case MPR_TYPE_CFUNCTION: - mprAllocSprintf(out, size, "[C Function]"); - break; - - case MPR_TYPE_STRING_CFUNCTION: - mprAllocSprintf(out, size, "[C StringFunction]"); - break; - - case MPR_TYPE_FUNCTION: - mprAllocSprintf(out, size, "[JavaScript Function]"); - break; - - case MPR_TYPE_OBJECT: - /* FUTURE -- really want: [object class: name] */ - mprAllocSprintf(out, size, "[object %s]", obj->name); - break; - - case MPR_TYPE_STRING: - src = obj->string; - - mprAssert(src); - if (fmt && *fmt) { - mprAllocSprintf(out, size, fmt, src); - - } else if (src == NULL) { - *out = mprStrdup("null"); - - } else { - *out = mprStrdup(src); - } - break; - - default: - mprAssert(0); - } -} - -/******************************************************************************/ -/* - * Parse a string based on formatting instructions and intelligently - * create a variable. - */ - -MprVar mprParseVar(char *buf, MprType preferredType) -{ - MprType type; - char *cp; - - mprAssert(buf); - - type = preferredType; - - if (preferredType == MPR_TYPE_UNDEFINED) { - if (*buf == '-') { - type = MPR_NUM_VAR; - - } else if (!isdigit((int) *buf)) { - if (strcmp(buf, "true") == 0 || strcmp(buf, "false") == 0) { - type = MPR_TYPE_BOOL; - } else { - type = MPR_TYPE_STRING; - } - - } else if (isdigit((int) *buf)) { - type = MPR_NUM_VAR; - cp = buf; - if (*cp && tolower(cp[1]) == 'x') { - cp = &cp[2]; - } - for (cp = buf; *cp; cp++) { - if (! isdigit((int) *cp)) { - break; - } - } - - if (*cp != '\0') { -#if BLD_FEATURE_FLOATING_POINT - if (*cp == '.' || tolower(*cp) == 'e') { - type = MPR_TYPE_FLOAT; - } else -#endif - { - type = MPR_NUM_VAR; - } - } - } - } - - switch (type) { - case MPR_TYPE_OBJECT: - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - case MPR_TYPE_PTR: - default: - break; - - case MPR_TYPE_BOOL: - return mprCreateBoolVar(buf[0] == 't' ? 1 : 0); - - case MPR_TYPE_INT: - return mprCreateIntegerVar(mprParseInteger(buf)); - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - return mprCreateInteger64Var(mprParseInteger64(buf)); -#endif - - case MPR_TYPE_STRING: - if (strcmp(buf, "null") == 0) { - return mprCreateNullVar(); - } else if (strcmp(buf, "undefined") == 0) { - return mprCreateUndefinedVar(); - } - - return mprCreateStringVar(buf, 1); - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - return mprCreateFloatVar(atof(buf)); -#endif - - } - return mprCreateUndefinedVar(); -} - -/******************************************************************************/ -/* - * Convert the variable to a boolean. Only for primitive types. - */ - -bool mprVarToBool(const MprVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - case MPR_TYPE_STRING_CFUNCTION: - case MPR_TYPE_CFUNCTION: - case MPR_TYPE_FUNCTION: - case MPR_TYPE_OBJECT: - return 0; - - case MPR_TYPE_PTR: - return (vp->ptr != NULL); - - case MPR_TYPE_BOOL: - return vp->boolean; - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - return (vp->floating != 0 && !mprIsNan(vp->floating)); -#endif - - case MPR_TYPE_INT: - return (vp->integer != 0); - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - return (vp->integer64 != 0); -#endif - - case MPR_TYPE_STRING: - mprAssert(vp->string); - return (vp->string[0] != '\0'); - } - - /* Not reached */ - return 0; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Convert the variable to a floating point number. Only for primitive types. - */ - -double mprVarToFloat(const MprVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - case MPR_TYPE_STRING_CFUNCTION: - case MPR_TYPE_CFUNCTION: - case MPR_TYPE_FUNCTION: - case MPR_TYPE_OBJECT: - case MPR_TYPE_PTR: - return 0; - - case MPR_TYPE_BOOL: - return (vp->boolean) ? 1.0 : 0.0; - - case MPR_TYPE_FLOAT: - return vp->floating; - - case MPR_TYPE_INT: - return (double) vp->integer; - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - return (double) vp->integer64; -#endif - - case MPR_TYPE_STRING: - mprAssert(vp->string); - return atof(vp->string); - } - - /* Not reached */ - return 0; -} - -#endif -/******************************************************************************/ -/* - * Convert the variable to a number type. Only works for primitive types. - */ - -MprNum mprVarToNumber(const MprVar *vp) -{ -#if BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_INT64 - return mprVarToInteger64(vp); -#elif BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_FLOAT - return mprVarToFloat(vp); -#else - return mprVarToInteger(vp); -#endif -} - -/******************************************************************************/ -/* - * Convert the variable to a number type. Only works for primitive types. - */ - -MprNum mprParseNumber(char *s) -{ -#if BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_INT64 - return mprParseInteger64(s); -#elif BLD_FEATURE_NUM_TYPE_ID == MPR_TYPE_FLOAT - return mprParseFloat(s); -#else - return mprParseInteger(s); -#endif -} - -/******************************************************************************/ -#if BLD_FEATURE_INT64 -/* - * Convert the variable to an Integer64 type. Only works for primitive types. - */ - -int64 mprVarToInteger64(const MprVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - case MPR_TYPE_STRING_CFUNCTION: - case MPR_TYPE_CFUNCTION: - case MPR_TYPE_FUNCTION: - case MPR_TYPE_OBJECT: - case MPR_TYPE_PTR: - return 0; - - case MPR_TYPE_BOOL: - return (vp->boolean) ? 1 : 0; - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - if (mprIsNan(vp->floating)) { - return 0; - } - return (int64) vp->floating; -#endif - - case MPR_TYPE_INT: - return vp->integer; - - case MPR_TYPE_INT64: - return vp->integer64; - - case MPR_TYPE_STRING: - return mprParseInteger64(vp->string); - } - - /* Not reached */ - return 0; -} - -/******************************************************************************/ -/* - * Convert the string buffer to an Integer64. - */ - -int64 mprParseInteger64(char *str) -{ - char *cp; - int64 num64; - int radix, c, negative; - - mprAssert(str); - - cp = str; - num64 = 0; - negative = 0; - - if (*cp == '-') { - cp++; - negative = 1; - } - - /* - * Parse a number. Observe hex and octal prefixes (0x, 0) - */ - if (*cp != '0') { - /* - * Normal numbers (Radix 10) - */ - while (isdigit((int) *cp)) { - num64 = (*cp - '0') + (num64 * 10); - cp++; - } - } else { - cp++; - if (tolower(*cp) == 'x') { - cp++; - radix = 16; - while (*cp) { - c = tolower(*cp); - if (isdigit(c)) { - num64 = (c - '0') + (num64 * radix); - } else if (c >= 'a' && c <= 'f') { - num64 = (c - ('a' - 10)) + (num64 * radix); - } else { - break; - } - cp++; - } - - } else{ - radix = 8; - while (*cp) { - c = tolower(*cp); - if (isdigit(c) && c < '8') { - num64 = (c - '0') + (num64 * radix); - } else { - break; - } - cp++; - } - } - } - - if (negative) { - return 0 - num64; - } - return num64; -} - -#endif /* BLD_FEATURE_INT64 */ -/******************************************************************************/ -/* - * Convert the variable to an Integer type. Only works for primitive types. - */ - -int mprVarToInteger(const MprVar *vp) -{ - mprAssert(vp); - - switch (vp->type) { - case MPR_TYPE_UNDEFINED: - case MPR_TYPE_NULL: - case MPR_TYPE_STRING_CFUNCTION: - case MPR_TYPE_CFUNCTION: - case MPR_TYPE_FUNCTION: - case MPR_TYPE_OBJECT: - case MPR_TYPE_PTR: - return 0; - - case MPR_TYPE_BOOL: - return (vp->boolean) ? 1 : 0; - -#if BLD_FEATURE_FLOATING_POINT - case MPR_TYPE_FLOAT: - if (mprIsNan(vp->floating)) { - return 0; - } - return (int) vp->floating; -#endif - - case MPR_TYPE_INT: - return vp->integer; - -#if BLD_FEATURE_INT64 - case MPR_TYPE_INT64: - return (int) vp->integer64; -#endif - - case MPR_TYPE_STRING: - return mprParseInteger(vp->string); - } - - /* Not reached */ - return 0; -} - -/******************************************************************************/ -/* - * Convert the string buffer to an Integer. - */ - -int mprParseInteger(char *str) -{ - char *cp; - int num; - int radix, c, negative; - - mprAssert(str); - - cp = str; - num = 0; - negative = 0; - - if (*cp == '-') { - cp++; - negative = 1; - } - - /* - * Parse a number. Observe hex and octal prefixes (0x, 0) - */ - if (*cp != '0') { - /* - * Normal numbers (Radix 10) - */ - while (isdigit((int) *cp)) { - num = (*cp - '0') + (num * 10); - cp++; - } - } else { - cp++; - if (tolower(*cp) == 'x') { - cp++; - radix = 16; - while (*cp) { - c = tolower(*cp); - if (isdigit(c)) { - num = (c - '0') + (num * radix); - } else if (c >= 'a' && c <= 'f') { - num = (c - ('a' - 10)) + (num * radix); - } else { - break; - } - cp++; - } - - } else{ - radix = 8; - while (*cp) { - c = tolower(*cp); - if (isdigit(c) && c < '8') { - num = (c - '0') + (num * radix); - } else { - break; - } - cp++; - } - } - } - - if (negative) { - return 0 - num; - } - return num; -} - -/******************************************************************************/ -#if BLD_FEATURE_FLOATING_POINT -/* - * Convert the string buffer to an Floating. - */ - -double mprParseFloat(char *str) -{ - return atof(str); -} - -/******************************************************************************/ - -bool mprIsNan(double f) -{ -#if WIN - return _isnan(f); -#elif VXWORKS - /* FUTURE */ - return (0); -#elif defined(FP_NAN) - return (f == FP_NAN); -#else - return 0; -#endif -} -/******************************************************************************/ - -bool mprIsInfinite(double f) -{ -#if WIN - return !_finite(f); -#elif VXWORKS - /* FUTURE */ - return (0); -#elif defined(FP_INFINITE) - return (f == FP_INFINITE); -#else - return 0; -#endif -} - -#endif /* BLD_FEATURE_FLOATING_POINT */ -/******************************************************************************/ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/appweb/mpr/var.h b/source4/lib/appweb/mpr/var.h deleted file mode 100644 index 98313c0476..0000000000 --- a/source4/lib/appweb/mpr/var.h +++ /dev/null @@ -1,487 +0,0 @@ -/* - * @file var.h - * @brief MPR Universal Variable Type - * @copy default.m - * - * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved. - * Copyright (c) Michael O'Brien, 1994-1995. All Rights Reserved. - * - * This software is distributed under commercial and open source licenses. - * You may use the GPL open source license described below or you may acquire - * a commercial license from Mbedthis Software. You agree to be fully bound - * by the terms of either license. Consult the LICENSE.TXT distributed with - * this software for full details. - * - * This software is open source; 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. See the GNU General Public License for more - * details at: http://www.mbedthis.com/downloads/gplLicense.html - * - * This program is distributed WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * This GPL license does NOT permit incorporating this software into - * proprietary programs. If you are unable to comply with the GPL, you must - * acquire a commercial license to use this software. Commercial licenses - * for this software and support services are available from Mbedthis - * Software at http://www.mbedthis.com - * - * @end - */ - -/******************************* Documentation ********************************/ -/* - * Variables can efficiently store primitive types and can hold references to - * objects. Objects can store properties which are themselves variables. - * Properties can be primitive data types, other objects or functions. - * Properties are indexed by a character name. A variable may store one of - * the following types: - * - * string, integer, integer-64bit, C function, C function with string args, - * Javascript function, Floating point number, boolean value, Undefined - * value and the Null value. - * - * Variables have names while objects may be referenced by multiple variables. - * Objects use reference counting for garbage collection. - * - * This module is not thread safe for performance and compactness. It relies - * on upper modules to provide thread synchronization as required. The API - * provides primitives to get variable/object references or to get copies of - * variables which will help minimize required lock times. - */ - -#ifndef _h_MPR_VAR -#define _h_MPR_VAR 1 - -/********************************* Includes ***********************************/ - -#include "miniMpr.h" - -/********************************** Defines ***********************************/ - -/* - * Define VAR_DEBUG if you want to track objects. However, this code is not - * thread safe and you need to run the server single threaded. - * - * #define VAR_DEBUG 1 - */ - -#ifdef __cplusplus -extern "C" { -#endif -/* - * Forward declare types - */ -struct MprProperties; -struct MprVar; - -/* - * Possible variable types. Don't use enum because we need to be able to - * do compile time conditional compilation on BLD_FEATURE_NUM_TYPE_ID. - */ -typedef int MprType; -#define MPR_TYPE_UNDEFINED 0 /* Undefined. No value has been set. */ -#define MPR_TYPE_NULL 1 /* Value defined to be null. */ -#define MPR_TYPE_BOOL 2 /* Boolean type. */ -#define MPR_TYPE_CFUNCTION 3 /* C function or C++ method */ -#define MPR_TYPE_FLOAT 4 /* Floating point number */ -#define MPR_TYPE_INT 5 /* Integer number */ -#define MPR_TYPE_INT64 6 /* 64-bit Integer number */ -#define MPR_TYPE_OBJECT 7 /* Object reference */ -#define MPR_TYPE_FUNCTION 8 /* JavaScript function */ -#define MPR_TYPE_STRING 9 /* String (immutable) */ -#define MPR_TYPE_STRING_CFUNCTION 10 /* C/C++ function with string args */ -#define MPR_TYPE_PTR 11 /* Opaque pointer */ - -/* - * Create a type for the default number type - * Config.h will define the default number type. For example: - * - * BLD_FEATURE_NUM_TYPE=int - * BLD_FEATURE_NUM_TYPE_ID=MPR_TYPE_INT - */ - -/** - * Set to the type used for MPR numeric variables. Will equate to int, int64 - * or double. - */ -typedef BLD_FEATURE_NUM_TYPE MprNum; - -/** - * Set to the MPR_TYPE used for MPR numeric variables. Will equate to - * MPR_TYPE_INT, MPR_TYPE_INT64 or MPR_TYPE_FLOAT. - */ -#define MPR_NUM_VAR BLD_FEATURE_NUM_TYPE_ID -#define MPR_TYPE_NUM BLD_FEATURE_NUM_TYPE_ID - -/* - * Return TRUE if a variable is a function type - */ -#define mprVarIsFunction(type) \ - (type == MPR_TYPE_FUNCTION || type == MPR_TYPE_STRING_CFUNCTION || \ - type == MPR_TYPE_CFUNCTION) - -/* - * Return TRUE if a variable is a numeric type - */ -#define mprVarIsNumber(type) \ - (type == MPR_TYPE_INT || type == MPR_TYPE_INT64 || type == MPR_TYPE_FLOAT) - -/* - * Return TRUE if a variable is a boolean - */ -#define mprVarIsBoolean(type) \ - (type == MPR_TYPE_BOOL) -#define mprVarIsString(type) \ - (type == MPR_TYPE_STRING) -#define mprVarIsObject(type) \ - (type == MPR_TYPE_OBJECT) -#define mprVarIsFloating(type) \ - (type == MPR_TYPE_FLOAT) -#define mprVarIsPtr(type) \ - (type == MPR_TYPE_PTR) -#define mprVarIsUndefined(var) \ - ((var)->type == MPR_TYPE_UNDEFINED) -#define mprVarIsNull(var) \ - ((var)->type == MPR_TYPE_NULL) -#define mprVarIsValid(var) \ - (((var)->type != MPR_TYPE_NULL) && ((var)->type != MPR_TYPE_UNDEFINED)) - -#define MPR_VAR_MAX_RECURSE 5 /* Max object loops */ - -#if BLD_FEATURE_SQUEEZE -#define MPR_MAX_VAR 64 /* Max var full name */ -#else -#define MPR_MAX_VAR 512 -#endif - -/* - * Function signatures - */ -typedef int MprVarHandle; -typedef int (*MprCFunction)(MprVarHandle userHandle, int argc, - struct MprVar **argv); -typedef int (*MprStringCFunction)(MprVarHandle userHandle, int argc, - char **argv); - -/* - * Triggers - */ -typedef enum { - MPR_VAR_WRITE, /* This property is being updated */ - MPR_VAR_READ, /* This property is being read */ - MPR_VAR_CREATE_PROPERTY, /* A property is being created */ - MPR_VAR_DELETE_PROPERTY, /* A property is being deleted */ - MPR_VAR_DELETE /* This object is being deleted */ -} MprVarTriggerOp; - -/* - * Trigger function return codes. - */ -typedef enum { - MPR_TRIGGER_ABORT, /* Abort the current operation */ - MPR_TRIGGER_USE_NEW_VALUE, /* Proceed and use the newValue */ - MPR_TRIGGER_PROCEED /* Proceed with the operation */ -} MprVarTriggerStatus; - -/* - * The MprVarTrigger arguments have the following meaning: - * - * op The operation being performed. See MprVarTriggerOp. - * parentProperties Pointer to the MprProperties structure. - * vp Pointer to the property that registered the trigger. - * newValue New value (see below for more details). - * copyDepth Specify what data items to copy. - * - * For VAR_READ, newVar is set to a temporary variable that the trigger - * function may assign a value to be returned instead of the actual - * property value. - * For VAR_WRITE, newValue holds the new value. The old existing value may be - * accessed via vp. - * For DELETE_PROPERTY, vp is the property being deleted. newValue is null. - * For ADD_PROPERTY, vp is set to the property being added and newValue holds - * the new value. - */ -typedef MprVarTriggerStatus (*MprVarTrigger)(MprVarTriggerOp op, - struct MprProperties *parentProperties, struct MprVar *vp, - struct MprVar *newValue, int copyDepth); - -/* - * mprCreateFunctionVar flags - */ -/** Use the alternate handle on function callbacks */ -#define MPR_VAR_ALT_HANDLE 0x1 - -/** Use the script handle on function callbacks */ -#define MPR_VAR_SCRIPT_HANDLE 0x2 - -/* - * Useful define for the copyDepth argument - */ -/** Don't copy any data. Copy only the variable name */ -#define MPR_NO_COPY 0 - -/** Copy strings. Increment object reference counts. */ -#define MPR_SHALLOW_COPY 1 - -/** Copy strings and do complete object copies. */ -#define MPR_DEEP_COPY 2 - -/* - * GetFirst / GetNext flags - */ -/** Step into data properties. */ -#define MPR_ENUM_DATA 0x1 - -/** Step into functions properties. */ -#define MPR_ENUM_FUNCTIONS 0x2 - -/* - * Collection type to hold properties in an object - */ -typedef struct MprProperties { /* Collection of properties */ -#if VAR_DEBUG - struct MprProperties *next; /* Linked list */ - struct MprProperties *prev; /* Linked list */ - char name[32]; /* Debug name */ -#endif - struct MprVar **buckets; /* Hash chains */ - int numItems; /* Total count of items */ - /* FUTURE - Better way of doing this */ - int numDataItems; /* Enumerable data items */ - uint hashSize : 8; /* Size of the hash table */ - /* FUTURE -- increase size of refCount */ - uint refCount : 8; /* References to this property*/ - /* FUTURE - make these flags */ - uint deleteProtect : 8; /* Don't recursively delete */ - uint visited : 8; /* Node has been processed */ -} MprProperties; - -/* - * Universal Variable Type - */ -typedef struct MprVar { - /* FUTURE - remove name to outside reference */ - MprStr name; /* Property name */ - /* FUTURE - remove */ - MprStr fullName; /* Full object name */ - /* FUTURE - make part of the union */ - MprProperties *properties; /* Pointer to properties */ - - /* - * Packed bit field - */ - MprType type : 8; /* Selector into union */ - uint bucketIndex : 8; /* Copy of bucket index */ - - uint flags : 5; /* Type specific flags */ - uint allocatedData : 1; /* Data needs freeing */ - uint readonly : 1; /* Unmodifiable */ - uint deleteProtect : 1; /* Don't recursively delete */ - - uint visited : 1; /* Node has been processed */ - uint allocatedVar : 1; /* Var needs freeing */ - uint spare : 6; /* Unused */ - - struct MprVar *forw; /* Hash table linkage */ - MprVarTrigger trigger; /* Trigger function */ - -#if UNUSED && KEEP - struct MprVar *baseClass; /* Pointer to class object */ -#endif - MprProperties *parentProperties; /* Pointer to parent object */ - - /* - * Union of primitive types. When debugging on Linux, don't use unions - * as the gdb debugger can't display them. - */ -#if 0 && !BLD_DEBUG && !LINUX && !VXWORKS - union { -#endif - bool boolean; -#if BLD_FEATURE_FLOATING_POINT - double floating; -#endif - int integer; -#if BLD_FEATURE_INT64 - int64 integer64; -#endif - struct { /* Javascript functions */ - MprArray *args; /* Null terminated */ - char *body; - } function; - struct { /* Function with MprVar args */ - MprCFunction fn; - void *thisPtr; - } cFunction; - struct { /* Function with string args */ - MprStringCFunction fn; - void *thisPtr; - } cFunctionWithStrings; - MprStr string; /* Allocated string */ - void *ptr; /* Opaque pointer */ -#if 0 && !BLD_DEBUG && !LINUX && !VXWORKS - }; -#endif -} MprVar; - -/* - * Define a field macro so code an use numbers in a "generic" fashion. - */ -#if MPR_NUM_VAR == MPR_TYPE_INT || DOXYGEN -/* Default numeric type */ -#define mprNumber integer -#endif -#if MPR_NUM_VAR == MPR_TYPE_INT64 -/* Default numeric type */ -#define mprNumber integer64 -#endif -#if MPR_NUM_VAR == MPR_TYPE_FLOAT -/* Default numeric type */ -#define mprNumber floating -#endif - -typedef BLD_FEATURE_NUM_TYPE MprNumber; - -/********************************* Prototypes *********************************/ -/* - * Variable constructors and destructors - */ -extern MprVar mprCreateObjVar(const char *name, int hashSize); -extern MprVar mprCreateBoolVar(bool value); -extern MprVar mprCreateCFunctionVar(MprCFunction fn, void *thisPtr, - int flags); -#if BLD_FEATURE_FLOATING_POINT -extern MprVar mprCreateFloatVar(double value); -#endif -extern MprVar mprCreateIntegerVar(int value); -#if BLD_FEATURE_INT64 -extern MprVar mprCreateInteger64Var(int64 value); -#endif -extern MprVar mprCreateFunctionVar(char *args, char *body, int flags); -extern MprVar mprCreateNullVar(void); -extern MprVar mprCreateNumberVar(MprNumber value); -extern MprVar mprCreateStringCFunctionVar(MprStringCFunction fn, - void *thisPtr, int flags); -extern MprVar mprCreateStringVar(const char *value, bool allocate); -extern MprVar mprCreateUndefinedVar(void); -extern MprVar mprCreatePtrVar(void *ptr); -extern bool mprDestroyVar(MprVar *vp); -extern bool mprDestroyAllVars(MprVar* vp); -extern MprType mprGetVarType(MprVar *vp); - -/* - * Copy - */ -extern void mprCopyVar(MprVar *dest, MprVar *src, int copyDepth); -extern void mprCopyVarValue(MprVar *dest, MprVar src, int copyDepth); -extern MprVar *mprDupVar(MprVar *src, int copyDepth); - -/* - * Manage vars - */ -extern MprVarTrigger - mprAddVarTrigger(MprVar *vp, MprVarTrigger fn); -extern int mprGetVarRefCount(MprVar *vp); -extern void mprSetVarDeleteProtect(MprVar *vp, int deleteProtect); -extern void mprSetVarFullName(MprVar *vp, char *name); -extern void mprSetVarReadonly(MprVar *vp, int readonly); -extern void mprSetVarName(MprVar *vp, char *name); - -/* - * Create properties and return a reference to the property. - */ -extern MprVar *mprCreateProperty(MprVar *obj, const char *property, - MprVar *newValue); -extern MprVar *mprCreatePropertyValue(MprVar *obj, const char *property, - MprVar newValue); -extern int mprDeleteProperty(MprVar *obj, const char *property); - -/* - * Get/Set properties. Set will update/create. - */ -extern MprVar *mprGetProperty(MprVar *obj, const char *property, - MprVar *value); -extern MprVar *mprSetProperty(MprVar *obj, const char *property, - MprVar *value); -extern MprVar *mprSetPropertyValue(MprVar *obj, const char *property, - MprVar value); - -/* - * Directly read/write property values (the property must already exist) - * For mprCopyProperty, mprDestroyVar must always called on the var. - */ -extern int mprReadProperty(MprVar *prop, MprVar *value); -extern int mprWriteProperty(MprVar *prop, MprVar *newValue); -extern int mprWritePropertyValue(MprVar *prop, MprVar newValue); - -/* - * Copy a property. NOTE: reverse of most other args: (dest, src) - */ -extern int mprCopyProperty(MprVar *dest, MprVar *prop, int copyDepth); - -/* - * Enumerate properties - */ -extern MprVar *mprGetFirstProperty(MprVar *obj, int includeFlags); -extern MprVar *mprGetNextProperty(MprVar *obj, MprVar *currentProperty, - int includeFlags); - -/* - * Query properties characteristics - */ -extern int mprGetPropertyCount(MprVar *obj, int includeFlags); - -/* - * Conversion routines - */ -extern MprVar mprParseVar(char *str, MprType prefType); -extern MprNum mprVarToNumber(const MprVar *vp); -extern int mprVarToInteger(const MprVar *vp); -#if BLD_FEATURE_INT64 -extern int64 mprVarToInteger64(const MprVar *vp); -#endif -extern bool mprVarToBool(const MprVar *vp); -#if BLD_FEATURE_FLOATING_POINT -extern double mprVarToFloat(const MprVar *vp); -#endif -extern void mprVarToString(char** buf, int size, char *fmt, MprVar *vp); - -/* - * Parsing and utility routines - */ -extern MprNum mprParseNumber(char *str); -extern int mprParseInteger(char *str); - -#if BLD_FEATURE_INT64 -extern int64 mprParseInteger64(char *str); -#endif - -#if BLD_FEATURE_FLOATING_POINT -extern double mprParseFloat(char *str); -extern bool mprIsInfinite(double f); -extern bool mprIsNan(double f); -#endif - -#if VAR_DEBUG -extern void mprPrintObjects(char *msg); -extern void mprPrintObjRefCount(MprVar *vp); -#endif - -#ifdef __cplusplus -} -#endif - -/*****************************************************************************/ -#endif /* _h_MPR_VAR */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim:tw=78 - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/source4/lib/charset/charset.h b/source4/lib/charset/charset.h index c49745cd7f..041eaeace7 100644 --- a/source4/lib/charset/charset.h +++ b/source4/lib/charset/charset.h @@ -97,6 +97,7 @@ size_t count_chars_w(const char *s, char c); void strupper_m(char *s); void strlower_m(char *s); char *strupper_talloc(TALLOC_CTX *ctx, const char *src); +char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *src); char *strupper_talloc_n(TALLOC_CTX *ctx, const char *src, size_t n); char *strlower_talloc(TALLOC_CTX *ctx, const char *src); bool strhasupper(const char *string); @@ -146,4 +147,8 @@ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx, const char *dos_charset, const char *unix_charset, bool native_iconv); + +void load_case_tables(void); +bool charset_register_backend(const void *_funcs); + #endif /* __CHARSET_H__ */ diff --git a/source4/lib/charset/iconv.c b/source4/lib/charset/iconv.c index d4f930b462..150383e7f9 100644 --- a/source4/lib/charset/iconv.c +++ b/source4/lib/charset/iconv.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "system/iconv.h" #include "system/filesys.h" #include "param/param.h" diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c index 09ec7b0471..e4f4bb551a 100644 --- a/source4/lib/charset/util_unistr.c +++ b/source4/lib/charset/util_unistr.c @@ -37,7 +37,7 @@ static void *lowcase_table; /******************************************************************* load the case handling tables ********************************************************************/ -static void load_case_tables(void) +void load_case_tables(void) { TALLOC_CTX *mem_ctx; @@ -386,6 +386,9 @@ _PUBLIC_ size_t strlen_m_term(const char *s) **/ _PUBLIC_ char *strchr_m(const char *s, char c) { + if (s == NULL) { + return NULL; + } /* characters below 0x3F are guaranteed to not appear in non-initial position in multi-byte charsets */ if ((c & 0xC0) == 0) { @@ -411,6 +414,10 @@ _PUBLIC_ char *strrchr_m(const char *s, char c) { char *ret = NULL; + if (s == NULL) { + return NULL; + } + /* characters below 0x3F are guaranteed to not appear in non-initial position in multi-byte charsets */ if ((c & 0xC0) == 0) { @@ -570,7 +577,13 @@ _PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) return strupper_talloc_n(ctx, src, src?strlen(src):0); } - +/** + talloc_strdup() a unix string to upper case. +**/ +_PUBLIC_ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *src) +{ + return strupper_talloc(ctx, src); +} /** Convert a string to lower case. diff --git a/source4/lib/cmdline/credentials.c b/source4/lib/cmdline/credentials.c index 2e5c6fd94a..f919842e6a 100644 --- a/source4/lib/cmdline/credentials.c +++ b/source4/lib/cmdline/credentials.c @@ -20,6 +20,7 @@ #include "includes.h" #include "system/filesys.h" #include "auth/credentials/credentials.h" +#include "lib/cmdline/credentials.h" static const char *cmdline_get_userpassword(struct cli_credentials *credentials) { diff --git a/source4/lib/cmdline/popt_common.h b/source4/lib/cmdline/popt_common.h index df432bb475..733d12a443 100644 --- a/source4/lib/cmdline/popt_common.h +++ b/source4/lib/cmdline/popt_common.h @@ -36,4 +36,6 @@ extern struct poptOption popt_common_credentials[]; extern struct cli_credentials *cmdline_credentials; extern struct loadparm_context *cmdline_lp_ctx; +void popt_common_dont_ask(void); + #endif /* _POPT_COMMON_H */ diff --git a/source4/lib/com/README b/source4/lib/com/README new file mode 100644 index 0000000000..361024e02c --- /dev/null +++ b/source4/lib/com/README @@ -0,0 +1,9 @@ +This directory contains Samba's very simple COM implementation. +It is by no means finished yet. + +The main aim of this implementation is for use by our DCOM implementation, +which lives in the dcom subdirectory. The local version is used mostly for +testing. + +More information on this effort can be found in the DCOM whitepaper in +the lorikeet repository. diff --git a/source4/lib/com/classes/simple.c b/source4/lib/com/classes/simple.c new file mode 100644 index 0000000000..295f113207 --- /dev/null +++ b/source4/lib/com/classes/simple.c @@ -0,0 +1,122 @@ +/* + Unix SMB/CIFS implementation. + Simple class + Copyright (C) 2004-2005 Jelmer Vernooij + + 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" +#include "lib/com/com.h" +#include "librpc/gen_ndr/com_dcom.h" + +static struct IClassFactory_vtable simple_classobject_vtable; +static struct IStream_vtable simple_IStream_vtable; + +static WERROR simple_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun) +{ + *iun = d; + return WERR_OK; +} + +static uint32_t simple_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +static uint32_t simple_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +static WERROR simple_IStream_Read (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *pv, uint32_t num_requested, uint32_t *num_readx, uint32_t num_read) +{ + printf("%d bytes are being read\n", num_read); + return WERR_OK; +} + +static WERROR simple_IStream_Write (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t num_requested, uint32_t num_written) +{ + printf("%d bytes are being written\n", num_requested); + return WERR_OK; +} + +static WERROR simpleclass_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun) +{ + /* FIXME: Return WERR_IFACE_NOT_SUPPORTED if IID != IID_IUNKNOWN and IID != IID_CLASSFACTORY */ + *iun = d; + return WERR_OK; +} + +static WERROR simpleclass_IClassFactory_CreateInstance (struct IClassFactory *d, TALLOC_CTX *mem_ctx, struct IUnknown *iunk, struct GUID *iid, struct IUnknown **ppv) +{ + struct IStream *ret; + /* FIXME: Check whether IID == ISTREAM_IID */ + ret = talloc(mem_ctx, struct IStream); + ret->ctx = NULL; + ret->vtable = &simple_IStream_vtable; + ret->object_data = NULL; + + *ppv = (struct IUnknown *)ret; + + return WERR_OK; +} + +static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +static uint32_t simpleclass_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +/* Everything below this line should be autogenerated later on */ +static struct IClassFactory_vtable simple_classobject_vtable = { + { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } }, + simpleclass_IUnknown_QueryInterface, + simpleclass_IUnknown_AddRef, + simpleclass_IUnknown_Release, + simpleclass_IClassFactory_CreateInstance, + NULL, + NULL, + NULL +}; + +static struct IStream_vtable simple_IStream_vtable = { + { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } }, + simple_IUnknown_QueryInterface, + simple_IUnknown_AddRef, + simple_IUnknown_Release, + simple_IStream_Read, + simple_IStream_Write +}; + +NTSTATUS com_simple_init(void) +{ + struct GUID clsid; + struct IUnknown *class_object = talloc(talloc_autofree_context(), struct IUnknown); + + class_object->ctx = NULL; + class_object->object_data = NULL; + class_object->vtable = (struct IUnknown_vtable *)&simple_classobject_vtable; + + GUID_from_string(CLSID_SIMPLE, &clsid); + GUID_from_string(COM_ICLASSFACTORY_UUID, &simple_classobject_vtable.iid); + GUID_from_string(COM_ISTREAM_UUID, &simple_IStream_vtable.iid); + + return com_register_running_class(&clsid, PROGID_SIMPLE, class_object); +} diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h new file mode 100644 index 0000000000..5d594ad41b --- /dev/null +++ b/source4/lib/com/com.h @@ -0,0 +1,52 @@ +/* + Unix SMB/CIFS implementation. + Utility functions for Samba + Copyright (C) Jelmer Vernooij 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 . +*/ + +#ifndef __SAMBA_COM_H__ +#define __SAMBA_COM_H__ + +#include "librpc/gen_ndr/misc.h" + +struct com_context; +struct event_context; + +struct com_context +{ + struct dcom_client_context *dcom; + struct event_context *event_ctx; + struct com_extension { + uint32_t id; + void *data; + struct com_extension *prev, *next; + } *extensions; + struct loadparm_context *lp_ctx; +}; + +struct IUnknown *com_class_by_clsid(struct com_context *ctx, const struct GUID *clsid); +NTSTATUS com_register_running_class(struct GUID *clsid, const char *progid, struct IUnknown *p); + +struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid); + +WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx); +WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results); +WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip); +NTSTATUS com_init(void); + +typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid); + +#endif /* __SAMBA_COM_H__ */ diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk new file mode 100644 index 0000000000..73836ef5f8 --- /dev/null +++ b/source4/lib/com/config.mk @@ -0,0 +1,22 @@ +[SUBSYSTEM::COM] +PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBEVENTS LIBNDR + +COM_OBJ_FILES = $(addprefix $(comsrcdir)/, tables.o rot.o main.o) + +[SUBSYSTEM::DCOM] +PUBLIC_DEPENDENCIES = COM DCOM_PROXY_DCOM RPC_NDR_REMACT \ + RPC_NDR_OXIDRESOLVER + +DCOM_OBJ_FILES = $(addprefix $(comsrcdir)/dcom/, main.o tables.o) + +[MODULE::com_simple] +SUBSYSTEM = COM +INIT_FUNCTION = com_simple_init + +com_simple_OBJ_FILES = $(comsrcdir)/classes/simple.o + +[PYTHON::pycom] +LIBRARY_REALNAME = samba/com.$(SHLIBEXT) +PRIVATE_DEPENDENCIES = COM + +pycom_OBJ_FILES = $(comsrcdir)/pycom.o diff --git a/source4/lib/com/dcom/dcom.h b/source4/lib/com/dcom/dcom.h new file mode 100644 index 0000000000..56d6eac93c --- /dev/null +++ b/source4/lib/com/dcom/dcom.h @@ -0,0 +1,85 @@ +/* + Unix SMB/CIFS implementation. + COM standard objects + Copyright (C) Jelmer Vernooij 2004-2005. + + 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. +*/ + +#ifndef _DCOM_H /* _DCOM_H */ +#define _DCOM_H + +struct cli_credentials; +struct dcerpc_pipe; + +#include "lib/com/com.h" +#include "librpc/gen_ndr/orpc.h" + +struct dcom_client_context { + struct dcom_server_credentials { + const char *server; + struct cli_credentials *credentials; + struct dcom_server_credentials *prev, *next; + } *credentials; + struct dcom_object_exporter { + uint64_t oxid; + char *host; + struct IRemUnknown *rem_unknown; + struct DUALSTRINGARRAY *bindings; + struct dcerpc_pipe *pipe; + struct dcom_object_exporter *prev, *next; + } *object_exporters; +}; + +typedef enum ndr_err_code (*marshal_fn)(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struct OBJREF *o); +typedef enum ndr_err_code (*unmarshal_fn)(TALLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown **pv); + + +struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials); +struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, uint64_t oxid); +struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip); +WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results); +WERROR dcom_get_class_object(struct com_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct IUnknown **ip); +NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp); +NTSTATUS dcom_OBJREF_from_IUnknown(struct OBJREF *o, struct IUnknown *p); +NTSTATUS dcom_IUnknown_from_OBJREF(TALLOC_CTX *mem_ctx, struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o); +uint64_t dcom_get_current_oxid(void); +void dcom_add_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials); +WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results); + +#include "librpc/gen_ndr/com_dcom.h" + +NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable); +struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid); +NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal); + +#include "libcli/composite/composite.h" +void dcom_release_continue(struct composite_context *cr); +#define IUnknown_ipid(d) ((d)->obj.u_objref.u_standard.std.ipid) +struct composite_context *dcom_release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx); +marshal_fn dcom_marshal_by_clsid(struct GUID *clsid); +unmarshal_fn dcom_unmarshal_by_clsid(struct GUID *clsid); + +struct dcom_proxy_async_call_state { + struct IUnknown *d; + const struct ndr_interface_table *table; + uint32_t opnum; + void (*continuation)(struct rpc_request *); + TALLOC_CTX *mem_ctx; + void *r; +}; + + +#endif /* _DCOM_H */ diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c new file mode 100644 index 0000000000..695bfa7f98 --- /dev/null +++ b/source4/lib/com/dcom/main.c @@ -0,0 +1,710 @@ +/* + Unix SMB/CIFS implementation. + Main DCOM functionality + Copyright (C) 2004 Jelmer Vernooij + Copyright (C) 2006 Andrzej Hajda + + 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" +#include "system/filesys.h" +#include "librpc/gen_ndr/epmapper.h" +#include "librpc/gen_ndr/ndr_remact_c.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "librpc/gen_ndr/dcom.h" +#include "librpc/rpc/dcerpc.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/ndr/ndr_table.h" +#include "../lib/util/dlinklist.h" +#include "auth/credentials/credentials.h" +#include "libcli/composite/composite.h" + +#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC } + +static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dcerpc_binding **b_out, struct STRINGBINDING *bd) +{ + char *host, *endpoint; + struct dcerpc_binding *b; + + b = talloc_zero(mem_ctx, struct dcerpc_binding); + if (!b) { + return NT_STATUS_NO_MEMORY; + } + + b->transport = dcerpc_transport_by_endpoint_protocol(bd->wTowerId); + + if (b->transport == -1) { + DEBUG(1, ("Can't find transport match endpoint protocol %d\n", bd->wTowerId)); + talloc_free(b); + return NT_STATUS_NOT_SUPPORTED; + } + + host = talloc_strdup(b, bd->NetworkAddr); + endpoint = strchr(host, '['); + + if (endpoint) { + *endpoint = '\0'; + endpoint++; + + endpoint[strlen(endpoint)-1] = '\0'; + } + + b->host = host; + b->endpoint = talloc_strdup(b, endpoint); + + *b_out = b; + return NT_STATUS_OK; +} + +struct cli_credentials *dcom_get_server_credentials(struct com_context *ctx, const char *server) +{ + struct dcom_server_credentials *c; + struct cli_credentials *d; + + d = NULL; + for (c = ctx->dcom->credentials; c; c = c->next) { + if (c->server == NULL) { + d = c->credentials; + continue; + } + if (server && !strcmp(c->server, server)) return c->credentials; + } + return d; +} + +/** + * Register credentials for a specific server. + * + * @param ctx COM context + * @param server Name of server, can be NULL + * @param credentials Credentials object + */ +void dcom_add_server_credentials(struct com_context *ctx, const char *server, + struct cli_credentials *credentials) +{ + struct dcom_server_credentials *c; + + /* FIXME: Don't use talloc_find_parent_bytype */ + for (c = ctx->dcom->credentials; c; c = c->next) { + if ((server == NULL && c->server == NULL) || + (server != NULL && c->server != NULL && + !strcmp(c->server, server))) { + if (c->credentials && c->credentials != credentials) { + talloc_unlink(c, c->credentials); + c->credentials = credentials; + if (talloc_find_parent_bytype(c->credentials, struct dcom_server_credentials)) + (void)talloc_reference(c, c->credentials); + else + talloc_steal(c, c->credentials); + } + + return; + } + } + + c = talloc(ctx->event_ctx, struct dcom_server_credentials); + c->server = talloc_strdup(c, server); + c->credentials = credentials; + if (talloc_find_parent_bytype(c->credentials, struct dcom_server_credentials)) + (void)talloc_reference(c, c->credentials); + else + talloc_steal(c, c->credentials); + + DLIST_ADD(ctx->dcom->credentials, c); +} + +void dcom_update_credentials_for_aliases(struct com_context *ctx, + const char *server, + struct DUALSTRINGARRAY *pds) +{ + struct cli_credentials *cc; + struct dcerpc_binding *b; + uint32_t i; + NTSTATUS status; + + cc = dcom_get_server_credentials(ctx, server); + for (i = 0; pds->stringbindings[i]; ++i) { + if (pds->stringbindings[i]->wTowerId != EPM_PROTOCOL_TCP) + continue; + status = dcerpc_binding_from_STRINGBINDING(ctx, &b, pds->stringbindings[i]); + if (!NT_STATUS_IS_OK(status)) + continue; + dcom_add_server_credentials(ctx, b->host, cc); + talloc_free(b); + } +} + +struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials) +{ + ctx->dcom = talloc_zero(ctx, struct dcom_client_context); + if (!credentials) { + credentials = cli_credentials_init(ctx); + cli_credentials_set_conf(credentials, ctx->lp_ctx); + cli_credentials_parse_string(credentials, "%", CRED_SPECIFIED); + } + dcom_add_server_credentials(ctx, NULL, credentials); + return ctx->dcom; +} + +static NTSTATUS dcom_connect_host(struct com_context *ctx, + struct dcerpc_pipe **p, const char *server) +{ + struct dcerpc_binding *bd; + const char * available_transports[] = { "ncacn_ip_tcp", "ncacn_np" }; + int i; + NTSTATUS status; + TALLOC_CTX *loc_ctx; + + if (server == NULL) { + return dcerpc_pipe_connect(ctx->event_ctx, p, "ncalrpc", + &ndr_table_IRemoteActivation, + dcom_get_server_credentials(ctx, NULL), ctx->event_ctx, ctx->lp_ctx); + } + loc_ctx = talloc_new(ctx); + + /* Allow server name to contain a binding string */ + if (strchr(server, ':') && + NT_STATUS_IS_OK(dcerpc_parse_binding(loc_ctx, server, &bd))) { + if (DEBUGLVL(11)) + bd->flags |= DCERPC_DEBUG_PRINT_BOTH; + status = dcerpc_pipe_connect_b(ctx->event_ctx, p, bd, + &ndr_table_IRemoteActivation, + dcom_get_server_credentials(ctx, bd->host), ctx->event_ctx, ctx->lp_ctx); + goto end; + } + + for (i = 0; i < ARRAY_SIZE(available_transports); i++) + { + char *binding = talloc_asprintf(loc_ctx, "%s:%s", available_transports[i], server); + if (!binding) { + status = NT_STATUS_NO_MEMORY; + goto end; + } + status = dcerpc_pipe_connect(ctx->event_ctx, p, binding, + &ndr_table_IRemoteActivation, + dcom_get_server_credentials(ctx, server), + ctx->event_ctx, ctx->lp_ctx); + + if (NT_STATUS_IS_OK(status)) { + if (DEBUGLVL(11)) + (*p)->conn->flags |= DCERPC_DEBUG_PRINT_BOTH; + goto end; + } else { + DEBUG(1,(__location__": dcom_connect_host : %s\n", get_friendly_nt_error_msg(status))); + } + } + +end: + talloc_free(loc_ctx); + return status; +} + +struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, + uint64_t oxid) +{ + struct dcom_object_exporter *ox; + for (ox = ctx->dcom->object_exporters; ox; ox = ox->next) { + if (ox->oxid == oxid) { + return ox; + } + } + + return NULL; +} + +struct dcom_object_exporter *object_exporter_update_oxid(struct com_context *ctx, uint64_t oxid, struct DUALSTRINGARRAY *bindings) +{ + struct dcom_object_exporter *ox; + ox = object_exporter_by_oxid(ctx, oxid); + if (!ox) { + ox = talloc_zero(ctx, struct dcom_object_exporter); + DLIST_ADD(ctx->dcom->object_exporters, ox); + ox->oxid = oxid; + } else { + talloc_free(ox->bindings); + } + ox->bindings = bindings; + talloc_steal(ox, bindings); + return ox; +} + +struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip) +{ + return object_exporter_by_oxid(ctx, ip->obj.u_objref.u_standard.std.oxid); +} + +WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results) +{ + uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS; + struct dcerpc_pipe *p; + struct dcom_object_exporter *m; + NTSTATUS status; + struct RemoteActivation r; + struct DUALSTRINGARRAY *pds; + int i; + WERROR hr; + uint64_t oxid; + struct GUID ipidRemUnknown; + struct IUnknown *ru_template; + struct ORPCTHAT that; + uint32_t AuthnHint; + struct COMVERSION ServerVersion; + struct MInterfacePointer **ifaces; + TALLOC_CTX *loc_ctx; + + status = dcom_connect_host(ctx, &p, server); + if (NT_STATUS_IS_ERR(status)) { + DEBUG(1, ("Unable to connect to %s - %s\n", server, get_friendly_nt_error_msg(status))); + return ntstatus_to_werror(status); + } + loc_ctx = talloc_new(ctx); + + ifaces = talloc_array(loc_ctx, struct MInterfacePointer *, num_ifaces); + + ZERO_STRUCT(r.in); + r.in.this.version.MajorVersion = COM_MAJOR_VERSION; + r.in.this.version.MinorVersion = COM_MINOR_VERSION; + r.in.this.cid = GUID_random(); + r.in.Clsid = *clsid; + r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; + r.in.num_protseqs = ARRAY_SIZE(protseq); + r.in.protseq = protseq; + r.in.Interfaces = num_ifaces; + r.in.pIIDs = iid; + r.out.that = &that; + r.out.pOxid = &oxid; + r.out.pdsaOxidBindings = &pds; + r.out.ipidRemUnknown = &ipidRemUnknown; + r.out.AuthnHint = &AuthnHint; + r.out.ServerVersion = &ServerVersion; + r.out.hr = &hr; + r.out.ifaces = ifaces; + r.out.results = results; + + status = dcerpc_RemoteActivation(p, loc_ctx, &r); + talloc_free(p); + + if(NT_STATUS_IS_ERR(status)) { + DEBUG(1, ("Error while running RemoteActivation %s\n", nt_errstr(status))); + hr = ntstatus_to_werror(status); + goto end; + } + + if(!W_ERROR_IS_OK(r.out.result)) { + hr = r.out.result; + goto end; + } + + if(!W_ERROR_IS_OK(hr)) { + goto end; + } + + m = object_exporter_update_oxid(ctx, oxid, pds); + + ru_template = NULL; + *ip = talloc_array(ctx, struct IUnknown *, num_ifaces); + for (i = 0; i < num_ifaces; i++) { + (*ip)[i] = NULL; + if (W_ERROR_IS_OK(results[i])) { + status = dcom_IUnknown_from_OBJREF(ctx, &(*ip)[i], &r.out.ifaces[i]->obj); + if (!NT_STATUS_IS_OK(status)) { + results[i] = ntstatus_to_werror(status); + } else if (!ru_template) + ru_template = (*ip)[i]; + } + } + + /* TODO:avg check when exactly oxid should be updated,its lifetime etc */ + if (m->rem_unknown && memcmp(&m->rem_unknown->obj.u_objref.u_standard.std.ipid, &ipidRemUnknown, sizeof(ipidRemUnknown))) { + talloc_free(m->rem_unknown); + m->rem_unknown = NULL; + } + if (!m->rem_unknown) { + if (!ru_template) { + DEBUG(1,("dcom_create_object: Cannot Create IRemUnknown - template interface not available\n")); + hr = WERR_GENERAL_FAILURE; + } + m->rem_unknown = talloc_zero(m, struct IRemUnknown); + memcpy(m->rem_unknown, ru_template, sizeof(struct IUnknown)); + GUID_from_string(COM_IREMUNKNOWN_UUID, &m->rem_unknown->obj.iid); + m->rem_unknown->obj.u_objref.u_standard.std.ipid = ipidRemUnknown; + m->rem_unknown->vtable = (struct IRemUnknown_vtable *)dcom_proxy_vtable_by_iid(&m->rem_unknown->obj.iid); + /* TODO:avg copy stringbindigs?? */ + } + + dcom_update_credentials_for_aliases(ctx, server, pds); + { + char *c; + c = strchr(server, '['); + if (m->host) talloc_free(m->host); + m->host = c ? talloc_strndup(m, server, c - server) : talloc_strdup(m, server); + } + hr = WERR_OK; +end: + talloc_free(loc_ctx); + return hr; +} + +int find_similar_binding(struct STRINGBINDING **sb, const char *host) +{ + int i, l; + l = strlen(host); + for (i = 0; sb[i]; ++i) { + if ((sb[i]->wTowerId == EPM_PROTOCOL_TCP) && !strncasecmp(host, sb[i]->NetworkAddr, l) && (sb[i]->NetworkAddr[l] == '[')) + break; + } + return i; +} + +WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results) +{ + struct dcom_object_exporter *ox; + struct REMQIRESULT *rqir; + WERROR result; + NTSTATUS status; + int i; + TALLOC_CTX *loc_ctx; + struct IUnknown ru; + + loc_ctx = talloc_new(d); + ox = object_exporter_by_ip(d->ctx, d); + + result = IRemUnknown_RemQueryInterface(ox->rem_unknown, loc_ctx, &IUnknown_ipid(d), cRefs, cIids, iids, &rqir); + if (!W_ERROR_IS_OK(result)) { + DEBUG(1, ("dcom_query_interface failed: %08X\n", W_ERROR_V(result))); + talloc_free(loc_ctx); + return result; + } + ru = *(struct IUnknown *)ox->rem_unknown; + for (i = 0; i < cIids; ++i) { + ip[i] = NULL; + results[i] = rqir[i].hResult; + if (W_ERROR_IS_OK(results[i])) { + ru.obj.iid = iids[i]; + ru.obj.u_objref.u_standard.std = rqir[i].std; + status = dcom_IUnknown_from_OBJREF(d->ctx, &ip[i], &ru.obj); + if (!NT_STATUS_IS_OK(status)) { + results[i] = ntstatus_to_werror(status); + } + } + } + + talloc_free(loc_ctx); + return WERR_OK; +} + +int is_ip_binding(const char* s) +{ + while (*s && (*s != '[')) { + if (((*s >= '0') && (*s <= '9')) || *s == '.') + ++s; + else + return 0; + } + return 1; +} + +NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp) +{ + struct dcerpc_binding *binding; + struct GUID iid; + uint64_t oxid; + NTSTATUS status; + int i, j, isimilar; + struct dcerpc_pipe *p; + struct dcom_object_exporter *ox; + const struct ndr_interface_table *table; + + ox = object_exporter_by_oxid(iface->ctx, iface->obj.u_objref.u_standard.std.oxid); + if (!ox) { + DEBUG(0, ("dcom_get_pipe: OXID not found\n")); + return NT_STATUS_NOT_SUPPORTED; + } + + p = ox->pipe; + + iid = iface->vtable->iid; + table = ndr_table_by_uuid(&iid); + if (table == NULL) { + char *guid_str; + guid_str = GUID_string(NULL, &iid); + DEBUG(0,(__location__": dcom_get_pipe - unrecognized interface{%s}\n", guid_str)); + talloc_free(guid_str); + return NT_STATUS_NOT_SUPPORTED; + } + + if (p && p->last_fault_code) { + talloc_free(p); + ox->pipe = p = NULL; + } + + if (p) { + if (!GUID_equal(&p->syntax.uuid, &iid)) { + ox->pipe->syntax.uuid = iid; + + /* interface will always be present, so + * idl_iface_by_uuid can't return NULL */ + /* status = dcerpc_secondary_context(p, &p2, idl_iface_by_uuid(&iid)); */ + status = dcerpc_alter_context(p, p, &ndr_table_by_uuid(&iid)->syntax_id, &p->transfer_syntax); + } else + status = NT_STATUS_OK; + *pp = p; + return status; + } + + status = NT_STATUS_NO_MORE_ENTRIES; + + /* To avoid delays whe connecting nonroutable bindings we 1st check binding starting with hostname */ + /* FIX:low create concurrent connections to all bindings, fastest wins - Win2k and newer does this way???? */ + isimilar = find_similar_binding(ox->bindings->stringbindings, ox->host); + DEBUG(1, (__location__": dcom_get_pipe: host=%s, similar=%s\n", ox->host, ox->bindings->stringbindings[isimilar] ? ox->bindings->stringbindings[isimilar]->NetworkAddr : "None")); + j = isimilar - 1; + for (i = 0; ox->bindings->stringbindings[i]; ++i) { + if (!ox->bindings->stringbindings[++j]) j = 0; + /* FIXME:LOW Use also other transports if possible */ + if ((j != isimilar) && (ox->bindings->stringbindings[j]->wTowerId != EPM_PROTOCOL_TCP || !is_ip_binding(ox->bindings->stringbindings[j]->NetworkAddr))) { + DEBUG(9, ("dcom_get_pipe: Skipping stringbinding %24.24s\n", ox->bindings->stringbindings[j]->NetworkAddr)); + continue; + } + DEBUG(9, ("dcom_get_pipe: Trying stringbinding %s\n", ox->bindings->stringbindings[j]->NetworkAddr)); + status = dcerpc_binding_from_STRINGBINDING(iface->ctx, &binding, + ox->bindings->stringbindings[j]); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Error parsing string binding")); + } else { + /* FIXME:LOW Make flags more flexible */ + binding->flags |= DCERPC_AUTH_NTLM | DCERPC_SIGN; + if (DEBUGLVL(11)) + binding->flags |= DCERPC_DEBUG_PRINT_BOTH; + status = dcerpc_pipe_connect_b(iface->ctx->event_ctx, &p, binding, + ndr_table_by_uuid(&iid), + dcom_get_server_credentials(iface->ctx, binding->host), + iface->ctx->event_ctx, iface->ctx->lp_ctx); + talloc_unlink(iface->ctx, binding); + } + if (NT_STATUS_IS_OK(status)) break; + } + + if (NT_STATUS_IS_ERR(status)) { + DEBUG(0, ("Unable to connect to remote host - %s\n", nt_errstr(status))); + return status; + } + + DEBUG(2, ("Successfully connected to OXID %llx\n", (long long)oxid)); + + ox->pipe = *pp = p; + + return NT_STATUS_OK; +} + +NTSTATUS dcom_OBJREF_from_IUnknown(TALLLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown *p) +{ + /* FIXME: Cache generated objref objects? */ + ZERO_STRUCTP(o); + + if (!p) { + o->signature = OBJREF_SIGNATURE; + o->flags = OBJREF_NULL; + } else { + *o = p->obj; + switch(o->flags) { + case OBJREF_CUSTOM: { + marshal_fn marshal; + + marshal = dcom_marshal_by_clsid(&o->u_objref.u_custom.clsid); + if (marshal) { + return marshal(mem_ctx, p, o); + } else { + return NT_STATUS_NOT_SUPPORTED; + } + } + } + } + + return NT_STATUS_OK; +} + +enum ndr_err_code dcom_IUnknown_from_OBJREF(struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o) +{ + struct IUnknown *p; + struct dcom_object_exporter *ox; + unmarshal_fn unmarshal; + + switch(o->flags) { + case OBJREF_NULL: + *_p = NULL; + return NDR_ERR_SUCCESS; + + case OBJREF_STANDARD: + p = talloc_zero(ctx, struct IUnknown); + p->ctx = ctx; + p->obj = *o; + p->vtable = dcom_proxy_vtable_by_iid(&o->iid); + + if (!p->vtable) { + DEBUG(0, ("Unable to find proxy class for interface with IID %s\n", GUID_string(ctx, &o->iid))); + return NDR_ERR_INVALID_POINTER; + } + + p->vtable->Release_send = dcom_release_send; + + ox = object_exporter_by_oxid(ctx, o->u_objref.u_standard.std.oxid); + /* FIXME: Add object to list of objects to ping */ + *_p = p; + return NDR_ERR_SUCCESS; + + case OBJREF_HANDLER: + p = talloc_zero(ctx, struct IUnknown); + p->ctx = ctx; + p->obj = *o; + ox = object_exporter_by_oxid(ctx, o->u_objref.u_handler.std.oxid ); + /* FIXME: Add object to list of objects to ping */ +/*FIXME p->vtable = dcom_vtable_by_clsid(&o->u_objref.u_handler.clsid);*/ + /* FIXME: Do the custom unmarshaling call */ + + *_p = p; + return NDR_ERR_BAD_SWITCH; + + case OBJREF_CUSTOM: + p = talloc_zero(ctx, struct IUnknown); + p->ctx = ctx; + p->vtable = NULL; + p->obj = *o; + unmarshal = dcom_unmarshal_by_clsid(&o->u_objref.u_custom.clsid); + *_p = p; + if (unmarshal) { + return unmarshal(ctx, o, _p); + } else { + return NDR_ERR_BAD_SWITCH; + } + } + + return NDR_ERR_BAD_SWITCH; +} + +uint64_t dcom_get_current_oxid(void) +{ + return getpid(); +} + +/* FIXME:Fake async dcom_get_pipe_* */ +struct composite_context *dcom_get_pipe_send(struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c; + + c = composite_create(0, d->ctx->event_ctx); + if (c == NULL) return NULL; + c->private_data = d; + /* composite_done(c); bugged - callback is triggered twice by composite_continue and composite_done */ + c->state = COMPOSITE_STATE_DONE; /* this is workaround */ + + return c; +} + +NTSTATUS dcom_get_pipe_recv(struct composite_context *c, struct dcerpc_pipe **pp) +{ + NTSTATUS status; + + status = dcom_get_pipe((struct IUnknown *)c->private_data, pp); + talloc_free(c); + + return status; +} + +/* FIXME:avg put IUnknown_Release_out into header */ +struct IUnknown_Release_out { + uint32_t result; +}; + +void dcom_release_continue(struct composite_context *cr) +{ + struct composite_context *c; + struct IUnknown *d; + struct IUnknown_Release_out *out; + WERROR r; + + c = talloc_get_type(cr->async.private_data, struct composite_context); + d = c->private_data; + r = IRemUnknown_RemRelease_recv(cr); + talloc_free(d); + out = talloc_zero(c, struct IUnknown_Release_out); + out->result = W_ERROR_V(r); + c->private_data = out; + composite_done(c); +} + +struct composite_context *dcom_release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c, *cr; + struct REMINTERFACEREF iref; + struct dcom_object_exporter *ox; + + c = composite_create(d->ctx, d->ctx->event_ctx); + if (c == NULL) return NULL; + c->private_data = d; + + ox = object_exporter_by_ip(d->ctx, d); + iref.ipid = IUnknown_ipid(d); + iref.cPublicRefs = 5; + iref.cPrivateRefs = 0; + cr = IRemUnknown_RemRelease_send(ox->rem_unknown, mem_ctx, 1, &iref); + + composite_continue(c, cr, dcom_release_continue, c); + return c; +} + +uint32_t dcom_release_recv(struct composite_context *c) +{ + NTSTATUS status; + WERROR r; + + status = composite_wait(c); + if (!NT_STATUS_IS_OK(status)) + r = ntstatus_to_werror(status); + else + W_ERROR_V(r) = ((struct IUnknown_Release_out *)c->private_data)->result; + talloc_free(c); + return W_ERROR_IS_OK(r) ? 0 : W_ERROR_V(r); +} + +uint32_t dcom_release(void *interface, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c; + + c = dcom_release_send(interface, mem_ctx); + return dcom_release_recv(c); +} + +void dcom_proxy_async_call_recv_pipe_send_rpc(struct composite_context *c_pipe) +{ + struct composite_context *c; + struct dcom_proxy_async_call_state *s; + struct dcerpc_pipe *p; + struct rpc_request *req; + NTSTATUS status; + + c = c_pipe->async.private_data; + s = talloc_get_type(c->private_data, struct dcom_proxy_async_call_state); + + status = dcom_get_pipe_recv(c_pipe, &p); + if (!NT_STATUS_IS_OK(status)) { + composite_error(c, NT_STATUS_RPC_NT_CALL_FAILED); + return; + } + + req = dcerpc_ndr_request_send(p, &s->d->obj.u_objref.u_standard.std.ipid, s->table, s->opnum, s, s->r); + composite_continue_rpc(c, req, s->continuation, c); +} diff --git a/source4/lib/com/dcom/tables.c b/source4/lib/com/dcom/tables.c new file mode 100644 index 0000000000..f94aa87925 --- /dev/null +++ b/source4/lib/com/dcom/tables.c @@ -0,0 +1,92 @@ +/* + Unix SMB/CIFS implementation. + DCOM proxy tables functionality + Copyright (C) 2005 Jelmer Vernooij + Copyright (C) 2006 Andrzej Hajda + + 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" +#include "../lib/util/dlinklist.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/com/dcom/dcom.h" + +static struct dcom_proxy { + struct IUnknown_vtable *vtable; + struct dcom_proxy *prev, *next; +} *proxies = NULL; + +NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable) +{ + struct dcom_proxy *proxy = talloc(talloc_autofree_context(), struct dcom_proxy); + + proxy->vtable = proxy_vtable; + DLIST_ADD(proxies, proxy); + + return NT_STATUS_OK; +} + +struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid) +{ + struct dcom_proxy *p; + for (p = proxies; p; p = p->next) { + if (GUID_equal(&p->vtable->iid, iid)) { + return p->vtable; + } + } + return NULL; +} + +static struct dcom_marshal { + struct GUID clsid; + marshal_fn marshal; + unmarshal_fn unmarshal; + struct dcom_marshal *prev, *next; +} *marshals = NULL; + +NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal) +{ + struct dcom_marshal *p = talloc(talloc_autofree_context(), struct dcom_marshal); + + p->clsid = *clsid; + p->marshal = marshal; + p->unmarshal = unmarshal; + DLIST_ADD(marshals, p); + return NT_STATUS_OK; +} + +_PUBLIC_ marshal_fn dcom_marshal_by_clsid(struct GUID *clsid) +{ + struct dcom_marshal *p; + for (p = marshals; p; p = p->next) { + if (GUID_equal(&p->clsid, clsid)) { + return p->marshal; + } + } + return NULL; +} + +_PUBLIC_ unmarshal_fn dcom_unmarshal_by_clsid(struct GUID *clsid) +{ + struct dcom_marshal *p; + for (p = marshals; p; p = p->next) { + if (GUID_equal(&p->clsid, clsid)) { + return p->unmarshal; + } + } + return NULL; +} + diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c new file mode 100644 index 0000000000..daed8c11e5 --- /dev/null +++ b/source4/lib/com/main.c @@ -0,0 +1,90 @@ +/* + Unix SMB/CIFS implementation. + Main COM functionality + Copyright (C) 2004 Jelmer Vernooij + + 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" +#include "../lib/util/dlinklist.h" +#include "lib/com/com.h" +#include "lib/events/events.h" +#include "librpc/gen_ndr/com_dcom.h" + +WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx) +{ + *ctx = talloc(NULL, struct com_context); + if (event_ctx == NULL) { + event_ctx = event_context_init(*ctx); + } + (*ctx)->event_ctx = event_ctx; + return WERR_OK; +} + +WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results) +{ + struct IUnknown *iunk = NULL; + struct IClassFactory *factory; + WERROR error; + int i; + struct GUID classfact_iid; + + GUID_from_string(NDR_ICLASSFACTORY_UUID, &classfact_iid); + + /* Obtain class object */ + error = com_get_class_object(ctx, clsid, &classfact_iid, (struct IUnknown **)&factory); + if (!W_ERROR_IS_OK(error)) { + DEBUG(3, ("Unable to obtain class object for %s\n", GUID_string(NULL, clsid))); + return error; + } + + /* Run IClassFactory::CreateInstance() */ + error = IClassFactory_CreateInstance(factory, ctx, NULL, &classfact_iid, &iunk); + if (!W_ERROR_IS_OK(error)) { + DEBUG(3, ("Error while calling IClassFactory::CreateInstance : %s\n", win_errstr(error))); + return error; + } + + if (!iunk) { + DEBUG(0, ("IClassFactory_CreateInstance returned success but result pointer is still NULL!\n")); + return WERR_GENERAL_FAILURE; + } + + /* Release class object */ + IUnknown_Release(factory, ctx); + + error = WERR_OK; + + /* Do one or more QueryInterface calls */ + for (i = 0; i < num_ifaces; i++) { + results[i] = IUnknown_QueryInterface(iunk, ctx, &iid[i], &ip[i]); + if (!W_ERROR_IS_OK(results[i])) error = results[i]; + } + + return error; +} + +WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip) +{ + struct IUnknown *iu; + + iu = com_class_by_clsid(ctx, clsid); + if (!iu) { + return WERR_CLASS_NOT_REGISTERED; + } + + return IUnknown_QueryInterface(iu, ctx, iid, ip); +} diff --git a/source4/lib/com/pycom.c b/source4/lib/com/pycom.c new file mode 100644 index 0000000000..9222be438d --- /dev/null +++ b/source4/lib/com/pycom.c @@ -0,0 +1,81 @@ +/* + Unix SMB/CIFS implementation. + Python bindings for COM library. + Copyright (C) Jelmer Vernooij 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 . +*/ + +#include "includes.h" +#include +#include "lib/com/com.h" +#include "librpc/ndr/libndr.h" +#include "libcli/util/pyerrors.h" + +static struct com_context *py_com_ctx = NULL; /* FIXME: evil global */ + +static PyObject *py_get_class_object(PyObject *self, PyObject *args) +{ + char *s_clsid, *s_iid; + struct GUID clsid, iid; + struct IUnknown *object; + NTSTATUS status; + WERROR error; + + if (!PyArg_ParseTuple(args, "ss", &s_clsid, &s_iid)) + return NULL; + + status = GUID_from_string(s_clsid, &clsid); + if (!NT_STATUS_IS_OK(status)) { + PyErr_FromNTSTATUS(status); + return NULL; + } + + status = GUID_from_string(s_iid, &iid); + if (!NT_STATUS_IS_OK(status)) { + PyErr_FromNTSTATUS(status); + return NULL; + } + + error = com_get_class_object(py_com_ctx, &clsid, &iid, &object); + if (!W_ERROR_IS_OK(error)) { + PyErr_FromWERROR(error); + return NULL; + } + + /* FIXME: Magic, integrate with stubs generated by pidl. */ + + return Py_None; +} + +static struct PyMethodDef com_methods[] = { + { "get_class_object", (PyCFunction)py_get_class_object, METH_VARARGS, "S.get_class_object(clsid, iid) -> instance" }, + { NULL }, +}; + +void initcom(void) +{ + PyObject *m; + WERROR error; + + error = com_init_ctx(&py_com_ctx, NULL); + if (!W_ERROR_IS_OK(error)) { + PyErr_FromWERROR(error); + return; + } + + m = Py_InitModule3("com", com_methods, "Simple COM implementation"); + if (m == NULL) + return; +} diff --git a/source4/lib/com/rot.c b/source4/lib/com/rot.c new file mode 100644 index 0000000000..0180a92f1b --- /dev/null +++ b/source4/lib/com/rot.c @@ -0,0 +1,35 @@ +/* + Unix SMB/CIFS implementation. + + Running object table functions + + Copyright (C) Jelmer Vernooij 2004-2005 + + 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" +#include "lib/com/com.h" + +struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid) +{ + /* FIXME: Call the local ROT and do a + * rot_get_interface_pointer call */ + + /* FIXME: Perhaps have a local (thread-local) table with + * local DCOM objects so that not every DCOM call requires a lookup + * to the ROT? */ + return NULL; +} diff --git a/source4/lib/com/tables.c b/source4/lib/com/tables.c new file mode 100644 index 0000000000..ed21da7cd8 --- /dev/null +++ b/source4/lib/com/tables.c @@ -0,0 +1,109 @@ +/* + Unix SMB/CIFS implementation. + COM class tables + Copyright (C) 2004 Jelmer Vernooij + + 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" +#include "../lib/util/dlinklist.h" +#include "lib/com/com.h" +#include "librpc/gen_ndr/ndr_misc.h" + +/* Specific implementation of one or more interfaces */ +struct com_class +{ + const char *progid; + struct GUID clsid; + + struct IUnknown *class_object; + struct com_class *prev, *next; +} * running_classes = NULL; + +static struct IUnknown *get_com_class_running(const struct GUID *clsid) +{ + struct com_class *c = running_classes; + + while(c) { + + if (GUID_equal(clsid, &c->clsid)) { + return c->class_object; + } + + c = c->next; + } + + return NULL; +} + +static struct IUnknown *get_com_class_so(TALLOC_CTX *mem_ctx, const struct GUID *clsid) +{ + char *mod_name; + char *clsid_str; + void *mod; + get_class_object_function f; + + clsid_str = GUID_string(mem_ctx, clsid); + mod_name = talloc_asprintf(mem_ctx, "%s.so", clsid_str); + talloc_free(clsid_str); + + mod = dlopen(mod_name, 0); + + if (!mod) { + return NULL; + } + + f = dlsym(mod, "get_class_object"); + + if (!f) { + return NULL; + } + + return f(clsid); +} + +struct IUnknown *com_class_by_clsid(struct com_context *ctx, const struct GUID *clsid) +{ + struct IUnknown *c; + + /* Check list of running COM classes first */ + c = get_com_class_running(clsid); + + if (c != NULL) { + return c; + } + + c = get_com_class_so(ctx, clsid); + + if (c != NULL) { + return c; + } + + return NULL; +} + +NTSTATUS com_register_running_class(struct GUID *clsid, const char *progid, struct IUnknown *p) +{ + struct com_class *l = talloc_zero(running_classes?running_classes:talloc_autofree_context(), struct com_class); + + l->clsid = *clsid; + l->progid = talloc_strdup(l, progid); + l->class_object = p; + + DLIST_ADD(running_classes, l); + + return NT_STATUS_OK; +} diff --git a/source4/lib/compression/mszip.c b/source4/lib/compression/mszip.c deleted file mode 100644 index 59961d6c06..0000000000 --- a/source4/lib/compression/mszip.c +++ /dev/null @@ -1,676 +0,0 @@ -/* mszip decompression - based on cabextract.c code from - * Stuart Caie - * - * adapted for Samba by Andrew Tridgell and Stefan Metzmacher 2005 - * - * (C) 2000-2001 Stuart Caie - * reaktivate-specifics by Malte Starostik - * - * 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 . - */ - -#include "includes.h" -#include "lib/compression/mszip.h" - -/*--------------------------------------------------------------------------*/ -/* our archiver information / state */ - -/* MSZIP stuff */ -#define ZIPWSIZE 0x8000 /* window size */ -#define ZIPLBITS 9 /* bits in base literal/length lookup table */ -#define ZIPDBITS 6 /* bits in base distance lookup table */ -#define ZIPBMAX 16 /* maximum bit length of any code */ -#define ZIPN_MAX 288 /* maximum number of codes in any set */ - -struct Ziphuft { - uint8_t e; /* number of extra bits or operation */ - uint8_t b; /* number of bits in this code or subcode */ - union { - uint16_t n; /* literal, length base, or distance base */ - struct Ziphuft *t; /* pointer to next level of table */ - } v; -}; - -struct ZIPstate { - uint32_t window_posn; /* current offset within the window */ - uint32_t bb; /* bit buffer */ - uint32_t bk; /* bits in bit buffer */ - uint32_t ll[288+32]; /* literal/length and distance code lengths */ - uint32_t c[ZIPBMAX+1]; /* bit length count table */ - int32_t lx[ZIPBMAX+1]; /* memory for l[-1..ZIPBMAX-1] */ - struct Ziphuft *u[ZIPBMAX]; /* table stack */ - uint32_t v[ZIPN_MAX]; /* values in order of bit length */ - uint32_t x[ZIPBMAX+1]; /* bit offsets, then code stack */ - uint8_t *inpos; -}; - -/* generic stuff */ -#define CAB(x) (decomp_state->x) -#define ZIP(x) (decomp_state->methods.zip.x) - -/* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed - * blocks have zero growth. MSZIP guarantees that it won't grow above - * uncompressed size by more than 12 bytes. LZX guarantees it won't grow - * more than 6144 bytes. - */ -#define CAB_BLOCKMAX (32768) -#define CAB_INPUTMAX (CAB_BLOCKMAX+6144) - -struct decomp_state { - struct folder *current; /* current folder we're extracting from */ - uint32_t offset; /* uncompressed offset within folder */ - uint8_t *outpos; /* (high level) start of data to use up */ - uint16_t outlen; /* (high level) amount of data to use up */ - uint16_t split; /* at which split in current folder? */ - int (*decompress)(int, int); /* the chosen compression func */ - uint8_t inbuf[CAB_INPUTMAX+2]; /* +2 for lzx bitbuffer overflows! */ - uint8_t outbuf[CAB_BLOCKMAX]; - union { - struct ZIPstate zip; - } methods; -}; - - -/* MSZIP decruncher */ - -/* Dirk Stoecker wrote the ZIP decoder, based on the InfoZip deflate code */ - -/* Tables for deflate from PKZIP's appnote.txt. */ -static const uint8_t Zipborder[] = /* Order of the bit length code lengths */ -{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; -static const uint16_t Zipcplens[] = /* Copy lengths for literal codes 257..285 */ -{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, - 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; -static const uint16_t Zipcplext[] = /* Extra bits for literal codes 257..285 */ -{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, - 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ -static const uint16_t Zipcpdist[] = /* Copy offsets for distance codes 0..29 */ -{ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, -513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; -static const uint16_t Zipcpdext[] = /* Extra bits for distance codes */ -{ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, -10, 11, 11, 12, 12, 13, 13}; - -/* And'ing with Zipmask[n] masks the lower n bits */ -static const uint16_t Zipmask[17] = { - 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - -#define ZIPNEEDBITS(n) {while(k<(n)){int32_t c=*(ZIP(inpos)++);\ - b|=((uint32_t)c)<>=(n);k-=(n);} - -static void Ziphuft_free(struct Ziphuft *t) -{ - register struct Ziphuft *p, *q; - - /* Go through linked list, freeing from the allocated (t[-1]) address. */ - p = t; - while (p != (struct Ziphuft *)NULL) - { - q = (--p)->v.t; - free(p); - p = q; - } -} - -static int32_t Ziphuft_build(struct decomp_state *decomp_state, - uint32_t *b, uint32_t n, uint32_t s, const uint16_t *d, const uint16_t *e, - struct Ziphuft **t, int32_t *m) -{ - uint32_t a; /* counter for codes of length k */ - uint32_t el; /* length of EOB code (value 256) */ - uint32_t f; /* i repeats in table every f entries */ - int32_t g; /* maximum code length */ - int32_t h; /* table level */ - register uint32_t i; /* counter, current code */ - register uint32_t j; /* counter */ - register int32_t k; /* number of bits in current code */ - int32_t *l; /* stack of bits per table */ - register uint32_t *p; /* pointer into ZIP(c)[],ZIP(b)[],ZIP(v)[] */ - register struct Ziphuft *q; /* points to current table */ - struct Ziphuft r; /* table entry for structure assignment */ - register int32_t w; /* bits before this table == (l * h) */ - uint32_t *xp; /* pointer into x */ - int32_t y; /* number of dummy codes added */ - uint32_t z; /* number of entries in current table */ - - l = ZIP(lx)+1; - - /* Generate counts for each bit length */ - el = n > 256 ? b[256] : ZIPBMAX; /* set length of EOB code, if any */ - - for(i = 0; i < ZIPBMAX+1; ++i) - ZIP(c)[i] = 0; - p = b; i = n; - do - { - ZIP(c)[*p]++; p++; /* assume all entries <= ZIPBMAX */ - } while (--i); - if (ZIP(c)[0] == n) /* null input--all zero length codes */ - { - *t = (struct Ziphuft *)NULL; - *m = 0; - return 0; - } - - /* Find minimum and maximum length, bound *m by those */ - for (j = 1; j <= ZIPBMAX; j++) - if (ZIP(c)[j]) - break; - k = j; /* minimum code length */ - if ((uint32_t)*m < j) - *m = j; - for (i = ZIPBMAX; i; i--) - if (ZIP(c)[i]) - break; - g = i; /* maximum code length */ - if ((uint32_t)*m > i) - *m = i; - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= ZIP(c)[j]) < 0) - return 2; /* bad input: more codes than bits */ - if ((y -= ZIP(c)[i]) < 0) - return 2; - ZIP(c)[i] += y; - - /* Generate starting offsets int32_to the value table for each length */ - ZIP(x)[1] = j = 0; - p = ZIP(c) + 1; xp = ZIP(x) + 2; - while (--i) - { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do{ - if ((j = *p++) != 0) - ZIP(v)[ZIP(x)[j]++] = i; - } while (++i < n); - - - /* Generate the Huffman codes and for each, make the table entries */ - ZIP(x)[0] = i = 0; /* first Huffman code is zero */ - p = ZIP(v); /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = l[-1] = 0; /* no bits decoded yet */ - ZIP(u)[0] = (struct Ziphuft *)NULL; /* just to keep compilers happy */ - q = (struct Ziphuft *)NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = ZIP(c)[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l[h]) - { - w += l[h++]; /* add bits already decoded */ - - /* compute minimum size table less than or equal to *m bits */ - z = (z = g - w) > (uint32_t)*m ? *m : z; /* upper limit */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = ZIP(c) + k; - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - if ((uint32_t)w + j > el && (uint32_t)w < el) - j = el - w; /* make EOB code end at table */ - z = 1 << j; /* table entries for j-bit table */ - l[h] = j; /* set table size in stack */ - - /* allocate and link in new table */ - if (!(q = (struct Ziphuft *) malloc((z + 1)*sizeof(struct Ziphuft)))) - { - if(h) - Ziphuft_free(ZIP(u)[0]); - return 3; /* not enough memory */ - } - *t = q + 1; /* link to list for Ziphuft_free() */ - *(t = &(q->v.t)) = (struct Ziphuft *)NULL; - ZIP(u)[h] = ++q; /* table starts after link */ - - /* connect to last table, if there is one */ - if (h) - { - ZIP(x)[h] = i; /* save pattern for backing up */ - r.b = (uint8_t)l[h-1]; /* bits to dump before this table */ - r.e = (uint8_t)(16 + j); /* bits in this table */ - r.v.t = q; /* pointer to this table */ - j = (i & ((1 << w) - 1)) >> (w - l[h-1]); - ZIP(u)[h-1][j] = r; /* connect to last table */ - } - } - - /* set up table entry in r */ - r.b = (uint8_t)(k - w); - if (p >= ZIP(v) + n) - r.e = 99; /* out of values--invalid code */ - else if (*p < s) - { - r.e = (uint8_t)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */ - r.v.n = *p++; /* simple code is just the value */ - } - else - { - r.e = (uint8_t)e[*p - s]; /* non-simple--look up in lists */ - r.v.n = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - while ((i & ((1 << w) - 1)) != ZIP(x)[h]) - w -= l[--h]; /* don't need to update q */ - } - } - - /* return actual size of base table */ - *m = l[0]; - - /* Return true (1) if we were given an incomplete table */ - return y != 0 && g != 1; -} - -static int32_t Zipinflate_codes(struct decomp_state *decomp_state, - struct Ziphuft *tl, struct Ziphuft *td, - int32_t bl, int32_t bd) -{ - register uint32_t e; /* table entry flag/number of extra bits */ - uint32_t n, d; /* length and index for copy */ - uint32_t w; /* current window position */ - struct Ziphuft *t; /* pointer to table entry */ - uint32_t ml, md; /* masks for bl and bd bits */ - register uint32_t b; /* bit buffer */ - register uint32_t k; /* number of bits in bit buffer */ - - DEBUG(10,("Zipinflate_codes\n")); - - /* make local copies of globals */ - b = ZIP(bb); /* initialize bit buffer */ - k = ZIP(bk); - w = ZIP(window_posn); /* initialize window position */ - - /* inflate the coded data */ - ml = Zipmask[bl]; /* precompute masks for speed */ - md = Zipmask[bd]; - - for(;;) - { - ZIPNEEDBITS((uint32_t)bl) - if((e = (t = tl + ((uint32_t)b & ml))->e) > 16) - do - { - if (e == 99) - return 1; - ZIPDUMPBITS(t->b) - e -= 16; - ZIPNEEDBITS(e) - } while ((e = (t = t->v.t + ((uint32_t)b & Zipmask[e]))->e) > 16); - ZIPDUMPBITS(t->b) - if (w >= CAB_BLOCKMAX) break; - if (e == 16) /* then it's a literal */ - CAB(outbuf)[w++] = (uint8_t)t->v.n; - else /* it's an EOB or a length */ - { - /* exit if end of block */ - if(e == 15) - break; - - /* get length of block to copy */ - ZIPNEEDBITS(e) - n = t->v.n + ((uint32_t)b & Zipmask[e]); - ZIPDUMPBITS(e); - - /* decode distance of block to copy */ - ZIPNEEDBITS((uint32_t)bd) - if ((e = (t = td + ((uint32_t)b & md))->e) > 16) - do { - if (e == 99) - return 1; - ZIPDUMPBITS(t->b) - e -= 16; - ZIPNEEDBITS(e) - } while ((e = (t = t->v.t + ((uint32_t)b & Zipmask[e]))->e) > 16); - ZIPDUMPBITS(t->b) - ZIPNEEDBITS(e) - d = w - t->v.n - ((uint32_t)b & Zipmask[e]); - ZIPDUMPBITS(e) - do - { - n -= (e = (e = ZIPWSIZE - ((d &= ZIPWSIZE-1) > w ? d : w)) > n ?n:e); - do - { - CAB(outbuf)[w++] = CAB(outbuf)[d++]; - } while (--e); - } while (n); - } - } - - /* restore the globals from the locals */ - ZIP(window_posn) = w; /* restore global window pointer */ - ZIP(bb) = b; /* restore global bit buffer */ - ZIP(bk) = k; - - /* done */ - return 0; -} - -/* "decompress" an inflated type 0 (stored) block. */ -static int32_t Zipinflate_stored(struct decomp_state *decomp_state) -{ - uint32_t n; /* number of bytes in block */ - uint32_t w; /* current window position */ - register uint32_t b; /* bit buffer */ - register uint32_t k; /* number of bits in bit buffer */ - - /* make local copies of globals */ - b = ZIP(bb); /* initialize bit buffer */ - k = ZIP(bk); - w = ZIP(window_posn); /* initialize window position */ - - /* go to byte boundary */ - n = k & 7; - ZIPDUMPBITS(n); - - /* get the length and its complement */ - ZIPNEEDBITS(16) - n = ((uint32_t)b & 0xffff); - ZIPDUMPBITS(16) - ZIPNEEDBITS(16) - if (n != (uint32_t)((~b) & 0xffff)) - return 1; /* error in compressed data */ - ZIPDUMPBITS(16) - - /* read and output the compressed data */ - while(n--) - { - ZIPNEEDBITS(8) - CAB(outbuf)[w++] = (uint8_t)b; - ZIPDUMPBITS(8) - } - - /* restore the globals from the locals */ - ZIP(window_posn) = w; /* restore global window pointer */ - ZIP(bb) = b; /* restore global bit buffer */ - ZIP(bk) = k; - return 0; -} - -static int32_t Zipinflate_fixed(struct decomp_state *decomp_state) -{ - struct Ziphuft *fixed_tl; - struct Ziphuft *fixed_td; - int32_t fixed_bl, fixed_bd; - int32_t i; /* temporary variable */ - uint32_t *l; - - l = ZIP(ll); - - /* literal table */ - for(i = 0; i < 144; i++) - l[i] = 8; - for(; i < 256; i++) - l[i] = 9; - for(; i < 280; i++) - l[i] = 7; - for(; i < 288; i++) /* make a complete, but wrong code set */ - l[i] = 8; - fixed_bl = 7; - if((i = Ziphuft_build(decomp_state, l, 288, 257, Zipcplens, Zipcplext, &fixed_tl, &fixed_bl))) - return i; - - /* distance table */ - for(i = 0; i < 30; i++) /* make an incomplete code set */ - l[i] = 5; - fixed_bd = 5; - if((i = Ziphuft_build(decomp_state, l, 30, 0, Zipcpdist, Zipcpdext, &fixed_td, &fixed_bd)) > 1) - { - Ziphuft_free(fixed_tl); - return i; - } - - /* decompress until an end-of-block code */ - i = Zipinflate_codes(decomp_state, fixed_tl, fixed_td, fixed_bl, fixed_bd); - - Ziphuft_free(fixed_td); - Ziphuft_free(fixed_tl); - return i; -} - -/* decompress an inflated type 2 (dynamic Huffman codes) block. */ -static int32_t Zipinflate_dynamic(struct decomp_state *decomp_state) -{ - int32_t i; /* temporary variables */ - uint32_t j; - uint32_t *ll; - uint32_t l; /* last length */ - uint32_t m; /* mask for bit lengths table */ - uint32_t n; /* number of lengths to get */ - struct Ziphuft *tl; /* literal/length code table */ - struct Ziphuft *td; /* distance code table */ - int32_t bl; /* lookup bits for tl */ - int32_t bd; /* lookup bits for td */ - uint32_t nb; /* number of bit length codes */ - uint32_t nl; /* number of literal/length codes */ - uint32_t nd; /* number of distance codes */ - register uint32_t b; /* bit buffer */ - register uint32_t k; /* number of bits in bit buffer */ - - /* make local bit buffer */ - b = ZIP(bb); - k = ZIP(bk); - ll = ZIP(ll); - - /* read in table lengths */ - ZIPNEEDBITS(5) - nl = 257 + ((uint32_t)b & 0x1f); /* number of literal/length codes */ - ZIPDUMPBITS(5) - ZIPNEEDBITS(5) - nd = 1 + ((uint32_t)b & 0x1f); /* number of distance codes */ - ZIPDUMPBITS(5) - ZIPNEEDBITS(4) - nb = 4 + ((uint32_t)b & 0xf); /* number of bit length codes */ - ZIPDUMPBITS(4) - if(nl > 288 || nd > 32) - return 1; /* bad lengths */ - - /* read in bit-length-code lengths */ - for(j = 0; j < nb; j++) - { - ZIPNEEDBITS(3) - ll[Zipborder[j]] = (uint32_t)b & 7; - ZIPDUMPBITS(3) - } - for(; j < 19; j++) - ll[Zipborder[j]] = 0; - - /* build decoding table for trees--single level, 7 bit lookup */ - bl = 7; - if((i = Ziphuft_build(decomp_state, ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) - { - if(i == 1) - Ziphuft_free(tl); - return i; /* incomplete code set */ - } - - /* read in literal and distance code lengths */ - n = nl + nd; - m = Zipmask[bl]; - i = l = 0; - while((uint32_t)i < n) - { - ZIPNEEDBITS((uint32_t)bl) - j = (td = tl + ((uint32_t)b & m))->b; - ZIPDUMPBITS(j) - j = td->v.n; - if (j < 16) /* length of code in bits (0..15) */ - ll[i++] = l = j; /* save last length in l */ - else if (j == 16) /* repeat last length 3 to 6 times */ - { - ZIPNEEDBITS(2) - j = 3 + ((uint32_t)b & 3); - ZIPDUMPBITS(2) - if((uint32_t)i + j > n) - return 1; - while (j--) - ll[i++] = l; - } - else if (j == 17) /* 3 to 10 zero length codes */ - { - ZIPNEEDBITS(3) - j = 3 + ((uint32_t)b & 7); - ZIPDUMPBITS(3) - if ((uint32_t)i + j > n) - return 1; - while (j--) - ll[i++] = 0; - l = 0; - } - else /* j == 18: 11 to 138 zero length codes */ - { - ZIPNEEDBITS(7) - j = 11 + ((uint32_t)b & 0x7f); - ZIPDUMPBITS(7) - if ((uint32_t)i + j > n) - return 1; - while (j--) - ll[i++] = 0; - l = 0; - } - } - - /* free decoding table for trees */ - Ziphuft_free(tl); - - /* restore the global bit buffer */ - ZIP(bb) = b; - ZIP(bk) = k; - - /* build the decoding tables for literal/length and distance codes */ - bl = ZIPLBITS; - if((i = Ziphuft_build(decomp_state, ll, nl, 257, Zipcplens, Zipcplext, &tl, &bl)) != 0) - { - if(i == 1) - Ziphuft_free(tl); - return i; /* incomplete code set */ - } - bd = ZIPDBITS; - Ziphuft_build(decomp_state, ll + nl, nd, 0, Zipcpdist, Zipcpdext, &td, &bd); - - /* decompress until an end-of-block code */ - if(Zipinflate_codes(decomp_state, tl, td, bl, bd)) - return 1; - - /* free the decoding tables, return */ - Ziphuft_free(tl); - Ziphuft_free(td); - return 0; -} - -/* e == last block flag */ -static int32_t Zipinflate_block(struct decomp_state *decomp_state, int32_t *e) -{ /* decompress an inflated block */ - uint32_t t; /* block type */ - register uint32_t b; /* bit buffer */ - register uint32_t k; /* number of bits in bit buffer */ - - DEBUG(10,("Zipinflate_block\n")); - - /* make local bit buffer */ - b = ZIP(bb); - k = ZIP(bk); - - /* read in last block bit */ - ZIPNEEDBITS(1) - *e = (int32_t)b & 1; - ZIPDUMPBITS(1) - - /* read in block type */ - ZIPNEEDBITS(2) - t = (uint32_t)b & 3; - ZIPDUMPBITS(2) - - /* restore the global bit buffer */ - ZIP(bb) = b; - ZIP(bk) = k; - - DEBUG(10,("inflate type %d\n", t)); - - /* inflate that block type */ - if(t == 2) - return Zipinflate_dynamic(decomp_state); - if(t == 0) - return Zipinflate_stored(decomp_state); - if(t == 1) - return Zipinflate_fixed(decomp_state); - /* bad block type */ - return 2; -} - -_PUBLIC_ struct decomp_state *ZIPdecomp_state(TALLOC_CTX *mem_ctx) -{ - return talloc_zero(mem_ctx, struct decomp_state); -} - -int ZIPdecompress(struct decomp_state *decomp_state, DATA_BLOB *inbuf, DATA_BLOB *outbuf) -{ - int32_t e = 0;/* last block flag */ - - ZIP(inpos) = CAB(inbuf); - ZIP(bb) = ZIP(bk) = ZIP(window_posn) = 0; - - if (inbuf->length > sizeof(decomp_state->inbuf)) return DECR_INPUT; - - if (outbuf->length > sizeof(decomp_state->outbuf)) return DECR_OUTPUT; - - if (outbuf->length > ZIPWSIZE) return DECR_DATAFORMAT; - - memcpy(decomp_state->inbuf, inbuf->data, inbuf->length); - - /* CK = Chris Kirmse, official Microsoft purloiner */ - if (ZIP(inpos)[0] != 'C' || ZIP(inpos)[1] != 'K') return DECR_ILLEGALDATA; - ZIP(inpos) += 2; - - while (!e) { - if (Zipinflate_block(decomp_state, &e)) { - return DECR_ILLEGALDATA; - } - } - - memcpy(outbuf->data, decomp_state->outbuf, outbuf->length); - - return DECR_OK; -} diff --git a/source4/lib/compression/mszip.h b/source4/lib/compression/mszip.h deleted file mode 100644 index bb835f2595..0000000000 --- a/source4/lib/compression/mszip.h +++ /dev/null @@ -1,33 +0,0 @@ -/* mszip decompression - based on cabextract.c code from - * Stuart Caie - * - * adapted for Samba by Andrew Tridgell and Stefan Metzmacher 2005 - * - * (C) 2000-2001 Stuart Caie - * reaktivate-specifics by Malte Starostik - * - * 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 . - */ - -struct decomp_state; -struct decomp_state *ZIPdecomp_state(TALLOC_CTX *mem_ctx); - -#define DECR_OK (0) -#define DECR_DATAFORMAT (1) -#define DECR_ILLEGALDATA (2) -#define DECR_NOMEMORY (3) -#define DECR_CHECKSUM (4) -#define DECR_INPUT (5) -#define DECR_OUTPUT (6) -int ZIPdecompress(struct decomp_state *decomp_state, DATA_BLOB *inbuf, DATA_BLOB *outbuf); diff --git a/source4/lib/crypto/crypto.h b/source4/lib/crypto/crypto.h deleted file mode 100644 index fc283f72ba..0000000000 --- a/source4/lib/crypto/crypto.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Andrew Tridgell 2004 - - 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 . -*/ - -#include "lib/crypto/crc32.h" -#include "lib/crypto/md4.h" -#include "lib/crypto/md5.h" -#include "lib/crypto/hmacmd5.h" -#include "lib/crypto/sha256.h" -#include "lib/crypto/hmacsha256.h" - -struct arcfour_state { - uint8_t sbox[256]; - uint8_t index_i; - uint8_t index_j; -}; - -void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key); -void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len); -void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key); -void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len); - diff --git a/source4/lib/dbwrap/dbwrap.c b/source4/lib/dbwrap/dbwrap.c index be48e97b5a..69203773f0 100644 --- a/source4/lib/dbwrap/dbwrap.c +++ b/source4/lib/dbwrap/dbwrap.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/dbwrap/dbwrap.h" #include "param/param.h" diff --git a/source4/lib/dbwrap/dbwrap_ctdb.c b/source4/lib/dbwrap/dbwrap_ctdb.c index f3daa7dfe5..b079658a00 100644 --- a/source4/lib/dbwrap/dbwrap_ctdb.c +++ b/source4/lib/dbwrap/dbwrap_ctdb.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/dbwrap/dbwrap.h" #include "cluster/cluster.h" #include "cluster/ctdb/include/ctdb.h" diff --git a/source4/lib/dbwrap/dbwrap_tdb.c b/source4/lib/dbwrap/dbwrap_tdb.c index fae73a1db8..3fd13dbd13 100644 --- a/source4/lib/dbwrap/dbwrap_tdb.c +++ b/source4/lib/dbwrap/dbwrap_tdb.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/dbwrap/dbwrap.h" #include "system/filesys.h" #include "tdb_wrap.h" diff --git a/source4/lib/events/Makefile.in b/source4/lib/events/Makefile.in index 0a0df9bef9..4257119849 100644 --- a/source4/lib/events/Makefile.in +++ b/source4/lib/events/Makefile.in @@ -9,9 +9,11 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ includedir = @includedir@ libdir = @libdir@ -VPATH = @srcdir@:@tallocdir@:@libreplacedir@ +VPATH = @srcdir@:@libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ +sharedbuilddir = @sharedbuilddir@ +INSTALLCMD = @INSTALL@ CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I. LDFLAGS = @LDFLAGS@ EXEEXT = @EXEEXT@ @@ -28,26 +30,40 @@ PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@ PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@ LIB_PATH_VAR = @LIB_PATH_VAR@ eventsdir = @eventsdir@ -tallocdir = @tallocdir@ -TALLOC_LIBS = @TALLOC_LIBS@ TALLOC_CFLAGS = @TALLOC_CFLAGS@ -TALLOC_OBJ = @TALLOC_OBJ@ +TALLOC_LDFLAGS = @TALLOC_CFLAGS@ +TALLOC_LIBS = @TALLOC_LIBS@ -CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) @CFLAGS@ +EVENTS_CFLAGS = @EVENTS_CFLAGS@ +EVENTS_LDFLAGS = @EVENTS_CFLAGS@ +EVENTS_LIBS = @EVENTS_LIBS@ -EVENTS_OBJ = @EVENTS_OBJ@ $(TALLOC_OBJ) @LIBREPLACEOBJ@ +CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) $(EVENTS_CFLAGS) @CFLAGS@ +LDFLAGS = $(TALLOC_LDFLAGS) $(EVENTS_LDFLAGS) @LDFLAGS@ +LIBS = $(TALLOC_LIBS) $(EVENTS_LIBS) @LIBS@ + +EVENTS_OBJ = @EVENTS_OBJ@ @LIBREPLACEOBJ@ default: all include $(eventsdir)/events.mk include $(eventsdir)/rules.mk -all:: showflags dirs $(PROGS) $(LIBEVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET) +all:: showflags dirs $(PROGS) $(EVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET) install:: all -$(LIBEVENTS_SOLIB): $(EVENTS_OBJ) - $(SHLD) $(SHLD_FLAGS) -o $@ $(EVENTS_OBJ) $(TALLOC_LIBS) @SONAMEFLAG@$(LIBEVENTS_SONAME) +$(EVENTS_SOLIB): $(EVENTS_OBJ) + $(SHLD) $(SHLD_FLAGS) $(LDFLAGS) $(LIBS) -o $@ $(EVENTS_OBJ) @SONAMEFLAG@$(EVENTS_SONAME) + +shared-build: all + ${INSTALLCMD} -d $(sharedbuilddir)/lib + ${INSTALLCMD} -m 644 libevents.a $(sharedbuilddir)/lib + ${INSTALLCMD} -m 755 $(EVENTS_SOLIB) $(sharedbuilddir)/lib + ln -sf $(EVENTS_SOLIB) $(sharedbuilddir)/lib/$(EVENTS_SONAME) + ln -sf $(EVENTS_SOLIB) $(sharedbuilddir)/lib/libevents.so + ${INSTALLCMD} -d $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 $(srcdir)/events.h $(sharedbuilddir)/include check: test @@ -56,7 +72,6 @@ installcheck:: test install clean:: rm -f *.o *.a */*.o - rm -f $(TALLOC_OBJ) distclean:: clean rm -f config.log config.status include/config.h config.cache diff --git a/source4/lib/events/autogen.sh b/source4/lib/events/autogen.sh index b13a4b685d..fec05f54d4 100755 --- a/source4/lib/events/autogen.sh +++ b/source4/lib/events/autogen.sh @@ -3,8 +3,7 @@ rm -rf autom4te.cache rm -f configure config.h.in -IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace" -IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc" +IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace" autoconf $IPATHS || exit 1 autoheader $IPATHS || exit 1 diff --git a/source4/lib/events/build_macros.m4 b/source4/lib/events/build_macros.m4 new file mode 100644 index 0000000000..c036668cd1 --- /dev/null +++ b/source4/lib/events/build_macros.m4 @@ -0,0 +1,14 @@ +AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, + [ AC_ARG_WITH([shared-build-dir], + [AC_HELP_STRING([--with-shared-build-dir=DIR], + [temporary build directory where libraries are installed [$srcdir/sharedbuild]])]) + + sharedbuilddir="$srcdir/sharedbuild" + if test x"$with_shared_build_dir" != x; then + sharedbuilddir=$with_shared_build_dir + CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" + fi + AC_SUBST(sharedbuilddir) + ]) + diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac index fbd23b10e5..895f2a1daa 100644 --- a/source4/lib/events/configure.ac +++ b/source4/lib/events/configure.ac @@ -8,8 +8,6 @@ AC_CONFIG_SRCDIR([events.c]) AC_CONFIG_HEADER(config.h) AC_LIBREPLACE_ALL_CHECKS -m4_include(libtalloc.m4) - AC_LD_EXPORT_DYNAMIC AC_LD_SONAMEFLAG AC_LD_PICFLAG @@ -17,6 +15,13 @@ AC_LD_SHLIBEXT AC_LIBREPLACE_SHLD AC_LIBREPLACE_SHLD_FLAGS AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR + +m4_include(build_macros.m4) +BUILD_WITH_SHARED_BUILD_DIR + +m4_include(pkg.m4) +m4_include(libtalloc.m4) + m4_include(libevents.m4) AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python]) diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i index 5f790aeac5..8a0d9c4b6f 100644 --- a/source4/lib/events/events.i +++ b/source4/lib/events/events.i @@ -18,7 +18,7 @@ %module(docstring="Event management.",package="samba.events") events; -%import "../talloc/talloc.i"; +%import "../../../lib/talloc/talloc.i"; %{ #include "events.h" diff --git a/source4/lib/events/events.mk b/source4/lib/events/events.mk index f4b02eae83..2bc6221689 100644 --- a/source4/lib/events/events.mk +++ b/source4/lib/events/events.mk @@ -5,7 +5,7 @@ EVENTS_SOLIB = libevents.$(SHLIBEXT).$(PACKAGE_VERSION) libevents.a: $(EVENTS_OBJ) ar -rv libevents.a $(EVENTS_OBJ) -libevents.$(SHLIBEXT): $(LIBEVENTS_SOLIB) +libevents.$(SHLIBEXT): $(EVENTS_SOLIB) ln -fs $< $@ $(EVENTS_SONAME): $(EVENTS_SOLIB) @@ -24,7 +24,7 @@ installheaders:: installdirs installlibs:: installdirs cp events.pc $(DESTDIR)$(libdir)/pkgconfig - cp libevents.a $(LIBEVENTS_SOLIB) $(DESTDIR)$(libdir) + cp libevents.a $(EVENTS_SOLIB) $(DESTDIR)$(libdir) install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET) diff --git a/source4/lib/events/events.py b/source4/lib/events/events.py index f217c29d78..c15ea8b9e5 100644 --- a/source4/lib/events/events.py +++ b/source4/lib/events/events.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.33 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/lib/events/events_util.c b/source4/lib/events/events_util.c index 93f6492560..9e7d758405 100644 --- a/source4/lib/events/events_util.c +++ b/source4/lib/events/events_util.c @@ -22,6 +22,7 @@ #include "talloc.h" #include "events.h" #include "events_internal.h" +#include "events_util.h" #include /** diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c index ccaeab7ad6..335652101b 100644 --- a/source4/lib/events/events_wrap.c +++ b/source4/lib/events/events_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2511,7 +2517,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0}; #define SWIG_name "_events" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2623,10 +2629,10 @@ fail: SWIGINTERN PyObject *_wrap_event_loop_once(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; event *arg1 = (event *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2646,10 +2652,10 @@ fail: SWIGINTERN PyObject *_wrap_event_loop_wait(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; event *arg1 = (event *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2681,7 +2687,6 @@ SWIGINTERN PyObject *_wrap_delete_event(PyObject *SWIGUNUSEDPARM(self), PyObject } arg1 = (event *)(argp1); delete_event(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -2704,7 +2709,6 @@ SWIGINTERN PyObject *_wrap_event_context_init_byname(PyObject *SWIGUNUSEDPARM(se PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; char *arg2 = (char *) 0 ; - struct event_context *result = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; @@ -2712,6 +2716,7 @@ SWIGINTERN PyObject *_wrap_event_context_init_byname(PyObject *SWIGUNUSEDPARM(se char * kwnames[] = { (char *) "name", NULL }; + struct event_context *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:event_context_init_byname",kwnames,&obj0)) SWIG_fail; diff --git a/source4/lib/events/libevents.m4 b/source4/lib/events/libevents.m4 index d17da64b32..ed76b03d4f 100644 --- a/source4/lib/events/libevents.m4 +++ b/source4/lib/events/libevents.m4 @@ -43,7 +43,7 @@ SMB_EXT_LIB(LIBAIO_LINUX, $AIO_LIBS) EVENTS_CFLAGS="-I$eventsdir" AC_SUBST(EVENTS_CFLAGS) -EVENTS_LIBS="" +EVENTS_LIBS="$AIO_LIBS" AC_SUBST(EVENTS_LIBS) diff --git a/source4/lib/events/libtalloc.m4 b/source4/lib/events/libtalloc.m4 new file mode 100644 index 0000000000..a4c5b8a9d9 --- /dev/null +++ b/source4/lib/events/libtalloc.m4 @@ -0,0 +1,7 @@ +AC_SUBST(TALLOC_OBJ) +AC_SUBST(TALLOC_CFLAGS) +AC_SUBST(TALLOC_LIBS) + +AC_CHECK_HEADER(talloc.h, + [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ], + [PKG_CHECK_MODULES(TALLOC, talloc)]) diff --git a/source4/lib/events/pkg.m4 b/source4/lib/events/pkg.m4 new file mode 100644 index 0000000000..a8b3d06c81 --- /dev/null +++ b/source4/lib/events/pkg.m4 @@ -0,0 +1,156 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# +# 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 . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES diff --git a/source4/lib/gencache/gencache.c b/source4/lib/gencache/gencache.c deleted file mode 100644 index aaaa40eea8..0000000000 --- a/source4/lib/gencache/gencache.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Generic, persistent and shared between processes cache mechanism for use - by various parts of the Samba code - - Copyright (C) Rafal Szczesniak 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 . -*/ - -#include "includes.h" -#include "system/time.h" -#include "system/filesys.h" -#include "tdb_wrap.h" -#include "lib/gencache/gencache.h" - -#define TIMEOUT_LEN 12 -#define CACHE_DATA_FMT "%12u/%s" - -static struct tdb_wrap *cache; - -/** - * @file gencache.c - * @brief Generic, persistent and shared between processes cache mechanism - * for use by various parts of the Samba code - * - **/ - - -/** - * Cache initialisation function. Opens cache tdb file or creates - * it if does not exist. - * - * @return true on successful initialisation of the cache or - * false on failure - **/ - -bool gencache_init(struct loadparm_context *lp_ctx) -{ - char* cache_fname = NULL; - TALLOC_CTX *mem_ctx = talloc_autofree_context(); - - /* skip file open if it's already opened */ - if (cache) return true; - - cache_fname = lock_path(mem_ctx, lp_ctx, "gencache.tdb"); - if (cache_fname != NULL) { - DEBUG(5, ("Opening cache file at %s\n", cache_fname)); - } else { - DEBUG(0, ("Filename allocation failed.\n")); - return false; - } - - cache = tdb_wrap_open(mem_ctx, cache_fname, 0, TDB_DEFAULT, - O_RDWR|O_CREAT, 0644); - - talloc_free(cache_fname); - if (!cache) { - DEBUG(5, ("Attempt to open gencache.tdb has failed.\n")); - return false; - } - return true; -} - - -/** - * Cache shutdown function. Closes opened cache tdb file. - * - * @return true on successful closing the cache or - * false on failure during cache shutdown - **/ - -bool gencache_shutdown(void) -{ - if (!cache) return false; - DEBUG(5, ("Closing cache file\n")); - talloc_free(cache); - return true; -} - - -/** - * Set an entry in the cache file. If there's no such - * one, then add it. - * - * @param keystr string that represents a key of this entry - * @param value text representation value being cached - * @param timeout time when the value is expired - * - * @retval true when entry is successfuly stored - * @retval false on failure - **/ - -bool gencache_set(const char *keystr, const char *value, time_t timeout) -{ - int ret; - TDB_DATA keybuf, databuf; - char* valstr = NULL; - - /* fail completely if get null pointers passed */ - SMB_ASSERT(keystr && value); - - if (!gencache_init()) return false; - - asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value); - if (!valstr) - return false; - - keybuf.dptr = (uint8_t *)strdup(keystr); - keybuf.dsize = strlen(keystr)+1; - databuf.dptr = (uint8_t *)strdup(valstr); - databuf.dsize = strlen(valstr)+1; - DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout \ - = %s (%d seconds %s)\n", keybuf.dptr, value, ctime(&timeout), - (int)(timeout - time(NULL)), timeout > time(NULL) ? "ahead" : "in the past")); - - ret = tdb_store(cache->tdb, keybuf, databuf, 0); - SAFE_FREE(valstr); - SAFE_FREE(keybuf.dptr); - SAFE_FREE(databuf.dptr); - - return ret == 0; -} - - -/** - * Set existing entry to the cache file. - * - * @param keystr string that represents a key of this entry - * @param valstr text representation value being cached - * @param timeout time when the value is expired - * - * @retval true when entry is successfuly set - * @retval false on failure - **/ - -bool gencache_set_only(const char *keystr, const char *valstr, time_t timeout) -{ - int ret = -1; - TDB_DATA keybuf, databuf; - char *old_valstr, *datastr; - time_t old_timeout; - - /* fail completely if get null pointers passed */ - SMB_ASSERT(keystr && valstr); - - if (!gencache_init()) return false; - - /* - * Check whether entry exists in the cache - * Don't verify gencache_get exit code, since the entry may be expired - */ - gencache_get(keystr, &old_valstr, &old_timeout); - - if (!(old_valstr && old_timeout)) return false; - - DEBUG(10, ("Setting cache entry with key = %s; old value = %s and old timeout \ - = %s\n", keystr, old_valstr, ctime(&old_timeout))); - - asprintf(&datastr, CACHE_DATA_FMT, (int)timeout, valstr); - keybuf.dptr = (uint8_t *)strdup(keystr); - keybuf.dsize = strlen(keystr)+1; - databuf.dptr = (uint8_t *)strdup(datastr); - databuf.dsize = strlen(datastr)+1; - DEBUGADD(10, ("New value = %s, new timeout = %s (%d seconds %s)", valstr, - ctime(&timeout), (int)(timeout - time(NULL)), - timeout > time(NULL) ? "ahead" : "in the past")); - - - ret = tdb_store(cache->tdb, keybuf, databuf, TDB_REPLACE); - - SAFE_FREE(datastr); - SAFE_FREE(old_valstr); - SAFE_FREE(keybuf.dptr); - SAFE_FREE(databuf.dptr); - - return ret == 0; -} - - -/** - * Delete one entry from the cache file. - * - * @param keystr string that represents a key of this entry - * - * @retval true upon successful deletion - * @retval false in case of failure - **/ - -bool gencache_del(const char *keystr) -{ - int ret; - TDB_DATA keybuf; - - /* fail completely if get null pointers passed */ - SMB_ASSERT(keystr); - - if (!gencache_init()) return false; - - keybuf.dptr = (uint8_t *)strdup(keystr); - keybuf.dsize = strlen(keystr)+1; - DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr)); - ret = tdb_delete(cache->tdb, keybuf); - - SAFE_FREE(keybuf.dptr); - return ret == 0; -} - - -/** - * Get existing entry from the cache file. - * - * @param keystr string that represents a key of this entry - * @param valstr buffer that is allocated and filled with the entry value - * buffer's disposing must be done outside - * @param timeout pointer to a time_t that is filled with entry's - * timeout - * - * @retval true when entry is successfuly fetched - * @retval false for failure - **/ - -bool gencache_get(const char *keystr, char **valstr, time_t *timeout) -{ - TDB_DATA keybuf, databuf; - - /* fail completely if get null pointers passed */ - SMB_ASSERT(keystr); - - if (!gencache_init()) - return false; - - keybuf.dptr = (uint8_t *)strdup(keystr); - keybuf.dsize = strlen(keystr)+1; - databuf = tdb_fetch(cache->tdb, keybuf); - SAFE_FREE(keybuf.dptr); - - if (databuf.dptr && databuf.dsize > TIMEOUT_LEN) { - char* entry_buf = strndup((char *)databuf.dptr, databuf.dsize); - char *v; - time_t t; - unsigned i; - - v = malloc_array_p(char, databuf.dsize - TIMEOUT_LEN); - - SAFE_FREE(databuf.dptr); - sscanf(entry_buf, CACHE_DATA_FMT, (int*)&i, v); - SAFE_FREE(entry_buf); - t = i; - - DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, " - "timeout = %s\n", t > time(NULL) ? "valid" : - "expired", keystr, v, ctime(&t))); - - if (valstr) - *valstr = v; - else - SAFE_FREE(v); - - if (timeout) - *timeout = t; - - return t > time(NULL); - - } else { - SAFE_FREE(databuf.dptr); - - if (valstr) - *valstr = NULL; - - if (timeout) - timeout = NULL; - - DEBUG(10, ("Cache entry with key = %s couldn't be found\n", - keystr)); - - return false; - } -} - - -/** - * Iterate through all entries which key matches to specified pattern - * - * @param fn pointer to the function that will be supplied with each single - * matching cache entry (key, value and timeout) as an arguments - * @param data void pointer to an arbitrary data that is passed directly to the fn - * function on each call - * @param keystr_pattern pattern the existing entries' keys are matched to - * - **/ - -void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr), - void* data, const char* keystr_pattern) -{ - TDB_LIST_NODE *node, *first_node; - TDB_DATA databuf; - char *keystr = NULL, *valstr = NULL, *entry = NULL; - time_t timeout = 0; - unsigned i; - - /* fail completely if get null pointers passed */ - SMB_ASSERT(fn && keystr_pattern); - - if (!gencache_init()) return; - - DEBUG(5, ("Searching cache keys with pattern %s\n", keystr_pattern)); - node = tdb_search_keys(cache->tdb, keystr_pattern); - first_node = node; - - while (node) { - /* ensure null termination of the key string */ - keystr = strndup((char *)node->node_key.dptr, node->node_key.dsize); - - /* - * We don't use gencache_get function, because we need to iterate through - * all of the entries. Validity verification is up to fn routine. - */ - databuf = tdb_fetch(cache->tdb, node->node_key); - if (!databuf.dptr || databuf.dsize <= TIMEOUT_LEN) { - SAFE_FREE(databuf.dptr); - SAFE_FREE(keystr); - node = node->next; - continue; - } - entry = strndup((char *)databuf.dptr, databuf.dsize); - SAFE_FREE(databuf.dptr); - valstr = malloc_array_p(char, databuf.dsize - TIMEOUT_LEN); - sscanf(entry, CACHE_DATA_FMT, (int*)(&i), valstr); - timeout = i; - - DEBUG(10, ("Calling function with arguments (key = %s, value = %s, timeout = %s)\n", - keystr, valstr, ctime(&timeout))); - fn(keystr, valstr, timeout, data); - - SAFE_FREE(valstr); - SAFE_FREE(entry); - SAFE_FREE(keystr); - node = node->next; - } - - tdb_search_list_free(first_node); -} - -/******************************************************************** - lock a key -********************************************************************/ - -int gencache_lock_entry( const char *key ) -{ - return tdb_lock_bystring(cache->tdb, key); -} - -/******************************************************************** - unlock a key -********************************************************************/ - -void gencache_unlock_entry( const char *key ) -{ - tdb_unlock_bystring(cache->tdb, key); -} - - diff --git a/source4/lib/gencache/gencache.h b/source4/lib/gencache/gencache.h deleted file mode 100644 index 1481676fd9..0000000000 --- a/source4/lib/gencache/gencache.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef __LIB_GENCACHE_GENCACHE_H__ -#define __LIB_GENCACHE_GENCACHE_H__ - -/** - * Cache initialisation function. Opens cache tdb file or creates - * it if does not exist. - * - * @return true on successful initialisation of the cache or - * false on failure - **/ -bool gencache_init(struct loadparm_context *lp_ctx); - -/** - * Cache shutdown function. Closes opened cache tdb file. - * - * @return true on successful closing the cache or - * false on failure during cache shutdown - **/ -bool gencache_shutdown(void); - -/** - * Set an entry in the cache file. If there's no such - * one, then add it. - * - * @param keystr string that represents a key of this entry - * @param value text representation value being cached - * @param timeout time when the value is expired - * - * @retval true when entry is successfuly stored - * @retval false on failure - **/ -bool gencache_set(const char *keystr, const char *value, time_t timeout); - -/** - * Set existing entry to the cache file. - * - * @param keystr string that represents a key of this entry - * @param valstr text representation value being cached - * @param timeout time when the value is expired - * - * @retval true when entry is successfuly set - * @retval false on failure - **/ -bool gencache_set_only(const char *keystr, const char *valstr, time_t timeout); - -/** - * Delete one entry from the cache file. - * - * @param keystr string that represents a key of this entry - * - * @retval true upon successful deletion - * @retval false in case of failure - **/ -bool gencache_del(const char *keystr); - -/** - * Get existing entry from the cache file. - * - * @param keystr string that represents a key of this entry - * @param valstr buffer that is allocated and filled with the entry value - * buffer's disposing must be done outside - * @param timeout pointer to a time_t that is filled with entry's - * timeout - * - * @retval true when entry is successfuly fetched - * @retval false for failure - **/ -bool gencache_get(const char *keystr, char **valstr, time_t *timeout); - -/** - * Iterate through all entries which key matches to specified pattern - * - * @param fn pointer to the function that will be supplied with each single - * matching cache entry (key, value and timeout) as an arguments - * @param data void pointer to an arbitrary data that is passed directly to the fn - * function on each call - * @param keystr_pattern pattern the existing entries' keys are matched to - * - **/ -void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr), - void* data, const char* keystr_pattern); - -/******************************************************************** - lock a key -********************************************************************/ -int gencache_lock_entry( const char *key ); - -/******************************************************************** - unlock a key -********************************************************************/ -void gencache_unlock_entry( const char *key ); - -#endif /* __LIB_GENCACHE_GENCACHE_H__ */ - diff --git a/source4/lib/json/AUTHORS b/source4/lib/json/AUTHORS deleted file mode 100644 index 38f2ce02a2..0000000000 --- a/source4/lib/json/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Michael Clark -C. Watford (christopher.watford@gmail.com) diff --git a/source4/lib/json/COPYING b/source4/lib/json/COPYING deleted file mode 100644 index b07ea94498..0000000000 --- a/source4/lib/json/COPYING +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2004, 2005 Metaparadigm Pte Ltd - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/source4/lib/json/ChangeLog b/source4/lib/json/ChangeLog deleted file mode 100644 index a0f848e261..0000000000 --- a/source4/lib/json/ChangeLog +++ /dev/null @@ -1,55 +0,0 @@ -0.6 - * Fix bug in escaping of control characters - Johan Björklund, johbjo09 at kth dot se - * Remove include "config.h" from headers (should only - be included from .c files) - Michael Clark - -0.5 - * Make headers C++ compatible by change *this to *obj - * Add ifdef C++ extern "C" to headers - * Use simpler definition of min and max in bits.h - Larry Lansing, llansing at fuzzynerd dot com - - * Remove automake 1.6 requirement - * Move autogen commands into autogen.sh. Update README - * Remove error pointer special case for Windows - * Change license from LGPL to MIT - Michael Clark - -0.4 - * Fix additional error case in object parsing - * Add back sign reversal in nested object parse as error pointer - value is negative, while error value is positive. - Michael Clark - -0.3 - * fix pointer arithmetic bug for error pointer check in is_error() macro - * fix type passed to printbuf_memappend in json_tokener - * update autotools bootstrap instructions in README - Michael Clark - -0.2 - * printbuf.c - C. Watford (christopher.watford@gmail.com) - Added a Win32/Win64 compliant implementation of vasprintf - * debug.c - C. Watford (christopher.watford@gmail.com) - Removed usage of vsyslog on Win32/Win64 systems, needs to be handled - by a configure script - * json_object.c - C. Watford (christopher.watford@gmail.com) - Added scope operator to wrap usage of json_object_object_foreach, this - needs to be rethought to be more ANSI C friendly - * json_object.h - C. Watford (christopher.watford@gmail.com) - Added Microsoft C friendly version of json_object_object_foreach - * json_tokener.c - C. Watford (christopher.watford@gmail.com) - Added a Win32/Win64 compliant implementation of strndup - * json_util.c - C. Watford (christopher.watford@gmail.com) - Added cast and mask to suffice size_t v. unsigned int conversion - correctness - * json_tokener.c - sign reversal issue on error info for nested object parse - spotted by Johan Björklund (johbjo09 at kth.se) - * json_object.c - escape " in json_escape_str - * Change to automake and libtool to build shared and static library - Michael Clark - -0.1 - * initial release diff --git a/source4/lib/json/Doxyfile b/source4/lib/json/Doxyfile deleted file mode 100644 index 7e5f306df3..0000000000 --- a/source4/lib/json/Doxyfile +++ /dev/null @@ -1,1153 +0,0 @@ -# Doxyfile 1.3.8 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = json-c - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 0.2 - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doc - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of source -# files, where putting all generated files in the same directory would otherwise -# cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is used -# as the annotated text. Otherwise, the brief description is used as-is. If left -# blank, the following values are used ("$name" is automatically replaced with the -# name of the entity): "The $name class" "The $name widget" "The $name file" -# "is" "provides" "specifies" "contains" "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = NO - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm - -FILE_PATTERNS = *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superseded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/source4/lib/json/INSTALL b/source4/lib/json/INSTALL deleted file mode 100644 index a4b34144dc..0000000000 --- a/source4/lib/json/INSTALL +++ /dev/null @@ -1,229 +0,0 @@ -Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/source4/lib/json/Makefile.am b/source4/lib/json/Makefile.am deleted file mode 100644 index 4b01dc16bf..0000000000 --- a/source4/lib/json/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -D_REENTRANT - -lib_LTLIBRARIES = libjson.la - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = json.pc - -libjsonincludedir = $(includedir)/json -libjsoninclude_HEADERS = \ - json.h \ - bits.h \ - debug.h \ - linkhash.h \ - arraylist.h \ - json_util.h \ - json_object.h \ - json_tokener.h - -libjson_la_LDFLAGS = -version-info 0:1:0 - -libjson_la_SOURCES = \ - arraylist.c \ - debug.c \ - json_object.c \ - json_tokener.c \ - json_util.c \ - linkhash.c \ - printbuf.c - -check_PROGRAMS = test1 test2 - -test1_SOURCES = test1.c -test1_LDADD = $(lib_LTLIBRARIES) - -test2_SOURCES = test2.c -test2_LDADD = $(lib_LTLIBRARIES) diff --git a/source4/lib/json/Makefile.in b/source4/lib/json/Makefile.in deleted file mode 100644 index f135701e14..0000000000 --- a/source4/lib/json/Makefile.in +++ /dev/null @@ -1,533 +0,0 @@ -# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = . - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ -AR = @AR@ -AS = @AS@ -CC = @CC@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DLLTOOL = @DLLTOOL@ -ECHO = @ECHO@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -HAVE_LIB = @HAVE_LIB@ -LIB = @LIB@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -LTLIB = @LTLIB@ -MAKEINFO = @MAKEINFO@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -RC = @RC@ -STRIP = @STRIP@ -VERSION = @VERSION@ - -CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -D_REENTRANT - -lib_LTLIBRARIES = libjson.la - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = json.pc - -libjsonincludedir = $(includedir)/json -libjsoninclude_HEADERS = json.h bits.h debug.h linkhash.h arraylist.h json_util.h json_object.h json_tokener.h - - -libjson_la_LDFLAGS = -version-info 0:1:0 - -libjson_la_SOURCES = arraylist.c debug.c json_object.c json_tokener.c json_util.c linkhash.c printbuf.c - - -check_PROGRAMS = test1 test2 - -test1_SOURCES = test1.c -test1_LDADD = $(lib_LTLIBRARIES) - -test2_SOURCES = test2.c -test2_LDADD = $(lib_LTLIBRARIES) -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = json.pc -LTLIBRARIES = $(lib_LTLIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -I. -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -libjson_la_LIBADD = -libjson_la_OBJECTS = arraylist.lo debug.lo json_object.lo \ -json_tokener.lo json_util.lo linkhash.lo printbuf.lo -check_PROGRAMS = test1$(EXEEXT) test2$(EXEEXT) -test1_OBJECTS = test1.$(OBJEXT) -test1_DEPENDENCIES = libjson.la -test1_LDFLAGS = -test2_OBJECTS = test2.$(OBJEXT) -test2_DEPENDENCIES = libjson.la -test2_LDFLAGS = -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DATA = $(pkgconfig_DATA) - -HEADERS = $(libjsoninclude_HEADERS) - -DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ -Makefile.am Makefile.in NEWS aclocal.m4 config.guess config.h.in \ -config.sub configure configure.in install-sh json.pc.in ltmain.sh \ -missing mkinstalldirs - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = tar -GZIP_ENV = --best -DEP_FILES = .deps/arraylist.P .deps/debug.P .deps/json_object.P \ -.deps/json_tokener.P .deps/json_util.P .deps/linkhash.P \ -.deps/printbuf.P .deps/test1.P .deps/test2.P -SOURCES = $(libjson_la_SOURCES) $(test1_SOURCES) $(test2_SOURCES) -OBJECTS = $(libjson_la_OBJECTS) $(test1_OBJECTS) $(test2_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .obj .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status - -$(ACLOCAL_M4): configure.in - cd $(srcdir) && $(ACLOCAL) - -config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck -$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) - cd $(srcdir) && $(AUTOCONF) - -config.h: stamp-h - @if test ! -f $@; then \ - rm -f stamp-h; \ - $(MAKE) stamp-h; \ - else :; fi -stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES= CONFIG_HEADERS=config.h \ - $(SHELL) ./config.status - @echo timestamp > stamp-h 2> /dev/null -$(srcdir)/config.h.in: $(srcdir)/stamp-h.in - @if test ! -f $@; then \ - rm -f $(srcdir)/stamp-h.in; \ - $(MAKE) $(srcdir)/stamp-h.in; \ - else :; fi -$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOHEADER) - @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null - -mostlyclean-hdr: - -clean-hdr: - -distclean-hdr: - -rm -f config.h - -maintainer-clean-hdr: -json.pc: $(top_builddir)/config.status json.pc.in - cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status - -mostlyclean-libLTLIBRARIES: - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - -distclean-libLTLIBRARIES: - -maintainer-clean-libLTLIBRARIES: - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ - done - -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -libjson.la: $(libjson_la_OBJECTS) $(libjson_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libjson_la_LDFLAGS) $(libjson_la_OBJECTS) $(libjson_la_LIBADD) $(LIBS) - -mostlyclean-checkPROGRAMS: - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -distclean-checkPROGRAMS: - -maintainer-clean-checkPROGRAMS: - -test1$(EXEEXT): $(test1_OBJECTS) $(test1_DEPENDENCIES) - @rm -f test1$(EXEEXT) - $(LINK) $(test1_LDFLAGS) $(test1_OBJECTS) $(test1_LDADD) $(LIBS) - -test2$(EXEEXT): $(test2_OBJECTS) $(test2_DEPENDENCIES) - @rm -f test2$(EXEEXT) - $(LINK) $(test2_LDFLAGS) $(test2_OBJECTS) $(test2_LDADD) $(LIBS) - -install-pkgconfigDATA: $(pkgconfig_DATA) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) - @list='$(pkgconfig_DATA)'; for p in $$list; do \ - if test -f $(srcdir)/$$p; then \ - echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ - $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p; \ - else if test -f $$p; then \ - echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ - $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p; \ - fi; fi; \ - done - -uninstall-pkgconfigDATA: - @$(NORMAL_UNINSTALL) - list='$(pkgconfig_DATA)'; for p in $$list; do \ - rm -f $(DESTDIR)$(pkgconfigdir)/$$p; \ - done - -install-libjsonincludeHEADERS: $(libjsoninclude_HEADERS) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libjsonincludedir) - @list='$(libjsoninclude_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ - echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libjsonincludedir)/$$p"; \ - $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libjsonincludedir)/$$p; \ - done - -uninstall-libjsonincludeHEADERS: - @$(NORMAL_UNINSTALL) - list='$(libjsoninclude_HEADERS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(libjsonincludedir)/$$p; \ - done - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP)) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - -rm -rf $(distdir) - GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz - mkdir $(distdir)/=build - mkdir $(distdir)/=inst - dc_install_base=`cd $(distdir)/=inst && pwd`; \ - cd $(distdir)/=build \ - && ../configure --srcdir=.. --prefix=$$dc_install_base \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) dist - -rm -rf $(distdir) - @banner="$(distdir).tar.gz is ready for distribution"; \ - dashes=`echo "$$banner" | sed s/./=/g`; \ - echo "$$dashes"; \ - echo "$$banner"; \ - echo "$$dashes" -dist: distdir - -chmod -R a+r $(distdir) - GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) - -rm -rf $(distdir) -dist-all: distdir - -chmod -R a+r $(distdir) - GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) - -rm -rf $(distdir) -distdir: $(DISTFILES) - -rm -rf $(distdir) - mkdir $(distdir) - -chmod 777 $(distdir) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -rm -rf .deps - -maintainer-clean-depend: - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) -check: check-am -installcheck-am: -installcheck: installcheck-am -all-recursive-am: config.h - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -install-exec-am: install-libLTLIBRARIES -install-exec: install-exec-am - -install-data-am: install-pkgconfigDATA install-libjsonincludeHEADERS -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgconfigDATA \ - uninstall-libjsonincludeHEADERS -uninstall: uninstall-am -all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) config.h -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(pkgconfigdir) \ - $(DESTDIR)$(libjsonincludedir) - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-hdr mostlyclean-libLTLIBRARIES \ - mostlyclean-compile mostlyclean-libtool \ - mostlyclean-checkPROGRAMS mostlyclean-tags \ - mostlyclean-depend mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-hdr clean-libLTLIBRARIES clean-compile clean-libtool \ - clean-checkPROGRAMS clean-tags clean-depend \ - clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-hdr distclean-libLTLIBRARIES distclean-compile \ - distclean-libtool distclean-checkPROGRAMS \ - distclean-tags distclean-depend distclean-generic \ - clean-am - -rm -f libtool - -distclean: distclean-am - -rm -f config.status - -maintainer-clean-am: maintainer-clean-hdr \ - maintainer-clean-libLTLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-checkPROGRAMS maintainer-clean-tags \ - maintainer-clean-depend maintainer-clean-generic \ - distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -rm -f config.status - -.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ -mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ -clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ -uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool mostlyclean-checkPROGRAMS \ -distclean-checkPROGRAMS clean-checkPROGRAMS \ -maintainer-clean-checkPROGRAMS uninstall-pkgconfigDATA \ -install-pkgconfigDATA uninstall-libjsonincludeHEADERS \ -install-libjsonincludeHEADERS tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir mostlyclean-depend \ -distclean-depend clean-depend maintainer-clean-depend info-am info \ -dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ -install-exec-am install-exec install-data-am install-data install-am \ -install uninstall-am uninstall all-redirect all-am all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/source4/lib/json/NEWS b/source4/lib/json/NEWS deleted file mode 100644 index 41e843b5a5..0000000000 --- a/source4/lib/json/NEWS +++ /dev/null @@ -1 +0,0 @@ -News diff --git a/source4/lib/json/README b/source4/lib/json/README deleted file mode 100644 index beeba53d5f..0000000000 --- a/source4/lib/json/README +++ /dev/null @@ -1,20 +0,0 @@ -Building on Unix with gcc and autotools - -If checking out from CVS: - - sh autogen.sh - -Then configure, make, make install - - -Test programs - -To build the test programs run 'make check' - - -Linking to libjson - -If your system has pkgconfig then you can just add this to your makefile - -CFLAGS += $(shell pkg-config --cflags json) -LDFLAGS += $(shell pkg-config --libs json) diff --git a/source4/lib/json/README-WIN32.html b/source4/lib/json/README-WIN32.html deleted file mode 100644 index fb50159819..0000000000 --- a/source4/lib/json/README-WIN32.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - JSON-C - A JSON implementation in C - Win32 specific notes - - - -

Windows specific notes for JSON-C

-

Please send Win32 bug reports to christopher.watford@gmail.com

-

Win32 Specific Changes:

-
    -
  • - Various functions have been redefined to their Win32 version (i.e. open - on win32 is _open)
  • -
  • - Implemented missing functions from MS's libc (i.e. vasprintf and strndup)
  • -
  • - Added code to allow Win64 support without integer resizing issues, this - probably makes it much nicer on 64bit machines everywhere (i.e. using ptrdiff_t - for pointer math)
  • -
-

Porting Changelog:

-
-
printbuf.c - C. Watford (christopher.watford@gmail.com)
-
- Added a Win32/Win64 compliant implementation of vasprintf
-
debug.c - C. Watford (christopher.watford@gmail.com)
-
- Removed usage of vsyslog on Win32/Win64 systems, needs to be handled - by a configure script
-
json_object.c - C. Watford (christopher.watford@gmail.com)
-
- Added scope operator to wrap usage of json_object_object_foreach, this needs to be - rethought to be more ANSI C friendly
-
json_object.h - C. Watford (christopher.watford@gmail.com)
-
- Added Microsoft C friendly version of json_object_object_foreach
-
json_tokener.c - C. Watford (christopher.watford@gmail.com)
-
- Added a Win32/Win64 compliant implementation of strndup
-
json_util.c - C. Watford (christopher.watford@gmail.com)
-
- Added cast and mask to suffice size_t v. unsigned int - conversion correctness
-
-

Anonymous CVS

-

# export CVSROOT=:pserver:anoncvs@cvs.metaparadigm.com:/cvsroot
- # cvs login
- Logging in to :pserver:anoncvs@cvs.metaparadigm.com:2401/cvsroot
- CVS password: <enter 'anoncvs'>
- # cvs co json-c

-

Copyright Metaparadigm Pte. Ltd. 2004, 2005. Michael - Clark -

-

This program is free software; you can redistribute it and/or modify it under - the terms of the MIT License. See COPYING for details.

-
- - diff --git a/source4/lib/json/README.html b/source4/lib/json/README.html deleted file mode 100644 index 7b3a65ebe9..0000000000 --- a/source4/lib/json/README.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - JSON-C - A JSON implementation in C - - - -

JSON-C - A JSON implementation in C

-

Latest release: json-c-0.6.tar.gz

-

JSON-C implements a reference counting object model that allows you to easily - construct JSON objects in C, output them as JSON formatted strings and parse - JSON formatted strings back into the C representation of JSON objects.

-

Minimal documentation exists here, - Although you are probably better reading the example code in test1.c.

-

To setup JSON-C to build on your system please run configure before - compiling. If you are on Win32 and are not using the VS project file, be sure - to rename config.h.win32 to config.h before building.

-

Win32 specific notes can be found here.

-

Please send bug reports to michael@metaparadigm.com

-

Please send Win32 bug reports to christopher.watford@gmail.com

-

Anonymous CVS

-

# export CVSROOT=:pserver:anoncvs@cvs.metaparadigm.com:/cvsroot
- # cvs login
- Logging in to :pserver:anoncvs@cvs.metaparadigm.com:2401/cvsroot
- CVS password: <enter 'anoncvs'>
- # cvs co json-c

-

Copyright Metaparadigm Pte. Ltd. 2004, 2005. Michael - Clark -

-

This program is free software; you can redistribute it and/or modify it under - the terms of the MIT License. See COPYING for details.

-
- - diff --git a/source4/lib/json/aclocal.m4 b/source4/lib/json/aclocal.m4 deleted file mode 100644 index 6f6764ecad..0000000000 --- a/source4/lib/json/aclocal.m4 +++ /dev/null @@ -1,7379 +0,0 @@ -dnl aclocal.m4t generated automatically by aclocal 1.4-p6 - -dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without -dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A -dnl PARTICULAR PURPOSE. - -# lib-prefix.m4 serial 4 (gettext-0.14.2) -dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -dnl require excessive bracketing. -ifdef([AC_HELP_STRING], -[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) - -dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -dnl to access previously installed libraries. The basic assumption is that -dnl a user will want packages to use other packages he previously installed -dnl with the same --prefix option. -dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -dnl libraries, but is otherwise very convenient. -AC_DEFUN([AC_LIB_PREFIX], -[ - AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib-prefix], -[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib - --without-lib-prefix don't search for libraries in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/lib" - fi - fi -]) - if test $use_additional = yes; then - dnl Potentially add $additional_includedir to $CPPFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's already present in $CPPFLAGS, - dnl 3. if it's /usr/local/include and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - for x in $CPPFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $CPPFLAGS. - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" - fi - fi - fi - fi - dnl Potentially add $additional_libdir to $LDFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's already present in $LDFLAGS, - dnl 3. if it's /usr/local/lib and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/lib"; then - haveit= - for x in $LDFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in - linux*) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LDFLAGS. - LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" - fi - fi - fi - fi - fi -]) - -dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -dnl acl_final_exec_prefix, containing the values to which $prefix and -dnl $exec_prefix will expand at the end of the configure script. -AC_DEFUN([AC_LIB_PREPARE_PREFIX], -[ - dnl Unfortunately, prefix and exec_prefix get only finally determined - dnl at the end of configure. - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -dnl variables prefix and exec_prefix bound to the values they will have -dnl at the end of the configure script. -AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -[ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - $1 - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -]) - -# lib-link.m4 serial 6 (gettext-0.14.3) -dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_PREREQ(2.50) - -dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and -dnl augments the CPPFLAGS variable. -AC_DEFUN([AC_LIB_LINKFLAGS], -[ - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - define([Name],[translit([$1],[./-], [___])]) - define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ - AC_LIB_LINKFLAGS_BODY([$1], [$2]) - ac_cv_lib[]Name[]_libs="$LIB[]NAME" - ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" - ac_cv_lib[]Name[]_cppflags="$INC[]NAME" - ]) - LIB[]NAME="$ac_cv_lib[]Name[]_libs" - LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" - INC[]NAME="$ac_cv_lib[]Name[]_cppflags" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - AC_SUBST([LIB]NAME) - AC_SUBST([LTLIB]NAME) - dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the - dnl results of this search when this library appears as a dependency. - HAVE_LIB[]NAME=yes - undefine([Name]) - undefine([NAME]) -]) - -dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) -dnl searches for libname and the libraries corresponding to explicit and -dnl implicit dependencies, together with the specified include files and -dnl the ability to compile and link the specified testcode. If found, it -dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and -dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and -dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs -dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. -AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], -[ - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - define([Name],[translit([$1],[./-], [___])]) - define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - - dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([$1], [$2]) - - dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, - dnl because if the user has installed lib[]Name and not disabled its use - dnl via --without-lib[]Name-prefix, he wants to use it. - ac_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - - AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ - ac_save_LIBS="$LIBS" - LIBS="$LIBS $LIB[]NAME" - AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) - LIBS="$ac_save_LIBS" - ]) - if test "$ac_cv_lib[]Name" = yes; then - HAVE_LIB[]NAME=yes - AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) - AC_MSG_CHECKING([how to link with lib[]$1]) - AC_MSG_RESULT([$LIB[]NAME]) - else - HAVE_LIB[]NAME=no - dnl If $LIB[]NAME didn't lead to a usable library, we don't need - dnl $INC[]NAME either. - CPPFLAGS="$ac_save_CPPFLAGS" - LIB[]NAME= - LTLIB[]NAME= - fi - AC_SUBST([HAVE_LIB]NAME) - AC_SUBST([LIB]NAME) - AC_SUBST([LTLIB]NAME) - undefine([Name]) - undefine([NAME]) -]) - -dnl Determine the platform dependent parameters needed to use rpath: -dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, -dnl hardcode_direct, hardcode_minus_L. -AC_DEFUN([AC_LIB_RPATH], -[ - dnl Tell automake >= 1.10 to complain if config.rpath is missing. - m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) - AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS - AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld - AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host - AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - ]) - wl="$acl_cv_wl" - libext="$acl_cv_libext" - shlibext="$acl_cv_shlibext" - hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - hardcode_direct="$acl_cv_hardcode_direct" - hardcode_minus_L="$acl_cv_hardcode_minus_L" - dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE(rpath, - [ --disable-rpath do not hardcode runtime library paths], - :, enable_rpath=yes) -]) - -dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -[ - define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib$1-prefix], -[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib - --without-lib$1-prefix don't search for lib$1 in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/lib" - fi - fi -]) - dnl Search the library and its dependencies in $additional_libdir and - dnl $LDFLAGS. Using breadth-first-seach. - LIB[]NAME= - LTLIB[]NAME= - INC[]NAME= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='$1 $2' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - dnl See if it was already located by an earlier AC_LIB_LINKFLAGS - dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" - else - dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined - dnl that this library doesn't exist. So just drop it. - : - fi - else - dnl Search the library lib$name in $additional_libdir and $LDFLAGS - dnl and the already constructed $LIBNAME/$LTLIBNAME. - found_dir= - found_la= - found_so= - found_a= - if test $use_additional = yes; then - if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then - found_dir="$additional_libdir" - found_so="$additional_libdir/lib$name.$shlibext" - if test -f "$additional_libdir/lib$name.la"; then - found_la="$additional_libdir/lib$name.la" - fi - else - if test -f "$additional_libdir/lib$name.$libext"; then - found_dir="$additional_libdir" - found_a="$additional_libdir/lib$name.$libext" - if test -f "$additional_libdir/lib$name.la"; then - found_la="$additional_libdir/lib$name.la" - fi - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then - found_dir="$dir" - found_so="$dir/lib$name.$shlibext" - if test -f "$dir/lib$name.la"; then - found_la="$dir/lib$name.la" - fi - else - if test -f "$dir/lib$name.$libext"; then - found_dir="$dir" - found_a="$dir/lib$name.$libext" - if test -f "$dir/lib$name.la"; then - found_la="$dir/lib$name.la" - fi - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - dnl Found the library. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - dnl Linking with a shared library. We attempt to hardcode its - dnl directory into the executable's runpath, unless it's the - dnl standard /usr/lib. - if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then - dnl No hardcoding is needed. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - dnl The hardcoding into $LIBNAME is system dependent. - if test "$hardcode_direct" = yes; then - dnl Using DIR/libNAME.so during linking hardcodes DIR into the - dnl resulting binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - dnl Rely on "-L$found_dir". - dnl But don't add it if it's already contained in the LDFLAGS - dnl or the already constructed $LIBNAME - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" - fi - if test "$hardcode_minus_L" != no; then - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH - dnl here, because this doesn't fit in flags passed to the - dnl compiler. So give up. No hardcoding. This affects only - dnl very old systems. - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - dnl Linking with a static library. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" - else - dnl We shouldn't come here, but anyway it's good to have a - dnl fallback. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" - fi - fi - dnl Assume the include files are nearby. - additional_includedir= - case "$found_dir" in - */lib | */lib/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - dnl Potentially add $additional_includedir to $INCNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's /usr/local/include and we are using GCC on Linux, - dnl 3. if it's already present in $CPPFLAGS or the already - dnl constructed $INCNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INC[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $INCNAME. - INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - dnl Look for dependencies. - if test -n "$found_la"; then - dnl Read the .la file. It defines the variables - dnl dlname, library_names, old_library, dependency_libs, current, - dnl age, revision, installed, dlopen, dlpreopen, libdir. - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - dnl We use only dependency_libs. - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's /usr/local/lib and we are using GCC on Linux, - dnl 3. if it's already present in $LDFLAGS or the already - dnl constructed $LIBNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/lib"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/lib"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LIBNAME. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LTLIBNAME. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - dnl Handle this in the next round. Throw away the .la's - dnl directory; it is already contained in a preceding -L - dnl option. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - dnl Most likely an immediate library name. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" - ;; - esac - done - fi - else - dnl Didn't find the library; assume it is in the system directories - dnl known to the linker and runtime loader. (All the system - dnl directories known to the linker should also be known to the - dnl runtime loader, otherwise the system is severely misconfigured.) - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user must - dnl pass all path elements in one option. We can arrange that for a - dnl single library, but not when more than one $LIBNAMEs are used. - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" - done - dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - else - dnl The -rpath options are cumulative. - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - dnl When using libtool, the option that works for both libraries and - dnl executables is -R. The -R options are cumulative. - for found_dir in $ltrpathdirs; do - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done - fi -]) - -dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -dnl unless already present in VAR. -dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -dnl contains two or three consecutive elements that belong together. -AC_DEFUN([AC_LIB_APPENDTOVAR], -[ - for element in [$2]; do - haveit= - for x in $[$1]; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - [$1]="${[$1]}${[$1]:+ }$element" - fi - done -]) - -# lib-ld.m4 serial 3 (gettext-0.13) -dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Subroutines of libtool.m4, -dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision -dnl with libtool.m4. - -dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. -AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, -[# I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by GCC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]* | [A-Za-z]:[\\/]*)] - [re_direlt='/[^/][^/]*/\.\./'] - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(acl_cv_path_LD, -[if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in - *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break ;; - *) - test "$with_gnu_ld" != yes && break ;; - esac - fi - done - IFS="$ac_save_ifs" -else - acl_cv_path_LD="$LD" # Let the user override the test with a path. -fi]) -LD="$acl_cv_path_LD" -if test -n "$LD"; then - AC_MSG_RESULT($LD) -else - AC_MSG_RESULT(no) -fi -test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) -AC_LIB_PROG_LD_GNU -]) - -# Do all the work for Automake. This macro actually does too much -- -# some checks are only needed if your package does certain things. -# But this isn't really a big deal. - -# serial 1 - -dnl Usage: -dnl AM_INIT_AUTOMAKE(package,version, [no-define]) - -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL]) -PACKAGE=[$1] -AC_SUBST(PACKAGE) -VERSION=[$2] -AC_SUBST(VERSION) -dnl test to see if srcdir already configured -if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) -fi -ifelse([$3],, -AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) -AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) -AC_REQUIRE([AM_SANITY_CHECK]) -AC_REQUIRE([AC_ARG_PROGRAM]) -dnl FIXME This is truly gross. -missing_dir=`cd $ac_aux_dir && pwd` -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir) -AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir) -AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) -AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) -AC_REQUIRE([AC_PROG_MAKE_SET])]) - -# Copyright 2002 Free Software Foundation, Inc. - -# 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, 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 . - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"]) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION so it can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], - [AM_AUTOMAKE_VERSION([1.4-p6])]) - -# -# Check to make sure that the build environment is sane. -# - -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftestfile -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` - if test "[$]*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftestfile` - fi - if test "[$]*" != "X $srcdir/configure conftestfile" \ - && test "[$]*" != "X conftestfile $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - - test "[$]2" = conftestfile - ) -then - # Ok. - : -else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) -fi -rm -f conftest* -AC_MSG_RESULT(yes)]) - -dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) -dnl The program must properly implement --version. -AC_DEFUN([AM_MISSING_PROG], -[AC_MSG_CHECKING(for working $2) -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if ($2 --version) < /dev/null > /dev/null 2>&1; then - $1=$2 - AC_MSG_RESULT(found) -else - $1="$3/missing $2" - AC_MSG_RESULT(missing) -fi -AC_SUBST($1)]) - -# Like AC_CONFIG_HEADER, but automatically create stamp file. - -AC_DEFUN([AM_CONFIG_HEADER], -[AC_PREREQ([2.12]) -AC_CONFIG_HEADER([$1]) -dnl When config.status generates a header, we must update the stamp-h file. -dnl This file resides in the same directory as the config header -dnl that is generated. We must strip everything past the first ":", -dnl and everything past the last "/". -AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl -ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, -<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, -<>; do - case " <<$>>CONFIG_HEADERS " in - *" <<$>>am_file "*<<)>> - echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx - ;; - esac - am_indx=`expr "<<$>>am_indx" + 1` -done<<>>dnl>>) -changequote([,]))]) - -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- - -# serial 48 Debian 1.5.22-2 AC_PROG_LIBTOOL - - -# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) -# ----------------------------------------------------------- -# If this macro is not defined by Autoconf, define it here. -m4_ifdef([AC_PROVIDE_IFELSE], - [], - [m4_define([AC_PROVIDE_IFELSE], - [m4_ifdef([AC_PROVIDE_$1], - [$2], [$3])])]) - - -# AC_PROG_LIBTOOL -# --------------- -AC_DEFUN([AC_PROG_LIBTOOL], -[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl -dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX -dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. - AC_PROVIDE_IFELSE([AC_PROG_CXX], - [AC_LIBTOOL_CXX], - [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX - ])]) -dnl And a similar setup for Fortran 77 support - AC_PROVIDE_IFELSE([AC_PROG_F77], - [AC_LIBTOOL_F77], - [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 -])]) - -dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. -dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run -dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. - AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [ifdef([AC_PROG_GCJ], - [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([A][M_PROG_GCJ], - [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([LT_AC_PROG_GCJ], - [define([LT_AC_PROG_GCJ], - defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) -])])# AC_PROG_LIBTOOL - - -# _AC_PROG_LIBTOOL -# ---------------- -AC_DEFUN([_AC_PROG_LIBTOOL], -[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl -AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl -AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -# Prevent multiple expansion -define([AC_PROG_LIBTOOL], []) -])# _AC_PROG_LIBTOOL - - -# AC_LIBTOOL_SETUP -# ---------------- -AC_DEFUN([AC_LIBTOOL_SETUP], -[AC_PREREQ(2.50)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -AC_REQUIRE([AC_PROG_NM])dnl - -AC_REQUIRE([AC_PROG_LN_S])dnl -AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! -AC_REQUIRE([AC_OBJEXT])dnl -AC_REQUIRE([AC_EXEEXT])dnl -dnl - -AC_LIBTOOL_SYS_MAX_CMD_LEN -AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -AC_LIBTOOL_OBJDIR - -AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -_LT_AC_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' -[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] - -# Same as above, but do not quote variable references. -[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -AC_CHECK_TOOL(AR, ar, false) -AC_CHECK_TOOL(RANLIB, ranlib, :) -AC_CHECK_TOOL(STRIP, strip, :) - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - AC_PATH_MAGIC - fi - ;; -esac - -AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -enable_win32_dll=yes, enable_win32_dll=no) - -AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -AC_ARG_WITH([pic], - [AC_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) -test -z "$pic_mode" && pic_mode=default - -# Use C for the default configuration in the libtool script -tagname= -AC_LIBTOOL_LANG_C_CONFIG -_LT_AC_TAGCONFIG -])# AC_LIBTOOL_SETUP - - -# _LT_AC_SYS_COMPILER -# ------------------- -AC_DEFUN([_LT_AC_SYS_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_AC_SYS_COMPILER - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -AC_DEFUN([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -AC_DEFUN([_LT_COMPILER_BOILERPLATE], -[ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -AC_DEFUN([_LT_LINKER_BOILERPLATE], -[ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* -])# _LT_LINKER_BOILERPLATE - - -# _LT_AC_SYS_LIBPATH_AIX -# ---------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], -[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_AC_SYS_LIBPATH_AIX - - -# _LT_AC_SHELL_INIT(ARG) -# ---------------------- -AC_DEFUN([_LT_AC_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_AC_SHELL_INIT - - -# _LT_AC_PROG_ECHO_BACKSLASH -# -------------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -[_LT_AC_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -echo=${ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat </dev/null 2>&1 && unset CDPATH - -if test -z "$ECHO"; then -if test "X${echo_test_string+set}" != Xset; then -# find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if (echo_test_string=`eval $cmd`) 2>/dev/null && - echo_test_string=`eval $cmd` && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(ECHO) -])])# _LT_AC_PROG_ECHO_BACKSLASH - - -# _LT_AC_LOCK -# ----------- -AC_DEFUN([_LT_AC_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) LD="${LD-ld} -64" ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw* | *-*-pw32*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; - ]) -esac - -need_locks="$enable_libtool_lock" - -])# _LT_AC_LOCK - - -# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], -[AC_REQUIRE([LT_AC_PROG_SED]) -AC_CACHE_CHECK([$1], [$2], - [$2=no - ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $rm conftest* -]) - -if test x"[$]$2" = xyes; then - ifelse([$5], , :, [$5]) -else - ifelse([$6], , :, [$6]) -fi -])# AC_LIBTOOL_COMPILER_OPTION - - -# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ------------------------------------------------------------ -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], -[AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - ifelse([$4], , :, [$4]) -else - ifelse([$5], , :, [$5]) -fi -])# AC_LIBTOOL_LINKER_OPTION - - -# AC_LIBTOOL_SYS_MAX_CMD_LEN -# -------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], -[# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ - = "XX$teststring") >/dev/null 2>&1 && - new_result=`expr "X$teststring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - teststring= - # Add a significant safety factor because C++ compilers can tack on massive - # amounts of additional arguments before passing them to the linker. - # It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -])# AC_LIBTOOL_SYS_MAX_CMD_LEN - - -# _LT_AC_CHECK_DLFCN -# ------------------ -AC_DEFUN([_LT_AC_CHECK_DLFCN], -[AC_CHECK_HEADERS(dlfcn.h)dnl -])# _LT_AC_CHECK_DLFCN - - -# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# --------------------------------------------------------------------- -AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - exit (status); -}] -EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_AC_TRY_DLOPEN_SELF - - -# AC_LIBTOOL_DLOPEN_SELF -# ---------------------- -AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -])# AC_LIBTOOL_DLOPEN_SELF - - -# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) -# --------------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler -AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* -]) -])# AC_LIBTOOL_PROG_CC_C_O - - -# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) -# ----------------------------------------- -# Check to see if we can do hard links to lock some files if needed -AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], -[AC_REQUIRE([_LT_AC_LOCK])dnl - -hard_links="nottested" -if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS - - -# AC_LIBTOOL_OBJDIR -# ----------------- -AC_DEFUN([AC_LIBTOOL_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -])# AC_LIBTOOL_OBJDIR - - -# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) -# ---------------------------------------------- -# Check hardcoding attributes. -AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_AC_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ - test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ - test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_AC_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_AC_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_AC_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH - - -# AC_LIBTOOL_SYS_LIB_STRIP -# ------------------------ -AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], -[striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) -fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -])# AC_LIBTOOL_SYS_LIB_STRIP - - -# AC_LIBTOOL_SYS_DYNAMIC_LINKER -# ----------------------------- -# PORTME Fill in your ld.so characteristics -AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], -[AC_MSG_CHECKING([dynamic linker characteristics]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[123]]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - freebsd*) # from 4.6 on - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix3*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - shlibpath_overrides_runpath=no - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - shlibpath_overrides_runpath=yes - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi -])# AC_LIBTOOL_SYS_DYNAMIC_LINKER - - -# _LT_AC_TAGCONFIG -# ---------------- -AC_DEFUN([_LT_AC_TAGCONFIG], -[AC_ARG_WITH([tags], - [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], - [include additional configurations @<:@automatic@:>@])], - [tagnames="$withval"]) - -if test -f "$ltmain" && test -n "$tagnames"; then - if test ! -f "${ofile}"; then - AC_MSG_WARN([output file `$ofile' does not exist]) - fi - - if test -z "$LTCC"; then - eval "`$SHELL ${ofile} --config | grep '^LTCC='`" - if test -z "$LTCC"; then - AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) - else - AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) - fi - fi - if test -z "$LTCFLAGS"; then - eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" - fi - - # Extract list of available tagged configurations in $ofile. - # Note that this assumes the entire list is on one line. - available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` - - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for tagname in $tagnames; do - IFS="$lt_save_ifs" - # Check whether tagname contains only valid characters - case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in - "") ;; - *) AC_MSG_ERROR([invalid tag name: $tagname]) - ;; - esac - - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null - then - AC_MSG_ERROR([tag name \"$tagname\" already exists]) - fi - - # Update the list of available tags. - if test -n "$tagname"; then - echo appending configuration tag \"$tagname\" to $ofile - - case $tagname in - CXX) - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_LIBTOOL_LANG_CXX_CONFIG - else - tagname="" - fi - ;; - - F77) - if test -n "$F77" && test "X$F77" != "Xno"; then - AC_LIBTOOL_LANG_F77_CONFIG - else - tagname="" - fi - ;; - - GCJ) - if test -n "$GCJ" && test "X$GCJ" != "Xno"; then - AC_LIBTOOL_LANG_GCJ_CONFIG - else - tagname="" - fi - ;; - - RC) - AC_LIBTOOL_LANG_RC_CONFIG - ;; - - *) - AC_MSG_ERROR([Unsupported tag name: $tagname]) - ;; - esac - - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" - - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - AC_MSG_ERROR([unable to update list of available tagged configurations.]) - fi -fi -])# _LT_AC_TAGCONFIG - - -# AC_LIBTOOL_DLOPEN -# ----------------- -# enable checks for dlopen support -AC_DEFUN([AC_LIBTOOL_DLOPEN], - [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_DLOPEN - - -# AC_LIBTOOL_WIN32_DLL -# -------------------- -# declare package support for building win32 DLLs -AC_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_WIN32_DLL - - -# AC_ENABLE_SHARED([DEFAULT]) -# --------------------------- -# implement the --enable-shared flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_SHARED], -[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([shared], - [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]AC_ENABLE_SHARED_DEFAULT) -])# AC_ENABLE_SHARED - - -# AC_DISABLE_SHARED -# ----------------- -# set the default shared flag to --disable-shared -AC_DEFUN([AC_DISABLE_SHARED], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_SHARED(no) -])# AC_DISABLE_SHARED - - -# AC_ENABLE_STATIC([DEFAULT]) -# --------------------------- -# implement the --enable-static flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_STATIC], -[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([static], - [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]AC_ENABLE_STATIC_DEFAULT) -])# AC_ENABLE_STATIC - - -# AC_DISABLE_STATIC -# ----------------- -# set the default static flag to --disable-static -AC_DEFUN([AC_DISABLE_STATIC], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_STATIC(no) -])# AC_DISABLE_STATIC - - -# AC_ENABLE_FAST_INSTALL([DEFAULT]) -# --------------------------------- -# implement the --enable-fast-install flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_FAST_INSTALL], -[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([fast-install], - [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) -])# AC_ENABLE_FAST_INSTALL - - -# AC_DISABLE_FAST_INSTALL -# ----------------------- -# set the default to --disable-fast-install -AC_DEFUN([AC_DISABLE_FAST_INSTALL], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_FAST_INSTALL(no) -])# AC_DISABLE_FAST_INSTALL - - -# AC_LIBTOOL_PICMODE([MODE]) -# -------------------------- -# implement the --with-pic flag -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -AC_DEFUN([AC_LIBTOOL_PICMODE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -pic_mode=ifelse($#,1,$1,default) -])# AC_LIBTOOL_PICMODE - - -# AC_PROG_EGREP -# ------------- -# This is predefined starting with Autoconf 2.54, so this conditional -# definition can be removed once we require Autoconf 2.54 or later. -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], -[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], - [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi]) - EGREP=$ac_cv_prog_egrep - AC_SUBST([EGREP]) -])]) - - -# AC_PATH_TOOL_PREFIX -# ------------------- -# find a file program which can recognise shared library -AC_DEFUN([AC_PATH_TOOL_PREFIX], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="ifelse([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -])# AC_PATH_TOOL_PREFIX - - -# AC_PATH_MAGIC -# ------------- -# find a file program which can recognise a shared library -AC_DEFUN([AC_PATH_MAGIC], -[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# AC_PATH_MAGIC - - -# AC_PROG_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([AC_PROG_LD], -[AC_ARG_WITH([gnu-ld], - [AC_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no]) -AC_REQUIRE([LT_AC_PROG_SED])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix3*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -nto-qnx*) - lt_cv_deplibs_check_method=unknown - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown -])# AC_DEPLIBS_CHECK_METHOD - - -# AC_PROG_NM -# ---------- -# find the pathname to a BSD-compatible name lister -AC_DEFUN([AC_PROG_NM], -[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi]) -NM="$lt_cv_path_NM" -])# AC_PROG_NM - - -# AC_CHECK_LIBM -# ------------- -# check for math library -AC_DEFUN([AC_CHECK_LIBM], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -])# AC_CHECK_LIBM - - -# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) -# ----------------------------------- -# sets LIBLTDL to the link flags for the libltdl convenience library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-convenience to the configure arguments. Note that -# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, -# it is assumed to be `libltdl'. LIBLTDL will be prefixed with -# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' -# (note the single quotes!). If your package is not flat and you're not -# using automake, define top_builddir and top_srcdir appropriately in -# the Makefiles. -AC_DEFUN([AC_LIBLTDL_CONVENIENCE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - case $enable_ltdl_convenience in - no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; - "") enable_ltdl_convenience=yes - ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; - esac - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la - LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - # For backwards non-gettext consistent compatibility... - INCLTDL="$LTDLINCL" -])# AC_LIBLTDL_CONVENIENCE - - -# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) -# ----------------------------------- -# sets LIBLTDL to the link flags for the libltdl installable library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-install to the configure arguments. Note that -# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, -# and an installed libltdl is not found, it is assumed to be `libltdl'. -# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with -# '${top_srcdir}/' (note the single quotes!). If your package is not -# flat and you're not using automake, define top_builddir and top_srcdir -# appropriately in the Makefiles. -# In the future, this macro may have to be called after AC_PROG_LIBTOOL. -AC_DEFUN([AC_LIBLTDL_INSTALLABLE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - AC_CHECK_LIB(ltdl, lt_dlinit, - [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], - [if test x"$enable_ltdl_install" = xno; then - AC_MSG_WARN([libltdl not installed, but installation disabled]) - else - enable_ltdl_install=yes - fi - ]) - if test x"$enable_ltdl_install" = x"yes"; then - ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la - LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - else - ac_configure_args="$ac_configure_args --enable-ltdl-install=no" - LIBLTDL="-lltdl" - LTDLINCL= - fi - # For backwards non-gettext consistent compatibility... - INCLTDL="$LTDLINCL" -])# AC_LIBLTDL_INSTALLABLE - - -# AC_LIBTOOL_CXX -# -------------- -# enable support for C++ libraries -AC_DEFUN([AC_LIBTOOL_CXX], -[AC_REQUIRE([_LT_AC_LANG_CXX]) -])# AC_LIBTOOL_CXX - - -# _LT_AC_LANG_CXX -# --------------- -AC_DEFUN([_LT_AC_LANG_CXX], -[AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([_LT_AC_PROG_CXXCPP]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) -])# _LT_AC_LANG_CXX - -# _LT_AC_PROG_CXXCPP -# ------------------ -AC_DEFUN([_LT_AC_PROG_CXXCPP], -[ -AC_REQUIRE([AC_PROG_CXX]) -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -fi -])# _LT_AC_PROG_CXXCPP - -# AC_LIBTOOL_F77 -# -------------- -# enable support for Fortran 77 libraries -AC_DEFUN([AC_LIBTOOL_F77], -[AC_REQUIRE([_LT_AC_LANG_F77]) -])# AC_LIBTOOL_F77 - - -# _LT_AC_LANG_F77 -# --------------- -AC_DEFUN([_LT_AC_LANG_F77], -[AC_REQUIRE([AC_PROG_F77]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) -])# _LT_AC_LANG_F77 - - -# AC_LIBTOOL_GCJ -# -------------- -# enable support for GCJ libraries -AC_DEFUN([AC_LIBTOOL_GCJ], -[AC_REQUIRE([_LT_AC_LANG_GCJ]) -])# AC_LIBTOOL_GCJ - - -# _LT_AC_LANG_GCJ -# --------------- -AC_DEFUN([_LT_AC_LANG_GCJ], -[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], - [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], - [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], - [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) -])# _LT_AC_LANG_GCJ - - -# AC_LIBTOOL_RC -# ------------- -# enable support for Windows resource files -AC_DEFUN([AC_LIBTOOL_RC], -[AC_REQUIRE([LT_AC_PROG_RC]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) -])# AC_LIBTOOL_RC - - -# AC_LIBTOOL_LANG_C_CONFIG -# ------------------------ -# Ensure that the configuration vars for the C compiler are -# suitably defined. Those variables are subsequently used by -# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) -AC_DEFUN([_LT_AC_LANG_C_CONFIG], -[lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_AC_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}\n' - -_LT_AC_SYS_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) -AC_LIBTOOL_PROG_COMPILER_PIC($1) -AC_LIBTOOL_PROG_CC_C_O($1) -AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -AC_LIBTOOL_PROG_LD_SHLIBS($1) -AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) -AC_LIBTOOL_SYS_LIB_STRIP -AC_LIBTOOL_DLOPEN_SELF - -# Report which library types will actually be built -AC_MSG_CHECKING([if libtool supports shared libraries]) -AC_MSG_RESULT([$can_build_shared]) - -AC_MSG_CHECKING([whether to build shared libraries]) -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case $host_os in -aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - -aix4* | aix5*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; -esac -AC_MSG_RESULT([$enable_shared]) - -AC_MSG_CHECKING([whether to build static libraries]) -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -AC_MSG_RESULT([$enable_static]) - -AC_LIBTOOL_CONFIG($1) - -AC_LANG_POP -CC="$lt_save_CC" -])# AC_LIBTOOL_LANG_C_CONFIG - - -# AC_LIBTOOL_LANG_CXX_CONFIG -# -------------------------- -# Ensure that the configuration vars for the C compiler are -# suitably defined. Those variables are subsequently used by -# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) -AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], -[AC_LANG_PUSH(C++) -AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([_LT_AC_PROG_CXXCPP]) - -_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_AC_TAGVAR(allow_undefined_flag, $1)= -_LT_AC_TAGVAR(always_export_symbols, $1)=no -_LT_AC_TAGVAR(archive_expsym_cmds, $1)= -_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_AC_TAGVAR(hardcode_direct, $1)=no -_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -_LT_AC_TAGVAR(hardcode_minus_L, $1)=no -_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_AC_TAGVAR(hardcode_automatic, $1)=no -_LT_AC_TAGVAR(module_cmds, $1)= -_LT_AC_TAGVAR(module_expsym_cmds, $1)= -_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown -_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_AC_TAGVAR(no_undefined_flag, $1)= -_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Dependencies to place before and after the object being linked: -_LT_AC_TAGVAR(predep_objects, $1)= -_LT_AC_TAGVAR(postdep_objects, $1)= -_LT_AC_TAGVAR(predeps, $1)= -_LT_AC_TAGVAR(postdeps, $1)= -_LT_AC_TAGVAR(compiler_lib_search_path, $1)= - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_AC_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_AC_SYS_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_LD=$LD -lt_save_GCC=$GCC -GCC=$GXX -lt_save_with_gnu_ld=$with_gnu_ld -lt_save_path_LD=$lt_cv_path_LD -if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx -else - $as_unset lt_cv_prog_gnu_ld -fi -if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX -else - $as_unset lt_cv_path_LD -fi -test -z "${LDCXX+set}" || LD=$LDCXX -CC=${CXX-"c++"} -compiler=$CC -_LT_AC_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) - -# We don't want -fno-exception wen compiling C++ code, so set the -# no_builtin_flag separately -if test "$GXX" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' -else - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= -fi - -if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - AC_PROG_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ - grep 'no-whole-archive' > /dev/null; then - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - -else - GXX=no - with_gnu_ld=no - wlarc= -fi - -# PORTME: fill in a description of your system's C++ link characteristics -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -_LT_AC_TAGVAR(ld_shlibs, $1)=yes -case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_AC_TAGVAR(archive_cmds, $1)='' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - else - # We have old collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GXX" = yes ; then - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - fi - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - freebsd[[12]]*) - # C++ shared libraries reported to be fairly broken before switch to ELF - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - freebsd-elf*) - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - ;; - gnu*) - ;; - hpux9*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - ;; - *) - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - interix3*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' - fi - fi - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - linux*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc*) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC*) - # Portland Group C++ compiler - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - esac - ;; - lynxos*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - m88k*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - openbsd2*) - # C++ shared libraries are fairly broken - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - openbsd*) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd='echo' - ;; - osf3*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ - $rm $lib.exp' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - psos*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The C++ compiler is used as linker so we must use $wl - # flag to pass the commands to the underlying system - # linker. We must also pass each convience library through - # to the system linker between allextract/defaultextract. - # The C++ compiler will combine linker options so we - # cannot just pass the convience library names through - # without $wl. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' - ;; - esac - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | grep -v '^2\.7' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" - fi - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - fi - ;; - esac - ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - # So that behaviour is only enabled if SCOABSPATH is set to a - # non-empty value in the environment. Most likely only useful for - # creating official distributions of packages. - # This is a hack until libtool officially supports absolute path - # names for shared libraries. - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - vxworks*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; -esac -AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_AC_TAGVAR(GCC, $1)="$GXX" -_LT_AC_TAGVAR(LD, $1)="$LD" - -AC_LIBTOOL_POSTDEP_PREDEP($1) -AC_LIBTOOL_PROG_COMPILER_PIC($1) -AC_LIBTOOL_PROG_CC_C_O($1) -AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -AC_LIBTOOL_PROG_LD_SHLIBS($1) -AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) - -AC_LIBTOOL_CONFIG($1) - -AC_LANG_POP -CC=$lt_save_CC -LDCXX=$LD -LD=$lt_save_LD -GCC=$lt_save_GCC -with_gnu_ldcxx=$with_gnu_ld -with_gnu_ld=$lt_save_with_gnu_ld -lt_cv_path_LDCXX=$lt_cv_path_LD -lt_cv_path_LD=$lt_save_path_LD -lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld -lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -])# AC_LIBTOOL_LANG_CXX_CONFIG - -# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) -# ------------------------------------ -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" -ifelse([$1], [], -[#! $SHELL - -# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# -# This file is part of GNU Libtool: -# Originally by Gordon Matzigkeit , 1996 -# -# 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="$SED -e 1s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# The names of the tagged configurations supported by this script. -available_tags= - -# ### BEGIN LIBTOOL CONFIG], -[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) - -# Is the compiler the GNU C compiler? -with_gcc=$_LT_AC_TAGVAR(GCC, $1) - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_[]_LT_AC_TAGVAR(LD, $1) - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) - -# Commands used to build and install a shared archive. -archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) -archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) -module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" - -# Set to yes if exported symbols are required. -always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) - -# The commands to list exported symbols. -export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) - -# Symbols that must always be exported. -include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) - -ifelse([$1],[], -[# ### END LIBTOOL CONFIG], -[# ### END LIBTOOL TAG CONFIG: $tagname]) - -__EOF__ - -ifelse([$1],[], [ - case $host_os in - aix3*) - cat <<\EOF >> "$cfgfile" - -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -EOF - ;; - esac - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || \ - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -]) -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi -])# AC_LIBTOOL_CONFIG - - -# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------------------- -AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl - -_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI - - -# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -# --------------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], -[AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_NM]) -AC_REQUIRE([AC_OBJEXT]) -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) # Its linker distinguishes data from code symbols - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -linux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDGIRSTW]]' - lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if grep ' nm_test_var$' "$nlist" >/dev/null; then - if grep ' nm_test_func$' "$nlist" >/dev/null; then - cat < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr_t void * -#else -# define lt_ptr_t char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr_t address; -} -lt_preloaded_symbols[[]] = -{ -EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -f conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi -]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE - - -# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) -# --------------------------------------- -AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], -[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) - ifelse([$1],[CXX],[ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | os2* | pw32*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix4* | aix5*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux*) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - icpc* | ecpc*) - # Intel C++ - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC*) - # Portland Group C++ compiler. - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - esac - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - newsos6) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - linux*) - case $cc_basename in - icc* | ecc*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then - AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], - _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), - [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" - ;; -esac - -# -# Check to make sure the static flag actually works. -# -wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" -AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) -]) - - -# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) -# ------------------------------------ -# See if the linker supports building shared libraries. -AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], -[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -ifelse([$1],[CXX],[ - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix4* | aix5*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - else - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw*) - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' - ;; - kfreebsd*-gnu) - _LT_AC_TAGVAR(link_all_deplibs, $1)=no - ;; - linux*) - _LT_AC_TAGVAR(link_all_deplibs, $1)=no - ;; - *) - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -],[ - runpath_var= - _LT_AC_TAGVAR(allow_undefined_flag, $1)= - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_AC_TAGVAR(archive_cmds, $1)= - _LT_AC_TAGVAR(archive_expsym_cmds, $1)= - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= - _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_minus_L, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown - _LT_AC_TAGVAR(hardcode_automatic, $1)=no - _LT_AC_TAGVAR(module_cmds, $1)= - _LT_AC_TAGVAR(module_expsym_cmds, $1)= - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_AC_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - extract_expsyms_cmds= - # Just being paranoid about ensuring that cc_basename is set. - _LT_CC_BASENAME([$compiler]) - case $host_os in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>/dev/null` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - fi - ;; - - amigaos*) - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - interix3*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - linux*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - tmp_addflag= - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - esac - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test $supports_anon_versioning = yes; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - $echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - _LT_AC_TAGVAR(link_all_deplibs, $1)=no - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - else - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_AC_TAGVAR(archive_cmds, $1)='' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - else - # We have old collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - # see comment about different semantics on the GNU ld section - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - bsdi[[45]]*) - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' - _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - if test "$GCC" = yes ; then - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi - ;; - - dgux*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # GNU/kFreeBSD uses gcc -shared to do shared libraries. - kfreebsd*-gnu) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(link_all_deplibs, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - openbsd*) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - wlarc='' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine linker options so we - # cannot just pass the convience library names through - # without $wl, iff we do not link with $LD. - # Luckily, gcc supports the same syntax we need for Sun Studio. - # Supported since Solaris 2.6 (maybe 2.5.1?) - case $wlarc in - '') - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; - *) - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; - esac ;; - esac - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*) - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi -]) -AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -# -# Do we need to explicitly link libc? -# -case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_AC_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) - _LT_AC_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) - then - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac -])# AC_LIBTOOL_PROG_LD_SHLIBS - - -# _LT_AC_FILE_LTDLL_C -# ------------------- -# Be careful that the start marker always follows a newline. -AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ -# /* ltdll.c starts here */ -# #define WIN32_LEAN_AND_MEAN -# #include -# #undef WIN32_LEAN_AND_MEAN -# #include -# -# #ifndef __CYGWIN__ -# # ifdef __CYGWIN32__ -# # define __CYGWIN__ __CYGWIN32__ -# # endif -# #endif -# -# #ifdef __cplusplus -# extern "C" { -# #endif -# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -# #ifdef __cplusplus -# } -# #endif -# -# #ifdef __CYGWIN__ -# #include -# DECLARE_CYGWIN_DLL( DllMain ); -# #endif -# HINSTANCE __hDllInstance_base; -# -# BOOL APIENTRY -# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -# { -# __hDllInstance_base = hInst; -# return TRUE; -# } -# /* ltdll.c ends here */ -])# _LT_AC_FILE_LTDLL_C - - -# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) -# --------------------------------- -AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) - - -# old names -AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) -AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) -AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) -AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) -AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) - -# This is just to silence aclocal about the macro not being used -ifelse([AC_DISABLE_FAST_INSTALL]) - -AC_DEFUN([LT_AC_PROG_GCJ], -[AC_CHECK_TOOL(GCJ, gcj, no) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS) -]) - -AC_DEFUN([LT_AC_PROG_RC], -[AC_CHECK_TOOL(RC, windres, no) -]) - -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -# LT_AC_PROG_SED -# -------------- -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -AC_DEFUN([LT_AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_MSG_RESULT([$SED]) -]) - diff --git a/source4/lib/json/arraylist.c b/source4/lib/json/arraylist.c deleted file mode 100644 index dbd075d80d..0000000000 --- a/source4/lib/json/arraylist.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * $Id: arraylist.c,v 1.4 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#if STDC_HEADERS -# include -# include -#endif /* STDC_HEADERS */ - -#if HAVE_STRINGS_H -# include -#endif /* HAVE_STRINGS_H */ - -#include "bits.h" -#include "arraylist.h" - -struct array_list* -array_list_new(array_list_free_fn *free_fn) -{ - struct array_list *this; - - if(!(this = calloc(1, sizeof(struct array_list)))) return NULL; - this->size = ARRAY_LIST_DEFAULT_SIZE; - this->length = 0; - this->free_fn = free_fn; - if(!(this->array = calloc(sizeof(void*), this->size))) { - free(this); - return NULL; - } - return this; -} - -extern void -array_list_free(struct array_list *this) -{ - int i; - for(i = 0; i < this->length; i++) - if(this->array[i]) this->free_fn(this->array[i]); - free(this->array); - free(this); -} - -void* -array_list_get_idx(struct array_list *this, int i) -{ - if(i >= this->length) return NULL; - return this->array[i]; -} - -static int array_list_expand_internal(struct array_list *this, int max) -{ - void *t; - int new_size; - - if(max < this->size) return 0; - new_size = max(this->size << 1, max); - if(!(t = realloc(this->array, new_size*sizeof(void*)))) return -1; - this->array = t; - (void)memset(this->array + this->size, 0, (new_size-this->size)*sizeof(void*)); - this->size = new_size; - return 0; -} - -int -array_list_put_idx(struct array_list *this, int idx, void *data) -{ - if(array_list_expand_internal(this, idx)) return -1; - if(this->array[idx]) this->free_fn(this->array[idx]); - this->array[idx] = data; - if(this->length <= idx) this->length = idx + 1; - return 0; -} - -int -array_list_add(struct array_list *this, void *data) -{ - return array_list_put_idx(this, this->length, data); -} - -int -array_list_length(struct array_list *this) -{ - return this->length; -} diff --git a/source4/lib/json/arraylist.h b/source4/lib/json/arraylist.h deleted file mode 100644 index 2948e042a9..0000000000 --- a/source4/lib/json/arraylist.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _arraylist_h_ -#define _arraylist_h_ - -#define ARRAY_LIST_DEFAULT_SIZE 32 - -typedef void (array_list_free_fn) (void *data); - -struct array_list -{ - void **array; - int length; - int size; - array_list_free_fn *free_fn; -}; - -extern struct array_list* -array_list_new(array_list_free_fn *free_fn); - -extern void -array_list_free(struct array_list *al); - -extern void* -array_list_get_idx(struct array_list *al, int i); - -extern int -array_list_put_idx(struct array_list *al, int i, void *data); - -extern int -array_list_add(struct array_list *al, void *data); - -extern int -array_list_length(struct array_list *al); - -#endif diff --git a/source4/lib/json/autogen.sh b/source4/lib/json/autogen.sh deleted file mode 100644 index c67b9034d5..0000000000 --- a/source4/lib/json/autogen.sh +++ /dev/null @@ -1 +0,0 @@ -autoreconf -v --install || exit 1 diff --git a/source4/lib/json/bits.h b/source4/lib/json/bits.h deleted file mode 100644 index 2c107cce11..0000000000 --- a/source4/lib/json/bits.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _bits_h_ -#define _bits_h_ - -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) -#define error_ptr(error) ((void*)error) -#define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L) - -#endif diff --git a/source4/lib/json/config.guess b/source4/lib/json/config.guess deleted file mode 100755 index dd7f7136cc..0000000000 --- a/source4/lib/json/config.guess +++ /dev/null @@ -1,1464 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-04-22' - -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - amd64:OpenBSD:*:*) - echo x86_64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - cats:OpenBSD:*:*) - echo arm-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - luna88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit 0 ;; - macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit 0 ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - amd64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit 0 ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit 0 ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit 0 ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit 0 ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms && exit 0 ;; - I*) echo ia64-dec-vms && exit 0 ;; - V*) echo vax-dec-vms && exit 0 ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/json/config.h.in b/source4/lib/json/config.h.in deleted file mode 100644 index 83ab7973a8..0000000000 --- a/source4/lib/json/config.h.in +++ /dev/null @@ -1,117 +0,0 @@ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -#undef HAVE_DOPRNT - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#undef HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `open' function. */ -#undef HAVE_OPEN - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#undef HAVE_REALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDARG_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strerror' function. */ -#undef HAVE_STRERROR - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strncasecmp' function. */ -#undef HAVE_STRNCASECMP - -/* Define to 1 if you have the `strndup' function. */ -#undef HAVE_STRNDUP - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYSLOG_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `vasprintf' function. */ -#undef HAVE_VASPRINTF - -/* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF - -/* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF - -/* Define to 1 if you have the `vsyslog' function. */ -#undef HAVE_VSYSLOG - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - -/* Define to rpl_realloc if the replacement function should be used. */ -#undef realloc - -/* Define to `unsigned' if does not define. */ -#undef size_t diff --git a/source4/lib/json/config.h.win32 b/source4/lib/json/config.h.win32 deleted file mode 100644 index 7f7e6aee16..0000000000 --- a/source4/lib/json/config.h.win32 +++ /dev/null @@ -1,94 +0,0 @@ -/* - * $Id: config.h.win32,v 1.2 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -/* config.h.win32 Generated by configure. */ - -#define PACKAGE_STRING "JSON C Library 0.2" -#define PACKAGE_BUGREPORT "michael@metaparadigm.com" -#define PACKAGE_NAME "JSON C Library" -#define PACKAGE_TARNAME "json-c" -#define PACKAGE_VERSION "0.2" - -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -/* #undef HAVE_DOPRNT */ - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `open' function. */ -#undef HAVE_OPEN - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#define HAVE_REALLOC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRNDUP - -/* Define to 1 if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYSLOG_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF - -/* Define to 1 if you have the `vsyslog' function. */ -#undef HAVE_VSYSLOG - -/* Define to 1 if you have the `strncasecmp' function. */ -#undef HAVE_STRNCASECMP - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 diff --git a/source4/lib/json/config.sub b/source4/lib/json/config.sub deleted file mode 100755 index aa620b5a56..0000000000 --- a/source4/lib/json/config.sub +++ /dev/null @@ -1,1568 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2007-07-10' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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 . - - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | msp430 \ - | ns16k | ns32k \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | msp430-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - or32 | or32-*) - basic_machine=or32-unknown - os=-coff - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/json/configure b/source4/lib/json/configure deleted file mode 100755 index dadf0d5d71..0000000000 --- a/source4/lib/json/configure +++ /dev/null @@ -1,20603 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for JSON C Library 0.3. -# -# Report bugs to . -# -# Copyright (C) 2003 Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - - - -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` - ;; -esac - -echo=${ECHO-echo} -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat </dev/null 2>&1 && unset CDPATH - -if test -z "$ECHO"; then -if test "X${echo_test_string+set}" != Xset; then -# find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if (echo_test_string=`eval $cmd`) 2>/dev/null && - echo_test_string=`eval $cmd` && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL $0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL $0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "$0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -fi - - - - -tagnames=${tagnames+${tagnames},}CXX - -tagnames=${tagnames+${tagnames},}F77 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -exec 6>&1 - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_config_libobj_dir=. -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - -# Identity of this package. -PACKAGE_NAME='JSON C Library' -PACKAGE_TARNAME='json-c' -PACKAGE_VERSION='0.3' -PACKAGE_STRING='JSON C Library 0.3' -PACKAGE_BUGREPORT='michael@metaparadigm.com' - -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#if HAVE_SYS_TYPES_H -# include -#endif -#if HAVE_SYS_STAT_H -# include -#endif -#if STDC_HEADERS -# include -# include -#else -# if HAVE_STDLIB_H -# include -# endif -#endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#endif -#if HAVE_STRINGS_H -# include -#endif -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# endif -#endif -#if HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBOBJS build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CXX CXXFLAGS ac_ct_CXX CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LTLIBOBJS' -ac_subst_files='' - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -ac_prev= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi -fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 - { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CPP_set=${CPP+set} -ac_env_CPP_value=$CPP -ac_cv_env_CPP_set=${CPP+set} -ac_cv_env_CPP_value=$CPP -ac_env_CXX_set=${CXX+set} -ac_env_CXX_value=$CXX -ac_cv_env_CXX_set=${CXX+set} -ac_cv_env_CXX_value=$CXX -ac_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_env_CXXFLAGS_value=$CXXFLAGS -ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_cv_env_CXXFLAGS_value=$CXXFLAGS -ac_env_CXXCPP_set=${CXXCPP+set} -ac_env_CXXCPP_value=$CXXCPP -ac_cv_env_CXXCPP_set=${CXXCPP+set} -ac_cv_env_CXXCPP_value=$CXXCPP -ac_env_F77_set=${F77+set} -ac_env_F77_value=$F77 -ac_cv_env_F77_set=${F77+set} -ac_cv_env_F77_value=$F77 -ac_env_FFLAGS_set=${FFLAGS+set} -ac_env_FFLAGS_value=$FFLAGS -ac_cv_env_FFLAGS_set=${FFLAGS+set} -ac_cv_env_FFLAGS_value=$FFLAGS - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures JSON C Library 0.3 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -_ACEOF - - cat <<_ACEOF -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of JSON C Library 0.3:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-shared[=PKGS] - build shared libraries [default=yes] - --enable-static[=PKGS] - build static libraries [default=yes] - --enable-fast-install[=PKGS] - optimize for fast installation [default=yes] - --disable-libtool-lock avoid locking (might break parallel builds) - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-pic try to use only PIC/non-PIC objects [default=use - both] - --with-tags[=TAGS] - include additional configurations [automatic] - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory - CPP C preprocessor - CXX C++ compiler command - CXXFLAGS C++ compiler flags - CXXCPP C++ preprocessor - F77 Fortran 77 compiler command - FFLAGS Fortran 77 compiler flags - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -_ACEOF -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - ac_popdir=`pwd` - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" - done -fi - -test -n "$ac_init_help" && exit 0 -if $ac_init_version; then - cat <<\_ACEOF -JSON C Library configure 0.3 -generated by GNU Autoconf 2.59 - -Copyright (C) 2003 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit 0 -fi -exec 5>config.log -cat >&5 <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by JSON C Library $as_me 0.3, which was -generated by GNU Autoconf 2.59. Invocation command line was - - $ $0 $@ - -_ACEOF -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_sep= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -{ - (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) - sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; - *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - sed "/^$/d" confdefs.h | sort - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status - ' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - - - - - - - - - - - - - - - - - - - - - -am__api_version="1.4" -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f $ac_dir/shtool; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} - { (exit 1); exit 1; }; } -fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - done - done - ;; -esac -done - - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL=$ac_install_sh - fi -fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -echo "$as_me:$LINENO: checking whether build environment is sane" >&5 -echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 -# Just in case -sleep 1 -echo timestamp > conftestfile -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t $srcdir/configure conftestfile` - fi - if test "$*" != "X $srcdir/configure conftestfile" \ - && test "$*" != "X conftestfile $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&5 -echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&2;} - { (exit 1); exit 1; }; } - fi - - test "$2" = conftestfile - ) -then - # Ok. - : -else - { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! -Check your system clock" >&5 -echo "$as_me: error: newly created file is older than distributed files! -Check your system clock" >&2;} - { (exit 1); exit 1; }; } -fi -rm -f conftest* -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -test "$program_prefix" != NONE && - program_transform_name="s,^,$program_prefix,;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s,\$,$program_suffix,;$program_transform_name" -# Double any \ or $. echo might interpret backslashes. -# By default was `s,x,x', remove it if useless. -cat <<\_ACEOF >conftest.sed -s/[\\$]/&&/g;s/;s,x,x,$// -_ACEOF -program_transform_name=`echo $program_transform_name | sed -f conftest.sed` -rm conftest.sed - -echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.make <<\_ACEOF -all: - @echo 'ac_maketemp="$(MAKE)"' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftest.make -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - SET_MAKE= -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - - -PACKAGE=JSON C Library - -VERSION=0.3 - -if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then - { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} - { (exit 1); exit 1; }; } -fi - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - - - -missing_dir=`cd $ac_aux_dir && pwd` -echo "$as_me:$LINENO: checking for working aclocal-${am__api_version}" >&5 -echo $ECHO_N "checking for working aclocal-${am__api_version}... $ECHO_C" >&6 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (aclocal-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then - ACLOCAL=aclocal-${am__api_version} - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 -else - ACLOCAL="$missing_dir/missing aclocal-${am__api_version}" - echo "$as_me:$LINENO: result: missing" >&5 -echo "${ECHO_T}missing" >&6 -fi - -echo "$as_me:$LINENO: checking for working autoconf" >&5 -echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoconf --version) < /dev/null > /dev/null 2>&1; then - AUTOCONF=autoconf - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 -else - AUTOCONF="$missing_dir/missing autoconf" - echo "$as_me:$LINENO: result: missing" >&5 -echo "${ECHO_T}missing" >&6 -fi - -echo "$as_me:$LINENO: checking for working automake-${am__api_version}" >&5 -echo $ECHO_N "checking for working automake-${am__api_version}... $ECHO_C" >&6 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (automake-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then - AUTOMAKE=automake-${am__api_version} - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 -else - AUTOMAKE="$missing_dir/missing automake-${am__api_version}" - echo "$as_me:$LINENO: result: missing" >&5 -echo "${ECHO_T}missing" >&6 -fi - -echo "$as_me:$LINENO: checking for working autoheader" >&5 -echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoheader --version) < /dev/null > /dev/null 2>&1; then - AUTOHEADER=autoheader - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 -else - AUTOHEADER="$missing_dir/missing autoheader" - echo "$as_me:$LINENO: result: missing" >&5 -echo "${ECHO_T}missing" >&6 -fi - -echo "$as_me:$LINENO: checking for working makeinfo" >&5 -echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (makeinfo --version) < /dev/null > /dev/null 2>&1; then - MAKEINFO=makeinfo - echo "$as_me:$LINENO: result: found" >&5 -echo "${ECHO_T}found" >&6 -else - MAKEINFO="$missing_dir/missing makeinfo" - echo "$as_me:$LINENO: result: missing" >&5 -echo "${ECHO_T}missing" >&6 -fi - - - -# Checks for programs. - -# Checks for libraries. - -# Checks for header files. - - ac_config_headers="$ac_config_headers config.h" - - ac_config_commands="$ac_config_commands default-1" - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi - -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CC" && break -done - - CC=$ac_ct_CC -fi - -fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; - * ) - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 - -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cc_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_prog_cc_stdc=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext -done -rm -f conftest.$ac_ext conftest.$ac_objext -CC=$ac_save_CC - -fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; - *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; -esac - -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -echo "$as_me:$LINENO: result: $CPP" >&5 -echo "${ECHO_T}$CPP" >&6 -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - - - - -for ac_header in fcntl.h limits.h strings.h syslog.h unistd.h sys/param.h stdarg.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## --------------------------------------- ## -## Report this to michael@metaparadigm.com ## -## --------------------------------------- ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# Checks for typedefs, structures, and compiler characteristics. -echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 -echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 -if test "${ac_cv_c_const+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset x; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *ccp; - char **p; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - ccp = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++ccp; - p = (char**) ccp; - ccp = (char const *const *) p; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - } -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_const=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_c_const=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 -echo "${ECHO_T}$ac_cv_c_const" >&6 -if test $ac_cv_c_const = no; then - -cat >>confdefs.h <<\_ACEOF -#define const -_ACEOF - -fi - -echo "$as_me:$LINENO: checking for size_t" >&5 -echo $ECHO_N "checking for size_t... $ECHO_C" >&6 -if test "${ac_cv_type_size_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if ((size_t *) 0) - return 0; -if (sizeof (size_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_size_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_type_size_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 -echo "${ECHO_T}$ac_cv_type_size_t" >&6 -if test $ac_cv_type_size_t = yes; then - : -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned -_ACEOF - -fi - - -# Checks for library functions. - -for ac_func in vprintf -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -echo "$as_me:$LINENO: checking for _doprnt" >&5 -echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 -if test "${ac_cv_func__doprnt+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define _doprnt to an innocuous variant, in case declares _doprnt. - For example, HP-UX 11i declares gettimeofday. */ -#define _doprnt innocuous__doprnt - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char _doprnt (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef _doprnt - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char _doprnt (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub__doprnt) || defined (__stub____doprnt) -choke me -#else -char (*f) () = _doprnt; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != _doprnt; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func__doprnt=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func__doprnt=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 -echo "${ECHO_T}$ac_cv_func__doprnt" >&6 -if test $ac_cv_func__doprnt = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_DOPRNT 1 -_ACEOF - -fi - -fi -done - - -echo "$as_me:$LINENO: checking for working memcmp" >&5 -echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6 -if test "${ac_cv_func_memcmp_working+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_memcmp_working=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* Some versions of memcmp are not 8-bit clean. */ - char c0 = 0x40, c1 = 0x80, c2 = 0x81; - if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) - exit (1); - - /* The Next x86 OpenStep bug shows up only when comparing 16 bytes - or more and with at least one buffer not starting on a 4-byte boundary. - William Lewis provided this test program. */ - { - char foo[21]; - char bar[21]; - int i; - for (i = 0; i < 4; i++) - { - char *a = foo + i; - char *b = bar + i; - strcpy (a, "--------01111111"); - strcpy (b, "--------10000000"); - if (memcmp (a, b, 16) >= 0) - exit (1); - } - exit (0); - } - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_memcmp_working=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_memcmp_working=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5 -echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6 -test $ac_cv_func_memcmp_working = no && case $LIBOBJS in - "memcmp.$ac_objext" | \ - *" memcmp.$ac_objext" | \ - "memcmp.$ac_objext "* | \ - *" memcmp.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" ;; -esac - - - -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## --------------------------------------- ## -## Report this to michael@metaparadigm.com ## -## --------------------------------------- ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 -echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6 -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_malloc_0_nonnull=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if STDC_HEADERS || HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -exit (malloc (0) ? 0 : 1); - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_malloc_0_nonnull=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6 -if test $ac_cv_func_malloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 0 -_ACEOF - - case $LIBOBJS in - "malloc.$ac_objext" | \ - *" malloc.$ac_objext" | \ - "malloc.$ac_objext "* | \ - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; -esac - - -cat >>confdefs.h <<\_ACEOF -#define malloc rpl_malloc -_ACEOF - -fi - - - - -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## --------------------------------------- ## -## Report this to michael@metaparadigm.com ## -## --------------------------------------- ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 -echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6 -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_realloc_0_nonnull=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if STDC_HEADERS || HAVE_STDLIB_H -# include -#else -char *realloc (); -#endif - -int -main () -{ -exit (realloc (0, 0) ? 0 : 1); - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_realloc_0_nonnull=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_realloc_0_nonnull=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6 -if test $ac_cv_func_realloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_REALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_REALLOC 0 -_ACEOF - - case $LIBOBJS in - "realloc.$ac_objext" | \ - *" realloc.$ac_objext" | \ - "realloc.$ac_objext "* | \ - *" realloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; -esac - - -cat >>confdefs.h <<\_ACEOF -#define realloc rpl_realloc -_ACEOF - -fi - - - - - - - - - - -for ac_func in strndup strerror vsnprintf vasprintf open vsyslog strncasecmp -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) -choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != $ac_func; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_var=no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -# Check whether --enable-shared or --disable-shared was given. -if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_shared=yes -fi; - -# Check whether --enable-static or --disable-static was given. -if test "${enable_static+set}" = set; then - enableval="$enable_static" - p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=yes -fi; - -# Check whether --enable-fast-install or --disable-fast-install was given. -if test "${enable_fast_install+set}" = set; then - enableval="$enable_fast_install" - p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_fast_install=yes -fi; - -# Make sure we can run config.sub. -$ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -echo "$as_me: error: cannot run $ac_config_sub" >&2;} - { (exit 1); exit 1; }; } - -echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6 -if test "${ac_cv_build+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_build_alias=$build_alias -test -z "$ac_cv_build_alias" && - ac_cv_build_alias=`$ac_config_guess` -test -z "$ac_cv_build_alias" && - { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } -ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} - { (exit 1); exit 1; }; } - -fi -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 -build=$ac_cv_build -build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6 -if test "${ac_cv_host+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_host_alias=$host_alias -test -z "$ac_cv_host_alias" && - ac_cv_host_alias=$ac_cv_build_alias -ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} - { (exit 1); exit 1; }; } - -fi -echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6 -host=$ac_cv_host -host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 -echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 -if test "${lt_cv_path_SED+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done - -fi - -SED=$lt_cv_path_SED -echo "$as_me:$LINENO: result: $SED" >&5 -echo "${ECHO_T}$SED" >&6 - - -# Check whether --with-gnu-ld or --without-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then - withval="$with_gnu_ld" - test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi; -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo "$as_me:$LINENO: checking for ld used by $CC" >&5 -echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - echo "$as_me:$LINENO: checking for GNU ld" >&5 -echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 -else - echo "$as_me:$LINENO: checking for non-GNU ld" >&5 -echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 -fi -if test "${lt_cv_path_LD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -echo "${ECHO_T}$LD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 -echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} - { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 -echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 -if test "${lt_cv_prog_gnu_ld+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 -with_gnu_ld=$lt_cv_prog_gnu_ld - - -echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 -echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 -if test "${lt_cv_ld_reload_flag+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_ld_reload_flag='-r' -fi -echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 -echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 -reload_flag=$lt_cv_ld_reload_flag -case $reload_flag in -"" | " "*) ;; -*) reload_flag=" $reload_flag" ;; -esac -reload_cmds='$LD$reload_flag -o $output$reload_objs' -case $host_os in - darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' - else - reload_cmds='$LD$reload_flag -o $output$reload_objs' - fi - ;; -esac - -echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 -echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 -if test "${lt_cv_path_NM+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi -fi -echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 -echo "${ECHO_T}$lt_cv_path_NM" >&6 -NM="$lt_cv_path_NM" - -echo "$as_me:$LINENO: checking whether ln -s works" >&5 -echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -else - echo "$as_me:$LINENO: result: no, using $LN_S" >&5 -echo "${ECHO_T}no, using $LN_S" >&6 -fi - -echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 -echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 -if test "${lt_cv_deplibs_check_method+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix4* | aix5*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi[45]*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # func_win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # func_win32_libid shell function, so use a weaker test based on 'objdump'. - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | kfreebsd*-gnu | dragonfly*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix3*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -nto-qnx*) - lt_cv_deplibs_check_method=unknown - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; -esac - -fi -echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 -echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - -# Check whether --enable-libtool-lock or --disable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then - enableval="$enable_libtool_lock" - -fi; -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '#line 5005 "configure"' > conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 -echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 -if test "${lt_cv_cc_needs_belf+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - lt_cv_cc_needs_belf=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -lt_cv_cc_needs_belf=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 -echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) LD="${LD-ld} -64" ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - - -esac - -need_locks="$enable_libtool_lock" - - - -for ac_header in dlfcn.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( - cat <<\_ASBOX -## --------------------------------------- ## -## Report this to michael@metaparadigm.com ## -## --------------------------------------- ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - echo "$as_me:$LINENO: result: $CXX" >&5 -echo "${ECHO_T}$CXX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -echo "${ECHO_T}$ac_ct_CXX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CXX" && break -done -test -n "$ac_ct_CXX" || ac_ct_CXX="g++" - - CXX=$ac_ct_CXX -fi - - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C++ compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 -GXX=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cxx_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cxx_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cxx_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 -echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 -if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -echo "$as_me:$LINENO: result: $CXXCPP" >&5 -echo "${ECHO_T}$CXXCPP" >&6 -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -fi - - -ac_ext=f -ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' -ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_f77_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$F77"; then - ac_cv_prog_F77="$F77" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_F77="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -F77=$ac_cv_prog_F77 -if test -n "$F77"; then - echo "$as_me:$LINENO: result: $F77" >&5 -echo "${ECHO_T}$F77" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$F77" && break - done -fi -if test -z "$F77"; then - ac_ct_F77=$F77 - for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_F77"; then - ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_F77="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_F77=$ac_cv_prog_ac_ct_F77 -if test -n "$ac_ct_F77"; then - echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 -echo "${ECHO_T}$ac_ct_F77" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_F77" && break -done - - F77=$ac_ct_F77 -fi - - -# Provide some information about the compiler. -echo "$as_me:6016:" \ - "checking for Fortran 77 compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -rm -f a.out - -# If we don't use `.F' as extension, the preprocessor is not run on the -# input file. (Note that this only needs to work for GNU compilers.) -ac_save_ext=$ac_ext -ac_ext=F -echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 -if test "${ac_cv_f77_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF - program main -#ifndef __GNUC__ - choke me -#endif - - end -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_f77_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 -ac_ext=$ac_save_ext -ac_test_FFLAGS=${FFLAGS+set} -ac_save_FFLAGS=$FFLAGS -FFLAGS= -echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 -echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_f77_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - FFLAGS=-g -cat >conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_f77_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_f77_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 -echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 -if test "$ac_test_FFLAGS" = set; then - FFLAGS=$ac_save_FFLAGS -elif test $ac_cv_prog_f77_g = yes; then - if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-g -O2" - else - FFLAGS="-g" - fi -else - if test "x$ac_cv_f77_compiler_gnu" = xyes; then - FFLAGS="-O2" - else - FFLAGS= - fi -fi - -G77=`test $ac_compiler_gnu = yes && echo yes` -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! - -# find the maximum length of command line arguments -echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 -echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 -if test "${lt_cv_sys_max_cmd_len+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ - = "XX$teststring") >/dev/null 2>&1 && - new_result=`expr "X$teststring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - teststring= - # Add a significant safety factor because C++ compilers can tack on massive - # amounts of additional arguments before passing them to the linker. - # It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - ;; - esac - -fi - -if test -n $lt_cv_sys_max_cmd_len ; then - echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 -echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 -else - echo "$as_me:$LINENO: result: none" >&5 -echo "${ECHO_T}none" >&6 -fi - - - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 -echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 -if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRST]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32*) - symcode='[ABCDGISTW]' - ;; -hpux*) # Its linker distinguishes data from code symbols - if test "$host_cpu" = ia64; then - symcode='[ABCDEGRST]' - fi - lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -linux*) - if test "$host_cpu" = ia64; then - symcode='[ABCDGIRSTW]' - lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - fi - ;; -irix* | nonstopux*) - symcode='[BCDEGRST]' - ;; -osf*) - symcode='[BCDEGQRST]' - ;; -solaris*) - symcode='[BDRT]' - ;; -sco3.2v5*) - symcode='[DT]' - ;; -sysv4.2uw2*) - symcode='[DT]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[ABDT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[ABCDGIRSTW]' ;; -esac - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 - (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if grep ' nm_test_var$' "$nlist" >/dev/null; then - if grep ' nm_test_func$' "$nlist" >/dev/null; then - cat < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr_t void * -#else -# define lt_ptr_t char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr_t address; -} -lt_preloaded_symbols[] = -{ -EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -f conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done - -fi - -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - echo "$as_me:$LINENO: result: failed" >&5 -echo "${ECHO_T}failed" >&6 -else - echo "$as_me:$LINENO: result: ok" >&5 -echo "${ECHO_T}ok" >&6 -fi - -echo "$as_me:$LINENO: checking for objdir" >&5 -echo $ECHO_N "checking for objdir... $ECHO_C" >&6 -if test "${lt_cv_objdir+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null -fi -echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 -echo "${ECHO_T}$lt_cv_objdir" >&6 -objdir=$lt_cv_objdir - - - - - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' -sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_AR+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - echo "$as_me:$LINENO: result: $AR" >&5 -echo "${ECHO_T}$AR" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_AR"; then - ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="ar" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 -echo "${ECHO_T}$ac_ct_AR" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - AR=$ac_ct_AR -else - AR="$ac_cv_prog_AR" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - echo "$as_me:$LINENO: result: $RANLIB" >&5 -echo "${ECHO_T}$RANLIB" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 -echo "${ECHO_T}$ac_ct_RANLIB" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - RANLIB=$ac_ct_RANLIB -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - echo "$as_me:$LINENO: result: $STRIP" >&5 -echo "${ECHO_T}$STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 -echo "${ECHO_T}$ac_ct_STRIP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - STRIP=$ac_ct_STRIP -else - STRIP="$ac_cv_prog_STRIP" -fi - - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 -echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 -echo "${ECHO_T}$MAGIC_CMD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - echo "$as_me:$LINENO: checking for file" >&5 -echo $ECHO_N "checking for file... $ECHO_C" >&6 -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 -echo "${ECHO_T}$MAGIC_CMD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -enable_dlopen=no -enable_win32_dll=no - -# Check whether --enable-libtool-lock or --disable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then - enableval="$enable_libtool_lock" - -fi; -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - - -# Check whether --with-pic or --without-pic was given. -if test "${with_pic+set}" = set; then - withval="$with_pic" - pic_mode="$withval" -else - pic_mode=default -fi; -test -z "$pic_mode" && pic_mode=default - -# Use C for the default configuration in the libtool script -tagname= -lt_save_CC="$CC" -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -objext=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}\n' - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* - -ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* - - - -lt_prog_compiler_no_builtin_flag= - -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag=' -fno-builtin' - - -echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7077: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:7081: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -else - : -fi - -fi - -lt_prog_compiler_wl= -lt_prog_compiler_pic= -lt_prog_compiler_static= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - if test "$GCC" = yes; then - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_static='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - fi - ;; - - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic='-fno-common' - ;; - - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic=-Kconform_pic - fi - ;; - - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - ;; - - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - else - lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - lt_prog_compiler_pic='-qnocommon' - lt_prog_compiler_wl='-Wl,' - ;; - esac - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static='-non_shared' - ;; - - newsos6) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - linux*) - case $cc_basename in - icc* | ecc*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - lt_prog_compiler_wl='-Qoption ld ';; - *) - lt_prog_compiler_wl='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl='-Qoption ld ' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic='-Kconform_pic' - lt_prog_compiler_static='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_can_build_shared=no - ;; - - uts4*) - lt_prog_compiler_pic='-pic' - lt_prog_compiler_static='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7345: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:7349: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_pic_works=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 - -if test x"$lt_prog_compiler_pic_works" = xyes; then - case $lt_prog_compiler_pic in - "" | " "*) ;; - *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; - esac -else - lt_prog_compiler_pic= - lt_prog_compiler_can_build_shared=no -fi - -fi -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic= - ;; - *) - lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" - ;; -esac - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 -if test "${lt_prog_compiler_static_works+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_static_works=yes - fi - else - lt_prog_compiler_static_works=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 -echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 - -if test x"$lt_prog_compiler_static_works" = xyes; then - : -else - lt_prog_compiler_static= -fi - - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7449: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:7453: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - runpath_var= - allow_undefined_flag= - enable_shared_with_static_runtimes=no - archive_cmds= - archive_expsym_cmds= - old_archive_From_new_cmds= - old_archive_from_expsyms_cmds= - export_dynamic_flag_spec= - whole_archive_flag_spec= - thread_safe_flag_spec= - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= - hardcode_libdir_separator= - hardcode_direct=no - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - link_all_deplibs=unknown - hardcode_automatic=no - module_cmds= - module_expsym_cmds= - always_export_symbols=no - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms="_GLOBAL_OFFSET_TABLE_" - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - extract_expsyms_cmds= - # Just being paranoid about ensuring that cc_basename is set. - for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - case $host_os in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - supports_anon_versioning=no - case `$LD -v 2>/dev/null` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - fi - ;; - - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - ld_shlibs=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - allow_undefined_flag=unsupported - always_export_symbols=no - enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs=no - fi - ;; - - interix3*) - hardcode_direct=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - linux*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - tmp_addflag= - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - esac - archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test $supports_anon_versioning = yes; then - archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - $echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - link_all_deplibs=no - else - ld_shlibs=no - fi - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = no; then - runpath_var= - hardcode_libdir_flag_spec= - export_dynamic_flag_spec= - whole_archive_flag_spec= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds='' - hardcode_direct=yes - hardcode_libdir_separator=':' - link_all_deplibs=yes - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; - - bsdi[45]*) - export_dynamic_flag_spec=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_From_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes=yes - ;; - - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[012]) - allow_undefined_flag='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - archive_cmds_need_lc=no - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - whole_archive_flag_spec='' - link_all_deplibs=yes - if test "$GCC" = yes ; then - output_verbose_link_cmd='echo' - archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - ld_shlibs=no - ;; - esac - fi - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - freebsd1*) - ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # GNU/kFreeBSD uses gcc -shared to do shared libraries. - kfreebsd*-gnu) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - link_all_deplibs=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - - hardcode_direct=yes - export_dynamic_flag_spec='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_libdir_flag_spec_ld='+b $libdir' - hardcode_direct=no - hardcode_shlibpath_var=no - ;; - *) - hardcode_direct=yes - export_dynamic_flag_spec='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_ld='-rpath $libdir' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - link_all_deplibs=yes - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - openbsd*) - hardcode_direct=yes - hardcode_shlibpath_var=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - - solaris*) - no_undefined_flag=' -z text' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine linker options so we - # cannot just pass the convience library names through - # without $wl, iff we do not link with $LD. - # Luckily, gcc supports the same syntax we need for Sun Studio. - # Supported since Solaris 2.6 (maybe 2.5.1?) - case $wlarc in - '') - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; - *) - whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; - esac ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds='$CC -r -o $output$reload_objs' - hardcode_direct=no - ;; - motorola) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) - no_undefined_flag='${wl}-z,text' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator=':' - link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $ld_shlibs" >&5 -echo "${ECHO_T}$ld_shlibs" >&6 -test "$ld_shlibs" = no && can_build_shared=no - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc=no - else - archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 -echo "${ECHO_T}$archive_cmds_need_lc" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[123]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - freebsd*) # from 4.6 on - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix3*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - shlibpath_overrides_runpath=no - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - shlibpath_overrides_runpath=yes - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var" || \ - test "X$hardcode_automatic" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action" >&5 -echo "${ECHO_T}$hardcode_action" >&6 - -if test "$hardcode_action" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - -striplib= -old_striplib= -echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 -echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - ;; - *) - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - ;; - esac -fi - -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - echo "$as_me:$LINENO: checking for shl_load" >&5 -echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 -if test "${ac_cv_func_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define shl_load to an innocuous variant, in case declares shl_load. - For example, HP-UX 11i declares gettimeofday. */ -#define shl_load innocuous_shl_load - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char shl_load (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef shl_load - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_shl_load) || defined (__stub___shl_load) -choke me -#else -char (*f) () = shl_load; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != shl_load; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 -echo "${ECHO_T}$ac_cv_func_shl_load" >&6 -if test $ac_cv_func_shl_load = yes; then - lt_cv_dlopen="shl_load" -else - echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 -echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_shl_load+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load (); -int -main () -{ -shl_load (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_shl_load=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_shl_load=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 -if test $ac_cv_lib_dld_shl_load = yes; then - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" -else - echo "$as_me:$LINENO: checking for dlopen" >&5 -echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 -if test "${ac_cv_func_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define dlopen to an innocuous variant, in case declares dlopen. - For example, HP-UX 11i declares gettimeofday. */ -#define dlopen innocuous_dlopen - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char dlopen (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef dlopen - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -char (*f) () = dlopen; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != dlopen; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 -echo "${ECHO_T}$ac_cv_func_dlopen" >&6 -if test $ac_cv_func_dlopen = yes; then - lt_cv_dlopen="dlopen" -else - echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 -echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 -if test "${ac_cv_lib_dl_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dl_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dl_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 -if test $ac_cv_lib_dl_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 -echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 -if test "${ac_cv_lib_svld_dlopen+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen (); -int -main () -{ -dlopen (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_svld_dlopen=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_svld_dlopen=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 -echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 -if test $ac_cv_lib_svld_dlopen = yes; then - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 -echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 -if test "${ac_cv_lib_dld_dld_link+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dld_link (); -int -main () -{ -dld_link (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_dld_dld_link=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_dld_dld_link=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 -echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 -if test $ac_cv_lib_dld_dld_link = yes; then - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 -echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self" >&6 - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 -echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 -if test "${lt_cv_dlopen_self_static+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self_static=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - exit (status); -} -EOF - if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 -echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi - - -# Report which library types will actually be built -echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 -echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $can_build_shared" >&5 -echo "${ECHO_T}$can_build_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 -echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case $host_os in -aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - -aix4* | aix5*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; -esac -echo "$as_me:$LINENO: result: $enable_shared" >&5 -echo "${ECHO_T}$enable_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build static libraries" >&5 -echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -echo "$as_me:$LINENO: result: $enable_static" >&5 -echo "${ECHO_T}$enable_static" >&6 - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # See if we are running on zsh, and set the options which allow our commands through - # without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler \ - CC \ - LD \ - lt_prog_compiler_wl \ - lt_prog_compiler_pic \ - lt_prog_compiler_static \ - lt_prog_compiler_no_builtin_flag \ - export_dynamic_flag_spec \ - thread_safe_flag_spec \ - whole_archive_flag_spec \ - enable_shared_with_static_runtimes \ - old_archive_cmds \ - old_archive_from_new_cmds \ - predep_objects \ - postdep_objects \ - predeps \ - postdeps \ - compiler_lib_search_path \ - archive_cmds \ - archive_expsym_cmds \ - postinstall_cmds \ - postuninstall_cmds \ - old_archive_from_expsyms_cmds \ - allow_undefined_flag \ - no_undefined_flag \ - export_symbols_cmds \ - hardcode_libdir_flag_spec \ - hardcode_libdir_flag_spec_ld \ - hardcode_libdir_separator \ - hardcode_automatic \ - module_cmds \ - module_expsym_cmds \ - lt_cv_prog_compiler_c_o \ - exclude_expsyms \ - include_expsyms; do - - case $var in - old_archive_cmds | \ - old_archive_from_new_cmds | \ - archive_cmds | \ - archive_expsym_cmds | \ - module_cmds | \ - module_expsym_cmds | \ - old_archive_from_expsyms_cmds | \ - export_symbols_cmds | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="${ofile}T" - trap "$rm \"$cfgfile\"; exit 1" 1 2 15 - $rm -f "$cfgfile" - { echo "$as_me:$LINENO: creating $ofile" >&5 -echo "$as_me: creating $ofile" >&6;} - - cat <<__EOF__ >> "$cfgfile" -#! $SHELL - -# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# -# This file is part of GNU Libtool: -# Originally by Gordon Matzigkeit , 1996 -# -# 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="$SED -e 1s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# The names of the tagged configurations supported by this script. -available_tags= - -# ### BEGIN LIBTOOL CONFIG - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU C compiler? -with_gcc=$GCC - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# ### END LIBTOOL CONFIG - -__EOF__ - - - case $host_os in - aix3*) - cat <<\EOF >> "$cfgfile" - -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -EOF - ;; - esac - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || \ - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - -# Check whether --with-tags or --without-tags was given. -if test "${with_tags+set}" = set; then - withval="$with_tags" - tagnames="$withval" -fi; - -if test -f "$ltmain" && test -n "$tagnames"; then - if test ! -f "${ofile}"; then - { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 -echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} - fi - - if test -z "$LTCC"; then - eval "`$SHELL ${ofile} --config | grep '^LTCC='`" - if test -z "$LTCC"; then - { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 -echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} - else - { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 -echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} - fi - fi - if test -z "$LTCFLAGS"; then - eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" - fi - - # Extract list of available tagged configurations in $ofile. - # Note that this assumes the entire list is on one line. - available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` - - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for tagname in $tagnames; do - IFS="$lt_save_ifs" - # Check whether tagname contains only valid characters - case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in - "") ;; - *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 -echo "$as_me: error: invalid tag name: $tagname" >&2;} - { (exit 1); exit 1; }; } - ;; - esac - - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null - then - { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 -echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} - { (exit 1); exit 1; }; } - fi - - # Update the list of available tags. - if test -n "$tagname"; then - echo appending configuration tag \"$tagname\" to $ofile - - case $tagname in - CXX) - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - - -archive_cmds_need_lc_CXX=no -allow_undefined_flag_CXX= -always_export_symbols_CXX=no -archive_expsym_cmds_CXX= -export_dynamic_flag_spec_CXX= -hardcode_direct_CXX=no -hardcode_libdir_flag_spec_CXX= -hardcode_libdir_flag_spec_ld_CXX= -hardcode_libdir_separator_CXX= -hardcode_minus_L_CXX=no -hardcode_shlibpath_var_CXX=unsupported -hardcode_automatic_CXX=no -module_cmds_CXX= -module_expsym_cmds_CXX= -link_all_deplibs_CXX=unknown -old_archive_cmds_CXX=$old_archive_cmds -no_undefined_flag_CXX= -whole_archive_flag_spec_CXX= -enable_shared_with_static_runtimes_CXX=no - -# Dependencies to place before and after the object being linked: -predep_objects_CXX= -postdep_objects_CXX= -predeps_CXX= -postdeps_CXX= -compiler_lib_search_path_CXX= - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -objext_CXX=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* - -ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* - - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_LD=$LD -lt_save_GCC=$GCC -GCC=$GXX -lt_save_with_gnu_ld=$with_gnu_ld -lt_save_path_LD=$lt_cv_path_LD -if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx -else - $as_unset lt_cv_prog_gnu_ld -fi -if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX -else - $as_unset lt_cv_path_LD -fi -test -z "${LDCXX+set}" || LD=$LDCXX -CC=${CXX-"c++"} -compiler=$CC -compiler_CXX=$CC -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - -# We don't want -fno-exception wen compiling C++ code, so set the -# no_builtin_flag separately -if test "$GXX" = yes; then - lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' -else - lt_prog_compiler_no_builtin_flag_CXX= -fi - -if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - -# Check whether --with-gnu-ld or --without-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then - withval="$with_gnu_ld" - test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi; -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - echo "$as_me:$LINENO: checking for ld used by $CC" >&5 -echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - echo "$as_me:$LINENO: checking for GNU ld" >&5 -echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 -else - echo "$as_me:$LINENO: checking for non-GNU ld" >&5 -echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 -fi -if test "${lt_cv_path_LD+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -echo "${ECHO_T}$LD" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 -echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} - { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 -echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 -if test "${lt_cv_prog_gnu_ld+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ - grep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_CXX= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - -else - GXX=no - with_gnu_ld=no - wlarc= -fi - -# PORTME: fill in a description of your system's C++ link characteristics -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 -ld_shlibs_CXX=yes -case $host_os in - aix3*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds_CXX='' - hardcode_direct_CXX=yes - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - - if test "$GXX" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct_CXX=yes - else - # We have old collect2 - hardcode_direct_CXX=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L_CXX=yes - hardcode_libdir_flag_spec_CXX='-L$libdir' - hardcode_libdir_separator_CXX= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols_CXX=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag_CXX='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - - archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_CXX="-z nodefs" - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag_CXX=' ${wl}-bernotok' - allow_undefined_flag_CXX=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_CXX='$convenience' - archive_cmds_need_lc_CXX=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_CXX=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_CXX=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_CXX='-L$libdir' - allow_undefined_flag_CXX=unsupported - always_export_symbols_CXX=no - enable_shared_with_static_runtimes_CXX=yes - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs_CXX=no - fi - ;; - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[012]) - allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - archive_cmds_need_lc_CXX=no - hardcode_direct_CXX=no - hardcode_automatic_CXX=yes - hardcode_shlibpath_var_CXX=unsupported - whole_archive_flag_spec_CXX='' - link_all_deplibs_CXX=yes - - if test "$GXX" = yes ; then - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - fi - module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - ld_shlibs_CXX=no - ;; - esac - fi - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - freebsd[12]*) - # C++ shared libraries reported to be fairly broken before switch to ELF - ld_shlibs_CXX=no - ;; - freebsd-elf*) - archive_cmds_need_lc_CXX=no - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - ld_shlibs_CXX=yes - ;; - gnu*) - ;; - hpux9*) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - export_dynamic_flag_spec_CXX='${wl}-E' - hardcode_direct_CXX=yes - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aCC*) - archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes; then - archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_libdir_flag_spec_ld_CXX='+b $libdir' - ;; - *) - export_dynamic_flag_spec_CXX='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - ;; - *) - hardcode_direct_CXX=yes - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - interix3*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' - fi - fi - link_all_deplibs_CXX=yes - ;; - esac - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - ;; - linux*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - - hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc*) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - archive_cmds_need_lc_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC*) - # Portland Group C++ compiler - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - esac - ;; - lynxos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - m88k*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - openbsd2*) - # C++ shared libraries are fairly broken - ld_shlibs_CXX=no - ;; - openbsd*) - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=no - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - export_dynamic_flag_spec_CXX='${wl}-E' - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd='echo' - ;; - osf3*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - hardcode_libdir_separator_CXX=: - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' - - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - cxx*) - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - hardcode_libdir_separator_CXX=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - cxx*) - allow_undefined_flag_CXX=' -expect_unresolved \*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ - $rm $lib.exp' - - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - psos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - archive_cmds_need_lc_CXX=yes - no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_shlibpath_var_CXX=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The C++ compiler is used as linker so we must use $wl - # flag to pass the commands to the underlying system - # linker. We must also pass each convience library through - # to the system linker between allextract/defaultextract. - # The C++ compiler will combine linker options so we - # cannot just pass the convience library names through - # without $wl. - # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' - ;; - esac - link_all_deplibs_CXX=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - no_undefined_flag_CXX=' ${wl}-z ${wl}defs' - if $CC --version | grep -v '^2\.7' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" - fi - - hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' - fi - ;; - esac - ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag_CXX='${wl}-z,text' - archive_cmds_need_lc_CXX=no - hardcode_shlibpath_var_CXX=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - # So that behaviour is only enabled if SCOABSPATH is set to a - # non-empty value in the environment. Most likely only useful for - # creating official distributions of packages. - # This is a hack until libtool officially supports absolute path - # names for shared libraries. - no_undefined_flag_CXX='${wl}-z,text' - allow_undefined_flag_CXX='${wl}-z,nodefs' - archive_cmds_need_lc_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - export_dynamic_flag_spec_CXX='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - vxworks*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; -esac -echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 -echo "${ECHO_T}$ld_shlibs_CXX" >&6 -test "$ld_shlibs_CXX" = no && can_build_shared=no - -GCC_CXX="$GXX" -LD_CXX="$LD" - - -cat > conftest.$ac_ext <&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - # The `*' in the case matches for architectures that use `case' in - # $output_verbose_cmd can trigger glob expansion during the loop - # eval without this substitution. - output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` - - for p in `eval $output_verbose_link_cmd`; do - case $p in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" \ - || test $p = "-R"; then - prev=$p - continue - else - prev= - fi - - if test "$pre_test_object_deps_done" = no; then - case $p in - -L* | -R*) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$compiler_lib_search_path_CXX"; then - compiler_lib_search_path_CXX="${prev}${p}" - else - compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$postdeps_CXX"; then - postdeps_CXX="${prev}${p}" - else - postdeps_CXX="${postdeps_CXX} ${prev}${p}" - fi - fi - ;; - - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$predep_objects_CXX"; then - predep_objects_CXX="$p" - else - predep_objects_CXX="$predep_objects_CXX $p" - fi - else - if test -z "$postdep_objects_CXX"; then - postdep_objects_CXX="$p" - else - postdep_objects_CXX="$postdep_objects_CXX $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling CXX test program" -fi - -$rm -f confest.$objext - -# PORTME: override above test on systems where it is broken -case $host_os in -interix3*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - predep_objects_CXX= - postdep_objects_CXX= - postdeps_CXX= - ;; - -solaris*) - case $cc_basename in - CC*) - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - postdeps_CXX='-lCstd -lCrun' - ;; - esac - ;; -esac - - -case " $postdeps_CXX " in -*" -lc "*) archive_cmds_need_lc_CXX=no ;; -esac - -lt_prog_compiler_wl_CXX= -lt_prog_compiler_pic_CXX= -lt_prog_compiler_static_CXX= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - fi - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | os2* | pw32*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_CXX='-DDLL_EXPORT' - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_CXX='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - lt_prog_compiler_pic_CXX= - ;; - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_CXX=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - else - case $host_os in - aix4* | aix5*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - else - lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - lt_prog_compiler_pic_CXX='-qnocommon' - lt_prog_compiler_wl_CXX='-Wl,' - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - lt_prog_compiler_pic_CXX='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - lt_prog_compiler_pic_CXX='+Z' - fi - ;; - aCC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_CXX='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux*) - case $cc_basename in - KCC*) - # KAI C++ Compiler - lt_prog_compiler_wl_CXX='--backend -Wl,' - lt_prog_compiler_pic_CXX='-fPIC' - ;; - icpc* | ecpc*) - # Intel C++ - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-static' - ;; - pgCC*) - # Portland Group C++ compiler. - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-fpic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - *) - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - lt_prog_compiler_pic_CXX='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - lt_prog_compiler_wl_CXX='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - lt_prog_compiler_pic_CXX='-pic' - ;; - cxx*) - # Digital/Compaq C++ - lt_prog_compiler_wl_CXX='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - lt_prog_compiler_wl_CXX='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - lt_prog_compiler_pic_CXX='-pic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - lcc*) - # Lucid - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - lt_prog_compiler_pic_CXX='-KPIC' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - esac - ;; - vxworks*) - ;; - *) - lt_prog_compiler_can_build_shared_CXX=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_CXX"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works_CXX=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12245: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:12249: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_pic_works_CXX=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 - -if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then - case $lt_prog_compiler_pic_CXX in - "" | " "*) ;; - *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; - esac -else - lt_prog_compiler_pic_CXX= - lt_prog_compiler_can_build_shared_CXX=no -fi - -fi -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_CXX= - ;; - *) - lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" - ;; -esac - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" -echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 -if test "${lt_prog_compiler_static_works_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_static_works_CXX=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_static_works_CXX=yes - fi - else - lt_prog_compiler_static_works_CXX=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5 -echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6 - -if test x"$lt_prog_compiler_static_works_CXX" = xyes; then - : -else - lt_prog_compiler_static_CXX= -fi - - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o_CXX=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12349: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:12353: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_CXX=yes - fi - fi - chmod u+w . 2>&5 - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix4* | aix5*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - export_symbols_cmds_CXX="$ltdll_cmds" - ;; - cygwin* | mingw*) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - ;; - kfreebsd*-gnu) - link_all_deplibs_CXX=no - ;; - linux*) - link_all_deplibs_CXX=no - ;; - *) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - -echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 -echo "${ECHO_T}$ld_shlibs_CXX" >&6 -test "$ld_shlibs_CXX" = no && can_build_shared=no - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_CXX" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_CXX=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_CXX in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_CXX - pic_flag=$lt_prog_compiler_pic_CXX - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_CXX - allow_undefined_flag_CXX= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc_CXX=no - else - archive_cmds_need_lc_CXX=yes - fi - allow_undefined_flag_CXX=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 -echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[123]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - freebsd*) # from 4.6 on - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix3*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - shlibpath_overrides_runpath=no - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - shlibpath_overrides_runpath=yes - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action_CXX= -if test -n "$hardcode_libdir_flag_spec_CXX" || \ - test -n "$runpath_var_CXX" || \ - test "X$hardcode_automatic_CXX" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct_CXX" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && - test "$hardcode_minus_L_CXX" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_CXX=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_CXX=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_CXX=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 -echo "${ECHO_T}$hardcode_action_CXX" >&6 - -if test "$hardcode_action_CXX" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # See if we are running on zsh, and set the options which allow our commands through - # without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_CXX \ - CC_CXX \ - LD_CXX \ - lt_prog_compiler_wl_CXX \ - lt_prog_compiler_pic_CXX \ - lt_prog_compiler_static_CXX \ - lt_prog_compiler_no_builtin_flag_CXX \ - export_dynamic_flag_spec_CXX \ - thread_safe_flag_spec_CXX \ - whole_archive_flag_spec_CXX \ - enable_shared_with_static_runtimes_CXX \ - old_archive_cmds_CXX \ - old_archive_from_new_cmds_CXX \ - predep_objects_CXX \ - postdep_objects_CXX \ - predeps_CXX \ - postdeps_CXX \ - compiler_lib_search_path_CXX \ - archive_cmds_CXX \ - archive_expsym_cmds_CXX \ - postinstall_cmds_CXX \ - postuninstall_cmds_CXX \ - old_archive_from_expsyms_cmds_CXX \ - allow_undefined_flag_CXX \ - no_undefined_flag_CXX \ - export_symbols_cmds_CXX \ - hardcode_libdir_flag_spec_CXX \ - hardcode_libdir_flag_spec_ld_CXX \ - hardcode_libdir_separator_CXX \ - hardcode_automatic_CXX \ - module_cmds_CXX \ - module_expsym_cmds_CXX \ - lt_cv_prog_compiler_c_o_CXX \ - exclude_expsyms_CXX \ - include_expsyms_CXX; do - - case $var in - old_archive_cmds_CXX | \ - old_archive_from_new_cmds_CXX | \ - archive_cmds_CXX | \ - archive_expsym_cmds_CXX | \ - module_cmds_CXX | \ - module_expsym_cmds_CXX | \ - old_archive_from_expsyms_cmds_CXX | \ - export_symbols_cmds_CXX | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_CXX - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_compiler_CXX - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_CXX - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_CXX - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_CXX - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_CXX -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_CXX - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_CXX -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_CXX -archive_expsym_cmds=$lt_archive_expsym_cmds_CXX -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_CXX -module_expsym_cmds=$lt_module_expsym_cmds_CXX - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_CXX - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_CXX - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_CXX - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_CXX - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_CXX - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_CXX - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_CXX - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_CXX - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_CXX - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_CXX - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_CXX - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_CXX - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_CXX" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_CXX - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_CXX - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_CXX - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_CXX - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC=$lt_save_CC -LDCXX=$LD -LD=$lt_save_LD -GCC=$lt_save_GCC -with_gnu_ldcxx=$with_gnu_ld -with_gnu_ld=$lt_save_with_gnu_ld -lt_cv_path_LDCXX=$lt_cv_path_LD -lt_cv_path_LD=$lt_save_path_LD -lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld -lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld - - else - tagname="" - fi - ;; - - F77) - if test -n "$F77" && test "X$F77" != "Xno"; then - -ac_ext=f -ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' -ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_f77_compiler_gnu - - -archive_cmds_need_lc_F77=no -allow_undefined_flag_F77= -always_export_symbols_F77=no -archive_expsym_cmds_F77= -export_dynamic_flag_spec_F77= -hardcode_direct_F77=no -hardcode_libdir_flag_spec_F77= -hardcode_libdir_flag_spec_ld_F77= -hardcode_libdir_separator_F77= -hardcode_minus_L_F77=no -hardcode_automatic_F77=no -module_cmds_F77= -module_expsym_cmds_F77= -link_all_deplibs_F77=unknown -old_archive_cmds_F77=$old_archive_cmds -no_undefined_flag_F77= -whole_archive_flag_spec_F77= -enable_shared_with_static_runtimes_F77=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -objext_F77=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code=" subroutine t\n return\n end\n" - -# Code to be used in simple link tests -lt_simple_link_test_code=" program t\n end\n" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* - -ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* - - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -CC=${F77-"f77"} -compiler=$CC -compiler_F77=$CC -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - -echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 -echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $can_build_shared" >&5 -echo "${ECHO_T}$can_build_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 -echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case $host_os in -aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; -aix4* | aix5*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; -esac -echo "$as_me:$LINENO: result: $enable_shared" >&5 -echo "${ECHO_T}$enable_shared" >&6 - -echo "$as_me:$LINENO: checking whether to build static libraries" >&5 -echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -echo "$as_me:$LINENO: result: $enable_static" >&5 -echo "${ECHO_T}$enable_static" >&6 - -GCC_F77="$G77" -LD_F77="$LD" - -lt_prog_compiler_wl_F77= -lt_prog_compiler_pic_F77= -lt_prog_compiler_static_F77= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - if test "$GCC" = yes; then - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_static_F77='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_F77='-Bstatic' - fi - ;; - - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_F77='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_F77='-fno-common' - ;; - - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared_F77=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_F77=-Kconform_pic - fi - ;; - - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_F77='-fPIC' - ;; - esac - ;; - - *) - lt_prog_compiler_pic_F77='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl_F77='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_F77='-Bstatic' - else - lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' - fi - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - lt_prog_compiler_pic_F77='-qnocommon' - lt_prog_compiler_wl_F77='-Wl,' - ;; - esac - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_F77='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl_F77='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_F77='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static_F77='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl_F77='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static_F77='-non_shared' - ;; - - newsos6) - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - linux*) - case $cc_basename in - icc* | ecc*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-fpic' - lt_prog_compiler_static_F77='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl_F77='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static_F77='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl_F77='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static_F77='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - lt_prog_compiler_wl_F77='-Qoption ld ';; - *) - lt_prog_compiler_wl_F77='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl_F77='-Qoption ld ' - lt_prog_compiler_pic_F77='-PIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic_F77='-Kconform_pic' - lt_prog_compiler_static_F77='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_pic_F77='-KPIC' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl_F77='-Wl,' - lt_prog_compiler_can_build_shared_F77=no - ;; - - uts4*) - lt_prog_compiler_pic_F77='-pic' - lt_prog_compiler_static_F77='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared_F77=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_F77"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works_F77=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_F77" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13937: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:13941: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_pic_works_F77=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 - -if test x"$lt_prog_compiler_pic_works_F77" = xyes; then - case $lt_prog_compiler_pic_F77 in - "" | " "*) ;; - *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; - esac -else - lt_prog_compiler_pic_F77= - lt_prog_compiler_can_build_shared_F77=no -fi - -fi -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_F77= - ;; - *) - lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" - ;; -esac - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\" -echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 -if test "${lt_prog_compiler_static_works_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_static_works_F77=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_static_works_F77=yes - fi - else - lt_prog_compiler_static_works_F77=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5 -echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6 - -if test x"$lt_prog_compiler_static_works_F77" = xyes; then - : -else - lt_prog_compiler_static_F77= -fi - - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o_F77=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14041: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:14045: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_F77=yes - fi - fi - chmod u+w . 2>&5 - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - runpath_var= - allow_undefined_flag_F77= - enable_shared_with_static_runtimes_F77=no - archive_cmds_F77= - archive_expsym_cmds_F77= - old_archive_From_new_cmds_F77= - old_archive_from_expsyms_cmds_F77= - export_dynamic_flag_spec_F77= - whole_archive_flag_spec_F77= - thread_safe_flag_spec_F77= - hardcode_libdir_flag_spec_F77= - hardcode_libdir_flag_spec_ld_F77= - hardcode_libdir_separator_F77= - hardcode_direct_F77=no - hardcode_minus_L_F77=no - hardcode_shlibpath_var_F77=unsupported - link_all_deplibs_F77=unknown - hardcode_automatic_F77=no - module_cmds_F77= - module_expsym_cmds_F77= - always_export_symbols_F77=no - export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms_F77= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - extract_expsyms_cmds= - # Just being paranoid about ensuring that cc_basename is set. - for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - case $host_os in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs_F77=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_F77='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_F77= - fi - supports_anon_versioning=no - case `$LD -v 2>/dev/null` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs_F77=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - fi - ;; - - amigaos*) - archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_minus_L_F77=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - ld_shlibs_F77=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_F77=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_F77=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_F77='-L$libdir' - allow_undefined_flag_F77=unsupported - always_export_symbols_F77=no - enable_shared_with_static_runtimes_F77=yes - export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs_F77=no - fi - ;; - - interix3*) - hardcode_direct_F77=no - hardcode_shlibpath_var_F77=no - hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' - export_dynamic_flag_spec_F77='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - linux*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - tmp_addflag= - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - esac - archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test $supports_anon_versioning = yes; then - archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - $echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - link_all_deplibs_F77=no - else - ld_shlibs_F77=no - fi - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs_F77=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_F77=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs_F77=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' - else - ld_shlibs_F77=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_F77=no - fi - ;; - esac - - if test "$ld_shlibs_F77" = no; then - runpath_var= - hardcode_libdir_flag_spec_F77= - export_dynamic_flag_spec_F77= - whole_archive_flag_spec_F77= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag_F77=unsupported - always_export_symbols_F77=yes - archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L_F77=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct_F77=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds_F77='' - hardcode_direct_F77=yes - hardcode_libdir_separator_F77=':' - link_all_deplibs_F77=yes - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct_F77=yes - else - # We have old collect2 - hardcode_direct_F77=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L_F77=yes - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_libdir_separator_F77= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols_F77=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag_F77='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_F77="-z nodefs" - archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag_F77=' ${wl}-bernotok' - allow_undefined_flag_F77=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_F77='$convenience' - archive_cmds_need_lc_F77=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_minus_L_F77=yes - # see comment about different semantics on the GNU ld section - ld_shlibs_F77=no - ;; - - bsdi[45]*) - export_dynamic_flag_spec_F77=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec_F77=' ' - allow_undefined_flag_F77=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_From_new_cmds_F77='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path_F77='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes_F77=yes - ;; - - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[012]) - allow_undefined_flag_F77='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - archive_cmds_need_lc_F77=no - hardcode_direct_F77=no - hardcode_automatic_F77=yes - hardcode_shlibpath_var_F77=unsupported - whole_archive_flag_spec_F77='' - link_all_deplibs_F77=yes - if test "$GCC" = yes ; then - output_verbose_link_cmd='echo' - archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - ld_shlibs_F77=no - ;; - esac - fi - ;; - - dgux*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_shlibpath_var_F77=no - ;; - - freebsd1*) - ld_shlibs_F77=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes - hardcode_minus_L_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - # GNU/kFreeBSD uses gcc -shared to do shared libraries. - kfreebsd*-gnu) - archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - link_all_deplibs_F77=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_F77=: - hardcode_direct_F77=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_F77=yes - export_dynamic_flag_spec_F77='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_F77=: - - hardcode_direct_F77=yes - export_dynamic_flag_spec_F77='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_F77=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_F77=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_libdir_flag_spec_ld_F77='+b $libdir' - hardcode_direct_F77=no - hardcode_shlibpath_var_F77=no - ;; - *) - hardcode_direct_F77=yes - export_dynamic_flag_spec_F77='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_F77=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' - fi - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_F77=: - link_all_deplibs_F77=yes - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - newsos6) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_F77=: - hardcode_shlibpath_var_F77=no - ;; - - openbsd*) - hardcode_direct_F77=yes - hardcode_shlibpath_var_F77=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' - export_dynamic_flag_spec_F77='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_F77='-R$libdir' - ;; - *) - archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_minus_L_F77=yes - allow_undefined_flag_F77=unsupported - archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag_F77=' -expect_unresolved \*' - archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_F77=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag_F77=' -expect_unresolved \*' - archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec_F77='-rpath $libdir' - fi - hardcode_libdir_separator_F77=: - ;; - - solaris*) - no_undefined_flag_F77=' -z text' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - wlarc='' - archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - fi - hardcode_libdir_flag_spec_F77='-R$libdir' - hardcode_shlibpath_var_F77=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine linker options so we - # cannot just pass the convience library names through - # without $wl, iff we do not link with $LD. - # Luckily, gcc supports the same syntax we need for Sun Studio. - # Supported since Solaris 2.6 (maybe 2.5.1?) - case $wlarc in - '') - whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; - *) - whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; - esac ;; - esac - link_all_deplibs_F77=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_direct_F77=yes - hardcode_minus_L_F77=yes - hardcode_shlibpath_var_F77=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds_F77='$CC -r -o $output$reload_objs' - hardcode_direct_F77=no - ;; - motorola) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var_F77=no - ;; - - sysv4.3*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_F77=no - export_dynamic_flag_spec_F77='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_F77=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs_F77=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) - no_undefined_flag_F77='${wl}-z,text' - archive_cmds_need_lc_F77=no - hardcode_shlibpath_var_F77=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag_F77='${wl}-z,text' - allow_undefined_flag_F77='${wl}-z,nodefs' - archive_cmds_need_lc_F77=no - hardcode_shlibpath_var_F77=no - hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator_F77=':' - link_all_deplibs_F77=yes - export_dynamic_flag_spec_F77='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_F77='-L$libdir' - hardcode_shlibpath_var_F77=no - ;; - - *) - ld_shlibs_F77=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 -echo "${ECHO_T}$ld_shlibs_F77" >&6 -test "$ld_shlibs_F77" = no && can_build_shared=no - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_F77" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_F77=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_F77 in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_F77 - pic_flag=$lt_prog_compiler_pic_F77 - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_F77 - allow_undefined_flag_F77= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc_F77=no - else - archive_cmds_need_lc_F77=yes - fi - allow_undefined_flag_F77=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 -echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[123]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - freebsd*) # from 4.6 on - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix3*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - shlibpath_overrides_runpath=no - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - shlibpath_overrides_runpath=yes - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action_F77= -if test -n "$hardcode_libdir_flag_spec_F77" || \ - test -n "$runpath_var_F77" || \ - test "X$hardcode_automatic_F77" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct_F77" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && - test "$hardcode_minus_L_F77" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_F77=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_F77=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_F77=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 -echo "${ECHO_T}$hardcode_action_F77" >&6 - -if test "$hardcode_action_F77" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # See if we are running on zsh, and set the options which allow our commands through - # without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_F77 \ - CC_F77 \ - LD_F77 \ - lt_prog_compiler_wl_F77 \ - lt_prog_compiler_pic_F77 \ - lt_prog_compiler_static_F77 \ - lt_prog_compiler_no_builtin_flag_F77 \ - export_dynamic_flag_spec_F77 \ - thread_safe_flag_spec_F77 \ - whole_archive_flag_spec_F77 \ - enable_shared_with_static_runtimes_F77 \ - old_archive_cmds_F77 \ - old_archive_from_new_cmds_F77 \ - predep_objects_F77 \ - postdep_objects_F77 \ - predeps_F77 \ - postdeps_F77 \ - compiler_lib_search_path_F77 \ - archive_cmds_F77 \ - archive_expsym_cmds_F77 \ - postinstall_cmds_F77 \ - postuninstall_cmds_F77 \ - old_archive_from_expsyms_cmds_F77 \ - allow_undefined_flag_F77 \ - no_undefined_flag_F77 \ - export_symbols_cmds_F77 \ - hardcode_libdir_flag_spec_F77 \ - hardcode_libdir_flag_spec_ld_F77 \ - hardcode_libdir_separator_F77 \ - hardcode_automatic_F77 \ - module_cmds_F77 \ - module_expsym_cmds_F77 \ - lt_cv_prog_compiler_c_o_F77 \ - exclude_expsyms_F77 \ - include_expsyms_F77; do - - case $var in - old_archive_cmds_F77 | \ - old_archive_from_new_cmds_F77 | \ - archive_cmds_F77 | \ - archive_expsym_cmds_F77 | \ - module_cmds_F77 | \ - module_expsym_cmds_F77 | \ - old_archive_from_expsyms_cmds_F77 | \ - export_symbols_cmds_F77 | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_F77 - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_compiler_F77 - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_F77 - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_F77 - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_F77 - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_F77 -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_F77 - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_F77 -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_F77 -archive_expsym_cmds=$lt_archive_expsym_cmds_F77 -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_F77 -module_expsym_cmds=$lt_module_expsym_cmds_F77 - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_F77 - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_F77 - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_F77 - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_F77 - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_F77 - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_F77 - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_F77 - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_F77 - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_F77 - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_F77 - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_F77 - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_F77 - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_F77" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_F77 - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_F77 - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_F77 - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_F77 - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - else - tagname="" - fi - ;; - - GCJ) - if test -n "$GCJ" && test "X$GCJ" != "Xno"; then - - - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -objext_GCJ=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* - -ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* - - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -CC=${GCJ-"gcj"} -compiler=$CC -compiler_GCJ=$CC -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -archive_cmds_need_lc_GCJ=no - -old_archive_cmds_GCJ=$old_archive_cmds - - -lt_prog_compiler_no_builtin_flag_GCJ= - -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' - - -echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16264: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:16268: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" -else - : -fi - -fi - -lt_prog_compiler_wl_GCJ= -lt_prog_compiler_pic_GCJ= -lt_prog_compiler_static_GCJ= - -echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 -echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 - - if test "$GCC" = yes; then - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_static_GCJ='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_GCJ='-Bstatic' - fi - ;; - - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_GCJ='-fno-common' - ;; - - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared_GCJ=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_GCJ=-Kconform_pic - fi - ;; - - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_GCJ='-fPIC' - ;; - esac - ;; - - *) - lt_prog_compiler_pic_GCJ='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl_GCJ='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_GCJ='-Bstatic' - else - lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' - fi - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - lt_prog_compiler_pic_GCJ='-qnocommon' - lt_prog_compiler_wl_GCJ='-Wl,' - ;; - esac - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl_GCJ='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_GCJ='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl_GCJ='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static_GCJ='-non_shared' - ;; - - newsos6) - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - linux*) - case $cc_basename in - icc* | ecc*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-fpic' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl_GCJ='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static_GCJ='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl_GCJ='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static_GCJ='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - lt_prog_compiler_wl_GCJ='-Qoption ld ';; - *) - lt_prog_compiler_wl_GCJ='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl_GCJ='-Qoption ld ' - lt_prog_compiler_pic_GCJ='-PIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic_GCJ='-Kconform_pic' - lt_prog_compiler_static_GCJ='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_pic_GCJ='-KPIC' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl_GCJ='-Wl,' - lt_prog_compiler_can_build_shared_GCJ=no - ;; - - uts4*) - lt_prog_compiler_pic_GCJ='-pic' - lt_prog_compiler_static_GCJ='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared_GCJ=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_GCJ"; then - -echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 -echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 -if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_pic_works_GCJ=no - ac_outfile=conftest.$ac_objext - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_GCJ" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16532: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:16536: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_pic_works_GCJ=yes - fi - fi - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 -echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 - -if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then - case $lt_prog_compiler_pic_GCJ in - "" | " "*) ;; - *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; - esac -else - lt_prog_compiler_pic_GCJ= - lt_prog_compiler_can_build_shared_GCJ=no -fi - -fi -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_GCJ= - ;; - *) - lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" - ;; -esac - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\" -echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 -if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_prog_compiler_static_works_GCJ=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_prog_compiler_static_works_GCJ=yes - fi - else - lt_prog_compiler_static_works_GCJ=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" - -fi -echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5 -echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6 - -if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then - : -else - lt_prog_compiler_static_GCJ= -fi - - -echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 -echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 -if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - lt_cv_prog_compiler_c_o_GCJ=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16636: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:16640: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_GCJ=yes - fi - fi - chmod u+w . 2>&5 - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* - -fi -echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 -echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 -echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:$LINENO: result: $hard_links" >&5 -echo "${ECHO_T}$hard_links" >&6 - if test "$hard_links" = no; then - { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - -echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 - - runpath_var= - allow_undefined_flag_GCJ= - enable_shared_with_static_runtimes_GCJ=no - archive_cmds_GCJ= - archive_expsym_cmds_GCJ= - old_archive_From_new_cmds_GCJ= - old_archive_from_expsyms_cmds_GCJ= - export_dynamic_flag_spec_GCJ= - whole_archive_flag_spec_GCJ= - thread_safe_flag_spec_GCJ= - hardcode_libdir_flag_spec_GCJ= - hardcode_libdir_flag_spec_ld_GCJ= - hardcode_libdir_separator_GCJ= - hardcode_direct_GCJ=no - hardcode_minus_L_GCJ=no - hardcode_shlibpath_var_GCJ=unsupported - link_all_deplibs_GCJ=unknown - hardcode_automatic_GCJ=no - module_cmds_GCJ= - module_expsym_cmds_GCJ= - always_export_symbols_GCJ=no - export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms_GCJ= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - extract_expsyms_cmds= - # Just being paranoid about ensuring that cc_basename is set. - for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - case $host_os in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs_GCJ=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_GCJ= - fi - supports_anon_versioning=no - case `$LD -v 2>/dev/null` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs_GCJ=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - fi - ;; - - amigaos*) - archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_minus_L_GCJ=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - ld_shlibs_GCJ=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_GCJ=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_GCJ='-L$libdir' - allow_undefined_flag_GCJ=unsupported - always_export_symbols_GCJ=no - enable_shared_with_static_runtimes_GCJ=yes - export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs_GCJ=no - fi - ;; - - interix3*) - hardcode_direct_GCJ=no - hardcode_shlibpath_var_GCJ=no - hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' - export_dynamic_flag_spec_GCJ='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - linux*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - tmp_addflag= - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - esac - archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test $supports_anon_versioning = yes; then - archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - $echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - link_all_deplibs_GCJ=no - else - ld_shlibs_GCJ=no - fi - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs_GCJ=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs_GCJ=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs_GCJ=no - fi - ;; - esac - - if test "$ld_shlibs_GCJ" = no; then - runpath_var= - hardcode_libdir_flag_spec_GCJ= - export_dynamic_flag_spec_GCJ= - whole_archive_flag_spec_GCJ= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag_GCJ=unsupported - always_export_symbols_GCJ=yes - archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L_GCJ=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct_GCJ=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds_GCJ='' - hardcode_direct_GCJ=yes - hardcode_libdir_separator_GCJ=':' - link_all_deplibs_GCJ=yes - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct_GCJ=yes - else - # We have old collect2 - hardcode_direct_GCJ=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L_GCJ=yes - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_libdir_separator_GCJ= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols_GCJ=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag_GCJ='-berok' - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_GCJ="-z nodefs" - archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag_GCJ=' ${wl}-bernotok' - allow_undefined_flag_GCJ=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_GCJ='$convenience' - archive_cmds_need_lc_GCJ=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_minus_L_GCJ=yes - # see comment about different semantics on the GNU ld section - ld_shlibs_GCJ=no - ;; - - bsdi[45]*) - export_dynamic_flag_spec_GCJ=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec_GCJ=' ' - allow_undefined_flag_GCJ=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_From_new_cmds_GCJ='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes_GCJ=yes - ;; - - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[012]) - allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[012]) - allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - archive_cmds_need_lc_GCJ=no - hardcode_direct_GCJ=no - hardcode_automatic_GCJ=yes - hardcode_shlibpath_var_GCJ=unsupported - whole_archive_flag_spec_GCJ='' - link_all_deplibs_GCJ=yes - if test "$GCC" = yes ; then - output_verbose_link_cmd='echo' - archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - ld_shlibs_GCJ=no - ;; - esac - fi - ;; - - dgux*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_shlibpath_var_GCJ=no - ;; - - freebsd1*) - ld_shlibs_GCJ=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes - hardcode_minus_L_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - # GNU/kFreeBSD uses gcc -shared to do shared libraries. - kfreebsd*-gnu) - archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - link_all_deplibs_GCJ=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - hardcode_direct_GCJ=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_GCJ=yes - export_dynamic_flag_spec_GCJ='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - - hardcode_direct_GCJ=yes - export_dynamic_flag_spec_GCJ='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_GCJ=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' - hardcode_direct_GCJ=no - hardcode_shlibpath_var_GCJ=no - ;; - *) - hardcode_direct_GCJ=yes - export_dynamic_flag_spec_GCJ='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L_GCJ=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' - fi - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - link_all_deplibs_GCJ=yes - ;; - - netbsd* | netbsdelf*-gnu | knetbsd*-gnu) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - newsos6) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - hardcode_shlibpath_var_GCJ=no - ;; - - openbsd*) - hardcode_direct_GCJ=yes - hardcode_shlibpath_var_GCJ=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' - export_dynamic_flag_spec_GCJ='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_GCJ='-R$libdir' - ;; - *) - archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_minus_L_GCJ=yes - allow_undefined_flag_GCJ=unsupported - archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag_GCJ=' -expect_unresolved \*' - archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_GCJ=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag_GCJ=' -expect_unresolved \*' - archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec_GCJ='-rpath $libdir' - fi - hardcode_libdir_separator_GCJ=: - ;; - - solaris*) - no_undefined_flag_GCJ=' -z text' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - wlarc='' - archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - fi - hardcode_libdir_flag_spec_GCJ='-R$libdir' - hardcode_shlibpath_var_GCJ=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine linker options so we - # cannot just pass the convience library names through - # without $wl, iff we do not link with $LD. - # Luckily, gcc supports the same syntax we need for Sun Studio. - # Supported since Solaris 2.6 (maybe 2.5.1?) - case $wlarc in - '') - whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; - *) - whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; - esac ;; - esac - link_all_deplibs_GCJ=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_direct_GCJ=yes - hardcode_minus_L_GCJ=yes - hardcode_shlibpath_var_GCJ=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds_GCJ='$CC -r -o $output$reload_objs' - hardcode_direct_GCJ=no - ;; - motorola) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var_GCJ=no - ;; - - sysv4.3*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_GCJ=no - export_dynamic_flag_spec_GCJ='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var_GCJ=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs_GCJ=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) - no_undefined_flag_GCJ='${wl}-z,text' - archive_cmds_need_lc_GCJ=no - hardcode_shlibpath_var_GCJ=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag_GCJ='${wl}-z,text' - allow_undefined_flag_GCJ='${wl}-z,nodefs' - archive_cmds_need_lc_GCJ=no - hardcode_shlibpath_var_GCJ=no - hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator_GCJ=':' - link_all_deplibs_GCJ=yes - export_dynamic_flag_spec_GCJ='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec_GCJ='-L$libdir' - hardcode_shlibpath_var_GCJ=no - ;; - - *) - ld_shlibs_GCJ=no - ;; - esac - fi - -echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 -echo "${ECHO_T}$ld_shlibs_GCJ" >&6 -test "$ld_shlibs_GCJ" = no && can_build_shared=no - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_GCJ" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_GCJ=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_GCJ in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 -echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_GCJ - pic_flag=$lt_prog_compiler_pic_GCJ - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ - allow_undefined_flag_GCJ= - if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 - (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - then - archive_cmds_need_lc_GCJ=no - else - archive_cmds_need_lc_GCJ=yes - fi - allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 -echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 - ;; - esac - fi - ;; -esac - -echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 -echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[123]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - freebsd*) # from 4.6 on - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix3*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - shlibpath_overrides_runpath=no - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - shlibpath_overrides_runpath=yes - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -echo "$as_me:$LINENO: result: $dynamic_linker" >&5 -echo "${ECHO_T}$dynamic_linker" >&6 -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 -echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 -hardcode_action_GCJ= -if test -n "$hardcode_libdir_flag_spec_GCJ" || \ - test -n "$runpath_var_GCJ" || \ - test "X$hardcode_automatic_GCJ" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$hardcode_direct_GCJ" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && - test "$hardcode_minus_L_GCJ" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_GCJ=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_GCJ=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_GCJ=unsupported -fi -echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 -echo "${ECHO_T}$hardcode_action_GCJ" >&6 - -if test "$hardcode_action_GCJ" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # See if we are running on zsh, and set the options which allow our commands through - # without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_GCJ \ - CC_GCJ \ - LD_GCJ \ - lt_prog_compiler_wl_GCJ \ - lt_prog_compiler_pic_GCJ \ - lt_prog_compiler_static_GCJ \ - lt_prog_compiler_no_builtin_flag_GCJ \ - export_dynamic_flag_spec_GCJ \ - thread_safe_flag_spec_GCJ \ - whole_archive_flag_spec_GCJ \ - enable_shared_with_static_runtimes_GCJ \ - old_archive_cmds_GCJ \ - old_archive_from_new_cmds_GCJ \ - predep_objects_GCJ \ - postdep_objects_GCJ \ - predeps_GCJ \ - postdeps_GCJ \ - compiler_lib_search_path_GCJ \ - archive_cmds_GCJ \ - archive_expsym_cmds_GCJ \ - postinstall_cmds_GCJ \ - postuninstall_cmds_GCJ \ - old_archive_from_expsyms_cmds_GCJ \ - allow_undefined_flag_GCJ \ - no_undefined_flag_GCJ \ - export_symbols_cmds_GCJ \ - hardcode_libdir_flag_spec_GCJ \ - hardcode_libdir_flag_spec_ld_GCJ \ - hardcode_libdir_separator_GCJ \ - hardcode_automatic_GCJ \ - module_cmds_GCJ \ - module_expsym_cmds_GCJ \ - lt_cv_prog_compiler_c_o_GCJ \ - exclude_expsyms_GCJ \ - include_expsyms_GCJ; do - - case $var in - old_archive_cmds_GCJ | \ - old_archive_from_new_cmds_GCJ | \ - archive_cmds_GCJ | \ - archive_expsym_cmds_GCJ | \ - module_cmds_GCJ | \ - module_expsym_cmds_GCJ | \ - old_archive_from_expsyms_cmds_GCJ | \ - export_symbols_cmds_GCJ | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_GCJ - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_compiler_GCJ - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_GCJ - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_GCJ - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_GCJ - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_GCJ -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_GCJ - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_GCJ -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_GCJ -archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_GCJ -module_expsym_cmds=$lt_module_expsym_cmds_GCJ - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_GCJ - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_GCJ - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_GCJ - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_GCJ - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_GCJ - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_GCJ - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_GCJ - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_GCJ - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_GCJ - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_GCJ - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_GCJ - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_GCJ" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_GCJ - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_GCJ - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_GCJ - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_GCJ - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - else - tagname="" - fi - ;; - - RC) - - - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -objext_RC=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* - -ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* - - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -CC=${RC-"windres"} -compiler=$CC -compiler_RC=$CC -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - -lt_cv_prog_compiler_c_o_RC=yes - -# The else clause should only fire when bootstrapping the -# libtool distribution, otherwise you forgot to ship ltmain.sh -# with your package, and you will get complaints that there are -# no rules to generate ltmain.sh. -if test -f "$ltmain"; then - # See if we are running on zsh, and set the options which allow our commands through - # without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - # Now quote all the things that may contain metacharacters while being - # careful not to overquote the AC_SUBSTed values. We take copies of the - # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ - SED SHELL STRIP \ - libname_spec library_names_spec soname_spec extract_expsyms_cmds \ - old_striplib striplib file_magic_cmd finish_cmds finish_eval \ - deplibs_check_method reload_flag reload_cmds need_locks \ - lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ - lt_cv_sys_global_symbol_to_c_name_address \ - sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - old_postinstall_cmds old_postuninstall_cmds \ - compiler_RC \ - CC_RC \ - LD_RC \ - lt_prog_compiler_wl_RC \ - lt_prog_compiler_pic_RC \ - lt_prog_compiler_static_RC \ - lt_prog_compiler_no_builtin_flag_RC \ - export_dynamic_flag_spec_RC \ - thread_safe_flag_spec_RC \ - whole_archive_flag_spec_RC \ - enable_shared_with_static_runtimes_RC \ - old_archive_cmds_RC \ - old_archive_from_new_cmds_RC \ - predep_objects_RC \ - postdep_objects_RC \ - predeps_RC \ - postdeps_RC \ - compiler_lib_search_path_RC \ - archive_cmds_RC \ - archive_expsym_cmds_RC \ - postinstall_cmds_RC \ - postuninstall_cmds_RC \ - old_archive_from_expsyms_cmds_RC \ - allow_undefined_flag_RC \ - no_undefined_flag_RC \ - export_symbols_cmds_RC \ - hardcode_libdir_flag_spec_RC \ - hardcode_libdir_flag_spec_ld_RC \ - hardcode_libdir_separator_RC \ - hardcode_automatic_RC \ - module_cmds_RC \ - module_expsym_cmds_RC \ - lt_cv_prog_compiler_c_o_RC \ - exclude_expsyms_RC \ - include_expsyms_RC; do - - case $var in - old_archive_cmds_RC | \ - old_archive_from_new_cmds_RC | \ - archive_cmds_RC | \ - archive_expsym_cmds_RC | \ - module_cmds_RC | \ - module_expsym_cmds_RC | \ - old_archive_from_expsyms_cmds_RC | \ - export_symbols_cmds_RC | \ - extract_expsyms_cmds | reload_cmds | finish_cmds | \ - postinstall_cmds | postuninstall_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) - # Double-quote double-evaled strings. - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" - ;; - *) - eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" - ;; - esac - done - - case $lt_echo in - *'\$0 --fallback-echo"') - lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` - ;; - esac - -cfgfile="$ofile" - - cat <<__EOF__ >> "$cfgfile" -# ### BEGIN LIBTOOL TAG CONFIG: $tagname - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_RC - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_compiler_RC - -# Is the compiler the GNU C compiler? -with_gcc=$GCC_RC - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_LD_RC - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_RC - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_RC -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_RC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_old_archive_cmds_RC -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC - -# Commands used to build and install a shared archive. -archive_cmds=$lt_archive_cmds_RC -archive_expsym_cmds=$lt_archive_expsym_cmds_RC -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_module_cmds_RC -module_expsym_cmds=$lt_module_expsym_cmds_RC - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_predep_objects_RC - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_postdep_objects_RC - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_predeps_RC - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_postdeps_RC - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_RC - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_RC - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_RC - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_RC - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$hardcode_direct_RC - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$hardcode_minus_L_RC - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_RC - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$hardcode_automatic_RC - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_RC - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$fix_srcfile_path_RC" - -# Set to yes if exported symbols are required. -always_export_symbols=$always_export_symbols_RC - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_RC - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_RC - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_RC - -# ### END LIBTOOL TAG CONFIG: $tagname - -__EOF__ - - -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - ;; - - *) - { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 -echo "$as_me: error: Unsupported tag name: $tagname" >&2;} - { (exit 1); exit 1; }; } - ;; - esac - - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" - - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 -echo "$as_me: error: unable to update list of available tagged configurations." >&2;} - { (exit 1); exit 1; }; } - fi -fi - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - -# Prevent multiple expansion - - - - - - - - - - - - - - - - - - - - - - ac_config_files="$ac_config_files Makefile json.pc" -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -{ - (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} | - sed ' - t clear - : clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" - cat confcache >$cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi -DUALCASE=1; export DUALCASE # for MKS sh - -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - -exec 6>&1 - -# Open the log real soon, to keep \$[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by JSON C Library $as_me 0.3, which was -generated by GNU Autoconf 2.59. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 -_ACEOF - -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi - -cat >>$CONFIG_STATUS <<\_ACEOF - -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to ." -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -JSON C Library config.status 0.3 -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" - -Copyright (C) 2003 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` - ac_shift=: - ;; - -*) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; - esac - - case $ac_option in - # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -# -# INIT-COMMANDS section. -# - - - -_ACEOF - - - -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_config_target in $ac_config_targets -do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "json.pc" ) CONFIG_FILES="$CONFIG_FILES json.pc" ;; - "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; - "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. -$debug || -{ - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} - -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - -# -# CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@PACKAGE@,$PACKAGE,;t t -s,@VERSION@,$VERSION,;t t -s,@ACLOCAL@,$ACLOCAL,;t t -s,@AUTOCONF@,$AUTOCONF,;t t -s,@AUTOMAKE@,$AUTOMAKE,;t t -s,@AUTOHEADER@,$AUTOHEADER,;t t -s,@MAKEINFO@,$MAKEINFO,;t t -s,@SET_MAKE@,$SET_MAKE,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@CPP@,$CPP,;t t -s,@EGREP@,$EGREP,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@build@,$build,;t t -s,@build_cpu@,$build_cpu,;t t -s,@build_vendor@,$build_vendor,;t t -s,@build_os@,$build_os,;t t -s,@host@,$host,;t t -s,@host_cpu@,$host_cpu,;t t -s,@host_vendor@,$host_vendor,;t t -s,@host_os@,$host_os,;t t -s,@LN_S@,$LN_S,;t t -s,@ECHO@,$ECHO,;t t -s,@AR@,$AR,;t t -s,@ac_ct_AR@,$ac_ct_AR,;t t -s,@RANLIB@,$RANLIB,;t t -s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t -s,@STRIP@,$STRIP,;t t -s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t -s,@CXX@,$CXX,;t t -s,@CXXFLAGS@,$CXXFLAGS,;t t -s,@ac_ct_CXX@,$ac_ct_CXX,;t t -s,@CXXCPP@,$CXXCPP,;t t -s,@F77@,$F77,;t t -s,@FFLAGS@,$FFLAGS,;t t -s,@ac_ct_F77@,$ac_ct_F77,;t t -s,@LIBTOOL@,$LIBTOOL,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat - fi -fi # test -n "$CONFIG_FILES" - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; - esac - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_HEADER section. -# - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='[ ].*$,\1#\2' -ac_dC=' ' -ac_dD=',;t' -# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='$,\1#\2define\3' -ac_uC=' ' -ac_uD=',;t' - -for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - # Do quote $f, to prevent DOS paths from being IFS'd. - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. - sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - -_ACEOF - -# Transform confdefs.h into two sed scripts, `conftest.defines' and -# `conftest.undefs', that substitutes the proper values into -# config.h.in to produce config.h. The first handles `#define' -# templates, and the second `#undef' templates. -# And first: Protect against being on the right side of a sed subst in -# config.status. Protect against being in an unquoted here document -# in config.status. -rm -f conftest.defines conftest.undefs -# Using a here document instead of a string reduces the quoting nightmare. -# Putting comments in sed scripts is not portable. -# -# `end' is used to avoid that the second main sed command (meant for -# 0-ary CPP macros) applies to n-ary macro definitions. -# See the Autoconf documentation for `clear'. -cat >confdef2sed.sed <<\_ACEOF -s/[\\&,]/\\&/g -s,[\\$`],\\&,g -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -t end -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -: end -_ACEOF -# If some macros were called several times there might be several times -# the same #defines, which is useless. Nevertheless, we may not want to -# sort them, since we want the *last* AC-DEFINE to be honored. -uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines -sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs -rm -f confdef2sed.sed - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >>conftest.undefs <<\_ACEOF -s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -_ACEOF - -# Break up conftest.defines because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS -echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS -echo ' :' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.defines >/dev/null -do - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. - echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/defines.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail - rm -f conftest.defines - mv conftest.tail conftest.defines -done -rm -f conftest.defines -echo ' fi # grep' >>$CONFIG_STATUS -echo >>$CONFIG_STATUS - -# Break up conftest.undefs because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #undef templates' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.undefs >/dev/null -do - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' - echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/undefs.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail - rm -f conftest.undefs - mv conftest.tail conftest.undefs -done -rm -f conftest.undefs - -cat >>$CONFIG_STATUS <<\_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - echo "/* Generated by configure. */" >$tmp/config.h - else - echo "/* $ac_file. Generated by configure. */" >$tmp/config.h - fi - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in - if test x"$ac_file" != x-; then - if diff $ac_file $tmp/config.h >/dev/null 2>&1; then - { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -echo "$as_me: $ac_file is unchanged" >&6;} - else - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - rm -f $ac_file - mv $tmp/config.h $ac_file - fi - else - cat $tmp/config.h - rm -f $tmp/config.h - fi -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_COMMANDS section. -# -for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue - ac_dest=`echo "$ac_file" | sed 's,:.*,,'` - ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_dir=`(dirname "$ac_dest") 2>/dev/null || -$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_dest" : 'X\(//\)[^/]' \| \ - X"$ac_dest" : 'X\(//\)$' \| \ - X"$ac_dest" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_dest" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac - - - { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 -echo "$as_me: executing $ac_dest commands" >&6;} - case $ac_dest in - default-1 ) test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h ;; - esac -done -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - diff --git a/source4/lib/json/configure.in b/source4/lib/json/configure.in deleted file mode 100644 index f0a7d3aa5c..0000000000 --- a/source4/lib/json/configure.in +++ /dev/null @@ -1,33 +0,0 @@ -AC_PREREQ(2.52) - -# Process this file with autoconf to produce a configure script. -AC_INIT([JSON C Library], 0.3, [michael@metaparadigm.com], [json-c]) - -AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) - -# Checks for programs. - -# Checks for libraries. - -# Checks for header files. -AM_CONFIG_HEADER(config.h) -AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/param.h] stdarg.h) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_VPRINTF -AC_FUNC_MEMCMP -AC_FUNC_MALLOC -AC_FUNC_REALLOC -AC_CHECK_FUNCS(strndup strerror vsnprintf vasprintf open vsyslog strncasecmp) - -AM_PROG_LIBTOOL - -AC_OUTPUT([ -Makefile -json.pc -]) diff --git a/source4/lib/json/debug.c b/source4/lib/json/debug.c deleted file mode 100644 index a315b0e2a4..0000000000 --- a/source4/lib/json/debug.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#include -#include -#include -#include - -#if HAVE_SYSLOG_H -# include -#endif /* HAVE_SYSLOG_H */ - -#if HAVE_UNISTD_H -# include -#endif /* HAVE_UNISTD_H */ - -#if HAVE_SYS_PARAM_H -#include -#endif /* HAVE_SYS_PARAM_H */ - -#include "debug.h" - -static int _syslog = 0; -static int _debug = 0; - -void mc_set_debug(int debug) { _debug = debug; } -int mc_get_debug() { return _debug; } - -extern void mc_set_syslog(int syslog) -{ - _syslog = syslog; -} - -_NORETURN_ void mc_abort(const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); -#if HAVE_VSYSLOG - if(_syslog) { - vsyslog(LOG_ERR, msg, ap); - } else -#endif - vprintf(msg, ap); - exit(1); -} - - -void mc_debug(const char *msg, ...) -{ - va_list ap; - if(_debug) { - va_start(ap, msg); -#if HAVE_VSYSLOG - if(_syslog) { - vsyslog(LOG_DEBUG, msg, ap); - } else -#endif - vprintf(msg, ap); - } -} - -void mc_error(const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); -#if HAVE_VSYSLOG - if(_syslog) { - vsyslog(LOG_ERR, msg, ap); - } else -#endif - vfprintf(stderr, msg, ap); -} - -void mc_info(const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); -#if HAVE_VSYSLOG - if(_syslog) { - vsyslog(LOG_INFO, msg, ap); - } else -#endif - vfprintf(stderr, msg, ap); -} diff --git a/source4/lib/json/debug.h b/source4/lib/json/debug.h deleted file mode 100644 index 1db69ef016..0000000000 --- a/source4/lib/json/debug.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _DEBUG_H_ -#define _DEBUG_H_ - -extern void mc_set_debug(int debug); -extern int mc_get_debug(); - -extern void mc_set_syslog(int syslog); -extern void mc_abort(const char *msg, ...); -extern void mc_debug(const char *msg, ...); -extern void mc_error(const char *msg, ...); -extern void mc_info(const char *msg, ...); - -#endif diff --git a/source4/lib/json/depcomp b/source4/lib/json/depcomp deleted file mode 100755 index c5b511c63d..0000000000 --- a/source4/lib/json/depcomp +++ /dev/null @@ -1,421 +0,0 @@ -#! /bin/sh - -# depcomp - compile a program generating dependencies as side-effects -# Copyright 1999, 2000 Free Software Foundation, Inc. - -# 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, 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 . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva . - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi -# `libtool' can also be set to `yes' or `no'. - -if test -z "$depfile"; then - base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` - dir=`echo "$object" | sed 's,/.*$,/,'` - if test "$dir" = "$object"; then - dir= - fi - # FIXME: should be _deps on DOS. - depfile="$dir.deps/$base" -fi - -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. This file always lives in the current directory. - # Also, the AIX compiler puts `$object:' at the start of each line; - # $object doesn't have directory information. - stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - outname="$stripped.o" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - tmpdepfile1="$dir.libs/$base.lo.d" - tmpdepfile2="$dir.libs/$base.d" - "$@" -Wc,-MD - else - tmpdepfile1="$dir$base.o.d" - tmpdepfile2="$dir$base.d" - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - if test -f "$tmpdepfile1"; then - tmpdepfile="$tmpdepfile1" - else - tmpdepfile="$tmpdepfile2" - fi - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a space and a tab in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. We will use -o /dev/null later, - # however we can't do the remplacement now because - # `-o $object' might simply not be used - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - -*) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the proprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 diff --git a/source4/lib/json/install-sh b/source4/lib/json/install-sh deleted file mode 100755 index fca26e5622..0000000000 --- a/source4/lib/json/install-sh +++ /dev/null @@ -1,269 +0,0 @@ -#!/bin/sh -# -# install - install a program, script, or datafile -# -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - : -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=$mkdirprog - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f "$src" ] || [ -d "$src" ] - then - : - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - : - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - : - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' - ' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - : - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - : - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/source4/lib/json/json-c.vcproj b/source4/lib/json/json-c.vcproj deleted file mode 100644 index 0b88754459..0000000000 --- a/source4/lib/json/json-c.vcproj +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source4/lib/json/json.h b/source4/lib/json/json.h deleted file mode 100644 index a5a3432b2c..0000000000 --- a/source4/lib/json/json.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _json_h_ -#define _json_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "bits.h" -#include "debug.h" -#include "linkhash.h" -#include "arraylist.h" -#include "json_util.h" -#include "json_object.h" -#include "json_tokener.h" - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source4/lib/json/json.pc.in b/source4/lib/json/json.pc.in deleted file mode 100644 index b3d140be97..0000000000 --- a/source4/lib/json/json.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: json -Description: JSON implementation in C -Version: @VERSION@ -Requires: -Libs: -L${libdir} -ljson -Cflags: -I${includedir}/json diff --git a/source4/lib/json/json_object.c b/source4/lib/json/json_object.c deleted file mode 100644 index 525e2171e9..0000000000 --- a/source4/lib/json/json_object.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - * $Id: json_object.c,v 1.15 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#include -#include -#include - -#include "debug.h" -#include "printbuf.h" -#include "linkhash.h" -#include "arraylist.h" -#include "json_object.h" -#include "json_object_private.h" -#include "json_tokener.h" - -#if !HAVE_STRNDUP - char* strndup(const char* str, size_t n); -#endif /* !HAVE_STRNDUP */ - -/* #define REFCOUNT_DEBUG 1 */ - -char *json_number_chars = "0123456789.+-e"; -char *json_hex_chars = "0123456789abcdef"; - -#ifdef REFCOUNT_DEBUG -static char* json_type_name[] = { - "null", - "boolean", - "double", - "int", - "object", - "array", - "string", -}; -#endif /* REFCOUNT_DEBUG */ - -static void json_object_generic_delete(struct json_object* this); -static struct json_object* json_object_new(enum json_type o_type); - - -/* ref count debugging */ - -#ifdef REFCOUNT_DEBUG - -static struct lh_table *json_object_table; - -static void json_object_init() __attribute__ ((constructor)); -static void json_object_init() { - mc_debug("json_object_init: creating object table\n"); - json_object_table = lh_kptr_table_new(128, "json_object_table", NULL); -} - -static void json_object_fini() __attribute__ ((destructor)); -static void json_object_fini() { - struct lh_entry *ent; - if(mc_get_debug() && json_object_table->count) { - mc_debug("json_object_fini: %d referenced objects at exit\n", - json_object_table->count); - lh_foreach(json_object_table, ent) { - struct json_object* obj = (struct json_object*)ent->v; - mc_debug("\t%s:%p\n", json_type_name[obj->o_type], obj); - } - } - mc_debug("json_object_fini: freeing object table\n"); - lh_table_free(json_object_table); -} -#endif /* REFCOUNT_DEBUG */ - - -/* string escaping */ - -static int json_escape_str(struct printbuf *pb, char *str) -{ - int pos = 0, start_offset = 0; - unsigned char c; - do { - c = str[pos]; - switch(c) { - case '\0': - break; - case '\b': - case '\n': - case '\r': - case '\t': - case '"': - if(pos - start_offset > 0) - printbuf_memappend(pb, str + start_offset, pos - start_offset); - if(c == '\b') printbuf_memappend(pb, "\\b", 2); - else if(c == '\n') printbuf_memappend(pb, "\\n", 2); - else if(c == '\r') printbuf_memappend(pb, "\\r", 2); - else if(c == '\t') printbuf_memappend(pb, "\\t", 2); - else if(c == '"') printbuf_memappend(pb, "\\\"", 2); - start_offset = ++pos; - break; - default: - if(c < ' ') { - if(pos - start_offset > 0) - printbuf_memappend(pb, str + start_offset, pos - start_offset); - sprintbuf(pb, "\\u00%c%c", - json_hex_chars[c >> 4], - json_hex_chars[c & 0xf]); - start_offset = ++pos; - } else pos++; - } - } while(c); - if(pos - start_offset > 0) - printbuf_memappend(pb, str + start_offset, pos - start_offset); - return 0; -} - - -/* reference counting */ - -extern struct json_object* json_object_get(struct json_object *this) -{ - if(this) { - this->_ref_count++; - } - return this; -} - -extern void json_object_put(struct json_object *this) -{ - if(this) { - this->_ref_count--; - if(!this->_ref_count) this->_delete(this); - } -} - - -/* generic object construction and destruction parts */ - -static void json_object_generic_delete(struct json_object* this) -{ -#ifdef REFCOUNT_DEBUG - mc_debug("json_object_delete_%s: %p\n", - json_type_name[this->o_type], this); - lh_table_delete(json_object_table, this); -#endif /* REFCOUNT_DEBUG */ - printbuf_free(this->_pb); - free(this); -} - -static struct json_object* json_object_new(enum json_type o_type) -{ - struct json_object *this = calloc(sizeof(struct json_object), 1); - if(!this) return NULL; - this->o_type = o_type; - this->_ref_count = 1; - this->_delete = &json_object_generic_delete; -#ifdef REFCOUNT_DEBUG - lh_table_insert(json_object_table, this, this); - mc_debug("json_object_new_%s: %p\n", json_type_name[this->o_type], this); -#endif /* REFCOUNT_DEBUG */ - return this; -} - - -/* type checking functions */ - -int json_object_is_type(struct json_object *this, enum json_type type) -{ - return (this->o_type == type); -} - -enum json_type json_object_get_type(struct json_object *this) -{ - return this->o_type; -} - - -/* json_object_to_json_string */ - -char* json_object_to_json_string(struct json_object *this) -{ - if(!this) return "null"; - if(!this->_pb) { - if(!(this->_pb = printbuf_new())) return NULL; - } else { - printbuf_reset(this->_pb); - } - if(this->_to_json_string(this, this->_pb) < 0) return NULL; - return this->_pb->buf; -} - - -/* json_object_object */ - -static int json_object_object_to_json_string(struct json_object* this, - struct printbuf *pb) -{ - int i=0; - struct json_object_iter iter; - sprintbuf(pb, "{"); - - /* CAW: scope operator to make ANSI correctness */ - /* CAW: switched to json_object_object_foreachC which uses an iterator struct */ - json_object_object_foreachC(this, iter) { - if(i) sprintbuf(pb, ","); - sprintbuf(pb, " \""); - json_escape_str(pb, iter.key); - sprintbuf(pb, "\": "); - if(iter.val == NULL) sprintbuf(pb, "null"); - else iter.val->_to_json_string(iter.val, pb); - i++; - } - - return sprintbuf(pb, " }"); -} - -static void json_object_lh_entry_free(struct lh_entry *ent) -{ - free(ent->k); - json_object_put((struct json_object*)ent->v); -} - -static void json_object_object_delete(struct json_object* this) -{ - lh_table_free(this->o.c_object); - json_object_generic_delete(this); -} - -struct json_object* json_object_new_object() -{ - struct json_object *this = json_object_new(json_type_object); - if(!this) return NULL; - this->_delete = &json_object_object_delete; - this->_to_json_string = &json_object_object_to_json_string; - this->o.c_object = lh_kchar_table_new(JSON_OBJECT_DEF_HASH_ENTIRES, - NULL, &json_object_lh_entry_free); - return this; -} - -struct lh_table* json_object_get_object(struct json_object *this) -{ - if(!this) return NULL; - switch(this->o_type) { - case json_type_object: - return this->o.c_object; - default: - return NULL; - } -} - -void json_object_object_add(struct json_object* this, char *key, - struct json_object *val) -{ - lh_table_delete(this->o.c_object, key); - lh_table_insert(this->o.c_object, strdup(key), val); -} - -struct json_object* json_object_object_get(struct json_object* this, char *key) -{ - return (struct json_object*) lh_table_lookup(this->o.c_object, key); -} - -void json_object_object_del(struct json_object* this, char *key) -{ - lh_table_delete(this->o.c_object, key); -} - - -/* json_object_boolean */ - -static int json_object_boolean_to_json_string(struct json_object* this, - struct printbuf *pb) -{ - if(this->o.c_boolean) return sprintbuf(pb, "true"); - else return sprintbuf(pb, "false"); -} - -struct json_object* json_object_new_boolean(boolean b) -{ - struct json_object *this = json_object_new(json_type_boolean); - if(!this) return NULL; - this->_to_json_string = &json_object_boolean_to_json_string; - this->o.c_boolean = b; - return this; -} - -boolean json_object_get_boolean(struct json_object *this) -{ - if(!this) return FALSE; - switch(this->o_type) { - case json_type_boolean: - return this->o.c_boolean; - case json_type_int: - return (this->o.c_int != 0); - case json_type_double: - return (this->o.c_double != 0); - case json_type_string: - if(strlen(this->o.c_string)) return TRUE; - default: - return TRUE; - } -} - - -/* json_object_int */ - -static int json_object_int_to_json_string(struct json_object* this, - struct printbuf *pb) -{ - return sprintbuf(pb, "%d", this->o.c_int); -} - -struct json_object* json_object_new_int(int i) -{ - struct json_object *this = json_object_new(json_type_int); - if(!this) return NULL; - this->_to_json_string = &json_object_int_to_json_string; - this->o.c_int = i; - return this; -} - -int json_object_get_int(struct json_object *this) -{ - int cint; - - if(!this) return 0; - switch(this->o_type) { - case json_type_int: - return this->o.c_int; - case json_type_double: - return (int)this->o.c_double; - case json_type_boolean: - return this->o.c_boolean; - case json_type_string: - if(sscanf(this->o.c_string, "%d", &cint) == 1) return cint; - default: - return 0; - } -} - - -/* json_object_double */ - -static int json_object_double_to_json_string(struct json_object* this, - struct printbuf *pb) -{ - return sprintbuf(pb, "%lf", this->o.c_double); -} - -struct json_object* json_object_new_double(double d) -{ - struct json_object *this = json_object_new(json_type_double); - if(!this) return NULL; - this->_to_json_string = &json_object_double_to_json_string; - this->o.c_double = d; - return this; -} - -double json_object_get_double(struct json_object *this) -{ - double cdouble; - - if(!this) return 0.0; - switch(this->o_type) { - case json_type_double: - return this->o.c_double; - case json_type_int: - return this->o.c_int; - case json_type_boolean: - return this->o.c_boolean; - case json_type_string: - if(sscanf(this->o.c_string, "%lf", &cdouble) == 1) return cdouble; - default: - return 0.0; - } -} - - -/* json_object_string */ - -static int json_object_string_to_json_string(struct json_object* this, - struct printbuf *pb) -{ - sprintbuf(pb, "\""); - json_escape_str(pb, this->o.c_string); - sprintbuf(pb, "\""); - return 0; -} - -static void json_object_string_delete(struct json_object* this) -{ - free(this->o.c_string); - json_object_generic_delete(this); -} - -struct json_object* json_object_new_string(char *s) -{ - struct json_object *this = json_object_new(json_type_string); - if(!this) return NULL; - this->_delete = &json_object_string_delete; - this->_to_json_string = &json_object_string_to_json_string; - this->o.c_string = strdup(s); - return this; -} - -struct json_object* json_object_new_string_len(char *s, int len) -{ - struct json_object *this = json_object_new(json_type_string); - if(!this) return NULL; - this->_delete = &json_object_string_delete; - this->_to_json_string = &json_object_string_to_json_string; - this->o.c_string = strndup(s, len); - return this; -} - -char* json_object_get_string(struct json_object *this) -{ - if(!this) return NULL; - switch(this->o_type) { - case json_type_string: - return this->o.c_string; - default: - return json_object_to_json_string(this); - } -} - - -/* json_object_array */ - -static int json_object_array_to_json_string(struct json_object* this, - struct printbuf *pb) -{ - int i; - sprintbuf(pb, "["); - for(i=0; i < json_object_array_length(this); i++) { - struct json_object *val; - if(i) { sprintbuf(pb, ", "); } - else { sprintbuf(pb, " "); } - - val = json_object_array_get_idx(this, i); - if(val == NULL) { sprintbuf(pb, "null"); } - else { val->_to_json_string(val, pb); } - } - return sprintbuf(pb, " ]"); -} - -static void json_object_array_entry_free(void *data) -{ - json_object_put((struct json_object*)data); -} - -static void json_object_array_delete(struct json_object* this) -{ - array_list_free(this->o.c_array); - json_object_generic_delete(this); -} - -struct json_object* json_object_new_array() -{ - struct json_object *this = json_object_new(json_type_array); - if(!this) return NULL; - this->_delete = &json_object_array_delete; - this->_to_json_string = &json_object_array_to_json_string; - this->o.c_array = array_list_new(&json_object_array_entry_free); - return this; -} - -struct array_list* json_object_get_array(struct json_object *this) -{ - if(!this) return NULL; - switch(this->o_type) { - case json_type_array: - return this->o.c_array; - default: - return NULL; - } -} - -int json_object_array_length(struct json_object *this) -{ - return array_list_length(this->o.c_array); -} - -int json_object_array_add(struct json_object *this,struct json_object *val) -{ - return array_list_add(this->o.c_array, val); -} - -int json_object_array_put_idx(struct json_object *this, int idx, - struct json_object *val) -{ - return array_list_put_idx(this->o.c_array, idx, val); -} - -struct json_object* json_object_array_get_idx(struct json_object *this, - int idx) -{ - return (struct json_object*)array_list_get_idx(this->o.c_array, idx); -} - diff --git a/source4/lib/json/json_object.h b/source4/lib/json/json_object.h deleted file mode 100644 index 5c25968dba..0000000000 --- a/source4/lib/json/json_object.h +++ /dev/null @@ -1,310 +0,0 @@ -/* - * $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _json_object_h_ -#define _json_object_h_ - -#define JSON_OBJECT_DEF_HASH_ENTIRES 16 - -#undef FALSE -#define FALSE ((boolean)0) - -#undef TRUE -#define TRUE ((boolean)1) - -extern char *json_number_chars; -extern char *json_hex_chars; - -/* forward structure definitions */ - -typedef int boolean; -struct printbuf; -struct lh_table; -struct array_list; -struct json_object; -struct json_object_iter; - -/* supported object types */ - -enum json_type { - json_type_null, - json_type_boolean, - json_type_double, - json_type_int, - json_type_object, - json_type_array, - json_type_string -}; - -/* reference counting functions */ - -/** - * Increment the reference count of json_object - * @param obj the json_object instance - */ -extern struct json_object* json_object_get(struct json_object *obj); - -/** - * Decrement the reference count of json_object and free if it reaches zero - * @param obj the json_object instance - */ -extern void json_object_put(struct json_object *obj); - - -/** - * Check if the json_object is of a given type - * @param obj the json_object instance - * @param type one of: - json_type_boolean, - json_type_double, - json_type_int, - json_type_object, - json_type_array, - json_type_string, - */ -extern int json_object_is_type(struct json_object *obj, enum json_type type); - -/** - * Get the type of the json_object - * @param obj the json_object instance - * @returns type being one of: - json_type_boolean, - json_type_double, - json_type_int, - json_type_object, - json_type_array, - json_type_string, - */ -extern enum json_type json_object_get_type(struct json_object *obj); - - -/** Stringify object to json format - * @param obj the json_object instance - * @returns a string in JSON format - */ -extern char* json_object_to_json_string(struct json_object *obj); - - -/* object type methods */ - -/** Create a new empty object - * @returns a json_object of type json_type_object - */ -extern struct json_object* json_object_new_object(); - -/** Get the hashtable of a json_object of type json_type_object - * @param obj the json_object instance - * @returns a linkhash - */ -extern struct lh_table* json_object_get_object(struct json_object *obj); - -/** Add an object field to a json_object of type json_type_object - * - * The reference count will *not* be incremented. This is to make adding - * fields to objects in code more compact. If you want to retain a reference - * to an added object you must wrap the passed object with json_object_get - * - * @param obj the json_object instance - * @param key the object field name (a private copy will be duplicated) - * @param val a json_object or NULL member to associate with the given field - */ -extern void json_object_object_add(struct json_object* obj, char *key, - struct json_object *val); - -/** Get the json_object associate with a given object field - * @param obj the json_object instance - * @param key the object field name - * @returns the json_object associated with the given field name - */ -extern struct json_object* json_object_object_get(struct json_object* obj, - char *key); - -/** Delete the given json_object field - * - * The reference count will be decremented for the deleted object - * - * @param obj the json_object instance - * @param key the object field name - */ -extern void json_object_object_del(struct json_object* obj, char *key); - -/** Iterate through all keys and values of an object - * @param obj the json_object instance - * @param key the local name for the char* key variable defined in the body - * @param val the local name for the json_object* object variable defined in the body - */ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - -# define json_object_object_foreach(obj,key,val) \ - char *key; struct json_object *val; \ - for(struct lh_entry *entry = json_object_get_object(obj)->head; ({ if(entry) { key = (char*)entry->k; val = (struct json_object*)entry->v; } ; entry; }); entry = entry->next ) - -#else /* ANSI C or MSC */ - -# define json_object_object_foreach(obj,key,val) \ - char *key; struct json_object *val; struct lh_entry *entry; \ - for(entry = json_object_get_object(obj)->head; (entry ? (key = (char*)entry->k, val = (struct json_object*)entry->v, entry) : 0); entry = entry->next) - -#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) */ - -/** Iterate through all keys and values of an object (ANSI C Safe) - * @param obj the json_object instance - * @param iter the object iterator - */ -#define json_object_object_foreachC(obj,iter) \ - for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next) - -/* Array type methods */ - -/** Create a new empty json_object of type json_type_array - * @returns a json_object of type json_type_array - */ -extern struct json_object* json_object_new_array(); - -/** Get the arraylist of a json_object of type json_type_array - * @param obj the json_object instance - * @returns an arraylist - */ -extern struct array_list* json_object_get_array(struct json_object *obj); - -/** Get the length of a json_object of type json_type_array - * @param obj the json_object instance - * @returns an int - */ -extern int json_object_array_length(struct json_object *obj); - -/** Add an element to the end of a json_object of type json_type_array - * - * The reference count will *not* be incremented. This is to make adding - * fields to objects in code more compact. If you want to retain a reference - * to an added object you must wrap the passed object with json_object_get - * - * @param obj the json_object instance - * @param val the json_object to be added - */ -extern int json_object_array_add(struct json_object *obj, - struct json_object *val); - -/** Insert or replace an element at a specified index in an array (a json_object of type json_type_array) - * - * The reference count will *not* be incremented. This is to make adding - * fields to objects in code more compact. If you want to retain a reference - * to an added object you must wrap the passed object with json_object_get - * - * The reference count of a replaced object will be decremented. - * - * The array size will be automatically be expanded to the size of the - * index if the index is larger than the current size. - * - * @param obj the json_object instance - * @param idx the index to insert the element at - * @param val the json_object to be added - */ -extern int json_object_array_put_idx(struct json_object *obj, int idx, - struct json_object *val); - -/** Get the element at specificed index of the array (a json_object of type json_type_array) - * @param obj the json_object instance - * @param idx the index to get the element at - * @returns the json_object at the specified index (or NULL) - */ -extern struct json_object* json_object_array_get_idx(struct json_object *obj, - int idx); - -/* boolean type methods */ - -/** Create a new empty json_object of type json_type_boolean - * @param b a boolean TRUE or FALSE (0 or 1) - * @returns a json_object of type json_type_boolean - */ -extern struct json_object* json_object_new_boolean(boolean b); - -/** Get the boolean value of a json_object - * - * The type is coerced to a boolean if the passed object is not a boolean. - * integer and double objects will return FALSE if there value is zero - * or TRUE otherwise. If the passed object is a string it will return - * TRUE if it has a non zero length. If any other object type is passed - * TRUE will be returned if the object is not NULL. - * - * @param obj the json_object instance - * @returns a boolean - */ -extern boolean json_object_get_boolean(struct json_object *obj); - - -/* int type methods */ - -/** Create a new empty json_object of type json_type_int - * @param i the integer - * @returns a json_object of type json_type_int - */ -extern struct json_object* json_object_new_int(int i); - -/** Get the int value of a json_object - * - * The type is coerced to a int if the passed object is not a int. - * double objects will return their integer conversion. Strings will be - * parsed as an integer. If no conversion exists then 0 is returned. - * - * @param obj the json_object instance - * @returns an int - */ -extern int json_object_get_int(struct json_object *obj); - - -/* double type methods */ - -/** Create a new empty json_object of type json_type_double - * @param d the double - * @returns a json_object of type json_type_double - */ -extern struct json_object* json_object_new_double(double d); - -/** Get the double value of a json_object - * - * The type is coerced to a double if the passed object is not a double. - * integer objects will return their dboule conversion. Strings will be - * parsed as a double. If no conversion exists then 0.0 is returned. - * - * @param obj the json_object instance - * @returns an double - */ -extern double json_object_get_double(struct json_object *obj); - - -/* string type methods */ - -/** Create a new empty json_object of type json_type_string - * - * A copy of the string is made and the memory is managed by the json_object - * - * @param s the string - * @returns a json_object of type json_type_string - */ -extern struct json_object* json_object_new_string(char *s); - -extern struct json_object* json_object_new_string_len(char *s, int len); - -/** Get the string value of a json_object - * - * If the passed object is not of type json_type_string then the JSON - * representation of the object is returned. - * - * The returned string memory is managed by the json_object and will - * be freed when the reference count of the json_object drops to zero. - * - * @param obj the json_object instance - * @returns a string - */ -extern char* json_object_get_string(struct json_object *obj); - -#endif diff --git a/source4/lib/json/json_object_private.h b/source4/lib/json/json_object_private.h deleted file mode 100644 index 35a44f3a09..0000000000 --- a/source4/lib/json/json_object_private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * $Id: json_object_private.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _json_object_private_h_ -#define _json_object_private_h_ - -typedef void (json_object_delete_fn)(struct json_object *o); -typedef int (json_object_to_json_string_fn)(struct json_object *o, - struct printbuf *pb); - -struct json_object -{ - enum json_type o_type; - json_object_delete_fn *_delete; - json_object_to_json_string_fn *_to_json_string; - int _ref_count; - struct printbuf *_pb; - union data { - boolean c_boolean; - double c_double; - int c_int; - struct lh_table *c_object; - struct array_list *c_array; - char *c_string; - } o; -}; - -/* CAW: added for ANSI C iteration correctness */ -struct json_object_iter -{ - char *key; - struct json_object *val; - struct lh_entry *entry; -}; - -#endif diff --git a/source4/lib/json/json_tokener.c b/source4/lib/json/json_tokener.c deleted file mode 100644 index a3ebf10878..0000000000 --- a/source4/lib/json/json_tokener.c +++ /dev/null @@ -1,465 +0,0 @@ -/* - * $Id: json_tokener.c,v 1.19 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#include -#include -#include -#include - -#include "bits.h" -#include "debug.h" -#include "printbuf.h" -#include "arraylist.h" -#include "json_object.h" -#include "json_tokener.h" - -#if !HAVE_STRNCASECMP && defined(_MSC_VER) - /* MSC has the version as _strnicmp */ -# define strncasecmp _strnicmp -#elif !HAVE_STRNCASECMP -# error You do not have strncasecmp on your system. -#endif /* HAVE_STRNCASECMP */ - - -static struct json_object* json_tokener_do_parse(struct json_tokener *this); - -struct json_object* json_tokener_parse(char * s) -{ - struct json_tokener tok; - struct json_object* obj; - - tok.source = s; - tok.pos = 0; - tok.pb = printbuf_new(); - obj = json_tokener_do_parse(&tok); - printbuf_free(tok.pb); - return obj; -} - -#if !HAVE_STRNDUP -/* CAW: compliant version of strndup() */ -char* strndup(const char* str, size_t n) -{ - if(str) { - size_t len = strlen(str); - size_t nn = min(len,n); - char* s = (char*)malloc(sizeof(char) * (nn + 1)); - - if(s) { - memcpy(s, str, nn); - s[nn] = '\0'; - } - - return s; - } - - return NULL; -} -#endif - -static struct json_object* json_tokener_do_parse(struct json_tokener *this) -{ - enum json_tokener_state state, saved_state; - enum json_tokener_error err = json_tokener_success; - struct json_object *current = NULL, *obj; - char *obj_field_name = NULL; - char quote_char; - int deemed_double, start_offset; - char c; - - state = json_tokener_state_eatws; - saved_state = json_tokener_state_start; - - do { - c = this->source[this->pos]; - switch(state) { - - case json_tokener_state_eatws: - if(isspace(c)) { - this->pos++; - } else if(c == '/') { - state = json_tokener_state_comment_start; - start_offset = this->pos++; - } else { - state = saved_state; - } - break; - - case json_tokener_state_start: - switch(c) { - case '{': - state = json_tokener_state_eatws; - saved_state = json_tokener_state_object; - current = json_object_new_object(); - this->pos++; - break; - case '[': - state = json_tokener_state_eatws; - saved_state = json_tokener_state_array; - current = json_object_new_array(); - this->pos++; - break; - case 'N': - case 'n': - state = json_tokener_state_null; - start_offset = this->pos++; - break; - case '"': - case '\'': - quote_char = c; - printbuf_reset(this->pb); - state = json_tokener_state_string; - start_offset = ++this->pos; - break; - case 'T': - case 't': - case 'F': - case 'f': - state = json_tokener_state_boolean; - start_offset = this->pos++; - break; -#if defined(__GNUC__) - case '0' ... '9': -#else - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': -#endif - case '-': - deemed_double = 0; - state = json_tokener_state_number; - start_offset = this->pos++; - break; - default: - err = json_tokener_error_parse_unexpected; - goto out; - } - break; - - case json_tokener_state_finish: - goto out; - - case json_tokener_state_null: - if(strncasecmp("null", this->source + start_offset, - this->pos - start_offset)) - return error_ptr(-json_tokener_error_parse_null); - if(this->pos - start_offset == 4) { - current = NULL; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else { - this->pos++; - } - break; - - case json_tokener_state_comment_start: - if(c == '*') { - state = json_tokener_state_comment; - } else if(c == '/') { - state = json_tokener_state_comment_eol; - } else { - err = json_tokener_error_parse_comment; - goto out; - } - this->pos++; - break; - - case json_tokener_state_comment: - if(c == '*') state = json_tokener_state_comment_end; - this->pos++; - break; - - case json_tokener_state_comment_eol: - if(c == '\n') { - if(mc_get_debug()) { - char *tmp = strndup(this->source + start_offset, - this->pos - start_offset); - mc_debug("json_tokener_comment: %s\n", tmp); - free(tmp); - } - state = json_tokener_state_eatws; - } - this->pos++; - break; - - case json_tokener_state_comment_end: - if(c == '/') { - if(mc_get_debug()) { - char *tmp = strndup(this->source + start_offset, - this->pos - start_offset + 1); - mc_debug("json_tokener_comment: %s\n", tmp); - free(tmp); - } - state = json_tokener_state_eatws; - } else { - state = json_tokener_state_comment; - } - this->pos++; - break; - - case json_tokener_state_string: - if(c == quote_char) { - printbuf_memappend(this->pb, this->source + start_offset, - this->pos - start_offset); - current = json_object_new_string(this->pb->buf); - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else if(c == '\\') { - saved_state = json_tokener_state_string; - state = json_tokener_state_string_escape; - } - this->pos++; - break; - - case json_tokener_state_string_escape: - switch(c) { - case '"': - case '\\': - printbuf_memappend(this->pb, this->source + start_offset, - this->pos - start_offset - 1); - start_offset = this->pos++; - state = saved_state; - break; - case 'b': - case 'n': - case 'r': - case 't': - printbuf_memappend(this->pb, this->source + start_offset, - this->pos - start_offset - 1); - if(c == 'b') printbuf_memappend(this->pb, "\b", 1); - else if(c == 'n') printbuf_memappend(this->pb, "\n", 1); - else if(c == 'r') printbuf_memappend(this->pb, "\r", 1); - else if(c == 't') printbuf_memappend(this->pb, "\t", 1); - start_offset = ++this->pos; - state = saved_state; - break; - case 'u': - printbuf_memappend(this->pb, this->source + start_offset, - this->pos - start_offset - 1); - start_offset = ++this->pos; - state = json_tokener_state_escape_unicode; - break; - default: - err = json_tokener_error_parse_string; - goto out; - } - break; - - case json_tokener_state_escape_unicode: - if(strchr(json_hex_chars, c)) { - this->pos++; - if(this->pos - start_offset == 4) { - unsigned char utf_out[3]; - unsigned int ucs_char = - (hexdigit(*(this->source + start_offset)) << 12) + - (hexdigit(*(this->source + start_offset + 1)) << 8) + - (hexdigit(*(this->source + start_offset + 2)) << 4) + - hexdigit(*(this->source + start_offset + 3)); - if (ucs_char < 0x80) { - utf_out[0] = ucs_char; - printbuf_memappend(this->pb, (char*)utf_out, 1); - } else if (ucs_char < 0x800) { - utf_out[0] = 0xc0 | (ucs_char >> 6); - utf_out[1] = 0x80 | (ucs_char & 0x3f); - printbuf_memappend(this->pb, (char*)utf_out, 2); - } else { - utf_out[0] = 0xe0 | (ucs_char >> 12); - utf_out[1] = 0x80 | ((ucs_char >> 6) & 0x3f); - utf_out[2] = 0x80 | (ucs_char & 0x3f); - printbuf_memappend(this->pb, (char*)utf_out, 3); - } - start_offset = this->pos; - state = saved_state; - } - } else { - err = json_tokener_error_parse_string; - goto out; - } - break; - - case json_tokener_state_boolean: - if(strncasecmp("true", this->source + start_offset, - this->pos - start_offset) == 0) { - if(this->pos - start_offset == 4) { - current = json_object_new_boolean(1); - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else { - this->pos++; - } - } else if(strncasecmp("false", this->source + start_offset, - this->pos - start_offset) == 0) { - if(this->pos - start_offset == 5) { - current = json_object_new_boolean(0); - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else { - this->pos++; - } - } else { - err = json_tokener_error_parse_boolean; - goto out; - } - break; - - case json_tokener_state_number: - if(!c || !strchr(json_number_chars, c)) { - int numi; - double numd; - char *tmp = strndup(this->source + start_offset, - this->pos - start_offset); - if(!deemed_double && sscanf(tmp, "%d", &numi) == 1) { - current = json_object_new_int(numi); - } else if(deemed_double && sscanf(tmp, "%lf", &numd) == 1) { - current = json_object_new_double(numd); - } else { - free(tmp); - err = json_tokener_error_parse_number; - goto out; - } - free(tmp); - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else { - if(c == '.' || c == 'e') deemed_double = 1; - this->pos++; - } - break; - - case json_tokener_state_array: - if(c == ']') { - this->pos++; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else { - obj = json_tokener_do_parse(this); - if(is_error(obj)) { - err = -(enum json_tokener_error)obj; - goto out; - } - json_object_array_add(current, obj); - saved_state = json_tokener_state_array_sep; - state = json_tokener_state_eatws; - } - break; - - case json_tokener_state_array_sep: - if(c == ']') { - this->pos++; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else if(c == ',') { - this->pos++; - saved_state = json_tokener_state_array; - state = json_tokener_state_eatws; - } else { - json_object_put(current); - return error_ptr(-json_tokener_error_parse_array); - } - break; - - case json_tokener_state_object: - state = json_tokener_state_object_field_start; - start_offset = this->pos; - break; - - case json_tokener_state_object_field_start: - if(c == '}') { - this->pos++; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else if (c == '"' || c == '\'') { - quote_char = c; - printbuf_reset(this->pb); - state = json_tokener_state_object_field; - start_offset = ++this->pos; - } else { - err = json_tokener_error_parse_object; - goto out; - } - break; - - case json_tokener_state_object_field: - if(c == quote_char) { - printbuf_memappend(this->pb, this->source + start_offset, - this->pos - start_offset); - obj_field_name = strdup(this->pb->buf); - saved_state = json_tokener_state_object_field_end; - state = json_tokener_state_eatws; - } else if(c == '\\') { - saved_state = json_tokener_state_object_field; - state = json_tokener_state_string_escape; - } - this->pos++; - break; - - case json_tokener_state_object_field_end: - if(c == ':') { - this->pos++; - saved_state = json_tokener_state_object_value; - state = json_tokener_state_eatws; - } else { - return error_ptr(-json_tokener_error_parse_object); - } - break; - - case json_tokener_state_object_value: - obj = json_tokener_do_parse(this); - if(is_error(obj)) { - err = -(enum json_tokener_error)obj; - goto out; - } - json_object_object_add(current, obj_field_name, obj); - free(obj_field_name); - obj_field_name = NULL; - saved_state = json_tokener_state_object_sep; - state = json_tokener_state_eatws; - break; - - case json_tokener_state_object_sep: - if(c == '}') { - this->pos++; - saved_state = json_tokener_state_finish; - state = json_tokener_state_eatws; - } else if(c == ',') { - this->pos++; - saved_state = json_tokener_state_object; - state = json_tokener_state_eatws; - } else { - err = json_tokener_error_parse_object; - goto out; - } - break; - - } - } while(c); - - if(state != json_tokener_state_finish && - saved_state != json_tokener_state_finish) - err = json_tokener_error_parse_eof; - - out: - free(obj_field_name); - if(err == json_tokener_success) return current; - mc_debug("json_tokener_do_parse: error=%d state=%d char=%c\n", - err, state, c); - json_object_put(current); - return error_ptr(-err); -} diff --git a/source4/lib/json/json_tokener.h b/source4/lib/json/json_tokener.h deleted file mode 100644 index 12227a996b..0000000000 --- a/source4/lib/json/json_tokener.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $Id: json_tokener.h,v 1.9 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _json_tokener_h_ -#define _json_tokener_h_ - -#include "json_object.h" - -enum json_tokener_error { - json_tokener_success, - json_tokener_error_parse_unexpected, - json_tokener_error_parse_null, - json_tokener_error_parse_boolean, - json_tokener_error_parse_number, - json_tokener_error_parse_array, - json_tokener_error_parse_object, - json_tokener_error_parse_string, - json_tokener_error_parse_comment, - json_tokener_error_parse_eof -}; - -enum json_tokener_state { - json_tokener_state_eatws, - json_tokener_state_start, - json_tokener_state_finish, - json_tokener_state_null, - json_tokener_state_comment_start, - json_tokener_state_comment, - json_tokener_state_comment_eol, - json_tokener_state_comment_end, - json_tokener_state_string, - json_tokener_state_string_escape, - json_tokener_state_escape_unicode, - json_tokener_state_boolean, - json_tokener_state_number, - json_tokener_state_array, - json_tokener_state_array_sep, - json_tokener_state_object, - json_tokener_state_object_field_start, - json_tokener_state_object_field, - json_tokener_state_object_field_end, - json_tokener_state_object_value, - json_tokener_state_object_sep -}; - -struct json_tokener -{ - char *source; - int pos; - struct printbuf *pb; -}; - -extern struct json_object* json_tokener_parse(char *s); - -#endif diff --git a/source4/lib/json/json_util.c b/source4/lib/json/json_util.c deleted file mode 100644 index e20be24038..0000000000 --- a/source4/lib/json/json_util.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * $Id: json_util.c,v 1.4 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#if HAVE_SYS_TYPES_H -#include -#endif /* HAVE_SYS_TYPES_H */ - -#if HAVE_SYS_STAT_H -#include -#endif /* HAVE_SYS_STAT_H */ - -#if HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ - -#if HAVE_UNISTD_H -# include -#endif /* HAVE_UNISTD_H */ - -#ifdef WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# include -#endif /* defined(WIN32) */ - -#if !HAVE_OPEN && defined(WIN32) -# define open _open -#endif - - -#include "bits.h" -#include "debug.h" -#include "printbuf.h" -#include "json_object.h" -#include "json_tokener.h" -#include "json_util.h" - -struct json_object* json_object_from_file(char *filename) -{ - struct printbuf *pb; - struct json_object *obj; - char buf[JSON_FILE_BUF_SIZE]; - int fd, ret; - - if((fd = open(filename, O_RDONLY)) < 0) { - mc_error("json_object_from_file: error reading file %s: %s\n", - filename, strerror(errno)); - return error_ptr(-1); - } - if(!(pb = printbuf_new())) { - mc_error("json_object_from_file: printbuf_new failed\n"); - return error_ptr(-1); - } - while((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) { - printbuf_memappend(pb, buf, ret); - } - close(fd); - if(ret < 0) { - mc_abort("json_object_from_file: error reading file %s: %s\n", - filename, strerror(errno)); - printbuf_free(pb); - return error_ptr(-1); - } - obj = json_tokener_parse(pb->buf); - printbuf_free(pb); - return obj; -} - -int json_object_to_file(char *filename, struct json_object *obj) -{ - char *json_str; - int fd, ret; - unsigned int wpos, wsize; - - if(!obj) { - mc_error("json_object_to_file: object is null\n"); - return -1; - } - - if((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0) { - mc_error("json_object_to_file: error opening file %s: %s\n", - filename, strerror(errno)); - return -1; - } - - if(!(json_str = json_object_to_json_string(obj))) { return -1; } - - - wsize = (unsigned int)(strlen(json_str) & UINT_MAX); /* CAW: probably unnecessary, but the most 64bit safe */ - wpos = 0; - while(wpos < wsize) { - if((ret = write(fd, json_str + wpos, wsize-wpos)) < 0) { - close(fd); - mc_error("json_object_to_file: error writing file %s: %s\n", - filename, strerror(errno)); - return -1; - } - - /* because of the above check for ret < 0, we can safely cast and add */ - wpos += (unsigned int)ret; - } - - close(fd); - return 0; -} diff --git a/source4/lib/json/json_util.h b/source4/lib/json/json_util.h deleted file mode 100644 index 30fe2ab2c4..0000000000 --- a/source4/lib/json/json_util.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _json_util_h_ -#define _json_util_h_ - -#include "json_object.h" - -#define JSON_FILE_BUF_SIZE 4096 - -/* utlitiy functions */ -extern struct json_object* json_object_from_file(char *filename); -extern int json_object_to_file(char *filename, struct json_object *obj); - -#endif diff --git a/source4/lib/json/linkhash.c b/source4/lib/json/linkhash.c deleted file mode 100644 index b04254b597..0000000000 --- a/source4/lib/json/linkhash.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * $Id: linkhash.c,v 1.4 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "linkhash.h" - -_NORETURN_ void lh_abort(const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); - vprintf(msg, ap); - exit(1); -} - -unsigned long lh_ptr_hash(void *k) -{ - /* CAW: refactored to be 64bit nice */ - return (unsigned long)((((ptrdiff_t)k * LH_PRIME) >> 4) & ULONG_MAX); -} - -int lh_ptr_equal(void *k1, void *k2) -{ - return (k1 == k2); -} - -unsigned long lh_char_hash(void *k) -{ - unsigned int h = 0; - const char* data = k; - - while( *data!=0 ) h = h*129 + (unsigned int)(*data++) + LH_PRIME; - - return h; -} - -int lh_char_equal(void *k1, void *k2) -{ - return (strcmp((char*)k1, (char*)k2) == 0); -} - -struct lh_table* lh_table_new(int size, char *name, - lh_entry_free_fn *free_fn, - lh_hash_fn *hash_fn, - lh_equal_fn *equal_fn) -{ - int i; - struct lh_table *t; - - t = calloc(1, sizeof(struct lh_table)); - if(!t) lh_abort("lh_table_new: calloc failed\n"); - t->count = 0; - t->size = size; - t->name = name; - t->table = calloc(size, sizeof(struct lh_entry)); - if(!t->table) lh_abort("lh_table_new: calloc failed\n"); - t->free_fn = free_fn; - t->hash_fn = hash_fn; - t->equal_fn = equal_fn; - for(i = 0; i < size; i++) t->table[i].k = LH_EMPTY; - return t; -} - -struct lh_table* lh_kchar_table_new(int size, char *name, - lh_entry_free_fn *free_fn) -{ - return lh_table_new(size, name, free_fn, lh_char_hash, lh_char_equal); -} - -struct lh_table* lh_kptr_table_new(int size, char *name, - lh_entry_free_fn *free_fn) -{ - return lh_table_new(size, name, free_fn, lh_ptr_hash, lh_ptr_equal); -} - -void lh_table_resize(struct lh_table *t, int new_size) -{ - struct lh_table *new_t; - struct lh_entry *ent; - - new_t = lh_table_new(new_size, t->name, NULL, t->hash_fn, t->equal_fn); - ent = t->head; - while(ent) { - lh_table_insert(new_t, ent->k, ent->v); - ent = ent->next; - } - free(t->table); - t->table = new_t->table; - t->size = new_size; - t->head = new_t->head; - t->tail = new_t->tail; - t->resizes++; - free(new_t); -} - -void lh_table_free(struct lh_table *t) -{ - struct lh_entry *c; - for(c = t->head; c != NULL; c = c->next) { - if(t->free_fn) { - t->free_fn(c); - } - } - free(t->table); - free(t); -} - - -int lh_table_insert(struct lh_table *t, void *k, void *v) -{ - unsigned long h, n; - - t->inserts++; - if(t->count > t->size * 0.66) lh_table_resize(t, t->size * 2); - - h = t->hash_fn(k); - n = h % t->size; - - while( 1 ) { - if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) break; - t->collisions++; - if(++n == t->size) n = 0; - } - - t->table[n].k = k; - t->table[n].v = v; - t->count++; - - if(t->head == NULL) { - t->head = t->tail = &t->table[n]; - t->table[n].next = t->table[n].prev = NULL; - } else { - t->tail->next = &t->table[n]; - t->table[n].prev = t->tail; - t->table[n].next = NULL; - t->tail = &t->table[n]; - } - - return 0; -} - - -struct lh_entry* lh_table_lookup_entry(struct lh_table *t, void *k) -{ - unsigned long h = t->hash_fn(k); - unsigned long n = h % t->size; - - t->lookups++; - while( 1 ) { - if(t->table[n].k == LH_EMPTY) return NULL; - if(t->table[n].k != LH_FREED && - t->equal_fn(t->table[n].k, k)) return &t->table[n]; - if(++n == t->size) n = 0; - } - return NULL; -} - - -void* lh_table_lookup(struct lh_table *t, void *k) -{ - struct lh_entry *e = lh_table_lookup_entry(t, k); - if(e) return e->v; - return NULL; -} - - -int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e) -{ - ptrdiff_t n = (ptrdiff_t)(e - t->table); /* CAW: fixed to be 64bit nice, still need the crazy negative case... */ - - /* CAW: this is bad, really bad, maybe stack goes other direction on this machine... */ - if(n < 0) { return -2; } - - if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) return -1; - t->count--; - if(t->free_fn) t->free_fn(e); - t->table[n].v = NULL; - t->table[n].k = LH_FREED; - if(t->tail == &t->table[n] && t->head == &t->table[n]) { - t->head = t->tail = NULL; - } else if (t->head == &t->table[n]) { - t->head->next->prev = NULL; - t->head = t->head->next; - } else if (t->tail == &t->table[n]) { - t->tail->prev->next = NULL; - t->tail = t->tail->prev; - } else { - t->table[n].prev->next = t->table[n].next; - t->table[n].next->prev = t->table[n].prev; - } - t->table[n].next = t->table[n].prev = NULL; - return 0; -} - - -int lh_table_delete(struct lh_table *t, void *k) -{ - struct lh_entry *e = lh_table_lookup_entry(t, k); - if(!e) return -1; - return lh_table_delete_entry(t, e); -} - diff --git a/source4/lib/json/linkhash.h b/source4/lib/json/linkhash.h deleted file mode 100644 index 5c9fa852d8..0000000000 --- a/source4/lib/json/linkhash.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _linkhash_h_ -#define _linkhash_h_ - -/** - * golden prime used in hash functions - */ -#define LH_PRIME 0x9e370001UL - -/** - * sentinel pointer value for empty slots - */ -#define LH_EMPTY (void*)-1 - -/** - * sentinel pointer value for freed slots - */ -#define LH_FREED (void*)-2 - -struct lh_entry; - -/** - * callback function prototypes - */ -typedef void (lh_entry_free_fn) (struct lh_entry *e); -/** - * callback function prototypes - */ -typedef unsigned long (lh_hash_fn) (void *k); -/** - * callback function prototypes - */ -typedef int (lh_equal_fn) (void *k1, void *k2); - -/** - * An entry in the hash table - */ -struct lh_entry { - /** - * The key. - */ - void *k; - /** - * The value. - */ - void *v; - /** - * The next entry - */ - struct lh_entry *next; - /** - * The previous entry. - */ - struct lh_entry *prev; -}; - - -/** - * The hash table structure. - */ -struct lh_table { - /** - * Size of our hash. - */ - int size; - /** - * Numbers of entries. - */ - int count; - - /** - * Number of collisions. - */ - int collisions; - - /** - * Number of resizes. - */ - int resizes; - - /** - * Number of lookups. - */ - int lookups; - - /** - * Number of inserts. - */ - int inserts; - - /** - * Number of deletes. - */ - int deletes; - - /** - * Name of the hash table. - */ - char *name; - - /** - * The first entry. - */ - struct lh_entry *head; - - /** - * The last entry. - */ - struct lh_entry *tail; - - struct lh_entry *table; - - /** - * A pointer onto the function responsible for freeing an entry. - */ - lh_entry_free_fn *free_fn; - lh_hash_fn *hash_fn; - lh_equal_fn *equal_fn; -}; - - -/** - * Pre-defined hash and equality functions - */ -extern unsigned long lh_ptr_hash(void *k); -extern int lh_ptr_equal(void *k1, void *k2); - -extern unsigned long lh_char_hash(void *k); -extern int lh_char_equal(void *k1, void *k2); - - -/** - * Convenience list iterator. - */ -#define lh_foreach(table, entry) \ -for(entry = table->head; entry; entry = entry->next) - -/** - * lh_foreach_safe allows calling of deletion routine while iterating. - */ -#define lh_foreach_safe(table, entry, tmp) \ -for(entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp) - - - -/** - * Create a new linkhash table. - * @param size initial table size. The table is automatically resized - * although this incurs a performance penalty. - * @param name the table name. - * @param free_fn callback function used to free memory for entries - * when lh_table_free or lh_table_delete is called. - * If NULL is provided, then memory for keys and values - * must be freed by the caller. - * @param hash_fn function used to hash keys. 2 standard ones are defined: - * lh_ptr_hash and lh_char_hash for hashing pointer values - * and C strings respectively. - * @param equal_fn comparison function to compare keys. 2 standard ones defined: - * lh_ptr_hash and lh_char_hash for comparing pointer values - * and C strings respectively. - * @return a pointer onto the linkhash table. - */ -extern struct lh_table* lh_table_new(int size, char *name, - lh_entry_free_fn *free_fn, - lh_hash_fn *hash_fn, - lh_equal_fn *equal_fn); - -/** - * Convenience function to create a new linkhash - * table with char keys. - * @param size initial table size. - * @param name table name. - * @param free_fn callback function used to free memory for entries. - * @return a pointer onto the linkhash table. - */ -extern struct lh_table* lh_kchar_table_new(int size, char *name, - lh_entry_free_fn *free_fn); - - -/** - * Convenience function to create a new linkhash - * table with ptr keys. - * @param size initial table size. - * @param name table name. - * @param free_fn callback function used to free memory for entries. - * @return a pointer onto the linkhash table. - */ -extern struct lh_table* lh_kptr_table_new(int size, char *name, - lh_entry_free_fn *free_fn); - - -/** - * Free a linkhash table. - * If a callback free function is provided then it is called for all - * entries in the table. - * @param t table to free. - */ -extern void lh_table_free(struct lh_table *t); - - -/** - * Insert a record into the table. - * @param t the table to insert into. - * @param k a pointer to the key to insert. - * @param v a pointer to the value to insert. - */ -extern int lh_table_insert(struct lh_table *t, void *k, void *v); - - -/** - * Lookup a record into the table. - * @param t the table to lookup - * @param k a pointer to the key to lookup - * @return a pointer to the record structure of the value or NULL if it does not exist. - */ -extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, void *k); - -/** - * Lookup a record into the table - * @param t the table to lookup - * @param k a pointer to the key to lookup - * @return a pointer to the found value or NULL if it does not exist. - */ -extern void* lh_table_lookup(struct lh_table *t, void *k); - - -/** - * Delete a record from the table. - * If a callback free function is provided then it is called for the - * for the item being deleted. - * @param t the table to delete from. - * @param e a pointer to the entry to delete. - * @return 0 if the item was deleted. - * @return -1 if it was not found. - */ -extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e); - - -/** - * Delete a record from the table. - * If a callback free function is provided then it is called for the - * for the item being deleted. - * @param t the table to delete from. - * @param k a pointer to the key to delete. - * @return 0 if the item was deleted. - * @return -1 if it was not found. - */ -extern int lh_table_delete(struct lh_table *t, void *k); - - -#endif diff --git a/source4/lib/json/ltmain.sh b/source4/lib/json/ltmain.sh deleted file mode 100644 index cf3e25def5..0000000000 --- a/source4/lib/json/ltmain.sh +++ /dev/null @@ -1,6425 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun configure. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 -# Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -basename="s,^.*/,,g" - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - -# The name of this program: -progname=`echo "$progpath" | $SED $basename` -modename="$progname" - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -PROGRAM=ltmain.sh -PACKAGE=libtool -VERSION=1.5.6 -TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 224 $" - - -# Check that we have a working $echo. -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell, and then maybe $echo will work. - exec $SHELL "$progpath" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit $EXIT_FAILURE -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" - -##################################### -# Shell function definitions: -# This seems to be the best place for them - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -func_win32_libid () { - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ - $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then - win32_nmres=`eval $NM -f posix -A $1 | \ - sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` - if test "X$win32_nmres" = "Ximport" ; then - win32_libid_type="x86 archive import" - else - win32_libid_type="x86 archive static" - fi - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $echo $win32_libid_type -} - - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () { - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - CC_quoted="$CC_quoted $arg" - done - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - CC_quoted="$CC_quoted $arg" - done - case "$@ " in - " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - $echo "$modename: unable to infer tagged configuration" - $echo "$modename: specify a tag with \`--tag'" 1>&2 - exit $EXIT_FAILURE -# else -# $echo "$modename: using $tagname tagged configuration" - fi - ;; - esac - fi -} -# End of Shell function definitions -##################################### - -# Darwin sucks -eval std_shrext=\"$shrext_cmds\" - -# Parse our command line options once, thoroughly. -while test "$#" -gt 0 -do - arg="$1" - shift - - case $arg in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; - tag) - tagname="$arg" - preserve_args="${preserve_args}=$arg" - - # Check whether tagname contains only valid characters - case $tagname in - *[!-_A-Za-z0-9,/]*) - $echo "$progname: invalid tag name: $tagname" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - case $tagname in - CC) - # Don't test for the "default" C tag, as we know, it's there, but - # not specially marked. - ;; - *) - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then - taglist="$taglist $tagname" - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" - else - $echo "$progname: ignoring unknown tag $tagname" 1>&2 - fi - ;; - esac - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case $arg in - --help) - show_help=yes - ;; - - --version) - $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" - $echo - $echo "Copyright (C) 2003 Free Software Foundation, Inc." - $echo "This is free software; see the source for copying conditions. There is NO" - $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - exit $EXIT_SUCCESS - ;; - - --config) - ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath - # Now print the configurations for the tags. - for tagname in $taglist; do - ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" - done - exit $EXIT_SUCCESS - ;; - - --debug) - $echo "$progname: enabling shell trace mode" - set -x - preserve_args="$preserve_args $arg" - ;; - - --dry-run | -n) - run=: - ;; - - --features) - $echo "host: $host" - if test "$build_libtool_libs" = yes; then - $echo "enable shared libraries" - else - $echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - $echo "enable static libraries" - else - $echo "disable static libraries" - fi - exit $EXIT_SUCCESS - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --preserve-dup-deps) duplicate_deps="yes" ;; - - --quiet | --silent) - show=: - preserve_args="$preserve_args $arg" - ;; - - --tag) prevopt="--tag" prev=tag ;; - --tag=*) - set tag "$optarg" ${1+"$@"} - shift - prev=tag - preserve_args="$preserve_args --tag" - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE -fi - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 - $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 - case $nonopt in - *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) - mode=link - for arg - do - case $arg in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx | *strace | *truss) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case $mode in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - - for arg - do - case "$arg_mode" in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - if test -n "$libobj" ; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit $EXIT_FAILURE - fi - arg_mode=target - continue - ;; - - -static | -prefer-pic | -prefer-non-pic) - later="$later $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - base_compile="$base_compile $lastarg" - continue - ;; - - * ) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - case $lastarg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - - base_compile="$base_compile $lastarg" - done # for arg - - case $arg_mode in - arg) - $echo "$modename: you must specify an argument for -Xcompile" - exit $EXIT_FAILURE - ;; - target) - $echo "$modename: you must specify a target with \`-o'" 1>&2 - exit $EXIT_FAILURE - ;; - *) - # Get the name of the library object. - [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSifmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.ii) xform=ii ;; - *.class) xform=class ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - *.java) xform=java ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case $libobj in - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir= - else - xdir=$xdir/ - fi - lobj=${xdir}$objdir/$objname - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - $run $rm $removelist - trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" - trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $run ln "$progpath" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $echo "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit $EXIT_FAILURE - fi - $echo $srcfile > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - - $run $rm "$libobj" "${libobj}T" - - # Create a libtool object file (analogous to a ".la" file), - # but don't create it if we're doing a dry run. - test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then - $echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - $show "$mv $output_obj $lobj" - if $run $mv $output_obj $lobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Append the name of the PIC object to the libtool object file. - test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then - $echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Append the name of the non-PIC object the libtool object file. - # Only append if the libtool object file exists. - test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - else - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - fi - build_libtool_libs=no - build_old_libs=yes - prefer_static_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test - ;; - *) qarg=$arg ;; - esac - libtool_args="$libtool_args $qarg" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - if test ! -f "$arg"; then - $echo "$modename: symbol file \`$arg' does not exist" - exit $EXIT_FAILURE - fi - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat $save_arg` - do -# moreargs="$moreargs $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - pic_object= - non_pic_object= - - # Read the .lo file - # If there is no directory component, then add one. - case $arg in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$pic_object" || \ - test -z "$non_pic_object" || - test "$pic_object" = none && \ - test "$non_pic_object" = none; then - $echo "$modename: cannot find name of object for \`$arg'" 1>&2 - exit $EXIT_FAILURE - fi - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - libobjs="$libobjs $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - fi - else - # Only an error if not doing a dry-run. - if test -z "$run"; then - $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 - exit $EXIT_FAILURE - else - # Dry-run case. - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` - non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" - fi - fi - done - else - $echo "$modename: link input file \`$save_arg' does not exist" - exit $EXIT_FAILURE - fi - arg=$save_arg - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit $EXIT_FAILURE - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" - continue - ;; - xcclinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" - exit $EXIT_FAILURE - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; - esac - continue - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit $EXIT_FAILURE - fi - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$dir:"*) ;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-mingw* | *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - deplibs="$deplibs -framework System" - continue - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - deplibs="$deplibs $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # gcc -m* arguments should be passed to the linker via $compiler_flags - # in order to pass architecture information to the linker - # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo - # but this is not reliable with gcc because gcc may use -mfoo to - # select a different linker, different libraries, etc, while - # -Wl,-mfoo simply passes -mfoo to the linker. - -m*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - if test "$with_gcc" = "yes" ; then - compiler_flags="$compiler_flags $arg" - fi - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # The PATH hackery in wrapper scripts is required on Windows - # in order for the loader to find any dlls it needs. - $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 - $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit $EXIT_FAILURE - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -static) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Wl,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $wl$flag" - linker_flags="$linker_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - - *.$objext) - # A standard object. - objs="$objs $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - pic_object= - non_pic_object= - - # Read the .lo file - # If there is no directory component, then add one. - case $arg in - */* | *\\*) . $arg ;; - *) . ./$arg ;; - esac - - if test -z "$pic_object" || \ - test -z "$non_pic_object" || - test "$pic_object" = none && \ - test "$non_pic_object" = none; then - $echo "$modename: cannot find name of object for \`$arg'" 1>&2 - exit $EXIT_FAILURE - fi - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - libobjs="$libobjs $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - non_pic_objects="$non_pic_objects $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - fi - else - # Only an error if not doing a dry-run. - if test -z "$run"; then - $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 - exit $EXIT_FAILURE - else - # Dry-run case. - - # Extract subdirectory from the argument. - xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$arg"; then - xdir= - else - xdir="$xdir/" - fi - - pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` - non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` - libobjs="$libobjs $pic_object" - non_pic_objects="$non_pic_objects $non_pic_object" - fi - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done # argument parsing loop - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` - if test "X$output_objdir" = "X$output"; then - output_objdir="$objdir" - else - output_objdir="$output_objdir/$objdir" - fi - # Create the object directory. - if test ! -d "$output_objdir"; then - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test "$status" -ne 0 && test ! -d "$output_objdir"; then - exit $status - fi - fi - - # Determine the type of output - case $output in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - case $host in - *cygwin* | *mingw* | *pw32*) - # don't eliminate duplications in $postdeps and $predeps - duplicate_compiler_generated_deps=yes - ;; - *) - duplicate_compiler_generated_deps=$duplicate_deps - ;; - esac - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if test "X$duplicate_deps" = "Xyes" ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - libs="$libs $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; - esac - pre_post_deps="$pre_post_deps $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - case $linkmode in - lib) - passes="conv link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 - exit $EXIT_FAILURE - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - for pass in $passes; do - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) - libs="$deplibs %DEPLIBS%" - test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" - ;; - esac - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if (${SED} -e '2q' $lib | - grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - library_names= - old_library= - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - *) - $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - if test "$deplibs_check_method" != pass_all; then - $echo - $echo "*** Warning: Trying to link with static lib archive $deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because the file extensions .$libext of this argument makes me believe" - $echo "*** that it is just a static archive that I should not used here." - else - $echo - $echo "*** Warning: Linking the shared library $output against the" - $echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - if test "$found" = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - - # Read the .la file - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 - exit $EXIT_FAILURE - fi - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - dlprefiles="$dlprefiles $lib $dependency_libs" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 - $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 - abs_ladir="$ladir" - fi - ;; - esac - laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - $echo "$modename: warning: library \`$lib' was moved." 1>&2 - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 - exit $EXIT_FAILURE - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - # This is a shared library - - # Warn about portability, can't link against -module's on - # some systems (darwin) - if test "$shouldnotlink" = yes && test "$pass" = link ; then - $echo - if test "$linkmode" = prog; then - $echo "*** Warning: Linking the executable $output against the loadable module" - else - $echo "*** Warning: Linking the shared library $output against the loadable module" - fi - $echo "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - realname="$2" - shift; shift - libname=`eval \\$echo \"$libname_spec\"` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw*) - major=`expr $current - $age` - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - soname=`$echo $soroot | ${SED} -e 's/^.*\///'` - newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' - cmds=$extract_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' - cmds=$old_archive_from_expsyms_cmds - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5* ) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a module then we can not link against - # it, someone is ignoring the new warnings I added - if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then - $echo "** Warning, lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - $echo - $echo "** And there doesn't seem to be a static archive available" - $echo "** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" - exit $EXIT_FAILURE - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - $echo - $echo "*** Warning: This system can not link to static lib archive $lib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - $echo "*** But as you try to build a module library, libtool will still create " - $echo "*** a static module, that should work as long as the dlopening application" - $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - $echo - $echo "*** However, this would only work if libtool was able to extract symbol" - $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - $echo "*** not find such a program. So, this module is probably useless." - $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - convenience="$convenience $dir/$old_library" - old_convenience="$old_convenience $dir/$old_library" - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$deplib" && dir="." - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 - absdir="$dir" - fi - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then - path="$absdir/$objdir" - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi - path="$absdir" - fi - depdepl= - case $host in - *-*-darwin*) - # we do not want to link against static libs, - # but need to link against shared - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$path/$depdepl" ; then - depdepl="$path/$depdepl" - fi - # do not add paths which are already there - case " $newlib_search_path " in - *" $path "*) ;; - *) newlib_search_path="$newlib_search_path $path";; - esac - fi - path="" - ;; - *) - path="-L$path" - ;; - esac - ;; - -l*) - case $host in - *-*-darwin*) - # Again, we only want to link against shared libraries - eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` - for tmp in $newlib_search_path ; do - if test -f "$tmp/lib$tmp_libs.dylib" ; then - eval depdepl="$tmp/lib$tmp_libs.dylib" - break - fi - done - path="" - ;; - *) continue ;; - esac - ;; - *) continue ;; - esac - case " $deplibs " in - *" $depdepl "*) ;; - *) deplibs="$depdepl $deplibs" ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - tmp_libs="$tmp_libs $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 - fi - - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 - fi - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 - exit $EXIT_FAILURE - else - $echo - $echo "*** Warning: Linking the shared library $output against the non-libtool" - $echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - if test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 - fi - - set dummy $rpath - if test "$#" -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 - fi - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - IFS="$save_ifs" - - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$2" - number_minor="$3" - number_revision="$4" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - darwin|linux|osf|windows) - current=`expr $number_major + $number_minor` - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - current=`expr $number_major + $number_minor - 1` - age="$number_minor" - revision="$number_minor" - ;; - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit $EXIT_FAILURE - ;; - esac - ;; - no) - current="$2" - revision="$3" - age="$4" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - if test "$age" -gt "$current"; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit $EXIT_FAILURE - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current"; - ;; - - irix | nonstopux) - major=`expr $current - $age + 1` - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - major=.`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - major=`expr $current - $age` - versuffix="-$major" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit $EXIT_FAILURE - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - fi - - if test "$mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$echo "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - removelist="$removelist $p" - ;; - *) ;; - esac - done - if test -n "$removelist"; then - $show "${rm}r $removelist" - $run ${rm}r $removelist - fi - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - for path in $notinst_path; do - lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $rm conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | ${SED} 10q \ - | $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $echo - $echo "*** Warning: linker path does not have real file for library $a_deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $echo "*** with $libname but no candidates were found. (...for file magic test)" - else - $echo "*** with $libname and none of the candidates passed a file format test" - $echo "*** using a file magic. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval $echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $echo - $echo "*** Warning: linker path does not have real file for library $a_deplib." - $echo "*** I have the capability to make that library automatically link in when" - $echo "*** you link to this library. But I can only do this if you have a" - $echo "*** shared version of the library, which you do not appear to have" - $echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $echo "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $echo "*** with $libname and none of the candidates passed a file format test" - $echo "*** using a regex pattern. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` - done - fi - if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ - | grep . >/dev/null; then - $echo - if test "X$deplibs_check_method" = "Xnone"; then - $echo "*** Warning: inter-library dependencies are not supported in this platform." - else - $echo "*** Warning: inter-library dependencies are not known to be supported." - fi - $echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - $echo - $echo "*** Warning: libtool could not satisfy all declared inter-library" - $echo "*** dependencies of module $libname. Therefore, libtool will create" - $echo "*** a static module, that should work as long as the dlopening" - $echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - $echo - $echo "*** However, this would only work if libtool was able to extract symbol" - $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - $echo "*** not find such a program. So, this module is probably useless." - $echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - $echo "*** The inter-library dependencies that have been dropped here will be" - $echo "*** automatically added whenever a program is linked with this library" - $echo "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - $echo - $echo "*** Since this library must not contain undefined symbols," - $echo "*** because either the platform does not support them or" - $echo "*** it was explicitly requested with -no-undefined," - $echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - if len=`expr "X$cmd" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - $show "$cmd" - $run eval "$cmd" || exit $? - skipped_export=false - else - # The command line is too long to execute in one step. - $show "using reloadable object file for export list..." - skipped_export=: - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then - $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - tmp_deplibs="$tmp_deplibs $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise. - $echo "creating reloadable object files..." - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - delfiles= - last_robj= - k=1 - output=$output_objdir/$save_output-${k}.$objext - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - eval test_cmds=\"$reload_cmds $objlist $last_robj\" - if test "X$objlist" = X || - { len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len"; }; then - objlist="$objlist $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - eval concat_cmds=\"$reload_cmds $objlist $last_robj\" - else - # All subsequent reloadable object files will link in - # the last one created. - eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" - fi - last_robj=$output_objdir/$save_output-${k}.$objext - k=`expr $k + 1` - output=$output_objdir/$save_output-${k}.$objext - objlist=$obj - len=1 - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" - - if ${skipped_export-false}; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - libobjs=$output - # Append the command to create the export file. - eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" - fi - - # Set up a command to remove the reloadale object files - # after they are used. - i=0 - while test "$i" -lt "$k" - do - i=`expr $i + 1` - delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" - done - - $echo "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - - # Append the command to remove the reloadable object files - # to the just-reset $cmds. - eval cmds=\"\$cmds~\$rm $delfiles\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 - fi - - case $output in - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit $EXIT_FAILURE - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $run eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - cmds=$reload_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 - fi - - if test "$preload" = yes; then - if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && - test "$dlopen_self_static" = unknown; then - $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." - fi - fi - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - case $host in - *darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - if test "$tagname" = CXX ; then - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - fi - ;; - esac - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$libdir:"*) ;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${outputname}S.c" - else - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - fi - fi - - if test -n "$dlsyms"; then - case $dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${outputname}.nm" - - $show "$rm $nlist ${nlist}S ${nlist}T" - $run $rm "$nlist" "${nlist}S" "${nlist}T" - - # Parse the name list into a source file. - $show "creating $output_objdir/$dlsyms" - - test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define lt_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - $show "generating symbol list for \`$output'" - - test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for arg in $progfiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then - $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$output.exp" - $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else - $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' - $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` - $run eval '$echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -z "$run"; then - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else - $echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ - -#undef lt_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{\ -" - - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" - - $echo >> "$output_objdir/$dlsyms" "\ - {0, (lt_ptr) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - fi - - pic_flag_for_symtable= - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag";; - esac - esac - - # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" - $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit $EXIT_FAILURE - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - $show "$link_command" - $run eval "$link_command" - status=$? - - # Delete the generated files. - if test -n "$dlsyms"; then - $show "$rm $output_objdir/${outputname}S.${objext}" - $run $rm "$output_objdir/${outputname}S.${objext}" - fi - - exit $status - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $run $rm $output - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 - $echo "$modename: \`$output' will be relinked during installation" 1>&2 - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname - - $show "$link_command" - $run eval "$link_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $echo for shipping. - if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then - case $progpath in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; - *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - cwrappersource=`$echo ${objdir}/lt-${output}.c` - cwrapper=`$echo ${output}.exe` - $rm $cwrappersource $cwrapper - trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - cat > $cwrappersource <> $cwrappersource<<"EOF" -#include -#include -#include -#include -#include -#include - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef DIR_SEPARATOR -#define DIR_SEPARATOR '/' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -#define HAVE_DOS_BASED_FILE_SYSTEM -#ifndef DIR_SEPARATOR_2 -#define DIR_SEPARATOR_2 '\\' -#endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -const char *program_name = NULL; - -void * xmalloc (size_t num); -char * xstrdup (const char *string); -char * basename (const char *name); -char * fnqualify(const char *path); -char * strendzap(char *str, const char *pat); -void lt_fatal (const char *message, ...); - -int -main (int argc, char *argv[]) -{ - char **newargz; - int i; - - program_name = (char *) xstrdup ((char *) basename (argv[0])); - newargz = XMALLOC(char *, argc+2); -EOF - - cat >> $cwrappersource <> $cwrappersource <<"EOF" - newargz[1] = fnqualify(argv[0]); - /* we know the script has the same name, without the .exe */ - /* so make sure newargz[1] doesn't end in .exe */ - strendzap(newargz[1],".exe"); - for (i = 1; i < argc; i++) - newargz[i+1] = xstrdup(argv[i]); - newargz[argc+1] = NULL; -EOF - - cat >> $cwrappersource <> $cwrappersource <<"EOF" -} - -void * -xmalloc (size_t num) -{ - void * p = (void *) malloc (num); - if (!p) - lt_fatal ("Memory exhausted"); - - return p; -} - -char * -xstrdup (const char *string) -{ - return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL -; -} - -char * -basename (const char *name) -{ - const char *base; - -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha (name[0]) && name[1] == ':') - name += 2; -#endif - - for (base = name; *name; name++) - if (IS_DIR_SEPARATOR (*name)) - base = name + 1; - return (char *) base; -} - -char * -fnqualify(const char *path) -{ - size_t size; - char *p; - char tmp[LT_PATHMAX + 1]; - - assert(path != NULL); - - /* Is it qualified already? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha (path[0]) && path[1] == ':') - return xstrdup (path); -#endif - if (IS_DIR_SEPARATOR (path[0])) - return xstrdup (path); - - /* prepend the current directory */ - /* doesn't handle '~' */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal ("getcwd failed"); - size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ - p = XMALLOC(char, size); - sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); - return p; -} - -char * -strendzap(char *str, const char *pat) -{ - size_t len, patlen; - - assert(str != NULL); - assert(pat != NULL); - - len = strlen(str); - patlen = strlen(pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp(str, pat) == 0) - *str = '\0'; - } - return str; -} - -static void -lt_error_core (int exit_status, const char * mode, - const char * message, va_list ap) -{ - fprintf (stderr, "%s: %s: ", program_name, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, "FATAL", message, ap); - va_end (ap); -} -EOF - # we should really use a build-platform specific compiler - # here, but OTOH, the wrappers (shell script and this C one) - # are only useful if you want to execute the "real" binary. - # Since the "real" binary is built for $host, then this - # wrapper might as well be built for $host, too. - $run $LTCC -s -o $cwrapper $cwrappersource - ;; - esac - $rm $output - trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 - - $echo > $output "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='${SED} -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variable: - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - echo=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$echo works! - : - else - # Restart under the correct shell, and then maybe \$echo will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" - else - $rm \"\$progdir/\$file\" - fi" - - $echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" - exit $EXIT_FAILURE - fi - fi - - $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $rm \"\$progdir/\$program\"; - $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $rm \"\$progdir/\$file\" - fi" - else - $echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $echo >> $output "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ - exec \$progdir\\\\\$program \${1+\"\$@\"} -" - ;; - - *) - $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} -" - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit $EXIT_FAILURE - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - $echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit $EXIT_FAILURE - fi -fi\ -" - chmod +x $output - fi - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "$mkdir $gentop" - $run $mkdir "$gentop" - status=$? - if test "$status" -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - # Add in members from convenience archives. - for xlib in $addlibs; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "$mkdir $xdir" - $run $mkdir "$xdir" - status=$? - if test "$status" -ne 0 && test ! -d "$xdir"; then - exit $status - fi - # We will extract separately just the conflicting names and we will no - # longer touch any unique names. It is faster to leave these extract - # automatically by $AR in one run. - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 - $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 - $AR t "$xabs" | sort | uniq -cd | while read -r count name - do - i=1 - while test "$i" -le "$count" - do - # Put our $i before any first dot (extension) - # Never overwrite any file - name_to="$name" - while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" - do - name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` - done - $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" - $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? - i=`expr $i + 1` - done - done - fi - - oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` - done - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - eval cmds=\"$old_archive_cmds\" - - if len=`expr "X$cmds" : ".*"` && - test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - $echo "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - # GNU ar 2.10+ was changed to match POSIX; thus no paths are - # encoded into archives. This makes 'ar r' malfunction in - # this piecewise linking case whenever conflicting object - # names appear in distinct ar calls; check, warn and compensate. - if (for obj in $save_oldobjs - do - $echo "X$obj" | $Xsed -e 's%^.*/%%' - done | sort | sort -uc >/dev/null 2>&1); then - : - else - $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 - $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 - AR_FLAGS=cq - fi - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - for obj in $save_oldobjs - do - oldobjs="$objlist $obj" - objlist="$objlist $obj" - eval test_cmds=\"$old_archive_cmds\" - if len=`expr "X$test_cmds" : ".*"` && - test "$len" -le "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - eval cmd=\"$cmd\" - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$generated"; then - $show "${rm}r$generated" - $run ${rm}r$generated - fi - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - $show "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - - # Only create the output if not a dry run. - if test -z "$run"; then - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - newdlfiles="$newdlfiles $libdir/$name" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit $EXIT_FAILURE - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlfiles="$newdlfiles $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlprefiles="$newdlprefiles $abs" - done - dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $echo >> $output "\ -relink_command=\"$relink_command\"" - fi - done - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac - exit $EXIT_SUCCESS - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test "$#" -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - library_names= - old_library= - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - if test "$inst_prefix_dir" = "$destdir"; then - $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 - exit $EXIT_FAILURE - fi - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` - fi - - $echo "$modename: warning: relinking \`$file'" 1>&2 - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - exit $EXIT_FAILURE - fi - fi - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$srcname $destdir/$realname" - $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? - if test -n "$stripme" && test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run eval "$striplib $destdir/$realname" || exit $? - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - for linkname - do - if test "$linkname" != "$realname"; then - $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - cmds=$postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - instname="$dir/$name"i - $show "$install_prog $instname $destdir/$name" - $run eval "$install_prog $instname $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - file=`$echo $file|${SED} 's,.exe$,,'` - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin*|*mingw*) - wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` - ;; - *) - wrapper=$file - ;; - esac - if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then - notinst_deplibs= - relink_command= - - # To insure that "foo" is sourced, and not "foo.exe", - # finese the cygwin/MSYS system by explicitly sourcing "foo." - # which disallows the automatic-append-.exe behavior. - case $build in - *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; - *) wrapperdot=${wrapper} ;; - esac - # If there is no directory component, then add one. - case $file in - */* | *\\*) . ${wrapperdot} ;; - *) . ./${wrapperdot} ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 - exit $EXIT_FAILURE - fi - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - relink_command= - # To insure that "foo" is sourced, and not "foo.exe", - # finese the cygwin/MSYS system by explicitly sourcing "foo." - # which disallows the automatic-append-.exe behavior. - case $build in - *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; - *) wrapperdot=${wrapper} ;; - esac - # If there is no directory component, then add one. - case $file in - */* | *\\*) . ${wrapperdot} ;; - *) . ./${wrapperdot} ;; - esac - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" - save_umask=`umask` - umask 0077 - if $mkdir "$tmpdir"; then - umask $save_umask - else - umask $save_umask - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi - file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - ${rm}r "$tmpdir" - continue - fi - file="$outputname" - else - $echo "$modename: warning: cannot relink \`$file'" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyways - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` - ;; - esac - ;; - esac - $show "$install_prog$stripme $file $destfile" - $run eval "$install_prog\$stripme \$file \$destfile" || exit $? - test -n "$outputname" && ${rm}r "$tmpdir" - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - if test -n "$stripme" && test -n "$old_striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. - cmds=$old_postinstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - cmds=$finish_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - test "$show" = : && exit $EXIT_SUCCESS - - $echo "----------------------------------------------------------------------" - $echo "Libraries have been installed in:" - for libdir in $libdirs; do - $echo " $libdir" - done - $echo - $echo "If you ever happen to want to link against installed libraries" - $echo "in a given directory, LIBDIR, you must either use libtool, and" - $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - $echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - $echo " during execution" - fi - if test -n "$runpath_var"; then - $echo " - add LIBDIR to the \`$runpath_var' environment variable" - $echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - $echo - $echo "See any operating system documentation about shared libraries for" - $echo "more information, such as the ld(1) and ld.so(8) manual pages." - $echo "----------------------------------------------------------------------" - exit $EXIT_SUCCESS - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit $EXIT_FAILURE - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit $EXIT_FAILURE - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi - if test "${save_LANG+set}" = set; then - LANG="$save_LANG"; export LANG - fi - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" - exit $EXIT_SUCCESS - fi - ;; - - # libtool clean and uninstall mode - clean | uninstall) - modename="$modename: $mode" - rm="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) rm="$rm $arg"; rmforce=yes ;; - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - fi - - rmdirs= - - origobjdir="$objdir" - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. - objdir="$origobjdir" - else - objdir="$dir/$origobjdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test "$mode" = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test "$mode" = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if (test -L "$file") >/dev/null 2>&1 \ - || (test -h "$file") >/dev/null 2>&1 \ - || test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - - if test "$mode" = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - cmds=$postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - cmds=$old_postuninstall_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $show "$cmd" - $run eval "$cmd" - if test "$?" -ne 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - # FIXME: should reinstall the best remaining shared library. - fi - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - - # Read the .lo file - . $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" \ - && test "$pic_object" != none; then - rmfiles="$rmfiles $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" \ - && test "$non_pic_object" != none; then - rmfiles="$rmfiles $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$mode" = clean ; then - noexename=$name - case $file in - *.exe) - file=`$echo $file|${SED} 's,.exe$,,'` - noexename=`$echo $name|${SED} 's,.exe$,,'` - # $file with .exe has already been added to rmfiles, - # add $file without .exe - rmfiles="$rmfiles $file" - ;; - esac - # Do a test to see if this is a libtool program. - if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$noexename - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - rmfiles="$rmfiles $objdir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done - objdir="$origobjdir" - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 - fi - done - - exit $exit_status - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit $EXIT_FAILURE - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit $EXIT_FAILURE - fi -fi # test -z "$show_help" - -if test -n "$exec_cmd"; then - eval exec $exec_cmd - exit $EXIT_FAILURE -fi - -# We need to display help for each of the modes. -case $mode in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - - --config show all configuration variables - --debug enable verbose shell tracing --n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --tag=TAG use configuration variables from tag TAG - --version print version information - -MODE must be one of the following: - - clean remove files from the build directory - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE. - -Report bugs to ." - exit $EXIT_SUCCESS - ;; - -clean) - $echo \ -"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -static always build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - -uninstall) - $echo \ -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit $EXIT_FAILURE - ;; -esac - -$echo -$echo "Try \`$modename --help' for more information about other modes." - -exit $EXIT_SUCCESS - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/source4/lib/json/missing b/source4/lib/json/missing deleted file mode 100755 index 5846bcf8b0..0000000000 --- a/source4/lib/json/missing +++ /dev/null @@ -1,334 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# 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, 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 . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing 0.4 - GNU automake" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. - You can get \`$1Help2man' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then - # We have makeinfo, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - tar) - shift - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - fi - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/source4/lib/json/mkinstalldirs b/source4/lib/json/mkinstalldirs deleted file mode 100755 index 8ab885ec92..0000000000 --- a/source4/lib/json/mkinstalldirs +++ /dev/null @@ -1,99 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -errstatus=0 -dirmode="" - -usage="\ -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." - -# process command line arguments -while test $# -gt 0 ; do - case "${1}" in - -h | --help | --h* ) # -h for help - echo "${usage}" 1>&2; exit 0 ;; - -m ) # -m PERM arg - shift - test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } - dirmode="${1}" - shift ;; - -- ) shift; break ;; # stop option processing - -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option - * ) break ;; # first non-opt arg - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in -0) exit 0 ;; -esac - -case $dirmode in -'') - if mkdir -p -- . 2>/dev/null; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - fi ;; -*) - if mkdir -m "$dirmode" -p -- . 2>/dev/null; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - fi ;; -esac - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - - lasterr="" - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 3 -# End: -# mkinstalldirs ends here diff --git a/source4/lib/json/printbuf.c b/source4/lib/json/printbuf.c deleted file mode 100644 index 79bdaf554a..0000000000 --- a/source4/lib/json/printbuf.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * $Id: printbuf.c,v 1.5 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#include "config.h" - -#include -#include -#include - -#if HAVE_STDARG_H -# include -#else /* !HAVE_STDARG_H */ -# error Not enough var arg support! -#endif /* HAVE_STDARG_H */ - -#include "bits.h" -#include "debug.h" -#include "printbuf.h" - -struct printbuf* printbuf_new() -{ - struct printbuf *p; - - if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL; - p->size = 32; - p->bpos = 0; - if(!(p->buf = malloc(p->size))) { - free(p); - return NULL; - } - return p; -} - - -int printbuf_memappend(struct printbuf *p, char *buf, int size) -{ - char *t; - if(p->size - p->bpos <= size) { - int new_size = max(p->size * 2, p->bpos + size + 8); -#ifdef PRINTBUF_DEBUG - mc_debug("printbuf_memappend: realloc " - "bpos=%d wrsize=%d old_size=%d new_size=%d\n", - p->bpos, size, p->size, new_size); -#endif /* PRINTBUF_DEBUG */ - if(!(t = realloc(p->buf, new_size))) return -1; - p->size = new_size; - p->buf = t; - } - memcpy(p->buf + p->bpos, buf, size); - p->bpos += size; - p->buf[p->bpos]= '\0'; - return size; -} - -#if !HAVE_VSNPRINTF && defined(WIN32) -# define vsnprintf _vsnprintf -#elif !HAVE_VSNPRINTF /* !HAVE_VSNPRINTF */ -# error Need vsnprintf! -#endif /* !HAVE_VSNPRINTF && defined(WIN32) */ - -#if !HAVE_VASPRINTF -/* CAW: compliant version of vasprintf */ -static int vasprintf(char **buf, const char *fmt, va_list ap) -{ -#ifndef WIN32 - static char _T_emptybuffer = '\0'; -#endif /* !defined(WIN32) */ - int chars; - char *b; - - if(!buf) { return -1; } - -#ifdef WIN32 - chars = _vscprintf(fmt, ap)+1; -#else /* !defined(WIN32) */ - /* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite - our buffer like on some 64bit sun systems.... but hey, its time to move on */ - chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap)+1; - if(chars < 0) { chars *= -1; } /* CAW: old glibc versions have this problem */ -#endif /* defined(WIN32) */ - - b = (char*)malloc(sizeof(char)*chars); - if(!b) { return -1; } - - if((chars = vsprintf(b, fmt, ap)) < 0) - { - free(b); - } else { - *buf = b; - } - - return chars; -} -#endif /* !HAVE_VASPRINTF */ - -int sprintbuf(struct printbuf *p, const char *msg, ...) -{ - va_list ap; - char *t; - int size; - char buf[128]; - - /* user stack buffer first */ - va_start(ap, msg); - size = vsnprintf(buf, 128, msg, ap); - va_end(ap); - /* if string is greater than stack buffer, then use dynamic string - with vasprintf. Note: some implementation of vsnprintf return -1 - if output is truncated whereas some return the number of bytes that - would have been writen - this code handles both cases. */ - if(size == -1 || size > 127) { - int ret; - va_start(ap, msg); - if((size = vasprintf(&t, msg, ap)) == -1) return -1; - va_end(ap); - ret = printbuf_memappend(p, t, size); - free(t); - return ret; - } else { - return printbuf_memappend(p, buf, size); - } -} - -void printbuf_reset(struct printbuf *p) -{ - p->buf[0] = '\0'; - p->bpos = 0; -} - -void printbuf_free(struct printbuf *p) -{ - if(p) { - free(p->buf); - free(p); - } -} diff --git a/source4/lib/json/printbuf.h b/source4/lib/json/printbuf.h deleted file mode 100644 index bc1669bd19..0000000000 --- a/source4/lib/json/printbuf.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ - * - * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. - * Michael Clark - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See COPYING for details. - * - */ - -#ifndef _printbuf_h_ -#define _printbuf_h_ - -#undef PRINTBUF_DEBUG - -struct printbuf { - char *buf; - int bpos; - int size; -}; - -extern struct printbuf* -printbuf_new(); - -extern int -printbuf_memappend(struct printbuf *p, char *buf, int size); - -extern int -sprintbuf(struct printbuf *p, const char *msg, ...); - -extern void -printbuf_reset(struct printbuf *p); - -extern void -printbuf_free(struct printbuf *p); - -#endif diff --git a/source4/lib/json/stamp-h.in b/source4/lib/json/stamp-h.in deleted file mode 100644 index 9788f70238..0000000000 --- a/source4/lib/json/stamp-h.in +++ /dev/null @@ -1 +0,0 @@ -timestamp diff --git a/source4/lib/json/test1.c b/source4/lib/json/test1.c deleted file mode 100644 index 8e49d100a3..0000000000 --- a/source4/lib/json/test1.c +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include -#include - -#include "json.h" - -int main(int argc, char **argv) -{ - struct json_object *my_string, *my_int, *my_object, *my_array; - struct json_object *new_obj; - int i; - - my_string = json_object_new_string("\t"); - printf("my_string=%s\n", json_object_get_string(my_string)); - printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string)); - json_object_put(my_string); - - my_string = json_object_new_string("foo"); - printf("my_string=%s\n", json_object_get_string(my_string)); - printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string)); - - my_int = json_object_new_int(9); - printf("my_int=%d\n", json_object_get_int(my_int)); - printf("my_int.to_string()=%s\n", json_object_to_json_string(my_int)); - - my_array = json_object_new_array(); - json_object_array_add(my_array, json_object_new_int(1)); - json_object_array_add(my_array, json_object_new_int(2)); - json_object_array_add(my_array, json_object_new_int(3)); - json_object_array_put_idx(my_array, 4, json_object_new_int(5)); - printf("my_array=\n"); - for(i=0; i < json_object_array_length(my_array); i++) { - struct json_object *obj = json_object_array_get_idx(my_array, i); - printf("\t[%d]=%s\n", i, json_object_to_json_string(obj)); - } - printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array)); - - my_object = json_object_new_object(); - json_object_object_add(my_object, "abc", json_object_new_int(12)); - json_object_object_add(my_object, "foo", json_object_new_string("bar")); - json_object_object_add(my_object, "bool0", json_object_new_boolean(0)); - json_object_object_add(my_object, "bool1", json_object_new_boolean(1)); - json_object_object_add(my_object, "baz", json_object_new_string("bang")); - json_object_object_add(my_object, "baz", json_object_new_string("fark")); - json_object_object_del(my_object, "baz"); - json_object_object_add(my_object, "arr", my_array); - printf("my_object=\n"); - json_object_object_foreach(my_object, key, val) { - printf("\t%s: %s\n", key, json_object_to_json_string(val)); - } - printf("my_object.to_string()=%s\n", json_object_to_json_string(my_object)); - - new_obj = json_tokener_parse("\"\003\""); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("/* hello */\"foo\""); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("// hello\n\"foo\""); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("\"\\u0041\\u0042\\u0043\""); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("null"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("True"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("12"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("12.3"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("[\"\\n\"]"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("[\"\\nabc\\n\"]"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("[null]"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("[]"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("[\"abc\",null,\"def\",12]"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("{}"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("{ \"foo\": \"bar\" }"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("{ \"foo\": \"bar\", \"baz\": null, \"bool0\": true }"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("{ \"foo\": [null, \"foo\"] }"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("{ \"abc\": 12, \"foo\": \"bar\", \"bool0\": false, \"bool1\": true, \"arr\": [ 1, 2, 3, null, 5 ] }"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - new_obj = json_tokener_parse("{ foo }"); - if(is_error(new_obj)) printf("got error as expected\n"); - - new_obj = json_tokener_parse("foo"); - if(is_error(new_obj)) printf("got error as expected\n"); - - json_object_put(my_string); - json_object_put(my_int); - json_object_put(my_object); - //json_object_put(my_array); - - return 0; -} diff --git a/source4/lib/json/test2.c b/source4/lib/json/test2.c deleted file mode 100644 index b7bdf62888..0000000000 --- a/source4/lib/json/test2.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -#include "json.h" - - -int main(int argc, char **argv) -{ - struct json_object *new_obj; - - mc_set_debug(1); - - new_obj = json_tokener_parse("/* more difficult test case */ { \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": \"A meta-markup language, used to create markup languages such as DocBook.\", \"GlossSeeAlso\": [\"GML\", \"XML\", \"markup\"] } ] } } }"); - printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); - json_object_put(new_obj); - - return 0; -} diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index ecb6b6516b..8d95dae7ea 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -11,9 +11,11 @@ includedir = @includedir@ libdir = @libdir@ bindir = @bindir@ mandir = @mandir@ -VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@:@eventsdir@ +VPATH = @srcdir@:@libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ +sharedbuilddir = @sharedbuilddir@ +INSTALLCMD = @INSTALL@ SLAPD = @SLAPD@ SWIG = swig EXTRA_OBJ=@EXTRA_OBJ@ @@ -21,9 +23,7 @@ TESTS=test-tdb.sh @TESTS@ PACKAGE_VERSION = @PACKAGE_VERSION@ PYTHON = @PYTHON@ PYTHON_CONFIG = @PYTHON_CONFIG@ -tdbdir = @tdbdir@ ldbdir = $(srcdir) -tallocdir = @tallocdir@ TALLOC_LIBS = @TALLOC_LIBS@ TALLOC_CFLAGS = @TALLOC_CFLAGS@ @@ -33,6 +33,7 @@ TDB_LIBS = @TDB_LIBS@ TDB_CFLAGS = @TDB_CFLAGS@ TDB_OBJ = @TDB_OBJ@ +EVENTS_LIBS = @EVENTS_LIBS@ EVENTS_CFLAGS = @EVENTS_CFLAGS@ EVENTS_OBJ = @EVENTS_OBJ@ @@ -65,7 +66,7 @@ OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(EVENTS_OBJ) $(TA headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h -BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest bin/oLschema2ldif +BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest EXAMPLES = examples/ldbreader examples/ldifreader @@ -81,24 +82,37 @@ nssdir: @mkdir -p $(NSSDIR) SONAME = libldb.$(SHLIBEXT).0 -SOLIB = lib/libldb.$(SHLIBEXT).$(PACKAGE_VERSION) +SOLIB = libldb.$(SHLIBEXT).$(PACKAGE_VERSION) +LIBSOLIB = lib/$(SOLIB) STATICLIB = lib/libldb.a -lib/$(SONAME): $(SOLIB) +lib/$(SONAME): $(LIBSOLIB) ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@ -lib/libldb.$(SHLIBEXT): $(SOLIB) +lib/libldb.$(SHLIBEXT): $(LIBSOLIB) ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@ -lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(SOLIB) - $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(SOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2 +lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(LIBSOLIB) + $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(LIBSOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2 -$(SOLIB): $(OBJS) - $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME) +$(LIBSOLIB): $(OBJS) + $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(EVENTS_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME) + ln -sf libldb.$(SHLIBEXT).$(PACKAGE_VERSION) lib/libldb.$(SHLIBEXT) -all: showflags dirs $(OBJS) $(STATICLIB) $(SOLIB) $(BINS) $(EXAMPLES) manpages \ +all: showflags dirs $(OBJS) $(STATICLIB) $(LIBSOLIB) $(BINS) $(EXAMPLES) manpages \ @PYTHON_BUILD_TARGET@ +shared-build: all + ${INSTALLCMD} -d $(sharedbuilddir)/lib + ${INSTALLCMD} -m 644 $(STATICLIB) $(sharedbuilddir)/lib + ${INSTALLCMD} -m 755 $(LIBSOLIB) $(sharedbuilddir)/lib + ln -sf $(SOLIB) $(sharedbuilddir)/lib/$(SONAME) + ln -sf $(SOLIB) $(sharedbuilddir)/lib/libldb.so + ${INSTALLCMD} -d $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 $(srcdir)/include/ldb.h $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 $(srcdir)/include/ldb_errors.h $(sharedbuilddir)/include + ${INSTALLCMD} -m 644 $(srcdir)/include/ldb_handlers.h $(sharedbuilddir)/include + dirs: @mkdir -p $(DIRS) @@ -110,7 +124,7 @@ doxygen:: clean:: rm -f *.o */*.o *.gcov */*.gc?? tdbtest.ldb* - rm -f $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(STATICLIB) $(NSS_LIB) $(SOLIB) + rm -f $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(STATICLIB) $(NSS_LIB) $(LIBSOLIB) rm -f $(POPT_OBJ) rm -f man/*.1 man/*.3 man/*.html rm -f $(EXAMPLES) @@ -149,7 +163,7 @@ installheaders:: installdirs cp $(headers) $(DESTDIR)$(includedir) installlibs:: installdirs - cp $(STATICLIB) $(SOLIB) $(DESTDIR)$(libdir) + cp $(STATICLIB) $(LIBSOLIB) $(DESTDIR)$(libdir) cp ldb.pc $(DESTDIR)$(libdir)/pkgconfig installbin:: installdirs diff --git a/source4/lib/ldb/autogen.sh b/source4/lib/ldb/autogen.sh index b81e5b094e..52fc8b63e2 100755 --- a/source4/lib/ldb/autogen.sh +++ b/source4/lib/ldb/autogen.sh @@ -3,14 +3,7 @@ rm -rf autom4te.cache rm -f configure config.h.in -IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace" -IPATHS="$IPATHS -I lib/events -I events -I ../events" -IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc" -IPATHS="$IPATHS -I lib/tdb -I tdb -I ../tdb" -IPATHS="$IPATHS -I lib/popt -I popt -I ../popt" - -# Always keep this listed last, so the built-in versions of tdb and talloc -# get used if available. +IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace" IPATHS="$IPATHS -I ./external" autoheader $IPATHS || exit 1 diff --git a/source4/lib/ldb/build_macros.m4 b/source4/lib/ldb/build_macros.m4 new file mode 100644 index 0000000000..c036668cd1 --- /dev/null +++ b/source4/lib/ldb/build_macros.m4 @@ -0,0 +1,14 @@ +AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, + [ AC_ARG_WITH([shared-build-dir], + [AC_HELP_STRING([--with-shared-build-dir=DIR], + [temporary build directory where libraries are installed [$srcdir/sharedbuild]])]) + + sharedbuilddir="$srcdir/sharedbuild" + if test x"$with_shared_build_dir" != x; then + sharedbuilddir=$with_shared_build_dir + CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" + fi + AC_SUBST(sharedbuilddir) + ]) + diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 9e04cc7845..c013565da0 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -88,15 +88,14 @@ void ldb_set_default_dns(struct ldb_context *ldb) }; tmp_ctx = talloc_new(ldb); - ret = ldb_search(ldb, ldb_dn_new(tmp_ctx, ldb, NULL), LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &res); + ret = ldb_search(ldb, tmp_ctx, &res, ldb_dn_new(tmp_ctx, ldb, NULL), + LDB_SCOPE_BASE, attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { talloc_free(tmp_ctx); return; } if (res->count != 1) { - talloc_free(res); talloc_free(tmp_ctx); return; } @@ -125,7 +124,6 @@ void ldb_set_default_dns(struct ldb_context *ldb) ldb_set_opaque(ldb, "defaultNamingContext", tmp_dn); } - talloc_free(res); talloc_free(tmp_ctx); } @@ -195,9 +193,6 @@ int ldb_connect(struct ldb_context *ldb, const char *url, return LDB_ERR_OTHER; } - /* TODO: get timeout from options if available there */ - ldb->default_timeout = 300; /* set default to 5 minutes */ - /* set the default base dn */ ldb_set_default_dns(ldb); @@ -398,24 +393,44 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type) { - int ret; + struct event_context *ev; + if (!handle) { - return LDB_SUCCESS; + return LDB_ERR_UNAVAILABLE; } - ret = handle->module->ops->wait(handle, type); - if (!ldb_errstring(handle->module->ldb)) { - /* Set a default error string, to place the blame somewhere */ - ldb_asprintf_errstring(handle->module->ldb, - "error waiting on module %s: %s (%d)", - handle->module->ops->name, - ldb_strerror(ret), ret); + if (handle->state == LDB_ASYNC_DONE) { + return handle->status; } - return ret; + + ev = ldb_get_event_context(handle->ldb); + if (NULL == ev) { + return LDB_ERR_OPERATIONS_ERROR; + } + + switch (type) { + case LDB_WAIT_NONE: + event_loop_once(ev); + if (handle->state == LDB_ASYNC_DONE || + handle->status != LDB_SUCCESS) { + return handle->status; + } + break; + + case LDB_WAIT_ALL: + while (handle->state != LDB_ASYNC_DONE) { + event_loop_once(ev); + if (handle->status != LDB_SUCCESS) { + return handle->status; + } + } + return handle->status; + } + + return LDB_SUCCESS; } /* set the specified timeout or, if timeout is 0 set the default timeout */ -/* timeout == -1 means no timeout */ int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout) @@ -437,20 +452,14 @@ int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq) { - time_t now; - if (newreq == NULL) return LDB_ERR_OPERATIONS_ERROR; - now = time(NULL); - - if (oldreq == NULL) + if (oldreq == NULL) { return ldb_set_timeout(ldb, newreq, 0); - - if ((now - oldreq->starttime) > oldreq->timeout) { - return LDB_ERR_TIME_LIMIT_EXCEEDED; } + newreq->starttime = oldreq->starttime; - newreq->timeout = oldreq->timeout - (now - oldreq->starttime); + newreq->timeout = oldreq->timeout; return LDB_SUCCESS; } @@ -485,6 +494,11 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req) struct ldb_module *module; int ret; + if (req->callback == NULL) { + ldb_set_errstring(ldb, "Requests MUST define callbacks"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } + ldb_reset_err_string(ldb); /* call the first module in the chain */ @@ -513,10 +527,6 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req) FIRST_OP(ldb, extended); ret = module->ops->extended(module, req); break; - case LDB_SEQUENCE_NUMBER: - FIRST_OP(ldb, sequence_number); - ret = module->ops->sequence_number(module, req); - break; default: FIRST_OP(ldb, request); ret = module->ops->request(module, req); @@ -526,6 +536,13 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req) return ret; } +int ldb_request_done(struct ldb_request *req, int status) +{ + req->handle->state = LDB_ASYNC_DONE; + req->handle->status = status; + return status; +} + /* search the database given a LDAP-like search expression @@ -534,32 +551,27 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req) Use talloc_free to free the ldb_message returned in 'res', if successful */ -int ldb_search_default_callback(struct ldb_context *ldb, - void *context, +int ldb_search_default_callback(struct ldb_request *req, struct ldb_reply *ares) { struct ldb_result *res; int n; - if (!context) { - ldb_set_errstring(ldb, "NULL Context in callback"); - return LDB_ERR_OPERATIONS_ERROR; - } - - res = talloc_get_type(context, struct ldb_result); + res = talloc_get_type(req->context, struct ldb_result); - if (!res || !ares) { - ldb_set_errstring(ldb, "NULL res or ares in callback"); - goto error; + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_request_done(req, ares->error); } switch (ares->type) { case LDB_REPLY_ENTRY: res->msgs = talloc_realloc(res, res->msgs, - struct ldb_message *, - res->count + 2); + struct ldb_message *, res->count + 2); if (! res->msgs) { - goto error; + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } res->msgs[res->count + 1] = NULL; @@ -567,6 +579,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, res->msgs[res->count] = talloc_move(res->msgs, &ares->message); res->count++; break; + case LDB_REPLY_REFERRAL: if (res->refs) { for (n = 0; res->refs[n]; n++) /*noop*/ ; @@ -576,37 +589,63 @@ int ldb_search_default_callback(struct ldb_context *ldb, res->refs = talloc_realloc(res, res->refs, char *, n + 2); if (! res->refs) { - goto error; + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } res->refs[n] = talloc_move(res->refs, &ares->referral); res->refs[n + 1] = NULL; break; - case LDB_REPLY_EXTENDED: + case LDB_REPLY_DONE: /* TODO: we should really support controls on entries * and referrals too! */ res->controls = talloc_move(res, &ares->controls); - break; + + /* this is the last message, and means the request is done */ + /* we have to signal and eventual ldb_wait() waiting that the + * async request operation was completed */ + return ldb_request_done(req, LDB_SUCCESS); } + talloc_free(ares); return LDB_SUCCESS; +} + +int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + int ret; + + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + + if (ares->error != LDB_SUCCESS) { + ret = ares->error; + talloc_free(ares); + return ldb_request_done(req, ret); + } + + if (ares->type != LDB_REPLY_DONE) { + talloc_free(ares); + ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } -error: talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_request_done(req, LDB_SUCCESS); } -int ldb_build_search_req(struct ldb_request **ret_req, +int ldb_build_search_req_ex(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, struct ldb_dn *base, enum ldb_scope scope, - const char *expression, + struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_control **controls, void *context, - ldb_request_callback_t callback) + ldb_request_callback_t callback, + struct ldb_request *parent) { struct ldb_request *req; @@ -614,7 +653,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, req = talloc(mem_ctx, struct ldb_request); if (req == NULL) { - ldb_set_errstring(ldb, "Out of Memory"); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -626,9 +665,9 @@ int ldb_build_search_req(struct ldb_request **ret_req, } req->op.search.scope = scope; - req->op.search.tree = ldb_parse_tree(req, expression); + req->op.search.tree = tree; if (req->op.search.tree == NULL) { - ldb_set_errstring(ldb, "Unable to parse search expression"); + ldb_set_errstring(ldb, "'tree' can't be NULL"); talloc_free(req); return LDB_ERR_OPERATIONS_ERROR; } @@ -638,17 +677,56 @@ int ldb_build_search_req(struct ldb_request **ret_req, req->context = context; req->callback = callback; + ldb_set_timeout_from_prev_req(ldb, parent, req); + + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + *ret_req = req; return LDB_SUCCESS; } +int ldb_build_search_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + struct ldb_dn *base, + enum ldb_scope scope, + const char *expression, + const char * const *attrs, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback, + struct ldb_request *parent) +{ + struct ldb_parse_tree *tree; + int ret; + + tree = ldb_parse_tree(mem_ctx, expression); + if (tree == NULL) { + ldb_set_errstring(ldb, "Unable to parse search expression"); + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_build_search_req_ex(ret_req, ldb, mem_ctx, base, + scope, tree, attrs, controls, + context, callback, parent); + if (ret == LDB_SUCCESS) { + talloc_steal(*ret_req, tree); + } + return ret; +} + int ldb_build_add_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, - ldb_request_callback_t callback) + ldb_request_callback_t callback, + struct ldb_request *parent) { struct ldb_request *req; @@ -666,6 +744,14 @@ int ldb_build_add_req(struct ldb_request **ret_req, req->context = context; req->callback = callback; + ldb_set_timeout_from_prev_req(ldb, parent, req); + + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + *ret_req = req; return LDB_SUCCESS; @@ -677,7 +763,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req, const struct ldb_message *message, struct ldb_control **controls, void *context, - ldb_request_callback_t callback) + ldb_request_callback_t callback, + struct ldb_request *parent) { struct ldb_request *req; @@ -695,6 +782,14 @@ int ldb_build_mod_req(struct ldb_request **ret_req, req->context = context; req->callback = callback; + ldb_set_timeout_from_prev_req(ldb, parent, req); + + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + *ret_req = req; return LDB_SUCCESS; @@ -706,7 +801,8 @@ int ldb_build_del_req(struct ldb_request **ret_req, struct ldb_dn *dn, struct ldb_control **controls, void *context, - ldb_request_callback_t callback) + ldb_request_callback_t callback, + struct ldb_request *parent) { struct ldb_request *req; @@ -724,6 +820,14 @@ int ldb_build_del_req(struct ldb_request **ret_req, req->context = context; req->callback = callback; + ldb_set_timeout_from_prev_req(ldb, parent, req); + + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + *ret_req = req; return LDB_SUCCESS; @@ -736,7 +840,8 @@ int ldb_build_rename_req(struct ldb_request **ret_req, struct ldb_dn *newdn, struct ldb_control **controls, void *context, - ldb_request_callback_t callback) + ldb_request_callback_t callback, + struct ldb_request *parent) { struct ldb_request *req; @@ -755,47 +860,46 @@ int ldb_build_rename_req(struct ldb_request **ret_req, req->context = context; req->callback = callback; + ldb_set_timeout_from_prev_req(ldb, parent, req); + + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + *ret_req = req; return LDB_SUCCESS; } -int ldb_extended_default_callback(struct ldb_context *ldb, - void *context, +int ldb_extended_default_callback(struct ldb_request *req, struct ldb_reply *ares) { struct ldb_result *res; - if (!context) { - ldb_set_errstring(ldb, "NULL Context in callback"); - return LDB_ERR_OPERATIONS_ERROR; - } + res = talloc_get_type(req->context, struct ldb_result); - res = talloc_get_type(context, struct ldb_result); - if (!res || !ares) { - ldb_set_errstring(ldb, "NULL res or ares in callback"); - goto error; + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_request_done(req, ares->error); } - switch (ares->type) { - case LDB_REPLY_ENTRY: - case LDB_REPLY_REFERRAL: - case LDB_REPLY_DONE: - ldb_set_errstring(ldb, "invalid ares type in callback"); - goto error; - case LDB_REPLY_EXTENDED: - /* TODO: we should really support controls on entries and - * referrals too! */ + if (ares->type == LDB_REPLY_DONE) { + + /* TODO: we should really support controls on entries and referrals too! */ res->extended = talloc_move(res, &ares->response); res->controls = talloc_move(res, &ares->controls); - break; + + talloc_free(ares); + return ldb_request_done(req, LDB_SUCCESS); } - talloc_free(ares); - return LDB_SUCCESS; -error: talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } int ldb_build_extended_req(struct ldb_request **ret_req, @@ -805,7 +909,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req, void *data, struct ldb_control **controls, void *context, - ldb_request_callback_t callback) + ldb_request_callback_t callback, + struct ldb_request *parent) { struct ldb_request *req; @@ -824,6 +929,14 @@ int ldb_build_extended_req(struct ldb_request **ret_req, req->context = context; req->callback = callback; + ldb_set_timeout_from_prev_req(ldb, parent, req); + + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + *ret_req = req; return LDB_SUCCESS; @@ -847,7 +960,8 @@ int ldb_extended(struct ldb_context *ldb, ret = ldb_build_extended_req(&req, ldb, ldb, oid, data, NULL, - res, ldb_extended_default_callback); + res, ldb_extended_default_callback, + NULL); if (ret != LDB_SUCCESS) goto done; ldb_set_timeout(ldb, req, 0); /* use default timeout */ @@ -873,95 +987,71 @@ done: note that ldb_search() will automatically replace a NULL 'base' value with the defaultNamingContext from the rootDSE if available. */ -int ldb_search(struct ldb_context *ldb, - struct ldb_dn *base, - enum ldb_scope scope, - const char *expression, - const char * const *attrs, - struct ldb_result **_res) +int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, + struct ldb_result **result, struct ldb_dn *base, + enum ldb_scope scope, const char * const *attrs, + const char *exp_fmt, ...) { struct ldb_request *req; - int ret; struct ldb_result *res; + char *expression; + va_list ap; + int ret; - *_res = NULL; + expression = NULL; + *result = NULL; + req = NULL; - res = talloc_zero(ldb, struct ldb_result); + res = talloc_zero(mem_ctx, struct ldb_result); if (!res) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ldb, ldb, + if (exp_fmt) { + va_start(ap, exp_fmt); + expression = talloc_vasprintf(mem_ctx, exp_fmt, ap); + va_end(ap); + + if (!expression) { + talloc_free(res); + return LDB_ERR_OPERATIONS_ERROR; + } + } + + ret = ldb_build_search_req(&req, ldb, mem_ctx, base?base:ldb_get_default_basedn(ldb), scope, expression, attrs, NULL, res, - ldb_search_default_callback); + ldb_search_default_callback, + NULL); if (ret != LDB_SUCCESS) goto done; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - ret = ldb_request(ldb, req); if (ret == LDB_SUCCESS) { ret = ldb_wait(req->handle, LDB_WAIT_ALL); } - talloc_free(req); - done: if (ret != LDB_SUCCESS) { talloc_free(res); - } - - *_res = res; - return ret; -} - -/* - a useful search function where you can easily define the expression and that - takes a memory context where results are allocated -*/ - -int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, - struct ldb_result **result, struct ldb_dn *base, - enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...) -{ - struct ldb_result *res; - char *expression; - va_list ap; - int ret; - - res = NULL; - *result = NULL; - - va_start(ap, exp_fmt); - expression = talloc_vasprintf(mem_ctx, exp_fmt, ap); - va_end(ap); - - if ( ! expression) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ret = ldb_search(ldb, base, scope, expression, attrs, &res); - - if (ret == LDB_SUCCESS) { - talloc_steal(mem_ctx, res); - *result = res; + res = NULL; } talloc_free(expression); + talloc_free(req); + *result = res; return ret; } /* - add a record to the database. Will fail if a record with the - given class and key already exists + add a record to the database. Will fail if a record with the given class + and key already exists */ int ldb_add(struct ldb_context *ldb, const struct ldb_message *message) @@ -978,12 +1068,11 @@ int ldb_add(struct ldb_context *ldb, message, NULL, NULL, + ldb_op_default_callback, NULL); if (ret != LDB_SUCCESS) return ret; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - /* do request and autostart a transaction */ ret = ldb_autotransaction_request(ldb, req); @@ -1009,12 +1098,11 @@ int ldb_modify(struct ldb_context *ldb, message, NULL, NULL, + ldb_op_default_callback, NULL); if (ret != LDB_SUCCESS) return ret; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - /* do request and autostart a transaction */ ret = ldb_autotransaction_request(ldb, req); @@ -1035,12 +1123,11 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn) dn, NULL, NULL, + ldb_op_default_callback, NULL); if (ret != LDB_SUCCESS) return ret; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - /* do request and autostart a transaction */ ret = ldb_autotransaction_request(ldb, req); @@ -1062,12 +1149,11 @@ int ldb_rename(struct ldb_context *ldb, newdn, NULL, NULL, + ldb_op_default_callback, NULL); if (ret != LDB_SUCCESS) return ret; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - /* do request and autostart a transaction */ ret = ldb_autotransaction_request(ldb, req); @@ -1080,38 +1166,49 @@ int ldb_rename(struct ldb_context *ldb, return the global sequence number */ int ldb_sequence_number(struct ldb_context *ldb, - enum ldb_sequence_type type, - uint64_t *seq_num) + enum ldb_sequence_type type, uint64_t *seq_num) { - struct ldb_request *req; + struct ldb_seqnum_request *seq; + struct ldb_seqnum_result *seqr; + struct ldb_result *res; + TALLOC_CTX *tmp_ctx; int ret; - req = talloc(ldb, struct ldb_request); - if (req == NULL) { + *seq_num = 0; + + tmp_ctx = talloc_zero(ldb, struct ldb_request); + if (tmp_ctx == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } + seq = talloc_zero(tmp_ctx, struct ldb_seqnum_request); + if (seq == NULL) { + ldb_set_errstring(ldb, "Out of Memory"); + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + seq->type = type; - req->operation = LDB_SEQUENCE_NUMBER; - req->controls = NULL; - req->context = NULL; - req->callback = NULL; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - - req->op.seq_num.type = type; - /* do request and autostart a transaction */ - ret = ldb_request(ldb, req); + ret = ldb_extended(ldb, LDB_EXTENDED_SEQUENCE_NUMBER, seq, &res); + if (ret != LDB_SUCCESS) { + goto done; + } + talloc_steal(tmp_ctx, res); - if (ret == LDB_SUCCESS) { - *seq_num = req->op.seq_num.seq_num; + if (strcmp(LDB_EXTENDED_SEQUENCE_NUMBER, res->extended->oid) != 0) { + ldb_set_errstring(ldb, "Invalid OID in reply"); + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } + seqr = talloc_get_type(res->extended->data, + struct ldb_seqnum_result); + *seq_num = seqr->seq_num; - talloc_free(req); +done: + talloc_free(tmp_ctx); return ret; } - - /* return extended error information */ diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index c0d36cfbf3..e36aea4e69 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -91,7 +91,7 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, struct ldb_context *ldb, const * exploded_dn control is used */ dn->special = true; /* FIXME: add a GUID string to ldb_dn structure */ - } else if (strdn->length >= 8 && strncasecmp((const char *)strdn->data, "length >= 5 && strncasecmp((const char *)strdn->data, "special = true; @@ -150,7 +150,7 @@ struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char * exploded_dn control is used */ dn->special = true; /* FIXME: add a GUID string to ldb_dn structure */ - } else if (strncasecmp(strdn, "callback == NULL) { + ldb_set_errstring(module->ldb, "Requests MUST define callbacks"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } + switch (request->operation) { case LDB_SEARCH: FIND_OP(module, search); @@ -511,10 +517,6 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request) FIND_OP(module, extended); ret = module->ops->extended(module, request); break; - case LDB_SEQUENCE_NUMBER: - FIND_OP(module, sequence_number); - ret = module->ops->sequence_number(module, request); - break; default: FIND_OP(module, request); ret = module->ops->request(module, request); @@ -555,6 +557,139 @@ int ldb_next_del_trans(struct ldb_module *module) return module->ops->del_transaction(module); } +struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb) +{ + struct ldb_handle *h; + + h = talloc_zero(mem_ctx, struct ldb_handle); + if (h == NULL) { + ldb_set_errstring(ldb, "Out of Memory"); + return NULL; + } + + h->status = LDB_SUCCESS; + h->state = LDB_ASYNC_INIT; + h->ldb = ldb; + + return h; +} + +/* calls the request callback to send an entry + * + * params: + * req: the original request passed to your module + * msg: reply message (must be a talloc pointer, and it will be stolen + * on the ldb_reply that is sent to the callback) + */ + +int ldb_module_send_entry(struct ldb_request *req, + struct ldb_message *msg) +{ + struct ldb_reply *ares; + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(req->handle->ldb); + req->callback(req, NULL); + return LDB_ERR_OPERATIONS_ERROR; + } + ares->type = LDB_REPLY_ENTRY; + ares->message = talloc_steal(ares, msg); + ares->error = LDB_SUCCESS; + + return req->callback(req, ares); +} + +/* calls the request callback to send an referrals + * + * params: + * req: the original request passed to your module + * ref: referral string (must be a talloc pointeri, steal) + */ + +int ldb_module_send_referral(struct ldb_request *req, + char *ref) +{ + struct ldb_reply *ares; + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(req->handle->ldb); + req->callback(req, NULL); + return LDB_ERR_OPERATIONS_ERROR; + } + ares->type = LDB_REPLY_REFERRAL; + ares->referral = talloc_steal(ares, ref); + ares->error = LDB_SUCCESS; + + return req->callback(req, ares); +} + +/* calls the original request callback + * + * params: + * req: the original request passed to your module + * ctrls: controls to send in the reply (must be a talloc pointer, steal) + * response: results for extended request (steal) + * error: LDB_SUCCESS for a succesful return + * any other ldb error otherwise + */ +int ldb_module_done(struct ldb_request *req, + struct ldb_control **ctrls, + struct ldb_extended *response, + int error) +{ + struct ldb_reply *ares; + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(req->handle->ldb); + req->callback(req, NULL); + return LDB_ERR_OPERATIONS_ERROR; + } + ares->type = LDB_REPLY_DONE; + ares->controls = talloc_steal(ares, ctrls); + ares->response = talloc_steal(ares, response); + ares->error = error; + + req->callback(req, ares); + return error; +} + +/* to be used *only* in modules init functions. + * this function i synchronous and will register + * the requested OID in the rootdse module if present + * otherwise it will return an error */ +int ldb_mod_register_control(struct ldb_module *module, const char *oid) +{ + struct ldb_request *req; + int ret; + + req = talloc_zero(module, struct ldb_request); + if (req == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + req->operation = LDB_REQ_REGISTER_CONTROL; + req->op.reg_control.oid = oid; + req->callback = ldb_op_default_callback; + + ldb_set_timeout(module->ldb, req, 0); + + req->handle = ldb_handle_new(req, module->ldb); + if (req->handle == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_request(module->ldb, req); + if (ret == LDB_SUCCESS) { + ret = ldb_wait(req->handle, LDB_WAIT_ALL); + } + talloc_free(req); + + return ret; +} + #ifndef STATIC_LIBLDB_MODULES #ifdef HAVE_LDB_LDAP diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac index 4a703e8139..095caa5e92 100644 --- a/source4/lib/ldb/configure.ac +++ b/source4/lib/ldb/configure.ac @@ -43,6 +43,10 @@ AC_SUBST(LDB_MODULESDIR) TESTS="" EXTRA_OBJ="" +m4_include(build_macros.m4) +BUILD_WITH_SHARED_BUILD_DIR + +m4_include(pkg.m4) m4_include(libpopt.m4) m4_include(libtalloc.m4) m4_include(libtdb.m4) diff --git a/source4/lib/ldb/examples/ldbreader.c b/source4/lib/ldb/examples/ldbreader.c index 6e58114531..e48b3d338a 100644 --- a/source4/lib/ldb/examples/ldbreader.c +++ b/source4/lib/ldb/examples/ldbreader.c @@ -88,8 +88,9 @@ int main(int argc, const char **argv) quite fine grained results with the LDAP search syntax, however it is a bit confusing to start with. See RFC2254. */ - if (LDB_SUCCESS != ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT, - expression, NULL, &resultMsg) ) { + if (LDB_SUCCESS != ldb_search(ldb, ldb, &resultMsg, + NULL, LDB_SCOPE_DEFAULT, NULL, + "%s", expression)) { printf("Problem in search\n"); exit(-1); } diff --git a/source4/lib/ldb/external/libevents.m4 b/source4/lib/ldb/external/libevents.m4 index f0f80e9d8e..4fd2e71ec2 100644 --- a/source4/lib/ldb/external/libevents.m4 +++ b/source4/lib/ldb/external/libevents.m4 @@ -1,4 +1,7 @@ -m4_include(pkg.m4) -EVENTS_OBJ="" AC_SUBST(EVENTS_OBJ) -PKG_CHECK_MODULES(EVENTS, events) +AC_SUBST(EVENTS_CFLAGS) +AC_SUBST(EVENTS_LIBS) + +AC_CHECK_HEADER(events.h, + [AC_CHECK_LIB(events, event_context_init, [EVENTS_LIBS="-levents"]) ], + [PKG_CHECK_MODULES(EVENTS, events)]) diff --git a/source4/lib/ldb/external/libtalloc.m4 b/source4/lib/ldb/external/libtalloc.m4 index d08bd42065..a4c5b8a9d9 100644 --- a/source4/lib/ldb/external/libtalloc.m4 +++ b/source4/lib/ldb/external/libtalloc.m4 @@ -1,4 +1,7 @@ -m4_include(pkg.m4) -TALLOC_OBJ="" AC_SUBST(TALLOC_OBJ) -PKG_CHECK_MODULES(TALLOC, talloc) +AC_SUBST(TALLOC_CFLAGS) +AC_SUBST(TALLOC_LIBS) + +AC_CHECK_HEADER(talloc.h, + [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ], + [PKG_CHECK_MODULES(TALLOC, talloc)]) diff --git a/source4/lib/ldb/external/libtdb.m4 b/source4/lib/ldb/external/libtdb.m4 index 4c1f4b530e..8c2cab702f 100644 --- a/source4/lib/ldb/external/libtdb.m4 +++ b/source4/lib/ldb/external/libtdb.m4 @@ -1,4 +1,7 @@ -m4_include(pkg.m4) -TDB_OBJ="" AC_SUBST(TDB_OBJ) -PKG_CHECK_MODULES(TDB, tdb >= 1.1.0) +AC_SUBST(TDB_CFLAGS) +AC_SUBST(TDB_LIBS) + +AC_CHECK_HEADER(tdb.h, + [AC_CHECK_LIB(tdb, tdb_open, [TDB_LIBS="-ltdb"]) ], + [PKG_CHECK_MODULES(TDB, tdb >= 1.1.0)]) diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 937029f52c..9bc5c183d8 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -181,6 +181,7 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1, LDB_SCOPE_SUBTREE=2}; struct ldb_context; +struct event_context; /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, @@ -651,7 +652,6 @@ enum ldb_request_type { LDB_DELETE, LDB_RENAME, LDB_EXTENDED, - LDB_SEQUENCE_NUMBER, LDB_REQ_REGISTER_CONTROL, LDB_REQ_REGISTER_PARTITION }; @@ -659,7 +659,6 @@ enum ldb_request_type { enum ldb_reply_type { LDB_REPLY_ENTRY, LDB_REPLY_REFERRAL, - LDB_REPLY_EXTENDED, LDB_REPLY_DONE }; @@ -679,28 +678,42 @@ struct ldb_extended { void *data; /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ }; +#define LDB_EXTENDED_SEQUENCE_NUMBER "1.3.6.1.4.1.7165.4.4.3" + +enum ldb_sequence_type { + LDB_SEQ_HIGHEST_SEQ, + LDB_SEQ_HIGHEST_TIMESTAMP, + LDB_SEQ_NEXT +}; + +struct ldb_seqnum_request { + enum ldb_sequence_type type; +}; + +struct ldb_seqnum_result { + uint64_t seq_num; + uint32_t flags; +}; + struct ldb_result { unsigned int count; struct ldb_message **msgs; - char **refs; struct ldb_extended *extended; struct ldb_control **controls; + char **refs; }; struct ldb_reply { + int error; enum ldb_reply_type type; struct ldb_message *message; struct ldb_extended *response; - char *referral; struct ldb_control **controls; + char *referral; }; -struct ldb_handle { - int status; - enum ldb_state state; - void *private_data; - struct ldb_module *module; -}; +struct ldb_request; +struct ldb_handle; struct ldb_search { struct ldb_dn *base; @@ -735,19 +748,8 @@ struct ldb_register_partition { struct ldb_dn *dn; }; -enum ldb_sequence_type { - LDB_SEQ_HIGHEST_SEQ, - LDB_SEQ_HIGHEST_TIMESTAMP, - LDB_SEQ_NEXT -}; +typedef int (*ldb_request_callback_t)(struct ldb_request *, struct ldb_reply *); -struct ldb_sequence_number { - enum ldb_sequence_type type; - uint64_t seq_num; - uint32_t flags; -}; - -typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *); struct ldb_request { enum ldb_request_type operation; @@ -759,7 +761,6 @@ struct ldb_request { struct ldb_delete del; struct ldb_rename rename; struct ldb_extended extended; - struct ldb_sequence_number seq_num; struct ldb_register_control reg_control; struct ldb_register_partition reg_partition; } op; @@ -775,7 +776,10 @@ struct ldb_request { }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); +int ldb_request_done(struct ldb_request *req, int status); +bool ldb_request_is_done(struct ldb_request *req); +int ldb_modules_wait(struct ldb_handle *handle); int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); @@ -831,6 +835,19 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx); (that is, with LDB_FLG_RDONLY). However in read-write mode, the database will be created if it does not exist. */ + +typedef void (*ldb_async_timeout_fn) (void *); +typedef bool (*ldb_async_callback_fn) (void *); +typedef int (*ldb_async_ctx_add_op_fn)(void *, time_t, void *, ldb_async_timeout_fn, ldb_async_callback_fn); +typedef int (*ldb_async_ctx_wait_op_fn)(void *); + +void ldb_async_ctx_set_private_data(struct ldb_context *ldb, + void *private_data); +void ldb_async_ctx_set_add_op(struct ldb_context *ldb, + ldb_async_ctx_add_op_fn add_op); +void ldb_async_ctx_set_wait_op(struct ldb_context *ldb, + ldb_async_ctx_wait_op_fn wait_op); + int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); /* @@ -860,13 +877,12 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** The default async search callback function - \param ldb the context associated with the database (from ldb_init()) - \param context the callback context (struct ldb_result *) + \param req the request we are callback of \param ares a single reply from the async core \return result code (LDB_SUCCESS on success, or a failure code) - \note this function expects the context to always be an struct ldb_result pointer + \note this function expects req->context to always be an struct ldb_result pointer AND a talloc context, this function will steal on the context each message from the ares reply passed on by the async core so that in the end all the messages will be in the context (ldb_result) memory tree. @@ -875,7 +891,18 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); request that can be freed as sson as the search request is finished) */ -int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); +int ldb_search_default_callback(struct ldb_request *req, struct ldb_reply *ares); + +/** + The default async extended operation callback function + + \param req the request we are callback of + \param ares a single reply from the async core + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ +int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares); + /** Helper function to build a search request @@ -889,7 +916,8 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l \param attrs the search attributes for the query (pass NULL if none required) \param controls an array of controls \param context the callback function context - \param callback the callback function to handle the async replies + \param the callback function to handle the async replies + \param the parent request if any \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -903,7 +931,20 @@ int ldb_build_search_req(struct ldb_request **ret_req, const char * const *attrs, struct ldb_control **controls, void *context, - ldb_request_callback_t callback); + ldb_request_callback_t callback, + struct ldb_request *parent); + +int ldb_build_search_req_ex(struct ldb_request **ret_req, + struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_dn *base, + enum ldb_scope scope, + struct ldb_parse_tree *tree, + const char * const *attrs, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback, + struct ldb_request *parent); /** Helper function to build an add request @@ -914,7 +955,8 @@ int ldb_build_search_req(struct ldb_request **ret_req, \param message contains the entry to be added \param controls an array of controls \param context the callback function context - \param callback the callback function to handle the async replies + \param the callback function to handle the async replies + \param the parent request if any \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -925,7 +967,8 @@ int ldb_build_add_req(struct ldb_request **ret_req, const struct ldb_message *message, struct ldb_control **controls, void *context, - ldb_request_callback_t callback); + ldb_request_callback_t callback, + struct ldb_request *parent); /** Helper function to build a modify request @@ -936,7 +979,8 @@ int ldb_build_add_req(struct ldb_request **ret_req, \param message contains the entry to be modified \param controls an array of controls \param context the callback function context - \param callback the callback function to handle the async replies + \param the callback function to handle the async replies + \param the parent request if any \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -947,7 +991,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req, const struct ldb_message *message, struct ldb_control **controls, void *context, - ldb_request_callback_t callback); + ldb_request_callback_t callback, + struct ldb_request *parent); /** Helper function to build a delete request @@ -958,7 +1003,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req, \param dn the DN to be deleted \param controls an array of controls \param context the callback function context - \param callback the callback function to handle the async replies + \param the callback function to handle the async replies + \param the parent request if any \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -969,7 +1015,8 @@ int ldb_build_del_req(struct ldb_request **ret_req, struct ldb_dn *dn, struct ldb_control **controls, void *context, - ldb_request_callback_t callback); + ldb_request_callback_t callback, + struct ldb_request *parent); /** Helper function to build a rename request @@ -981,7 +1028,8 @@ int ldb_build_del_req(struct ldb_request **ret_req, \param newdn the new DN \param controls an array of controls \param context the callback function context - \param callback the callback function to handle the async replies + \param the callback function to handle the async replies + \param the parent request if any \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -993,7 +1041,8 @@ int ldb_build_rename_req(struct ldb_request **ret_req, struct ldb_dn *newdn, struct ldb_control **controls, void *context, - ldb_request_callback_t callback); + ldb_request_callback_t callback, + struct ldb_request *parent); /** Add a ldb_control to a ldb_request @@ -1023,31 +1072,21 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char records that match an LDAP-like search expression \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx the memory context to use for the request and the results + \param result the return result \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) \param scope the search scope for the query - \param expression the search expression to use for this query \param attrs the search attributes for the query (pass NULL if none required) - \param res the return result + \param exp_fmt the search expression to use for this query (printf like) \return result code (LDB_SUCCESS on success, or a failure code) \note use talloc_free() to free the ldb_result returned */ -int ldb_search(struct ldb_context *ldb, - struct ldb_dn *base, - enum ldb_scope scope, - const char *expression, - const char * const *attrs, struct ldb_result **res); - -/* - * a useful search function where you can easily define the expression and - * that takes a memory context where results are allocated -*/ - -int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, - struct ldb_result **result, struct ldb_dn *base, - enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8); +int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, + struct ldb_result **result, struct ldb_dn *base, + enum ldb_scope scope, const char * const *attrs, + const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8); /** Add a record to the database. @@ -1113,13 +1152,12 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn); /** The default async extended operation callback function - \param ldb the context associated with the database (from ldb_init()) - \param context the callback context (struct ldb_result *) + \param req the request we are callback of \param ares a single reply from the async core \return result code (LDB_SUCCESS on success, or a failure code) - \note this function expects the context to always be an struct ldb_result pointer + \note this function expects req->context to always be an struct ldb_result pointer AND a talloc context, this function will steal on the context each message from the ares reply passed on by the async core so that in the end all the messages will be in the context (ldb_result) memory tree. @@ -1127,7 +1165,9 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn); (the request need to be freed separately and the result doe not depend on the request that can be freed as sson as the search request is finished) */ -int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); + +int ldb_extended_default_callback(struct ldb_request *req, struct ldb_reply *ares); + /** Helper function to build a extended request @@ -1140,7 +1180,8 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param controls an array of controls \param context the callback function context - \param callback the callback function to handle the async replies + \param the callback function to handle the async replies + \param the parent request if any \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -1151,7 +1192,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req, void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_control **controls, void *context, - ldb_request_callback_t callback); + ldb_request_callback_t callback, + struct ldb_request *parent); /** call an extended operation diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e1026ab781..8f7e010bee 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -43,6 +43,12 @@ struct ldb_module_ops; struct ldb_backend_ops; +struct ldb_handle { + int status; + enum ldb_state state; + struct ldb_context *ldb; +}; + /* basic module structure */ struct ldb_module { struct ldb_module *prev, *next; @@ -51,9 +57,8 @@ struct ldb_module { const struct ldb_module_ops *ops; }; -/* - these function pointers define the operations that a ldb module must perform - they correspond exactly to the ldb_*() interface +/* + these function pointers define the operations that a ldb module can intercept */ struct ldb_module_ops { const char *name; @@ -68,22 +73,10 @@ struct ldb_module_ops { int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); - int (*wait)(struct ldb_handle *, enum ldb_wait_type); int (*sequence_number)(struct ldb_module *, struct ldb_request *); + void *private_data; }; - -typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], - struct ldb_module **module); - - -struct ldb_backend_ops { - const char *name; - ldb_connect_fn connect_fn; -}; - -const char *ldb_default_modules_dir(void); - /* schema related information needed for matching rules */ @@ -145,27 +138,6 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op struct ldb_module **backend_module); void ldb_set_default_dns(struct ldb_context *ldb); -/* The following definitions come from lib/ldb/common/ldb_modules.c */ - -const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string); -int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out); -int ldb_load_modules(struct ldb_context *ldb, const char *options[]); -int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module); -int ldb_next_request(struct ldb_module *module, struct ldb_request *request); -int ldb_next_start_trans(struct ldb_module *module); -int ldb_next_end_trans(struct ldb_module *module); -int ldb_next_del_trans(struct ldb_module *module); -int ldb_next_init(struct ldb_module *module); - -void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); -void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); -void ldb_reset_err_string(struct ldb_context *ldb); - -int ldb_register_module(const struct ldb_module_ops *); -int ldb_register_backend(const char *url_prefix, ldb_connect_fn); -void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, - const char *symbol); - /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, @@ -239,6 +211,10 @@ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); +int ldb_msg_element_compare_name(struct ldb_message_element *el1, + struct ldb_message_element *el2); +void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f); + /** Obtain current/next database sequence number */ @@ -248,4 +224,60 @@ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, ui #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 +/* MODULES specific headers -- SSS */ + +/* The following definitions come from lib/ldb/common/ldb_modules.c */ + +const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string); +int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out); +int ldb_load_modules(struct ldb_context *ldb, const char *options[]); +int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module); +int ldb_next_request(struct ldb_module *module, struct ldb_request *request); +int ldb_next_start_trans(struct ldb_module *module); +int ldb_next_end_trans(struct ldb_module *module); +int ldb_next_del_trans(struct ldb_module *module); +int ldb_next_init(struct ldb_module *module); + +void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); +void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); +void ldb_reset_err_string(struct ldb_context *ldb); + +const char *ldb_default_modules_dir(void); + +int ldb_register_module(const struct ldb_module_ops *); + +typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url, + unsigned int flags, const char *options[], + struct ldb_module **module); + +struct ldb_backend_ops { + const char *name; + ldb_connect_fn connect_fn; +}; + +const char *ldb_default_modules_dir(void); + +int ldb_register_backend(const char *url_prefix, ldb_connect_fn); + +void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, + const char *symbol); + +struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); + +int ldb_module_send_entry(struct ldb_request *req, + struct ldb_message *msg); + +int ldb_module_send_referral(struct ldb_request *req, + char *ref); + +int ldb_module_done(struct ldb_request *req, + struct ldb_control **ctrls, + struct ldb_extended *response, + int error); + +int ldb_mod_register_control(struct ldb_module *module, const char *oid); + + +struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str); + #endif diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index 4b61ddba5b..6013462225 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -46,6 +46,7 @@ typedef struct ldb_context ldb; typedef struct ldb_dn ldb_dn; typedef struct ldb_ldif ldb_ldif; typedef struct ldb_message_element ldb_message_element; +typedef struct ldb_module ldb_module; typedef int ldb_error; typedef int ldb_int_error; @@ -152,17 +153,21 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx, * Wrap struct ldb_result */ -%typemap(in,noblock=1,numinputs=0) struct ldb_result **OUT (struct ldb_result *temp_ldb_result) { +%typemap(in,noblock=1,numinputs=0) struct ldb_result ** (struct ldb_result *temp_ldb_result) { $1 = &temp_ldb_result; } #ifdef SWIGPYTHON %typemap(argout,noblock=1) struct ldb_result ** (int i) { - $result = PyList_New((*$1)->count); - for (i = 0; i < (*$1)->count; i++) { - PyList_SetItem($result, i, - SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0) - ); + if ($1 == NULL) { + $result = Py_None; + } else { + $result = PyList_New((*$1)->count); + for (i = 0; i < (*$1)->count; i++) { + PyList_SetItem($result, i, + SWIG_NewPointerObj((*$1)->msgs[i], SWIGTYPE_p_ldb_message, 0) + ); + } } } @@ -189,7 +194,7 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx, #endif -%types(struct ldb_result *); +%types(struct ldb_result *, struct ldb_parse_tree *); /* * Wrap struct ldb_dn @@ -685,6 +690,20 @@ PyObject *PyExc_LdbError; /* Top-level ldb operations */ typedef struct ldb_context { + %rename(firstmodule) modules; + struct ldb_module *modules; + + %pythoncode { + def itermodules(self): + m = self.firstmodule + while m is not None: + yield m + m = m.next + + def modules(self): + return list(self.itermodules()) + } + %extend { ldb(void) { return ldb_init(NULL, event_context_init(NULL)); @@ -718,15 +737,14 @@ typedef struct ldb_context { attrs, controls, res, - ldb_search_default_callback); + ldb_search_default_callback, + NULL); if (ret != LDB_SUCCESS) { talloc_free(res); return ret; } - ldb_set_timeout($self, req, 0); /* use default timeout */ - ret = ldb_request($self, req); if (ret == LDB_SUCCESS) { @@ -826,8 +844,7 @@ typedef struct ldb_context { %typemap(freearg,noblock=1) struct ldb_result **result_as_bool { talloc_free(*$1); } ldb_error __contains__(ldb_dn *dn, struct ldb_result **result_as_bool) { - return ldb_search($self, dn, LDB_SCOPE_BASE, NULL, NULL, - result_as_bool); + return ldb_search($self, $self, result_as_bool, dn, LDB_SCOPE_BASE, NULL, NULL); } %feature("docstring") parse_ldif "S.parse_ldif(ldif) -> iter(messages)\n" \ @@ -915,10 +932,347 @@ static char *timestring(time_t t) "Parse a LDAP time string into a UNIX timestamp."; time_t ldb_string_to_time(const char *s); +typedef struct ldb_module { + struct ldb_module *prev, *next; + + %extend { +#ifdef SWIGPYTHON + const char *__str__() { + return $self->ops->name; + } + char *__repr__() { + char *ret; + asprintf(&ret, "", $self->ops->name); + return ret; + } +#endif + int search(struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const * attrs, struct ldb_result **res) { + int ret; + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + + req->operation = LDB_SEARCH; + req->op.search.base = base; + req->op.search.scope = scope; + req->op.search.tree = tree; + req->op.search.attrs = attrs; + + req->op.search.res = talloc_zero(NULL, struct ldb_result); + + ret = $self->ops->search($self, req); + + *res = req->op.search.res; + + talloc_free(req); + + return ret; + } + ldb_error add(struct ldb_message *message) { + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_ADD; + req->op.add.message = message; + + return $self->ops->add($self, &req); + } + ldb_error modify(struct ldb_message *message) { + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_MODIFY; + req->op.mod.message = message; + + return $self->ops->modify($self, &req); + } + ldb_error delete(struct ldb_dn *dn) { + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_DELETE; + req->op.del.dn = dn; + + return $self->ops->del($self, &req); + + } + ldb_error rename(struct ldb_dn *olddn, struct ldb_dn *newdn) { + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_RENAME; + req->op.rename.olddn = olddn; + req->op.rename.olddn = newdn; + + return $self->ops->rename($self, &req); + } + ldb_error start_transaction() { + return $self->ops->start_transaction($self); + } + ldb_error end_transaction() { + return $self->ops->end_transaction($self); + } + ldb_error del_transaction() { + return $self->ops->del_transaction($self); + } + } +} ldb_module; + +%{ +int py_module_search(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_base, *py_attrs, *py_tree; + + py_base = SWIG_NewPointerObj(req->op.search.base, SWIGTYPE_p_ldb_dn, 0); + + if (py_base == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_tree = SWIG_NewPointerObj(req->op.search.tree, SWIGTYPE_p_ldb_parse_tree, 0); + + if (py_tree == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + if (req->op.search.attrs == NULL) { + py_attrs = Py_None; + } else { + int i, len; + for (len = 0; req->op.search.attrs[len]; len++); + py_attrs = PyList_New(len); + for (i = 0; i < len; i++) + PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i])); + } + + py_result = PyObject_CallMethod(py_ldb, "search", "OiOO", py_base, req->op.search.scope, py_tree, py_attrs); + + Py_DECREF(py_attrs); + Py_DECREF(py_tree); + Py_DECREF(py_base); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (SWIG_ConvertPtr(py_result, &req->op.search.res, SWIGTYPE_p_ldb_result, 0) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_add(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.add.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "add", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_modify(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.mod.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "modify", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_dn; + + py_dn = SWIG_NewPointerObj(req->op.del.dn, SWIGTYPE_p_ldb_dn, 0); + + if (py_dn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "delete", "O", py_dn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_rename(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_olddn, *py_newdn; + + py_olddn = SWIG_NewPointerObj(req->op.rename.olddn, SWIGTYPE_p_ldb_dn, 0); + + if (py_olddn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_newdn = SWIG_NewPointerObj(req->op.rename.newdn, SWIGTYPE_p_ldb_dn, 0); + + if (py_newdn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "rename", "OO", py_olddn, py_newdn); + + Py_DECREF(py_olddn); + Py_DECREF(py_newdn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_request(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "request", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_extended(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "extended", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_start_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "start_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_end_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "end_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "del_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +static int py_module_destructor(void *_mod) +{ + struct ldb_module *mod = _mod; + Py_DECREF((PyObject *)mod->private_data); + return 0; +} + +int py_module_init (struct ldb_module *mod) +{ + PyObject *py_class = mod->ops->private_data; + PyObject *py_result, *py_next, *py_ldb; + + py_ldb = SWIG_NewPointerObj(mod->ldb, SWIGTYPE_p_ldb_context, 0); + + if (py_ldb == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_next = SWIG_NewPointerObj(mod->next, SWIGTYPE_p_ldb_module, 0); + + if (py_next == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallFunction(py_class, "OO", py_ldb, py_next); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + mod->private_data = py_result; + + talloc_set_destructor (mod, py_module_destructor); + + return ldb_next_init(mod); +} +%} + %typemap(in,noblock=1) const struct ldb_module_ops * { $1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); - $1->name = (char *)PyObject_GetAttrString($input, (char *)"name"); + $1->name = talloc_strdup($1, PyString_AsString(PyObject_GetAttrString($input, (char *)"name"))); + + Py_INCREF($input); + $1->private_data = $input; + $1->init_context = py_module_init; + $1->search = py_module_search; + $1->add = py_module_add; + $1->modify = py_module_modify; + $1->del = py_module_del; + $1->rename = py_module_rename; + $1->request = py_module_request; + $1->extended = py_module_extended; + $1->start_transaction = py_module_start_transaction; + $1->end_transaction = py_module_end_transaction; + $1->del_transaction = py_module_del_transaction; } %feature("docstring") ldb_register_module "S.register_module(module) -> None\n" @@ -928,4 +1282,5 @@ ldb_int_error ldb_register_module(const struct ldb_module_ops *); %pythoncode { __docformat__ = "restructuredText" +open = Ldb } diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index df11e9d2ab..a7b1cb0c69 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -1,7 +1,7 @@ -LDB_LIB = $(STATICLIB) +LDB_LIB = -Llib -lldb -LIB_FLAGS=$(LDFLAGS) -Llib $(LDB_LIB) $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \ - $(TDB_LIBS) $(LDAP_LIBS) $(LIBDL) +LIB_FLAGS=$(LDFLAGS) $(LIBS) $(LDB_LIB) $(POPT_LIBS) $(TALLOC_LIBS) \ + $(TDB_LIBS) $(EVENTS_LIBS) $(LDAP_LIBS) $(LIBDL) LDB_TDB_DIR=ldb_tdb LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \ @@ -34,34 +34,31 @@ lib/libldb.a: $(OBJS) sample.$(SHLIBEXT): tests/sample_module.o $(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o -bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS) +bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(CC) -o bin/ldbadd tools/ldbadd.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o $(LIBS) +bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o $(CC) -o bin/ldbsearch tools/ldbsearch.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/ldbdel: tools/ldbdel.o tools/cmdline.o $(LIBS) +bin/ldbdel: tools/ldbdel.o tools/cmdline.o $(CC) -o bin/ldbdel tools/ldbdel.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o $(LIBS) +bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o $(CC) -o bin/ldbmodify tools/ldbmodify.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/ldbedit: tools/ldbedit.o tools/cmdline.o $(LIBS) +bin/ldbedit: tools/ldbedit.o tools/cmdline.o $(CC) -o bin/ldbedit tools/ldbedit.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/ldbrename: tools/ldbrename.o tools/cmdline.o $(LIBS) +bin/ldbrename: tools/ldbrename.o tools/cmdline.o $(CC) -o bin/ldbrename tools/ldbrename.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/ldbtest: tools/ldbtest.o tools/cmdline.o $(LIBS) +bin/ldbtest: tools/ldbtest.o tools/cmdline.o $(CC) -o bin/ldbtest tools/ldbtest.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC) -bin/oLschema2ldif: tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIBS) - $(CC) -o bin/oLschema2ldif tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIB_FLAGS) - -examples/ldbreader: examples/ldbreader.o $(LIBS) +examples/ldbreader: examples/ldbreader.o $(CC) -o examples/ldbreader examples/ldbreader.o $(LIB_FLAGS) -examples/ldifreader: examples/ldifreader.o $(LIBS) +examples/ldifreader: examples/ldifreader.o $(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS) # Python bindings @@ -70,7 +67,7 @@ build-python:: _ldb.$(SHLIBEXT) ldb_wrap.o: $(ldbdir)/ldb_wrap.c $(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` -_ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o +_ldb.$(SHLIBEXT): ldb_wrap.o $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags` install-python:: build-python diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py index 5826c6b752..4cf36441fd 100644 --- a/source4/lib/ldb/ldb.py +++ b/source4/lib/ldb/ldb.py @@ -281,6 +281,16 @@ LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER class Ldb(object): """Connection to a LDB database.""" thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + firstmodule = _swig_property(_ldb.Ldb_firstmodule_get, _ldb.Ldb_firstmodule_set) + def itermodules(self): + m = self.firstmodule + while m is not None: + yield m + m = m.next + + def modules(self): + return list(self.itermodules()) + def __init__(self, *args, **kwargs): _ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs)) def connect(*args, **kwargs): @@ -464,6 +474,26 @@ def string_to_time(*args, **kwargs): Parse a LDAP time string into a UNIX timestamp. """ return _ldb.string_to_time(*args, **kwargs) +class ldb_module(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + prev = _swig_property(_ldb.ldb_module_prev_get, _ldb.ldb_module_prev_set) + next = _swig_property(_ldb.ldb_module_next_get, _ldb.ldb_module_next_set) + def __init__(self, *args, **kwargs): + _ldb.ldb_module_swiginit(self,_ldb.new_ldb_module(*args, **kwargs)) + __swig_destroy__ = _ldb.delete_ldb_module +ldb_module.__str__ = new_instancemethod(_ldb.ldb_module___str__,None,ldb_module) +ldb_module.__repr__ = new_instancemethod(_ldb.ldb_module___repr__,None,ldb_module) +ldb_module.search = new_instancemethod(_ldb.ldb_module_search,None,ldb_module) +ldb_module.add = new_instancemethod(_ldb.ldb_module_add,None,ldb_module) +ldb_module.modify = new_instancemethod(_ldb.ldb_module_modify,None,ldb_module) +ldb_module.delete = new_instancemethod(_ldb.ldb_module_delete,None,ldb_module) +ldb_module.rename = new_instancemethod(_ldb.ldb_module_rename,None,ldb_module) +ldb_module.start_transaction = new_instancemethod(_ldb.ldb_module_start_transaction,None,ldb_module) +ldb_module.end_transaction = new_instancemethod(_ldb.ldb_module_end_transaction,None,ldb_module) +ldb_module.del_transaction = new_instancemethod(_ldb.ldb_module_del_transaction,None,ldb_module) +ldb_module_swigregister = _ldb.ldb_module_swigregister +ldb_module_swigregister(ldb_module) + def register_module(*args, **kwargs): """ @@ -472,6 +502,7 @@ def register_module(*args, **kwargs): """ return _ldb.register_module(*args, **kwargs) __docformat__ = "restructuredText" +open = Ldb diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 5ad671ea2e..4aa71e6036 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -53,17 +53,57 @@ struct ildb_private { struct ldap_connection *ldap; - struct ldb_module *module; + struct event_context *event_ctx; }; struct ildb_context { + struct ldb_module *module; + struct ldb_request *req; + struct ildb_private *ildb; - struct ldb_handle *handle; - struct ldap_request *req; - void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); + struct ldap_request *ireq; + + bool done; + + struct ildb_destructor_ctx *dc; }; +static void ildb_request_done(struct ildb_context *ctx, + struct ldb_control **ctrls, int error) +{ + struct ldb_reply *ares; + + ctx->done = true; + + if (ctx->req == NULL) { + /* if the req has been freed already just return */ + return; + } + + ares = talloc_zero(ctx->req, struct ldb_reply); + if (!ares) { + ldb_oom(ctx->req->handle->ldb); + ctx->req->callback(ctx->req, NULL); + return; + } + ares->type = LDB_REPLY_DONE; + ares->controls = talloc_steal(ares, ctrls); + ares->error = error; + + ctx->req->callback(ctx->req, ares); +} + +static void ildb_auto_done_callback(struct event_context *ev, + struct timed_event *te, + struct timeval t, + void *private_data) +{ + struct ildb_context *ac; + + ac = talloc_get_type(private_data, struct ildb_context); + ildb_request_done(ac, NULL, LDB_SUCCESS); +} + /* convert a ldb_message structure to a list of ldap_mod structures ready for ildap_add() or ildap_modify() @@ -122,17 +162,19 @@ failed: /* map an ildap NTSTATUS to a ldb error code */ -static int ildb_map_error(struct ildb_private *ildb, NTSTATUS status) +static int ildb_map_error(struct ldb_module *module, NTSTATUS status) { + struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + TALLOC_CTX *mem_ctx = talloc_new(ildb); if (NT_STATUS_IS_OK(status)) { return LDB_SUCCESS; } if (!mem_ctx) { - ldb_oom(ildb->module->ldb); + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ldb_set_errstring(ildb->module->ldb, + ldb_set_errstring(module->ldb, ldap_errstr(ildb->ldap, mem_ctx, status)); talloc_free(mem_ctx); if (NT_STATUS_IS_LDAP(status)) { @@ -141,47 +183,46 @@ static int ildb_map_error(struct ildb_private *ildb, NTSTATUS status) return LDB_ERR_OPERATIONS_ERROR; } -static void ildb_request_timeout(struct event_context *ev, - struct timed_event *te, +static void ildb_request_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *private_data) { - struct ildb_context *ac; - struct ldb_handle *handle; - - ac = talloc_get_type(private_data, struct ildb_context); - handle = ac->handle; - - ac = talloc_get_type(private_data, struct ildb_context); + struct ildb_context *ac = talloc_get_type(private_data, struct ildb_context); - if (ac->req->state == LDAP_REQUEST_PENDING) { - DLIST_REMOVE(ac->req->conn->pending, ac->req); + if (ac->ireq->state == LDAP_REQUEST_PENDING) { + DLIST_REMOVE(ac->ireq->conn->pending, ac->ireq); } - handle->status = LDB_ERR_TIME_LIMIT_EXCEEDED; - - return; + ildb_request_done(ac, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED); } static void ildb_callback(struct ldap_request *req) { struct ildb_context *ac; - struct ldb_handle *handle; - struct ildb_private *ildb; NTSTATUS status; + struct ldap_SearchResEntry *search; + struct ldap_message *msg; + struct ldb_control **controls; + struct ldb_message *ldbmsg; + char *referral; + bool callback_failed; + bool request_done; + int ret; int i; ac = talloc_get_type(req->async.private_data, struct ildb_context); - ildb = ac->ildb; - handle = ac->handle; - handle->status = LDB_SUCCESS; + callback_failed = false; + request_done = false; + controls = NULL; if (!NT_STATUS_IS_OK(req->status)) { - handle->status = ildb_map_error(ildb, req->status); + ret = ildb_map_error(ac->module, req->status); + ildb_request_done(ac, NULL, ret); return; } if (req->num_replies < 1) { - handle->status = LDB_ERR_OPERATIONS_ERROR; + ret = LDB_ERR_OPERATIONS_ERROR; + ildb_request_done(ac, NULL, ret); return; } @@ -189,140 +230,112 @@ static void ildb_callback(struct ldap_request *req) case LDAP_TAG_ModifyRequest: if (req->replies[0]->type != LDAP_TAG_ModifyResponse) { - handle->status = LDB_ERR_PROTOCOL_ERROR; - return; + ret = LDB_ERR_PROTOCOL_ERROR; + break; } - status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult); - handle->status = ildb_map_error(ildb, status); - if (ac->callback && handle->status == LDB_SUCCESS) { - /* FIXME: build a corresponding ares to pass on */ - handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL); - } - handle->state = LDB_ASYNC_DONE; + status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult); + ret = ildb_map_error(ac->module, status); + request_done = true; break; case LDAP_TAG_AddRequest: if (req->replies[0]->type != LDAP_TAG_AddResponse) { - handle->status = LDB_ERR_PROTOCOL_ERROR; + ret = LDB_ERR_PROTOCOL_ERROR; return; } - status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult); - handle->status = ildb_map_error(ildb, status); - if (ac->callback && handle->status == LDB_SUCCESS) { - /* FIXME: build a corresponding ares to pass on */ - handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL); - } - handle->state = LDB_ASYNC_DONE; + status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult); + ret = ildb_map_error(ac->module, status); + request_done = true; break; case LDAP_TAG_DelRequest: if (req->replies[0]->type != LDAP_TAG_DelResponse) { - handle->status = LDB_ERR_PROTOCOL_ERROR; + ret = LDB_ERR_PROTOCOL_ERROR; return; } - status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult); - handle->status = ildb_map_error(ildb, status); - if (ac->callback && handle->status == LDB_SUCCESS) { - /* FIXME: build a corresponding ares to pass on */ - handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL); - } - handle->state = LDB_ASYNC_DONE; + status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult); + ret = ildb_map_error(ac->module, status); + request_done = true; break; case LDAP_TAG_ModifyDNRequest: if (req->replies[0]->type != LDAP_TAG_ModifyDNResponse) { - handle->status = LDB_ERR_PROTOCOL_ERROR; + ret = LDB_ERR_PROTOCOL_ERROR; return; } - status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult); - handle->status = ildb_map_error(ildb, status); - if (ac->callback && handle->status == LDB_SUCCESS) { - /* FIXME: build a corresponding ares to pass on */ - handle->status = ac->callback(ac->ildb->module->ldb, ac->context, NULL); - } - handle->state = LDB_ASYNC_DONE; + status = ldap_check_response(ac->ireq->conn, &req->replies[0]->r.GeneralResult); + ret = ildb_map_error(ac->module, status); + request_done = true; break; case LDAP_TAG_SearchRequest: /* loop over all messages */ for (i = 0; i < req->num_replies; i++) { - struct ldap_SearchResEntry *search; - struct ldb_reply *ares = NULL; - struct ldap_message *msg; - int ret; - - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return; - } msg = req->replies[i]; switch (msg->type) { case LDAP_TAG_SearchResultDone: - status = ldap_check_response(req->conn, &msg->r.GeneralResult); + status = ldap_check_response(ac->ireq->conn, &msg->r.GeneralResult); if (!NT_STATUS_IS_OK(status)) { - handle->status = ildb_map_error(ildb, status); - return; + ret = ildb_map_error(ac->module, status); + break; } - ares->controls = talloc_move(ares, &msg->controls); + controls = talloc_steal(ac, msg->controls); if (msg->r.SearchResultDone.resultcode) { if (msg->r.SearchResultDone.errormessage) { - ldb_set_errstring(ac->ildb->module->ldb, msg->r.SearchResultDone.errormessage); + ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage); } } - handle->status = msg->r.SearchResultDone.resultcode; - handle->state = LDB_ASYNC_DONE; - ares->type = LDB_REPLY_DONE; + ret = msg->r.SearchResultDone.resultcode; + request_done = true; break; case LDAP_TAG_SearchResultEntry: - - ares->message = ldb_msg_new(ares); - if (!ares->message) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return; + ldbmsg = ldb_msg_new(ac); + if (!ldbmsg) { + ret = LDB_ERR_OPERATIONS_ERROR; + break; } search = &(msg->r.SearchResultEntry); - ares->message->dn = ldb_dn_new(ares->message, ac->ildb->module->ldb, search->dn); - if ( ! ldb_dn_validate(ares->message->dn)) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return; + ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, search->dn); + if ( ! ldb_dn_validate(ldbmsg->dn)) { + ret = LDB_ERR_OPERATIONS_ERROR; + break; } - ares->message->num_elements = search->num_attributes; - ares->message->elements = talloc_move(ares->message, - &search->attributes); + ldbmsg->num_elements = search->num_attributes; + ldbmsg->elements = talloc_move(ldbmsg, &search->attributes); - handle->status = LDB_SUCCESS; - handle->state = LDB_ASYNC_PENDING; - ares->type = LDB_REPLY_ENTRY; + ret = ldb_module_send_entry(ac->req, ldbmsg); + if (ret != LDB_SUCCESS) { + callback_failed = true; + } break; case LDAP_TAG_SearchResultReference: - ares->referral = talloc_strdup(ares, msg->r.SearchResultReference.referral); + referral = talloc_strdup(ac, msg->r.SearchResultReference.referral); - handle->status = LDB_SUCCESS; - handle->state = LDB_ASYNC_PENDING; - ares->type = LDB_REPLY_REFERRAL; + ret = ldb_module_send_referral(ac->req, referral); + if (ret != LDB_SUCCESS) { + callback_failed = true; + } break; default: /* TAG not handled, fail ! */ - handle->status = LDB_ERR_PROTOCOL_ERROR; - return; + ret = LDB_ERR_PROTOCOL_ERROR; + break; } - ret = ac->callback(ac->ildb->module->ldb, ac->context, ares); - if (ret) { - handle->status = ret; + if (ret != LDB_SUCCESS) { + break; } } @@ -333,121 +346,81 @@ static void ildb_callback(struct ldap_request *req) break; default: - handle->status = LDB_ERR_PROTOCOL_ERROR; - return; + ret = LDB_ERR_PROTOCOL_ERROR; + break; } -} -static struct ildb_context *init_ildb_handle(struct ildb_private *ildb, - struct ldb_request *req) -{ - struct ildb_context *ildb_ac; - struct ldb_handle *h; + if (ret != LDB_SUCCESS) { - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(ildb->module->ldb, "Out of Memory"); - return NULL; + /* if the callback failed the caller will have freed the + * request. Just return and don't try to use it */ + if ( ! callback_failed) { + request_done = true; + } } - h->module = ildb->module; - - ildb_ac = talloc(h, struct ildb_context); - if (ildb_ac == NULL) { - ldb_set_errstring(ildb->module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; + if (request_done) { + ildb_request_done(ac, controls, ret); } - - h->private_data = ildb_ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ildb_ac->ildb = ildb; - ildb_ac->handle = h; - ildb_ac->context = req->context; - ildb_ac->callback = req->callback; - - req->handle = h; - return ildb_ac; + return; } -static int ildb_request_send(struct ildb_private *ildb, struct ldap_message *msg, struct ldb_request *r) +static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg) { - struct ildb_context *ildb_ac = init_ildb_handle(ildb, r); struct ldap_request *req; - if (!ildb_ac) { + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - req = ldap_request_send(ildb->ldap, msg); + req = ldap_request_send(ac->ildb->ldap, msg); if (req == NULL) { - ldb_set_errstring(ildb->module->ldb, "async send request failed"); + ldb_set_errstring(ac->module->ldb, "async send request failed"); return LDB_ERR_OPERATIONS_ERROR; } - ildb_ac->req = talloc_steal(ildb_ac, req); + ac->ireq = talloc_steal(ac, req); - if (!req->conn) { - ldb_set_errstring(ildb->module->ldb, "connection to remote LDAP server dropped?"); + if (!ac->ireq->conn) { + ldb_set_errstring(ac->module->ldb, "connection to remote LDAP server dropped?"); return LDB_ERR_OPERATIONS_ERROR; } talloc_free(req->time_event); req->time_event = NULL; - if (r->timeout) { - req->time_event = event_add_timed(req->conn->event.event_ctx, ildb_ac, - timeval_current_ofs(r->timeout, 0), - ildb_request_timeout, ildb_ac); + if (ac->req->timeout) { + req->time_event = event_add_timed(ac->ildb->event_ctx, ac, + timeval_current_ofs(ac->req->timeout, 0), + ildb_request_timeout, ac); } req->async.fn = ildb_callback; - req->async.private_data = ildb_ac; + req->async.private_data = ac; return LDB_SUCCESS; } -static int ildb_request_noop(struct ildb_private *ildb, struct ldb_request *req) -{ - struct ildb_context *ildb_ac = init_ildb_handle(ildb, req); - int ret = LDB_SUCCESS; - - if (!ildb_ac) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (ildb_ac->callback) { - ret = ildb_ac->callback(ildb->module->ldb, ildb_ac->context, NULL); - } - ildb_ac->handle->state = LDB_ASYNC_DONE; - return ret; -} - /* search for matching records using an asynchronous function */ -static int ildb_search(struct ldb_module *module, struct ldb_request *req) +static int ildb_search(struct ildb_context *ac) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ldb_request *req = ac->req; struct ldap_message *msg; int n; - req->handle = NULL; - if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context"); + ldb_set_errstring(ac->module->ldb, "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } if (req->op.search.tree == NULL) { - ldb_set_errstring(module->ldb, "Invalid expression parse tree"); + ldb_set_errstring(ac->module->ldb, "Invalid expression parse tree"); return LDB_ERR_OPERATIONS_ERROR; } msg = new_ldap_message(req); if (msg == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ac->module->ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -459,7 +432,7 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req) msg->r.SearchRequest.basedn = ldb_dn_alloc_linearized(msg, req->op.search.base); } if (msg->r.SearchRequest.basedn == NULL) { - ldb_set_errstring(module->ldb, "Unable to determine baseDN"); + ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN"); talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } @@ -481,26 +454,19 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req) msg->r.SearchRequest.attributes = discard_const(req->op.search.attrs); msg->controls = req->controls; - return ildb_request_send(ildb, msg, req); + return ildb_request_send(ac, msg); } /* add a record */ -static int ildb_add(struct ldb_module *module, struct ldb_request *req) +static int ildb_add(struct ildb_context *ac) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ldb_request *req = ac->req; struct ldap_message *msg; struct ldap_mod **mods; int i,n; - req->handle = NULL; - - /* ignore ltdb specials */ - if (ldb_dn_is_special(req->op.add.message->dn)) { - return ildb_request_noop(ildb, req); - } - msg = new_ldap_message(req); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -531,26 +497,19 @@ static int ildb_add(struct ldb_module *module, struct ldb_request *req) msg->r.AddRequest.attributes[i] = mods[i]->attrib; } - return ildb_request_send(ildb, msg, req); + return ildb_request_send(ac, msg); } /* modify a record */ -static int ildb_modify(struct ldb_module *module, struct ldb_request *req) +static int ildb_modify(struct ildb_context *ac) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ldb_request *req = ac->req; struct ldap_message *msg; struct ldap_mod **mods; int i,n; - req->handle = NULL; - - /* ignore ltdb specials */ - if (ldb_dn_is_special(req->op.mod.message->dn)) { - return ildb_request_noop(ildb, req); - } - msg = new_ldap_message(req); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -581,24 +540,17 @@ static int ildb_modify(struct ldb_module *module, struct ldb_request *req) msg->r.ModifyRequest.mods[i] = *mods[i]; } - return ildb_request_send(ildb, msg, req); + return ildb_request_send(ac, msg); } /* delete a record */ -static int ildb_delete(struct ldb_module *module, struct ldb_request *req) +static int ildb_delete(struct ildb_context *ac) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ldb_request *req = ac->req; struct ldap_message *msg; - req->handle = NULL; - - /* ignore ltdb specials */ - if (ldb_dn_is_special(req->op.del.dn)) { - return ildb_request_noop(ildb, req); - } - msg = new_ldap_message(req); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -612,24 +564,17 @@ static int ildb_delete(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_INVALID_DN_SYNTAX; } - return ildb_request_send(ildb, msg, req); + return ildb_request_send(ac, msg); } /* rename a record */ -static int ildb_rename(struct ldb_module *module, struct ldb_request *req) +static int ildb_rename(struct ildb_context *ac) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ldb_request *req = ac->req; struct ldap_message *msg; - req->handle = NULL; - - /* ignore ltdb specials */ - if (ldb_dn_is_special(req->op.rename.olddn) || ldb_dn_is_special(req->op.rename.newdn)) { - return ildb_request_noop(ildb, req); - } - msg = new_ldap_message(req); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -660,7 +605,7 @@ static int ildb_rename(struct ldb_module *module, struct ldb_request *req) msg->r.ModifyDNRequest.deleteolddn = true; - return ildb_request_send(ildb, msg, req); + return ildb_request_send(ac, msg); } static int ildb_start_trans(struct ldb_module *module) @@ -684,57 +629,105 @@ static int ildb_del_trans(struct ldb_module *module) return LDB_SUCCESS; } -static int ildb_request(struct ldb_module *module, struct ldb_request *req) +static bool ildb_dn_is_special(struct ldb_request *req) { - return LDB_ERR_OPERATIONS_ERROR; + struct ldb_dn *dn = NULL; + + switch (req->operation) { + case LDB_ADD: + dn = req->op.add.message->dn; + break; + case LDB_MODIFY: + dn = req->op.mod.message->dn; + break; + case LDB_DELETE: + dn = req->op.del.dn; + break; + case LDB_RENAME: + dn = req->op.rename.olddn; + break; + default: + break; + } + + if (dn && ldb_dn_is_special(dn)) { + return true; + } + return false; } -static int ildb_wait(struct ldb_handle *handle, enum ldb_wait_type type) +static int ildb_handle_request(struct ldb_module *module, struct ldb_request *req) { - struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context); + struct ildb_private *ildb; + struct ildb_context *ac; + struct timed_event *te; + int ret; + + ildb = talloc_get_type(module->private_data, struct ildb_private); - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; + if (req->starttime == 0 || req->timeout == 0) { + ldb_set_errstring(module->ldb, "Invalid timeout settings"); + return LDB_ERR_TIME_LIMIT_EXCEEDED; } - if (!ac) { + ac = talloc_zero(req, struct ildb_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } - handle->state = LDB_ASYNC_INIT; + ac->module = module; + ac->req = req; + ac->ildb = ildb; + + if (ildb_dn_is_special(req)) { - switch(type) { - case LDB_WAIT_NONE: - if (event_loop_once(ac->req->conn->event.event_ctx) != 0) { - return LDB_ERR_OTHER; + te = event_add_timed(ac->ildb->event_ctx, + ac, timeval_zero(), + ildb_auto_done_callback, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; } + + return LDB_SUCCESS; + } + + switch (ac->req->operation) { + case LDB_SEARCH: + ret = ildb_search(ac); break; - case LDB_WAIT_ALL: - while (handle->status == LDB_SUCCESS && handle->state != LDB_ASYNC_DONE) { - if (event_loop_once(ac->req->conn->event.event_ctx) != 0) { - return LDB_ERR_OTHER; - } - } + case LDB_ADD: + ret = ildb_add(ac); + break; + case LDB_MODIFY: + ret = ildb_modify(ac); + break; + case LDB_DELETE: + ret = ildb_delete(ac); + break; + case LDB_RENAME: + ret = ildb_rename(ac); break; default: - return LDB_ERR_OPERATIONS_ERROR; + /* no other op supported */ + ret = LDB_ERR_OPERATIONS_ERROR; + break; } - return handle->status; + return ret; } static const struct ldb_module_ops ildb_ops = { .name = "ldap", - .search = ildb_search, - .add = ildb_add, - .modify = ildb_modify, - .del = ildb_delete, - .rename = ildb_rename, - .request = ildb_request, + .search = ildb_handle_request, + .add = ildb_handle_request, + .modify = ildb_handle_request, + .del = ildb_handle_request, + .rename = ildb_handle_request, +/* .request = ildb_handle_request, */ .start_transaction = ildb_start_trans, .end_transaction = ildb_end_trans, .del_transaction = ildb_del_trans, - .wait = ildb_wait }; /* @@ -748,7 +741,6 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, struct ildb_private *ildb; NTSTATUS status; struct cli_credentials *creds; - struct event_context *event_ctx; module = talloc(ldb, struct ldb_module); if (!module) { @@ -758,7 +750,6 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, talloc_set_name_const(module, "ldb_ildap backend"); module->ldb = ldb; module->prev = module->next = NULL; - module->private_data = NULL; module->ops = &ildb_ops; ildb = talloc(module, struct ildb_private); @@ -767,12 +758,12 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, goto failed; } module->private_data = ildb; - ildb->module = module; - event_ctx = ldb_get_event_context(ldb); + ildb->event_ctx = ldb_get_event_context(ldb); + ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"), - event_ctx); + ildb->event_ctx); if (!ildb->ldap) { ldb_oom(ldb); goto failed; diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index a4534c549a..7caee10b47 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -45,17 +45,16 @@ struct lldb_private { LDAP *ldap; - struct ldb_module *module; }; struct lldb_context { + struct ldb_module *module; + struct ldb_request *req; + struct lldb_private *lldb; - struct ldb_handle *handle; + + struct ldb_control **controls; int msgid; - int timeout; - time_t starttime; - void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; static int lldb_ldap_to_ldb(int err) { @@ -63,42 +62,6 @@ static int lldb_ldap_to_ldb(int err) { return err; } -static struct lldb_context *init_lldb_handle(struct lldb_private *lldb, struct ldb_request *req) -{ - struct lldb_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(lldb->module->ldb, "Out of Memory"); - return NULL; - } - - h->module = lldb->module; - - ac = talloc(h, struct lldb_context); - if (ac == NULL) { - ldb_set_errstring(lldb->module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; - } - - h->private_data = ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->lldb = lldb; - ac->handle = h; - ac->context = req->context; - ac->callback = req->callback; - ac->timeout = req->timeout; - ac->starttime = req->starttime; - ac->msgid = 0; - - req->handle = h; - return ac; -} /* convert a ldb_message structure to a list of LDAPMod structures ready for ldap_add() or ldap_modify() @@ -230,10 +193,11 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, /* search for matching records */ -static int lldb_search(struct ldb_module *module, struct ldb_request *req) +static int lldb_search(struct lldb_context *lldb_ac) { - struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_context *lldb_ac; + struct lldb_private *lldb = lldb_ac->lldb; + struct ldb_module *module = lldb_ac->module; + struct ldb_request *req = lldb_ac->req; struct timeval tv; int ldap_scope; char *search_base; @@ -254,10 +218,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req) ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n"); } - lldb_ac = init_lldb_handle(lldb, req); - if (lldb_ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } + req->handle->state = LDB_ASYNC_PENDING; search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base); if (req->op.search.base == NULL) { @@ -307,23 +268,16 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req) /* add a record */ -static int lldb_add(struct ldb_module *module, struct ldb_request *req) +static int lldb_add(struct lldb_context *lldb_ac) { - struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_context *lldb_ac; + struct lldb_private *lldb = lldb_ac->lldb; + struct ldb_module *module = lldb_ac->module; + struct ldb_request *req = lldb_ac->req; LDAPMod **mods; char *dn; int ret; - /* ltdb specials should not reach this point */ - if (ldb_dn_is_special(req->op.add.message->dn)) { - return LDB_ERR_INVALID_DN_SYNTAX; - } - - lldb_ac = init_lldb_handle(lldb, req); - if (lldb_ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } + req->handle->state = LDB_ASYNC_PENDING; mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0); if (mods == NULL) { @@ -350,23 +304,16 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req) /* modify a record */ -static int lldb_modify(struct ldb_module *module, struct ldb_request *req) +static int lldb_modify(struct lldb_context *lldb_ac) { - struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_context *lldb_ac; + struct lldb_private *lldb = lldb_ac->lldb; + struct ldb_module *module = lldb_ac->module; + struct ldb_request *req = lldb_ac->req; LDAPMod **mods; char *dn; int ret; - /* ltdb specials should not reach this point */ - if (ldb_dn_is_special(req->op.mod.message->dn)) { - return LDB_ERR_INVALID_DN_SYNTAX; - } - - lldb_ac = init_lldb_handle(lldb, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } + req->handle->state = LDB_ASYNC_PENDING; mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1); if (mods == NULL) { @@ -393,22 +340,15 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req) /* delete a record */ -static int lldb_delete(struct ldb_module *module, struct ldb_request *req) +static int lldb_delete(struct lldb_context *lldb_ac) { - struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_context *lldb_ac; + struct lldb_private *lldb = lldb_ac->lldb; + struct ldb_module *module = lldb_ac->module; + struct ldb_request *req = lldb_ac->req; char *dnstr; int ret; - - /* ltdb specials should not reach this point */ - if (ldb_dn_is_special(req->op.del.dn)) { - return LDB_ERR_INVALID_DN_SYNTAX; - } - lldb_ac = init_lldb_handle(lldb, req); - if (lldb_ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } + req->handle->state = LDB_ASYNC_PENDING; dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn); @@ -427,24 +367,17 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req) /* rename a record */ -static int lldb_rename(struct ldb_module *module, struct ldb_request *req) +static int lldb_rename(struct lldb_context *lldb_ac) { - struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private); - struct lldb_context *lldb_ac; + struct lldb_private *lldb = lldb_ac->lldb; + struct ldb_module *module = lldb_ac->module; + struct ldb_request *req = lldb_ac->req; char *old_dn; char *newrdn; char *parentdn; int ret; - - /* ltdb specials should not reach this point */ - if (ldb_dn_is_special(req->op.rename.olddn) || ldb_dn_is_special(req->op.rename.newdn)) { - return LDB_ERR_INVALID_DN_SYNTAX; - } - lldb_ac = init_lldb_handle(lldb, req); - if (lldb_ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } + req->handle->state = LDB_ASYNC_PENDING; old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn); if (old_dn == NULL) { @@ -474,57 +407,99 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req) return lldb_ldap_to_ldb(ret); } -static int lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) +static int lldb_start_trans(struct ldb_module *module) +{ + /* TODO implement a local transaction mechanism here */ + + return LDB_SUCCESS; +} + +static int lldb_end_trans(struct ldb_module *module) +{ + /* TODO implement a local transaction mechanism here */ + + return LDB_SUCCESS; +} + +static int lldb_del_trans(struct ldb_module *module) +{ + /* TODO implement a local transaction mechanism here */ + + return LDB_SUCCESS; +} + +void lldb_request_done(struct ldb_request *req, + struct ldb_control **ctrls, int error) +{ + struct ldb_reply *ares; + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(req->handle->ldb); + req->callback(req, NULL); + return; + } + ares->type = LDB_REPLY_DONE; + ares->controls = talloc_steal(ares, ctrls); + ares->error = error; + + req->callback(req, ares); +} + +/* return false if the request is still in progress + * return true if the request is completed + */ +static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) { - struct ldb_handle *handle = ac->handle; struct lldb_private *lldb = ac->lldb; - struct ldb_reply *ares = NULL; - LDAPMessage *msg; - int type; + LDAPControl **serverctrlsp = NULL; + char **referralsp = NULL; char *matcheddnp = NULL; char *errmsgp = NULL; - char **referralsp = NULL; - LDAPControl **serverctrlsp = NULL; - int ret = LDB_SUCCESS; - - type = ldap_msgtype(result); + LDAPMessage *msg; + int type; + struct ldb_message *ldbmsg; + char *referral; + bool callback_failed; + bool request_done; + bool lret; + int ret; + int i; - handle->status = 0; + type = ldap_msgtype(result); + callback_failed = false; + request_done = false; switch (type) { - case LDAP_RES_SEARCH_ENTRY: + msg = ldap_first_entry(lldb->ldap, result); if (msg != NULL) { BerElement *berptr = NULL; char *attr, *dn; - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - ret = LDB_ERR_OPERATIONS_ERROR; - goto error; - } - - ares->message = ldb_msg_new(ares); - if (!ares->message) { + ldbmsg = ldb_msg_new(ac); + if (!ldbmsg) { ret = LDB_ERR_OPERATIONS_ERROR; - goto error; + break; } dn = ldap_get_dn(lldb->ldap, msg); if (!dn) { + talloc_free(ldbmsg); ret = LDB_ERR_OPERATIONS_ERROR; - goto error; + break; } - ares->message->dn = ldb_dn_new(ares->message, ac->lldb->module->ldb, dn); - if ( ! ldb_dn_validate(ares->message->dn)) { + ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, dn); + if ( ! ldb_dn_validate(ldbmsg->dn)) { + talloc_free(ldbmsg); ret = LDB_ERR_OPERATIONS_ERROR; - goto error; + break; } ldap_memfree(dn); - ares->message->num_elements = 0; - ares->message->elements = NULL; + ldbmsg->num_elements = 0; + ldbmsg->elements = NULL; /* loop over all attributes */ for (attr=ldap_first_attribute(lldb->ldap, msg, &berptr); @@ -534,97 +509,104 @@ static int lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) bval = ldap_get_values_len(lldb->ldap, msg, attr); if (bval) { - lldb_add_msg_attr(ac->lldb->module->ldb, ares->message, attr, bval); + lldb_add_msg_attr(ac->module->ldb, ldbmsg, attr, bval); ldap_value_free_len(bval); - } + } } if (berptr) ber_free(berptr, 0); + ret = ldb_module_send_entry(ac->req, ldbmsg); + if (ret != LDB_SUCCESS) { - ares->type = LDB_REPLY_ENTRY; - ret = ac->callback(ac->lldb->module->ldb, ac->context, ares); + callback_failed = true; + } } else { - handle->status = LDB_ERR_PROTOCOL_ERROR; - handle->state = LDB_ASYNC_DONE; + ret = LDB_ERR_OPERATIONS_ERROR; } break; case LDAP_RES_SEARCH_REFERENCE: - if (ldap_parse_result(lldb->ldap, result, &handle->status, + + if (ldap_parse_result(lldb->ldap, result, &ret, &matcheddnp, &errmsgp, &referralsp, &serverctrlsp, 0) != LDAP_SUCCESS) { ret = LDB_ERR_OPERATIONS_ERROR; - goto error; } - if (referralsp == NULL) { - handle->status = LDB_ERR_PROTOCOL_ERROR; - goto error; + if (ret != LDB_SUCCESS) { + break; } - - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - ret = LDB_ERR_OPERATIONS_ERROR; - goto error; + if (referralsp == NULL) { + ret = LDB_ERR_PROTOCOL_ERROR; + break; } - ares->referral = talloc_strdup(ares, *referralsp); - ares->type = LDB_REPLY_REFERRAL; - ret = ac->callback(ac->lldb->module->ldb, ac->context, ares); + for (i = 0; referralsp[i]; i++) { + referral = talloc_strdup(ac, referralsp[i]); + ret = ldb_module_send_referral(ac->req, referral); + if (ret != LDB_SUCCESS) { + callback_failed = true; + break; + } + } break; case LDAP_RES_SEARCH_RESULT: - if (ldap_parse_result(lldb->ldap, result, &handle->status, + case LDAP_RES_MODIFY: + case LDAP_RES_ADD: + case LDAP_RES_DELETE: + case LDAP_RES_MODDN: + + if (ldap_parse_result(lldb->ldap, result, &ret, &matcheddnp, &errmsgp, &referralsp, &serverctrlsp, 0) != LDAP_SUCCESS) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - goto error; - } - - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; - goto error; + } + if (ret != LDB_SUCCESS) { + break; } if (serverctrlsp != NULL) { /* FIXME: transform the LDAPControl list into an ldb_control one */ - ares->controls = NULL; + ac->controls = NULL; } - - ares->type = LDB_REPLY_DONE; - handle->state = LDB_ASYNC_DONE; - ret = ac->callback(ac->lldb->module->ldb, ac->context, ares); - - break; - case LDAP_RES_MODIFY: - case LDAP_RES_ADD: - case LDAP_RES_DELETE: - case LDAP_RES_MODDN: - if (ldap_parse_result(lldb->ldap, result, &handle->status, - &matcheddnp, &errmsgp, - &referralsp, &serverctrlsp, 0) != LDAP_SUCCESS) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - goto error; - } - if (ac->callback && handle->status == LDB_SUCCESS) { - ares = NULL; /* FIXME: build a corresponding ares to pass on */ - ret = ac->callback(ac->lldb->module->ldb, ac->context, ares); - } - handle->state = LDB_ASYNC_DONE; + request_done = true; break; default: ret = LDB_ERR_PROTOCOL_ERROR; - goto error; + break; } + if (ret != LDB_SUCCESS) { + + /* if the callback failed the caller will have freed the + * request. Just return and don't try to use it */ + if (callback_failed) { + + /* tell lldb_wait to remove the request from the + * queue */ + lret = true; + goto free_and_return; + } + + request_done = true; + } + + if (request_done) { + lldb_request_done(ac->req, ac->controls, ret); + lret = true; + goto free_and_return; + } + + lret = false; + +free_and_return: + if (matcheddnp) ldap_memfree(matcheddnp); if (errmsgp && *errmsgp) { - ldb_set_errstring(ac->lldb->module->ldb, errmsgp); - } else if (handle->status) { - ldb_set_errstring(ac->lldb->module->ldb, ldap_err2string(handle->status)); + ldb_set_errstring(ac->module->ldb, errmsgp); } if (errmsgp) { ldap_memfree(errmsgp); @@ -633,131 +615,203 @@ static int lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) if (serverctrlsp) ldap_controls_free(serverctrlsp); ldap_msgfree(result); - return lldb_ldap_to_ldb(handle->status); -error: - handle->state = LDB_ASYNC_DONE; - ldap_msgfree(result); - return ret; + return lret; } -static int lldb_wait(struct ldb_handle *handle, enum ldb_wait_type type) +static void lldb_timeout(struct event_context *ev, + struct timed_event *te, + struct timeval t, + void *private_data) { - struct lldb_context *ac = talloc_get_type(handle->private_data, struct lldb_context); - struct lldb_private *lldb = ac->lldb; - struct timeval timeout; + struct lldb_context *ac; + ac = talloc_get_type(private_data, struct lldb_context); + + lldb_request_done(ac->req, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED); +} + +static void lldb_callback(struct event_context *ev, + struct timed_event *te, + struct timeval t, + void *private_data) +{ + struct lldb_context *ac; + struct timed_event *lte; + struct timeval tv; LDAPMessage *result; - int ret, lret; + int lret; + + ac = talloc_get_type(private_data, struct lldb_context); - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; + if (!ac->msgid) { + lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + return; } - if (!ac || !ac->msgid) { - return LDB_ERR_OPERATIONS_ERROR; + tv.tv_sec = 0; + tv.tv_usec = 0; + lret = ldap_result(ac->lldb->ldap, ac->msgid, 0, &tv, &result); + if (lret == 0) { + goto respin; + } + if (lret == -1) { + lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + return; } - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; + if ( ! lldb_parse_result(ac, result)) { + goto respin; + } - switch(type) { - case LDB_WAIT_NONE: + return; - if ((ac->timeout != -1) && - ((ac->starttime + ac->timeout) > time(NULL))) { - return LDB_ERR_TIME_LIMIT_EXCEEDED; - } +respin: + tv.tv_sec = 0; + tv.tv_usec = 100; + lte = event_add_timed(ev, ac, tv, lldb_callback, ac); + if (NULL == lte) { + lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + } +} - timeout.tv_sec = 0; - timeout.tv_usec = 0; +static bool lldb_dn_is_special(struct ldb_request *req) +{ + struct ldb_dn *dn = NULL; - lret = ldap_result(lldb->ldap, ac->msgid, 0, &timeout, &result); - if (lret == -1) { - return LDB_ERR_OPERATIONS_ERROR; - } - if (lret == 0) { - ret = LDB_SUCCESS; - goto done; - } + switch (req->operation) { + case LDB_ADD: + dn = req->op.add.message->dn; + break; + case LDB_MODIFY: + dn = req->op.mod.message->dn; + break; + case LDB_DELETE: + dn = req->op.del.dn; + break; + case LDB_RENAME: + dn = req->op.rename.olddn; + break; + default: + break; + } - return lldb_parse_result(ac, result); + if (dn && ldb_dn_is_special(dn)) { + return true; + } + return false; +} - case LDB_WAIT_ALL: - timeout.tv_usec = 0; - ret = LDB_ERR_OPERATIONS_ERROR; +static void lldb_auto_done_callback(struct event_context *ev, + struct timed_event *te, + struct timeval t, + void *private_data) +{ + struct lldb_context *ac; - while (handle->status == LDB_SUCCESS && handle->state != LDB_ASYNC_DONE) { + ac = talloc_get_type(private_data, struct lldb_context); + lldb_request_done(ac->req, NULL, LDB_SUCCESS); +} - if (ac->timeout == -1) { - lret = ldap_result(lldb->ldap, ac->msgid, 0, NULL, &result); - } else { - timeout.tv_sec = ac->timeout - (time(NULL) - ac->starttime); - if (timeout.tv_sec <= 0) - return LDB_ERR_TIME_LIMIT_EXCEEDED; - lret = ldap_result(lldb->ldap, ac->msgid, 0, &timeout, &result); - } - if (lret == -1) { - return LDB_ERR_OPERATIONS_ERROR; - } - if (lret == 0) { - return LDB_ERR_TIME_LIMIT_EXCEEDED; - } +static int lldb_handle_request(struct ldb_module *module, struct ldb_request *req) +{ + struct lldb_private *lldb; + struct lldb_context *ac; + struct event_context *ev; + struct timed_event *te; + struct timeval tv; + int ret; - ret = lldb_parse_result(ac, result); - if (ret != LDB_SUCCESS) { - return ret; - } + lldb = talloc_get_type(module->private_data, struct lldb_private); + + if (req->starttime == 0 || req->timeout == 0) { + ldb_set_errstring(module->ldb, "Invalid timeout settings"); + return LDB_ERR_TIME_LIMIT_EXCEEDED; + } + + ev = ldb_get_event_context(module->ldb); + if (NULL == ev) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac = talloc_zero(module->ldb, struct lldb_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->module = module; + ac->req = req; + ac->lldb = lldb; + ac->msgid = 0; + + if (lldb_dn_is_special(req)) { + tv.tv_sec = 0; + tv.tv_usec = 0; + te = event_add_timed(ev, ac, tv, + lldb_auto_done_callback, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; } + return LDB_SUCCESS; + } + + switch (ac->req->operation) { + case LDB_SEARCH: + ret = lldb_search(ac); + break; + case LDB_ADD: + ret = lldb_add(ac); + break; + case LDB_MODIFY: + ret = lldb_modify(ac); + break; + case LDB_DELETE: + ret = lldb_delete(ac); + break; + case LDB_RENAME: + ret = lldb_rename(ac); break; - default: - handle->state = LDB_ASYNC_DONE; + /* no other op supported */ ret = LDB_ERR_OPERATIONS_ERROR; + break; } -done: - return ret; -} - -static int lldb_start_trans(struct ldb_module *module) -{ - /* TODO implement a local transaction mechanism here */ - - return LDB_SUCCESS; -} + if (ret != LDB_SUCCESS) { + lldb_request_done(req, NULL, ret); + return ret; + } -static int lldb_end_trans(struct ldb_module *module) -{ - /* TODO implement a local transaction mechanism here */ + tv.tv_sec = 0; + tv.tv_usec = 0; + te = event_add_timed(ev, ac, tv, lldb_callback, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; + } - return LDB_SUCCESS; -} -static int lldb_del_trans(struct ldb_module *module) -{ - /* TODO implement a local transaction mechanism here */ + tv.tv_sec = req->starttime + req->timeout; + tv.tv_usec = 0; + te = event_add_timed(ev, ac, tv, lldb_timeout, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; + } return LDB_SUCCESS; } -static int lldb_request(struct ldb_module *module, struct ldb_request *req) -{ - return LDB_ERR_OPERATIONS_ERROR; -} - static const struct ldb_module_ops lldb_ops = { .name = "ldap", - .search = lldb_search, - .add = lldb_add, - .modify = lldb_modify, - .del = lldb_delete, - .rename = lldb_rename, - .request = lldb_request, + .search = lldb_handle_request, + .add = lldb_handle_request, + .modify = lldb_handle_request, + .del = lldb_handle_request, + .rename = lldb_handle_request, + .request = lldb_handle_request, .start_transaction = lldb_start_trans, .end_transaction = lldb_end_trans, .del_transaction = lldb_del_trans, - .wait = lldb_wait }; @@ -771,8 +825,8 @@ static int lldb_destructor(struct lldb_private *lldb) connect to the database */ static int lldb_connect(struct ldb_context *ldb, - const char *url, - unsigned int flags, + const char *url, + unsigned int flags, const char *options[], struct ldb_module **_module) { @@ -790,7 +844,6 @@ static int lldb_connect(struct ldb_context *ldb, talloc_set_name_const(module, "ldb_ldap backend"); module->ldb = ldb; module->prev = module->next = NULL; - module->private_data = NULL; module->ops = &lldb_ops; lldb = talloc(module, struct lldb_private); @@ -799,7 +852,6 @@ static int lldb_connect(struct ldb_context *ldb, goto failed; } module->private_data = lldb; - lldb->module = module; lldb->ldap = NULL; ret = ldap_initialize(&lldb->ldap, url); diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c index b3f639dc67..fafbb63b0a 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.c +++ b/source4/lib/ldb/ldb_map/ldb_map.c @@ -3,6 +3,7 @@ Copyright (C) Jelmer Vernooij 2005 Copyright (C) Martin Kuehl 2006 + Copyright (C) Simo Sorce 2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -106,69 +107,23 @@ const struct ldb_map_context *map_get_context(struct ldb_module *module) } /* Create a generic request context. */ -static struct map_context *map_init_context(struct ldb_handle *h, struct ldb_request *req) +struct map_context *map_init_context(struct ldb_module *module, + struct ldb_request *req) { struct map_context *ac; - ac = talloc_zero(h, struct map_context); + ac = talloc_zero(req, struct map_context); if (ac == NULL) { - map_oom(h->module); + ldb_set_errstring(module->ldb, "Out of Memory"); return NULL; } - ac->module = h->module; - ac->orig_req = req; + ac->module = module; + ac->req = req; return ac; } -/* Create a search request context. */ -struct map_search_context *map_init_search_context(struct map_context *ac, struct ldb_reply *ares) -{ - struct map_search_context *sc; - - sc = talloc_zero(ac, struct map_search_context); - if (sc == NULL) { - map_oom(ac->module); - return NULL; - } - - sc->ac = ac; - sc->local_res = NULL; - sc->remote_res = ares; - - return sc; -} - -/* Create a request context and handle. */ -struct ldb_handle *map_init_handle(struct ldb_request *req, struct ldb_module *module) -{ - struct map_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - map_oom(module); - return NULL; - } - - h->module = module; - - ac = map_init_context(h, req); - if (ac == NULL) { - talloc_free(h); - return NULL; - } - - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - return h; -} - - /* Dealing with DNs for different partitions * ========================================= */ @@ -888,113 +843,52 @@ static int map_objectclass_convert_operator(struct ldb_module *module, void *mem /* Auxiliary request construction * ============================== */ -/* Store the DN of a single search result in context. */ -static int map_search_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) -{ - struct map_context *ac; - - if (context == NULL || ares == NULL) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); - return LDB_ERR_OPERATIONS_ERROR; - } - - ac = talloc_get_type(context, struct map_context); - - /* We are interested only in the single reply */ - if (ares->type != LDB_REPLY_ENTRY) { - talloc_free(ares); - return LDB_SUCCESS; - } - - /* We have already found a remote DN */ - if (ac->local_dn) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "Too many results to base search")); - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - - /* Store local DN */ - ac->local_dn = ares->message->dn; - - return LDB_SUCCESS; -} - /* Build a request to search a record by its DN. */ -struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_search_callback callback) +struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_map_callback_t callback) { + const struct ldb_parse_tree *search_tree; struct ldb_request *req; - - req = talloc_zero(ac, struct ldb_request); - if (req == NULL) { - map_oom(ac->module); - return NULL; - } - - req->operation = LDB_SEARCH; - req->op.search.base = dn; - req->op.search.scope = LDB_SCOPE_BASE; - req->op.search.attrs = attrs; + int ret; if (tree) { - req->op.search.tree = tree; + search_tree = tree; } else { - req->op.search.tree = ldb_parse_tree(req, NULL); - if (req->op.search.tree == NULL) { - talloc_free(req); + search_tree = ldb_parse_tree(ac, NULL); + if (search_tree == NULL) { return NULL; } } - req->controls = NULL; - req->context = context; - req->callback = callback; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, req); - - return req; -} - -/* Build a request to search the local record by its DN. */ -struct ldb_request *map_search_self_req(struct map_context *ac, struct ldb_dn *dn) -{ - /* attrs[] is returned from this function in - * ac->search_req->op.search.attrs, so it must be static, as - * otherwise the compiler can put it on the stack */ - static const char * const attrs[] = { IS_MAPPED, NULL }; - struct ldb_parse_tree *tree; - - /* Limit search to records with 'IS_MAPPED' present */ - /* TODO: `tree = ldb_parse_tree(ac, IS_MAPPED);' won't do. */ - tree = talloc_zero(ac, struct ldb_parse_tree); - if (tree == NULL) { - map_oom(ac->module); + ret = ldb_build_search_req_ex(&req, ac->module->ldb, ac, + dn, LDB_SCOPE_BASE, + search_tree, attrs, + NULL, + context, callback, + ac->req); + if (ret != LDB_SUCCESS) { return NULL; } - tree->operation = LDB_OP_PRESENT; - tree->u.present.attr = talloc_strdup(tree, IS_MAPPED); - - return map_search_base_req(ac, dn, attrs, tree, ac, map_search_self_callback); + return req; } /* Build a request to update the 'IS_MAPPED' attribute */ -struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *olddn, struct ldb_dn *newdn) +struct ldb_request *map_build_fixup_req(struct map_context *ac, + struct ldb_dn *olddn, + struct ldb_dn *newdn, + void *context, + ldb_map_callback_t callback) { struct ldb_request *req; struct ldb_message *msg; const char *dn; - - /* Prepare request */ - req = talloc_zero(ac, struct ldb_request); - if (req == NULL) { - map_oom(ac->module); - return NULL; - } + int ret; /* Prepare message */ - msg = ldb_msg_new(req); + msg = ldb_msg_new(ac); if (msg == NULL) { map_oom(ac->module); - goto failed; + return NULL; } /* Update local 'IS_MAPPED' to the new remote DN */ @@ -1010,193 +904,22 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *o goto failed; } - req->operation = LDB_MODIFY; - req->op.mod.message = msg; - req->controls = NULL; - req->handle = NULL; - req->context = NULL; - req->callback = NULL; + /* Prepare request */ + ret = ldb_build_mod_req(&req, ac->module->ldb, + ac, msg, NULL, + context, callback, + ac->req); + if (ret != LDB_SUCCESS) { + goto failed; + } + talloc_steal(req, msg); return req; - failed: - talloc_free(req); + talloc_free(msg); return NULL; } - -/* Asynchronous call structure - * =========================== */ - -/* Figure out which request is currently pending. */ -static struct ldb_request *map_get_req(struct map_context *ac) -{ - switch (ac->step) { - case MAP_SEARCH_SELF_MODIFY: - case MAP_SEARCH_SELF_DELETE: - case MAP_SEARCH_SELF_RENAME: - return ac->search_req; - - case MAP_ADD_REMOTE: - case MAP_MODIFY_REMOTE: - case MAP_DELETE_REMOTE: - case MAP_RENAME_REMOTE: - return ac->remote_req; - - case MAP_RENAME_FIXUP: - return ac->down_req; - - case MAP_ADD_LOCAL: - case MAP_MODIFY_LOCAL: - case MAP_DELETE_LOCAL: - case MAP_RENAME_LOCAL: - return ac->local_req; - - case MAP_SEARCH_REMOTE: - /* Can't happen */ - break; - } - - return NULL; /* unreachable; silences a warning */ -} - -typedef int (*map_next_function)(struct ldb_handle *handle); - -/* Figure out the next request to run. */ -static map_next_function map_get_next(struct map_context *ac) -{ - switch (ac->step) { - case MAP_SEARCH_REMOTE: - return NULL; - - case MAP_ADD_LOCAL: - return map_add_do_remote; - case MAP_ADD_REMOTE: - return NULL; - - case MAP_SEARCH_SELF_MODIFY: - return map_modify_do_local; - case MAP_MODIFY_LOCAL: - return map_modify_do_remote; - case MAP_MODIFY_REMOTE: - return NULL; - - case MAP_SEARCH_SELF_DELETE: - return map_delete_do_local; - case MAP_DELETE_LOCAL: - return map_delete_do_remote; - case MAP_DELETE_REMOTE: - return NULL; - - case MAP_SEARCH_SELF_RENAME: - return map_rename_do_local; - case MAP_RENAME_LOCAL: - return map_rename_do_fixup; - case MAP_RENAME_FIXUP: - return map_rename_do_remote; - case MAP_RENAME_REMOTE: - return NULL; - } - - return NULL; /* unreachable; silences a warning */ -} - -/* Wait for the current pending request to finish and continue with the next. */ -static int map_wait_next(struct ldb_handle *handle) -{ - struct map_context *ac; - struct ldb_request *req; - map_next_function next; - int ret; - - if (handle == NULL || handle->private_data == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct map_context); - - if (ac->step == MAP_SEARCH_REMOTE) { - int i; - for (i = 0; i < ac->num_searches; i++) { - req = ac->search_reqs[i]; - ret = ldb_wait(req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (req->handle->status != LDB_SUCCESS) { - handle->status = req->handle->status; - goto done; - } - if (req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - } - } else { - - req = map_get_req(ac); - - ret = ldb_wait(req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (req->handle->status != LDB_SUCCESS) { - handle->status = req->handle->status; - goto done; - } - if (req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - next = map_get_next(ac); - if (next) { - return next(handle); - } - } - - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - -/* Wait for all current pending requests to finish. */ -static int map_wait_all(struct ldb_handle *handle) -{ - int ret; - - while (handle->state != LDB_ASYNC_DONE) { - ret = map_wait_next(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; -} - -/* Wait for pending requests to finish. */ -int map_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - if (type == LDB_WAIT_ALL) { - return map_wait_all(handle); - } else { - return map_wait_next(handle); - } -} - - /* Module initialization * ===================== */ @@ -1256,7 +979,7 @@ static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(module->ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL); talloc_free(dn); if (ret != LDB_SUCCESS) { return ret; diff --git a/source4/lib/ldb/ldb_map/ldb_map.h b/source4/lib/ldb/ldb_map/ldb_map.h index e40bb9cd7e..7f92c15b98 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.h +++ b/source4/lib/ldb/ldb_map/ldb_map.h @@ -160,14 +160,12 @@ int map_search(struct ldb_module *module, struct ldb_request *req); int map_rename(struct ldb_module *module, struct ldb_request *req); int map_delete(struct ldb_module *module, struct ldb_request *req); int map_modify(struct ldb_module *module, struct ldb_request *req); -int map_wait(struct ldb_handle *handle, enum ldb_wait_type type); #define LDB_MAP_OPS \ .add = map_add, \ .modify = map_modify, \ .del = map_delete, \ .rename = map_rename, \ - .search = map_search, \ - .wait = map_wait, + .search = map_search, #endif /* __LDB_MAP_H__ */ diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c index 7fc3ac4ed5..96605f23eb 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c @@ -3,6 +3,7 @@ Copyright (C) Jelmer Vernooij 2005 Copyright (C) Martin Kuehl 2006 + Copyright (C) Simo Sorce 2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -178,51 +179,181 @@ static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *loca } -/* Inbound requests: add, modify, rename, delete - * ============================================= */ +static int map_add_do_local(struct map_context *ac); +static int map_modify_do_local(struct map_context *ac); +static int map_delete_do_local(struct map_context *ac); +static int map_rename_do_local(struct map_context *ac); +static int map_rename_do_fixup(struct map_context *ac); +static int map_rename_local_callback(struct ldb_request *req, + struct ldb_reply *ares); -/* Add the remote record. */ -int map_add_do_remote(struct ldb_handle *handle) + +/***************************************************************************** + * COMMON INBOUND functions +*****************************************************************************/ + +/* Store the DN of a single search result in context. */ +static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *ares) { struct map_context *ac; + int ret; - ac = talloc_get_type(handle->private_data, struct map_context); + ac = talloc_get_type(req->context, struct map_context); - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ac->step = MAP_ADD_REMOTE; + /* We are interested only in the single reply */ + switch(ares->type) { + case LDB_REPLY_ENTRY: + /* We have already found a remote DN */ + if (ac->local_dn) { + ldb_set_errstring(ac->module->ldb, + "Too many results!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; + /* Store local DN */ + ac->local_dn = talloc_steal(ac, ares->message->dn); + break; - return ldb_next_remote_request(ac->module, ac->remote_req); + case LDB_REPLY_DONE: + + switch (ac->req->operation) { + case LDB_MODIFY: + ret = map_modify_do_local(ac); + break; + case LDB_DELETE: + ret = map_delete_do_local(ac); + break; + case LDB_RENAME: + ret = map_rename_do_local(ac); + break; + default: + /* if we get here we have definitely a problem */ + ret = LDB_ERR_OPERATIONS_ERROR; + } + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + default: + /* ignore referrals */ + break; + } + + talloc_free(ares); + return LDB_SUCCESS; } -/* Add the local record. */ -int map_add_do_local(struct ldb_handle *handle) +/* Build a request to search the local record by its DN. */ +static int map_search_self_req(struct ldb_request **req, + struct map_context *ac, + struct ldb_dn *dn) +{ + /* attrs[] is returned from this function in + * ac->search_req->op.search.attrs, so it must be static, as + * otherwise the compiler can put it on the stack */ + static const char * const attrs[] = { IS_MAPPED, NULL }; + struct ldb_parse_tree *tree; + + /* Limit search to records with 'IS_MAPPED' present */ + tree = ldb_parse_tree(ac, "(" IS_MAPPED "=*)"); + if (tree == NULL) { + map_oom(ac->module); + return LDB_ERR_OPERATIONS_ERROR; + } + + *req = map_search_base_req(ac, dn, attrs, tree, + ac, map_search_self_callback); + if (*req == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + return LDB_SUCCESS; +} + +static int map_op_local_callback(struct ldb_request *req, + struct ldb_reply *ares) { struct map_context *ac; + int ret; - ac = talloc_get_type(handle->private_data, struct map_context); + ac = talloc_get_type(req->context, struct map_context); - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ac->step = MAP_ADD_LOCAL; + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; + /* Do the remote request. */ + ret = ldb_next_remote_request(ac->module, ac->remote_req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } - return ldb_next_request(ac->module, ac->local_req); + return LDB_SUCCESS; } +static int map_op_remote_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct map_context *ac; + + ac = talloc_get_type(req->context, struct map_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); +} + + +/***************************************************************************** + * ADD operations +*****************************************************************************/ + + /* Add a record. */ int map_add(struct ldb_module *module, struct ldb_request *req) { const struct ldb_message *msg = req->op.add.message; - struct ldb_handle *h; struct map_context *ac; - struct ldb_message *local, *remote; + struct ldb_message *remote_msg; const char *dn; + int ret; /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { @@ -240,141 +371,88 @@ int map_add(struct ldb_module *module, struct ldb_request *req) } /* Prepare context and handle */ - h = map_init_handle(req, module); - if (h == NULL) { + ac = map_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct map_context); - - /* Prepare the local operation */ - ac->local_req = talloc(ac, struct ldb_request); - if (ac->local_req == NULL) { - goto oom; - } - *(ac->local_req) = *req; /* copy the request */ - - ac->local_req->context = NULL; - ac->local_req->callback = NULL; - - /* Prepare the remote operation */ - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { - goto oom; - } - - *(ac->remote_req) = *req; /* copy the request */ - - ac->remote_req->context = NULL; - ac->remote_req->callback = NULL; /* Prepare the local message */ - local = ldb_msg_new(ac->local_req); - if (local == NULL) { - goto oom; + ac->local_msg = ldb_msg_new(ac); + if (ac->local_msg == NULL) { + map_oom(module); + return LDB_ERR_OPERATIONS_ERROR; } - local->dn = msg->dn; + ac->local_msg->dn = msg->dn; /* Prepare the remote message */ - remote = ldb_msg_new(ac->remote_req); - if (remote == NULL) { - goto oom; + remote_msg = ldb_msg_new(ac); + if (remote_msg == NULL) { + map_oom(module); + return LDB_ERR_OPERATIONS_ERROR; } - remote->dn = ldb_dn_map_local(ac->module, remote, msg->dn); + remote_msg->dn = ldb_dn_map_local(ac->module, remote_msg, msg->dn); /* Split local from remote message */ - ldb_msg_partition(module, local, remote, msg); - ac->local_req->op.add.message = local; - ac->remote_req->op.add.message = remote; + ldb_msg_partition(module, ac->local_msg, remote_msg, msg); + + /* Prepare the remote operation */ + ret = ldb_build_add_req(&ac->remote_req, module->ldb, + ac, remote_msg, + req->controls, + ac, map_op_remote_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - if ((local->num_elements == 0) || (!map_check_local_db(ac->module))) { + if ((ac->local_msg->num_elements == 0) || + ( ! map_check_local_db(ac->module))) { /* No local data or db, just run the remote request */ - talloc_free(ac->local_req); - req->handle = h; /* return our own handle to deal with this call */ - return map_add_do_remote(h); + return ldb_next_remote_request(ac->module, ac->remote_req); } /* Store remote DN in 'IS_MAPPED' */ /* TODO: use GUIDs here instead */ - dn = ldb_dn_alloc_linearized(local, remote->dn); - if (ldb_msg_add_string(local, IS_MAPPED, dn) != 0) { - goto failed; + dn = ldb_dn_alloc_linearized(ac->local_msg, remote_msg->dn); + if (ldb_msg_add_string(ac->local_msg, IS_MAPPED, dn) != 0) { + return LDB_ERR_OPERATIONS_ERROR; } - req->handle = h; /* return our own handle to deal with this call */ - return map_add_do_local(h); - -oom: - map_oom(module); -failed: - talloc_free(h); - return LDB_ERR_OPERATIONS_ERROR; -} - -/* Modify the remote record. */ -int map_modify_do_remote(struct ldb_handle *handle) -{ - struct map_context *ac; - - ac = talloc_get_type(handle->private_data, struct map_context); - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req); - - ac->step = MAP_MODIFY_REMOTE; - - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; - - return ldb_next_remote_request(ac->module, ac->remote_req); + return map_add_do_local(ac); } -/* Modify the local record. */ -int map_modify_do_local(struct ldb_handle *handle) +/* Add the local record. */ +static int map_add_do_local(struct map_context *ac) { - struct map_context *ac; - struct ldb_message *msg; - char *dn; - - ac = talloc_get_type(handle->private_data, struct map_context); - - if (ac->local_dn == NULL) { - /* No local record present, add it instead */ - msg = discard_const_p(struct ldb_message, ac->local_req->op.mod.message); - - /* Add local 'IS_MAPPED' */ - /* TODO: use GUIDs here instead */ - if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD, NULL) != 0) { - return LDB_ERR_OPERATIONS_ERROR; - } - dn = ldb_dn_alloc_linearized(msg, ac->remote_req->op.mod.message->dn); - if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0) { - return LDB_ERR_OPERATIONS_ERROR; - } + struct ldb_request *local_req; + int ret; - /* Turn request into 'add' */ - ac->local_req->operation = LDB_ADD; - ac->local_req->op.add.message = msg; - /* TODO: Could I just leave msg in there? I think so, - * but it looks clearer this way. */ + /* Prepare the local operation */ + ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ac->local_msg, + ac->req->controls, + ac, + map_op_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); - - ac->step = MAP_MODIFY_LOCAL; - - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; - - return ldb_next_request(ac->module, ac->local_req); + return ldb_next_request(ac->module, local_req); } +/***************************************************************************** + * MODIFY operations +*****************************************************************************/ + /* Modify a record. */ int map_modify(struct ldb_module *module, struct ldb_request *req) { const struct ldb_message *msg = req->op.mod.message; - struct ldb_handle *h; + struct ldb_request *search_req; + struct ldb_message *remote_msg; struct map_context *ac; - struct ldb_message *local, *remote; + int ret; /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { @@ -395,257 +473,200 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) } /* Prepare context and handle */ - h = map_init_handle(req, module); - if (h == NULL) { + ac = map_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct map_context); - - /* Prepare the local operation */ - ac->local_req = talloc(ac, struct ldb_request); - if (ac->local_req == NULL) { - goto oom; - } - - *(ac->local_req) = *req; /* copy the request */ - - ac->local_req->context = NULL; - ac->local_req->callback = NULL; - - /* Prepare the remote operation */ - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { - goto oom; - } - - *(ac->remote_req) = *req; /* copy the request */ - - ac->remote_req->context = NULL; - ac->remote_req->callback = NULL; /* Prepare the local message */ - local = ldb_msg_new(ac->local_req); - if (local == NULL) { - goto oom; + ac->local_msg = ldb_msg_new(ac); + if (ac->local_msg == NULL) { + map_oom(module); + return LDB_ERR_OPERATIONS_ERROR; } - local->dn = msg->dn; + ac->local_msg->dn = msg->dn; /* Prepare the remote message */ - remote = ldb_msg_new(ac->remote_req); - if (remote == NULL) { - goto oom; + remote_msg = ldb_msg_new(ac->remote_req); + if (remote_msg == NULL) { + map_oom(module); + return LDB_ERR_OPERATIONS_ERROR; } - remote->dn = ldb_dn_map_local(ac->module, remote, msg->dn); + remote_msg->dn = ldb_dn_map_local(ac->module, remote_msg, msg->dn); /* Split local from remote message */ - ldb_msg_partition(module, local, remote, msg); - ac->local_req->op.mod.message = local; - ac->remote_req->op.mod.message = remote; + ldb_msg_partition(module, ac->local_msg, remote_msg, msg); + + /* Prepare the remote operation */ + ret = ldb_build_mod_req(&ac->remote_req, module->ldb, + ac, remote_msg, + req->controls, + ac, map_op_remote_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - if ((local->num_elements == 0) || (!map_check_local_db(ac->module))) { + if ((ac->local_msg->num_elements == 0) || + ( ! map_check_local_db(ac->module))) { /* No local data or db, just run the remote request */ - talloc_free(ac->local_req); - req->handle = h; /* return our own handle to deal with this call */ - return map_modify_do_remote(h); + return ldb_next_remote_request(ac->module, ac->remote_req); } /* prepare the search operation */ - ac->search_req = map_search_self_req(ac, msg->dn); - if (ac->search_req == NULL) { - goto failed; + ret = map_search_self_req(&search_req, ac, msg->dn); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - ac->step = MAP_SEARCH_SELF_MODIFY; - - req->handle = h; /* return our own handle to deal with this call */ - return ldb_next_request(module, ac->search_req); - -oom: - map_oom(module); -failed: - talloc_free(h); - return LDB_ERR_OPERATIONS_ERROR; -} - -/* Delete the remote record. */ -int map_delete_do_remote(struct ldb_handle *handle) -{ - struct map_context *ac; - - ac = talloc_get_type(handle->private_data, struct map_context); - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req); - - ac->step = MAP_DELETE_REMOTE; - - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; - - return ldb_next_remote_request(ac->module, ac->remote_req); + return ldb_next_request(module, search_req); } -/* Delete the local record. */ -int map_delete_do_local(struct ldb_handle *handle) +/* Modify the local record. */ +static int map_modify_do_local(struct map_context *ac) { - struct map_context *ac; - - ac = talloc_get_type(handle->private_data, struct map_context); + struct ldb_request *local_req; + char *dn; + int ret; - /* No local record, continue remotely */ if (ac->local_dn == NULL) { - return map_delete_do_remote(handle); - } - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); - - ac->step = MAP_DELETE_LOCAL; + /* No local record present, add it instead */ + /* Add local 'IS_MAPPED' */ + /* TODO: use GUIDs here instead */ + if (ldb_msg_add_empty(ac->local_msg, IS_MAPPED, + LDB_FLAG_MOD_ADD, NULL) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + dn = ldb_dn_alloc_linearized(ac->local_msg, + ac->remote_req->op.mod.message->dn); + if (ldb_msg_add_string(ac->local_msg, IS_MAPPED, dn) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; + /* Prepare the local operation */ + ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ac->local_msg, + ac->req->controls, + ac, + map_op_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + } else { + /* Prepare the local operation */ + ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac, + ac->local_msg, + ac->req->controls, + ac, + map_op_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + } - return ldb_next_request(ac->module, ac->local_req); + return ldb_next_request(ac->module, local_req); } +/***************************************************************************** + * DELETE operations +*****************************************************************************/ + /* Delete a record. */ int map_delete(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; + struct ldb_request *search_req; struct map_context *ac; + int ret; /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.del.dn)) { return ldb_next_request(module, req); } - /* No mapping requested (perhaps no DN mapping specified), skip to next module */ + /* No mapping requested (perhaps no DN mapping specified). + * Skip to next module */ if (!ldb_dn_check_local(module, req->op.del.dn)) { return ldb_next_request(module, req); } /* Prepare context and handle */ - h = map_init_handle(req, module); - if (h == NULL) { + ac = map_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct map_context); - - /* Prepare the local operation */ - ac->local_req = talloc(ac, struct ldb_request); - if (ac->local_req == NULL) { - goto oom; - } - - *(ac->local_req) = *req; /* copy the request */ - ac->local_req->op.del.dn = req->op.del.dn; - - ac->local_req->context = NULL; - ac->local_req->callback = NULL; /* Prepare the remote operation */ - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { - goto oom; + ret = ldb_build_del_req(&ac->remote_req, module->ldb, ac, + ldb_dn_map_local(module, ac, req->op.del.dn), + req->controls, + ac, + map_op_remote_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - *(ac->remote_req) = *req; /* copy the request */ - ac->remote_req->op.del.dn = ldb_dn_map_local(module, ac->remote_req, req->op.del.dn); - /* No local db, just run the remote request */ if (!map_check_local_db(ac->module)) { - req->handle = h; /* return our own handle to deal with this call */ - return map_delete_do_remote(h); + /* Do the remote request. */ + return ldb_next_remote_request(ac->module, ac->remote_req); } - ac->remote_req->context = NULL; - ac->remote_req->callback = NULL; - /* Prepare the search operation */ - ac->search_req = map_search_self_req(ac, req->op.del.dn); - if (ac->search_req == NULL) { - goto failed; + ret = map_search_self_req(&search_req, ac, req->op.del.dn); + if (ret != LDB_SUCCESS) { + map_oom(module); + return LDB_ERR_OPERATIONS_ERROR; } - req->handle = h; /* return our own handle to deal with this call */ - - ac->step = MAP_SEARCH_SELF_DELETE; - - return ldb_next_request(module, ac->search_req); - -oom: - map_oom(module); -failed: - talloc_free(h); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_next_request(module, search_req); } -/* Rename the remote record. */ -int map_rename_do_remote(struct ldb_handle *handle) -{ - struct map_context *ac; - - ac = talloc_get_type(handle->private_data, struct map_context); - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req); - - ac->step = MAP_RENAME_REMOTE; - - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; - - return ldb_next_remote_request(ac->module, ac->remote_req); -} - -/* Update the local 'IS_MAPPED' attribute. */ -int map_rename_do_fixup(struct ldb_handle *handle) -{ - struct map_context *ac; - - ac = talloc_get_type(handle->private_data, struct map_context); - - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->down_req); - - ac->step = MAP_RENAME_FIXUP; - - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; - - return ldb_next_request(ac->module, ac->down_req); -} - -/* Rename the local record. */ -int map_rename_do_local(struct ldb_handle *handle) +/* Delete the local record. */ +static int map_delete_do_local(struct map_context *ac) { - struct map_context *ac; - - ac = talloc_get_type(handle->private_data, struct map_context); + struct ldb_request *local_req; + int ret; /* No local record, continue remotely */ if (ac->local_dn == NULL) { - return map_rename_do_remote(handle); + /* Do the remote request. */ + return ldb_next_remote_request(ac->module, ac->remote_req); } - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); - - ac->step = MAP_RENAME_LOCAL; - - handle->state = LDB_ASYNC_INIT; - handle->status = LDB_SUCCESS; - - return ldb_next_request(ac->module, ac->local_req); + /* Prepare the local operation */ + ret = ldb_build_del_req(&local_req, ac->module->ldb, ac, + ac->req->op.del.dn, + ac->req->controls, + ac, + map_op_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } + return ldb_next_request(ac->module, local_req); } +/***************************************************************************** + * RENAME operations +*****************************************************************************/ + /* Rename a record. */ int map_rename(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; + struct ldb_request *search_req; struct map_context *ac; + int ret; /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.rename.olddn)) { return ldb_next_request(module, req); } - /* No mapping requested (perhaps no DN mapping specified), skip to next module */ + /* No mapping requested (perhaps no DN mapping specified). + * Skip to next module */ if ((!ldb_dn_check_local(module, req->op.rename.olddn)) && (!ldb_dn_check_local(module, req->op.rename.newdn))) { return ldb_next_request(module, req); @@ -658,66 +679,113 @@ int map_rename(struct ldb_module *module, struct ldb_request *req) } /* Prepare context and handle */ - h = map_init_handle(req, module); - if (h == NULL) { + ac = map_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct map_context); - /* Prepare the local operation */ - ac->local_req = talloc(ac, struct ldb_request); - if (ac->local_req == NULL) { - goto oom; + /* Prepare the remote operation */ + ret = ldb_build_rename_req(&ac->remote_req, module->ldb, ac, + ldb_dn_map_local(module, ac, req->op.rename.olddn), + ldb_dn_map_local(module, ac, req->op.rename.newdn), + req->controls, + ac, map_op_remote_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - *(ac->local_req) = *req; /* copy the request */ - ac->local_req->op.rename.olddn = req->op.rename.olddn; - ac->local_req->op.rename.newdn = req->op.rename.newdn; + /* No local db, just run the remote request */ + if (!map_check_local_db(ac->module)) { + /* Do the remote request. */ + return ldb_next_remote_request(ac->module, ac->remote_req); + } - ac->local_req->context = NULL; - ac->local_req->callback = NULL; + /* Prepare the search operation */ + ret = map_search_self_req(&search_req, ac, req->op.rename.olddn); + if (ret != LDB_SUCCESS) { + map_oom(module); + return LDB_ERR_OPERATIONS_ERROR; + } - /* Prepare the remote operation */ - ac->remote_req = talloc(ac, struct ldb_request); - if (ac->remote_req == NULL) { - goto oom; + return ldb_next_request(module, search_req); +} + +/* Rename the local record. */ +static int map_rename_do_local(struct map_context *ac) +{ + struct ldb_request *local_req; + int ret; + + /* No local record, continue remotely */ + if (ac->local_dn == NULL) { + /* Do the remote request. */ + return ldb_next_remote_request(ac->module, ac->remote_req); } - *(ac->remote_req) = *req; /* copy the request */ - ac->remote_req->op.rename.olddn = ldb_dn_map_local(module, ac->remote_req, req->op.rename.olddn); - ac->remote_req->op.rename.newdn = ldb_dn_map_local(module, ac->remote_req, req->op.rename.newdn); + /* Prepare the local operation */ + ret = ldb_build_rename_req(&local_req, ac->module->ldb, ac, + ac->req->op.rename.olddn, + ac->req->op.rename.newdn, + ac->req->controls, + ac, + map_rename_local_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - ac->remote_req->context = NULL; - ac->remote_req->callback = NULL; + return ldb_next_request(ac->module, local_req); +} - /* No local db, just run the remote request */ - if (!map_check_local_db(ac->module)) { - req->handle = h; /* return our own handle to deal with this call */ - return map_rename_do_remote(h); +static int map_rename_local_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct map_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct map_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - /* Prepare the fixup operation */ - /* TODO: use GUIDs here instead -- or skip it when GUIDs are used. */ - ac->down_req = map_build_fixup_req(ac, req->op.rename.newdn, ac->remote_req->op.rename.newdn); - if (ac->down_req == NULL) { - goto failed; + if (ares->type != LDB_REPLY_DONE) { + ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - /* Prepare the search operation */ - ac->search_req = map_search_self_req(ac, req->op.rename.olddn); - if (ac->search_req == NULL) { - goto failed; + /* proceed with next step */ + ret = map_rename_do_fixup(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - req->handle = h; /* return our own handle to deal with this call */ + return LDB_SUCCESS; +} - ac->step = MAP_SEARCH_SELF_RENAME; +/* Update the local 'IS_MAPPED' attribute. */ +static int map_rename_do_fixup(struct map_context *ac) +{ + struct ldb_request *local_req; - return ldb_next_request(module, ac->search_req); + /* Prepare the fixup operation */ + /* TODO: use GUIDs here instead -- or skip it when GUIDs are used. */ + local_req = map_build_fixup_req(ac, + ac->req->op.rename.newdn, + ac->remote_req->op.rename.newdn, + ac, + map_op_local_callback); + if (local_req == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } -oom: - map_oom(module); -failed: - talloc_free(h); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_next_request(ac->module, local_req); } diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c index fbc097f313..5f524a8be3 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c @@ -4,6 +4,7 @@ Copyright (C) Jelmer Vernooij 2005 Copyright (C) Martin Kuehl 2006 Copyright (C) Andrew Bartlett 2006 + Copyright (C) Simo Sorce 2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -905,7 +906,11 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx, /* Split subtrees that query attributes in the local partition from * those that query the remote partition. */ -static int ldb_parse_tree_partition(struct ldb_module *module, void *local_ctx, void *remote_ctx, struct ldb_parse_tree **local_tree, struct ldb_parse_tree **remote_tree, const struct ldb_parse_tree *tree) +static int ldb_parse_tree_partition(struct ldb_module *module, + void *mem_ctx, + struct ldb_parse_tree **local_tree, + struct ldb_parse_tree **remote_tree, + const struct ldb_parse_tree *tree) { int ret; @@ -918,13 +923,13 @@ static int ldb_parse_tree_partition(struct ldb_module *module, void *local_ctx, } /* Generate local tree */ - ret = map_subtree_select_local(module, local_ctx, local_tree, tree); + ret = map_subtree_select_local(module, mem_ctx, local_tree, tree); if (ret) { return ret; } /* Generate remote tree */ - ret = map_subtree_collect_remote(module, remote_ctx, remote_tree, tree); + ret = map_subtree_collect_remote(module, mem_ctx, remote_tree, tree); if (ret) { talloc_free(*local_tree); return ret; @@ -1008,24 +1013,46 @@ oom: /* Outbound requests: search * ========================= */ -/* Pass a merged search result up the callback chain. */ -int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, struct ldb_reply *ares) +static int map_remote_search_callback(struct ldb_request *req, + struct ldb_reply *ares); +static int map_local_merge_callback(struct ldb_request *req, + struct ldb_reply *ares); +static int map_search_local(struct map_context *ac); + +static int map_save_entry(struct map_context *ac, struct ldb_reply *ares) { - int i; + struct map_reply *mr; - /* No callback registered, stop */ - if (req->callback == NULL) { - return LDB_SUCCESS; + mr = talloc_zero(ac, struct map_reply); + if (mr == NULL) { + map_oom(ac->module); + return LDB_ERR_OPERATIONS_ERROR; } - - /* Only records need special treatment */ - if (ares->type != LDB_REPLY_ENTRY) { - return req->callback(ldb, req->context, ares); + mr->remote = talloc_steal(mr, ares); + if (ac->r_current) { + ac->r_current->next = mr; + } else { + /* first entry */ + ac->r_list = mr; } + ac->r_current = mr; + + return LDB_SUCCESS; +} + +/* Pass a merged search result up the callback chain. */ +int map_return_entry(struct map_context *ac, struct ldb_reply *ares) +{ + struct ldb_message_element *el; + const char * const *attrs; + int i; /* Merged result doesn't match original query, skip */ - if (!ldb_match_msg(ldb, ares->message, req->op.search.tree, req->op.search.base, req->op.search.scope)) { - ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: " + if (!ldb_match_msg(ac->module->ldb, ares->message, + ac->req->op.search.tree, + ac->req->op.search.base, + ac->req->op.search.scope)) { + ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, "ldb_map: " "Skipping record '%s': " "doesn't match original search\n", ldb_dn_get_linearized(ares->message->dn)); @@ -1033,10 +1060,16 @@ int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, stru } /* Limit result to requested attrs */ - if ((req->op.search.attrs) && (!ldb_attr_in_list(req->op.search.attrs, "*"))) { - for (i = 0; i < ares->message->num_elements; ) { - struct ldb_message_element *el = &ares->message->elements[i]; - if (!ldb_attr_in_list(req->op.search.attrs, el->name)) { + if (ac->req->op.search.attrs && + (! ldb_attr_in_list(ac->req->op.search.attrs, "*"))) { + + attrs = ac->req->op.search.attrs; + i = 0; + + while (i < ares->message->num_elements) { + + el = &ares->message->elements[i]; + if ( ! ldb_attr_in_list(attrs, el->name)) { ldb_msg_remove_element(ares->message, el); } else { i++; @@ -1044,129 +1077,16 @@ int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, stru } } - return req->callback(ldb, req->context, ares); -} - -/* Merge the remote and local parts of a search result. */ -int map_local_merge_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) -{ - struct map_search_context *sc; - int ret; - - if (context == NULL || ares == NULL) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: " - "NULL Context or Result in `map_local_merge_callback`")); - return LDB_ERR_OPERATIONS_ERROR; - } - - sc = talloc_get_type(context, struct map_search_context); - - switch (ares->type) { - case LDB_REPLY_ENTRY: - /* We have already found a local record */ - if (sc->local_res) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: " - "Too many results to base search for local entry")); - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - - /* Store local result */ - sc->local_res = ares; - - /* Merge remote into local message */ - ret = ldb_msg_merge_local(sc->ac->module, ares->message, sc->remote_res->message); - if (ret) { - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - - return map_up_callback(ldb, sc->ac->orig_req, ares); - - case LDB_REPLY_DONE: - /* No local record found, continue with remote record */ - if (sc->local_res == NULL) { - return map_up_callback(ldb, sc->ac->orig_req, sc->remote_res); - } - return LDB_SUCCESS; - - default: - ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: " - "Unexpected result type in base search for local entry")); - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } -} - -/* Search the local part of a remote search result. */ -int map_remote_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) -{ - struct map_context *ac; - struct map_search_context *sc; - struct ldb_request *req; - int ret; - - if (context == NULL || ares == NULL) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "ldb_map: " - "NULL Context or Result in `map_remote_search_callback`")); - return LDB_ERR_OPERATIONS_ERROR; - } - - ac = talloc_get_type(context, struct map_context); - - /* It's not a record, stop searching */ - if (ares->type != LDB_REPLY_ENTRY) { - return map_up_callback(ldb, ac->orig_req, ares); - } - - /* Map result record into a local message */ - ret = map_reply_remote(ac, ares); - if (ret) { - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - - /* There is no local db, stop searching */ - if (!map_check_local_db(ac->module)) { - return map_up_callback(ldb, ac->orig_req, ares); - } - - /* Prepare local search context */ - sc = map_init_search_context(ac, ares); - if (sc == NULL) { - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - - /* Prepare local search request */ - /* TODO: use GUIDs here instead? */ - - ac->search_reqs = talloc_realloc(ac, ac->search_reqs, struct ldb_request *, ac->num_searches + 2); - if (ac->search_reqs == NULL) { - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - - ac->search_reqs[ac->num_searches] - = req = map_search_base_req(ac, ares->message->dn, - NULL, NULL, sc, map_local_merge_callback); - if (req == NULL) { - talloc_free(sc); - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; - } - ac->num_searches++; - ac->search_reqs[ac->num_searches] = NULL; - - return ldb_next_request(ac->module, req); + return ldb_module_send_entry(ac->req, ares->message); } /* Search a record. */ int map_search(struct ldb_module *module, struct ldb_request *req) { - struct ldb_handle *h; + struct ldb_parse_tree *remote_tree; + struct ldb_parse_tree *local_tree; + struct ldb_request *remote_req; struct map_context *ac; - struct ldb_parse_tree *local_tree, *remote_tree; int ret; const char *wildcard[] = { "*", NULL }; @@ -1176,8 +1096,9 @@ int map_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); /* Do not manipulate our control entries */ - if (ldb_dn_is_special(req->op.search.base)) + if (ldb_dn_is_special(req->op.search.base)) { return ldb_next_request(module, req); + } /* No mapping requested, skip to next module */ if ((req->op.search.base) && (!ldb_dn_check_local(module, req->op.search.base))) { @@ -1188,32 +1109,10 @@ int map_search(struct ldb_module *module, struct ldb_request *req) * targetting when there is no search base? */ /* Prepare context and handle */ - h = map_init_handle(req, module); - if (h == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - ac = talloc_get_type(h->private_data, struct map_context); - - ac->search_reqs = talloc_array(ac, struct ldb_request *, 2); - if (ac->search_reqs == NULL) { - talloc_free(h); + ac = map_init_context(module, req); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ac->num_searches = 1; - ac->search_reqs[1] = NULL; - - /* Prepare the remote operation */ - ac->search_reqs[0] = talloc(ac, struct ldb_request); - if (ac->search_reqs[0] == NULL) { - goto oom; - } - - *(ac->search_reqs[0]) = *req; /* copy the request */ - - ac->search_reqs[0]->handle = h; /* return our own handle to deal with this call */ - - ac->search_reqs[0]->context = ac; - ac->search_reqs[0]->callback = map_remote_search_callback; /* It is easier to deal with the two different ways of * expressing the wildcard in the same codepath */ @@ -1226,17 +1125,15 @@ int map_search(struct ldb_module *module, struct ldb_request *req) ret = map_attrs_collect_and_partition(module, ac, attrs, req->op.search.tree); if (ret) { - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } - ac->search_reqs[0]->op.search.attrs = ac->remote_attrs; - /* Split local from remote tree */ - ret = ldb_parse_tree_partition(module, ac, ac->search_reqs[0], - &local_tree, &remote_tree, + ret = ldb_parse_tree_partition(module, ac, + &local_tree, &remote_tree, req->op.search.tree); if (ret) { - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } if (((local_tree != NULL) && (remote_tree != NULL)) && @@ -1251,7 +1148,7 @@ int map_search(struct ldb_module *module, struct ldb_request *req) local_tree = talloc_zero(ac, struct ldb_parse_tree); if (local_tree == NULL) { map_oom(ac->module); - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } local_tree->operation = LDB_OP_PRESENT; @@ -1259,31 +1156,209 @@ int map_search(struct ldb_module *module, struct ldb_request *req) } if (remote_tree == NULL) { /* Construct default remote parse tree */ - remote_tree = ldb_parse_tree(ac->search_reqs[0], NULL); + remote_tree = ldb_parse_tree(ac, NULL); if (remote_tree == NULL) { - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } } ac->local_tree = local_tree; - ac->search_reqs[0]->op.search.tree = remote_tree; - ldb_set_timeout_from_prev_req(module->ldb, req, ac->search_reqs[0]); + /* Prepare the remote operation */ + ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + remote_tree, + ac->remote_attrs, + req->controls, + ac, map_remote_search_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; + return ldb_next_remote_request(module, remote_req); +} + +/* Now, search the local part of a remote search result. */ +static int map_remote_search_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct map_context *ac; + int ret; - ac->step = MAP_SEARCH_REMOTE; + ac = talloc_get_type(req->context, struct map_context); - ret = ldb_next_remote_request(module, ac->search_reqs[0]); - if (ret == LDB_SUCCESS) { - req->handle = h; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - return ret; -oom: - map_oom(module); -failed: - talloc_free(h); - return LDB_ERR_OPERATIONS_ERROR; + switch (ares->type) { + case LDB_REPLY_REFERRAL: + + /* ignore referrals */ + talloc_free(ares); + return LDB_SUCCESS; + + case LDB_REPLY_ENTRY: + + /* Map result record into a local message */ + ret = map_reply_remote(ac, ares); + if (ret) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + /* if we have no local db, then we can just return the reply to + * the upper layer, otherwise we must save it and process it + * when all replies ahve been gathered */ + if ( ! map_check_local_db(ac->module)) { + ret = map_return_entry(ac, ares); + } else { + ret = map_save_entry(ac,ares); + } + + if (ret != LDB_SUCCESS) { + talloc_free(ares); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + break; + + case LDB_REPLY_DONE: + + if ( ! map_check_local_db(ac->module)) { + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + } + + talloc_free(ares); + + /* reset the pointer to the start of the list */ + ac->r_current = ac->r_list; + + /* no entry just return */ + if (ac->r_current == NULL) { + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + } + + ret = map_search_local(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + } + + return LDB_SUCCESS; +} + +static int map_search_local(struct map_context *ac) +{ + struct ldb_request *search_req; + + if (ac->r_current == NULL || ac->r_current->remote == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + /* Prepare local search request */ + /* TODO: use GUIDs here instead? */ + search_req = map_search_base_req(ac, + ac->r_current->remote->message->dn, + NULL, NULL, + ac, map_local_merge_callback); + if (search_req == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + return ldb_next_request(ac->module, search_req); +} + +/* Merge the remote and local parts of a search result. */ +int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct map_context *ac; + int ret; + + ac = talloc_get_type(req->context, struct map_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: + /* We have already found a local record */ + if (ac->r_current->local) { + talloc_free(ares); + ldb_set_errstring(ac->module->ldb, "ldb_map: Too many results!"); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + /* Store local result */ + ac->r_current->local = talloc_steal(ac->r_current, ares); + + break; + + case LDB_REPLY_REFERRAL: + /* ignore referrals */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: + talloc_free(ares); + + /* No local record found, map and send remote record */ + if (ac->r_current->local != NULL) { + /* Merge remote into local message */ + ret = ldb_msg_merge_local(ac->module, + ac->r_current->local->message, + ac->r_current->remote->message); + if (ret == LDB_SUCCESS) { + ret = map_return_entry(ac, ac->r_current->local); + } + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + } else { + ret = map_return_entry(ac, ac->r_current->remote); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + } + + if (ac->r_current->next != NULL) { + ac->r_current = ac->r_current->next; + if (ac->r_current->remote->type == LDB_REPLY_ENTRY) { + ret = map_search_local(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + break; + } + } + + /* ok we are done with all search, finally it is time to + * finish operations for this module */ + return ldb_module_done(ac->req, + ac->r_current->remote->controls, + ac->r_current->remote->response, + ac->r_current->remote->error); + } + + return LDB_SUCCESS; } diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h index 58a9f2704e..0543ba71b9 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_private.h +++ b/source4/lib/ldb/ldb_map/ldb_map_private.h @@ -3,7 +3,7 @@ #define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); /* The type of search callback functions */ -typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct ldb_reply *); +typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *); /* The special DN from which the local and remote base DNs are fetched */ #define MAP_DN_NAME "@MAP" @@ -13,25 +13,17 @@ typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct ldb_repl /* Private data structures * ======================= */ +struct map_reply { + struct map_reply *next; + struct ldb_reply *remote; + struct ldb_reply *local; +}; + /* Context data for mapped requests */ struct map_context { - enum map_step { - MAP_SEARCH_REMOTE, - MAP_ADD_REMOTE, - MAP_ADD_LOCAL, - MAP_SEARCH_SELF_MODIFY, - MAP_MODIFY_REMOTE, - MAP_MODIFY_LOCAL, - MAP_SEARCH_SELF_DELETE, - MAP_DELETE_REMOTE, - MAP_DELETE_LOCAL, - MAP_SEARCH_SELF_RENAME, - MAP_RENAME_REMOTE, - MAP_RENAME_FIXUP, - MAP_RENAME_LOCAL - } step; struct ldb_module *module; + struct ldb_request *req; struct ldb_dn *local_dn; const struct ldb_parse_tree *local_tree; @@ -39,32 +31,20 @@ struct map_context { const char * const *remote_attrs; const char * const *all_attrs; - struct ldb_request *orig_req; - struct ldb_request *local_req; + struct ldb_message *local_msg; struct ldb_request *remote_req; - struct ldb_request *down_req; - struct ldb_request *search_req; - - /* for search, we may have a lot of contexts */ - int num_searches; - struct ldb_request **search_reqs; -}; -/* Context data for mapped search requests */ -struct map_search_context { - struct map_context *ac; - struct ldb_reply *local_res; - struct ldb_reply *remote_res; + struct map_reply *r_list; + struct map_reply *r_current; }; - /* Common operations * ================= */ /* The following definitions come from lib/ldb/modules/ldb_map.c */ const struct ldb_map_context *map_get_context(struct ldb_module *module); -struct map_search_context *map_init_search_context(struct map_context *ac, struct ldb_reply *ares); -struct ldb_handle *map_init_handle(struct ldb_request *req, struct ldb_module *module); +struct map_context *map_init_context(struct ldb_module *module, + struct ldb_request *req); int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request); @@ -86,25 +66,25 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn); struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn); -struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_search_callback callback); -struct ldb_request *map_search_self_req(struct map_context *ac, struct ldb_dn *dn); -struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *olddn, struct ldb_dn *newdn); - -int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *tree, const struct ldb_map_attribute *map); - -/* LDB Requests - * ============ */ - -/* The following definitions come from lib/ldb/modules/ldb_map_inbound.c */ -int map_add_do_remote(struct ldb_handle *handle); -int map_add_do_local(struct ldb_handle *handle); - -int map_modify_do_remote(struct ldb_handle *handle); -int map_modify_do_local(struct ldb_handle *handle); - -int map_delete_do_remote(struct ldb_handle *handle); -int map_delete_do_local(struct ldb_handle *handle); - -int map_rename_do_remote(struct ldb_handle *handle); -int map_rename_do_fixup(struct ldb_handle *handle); -int map_rename_do_local(struct ldb_handle *handle); +struct ldb_request *map_search_base_req(struct map_context *ac, + struct ldb_dn *dn, + const char * const *attrs, + const struct ldb_parse_tree *tree, + void *context, + ldb_map_callback_t callback); +struct ldb_request *map_build_fixup_req(struct map_context *ac, + struct ldb_dn *olddn, + struct ldb_dn *newdn, + void *context, + ldb_map_callback_t callback); +int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, + struct ldb_parse_tree **new, + const struct ldb_parse_tree *tree, + const struct ldb_map_attribute *map); +int map_return_fatal_error(struct ldb_request *req, + struct ldb_reply *ares); +int map_return_normal_error(struct ldb_request *req, + struct ldb_reply *ares, + int error); + +int map_return_entry(struct map_context *ac, struct ldb_reply *ares); diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index a0e63c8da1..be99c29d1e 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -44,51 +44,14 @@ struct lsqlite3_private { struct lsql_context { struct ldb_module *module; + struct ldb_request *req; /* search stuff */ long long current_eid; const char * const * attrs; struct ldb_reply *ares; - - /* async stuff */ - void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; -static struct ldb_handle *init_handle(struct lsqlite3_private *lsqlite3, - struct ldb_module *module, - struct ldb_request *req) -{ - struct lsql_context *ac; - struct ldb_handle *h; - - h = talloc_zero(lsqlite3, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - - ac = talloc(h, struct lsql_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; - } - - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->module = module; - ac->context = req->context; - ac->callback = req->callback; - - return h; -} - /* * Macros used throughout */ @@ -835,11 +798,6 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) char *query = NULL; int ret; - req->handle = init_handle(lsqlite3, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); if ((( ! ldb_dn_is_valid(req->op.search.base)) || ldb_dn_is_null(req->op.search.base)) && @@ -1013,10 +971,6 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) int i; int ret = LDB_SUCCESS; - req->handle = init_handle(lsqlite3, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); req->handle->state = LDB_ASYNC_DONE; req->handle->status = LDB_SUCCESS; @@ -1143,10 +1097,6 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) int i; int ret = LDB_SUCCESS; - req->handle = init_handle(lsqlite3, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); req->handle->state = LDB_ASYNC_DONE; req->handle->status = LDB_SUCCESS; @@ -1329,10 +1279,6 @@ static int lsql_delete(struct ldb_module *module, struct ldb_request *req) int ret = LDB_SUCCESS; - req->handle = init_handle(lsqlite3, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); req->handle->state = LDB_ASYNC_DONE; req->handle->status = LDB_SUCCESS; @@ -1382,10 +1328,6 @@ static int lsql_rename(struct ldb_module *module, struct ldb_request *req) char *query; int ret = LDB_SUCCESS; - req->handle = init_handle(lsqlite3, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); req->handle->state = LDB_ASYNC_DONE; req->handle->status = LDB_SUCCESS; @@ -1501,9 +1443,61 @@ static int lsql_request(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } -static int lsql_wait(struct ldb_handle *handle, enum ldb_wait_type type) +static int lsql_run_request(struct ldb_module *module, struct ldb_request *req) +{ + switch (req->operation) { + case LDB_SEARCH: + return lsql_search(module, req); + break; + case LDB_ADD: + return lsql_add(module, req); + break; + case LDB_MODIFY: + return lsql_modify(module, req); + break; + case LDB_DELETE: + return lsql_delete(module, req); + break; + case LDB_RENAME: + return lsql_rename(module, req); + break; +/* TODO: + case LDB_SEQUENCE_NUMBER: + return lsql_sequence_number(module, req); + break; + */ + default: + return lsql_request(module, req); + break; + } + + return LDB_ERR_OPERATIONS_ERROR; +} + +static int lsql_handle_request(struct ldb_module *module, struct ldb_request *req) { - return handle->status; + struct lsql_context *ac; + + if (check_critical_controls(req->controls)) { + return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; + } + + ac = talloc_zero(req, struct lsql_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->module = module; + ac->req = req; + + req->handle = ldb_handle_new(req, lsql_run_request, ac); + if (req->handle == NULL) { + talloc_free(ac); + return LDB_ERR_OPERATIONS_ERROR; + } + + return LDB_SUCCESS; } /* @@ -1511,16 +1505,16 @@ static int lsql_wait(struct ldb_handle *handle, enum ldb_wait_type type) */ static const struct ldb_module_ops lsqlite3_ops = { .name = "sqlite", - .search = lsql_search, - .add = lsql_add, - .modify = lsql_modify, - .del = lsql_delete, - .rename = lsql_rename, - .request = lsql_request, + .search = lsql_handle_request, + .add = lsql_handle_request, + .modify = lsql_handle_request, + .del = lsql_handle_request, + .rename = lsql_handle_request, + .request = lsql_handle_request, .start_transaction = lsql_start_trans, .end_transaction = lsql_end_trans, .del_transaction = lsql_del_trans, - .wait = lsql_wait, + /* TODO: .sequence_number = lsql_handle_request */ }; /* diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 269305a468..65711d9f4b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -667,74 +667,58 @@ static int ltdb_index_dn(struct ldb_module *module, extracting just the given attributes */ static int ltdb_index_filter(const struct dn_list *dn_list, - struct ldb_handle *handle) + struct ltdb_context *ac) { - struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); - struct ldb_reply *ares = NULL; + struct ldb_message *msg; unsigned int i; for (i = 0; i < dn_list->count; i++) { struct ldb_dn *dn; int ret; - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - return LDB_ERR_OPERATIONS_ERROR; - } - - ares->message = ldb_msg_new(ares); - if (!ares->message) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - talloc_free(ares); + msg = ldb_msg_new(ac); + if (!msg) { return LDB_ERR_OPERATIONS_ERROR; } - - dn = ldb_dn_new(ares->message, ac->module->ldb, dn_list->dn[i]); + dn = ldb_dn_new(msg, ac->module->ldb, dn_list->dn[i]); if (dn == NULL) { - talloc_free(ares); + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } - ret = ltdb_search_dn1(ac->module, dn, ares->message); + ret = ltdb_search_dn1(ac->module, dn, msg); talloc_free(dn); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* the record has disappeared? yes, this can happen */ - talloc_free(ares); + talloc_free(msg); continue; } if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) { /* an internal error */ - talloc_free(ares); + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } - if (!ldb_match_msg(ac->module->ldb, ares->message, ac->tree, ac->base, ac->scope)) { - talloc_free(ares); + if (!ldb_match_msg(ac->module->ldb, msg, + ac->tree, ac->base, ac->scope)) { + talloc_free(msg); continue; } /* filter the attributes that the user wants */ - ret = ltdb_filter_attrs(ares->message, ac->attrs); + ret = ltdb_filter_attrs(msg, ac->attrs); if (ret == -1) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - talloc_free(ares); + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } - ares->type = LDB_REPLY_ENTRY; - handle->state = LDB_ASYNC_PENDING; - handle->status = ac->callback(ac->module->ldb, ac->context, ares); - - if (handle->status != LDB_SUCCESS) { - handle->state = LDB_ASYNC_DONE; - return handle->status; + ret = ldb_module_send_entry(ac->req, msg); + if (ret != LDB_SUCCESS) { + ac->callback_failed = true; + return ret; } } @@ -746,9 +730,8 @@ static int ltdb_index_filter(const struct dn_list *dn_list, returns -1 if an indexed search is not possible, in which case the caller should call ltdb_search_full() */ -int ltdb_search_indexed(struct ldb_handle *handle) +int ltdb_search_indexed(struct ltdb_context *ac) { - struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private); struct dn_list *dn_list; int ret, idxattr, idxone; @@ -773,7 +756,7 @@ int ltdb_search_indexed(struct ldb_handle *handle) ret = LDB_ERR_OPERATIONS_ERROR; - dn_list = talloc_zero(handle, struct dn_list); + dn_list = talloc_zero(ac, struct dn_list); if (dn_list == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -810,9 +793,7 @@ int ltdb_search_indexed(struct ldb_handle *handle) if (ret == LDB_SUCCESS) { /* we've got a candidate list - now filter by the full tree and extract the needed attributes */ - ret = ltdb_index_filter(dn_list, handle); - handle->status = ret; - handle->state = LDB_ASYNC_DONE; + ret = ltdb_index_filter(dn_list, ac); } talloc_free(dn_list); diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index da899c361e..6ab06c4e48 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -205,7 +205,7 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module, return LDB_ERR_NO_SUCH_OBJECT on record-not-found and LDB_SUCCESS on success */ -int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn) +static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn) { struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; TDB_DATA tdb_key, tdb_data; @@ -276,30 +276,6 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes return LDB_SUCCESS; } -/* - lock the database for read - use by ltdb_search -*/ -static int ltdb_lock_read(struct ldb_module *module) -{ - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; - if (ltdb->in_transaction == 0) { - return tdb_lockall_read(ltdb->tdb); - } - return 0; -} - -/* - unlock the database after a ltdb_lock_read() -*/ -static int ltdb_unlock_read(struct ldb_module *module) -{ - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; - if (ltdb->in_transaction == 0) { - return tdb_unlockall_read(ltdb->tdb); - } - return 0; -} - /* add a set of attributes from a record to a set of results return 0 on success, -1 on failure @@ -395,71 +371,57 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) */ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { - struct ldb_handle *handle = talloc_get_type(state, struct ldb_handle); - struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); - struct ldb_reply *ares = NULL; + struct ltdb_context *ac; + struct ldb_message *msg; int ret; + ac = talloc_get_type(state, struct ltdb_context); + if (key.dsize < 4 || strncmp((char *)key.dptr, "DN=", 3) != 0) { return 0; } - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - return -1; - } - - ares->message = ldb_msg_new(ares); - if (!ares->message) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - talloc_free(ares); + msg = ldb_msg_new(ac); + if (!msg) { return -1; } /* unpack the record */ - ret = ltdb_unpack_data(ac->module, &data, ares->message); + ret = ltdb_unpack_data(ac->module, &data, msg); if (ret == -1) { - talloc_free(ares); + talloc_free(msg); return -1; } - if (!ares->message->dn) { - ares->message->dn = ldb_dn_new(ares->message, ac->module->ldb, (char *)key.dptr + 3); - if (ares->message->dn == NULL) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - talloc_free(ares); + if (!msg->dn) { + msg->dn = ldb_dn_new(msg, ac->module->ldb, + (char *)key.dptr + 3); + if (msg->dn == NULL) { + talloc_free(msg); return -1; } } /* see if it matches the given expression */ - if (!ldb_match_msg(ac->module->ldb, ares->message, ac->tree, - ac->base, ac->scope)) { - talloc_free(ares); + if (!ldb_match_msg(ac->module->ldb, msg, + ac->tree, ac->base, ac->scope)) { + talloc_free(msg); return 0; } /* filter the attributes that the user wants */ - ret = ltdb_filter_attrs(ares->message, ac->attrs); + ret = ltdb_filter_attrs(msg, ac->attrs); if (ret == -1) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - handle->state = LDB_ASYNC_DONE; - talloc_free(ares); + talloc_free(msg); return -1; } - ares->type = LDB_REPLY_ENTRY; - handle->state = LDB_ASYNC_PENDING; - handle->status = ac->callback(ac->module->ldb, ac->context, ares); - - if (handle->status != LDB_SUCCESS) { - /* don't try to free ares here, the callback is in charge of that */ + ret = ldb_module_send_entry(ac->req, msg); + if (ret != LDB_SUCCESS) { + ac->callback_failed = true; + /* the callback failed, abort the operation */ return -1; } @@ -471,23 +433,21 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi search the database with a LDAP-like expression. this is the "full search" non-indexed variant */ -static int ltdb_search_full(struct ldb_handle *handle) +static int ltdb_search_full(struct ltdb_context *ctx) { - struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context); - struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private); + struct ltdb_private *ltdb = talloc_get_type(ctx->module->private_data, struct ltdb_private); int ret; if (ltdb->in_transaction != 0) { - ret = tdb_traverse(ltdb->tdb, search_func, handle); + ret = tdb_traverse(ltdb->tdb, search_func, ctx); } else { - ret = tdb_traverse_read(ltdb->tdb, search_func, handle); + ret = tdb_traverse_read(ltdb->tdb, search_func, ctx); } if (ret == -1) { - handle->status = LDB_ERR_OPERATIONS_ERROR; + return LDB_ERR_OPERATIONS_ERROR; } - handle->state = LDB_ASYNC_DONE; return LDB_SUCCESS; } @@ -495,13 +455,15 @@ static int ltdb_search_full(struct ldb_handle *handle) search the database with a LDAP-like expression. choses a search method */ -int ltdb_search(struct ldb_module *module, struct ldb_request *req) +int ltdb_search(struct ltdb_context *ctx) { + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); - struct ltdb_context *ltdb_ac; - struct ldb_reply *ares; int ret; + req->handle->state = LDB_ASYNC_PENDING; + if (ltdb_lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; } @@ -516,12 +478,6 @@ int ltdb_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - req->handle = init_ltdb_handle(ltdb, module, req); - if (req->handle == NULL) { - ltdb_unlock_read(module); - return LDB_ERR_OPERATIONS_ERROR; - } - if ((req->op.search.base == NULL) || (ldb_dn_is_null(req->op.search.base) == true)) { /* Check what we should do with a NULL dn */ @@ -564,53 +520,32 @@ int ltdb_search(struct ldb_module *module, struct ldb_request *req) ret = LDB_SUCCESS; } - ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context); - - ltdb_ac->tree = req->op.search.tree; - ltdb_ac->scope = req->op.search.scope; - ltdb_ac->base = req->op.search.base; - ltdb_ac->attrs = req->op.search.attrs; - + ctx->tree = req->op.search.tree; + ctx->scope = req->op.search.scope; + ctx->base = req->op.search.base; + ctx->attrs = req->op.search.attrs; if (ret == LDB_SUCCESS) { - ret = ltdb_search_indexed(req->handle); + ret = ltdb_search_indexed(ctx); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* Not in the index, therefore OK! */ ret = LDB_SUCCESS; - } else if (ret == LDB_ERR_OPERATIONS_ERROR) { + } + /* Check if we got just a normal error. + * In that case proceed to a full search unless we got a + * callback error */ + if ( ! ctx->callback_failed && ret != LDB_SUCCESS) { /* Not indexed, so we need to do a full scan */ - ret = ltdb_search_full(req->handle); + ret = ltdb_search_full(ctx); if (ret != LDB_SUCCESS) { ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n"); } } } - if (ret != LDB_SUCCESS) { - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = ret; - } - - /* Finally send an LDB_REPLY_DONE packet when searching is finished */ - - ares = talloc_zero(req, struct ldb_reply); - if (!ares) { - ltdb_unlock_read(module); - return LDB_ERR_OPERATIONS_ERROR; - } - - req->handle->state = LDB_ASYNC_DONE; - - if (ret == LDB_SUCCESS) { - ares->type = LDB_REPLY_DONE; - - ret = req->callback(module->ldb, req->context, ares); - req->handle->status = ret; - } - ltdb_unlock_read(module); - return LDB_SUCCESS; + return ret; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 01d570c89a..34a4e03965 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -3,7 +3,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 - Copyright (C) Simo Sorce 2006 + Copyright (C) Simo Sorce 2006-2008 ** NOTE! The following LGPL license applies to the ldb @@ -39,6 +39,10 @@ * - description: make the module use asyncronous calls * date: Feb 2006 * Author: Simo Sorce + * + * - description: make it possible to use event contexts + * date: Jan 2008 + * Author: Simo Sorce */ #include "ldb_includes.h" @@ -75,41 +79,31 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code) return LDB_ERR_OTHER; } - -struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, - struct ldb_module *module, - struct ldb_request *req) +/* + lock the database for read - use by ltdb_search and ltdb_sequence_number +*/ +int ltdb_lock_read(struct ldb_module *module) { - struct ltdb_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; + struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + if (ltdb->in_transaction == 0) { + return tdb_lockall_read(ltdb->tdb); } + return 0; +} - h->module = module; - - ac = talloc_zero(h, struct ltdb_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; +/* + unlock the database after a ltdb_lock_read() +*/ +int ltdb_unlock_read(struct ldb_module *module) +{ + struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + if (ltdb->in_transaction == 0) { + return tdb_unlockall_read(ltdb->tdb); } - - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->module = module; - ac->context = req->context; - ac->callback = req->callback; - - return h; + return 0; } + /* form a TDB_DATA for a record key caller frees @@ -167,7 +161,7 @@ failed: check special dn's have valid attributes currently only @ATTRIBUTES is checked */ -int ltdb_check_special_dn(struct ldb_module *module, +static int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *msg) { int i, j; @@ -296,36 +290,20 @@ static int ltdb_add_internal(struct ldb_module *module, /* add a record to the database */ -static int ltdb_add(struct ldb_module *module, struct ldb_request *req) +static int ltdb_add(struct ltdb_context *ctx) { - struct ltdb_private *ltdb; - struct ltdb_context *ltdb_ac; - int tret, ret = LDB_SUCCESS; - - ltdb = talloc_get_type(module->private_data, struct ltdb_private); - - if (check_critical_controls(req->controls)) { - return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; - } + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + int tret; - req->handle = init_ltdb_handle(ltdb, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context); + req->handle->state = LDB_ASYNC_PENDING; tret = ltdb_add_internal(module, req->op.add.message); if (tret != LDB_SUCCESS) { - req->handle->status = tret; - goto done; + return tret; } - if (ltdb_ac->callback) { - ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL); - } -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* @@ -402,42 +380,24 @@ done: /* delete a record from the database */ -static int ltdb_delete(struct ldb_module *module, struct ldb_request *req) +static int ltdb_delete(struct ltdb_context *ctx) { - struct ltdb_private *ltdb; - struct ltdb_context *ltdb_ac; - int tret, ret = LDB_SUCCESS; - - ltdb = talloc_get_type(module->private_data, struct ltdb_private); - - if (check_critical_controls(req->controls)) { - return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; - } + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + int tret; - req->handle = NULL; + req->handle->state = LDB_ASYNC_PENDING; if (ltdb_cache_load(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; } - req->handle = init_ltdb_handle(ltdb, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context); - tret = ltdb_delete_internal(module, req->op.del.dn); if (tret != LDB_SUCCESS) { - req->handle->status = tret; - goto done; + return tret; } - if (ltdb_ac->callback) { - ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL); - } -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* @@ -784,83 +744,50 @@ failed: /* modify a record */ -static int ltdb_modify(struct ldb_module *module, struct ldb_request *req) +static int ltdb_modify(struct ltdb_context *ctx) { - struct ltdb_private *ltdb; - struct ltdb_context *ltdb_ac; - int tret, ret = LDB_SUCCESS; - - ltdb = talloc_get_type(module->private_data, struct ltdb_private); - - if (check_critical_controls(req->controls)) { - return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; - } - - req->handle = NULL; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + int tret; - req->handle = init_ltdb_handle(ltdb, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context); + req->handle->state = LDB_ASYNC_PENDING; tret = ltdb_check_special_dn(module, req->op.mod.message); if (tret != LDB_SUCCESS) { - req->handle->status = tret; - goto done; + return tret; } if (ltdb_cache_load(module) != 0) { - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } tret = ltdb_modify_internal(module, req->op.mod.message); if (tret != LDB_SUCCESS) { - req->handle->status = tret; - goto done; + return tret; } - if (ltdb_ac->callback) { - ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL); - } -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* rename a record */ -static int ltdb_rename(struct ldb_module *module, struct ldb_request *req) +static int ltdb_rename(struct ltdb_context *ctx) { - struct ltdb_private *ltdb; - struct ltdb_context *ltdb_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; struct ldb_message *msg; - int tret, ret = LDB_SUCCESS; - - ltdb = talloc_get_type(module->private_data, struct ltdb_private); - - if (check_critical_controls(req->controls)) { - return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; - } + int tret; - req->handle = NULL; + req->handle->state = LDB_ASYNC_PENDING; - if (ltdb_cache_load(module) != 0) { + if (ltdb_cache_load(ctx->module) != 0) { return LDB_ERR_OPERATIONS_ERROR; } - req->handle = init_ltdb_handle(ltdb, module, req); - if (req->handle == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - ltdb_ac = talloc_get_type(req->handle->private_data, struct ltdb_context); - - msg = talloc(ltdb_ac, struct ldb_message); + msg = talloc(ctx, struct ldb_message); if (msg == NULL) { - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* in case any attribute of the message was indexed, we need @@ -868,14 +795,12 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req) tret = ltdb_search_dn1(module, req->op.rename.olddn, msg); if (tret != LDB_SUCCESS) { /* not finding the old record is an error */ - req->handle->status = tret; - goto done; + return tret; } msg->dn = ldb_dn_copy(msg, req->op.rename.newdn); if (!msg->dn) { - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } if (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) == 0) { @@ -886,38 +811,32 @@ static int ltdb_rename(struct ldb_module *module, struct ldb_request *req) The only drawback to this is that if the delete succeeds but the add fails, we rely on the transaction to roll this all back. */ - ret = ltdb_delete_internal(module, req->op.rename.olddn); - if (ret != LDB_SUCCESS) { - goto done; + tret = ltdb_delete_internal(module, req->op.rename.olddn); + if (tret != LDB_SUCCESS) { + return tret; } - ret = ltdb_add_internal(module, msg); - if (ret != LDB_SUCCESS) { - goto done; + tret = ltdb_add_internal(module, msg); + if (tret != LDB_SUCCESS) { + return tret; } } else { /* The rename operation is changing DNs. Try to add the new DN first to avoid clobbering another DN not related to this rename operation. */ - ret = ltdb_add_internal(module, msg); - if (ret != LDB_SUCCESS) { - goto done; + tret = ltdb_add_internal(module, msg); + if (tret != LDB_SUCCESS) { + return tret; } tret = ltdb_delete_internal(module, req->op.rename.olddn); if (tret != LDB_SUCCESS) { ltdb_delete_internal(module, req->op.rename.newdn); - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } - if (ltdb_ac->callback) { - ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL); - } -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } static int ltdb_start_trans(struct ldb_module *module) @@ -962,95 +881,261 @@ static int ltdb_del_trans(struct ldb_module *module) return LDB_SUCCESS; } -static int ltdb_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - return handle->status; -} - -static int ltdb_request(struct ldb_module *module, struct ldb_request *req) -{ - /* check for oustanding critical controls - * and return an error if found */ - if (check_critical_controls(req->controls)) { - return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; - } - - /* search, add, modify, delete, rename are handled by their own, - * no other op supported */ - return LDB_ERR_OPERATIONS_ERROR; -} - /* return sequenceNumber from @BASEINFO */ -static int ltdb_sequence_number(struct ldb_module *module, - struct ldb_request *req) +static int ltdb_sequence_number(struct ltdb_context *ctx, + struct ldb_extended **ext) { + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; TALLOC_CTX *tmp_ctx; + struct ldb_seqnum_request *seq; + struct ldb_seqnum_result *res; struct ldb_message *msg = NULL; struct ldb_dn *dn; const char *date; - int tret; + int ret; + + seq = talloc_get_type(req->op.extended.data, + struct ldb_seqnum_request); + if (seq == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + req->handle->state = LDB_ASYNC_PENDING; + + if (ltdb_lock_read(module) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + res = talloc_zero(req, struct ldb_seqnum_result); + if (res == NULL) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } tmp_ctx = talloc_new(req); if (tmp_ctx == NULL) { - talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } dn = ldb_dn_new(tmp_ctx, module->ldb, LTDB_BASEINFO); msg = talloc(tmp_ctx, struct ldb_message); if (msg == NULL) { - talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } - req->op.seq_num.flags = 0; - - tret = ltdb_search_dn1(module, dn, msg); - if (tret != LDB_SUCCESS) { - talloc_free(tmp_ctx); - /* zero is as good as anything when we don't know */ - req->op.seq_num.seq_num = 0; - return LDB_SUCCESS; + ret = ltdb_search_dn1(module, dn, msg); + if (ret != LDB_SUCCESS) { + goto done; } - switch (req->op.seq_num.type) { + switch (seq->type) { case LDB_SEQ_HIGHEST_SEQ: - req->op.seq_num.seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0); + res->seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0); break; case LDB_SEQ_NEXT: - req->op.seq_num.seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0); - req->op.seq_num.seq_num++; + res->seq_num = ldb_msg_find_attr_as_uint64(msg, LTDB_SEQUENCE_NUMBER, 0); + res->seq_num++; break; case LDB_SEQ_HIGHEST_TIMESTAMP: date = ldb_msg_find_attr_as_string(msg, LTDB_MOD_TIMESTAMP, NULL); if (date) { - req->op.seq_num.seq_num = ldb_string_to_time(date); + res->seq_num = ldb_string_to_time(date); } else { - req->op.seq_num.seq_num = 0; + res->seq_num = 0; /* zero is as good as anything when we don't know */ } break; } + + *ext = talloc_zero(req, struct ldb_extended); + if (*ext == NULL) { + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + (*ext)->oid = LDB_EXTENDED_SEQUENCE_NUMBER; + (*ext)->data = talloc_steal(*ext, res); + + ret = LDB_SUCCESS; + +done: talloc_free(tmp_ctx); + ltdb_unlock_read(module); + return ret; +} + +static void ltdb_request_done(struct ldb_request *req, int error) +{ + struct ldb_reply *ares; + + /* if we already returned an error just return */ + if (req->handle->status != LDB_SUCCESS) { + return; + } + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(req->handle->ldb); + req->callback(req, NULL); + return; + } + ares->type = LDB_REPLY_DONE; + ares->error = error; + + req->callback(req, ares); +} + +static void ltdb_timeout(struct event_context *ev, + struct timed_event *te, + struct timeval t, + void *private_data) +{ + struct ltdb_context *ctx; + ctx = talloc_get_type(private_data, struct ltdb_context); + + ltdb_request_done(ctx->req, LDB_ERR_TIME_LIMIT_EXCEEDED); +} + +static void ltdb_request_extended_done(struct ldb_request *req, + struct ldb_extended *ext, + int error) +{ + struct ldb_reply *ares; + + /* if we already returned an error just return */ + if (req->handle->status != LDB_SUCCESS) { + return; + } + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(req->handle->ldb); + req->callback(req, NULL); + return; + } + ares->type = LDB_REPLY_DONE; + ares->response = ext; + ares->error = error; + + req->callback(req, ares); +} + +static void ltdb_handle_extended(struct ltdb_context *ctx) +{ + struct ldb_extended *ext = NULL; + int ret; + + if (strcmp(ctx->req->op.extended.oid, + LDB_EXTENDED_SEQUENCE_NUMBER) == 0) { + /* get sequence number */ + ret = ltdb_sequence_number(ctx, &ext); + } else { + /* not recognized */ + ret = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; + } + + ltdb_request_extended_done(ctx->req, ext, ret); +} + +static void ltdb_callback(struct event_context *ev, + struct timed_event *te, + struct timeval t, + void *private_data) +{ + struct ltdb_context *ctx; + int ret; + + ctx = talloc_get_type(private_data, struct ltdb_context); + + switch (ctx->req->operation) { + case LDB_SEARCH: + ret = ltdb_search(ctx); + break; + case LDB_ADD: + ret = ltdb_add(ctx); + break; + case LDB_MODIFY: + ret = ltdb_modify(ctx); + break; + case LDB_DELETE: + ret = ltdb_delete(ctx); + break; + case LDB_RENAME: + ret = ltdb_rename(ctx); + break; + case LDB_EXTENDED: + ltdb_handle_extended(ctx); + return; + default: + /* no other op supported */ + ret = LDB_ERR_UNWILLING_TO_PERFORM; + } + + if (!ctx->callback_failed) { + ltdb_request_done(ctx->req, ret); + } +} + +static int ltdb_handle_request(struct ldb_module *module, + struct ldb_request *req) +{ + struct event_context *ev; + struct ltdb_context *ac; + struct timed_event *te; + struct timeval tv; + + if (check_critical_controls(req->controls)) { + return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; + } + + if (req->starttime == 0 || req->timeout == 0) { + ldb_set_errstring(module->ldb, "Invalid timeout settings"); + return LDB_ERR_TIME_LIMIT_EXCEEDED; + } + + ev = ldb_get_event_context(module->ldb); + + ac = talloc_zero(req, struct ltdb_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->module = module; + ac->req = req; + + tv.tv_sec = 0; + tv.tv_usec = 0; + te = event_add_timed(ev, ac, tv, ltdb_callback, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; + } + + + tv.tv_sec = req->starttime + req->timeout; + te = event_add_timed(ev, ac, tv, ltdb_timeout, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; + } + return LDB_SUCCESS; } static const struct ldb_module_ops ltdb_ops = { .name = "tdb", - .search = ltdb_search, - .add = ltdb_add, - .modify = ltdb_modify, - .del = ltdb_delete, - .rename = ltdb_rename, - .request = ltdb_request, + .search = ltdb_handle_request, + .add = ltdb_handle_request, + .modify = ltdb_handle_request, + .del = ltdb_handle_request, + .rename = ltdb_handle_request, + .extended = ltdb_handle_request, .start_transaction = ltdb_start_trans, .end_transaction = ltdb_end_trans, .del_transaction = ltdb_del_trans, - .wait = ltdb_wait, - .sequence_number = ltdb_sequence_number }; /* @@ -1114,7 +1199,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, ltdb->sequence_number = 0; *module = talloc(ldb, struct ldb_module); - if (!module) { + if ((*module) == NULL) { ldb_oom(ldb); talloc_free(ltdb); return -1; diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index 4beced30eb..61e90bccc6 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -41,16 +41,15 @@ struct ltdb_private { */ struct ltdb_context { struct ldb_module *module; + struct ldb_request *req; + + bool callback_failed; /* search stuff */ const struct ldb_parse_tree *tree; struct ldb_dn *base; enum ldb_scope scope; const char * const *attrs; - - /* async stuff */ - void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); }; /* special record types */ @@ -80,7 +79,7 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value); struct ldb_parse_tree; -int ltdb_search_indexed(struct ldb_handle *handle); +int ltdb_search_indexed(struct ltdb_context *ctx); int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg); int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg); int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add); @@ -110,11 +109,11 @@ int ltdb_add_attr_results(struct ldb_module *module, unsigned int *count, struct ldb_message ***res); int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs); -int ltdb_search(struct ldb_module *module, struct ldb_request *req); +int ltdb_search(struct ltdb_context *ctx); /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */ -struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module, - struct ldb_request *req); +int ltdb_lock_read(struct ldb_module *module); +int ltdb_unlock_read(struct ldb_module *module); struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn); int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs); int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn); @@ -127,4 +126,3 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx, const char *path, int hash_size, int tdb_flags, int open_flags, mode_t mode, struct ldb_context *ldb); - diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c index 654574cd2f..4fea43c8c8 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c @@ -64,6 +64,10 @@ static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, con struct ldb_context *ldb = talloc_get_type(tdb_get_logging_private(tdb), struct ldb_context); enum ldb_debug_level ldb_level; char *message; + + if (ldb == NULL) + return; + va_start(ap, fmt); message = talloc_vasprintf(ldb, fmt, ap); va_end(ap); diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c index c9dd9dccd8..bc9266a306 100644 --- a/source4/lib/ldb/ldb_wrap.c +++ b/source4/lib/ldb/ldb_wrap.c @@ -2492,23 +2492,25 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) #define SWIGTYPE_p_ldb_ldif swig_types[6] #define SWIGTYPE_p_ldb_message swig_types[7] #define SWIGTYPE_p_ldb_message_element swig_types[8] -#define SWIGTYPE_p_ldb_module_ops swig_types[9] -#define SWIGTYPE_p_ldb_result swig_types[10] -#define SWIGTYPE_p_ldb_val swig_types[11] -#define SWIGTYPE_p_long_long swig_types[12] -#define SWIGTYPE_p_p_char swig_types[13] -#define SWIGTYPE_p_p_ldb_control swig_types[14] -#define SWIGTYPE_p_p_ldb_result swig_types[15] -#define SWIGTYPE_p_short swig_types[16] -#define SWIGTYPE_p_signed_char swig_types[17] -#define SWIGTYPE_p_unsigned_char swig_types[18] -#define SWIGTYPE_p_unsigned_int swig_types[19] -#define SWIGTYPE_p_unsigned_long swig_types[20] -#define SWIGTYPE_p_unsigned_long_long swig_types[21] -#define SWIGTYPE_p_unsigned_short swig_types[22] -#define SWIGTYPE_p_void swig_types[23] -static swig_type_info *swig_types[25]; -static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0}; +#define SWIGTYPE_p_ldb_module swig_types[9] +#define SWIGTYPE_p_ldb_module_ops swig_types[10] +#define SWIGTYPE_p_ldb_parse_tree swig_types[11] +#define SWIGTYPE_p_ldb_result swig_types[12] +#define SWIGTYPE_p_ldb_val swig_types[13] +#define SWIGTYPE_p_long_long swig_types[14] +#define SWIGTYPE_p_p_char swig_types[15] +#define SWIGTYPE_p_p_ldb_control swig_types[16] +#define SWIGTYPE_p_p_ldb_result swig_types[17] +#define SWIGTYPE_p_short swig_types[18] +#define SWIGTYPE_p_signed_char swig_types[19] +#define SWIGTYPE_p_unsigned_char swig_types[20] +#define SWIGTYPE_p_unsigned_int swig_types[21] +#define SWIGTYPE_p_unsigned_long swig_types[22] +#define SWIGTYPE_p_unsigned_long_long swig_types[23] +#define SWIGTYPE_p_unsigned_short swig_types[24] +#define SWIGTYPE_p_void swig_types[25] +static swig_type_info *swig_types[27]; +static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2562,6 +2564,7 @@ typedef struct ldb_context ldb; typedef struct ldb_dn ldb_dn; typedef struct ldb_ldif ldb_ldif; typedef struct ldb_message_element ldb_message_element; +typedef struct ldb_module ldb_module; typedef int ldb_error; typedef int ldb_int_error; @@ -3153,15 +3156,14 @@ SWIGINTERN ldb_error ldb_search_ex(ldb *self,TALLOC_CTX *mem_ctx,ldb_dn *base,en attrs, controls, res, - ldb_search_default_callback); + ldb_search_default_callback, + NULL); if (ret != 0) { talloc_free(res); return ret; } - ldb_set_timeout(self, req, 0); /* use default timeout */ - ret = ldb_request(self, req); if (ret == 0) { @@ -3201,8 +3203,7 @@ SWIGINTERN PyObject *ldb_schema_format_value(ldb *self,char const *element_name, return ret; } SWIGINTERN ldb_error ldb___contains__(ldb *self,ldb_dn *dn,struct ldb_result **result_as_bool){ - return ldb_search(self, dn, LDB_SCOPE_BASE, NULL, NULL, - result_as_bool); + return ldb_search(self, self, result_as_bool, dn, LDB_SCOPE_BASE, NULL, NULL); } SWIGINTERN PyObject *ldb_parse_ldif(ldb *self,char const *s){ PyObject *list = PyList_New(0); @@ -3226,6 +3227,319 @@ static char *timestring(time_t t) return result; } +SWIGINTERN char const *ldb_module___str__(ldb_module *self){ + return self->ops->name; + } +SWIGINTERN char *ldb_module___repr__(ldb_module *self){ + char *ret; + asprintf(&ret, "", self->ops->name); + return ret; + } +SWIGINTERN int ldb_module_search(ldb_module *self,struct ldb_dn *base,enum ldb_scope scope,struct ldb_parse_tree *tree,char const *const *attrs,struct ldb_result **res){ + int ret; + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + + req->operation = LDB_SEARCH; + req->op.search.base = base; + req->op.search.scope = scope; + req->op.search.tree = tree; + req->op.search.attrs = attrs; + + req->op.search.res = talloc_zero(NULL, struct ldb_result); + + ret = self->ops->search(self, req); + + *res = req->op.search.res; + + talloc_free(req); + + return ret; + } +SWIGINTERN ldb_error ldb_module_add(ldb_module *self,struct ldb_message *message){ + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_ADD; + req->op.add.message = message; + + return self->ops->add(self, &req); + } +SWIGINTERN ldb_error ldb_module_modify(ldb_module *self,struct ldb_message *message){ + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_MODIFY; + req->op.mod.message = message; + + return self->ops->modify(self, &req); + } +SWIGINTERN ldb_error ldb_module_delete(ldb_module *self,struct ldb_dn *dn){ + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_DELETE; + req->op.del.dn = dn; + + return self->ops->del(self, &req); + + } +SWIGINTERN ldb_error ldb_module_rename(ldb_module *self,struct ldb_dn *olddn,struct ldb_dn *newdn){ + struct ldb_request *req = talloc_zero(NULL, struct ldb_request); + req->operation = LDB_RENAME; + req->op.rename.olddn = olddn; + req->op.rename.olddn = newdn; + + return self->ops->rename(self, &req); + } +SWIGINTERN ldb_error ldb_module_start_transaction(ldb_module *self){ + return self->ops->start_transaction(self); + } +SWIGINTERN ldb_error ldb_module_end_transaction(ldb_module *self){ + return self->ops->end_transaction(self); + } +SWIGINTERN ldb_error ldb_module_del_transaction(ldb_module *self){ + return self->ops->del_transaction(self); + } + +int py_module_search(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_base, *py_attrs, *py_tree; + + py_base = SWIG_NewPointerObj(req->op.search.base, SWIGTYPE_p_ldb_dn, 0); + + if (py_base == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_tree = SWIG_NewPointerObj(req->op.search.tree, SWIGTYPE_p_ldb_parse_tree, 0); + + if (py_tree == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + if (req->op.search.attrs == NULL) { + py_attrs = Py_None; + } else { + int i, len; + for (len = 0; req->op.search.attrs[len]; len++); + py_attrs = PyList_New(len); + for (i = 0; i < len; i++) + PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i])); + } + + py_result = PyObject_CallMethod(py_ldb, "search", "OiOO", py_base, req->op.search.scope, py_tree, py_attrs); + + Py_DECREF(py_attrs); + Py_DECREF(py_tree); + Py_DECREF(py_base); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (SWIG_ConvertPtr(py_result, &req->op.search.res, SWIGTYPE_p_ldb_result, 0) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_add(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.add.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "add", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_modify(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.mod.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "modify", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_dn; + + py_dn = SWIG_NewPointerObj(req->op.del.dn, SWIGTYPE_p_ldb_dn, 0); + + if (py_dn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "delete", "O", py_dn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_rename(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_olddn, *py_newdn; + + py_olddn = SWIG_NewPointerObj(req->op.rename.olddn, SWIGTYPE_p_ldb_dn, 0); + + if (py_olddn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_newdn = SWIG_NewPointerObj(req->op.rename.newdn, SWIGTYPE_p_ldb_dn, 0); + + if (py_newdn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "rename", "OO", py_olddn, py_newdn); + + Py_DECREF(py_olddn); + Py_DECREF(py_newdn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_request(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "request", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_extended(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "extended", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_start_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "start_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_end_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "end_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "del_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +static int py_module_destructor(void *_mod) +{ + struct ldb_module *mod = _mod; + Py_DECREF((PyObject *)mod->private_data); + return 0; +} + +int py_module_init (struct ldb_module *mod) +{ + PyObject *py_class = mod->ops->private_data; + PyObject *py_result, *py_next, *py_ldb; + + py_ldb = SWIG_NewPointerObj(mod->ldb, SWIGTYPE_p_ldb_context, 0); + + if (py_ldb == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_next = SWIG_NewPointerObj(mod->next, SWIGTYPE_p_ldb_module, 0); + + if (py_next == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallFunction(py_class, "OO", py_ldb, py_next); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + mod->private_data = py_result; + + talloc_set_destructor (mod, py_module_destructor); + + return ldb_next_init(mod); +} + #ifdef __cplusplus extern "C" { #endif @@ -4433,6 +4747,64 @@ fail: } +SWIGINTERN PyObject *_wrap_Ldb_firstmodule_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb *arg1 = (ldb *) 0 ; + struct ldb_module *arg2 = (struct ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args,"Ldb_firstmodule_set",2,2,swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_firstmodule_set" "', argument " "1"" of type '" "ldb *""'"); + } + arg1 = (ldb *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_firstmodule_set" "', argument " "2"" of type '" "struct ldb_module *""'"); + } + arg2 = (struct ldb_module *)(argp2); + if (arg1 == NULL) + SWIG_exception(SWIG_ValueError, + "ldb context must be non-NULL"); + if (arg1) (arg1)->modules = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Ldb_firstmodule_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb *arg1 = (ldb *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct ldb_module *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_firstmodule_get" "', argument " "1"" of type '" "ldb *""'"); + } + arg1 = (ldb *)(argp1); + if (arg1 == NULL) + SWIG_exception(SWIG_ValueError, + "ldb context must be non-NULL"); + result = (struct ldb_module *) ((arg1)->modules); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_new_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *result = 0 ; @@ -4625,11 +4997,15 @@ SWIGINTERN PyObject *_wrap_Ldb_search_ex(PyObject *SWIGUNUSEDPARM(self), PyObjec SWIG_fail; } resultobj = Py_None; - resultobj = PyList_New((*arg8)->count); - for (i8 = 0; i8 < (*arg8)->count; i8++) { - PyList_SetItem(resultobj, i8, - SWIG_NewPointerObj((*arg8)->msgs[i8], SWIGTYPE_p_ldb_message, 0) - ); + if (arg8 == NULL) { + resultobj = Py_None; + } else { + resultobj = PyList_New((*arg8)->count); + for (i8 = 0; i8 < (*arg8)->count; i8++) { + PyList_SetItem(resultobj, i8, + SWIG_NewPointerObj((*arg8)->msgs[i8], SWIGTYPE_p_ldb_message, 0) + ); + } } talloc_free(arg3); if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); @@ -5707,19 +6083,552 @@ fail: } -SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { +SWIGINTERN PyObject *_wrap_ldb_module_prev_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - struct ldb_module_ops *arg1 = (struct ldb_module_ops *) 0 ; - PyObject * obj0 = 0 ; - char * kwnames[] = { - (char *)"arg1", NULL - }; - ldb_int_error result; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_module *arg2 = (struct ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:register_module",kwnames,&obj0)) SWIG_fail; - arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); + if (!SWIG_Python_UnpackTuple(args,"ldb_module_prev_set",2,2,swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_prev_set" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_prev_set" "', argument " "2"" of type '" "struct ldb_module *""'"); + } + arg2 = (struct ldb_module *)(argp2); + if (arg1) (arg1)->prev = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_prev_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct ldb_module *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_prev_get" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (struct ldb_module *) ((arg1)->prev); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_module *arg2 = (struct ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args,"ldb_module_next_set",2,2,swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_next_set" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_next_set" "', argument " "2"" of type '" "struct ldb_module *""'"); + } + arg2 = (struct ldb_module *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct ldb_module *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_next_get" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (struct ldb_module *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module___str__" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (char *)ldb_module___str__(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module___repr__" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (char *)ldb_module___repr__(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_search(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_dn *arg2 = (struct ldb_dn *) 0 ; + enum ldb_scope arg3 ; + struct ldb_parse_tree *arg4 = (struct ldb_parse_tree *) 0 ; + char **arg5 = (char **) 0 ; + struct ldb_result **arg6 = (struct ldb_result **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + struct ldb_result *temp_ldb_result6 ; + int i6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "base",(char *) "scope",(char *) "tree",(char *) "attrs", NULL + }; + int result; + + arg6 = &temp_ldb_result6; + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:ldb_module_search",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_search" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_search" "', argument " "2"" of type '" "struct ldb_dn *""'"); + } + arg2 = (struct ldb_dn *)(argp2); + ecode3 = SWIG_AsVal_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ldb_module_search" "', argument " "3"" of type '" "enum ldb_scope""'"); + } + arg3 = (enum ldb_scope)(val3); + res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_ldb_parse_tree, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ldb_module_search" "', argument " "4"" of type '" "struct ldb_parse_tree *""'"); + } + arg4 = (struct ldb_parse_tree *)(argp4); + if (obj4 == Py_None) { + arg5 = NULL; + } else if (PySequence_Check(obj4)) { + int i; + arg5 = talloc_array(NULL, char *, PySequence_Size(obj4)+1); + for(i = 0; i < PySequence_Size(obj4); i++) + arg5[i] = PyString_AsString(PySequence_GetItem(obj4, i)); + arg5[i] = NULL; + } else { + SWIG_exception(SWIG_TypeError, "expected sequence"); + } + result = (int)ldb_module_search(arg1,arg2,arg3,arg4,(char const *const *)arg5,arg6); + resultobj = SWIG_From_int((int)(result)); + if (arg6 == NULL) { + resultobj = Py_None; + } else { + resultobj = PyList_New((*arg6)->count); + for (i6 = 0; i6 < (*arg6)->count; i6++) { + PyList_SetItem(resultobj, i6, + SWIG_NewPointerObj((*arg6)->msgs[i6], SWIGTYPE_p_ldb_message, 0) + ); + } + } + talloc_free(arg5); + return resultobj; +fail: + talloc_free(arg5); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_message *arg2 = (struct ldb_message *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "message", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_add",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_add" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_add" "', argument " "2"" of type '" "struct ldb_message *""'"); + } + arg2 = (struct ldb_message *)(argp2); + result = ldb_module_add(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_message *arg2 = (struct ldb_message *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "message", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_modify",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_modify" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_modify" "', argument " "2"" of type '" "struct ldb_message *""'"); + } + arg2 = (struct ldb_message *)(argp2); + result = ldb_module_modify(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_dn *arg2 = (struct ldb_dn *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "dn", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_delete",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_delete" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_delete" "', argument " "2"" of type '" "struct ldb_dn *""'"); + } + arg2 = (struct ldb_dn *)(argp2); + result = ldb_module_delete(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_rename(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_dn *arg2 = (struct ldb_dn *) 0 ; + struct ldb_dn *arg3 = (struct ldb_dn *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "olddn",(char *) "newdn", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:ldb_module_rename",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_rename" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_rename" "', argument " "2"" of type '" "struct ldb_dn *""'"); + } + arg2 = (struct ldb_dn *)(argp2); + res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_ldb_dn, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ldb_module_rename" "', argument " "3"" of type '" "struct ldb_dn *""'"); + } + arg3 = (struct ldb_dn *)(argp3); + result = ldb_module_rename(arg1,arg2,arg3); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_start_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ldb_error result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_start_transaction" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = ldb_module_start_transaction(arg1); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_end_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ldb_error result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_end_transaction" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = ldb_module_end_transaction(arg1); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_del_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ldb_error result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_del_transaction" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = ldb_module_del_transaction(arg1); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ldb_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args,"new_ldb_module",0,0,0)) SWIG_fail; + result = (ldb_module *)calloc(1, sizeof(ldb_module)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_ldb_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ldb_module" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ldb_module_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_ldb_module, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *ldb_module_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + struct ldb_module_ops *arg1 = (struct ldb_module_ops *) 0 ; + PyObject * obj0 = 0 ; + char * kwnames[] = { + (char *)"arg1", NULL + }; + ldb_int_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:register_module",kwnames,&obj0)) SWIG_fail; + arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); + + arg1->name = talloc_strdup(arg1, PyString_AsString(PyObject_GetAttrString(obj0, (char *)"name"))); - arg1->name = (char *)PyObject_GetAttrString(obj0, (char *)"name"); + Py_INCREF(obj0); + arg1->private_data = obj0; + arg1->init_context = py_module_init; + arg1->search = py_module_search; + arg1->add = py_module_add; + arg1->modify = py_module_modify; + arg1->del = py_module_del; + arg1->rename = py_module_rename; + arg1->request = py_module_request; + arg1->extended = py_module_extended; + arg1->start_transaction = py_module_start_transaction; + arg1->end_transaction = py_module_end_transaction; + arg1->del_transaction = py_module_del_transaction; result = ldb_register_module((struct ldb_module_ops const *)arg1); if (result != 0) { PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_strerror(result))); @@ -5804,6 +6713,8 @@ static PyMethodDef SwigMethods[] = { { (char *)"Message_swigregister", Message_swigregister, METH_VARARGS, NULL}, { (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL}, { (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Ldb_firstmodule_set", _wrap_Ldb_firstmodule_set, METH_VARARGS, NULL}, + { (char *)"Ldb_firstmodule_get", (PyCFunction)_wrap_Ldb_firstmodule_get, METH_O, NULL}, { (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL}, { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, (char *)"\n" "S.connect(url,flags=0,options=None) -> None\n" @@ -5892,6 +6803,24 @@ static PyMethodDef SwigMethods[] = { "S.string_to_time(string) -> int\n" "Parse a LDAP time string into a UNIX timestamp.\n" ""}, + { (char *)"ldb_module_prev_set", _wrap_ldb_module_prev_set, METH_VARARGS, NULL}, + { (char *)"ldb_module_prev_get", (PyCFunction)_wrap_ldb_module_prev_get, METH_O, NULL}, + { (char *)"ldb_module_next_set", _wrap_ldb_module_next_set, METH_VARARGS, NULL}, + { (char *)"ldb_module_next_get", (PyCFunction)_wrap_ldb_module_next_get, METH_O, NULL}, + { (char *)"ldb_module___str__", (PyCFunction)_wrap_ldb_module___str__, METH_O, NULL}, + { (char *)"ldb_module___repr__", (PyCFunction)_wrap_ldb_module___repr__, METH_O, NULL}, + { (char *)"ldb_module_search", (PyCFunction) _wrap_ldb_module_search, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_add", (PyCFunction) _wrap_ldb_module_add, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_modify", (PyCFunction) _wrap_ldb_module_modify, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_delete", (PyCFunction) _wrap_ldb_module_delete, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_rename", (PyCFunction) _wrap_ldb_module_rename, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_start_transaction", (PyCFunction)_wrap_ldb_module_start_transaction, METH_O, NULL}, + { (char *)"ldb_module_end_transaction", (PyCFunction)_wrap_ldb_module_end_transaction, METH_O, NULL}, + { (char *)"ldb_module_del_transaction", (PyCFunction)_wrap_ldb_module_del_transaction, METH_O, NULL}, + { (char *)"new_ldb_module", (PyCFunction)_wrap_new_ldb_module, METH_NOARGS, NULL}, + { (char *)"delete_ldb_module", (PyCFunction)_wrap_delete_ldb_module, METH_O, NULL}, + { (char *)"ldb_module_swigregister", ldb_module_swigregister, METH_VARARGS, NULL}, + { (char *)"ldb_module_swiginit", ldb_module_swiginit, METH_VARARGS, NULL}, { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, (char *)"\n" "S.register_module(module) -> None\n" "Register a LDB module.\n" @@ -5911,7 +6840,9 @@ static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn * static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_module = {"_p_ldb_module", "struct ldb_module *|ldb_module *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_parse_tree = {"_p_ldb_parse_tree", "struct ldb_parse_tree *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0}; @@ -5937,7 +6868,9 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_ldb_ldif, &_swigt__p_ldb_message, &_swigt__p_ldb_message_element, + &_swigt__p_ldb_module, &_swigt__p_ldb_module_ops, + &_swigt__p_ldb_parse_tree, &_swigt__p_ldb_result, &_swigt__p_ldb_val, &_swigt__p_long_long, @@ -5963,7 +6896,9 @@ static swig_cast_info _swigc__p_ldb_dn[] = { {&_swigt__p_ldb_dn, 0, 0, 0},{0, 0 static swig_cast_info _swigc__p_ldb_ldif[] = { {&_swigt__p_ldb_ldif, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_message[] = { {&_swigt__p_ldb_message, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_message_element, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_module[] = { {&_swigt__p_ldb_module, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_module_ops[] = { {&_swigt__p_ldb_module_ops, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_parse_tree[] = { {&_swigt__p_ldb_parse_tree, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_val[] = { {&_swigt__p_ldb_val, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; @@ -5989,7 +6924,9 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_ldb_ldif, _swigc__p_ldb_message, _swigc__p_ldb_message_element, + _swigc__p_ldb_module, _swigc__p_ldb_module_ops, + _swigc__p_ldb_parse_tree, _swigc__p_ldb_result, _swigc__p_ldb_val, _swigc__p_long_long, diff --git a/source4/lib/ldb/libldb.m4 b/source4/lib/ldb/libldb.m4 index 77ebcc5ff4..5653794a88 100644 --- a/source4/lib/ldb/libldb.m4 +++ b/source4/lib/ldb/libldb.m4 @@ -2,6 +2,6 @@ # disable ldb_sqlite3 by default SMB_ENABLE(ldb_sqlite3, NO) -if test x"$with_sqlite3_support" = x"yes"; then - SMB_ENABLE(ldb_sqlite3, YES) -fi +#if test x"$with_sqlite3_support" = x"yes"; then +# SMB_ENABLE(ldb_sqlite3, YES) +#fi diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index eb27263b16..835715e7dc 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2005 + Copyright (C) Simo Sorce 2005-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -36,10 +36,10 @@ struct asq_context { - enum {ASQ_INIT, ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step; + enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step; struct ldb_module *module; - struct ldb_request *orig_req; + struct ldb_request *req; struct ldb_asq_control *asq_ctrl; @@ -52,7 +52,6 @@ struct asq_context { ASQ_CTRL_AFFECTS_MULTIPLE_DSA = 71 } asq_ret; - struct ldb_request *base_req; struct ldb_reply *base_res; struct ldb_request **reqs; @@ -62,192 +61,200 @@ struct asq_context { struct ldb_control **controls; }; -static struct ldb_handle *init_handle(struct ldb_request *req, struct ldb_module *module) +static struct asq_context *asq_context_init(struct ldb_module *module, struct ldb_request *req) { struct asq_context *ac; - struct ldb_handle *h; - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - h->module = module; - - ac = talloc_zero(h, struct asq_context); + ac = talloc_zero(req, struct asq_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); + ldb_oom(module->ldb); return NULL; } - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->step = ASQ_INIT; ac->module = module; - ac->orig_req = req; + ac->req = req; - return h; + return ac; } -static int asq_terminate(struct ldb_handle *handle) +static int asq_search_continue(struct asq_context *ac); + +static int asq_search_terminate(struct asq_context *ac) { - struct asq_context *ac; - struct ldb_reply *ares; struct ldb_asq_control *asq; int i; - ac = talloc_get_type(handle->private_data, struct asq_context); - if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - handle->status = LDB_SUCCESS; - handle->state = LDB_ASYNC_DONE; - - ares = talloc_zero(ac, struct ldb_reply); - if (ares == NULL) - return LDB_ERR_OPERATIONS_ERROR; - - ares->type = LDB_REPLY_DONE; - if (ac->controls) { - for (i = 0; ac->controls[i]; i++); - ares->controls = talloc_move(ares, &ac->controls); + for (i = 0; ac->controls[i]; i++) /* count em */ ; } else { i = 0; } - ares->controls = talloc_realloc(ares, ares->controls, struct ldb_control *, i + 2); - - if (ares->controls == NULL) + ac->controls = talloc_realloc(ac, ac->controls, struct ldb_control *, i + 2); + + if (ac->controls == NULL) { return LDB_ERR_OPERATIONS_ERROR; + } - ares->controls[i] = talloc(ares->controls, struct ldb_control); - if (ares->controls[i] == NULL) + ac->controls[i] = talloc(ac->controls, struct ldb_control); + if (ac->controls[i] == NULL) { return LDB_ERR_OPERATIONS_ERROR; + } - ares->controls[i]->oid = LDB_CONTROL_ASQ_OID; - ares->controls[i]->critical = 0; + ac->controls[i]->oid = LDB_CONTROL_ASQ_OID; + ac->controls[i]->critical = 0; - asq = talloc_zero(ares->controls[i], struct ldb_asq_control); + asq = talloc_zero(ac->controls[i], struct ldb_asq_control); if (asq == NULL) return LDB_ERR_OPERATIONS_ERROR; asq->result = ac->asq_ret; - - ares->controls[i]->data = asq; - ares->controls[i + 1] = NULL; + ac->controls[i]->data = asq; - ac->orig_req->callback(ac->module->ldb, ac->orig_req->context, ares); + ac->controls[i + 1] = NULL; - return LDB_SUCCESS; + return ldb_module_done(ac->req, ac->controls, NULL, LDB_SUCCESS); } -static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int asq_base_callback(struct ldb_request *req, struct ldb_reply *ares) { struct asq_context *ac; + int ret; - if (!context || !ares) { - ldb_set_errstring(ldb, "NULL Context or Result in callback"); - goto error; - } + ac = talloc_get_type(req->context, struct asq_context); - ac = talloc_get_type(context, struct asq_context); - if (ac == NULL) { - goto error; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - /* we are interested only in the single reply (base search) we receive here */ - if (ares->type == LDB_REPLY_ENTRY) { + switch (ares->type) { + case LDB_REPLY_ENTRY: ac->base_res = talloc_move(ac, &ares); - } else { + break; + + case LDB_REPLY_REFERRAL: + /* ignore referrals */ talloc_free(ares); - } + break; + case LDB_REPLY_DONE: + + talloc_free(ares); + + /* next step */ + ret = asq_search_continue(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + break; + + } return LDB_SUCCESS; -error: - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; } -static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int asq_reqs_callback(struct ldb_request *req, struct ldb_reply *ares) { struct asq_context *ac; + int ret; - if (!context || !ares) { - ldb_set_errstring(ldb, "NULL Context or Result in callback"); - goto error; - } + ac = talloc_get_type(req->context, struct asq_context); - ac = talloc_get_type(context, struct asq_context); - if (ac == NULL) { - goto error; + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - /* we are interested only in the single reply (base search) we receive here */ - if (ares->type == LDB_REPLY_ENTRY) { - + switch (ares->type) { + case LDB_REPLY_ENTRY: /* pass the message up to the original callback as we * do not have to elaborate on it any further */ - return ac->orig_req->callback(ac->module->ldb, ac->orig_req->context, ares); - - } else { /* ignore any REFERRAL or DONE reply */ + ret = ldb_module_send_entry(ac->req, ares->message); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + talloc_free(ares); + break; + + case LDB_REPLY_REFERRAL: + /* ignore referrals */ + talloc_free(ares); + break; + + case LDB_REPLY_DONE: + talloc_free(ares); + + ret = asq_search_continue(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + break; } return LDB_SUCCESS; -error: - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; } -static int asq_build_first_request(struct asq_context *ac) +static int asq_build_first_request(struct asq_context *ac, struct ldb_request **base_req) { - char **base_attrs; + const char **base_attrs; + int ret; - ac->base_req = talloc_zero(ac, struct ldb_request); - if (ac->base_req == NULL) return LDB_ERR_OPERATIONS_ERROR; + ac->req_attrs = ac->req->op.search.attrs; + ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute); + if (ac->req_attribute == NULL) + return LDB_ERR_OPERATIONS_ERROR; - ac->base_req->operation = ac->orig_req->operation; - ac->base_req->op.search.base = ac->orig_req->op.search.base; - ac->base_req->op.search.scope = LDB_SCOPE_BASE; - ac->base_req->op.search.tree = ac->orig_req->op.search.tree; - base_attrs = talloc_array(ac->base_req, char *, 2); + base_attrs = talloc_array(ac, const char *, 2); if (base_attrs == NULL) return LDB_ERR_OPERATIONS_ERROR; base_attrs[0] = talloc_strdup(base_attrs, ac->asq_ctrl->source_attribute); if (base_attrs[0] == NULL) return LDB_ERR_OPERATIONS_ERROR; base_attrs[1] = NULL; - ac->base_req->op.search.attrs = (const char * const *)base_attrs; - ac->base_req->context = ac; - ac->base_req->callback = asq_base_callback; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->base_req); + ret = ldb_build_search_req(base_req, ac->module->ldb, ac, + ac->req->op.search.base, + LDB_SCOPE_BASE, + NULL, + (const char * const *)base_attrs, + NULL, + ac, asq_base_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; + } return LDB_SUCCESS; } -static int asq_build_multiple_requests(struct asq_context *ac, struct ldb_handle *handle) +static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) { + struct ldb_control **saved_controls; + struct ldb_control *control; + struct ldb_dn *dn; struct ldb_message_element *el; - int i; + int ret, i; - /* look up the DNs */ if (ac->base_res == NULL) { return LDB_ERR_NO_SUCH_OBJECT; } + el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute); /* no values found */ if (el == NULL) { ac->asq_ret = ASQ_CTRL_SUCCESS; - return asq_terminate(handle); + *terminated = true; + return asq_search_terminate(ac); } ac->num_reqs = el->num_values; @@ -259,144 +266,75 @@ static int asq_build_multiple_requests(struct asq_context *ac, struct ldb_handle for (i = 0; i < el->num_values; i++) { - ac->reqs[i] = talloc_zero(ac->reqs, struct ldb_request); - if (ac->reqs[i] == NULL) - return LDB_ERR_OPERATIONS_ERROR; - ac->reqs[i]->operation = LDB_SEARCH; - ac->reqs[i]->op.search.base = ldb_dn_new(ac->reqs[i], ac->module->ldb, (const char *)el->values[i].data); - if ( ! ldb_dn_validate(ac->reqs[i]->op.search.base)) { + dn = ldb_dn_new(ac, ac->module->ldb, + (const char *)el->values[i].data); + if ( ! ldb_dn_validate(dn)) { ac->asq_ret = ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX; - return asq_terminate(handle); + *terminated = true; + return asq_search_terminate(ac); + } + + ret = ldb_build_search_req_ex(&ac->reqs[i], + ac->module->ldb, ac, + dn, LDB_SCOPE_BASE, + ac->req->op.search.tree, + ac->req_attrs, + ac->req->controls, + ac, asq_reqs_callback, + ac->req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - ac->reqs[i]->op.search.scope = LDB_SCOPE_BASE; - ac->reqs[i]->op.search.tree = ac->base_req->op.search.tree; - ac->reqs[i]->op.search.attrs = ac->req_attrs; - ac->reqs[i]->context = ac; - ac->reqs[i]->callback = asq_reqs_callback; - ldb_set_timeout_from_prev_req(ac->module->ldb, ac->base_req, ac->reqs[i]); + /* remove the ASQ control itself */ + control = ldb_request_get_control(ac->req, LDB_CONTROL_ASQ_OID); + if (!save_controls(control, ac->reqs[i], &saved_controls)) { + return LDB_ERR_OPERATIONS_ERROR; + } } return LDB_SUCCESS; } -static int asq_search_continue(struct ldb_handle *handle) +static int asq_search_continue(struct asq_context *ac) { - struct asq_context *ac; + bool terminated = false; int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - ac = talloc_get_type(handle->private_data, struct asq_context); - if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } switch (ac->step) { - case ASQ_INIT: - /* check the search is well formed */ - if (ac->orig_req->op.search.scope != LDB_SCOPE_BASE) { - ac->asq_ret = ASQ_CTRL_UNWILLING_TO_PERFORM; - return asq_terminate(handle); - } - - ac->req_attrs = ac->orig_req->op.search.attrs; - ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute); - if (ac->req_attribute == NULL) - return LDB_ERR_OPERATIONS_ERROR; - - /* get the object to retrieve the DNs to search */ - ret = asq_build_first_request(ac); - if (ret != LDB_SUCCESS) { - return ret; - } - - ac->step = ASQ_SEARCH_BASE; - - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - return ldb_request(ac->module->ldb, ac->base_req); - case ASQ_SEARCH_BASE: - ret = ldb_wait(ac->base_req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - - if (ac->base_req->handle->status != LDB_SUCCESS) { - handle->status = ac->base_req->handle->status; - goto done; + /* build up the requests call chain */ + ret = asq_build_multiple_requests(ac, &terminated); + if (ret != LDB_SUCCESS || terminated) { + return ret; } - if (ac->base_req->handle->state == LDB_ASYNC_DONE) { + ac->step = ASQ_SEARCH_MULTI; - /* build up the requests call chain */ - ret = asq_build_multiple_requests(ac, handle); - if (ret != LDB_SUCCESS) { - return ret; - } - if (handle->state == LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - ac->step = ASQ_SEARCH_MULTI; - - return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); - } - - /* request still pending, return to cycle again */ - return LDB_SUCCESS; + return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); case ASQ_SEARCH_MULTI: - ret = ldb_wait(ac->reqs[ac->cur_req]->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->reqs[ac->cur_req]->handle->status != LDB_SUCCESS) { - handle->status = ac->reqs[ac->cur_req]->handle->status; - } - - if (ac->reqs[ac->cur_req]->handle->state == LDB_ASYNC_DONE) { - ac->cur_req++; + ac->cur_req++; - if (ac->cur_req < ac->num_reqs) { - return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); - } - - return asq_terminate(handle); + if (ac->cur_req == ac->num_reqs) { + /* done */ + return asq_search_terminate(ac); } - /* request still pending, return to cycle again */ - return LDB_SUCCESS; - - default: - ret = LDB_ERR_OPERATIONS_ERROR; - break; + return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); } -done: - handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_ERR_OPERATIONS_ERROR; } static int asq_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_request *base_req; struct ldb_control *control; struct asq_context *ac; - struct ldb_handle *h; + int ret; /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_ASQ_OID); @@ -405,67 +343,37 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - req->handle = NULL; - - if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, - "Async interface called with NULL callback function or NULL context"); + ac = asq_context_init(module, req); + if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } - h = init_handle(req, module); - if (!h) { - return LDB_ERR_OPERATIONS_ERROR; + /* check the search is well formed */ + if (req->op.search.scope != LDB_SCOPE_BASE) { + ac->asq_ret = ASQ_CTRL_UNWILLING_TO_PERFORM; + return asq_search_terminate(ac); } - ac = talloc_get_type(h->private_data, struct asq_context); ac->asq_ctrl = talloc_get_type(control->data, struct ldb_asq_control); if (!ac->asq_ctrl) { return LDB_ERR_PROTOCOL_ERROR; } - req->handle = h; - - return asq_search_continue(h); -} - -static int asq_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; + ret = asq_build_first_request(ac, &base_req); + if (ret != LDB_SUCCESS) { + return ret; } - if (type == LDB_WAIT_ALL) { - while (handle->state != LDB_ASYNC_DONE) { - ret = asq_search_continue(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; - } + ac->step = ASQ_SEARCH_BASE; - return asq_search_continue(handle); + return ldb_request(module->ldb, base_req); } static int asq_init(struct ldb_module *module) { - struct ldb_request *req; int ret; - req = talloc_zero(module, struct ldb_request); - if (req == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "asq: Out of memory!\n"); - return LDB_ERR_OPERATIONS_ERROR; - } - - req->operation = LDB_REQ_REGISTER_CONTROL; - req->op.reg_control.oid = LDB_CONTROL_ASQ_OID; - - ret = ldb_request(module->ldb, req); + ret = ldb_mod_register_control(module, LDB_CONTROL_ASQ_OID); if (ret != LDB_SUCCESS) { ldb_debug(module->ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n"); } @@ -476,6 +384,5 @@ static int asq_init(struct ldb_module *module) const struct ldb_module_ops ldb_asq_module_ops = { .name = "asq", .search = asq_search, - .wait = asq_wait, .init_context = asq_init }; diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index a59e81becd..abb1d4ca1a 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -2,7 +2,7 @@ ldb database library Copyright (C) Andrew Tridgell 2005 - Copyright (C) Simo Sorce 2006 + Copyright (C) Simo Sorce 2006-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -173,38 +173,53 @@ failed: */ struct operational_context { - struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); + struct ldb_request *req; const char * const *attrs; }; -static int operational_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int operational_callback(struct ldb_request *req, struct ldb_reply *ares) { struct operational_context *ac; + int ret; - if (!context || !ares) { - ldb_set_errstring(ldb, "NULL Context or Result in callback"); - goto error; - } + ac = talloc_get_type(req->context, struct operational_context); - ac = talloc_get_type(context, struct operational_context); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - if (ares->type == LDB_REPLY_ENTRY) { + switch (ares->type) { + case LDB_REPLY_ENTRY: /* for each record returned post-process to add any derived attributes that have been asked for */ - if (operational_search_post_process(ac->module, ares->message, ac->attrs) != 0) { - goto error; + ret = operational_search_post_process(ac->module, + ares->message, + ac->attrs); + if (ret != 0) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - } + return ldb_module_send_entry(ac->req, ares->message); - return ac->up_callback(ldb, ac->up_context, ares); + case LDB_REPLY_REFERRAL: + /* ignore referrals */ + break; + + case LDB_REPLY_DONE: + + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); + } -error: talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return LDB_SUCCESS; } static int operational_search(struct ldb_module *module, struct ldb_request *req) @@ -212,9 +227,8 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req struct operational_context *ac; struct ldb_request *down_req; const char **search_attrs = NULL; - int i, a, ret; - - req->handle = NULL; + int i, a; + int ret; ac = talloc(req, struct operational_context); if (ac == NULL) { @@ -222,21 +236,10 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req } ac->module = module; - ac->up_context = req->context; - ac->up_callback = req->callback; + ac->req = req; ac->attrs = req->op.search.attrs; - down_req = talloc_zero(req, struct ldb_request); - if (down_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - down_req->operation = req->operation; - down_req->op.search.base = req->op.search.base; - down_req->op.search.scope = req->op.search.scope; - down_req->op.search.tree = req->op.search.tree; - - /* FIXME: I hink we should copy the tree and keep the original + /* FIXME: We must copy the tree and keep the original * unmodified. SSS */ /* replace any attributes in the parse tree that are searchable, but are stored using a different name in the @@ -264,27 +267,26 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req } } } - - /* use new set of attrs if any */ - if (search_attrs) down_req->op.search.attrs = search_attrs; - else down_req->op.search.attrs = req->op.search.attrs; - - down_req->controls = req->controls; - - down_req->context = ac; - down_req->callback = operational_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, down_req); - /* perform the search */ - ret = ldb_next_request(module, down_req); + /* use new set of attrs if any */ + if (search_attrs == NULL) { + search_attrs = req->op.search.attrs; + } - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + (const char * const *)search_attrs, + req->controls, + ac, operational_callback, + req); + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - return ret; + /* perform the search */ + return ldb_next_request(module, down_req); } static int operational_init(struct ldb_module *ctx) diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index b62b1f92cb..1a242f1be0 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2005-2006 + Copyright (C) Simo Sorce 2005-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -51,9 +51,8 @@ struct results_store { char *cookie; time_t timestamp; - struct results_store *prev; struct results_store *next; - + struct message_store *first; struct message_store *last; int num_entries; @@ -62,8 +61,6 @@ struct results_store { struct message_store *last_ref; struct ldb_control **controls; - - struct ldb_request *req; }; struct private_data { @@ -73,20 +70,25 @@ struct private_data { }; -int store_destructor(struct results_store *store) +static int store_destructor(struct results_store *del) { - if (store->prev) { - store->prev->next = store->next; - } - if (store->next) { - store->next->prev = store->prev; + struct private_data *priv = del->priv; + struct results_store *loop; + + if (priv->store == del) { + priv->store = del->next; + return 0; } - if (store == store->priv->store) { - store->priv->store = NULL; + for (loop = priv->store; loop; loop = loop->next) { + if (loop->next == del) { + loop->next = del->next; + return 0; + } } - return 0; + /* is not in list ? */ + return -1; } static struct results_store *new_store(struct private_data *priv) @@ -116,10 +118,7 @@ static struct results_store *new_store(struct private_data *priv) newr->first_ref = NULL; newr->controls = NULL; - /* put this entry as first */ - newr->prev = NULL; newr->next = priv->store; - if (priv->store != NULL) priv->store->prev = newr; priv->store = newr; talloc_set_destructor(newr, store_destructor); @@ -129,101 +128,164 @@ static struct results_store *new_store(struct private_data *priv) struct paged_context { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); - - int size; + struct ldb_request *req; struct results_store *store; + int size; + struct ldb_control **controls; }; -static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, - void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) +static int paged_results(struct paged_context *ac) { - struct paged_context *ac; - struct ldb_handle *h; + struct ldb_paged_control *paged; + struct message_store *msg; + int i, num_ctrls, ret; - h = talloc_zero(mem_ctx, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; + if (ac->store == NULL) { + return LDB_ERR_OPERATIONS_ERROR; } - h->module = module; + while (ac->store->num_entries > 0 && ac->size > 0) { + msg = ac->store->first; + ret = ldb_module_send_entry(ac->req, msg->r->message); + if (ret != LDB_SUCCESS) { + return ret; + } - ac = talloc_zero(h, struct paged_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; + ac->store->first = msg->next; + talloc_free(msg); + ac->store->num_entries--; + ac->size--; } - h->private_data = (void *)ac; + while (ac->store->first_ref != NULL) { + msg = ac->store->first_ref; + ret = ldb_module_send_referral(ac->req, msg->r->referral); + if (ret != LDB_SUCCESS) { + return ret; + } - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; + ac->store->first_ref = msg->next; + talloc_free(msg); + } - ac->module = module; - ac->up_context = context; - ac->up_callback = callback; + /* return result done */ + num_ctrls = 1; + i = 0; + + if (ac->store->controls != NULL) { + while (ac->store->controls[i]) i++; /* counting */ + + num_ctrls += i; + } + + ac->controls = talloc_array(ac, struct ldb_control *, num_ctrls +1); + if (ac->controls == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + ac->controls[num_ctrls] = NULL; + + for (i = 0; i < (num_ctrls -1); i++) { + ac->controls[i] = talloc_reference(ac->controls, ac->store->controls[i]); + } + + ac->controls[i] = talloc(ac->controls, struct ldb_control); + if (ac->controls[i] == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } - return h; + ac->controls[i]->oid = talloc_strdup(ac->controls[i], + LDB_CONTROL_PAGED_RESULTS_OID); + if (ac->controls[i]->oid == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->controls[i]->critical = 0; + + paged = talloc(ac->controls[i], struct ldb_paged_control); + if (paged == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->controls[i]->data = paged; + + if (ac->size > 0) { + paged->size = 0; + paged->cookie = NULL; + paged->cookie_len = 0; + } else { + paged->size = ac->store->num_entries; + paged->cookie = talloc_strdup(paged, ac->store->cookie); + paged->cookie_len = strlen(paged->cookie) + 1; + } + + return LDB_SUCCESS; } -static int paged_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int paged_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct paged_context *ac = NULL; + struct paged_context *ac ; + struct message_store *msg_store; + int ret; - if (!context || !ares) { - ldb_set_errstring(ldb, "NULL Context or Result in callback"); - goto error; + ac = talloc_get_type(req->context, struct paged_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - ac = talloc_get_type(context, struct paged_context); + switch (ares->type) { + case LDB_REPLY_ENTRY: + msg_store = talloc(ac->store, struct message_store); + if (msg_store == NULL) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + msg_store->next = NULL; + msg_store->r = talloc_steal(msg_store, ares); - if (ares->type == LDB_REPLY_ENTRY) { if (ac->store->first == NULL) { - ac->store->first = ac->store->last = talloc(ac->store, struct message_store); + ac->store->first = msg_store; } else { - ac->store->last->next = talloc(ac->store, struct message_store); - ac->store->last = ac->store->last->next; - } - if (ac->store->last == NULL) { - goto error; + ac->store->last->next = msg_store; } + ac->store->last = msg_store; ac->store->num_entries++; - ac->store->last->r = talloc_steal(ac->store->last, ares); - ac->store->last->next = NULL; - } + break; + + case LDB_REPLY_REFERRAL: + msg_store = talloc(ac->store, struct message_store); + if (msg_store == NULL) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + msg_store->next = NULL; + msg_store->r = talloc_steal(msg_store, ares); - if (ares->type == LDB_REPLY_REFERRAL) { if (ac->store->first_ref == NULL) { - ac->store->first_ref = ac->store->last_ref = talloc(ac->store, struct message_store); + ac->store->first_ref = msg_store; } else { - ac->store->last_ref->next = talloc(ac->store, struct message_store); - ac->store->last_ref = ac->store->last_ref->next; - } - if (ac->store->last_ref == NULL) { - goto error; + ac->store->last_ref->next = msg_store; } + ac->store->last_ref = msg_store; - ac->store->last_ref->r = talloc_steal(ac->store->last, ares); - ac->store->last_ref->next = NULL; - } + break; - if (ares->type == LDB_REPLY_DONE) { + case LDB_REPLY_DONE: ac->store->controls = talloc_move(ac->store, &ares->controls); - talloc_free(ares); + ret = paged_results(ac); + return ldb_module_done(ac->req, ac->controls, + ares->response, ret); } return LDB_SUCCESS; - -error: - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; } static int paged_search(struct ldb_module *module, struct ldb_request *req) @@ -232,8 +294,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) struct private_data *private_data; struct ldb_paged_control *paged_ctrl; struct ldb_control **saved_controls; + struct ldb_request *search_req; struct paged_context *ac; - struct ldb_handle *h; int ret; /* check if there's a paged request control */ @@ -243,65 +305,57 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - private_data = talloc_get_type(module->private_data, struct private_data); - - req->handle = NULL; - - if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, - "Async interface called with NULL callback function or NULL context"); - return LDB_ERR_OPERATIONS_ERROR; - } - paged_ctrl = talloc_get_type(control->data, struct ldb_paged_control); if (!paged_ctrl) { return LDB_ERR_PROTOCOL_ERROR; } - h = init_handle(req, module, req->context, req->callback); - if (!h) { + private_data = talloc_get_type(module->private_data, struct private_data); + + ac = talloc_zero(req, struct paged_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct paged_context); + ac->module = module; + ac->req = req; ac->size = paged_ctrl->size; /* check if it is a continuation search the store */ if (paged_ctrl->cookie_len == 0) { - - ac->store = new_store(private_data); - if (ac->store == NULL) { - talloc_free(h); - return LDB_ERR_UNWILLING_TO_PERFORM; + if (paged_ctrl->size == 0) { + return LDB_ERR_OPERATIONS_ERROR; } - ac->store->req = talloc(ac->store, struct ldb_request); - if (!ac->store->req) + ac->store = new_store(private_data); + if (ac->store == NULL) { return LDB_ERR_OPERATIONS_ERROR; + } - ac->store->req->operation = req->operation; - ac->store->req->op.search.base = req->op.search.base; - ac->store->req->op.search.scope = req->op.search.scope; - ac->store->req->op.search.tree = req->op.search.tree; - ac->store->req->op.search.attrs = req->op.search.attrs; - ac->store->req->controls = req->controls; + ret = ldb_build_search_req_ex(&search_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + req->op.search.attrs, + req->controls, + ac, + paged_search_callback, + req); /* save it locally and remove it from the list */ /* we do not need to replace them later as we * are keeping the original req intact */ - if (!save_controls(control, ac->store->req, &saved_controls)) { + if (!save_controls(control, search_req, &saved_controls)) { return LDB_ERR_OPERATIONS_ERROR; } - ac->store->req->context = ac; - ac->store->req->callback = paged_search_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, ac->store->req); - - ret = ldb_next_request(module, ac->store->req); + return ldb_next_request(module, search_req); } else { struct results_store *current = NULL; + /* TODO: age out old outstanding requests */ for (current = private_data->store; current; current = current->next) { if (strcmp(current->cookie, paged_ctrl->cookie) == 0) { current->timestamp = time(NULL); @@ -309,249 +363,52 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) } } if (current == NULL) { - talloc_free(h); return LDB_ERR_UNWILLING_TO_PERFORM; } ac->store = current; - ret = LDB_SUCCESS; - } - - req->handle = h; - - /* check if it is an abandon */ - if (ac->size == 0) { - talloc_free(ac->store); - h->status = LDB_SUCCESS; - h->state = LDB_ASYNC_DONE; - return LDB_SUCCESS; - } - - /* TODO: age out old outstanding requests */ - - return ret; - -} - -static int paged_results(struct ldb_handle *handle) -{ - struct paged_context *ac; - struct ldb_paged_control *paged; - struct ldb_reply *ares; - struct message_store *msg; - int i, num_ctrls, ret; - - ac = talloc_get_type(handle->private_data, struct paged_context); - - if (ac->store == NULL) - return LDB_ERR_OPERATIONS_ERROR; - while (ac->store->num_entries > 0 && ac->size > 0) { - msg = ac->store->first; - ret = ac->up_callback(ac->module->ldb, ac->up_context, msg->r); - if (ret != LDB_SUCCESS) { - handle->status = ret; - handle->state = LDB_ASYNC_DONE; - return ret; + /* check if it is an abandon */ + if (ac->size == 0) { + return ldb_module_done(req, NULL, NULL, + LDB_SUCCESS); } - ac->store->first = msg->next; - talloc_free(msg); - ac->store->num_entries--; - ac->size--; - } - - handle->state = LDB_ASYNC_DONE; - - while (ac->store->first_ref != NULL) { - msg = ac->store->first_ref; - ret = ac->up_callback(ac->module->ldb, ac->up_context, msg->r); + ret = paged_results(ac); if (ret != LDB_SUCCESS) { - handle->status = ret; - handle->state = LDB_ASYNC_DONE; - return ret; + return ldb_module_done(req, NULL, NULL, ret); } - - ac->store->first_ref = msg->next; - talloc_free(msg); - } - - ares = talloc_zero(ac->store, struct ldb_reply); - if (ares == NULL) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - num_ctrls = 2; - i = 0; - - if (ac->store->controls != NULL) { - ares->controls = ac->store->controls; - while (ares->controls[i]) i++; /* counting */ - - ares->controls = talloc_move(ares, &ac->store->controls); - num_ctrls += i; - } - - ares->controls = talloc_realloc(ares, ares->controls, struct ldb_control *, num_ctrls); - if (ares->controls == NULL) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; + return ldb_module_done(req, ac->controls, NULL, + LDB_SUCCESS); } - - ares->controls[i] = talloc(ares->controls, struct ldb_control); - if (ares->controls[i] == NULL) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - - ares->controls[i]->oid = talloc_strdup(ares->controls[i], LDB_CONTROL_PAGED_RESULTS_OID); - if (ares->controls[i]->oid == NULL) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - - ares->controls[i]->critical = 0; - ares->controls[i + 1] = NULL; - - paged = talloc(ares->controls[i], struct ldb_paged_control); - if (paged == NULL) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - - ares->controls[i]->data = paged; - - if (ac->size > 0) { - paged->size = 0; - paged->cookie = NULL; - paged->cookie_len = 0; - } else { - paged->size = ac->store->num_entries; - paged->cookie = talloc_strdup(paged, ac->store->cookie); - paged->cookie_len = strlen(paged->cookie) + 1; - } - - ares->type = LDB_REPLY_DONE; - - ret = ac->up_callback(ac->module->ldb, ac->up_context, ares); - - handle->status = ret; - - return ret; -} - -static int paged_wait_once(struct ldb_handle *handle) { - struct paged_context *ac; - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - - handle->state = LDB_ASYNC_PENDING; - - ac = talloc_get_type(handle->private_data, struct paged_context); - - if (ac->store->req->handle->state == LDB_ASYNC_DONE) { - /* if lower level is finished we do not need to call it anymore */ - /* return all we have until size == 0 or we empty storage */ - ret = paged_results(handle); - - /* we are done, if num_entries is zero free the storage - * as that mean we delivered the last batch */ - if (ac->store->num_entries == 0) { - talloc_free(ac->store); - } - - return ret; - } - - ret = ldb_wait(ac->store->req->handle, LDB_WAIT_NONE); - if (ret != LDB_SUCCESS) { - handle->state = LDB_ASYNC_DONE; - handle->status = ret; - return ret; - } - - handle->status = ret; - - if (ac->store->num_entries >= ac->size || - ac->store->req->handle->state == LDB_ASYNC_DONE) { - - ret = paged_results(handle); - - /* we are done, if num_entries is zero free the storage - * as that mean we delivered the last batch */ - if (ac->store->num_entries == 0) { - talloc_free(ac->store); - } - } - - return ret; -} - -static int paged_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (type == LDB_WAIT_ALL) { - while (handle->state != LDB_ASYNC_DONE) { - ret = paged_wait_once(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; - } - - return paged_wait_once(handle); } static int paged_request_init(struct ldb_module *module) { struct private_data *data; - struct ldb_request *req; int ret; data = talloc(module, struct private_data); if (data == NULL) { return LDB_ERR_OTHER; } - + data->next_free_id = 1; data->store = NULL; module->private_data = data; - req = talloc(module, struct ldb_request); - if (req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - req->operation = LDB_REQ_REGISTER_CONTROL; - req->op.reg_control.oid = LDB_CONTROL_PAGED_RESULTS_OID; - req->controls = NULL; - - ret = ldb_request(module->ldb, req); + ret = ldb_mod_register_control(module, LDB_CONTROL_PAGED_RESULTS_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "paged_request: Unable to register control with rootdse!\n"); + ldb_debug(module->ldb, LDB_DEBUG_WARNING, + "paged_request:" + "Unable to register control with rootdse!\n"); } - talloc_free(req); return ldb_next_init(module); } const struct ldb_module_ops ldb_paged_results_module_ops = { .name = "paged_results", .search = paged_search, - .wait = paged_wait, .init_context = paged_request_init }; diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 40e87f70d6..7a728e3bb0 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2005-2006 + Copyright (C) Simo Sorce 2005-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -46,12 +46,7 @@ struct private_data { struct ps_context { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); - - struct ldb_request *orig_req; - - struct ldb_request *new_req; + struct ldb_request *req; bool pending; @@ -59,51 +54,13 @@ struct ps_context { int num_referrals; }; -static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, - void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) +static int check_ps_continuation(struct ldb_request *req, struct ldb_reply *ares) { struct ps_context *ac; - struct ldb_handle *h; - - h = talloc_zero(mem_ctx, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - - ac = talloc_zero(h, struct ps_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; - } - - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->module = module; - ac->up_context = context; - ac->up_callback = callback; - - ac->pending = false; - - - - ac->saved_referrals = NULL; - ac->num_referrals = 0; - - return h; -} - -static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) -{ struct ldb_paged_control *rep_control, *req_control; + ac = talloc_get_type(req->context, struct ps_context); + /* look up our paged control */ if (!ares->controls || strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ares->controls[0]->oid) != 0) { /* something wrong here */ @@ -122,12 +79,12 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) /* if there's a reply control we must find a request * control matching it */ - if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ac->new_req->controls[0]->oid) != 0) { + if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, req->controls[0]->oid) != 0) { /* something wrong here */ return LDB_ERR_OPERATIONS_ERROR; } - req_control = talloc_get_type(ac->new_req->controls[0]->data, struct ldb_paged_control); + req_control = talloc_get_type(req->controls[0]->data, struct ldb_paged_control); if (req_control->cookie) { talloc_free(req_control->cookie); @@ -142,7 +99,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) return LDB_SUCCESS; } -static int store_referral(char *referral, struct ps_context *ac) +static int store_referral(struct ps_context *ac, char *referral) { ac->saved_referrals = talloc_realloc(ac, ac->saved_referrals, char *, ac->num_referrals + 2); if (!ac->saved_referrals) { @@ -160,13 +117,14 @@ static int store_referral(char *referral, struct ps_context *ac) return LDB_SUCCESS; } -static int send_referrals(struct ldb_context *ldb, struct ps_context *ac) +static int send_referrals(struct ps_context *ac) { struct ldb_reply *ares; + int ret; int i; for (i = 0; i < ac->num_referrals; i++) { - ares = talloc_zero(ac, struct ldb_reply); + ares = talloc_zero(ac->req, struct ldb_reply); if (!ares) { return LDB_ERR_OPERATIONS_ERROR; } @@ -174,69 +132,87 @@ static int send_referrals(struct ldb_context *ldb, struct ps_context *ac) ares->type = LDB_REPLY_REFERRAL; ares->referral = ac->saved_referrals[i]; - ac->up_callback(ldb, ac->up_context, ares); + ret = ldb_module_send_referral(ac->req, ares->referral); + if (ret != LDB_SUCCESS) { + return ret; + } } return LDB_SUCCESS; } -static int ps_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int ps_next_request(struct ps_context *ac); + +static int ps_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct ps_context *ac = NULL; - int ret = LDB_ERR_OPERATIONS_ERROR; + struct ps_context *ac; + int ret; - if (!context || !ares) { - ldb_set_errstring(ldb, "NULL Context or Result in callback"); - goto error; - } + ac = talloc_get_type(req->context, struct ps_context); - ac = talloc_get_type(context, struct ps_context); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } switch (ares->type) { case LDB_REPLY_ENTRY: - ac->up_callback(ldb, ac->up_context, ares); + ret = ldb_module_send_entry(ac->req, ares->message); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } break; case LDB_REPLY_REFERRAL: - ret = store_referral(ares->referral, ac); + ret = store_referral(ac, ares->referral); if (ret != LDB_SUCCESS) { - goto error; + return ldb_module_done(ac->req, NULL, NULL, ret); } break; case LDB_REPLY_DONE: - ret = check_ps_continuation(ares, ac); + + ret = check_ps_continuation(req, ares); if (ret != LDB_SUCCESS) { - goto error; + return ldb_module_done(ac->req, NULL, NULL, ret); } - if (!ac->pending) { + + if (ac->pending) { + + ret = ps_next_request(ac); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, + NULL, NULL, ret); + } + + } else { + /* send referrals */ - ret = send_referrals(ldb, ac); + ret = send_referrals(ac); if (ret != LDB_SUCCESS) { - goto error; + return ldb_module_done(ac->req, + NULL, NULL, ret); } /* send REPLY_DONE */ - ac->up_callback(ldb, ac->up_context, ares); + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); } break; - default: - goto error; } - return LDB_SUCCESS; - -error: talloc_free(ares); - return ret; + return LDB_SUCCESS; } static int ps_search(struct ldb_module *module, struct ldb_request *req) { struct private_data *private_data; - struct ldb_paged_control *control; struct ps_context *ac; - struct ldb_handle *h; private_data = talloc_get_type(module->private_data, struct private_data); @@ -248,216 +224,151 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, - "Async interface called with NULL callback function or NULL context"); - return LDB_ERR_OPERATIONS_ERROR; - } - - h = init_handle(req, module, req->context, req->callback); - if (!h) { + ac = talloc_zero(req, struct ps_context); + if (ac == NULL) { + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct ps_context); - - ac->new_req = talloc(ac, struct ldb_request); - if (!ac->new_req) return LDB_ERR_OPERATIONS_ERROR; - - ac->new_req->controls = talloc_array(ac->new_req, struct ldb_control *, 2); - if (!ac->new_req->controls) return LDB_ERR_OPERATIONS_ERROR; - - ac->new_req->controls[0] = talloc(ac->new_req->controls, struct ldb_control); - if (!ac->new_req->controls[0]) return LDB_ERR_OPERATIONS_ERROR; - - control = talloc(ac->new_req->controls[0], struct ldb_paged_control); - if (!control) return LDB_ERR_OPERATIONS_ERROR; - - control->size = PS_DEFAULT_PAGE_SIZE; - control->cookie = NULL; - control->cookie_len = 0; - - ac->new_req->controls[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID; - ac->new_req->controls[0]->critical = 1; - ac->new_req->controls[0]->data = control; - - ac->new_req->controls[1] = NULL; - ac->new_req->operation = req->operation; - ac->new_req->op.search.base = req->op.search.base; - ac->new_req->op.search.scope = req->op.search.scope; - ac->new_req->op.search.tree = req->op.search.tree; - ac->new_req->op.search.attrs = req->op.search.attrs; - ac->new_req->context = ac; - ac->new_req->callback = ps_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, ac->new_req); - - req->handle = h; + ac->module = module; + ac->req = req; + ac->pending = false; + ac->saved_referrals = NULL; + ac->num_referrals = 0; - return ldb_next_request(module, ac->new_req); + return ps_next_request(ac); } -static int ps_continuation(struct ldb_handle *handle) -{ - struct ps_context *ac; +static int ps_next_request(struct ps_context *ac) { - if (!handle || !handle->private_data) { + struct ldb_paged_control *control; + struct ldb_control **controls; + struct ldb_request *new_req; + int ret; + + controls = talloc_array(ac, struct ldb_control *, 2); + if (!controls) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(handle->private_data, struct ps_context); - - /* reset the requests handle */ - ac->new_req->handle = NULL; - - return ldb_next_request(handle->module, ac->new_req); -} - -static int ps_wait_once(struct ldb_handle *handle) -{ - struct ps_context *ac; - int ret; - - if (!handle || !handle->private_data) { + controls[0] = talloc(controls, struct ldb_control); + if (!controls[0]) { return LDB_ERR_OPERATIONS_ERROR; } - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; + control = talloc(controls[0], struct ldb_paged_control); + if (!control) { + return LDB_ERR_OPERATIONS_ERROR; } - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct ps_context); - - ret = ldb_wait(ac->new_req->handle, LDB_WAIT_NONE); + control->size = PS_DEFAULT_PAGE_SIZE; + control->cookie = NULL; + control->cookie_len = 0; + controls[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID; + controls[0]->critical = 1; + controls[0]->data = control; + controls[1] = NULL; + + ret = ldb_build_search_req_ex(&new_req, ac->module->ldb, ac, + ac->req->op.search.base, + ac->req->op.search.scope, + ac->req->op.search.tree, + ac->req->op.search.attrs, + controls, + ac, + ps_callback, + ac->req); if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - - if (ac->new_req->handle->status != LDB_SUCCESS) { - handle->status = ac->new_req->handle->status; - goto done; - } - - if (ac->new_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* see if we need to send another request for the next batch */ - if (ac->pending) { - ret = ps_continuation(handle); - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - - /* continue the search with the next request */ - return LDB_SUCCESS; + return ret; } + talloc_steal(new_req, controls); - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; + return ldb_next_request(ac->module, new_req); } -static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type) +static int check_supported_paged(struct ldb_request *req, + struct ldb_reply *ares) { - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } + struct private_data *data; - if (type == LDB_WAIT_ALL) { - while (handle->state != LDB_ASYNC_DONE) { - ret = ps_wait_once(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } + data = talloc_get_type(req->context, struct private_data); - return handle->status; + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } - return ps_wait_once(handle); -} -static int check_supported_paged(struct ldb_context *ldb, void *context, - struct ldb_reply *ares) -{ - struct private_data *data; - data = talloc_get_type(context, - struct private_data); - if (ares->type == LDB_REPLY_ENTRY) { + switch (ares->type) { + case LDB_REPLY_ENTRY: if (ldb_msg_check_string_attribute(ares->message, "supportedControl", LDB_CONTROL_PAGED_RESULTS_OID)) { data->paged_supported = true; } + break; + + case LDB_REPLY_REFERRAL: + /* ignore */ + break; + + case LDB_REPLY_DONE: + return ldb_request_done(req, LDB_SUCCESS); } + + talloc_free(ares); return LDB_SUCCESS; } - static int ps_init(struct ldb_module *module) { static const char *attrs[] = { "supportedControl", NULL }; struct private_data *data; + struct ldb_dn *base; int ret; struct ldb_request *req; data = talloc(module, struct private_data); if (data == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return LDB_ERR_OTHER; + ldb_oom(module->ldb); + return LDB_ERR_OPERATIONS_ERROR; } module->private_data = data; data->paged_supported = false; - req = talloc(module, struct ldb_request); - if (req == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + base = ldb_dn_new(module, module->ldb, ""); + if (base == NULL) { + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - - req->operation = LDB_SEARCH; - req->op.search.base = ldb_dn_new(req, module->ldb, ""); - req->op.search.scope = LDB_SCOPE_BASE; - - req->op.search.tree = ldb_parse_tree(req, "objectClass=*"); - if (req->op.search.tree == NULL) { - ldb_set_errstring(module->ldb, "Unable to parse search expression"); - talloc_free(req); - return LDB_ERR_OPERATIONS_ERROR; + ret = ldb_build_search_req(&req, module->ldb, module, + base, LDB_SCOPE_BASE, + "(objectClass=*)", + attrs, NULL, + data, check_supported_paged, + NULL); + if (ret != LDB_SUCCESS) { + return ret; } - req->op.search.attrs = attrs; - req->controls = NULL; - req->context = data; - req->callback = check_supported_paged; - ldb_set_timeout(module->ldb, req, 0); /* use default timeout */ - ret = ldb_next_request(module, req); - if (ret == LDB_SUCCESS) { ret = ldb_wait(req->handle, LDB_WAIT_ALL); } - - talloc_free(req); if (ret != LDB_SUCCESS) { return ret; } + talloc_free(base); + talloc_free(req); + return ldb_next_init(module); } _PUBLIC_ const struct ldb_module_ops ldb_paged_searches_module_ops = { .name = "paged_searches", .search = ps_search, - .wait = ps_wait, .init_context = ps_init }; diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 65c044c0f4..62b8ce5112 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -2,7 +2,7 @@ ldb database library Copyright (C) Andrew Bartlet 2005 - Copyright (C) Simo Sorce 2006 + Copyright (C) Simo Sorce 2006-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -38,6 +38,14 @@ #include "ldb_includes.h" +struct rename_context { + + struct ldb_module *module; + struct ldb_request *req; + + struct ldb_reply *ares; +}; + static struct ldb_message_element *rdn_name_find_attribute(const struct ldb_message *msg, const char *name) { int i; @@ -51,11 +59,38 @@ static struct ldb_message_element *rdn_name_find_attribute(const struct ldb_mess return NULL; } +static int rdn_name_add_callback(struct ldb_request *req, + struct ldb_reply *ares) +{ + struct rename_context *ac; + + ac = talloc_get_type(req->context, struct rename_context); + + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + if (ares->type != LDB_REPLY_DONE) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + + return ldb_module_done(ac->req, ares->controls, + ares->response, LDB_SUCCESS); +} + static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *down_req; + struct rename_context *ac; struct ldb_message *msg; struct ldb_message_element *attribute; + const struct ldb_schema_attribute *a; const char *rdn_name; struct ldb_val rdn_val; int i, ret; @@ -67,21 +102,22 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - down_req = talloc(req, struct ldb_request); - if (down_req == NULL) { + ac = talloc_zero(req, struct rename_context); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - *down_req = *req; + ac->module = module; + ac->req = req; - down_req->op.add.message = msg = ldb_msg_copy_shallow(down_req, req->op.add.message); + msg = ldb_msg_copy_shallow(req, req->op.add.message); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } rdn_name = ldb_dn_get_rdn_name(msg->dn); if (rdn_name == NULL) { - talloc_free(down_req); + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } @@ -93,7 +129,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) } if (ldb_msg_add_value(msg, "name", &rdn_val, NULL) != 0) { - talloc_free(down_req); + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } @@ -101,14 +137,16 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) if (!attribute) { if (ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL) != 0) { - talloc_free(down_req); + talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } } else { - const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, rdn_name); + a = ldb_schema_attribute_by_name(module->ldb, rdn_name); for (i = 0; i < attribute->num_values; i++) { - if (a->syntax->comparison_fn(module->ldb, msg, &rdn_val, &attribute->values[i]) == 0) { + ret = a->syntax->comparison_fn(module->ldb, msg, + &rdn_val, &attribute->values[i]); + if (ret == 0) { /* overwrite so it matches in case */ attribute->values[i] = rdn_val; break; @@ -118,218 +156,166 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "RDN mismatch on %s: %s (%s)", ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data); - talloc_free(down_req); + talloc_free(ac); /* Match AD's error here */ return LDB_ERR_INVALID_DN_SYNTAX; } } - /* go on with the call chain */ - ret = ldb_next_request(module, down_req); - - /* do not free down_req as the call results may be linked to it, - * it will be freed when the upper level request get freed */ - if (ret == LDB_SUCCESS) { - req->handle = down_req->handle; + ret = ldb_build_add_req(&down_req, module->ldb, req, + msg, + req->controls, + ac, rdn_name_add_callback, + req); + if (ret != LDB_SUCCESS) { + return ret; } - return ret; -} - -struct rename_context { + talloc_steal(down_req, msg); - enum {RENAME_RENAME, RENAME_MODIFY} step; - struct ldb_request *orig_req; - struct ldb_request *down_req; - struct ldb_request *mod_req; -}; + /* go on with the call chain */ + return ldb_next_request(module, down_req); +} -static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) +static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct ldb_handle *h; struct rename_context *ac; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); + ac = talloc_get_type(req->context, struct rename_context); - /* do not manipulate our control entries */ - if (ldb_dn_is_special(req->op.rename.newdn)) { - return ldb_next_request(module, req); + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - - h = talloc_zero(req, struct ldb_handle); - if (h == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); } - h->module = module; - - ac = talloc_zero(h, struct rename_context); - if (ac == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + /* the only supported reply right now is a LDB_REPLY_DONE */ + if (ares->type != LDB_REPLY_DONE) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->orig_req = req; - ac->down_req = talloc(req, struct ldb_request); - if (ac->down_req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - *(ac->down_req) = *req; - - ac->step = RENAME_RENAME; - - req->handle = h; - - /* rename first, modify "name" if rename is ok */ - return ldb_next_request(module, ac->down_req); + /* send saved controls eventually */ + return ldb_module_done(ac->req, ac->ares->controls, + ac->ares->response, LDB_SUCCESS); } -static int rdn_name_rename_do_mod(struct ldb_handle *h) { - +static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) +{ struct rename_context *ac; + struct ldb_request *mod_req; const char *rdn_name; struct ldb_val rdn_val; struct ldb_message *msg; + int ret; - ac = talloc_get_type(h->private_data, struct rename_context); + ac = talloc_get_type(req->context, struct rename_context); - ac->mod_req = talloc_zero(ac, struct ldb_request); + if (!ares) { + goto error; + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } - ac->mod_req->operation = LDB_MODIFY; - ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req); - if (msg == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + /* the only supported reply right now is a LDB_REPLY_DONE */ + if (ares->type != LDB_REPLY_DONE) { + goto error; } - msg->dn = ldb_dn_copy(msg, ac->orig_req->op.rename.newdn); + /* save reply for caller */ + ac->ares = talloc_steal(ac, ares); + + msg = ldb_msg_new(ac); + if (msg == NULL) { + goto error; + } + msg->dn = ldb_dn_copy(msg, ac->req->op.rename.newdn); if (msg->dn == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + goto error; } - - rdn_name = ldb_dn_get_rdn_name(ac->orig_req->op.rename.newdn); + rdn_name = ldb_dn_get_rdn_name(ac->req->op.rename.newdn); if (rdn_name == NULL) { - return LDB_ERR_OPERATIONS_ERROR; + goto error; } - rdn_val = ldb_val_dup(msg, ldb_dn_get_rdn_val(ac->orig_req->op.rename.newdn)); + rdn_val = ldb_val_dup(msg, ldb_dn_get_rdn_val(ac->req->op.rename.newdn)); if (ldb_msg_add_empty(msg, rdn_name, LDB_FLAG_MOD_REPLACE, NULL) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + goto error; } if (ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + goto error; } if (ldb_msg_add_empty(msg, "name", LDB_FLAG_MOD_REPLACE, NULL) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + goto error; } if (ldb_msg_add_value(msg, "name", &rdn_val, NULL) != 0) { - return LDB_ERR_OPERATIONS_ERROR; + goto error; } - ldb_set_timeout_from_prev_req(h->module->ldb, ac->orig_req, ac->mod_req); - - ac->step = RENAME_MODIFY; + ret = ldb_build_mod_req(&mod_req, ac->module->ldb, + ac, msg, NULL, + ac, rdn_modify_callback, + req); + if (ret != LDB_SUCCESS) { + return ldb_module_done(ac->req, NULL, NULL, ret); + } + talloc_steal(mod_req, msg); /* do the mod call */ - return ldb_request(h->module->ldb, ac->mod_req); + return ldb_request(ac->module->ldb, mod_req); + +error: + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } -static int rdn_name_wait_once(struct ldb_handle *handle) +static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) { struct rename_context *ac; + struct ldb_request *down_req; int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (handle->state == LDB_ASYNC_DONE) { - return handle->status; - } - handle->state = LDB_ASYNC_PENDING; - handle->status = LDB_SUCCESS; - - ac = talloc_get_type(handle->private_data, struct rename_context); - - switch(ac->step) { - case RENAME_RENAME: - ret = ldb_wait(ac->down_req->handle, LDB_WAIT_NONE); - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->down_req->handle->status != LDB_SUCCESS) { - handle->status = ac->down_req->handle->status; - goto done; - } - - if (ac->down_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - /* rename operation done */ - return rdn_name_rename_do_mod(handle); - - case RENAME_MODIFY: - ret = ldb_wait(ac->mod_req->handle, LDB_WAIT_NONE); - if (ret != LDB_SUCCESS) { - handle->status = ret; - goto done; - } - if (ac->mod_req->handle->status != LDB_SUCCESS) { - handle->status = ac->mod_req->handle->status; - goto done; - } - - if (ac->mod_req->handle->state != LDB_ASYNC_DONE) { - return LDB_SUCCESS; - } - - break; + ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); - default: - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; + /* do not manipulate our control entries */ + if (ldb_dn_is_special(req->op.rename.newdn)) { + return ldb_next_request(module, req); } - ret = LDB_SUCCESS; - -done: - handle->state = LDB_ASYNC_DONE; - return ret; -} - -static int rdn_name_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - int ret; - - if (!handle || !handle->private_data) { + ac = talloc_zero(req, struct rename_context); + if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - if (type == LDB_WAIT_ALL) { - while (handle->state != LDB_ASYNC_DONE) { - ret = rdn_name_wait_once(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } + ac->module = module; + ac->req = req; - return handle->status; + ret = ldb_build_rename_req(&down_req, + module->ldb, + ac, + req->op.rename.olddn, + req->op.rename.newdn, + req->controls, + ac, + rdn_rename_callback, + req); + + if (ret != LDB_SUCCESS) { + return LDB_ERR_OPERATIONS_ERROR; } - return rdn_name_wait_once(handle); + /* rename first, modify "name" if rename is ok */ + return ldb_next_request(module, down_req); } const struct ldb_module_ops ldb_rdn_name_module_ops = { .name = "rdn_name", .add = rdn_name_add, .rename = rdn_name_rename, - .wait = rdn_name_wait }; diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 746befa559..64d60f370c 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -1,7 +1,7 @@ /* ldb database library - Copyright (C) Simo Sorce 2005 + Copyright (C) Simo Sorce 2005-2008 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -43,8 +43,6 @@ struct opaque { struct sort_context { struct ldb_module *module; - void *up_context; - int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); char *attributeName; char *orderingRule; @@ -53,7 +51,6 @@ struct sort_context { struct ldb_request *req; struct ldb_message **msgs; char **referrals; - struct ldb_control **controls; int num_msgs; int num_refs; @@ -61,40 +58,6 @@ struct sort_context { int sort_result; }; -static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, - void *context, - int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) -{ - struct sort_context *ac; - struct ldb_handle *h; - - h = talloc_zero(mem_ctx, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - return NULL; - } - - h->module = module; - - ac = talloc_zero(h, struct sort_context); - if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); - talloc_free(h); - return NULL; - } - - h->private_data = (void *)ac; - - h->state = LDB_ASYNC_INIT; - h->status = LDB_SUCCESS; - - ac->module = module; - ac->up_context = context; - ac->up_callback = callback; - - return h; -} - static int build_response(void *mem_ctx, struct ldb_control ***ctrls, int result, const char *desc) { struct ldb_control **controls; @@ -142,7 +105,7 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo struct sort_context *ac = talloc_get_type(opaque, struct sort_context); struct ldb_message_element *el1, *el2; - if (ac->sort_result != 0) { + if (!ac || ac->sort_result != 0) { /* an error occurred previously, * let's exit the sorting by returning always 0 */ return 0; @@ -154,7 +117,7 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo if (!el1 || !el2) { /* the attribute was not found return and * set an error */ - ac->sort_result = 53; + ac->sort_result = LDB_ERR_UNWILLING_TO_PERFORM; return 0; } @@ -164,51 +127,111 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]); } -static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int server_sort_results(struct sort_context *ac) { - struct sort_context *ac = NULL; - - if (!context || !ares) { - ldb_set_errstring(ldb, "NULL Context or Result in callback"); - goto error; - } + struct ldb_reply *ares; + int i, ret; + + ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName); + ac->sort_result = 0; + + ldb_qsort(ac->msgs, ac->num_msgs, + sizeof(struct ldb_message *), + ac, (ldb_qsort_cmp_fn_t)sort_compare); + + if (ac->sort_result != LDB_SUCCESS) { + return ac->sort_result; + } + + for (i = 0; i < ac->num_msgs; i++) { + ares = talloc_zero(ac, struct ldb_reply); + if (!ares) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ares->type = LDB_REPLY_ENTRY; + ares->message = talloc_move(ares, &ac->msgs[i]); + + ret = ldb_module_send_entry(ac->req, ares->message); + if (ret != LDB_SUCCESS) { + return ret; + } + } + + for (i = 0; i < ac->num_refs; i++) { + ares = talloc_zero(ac, struct ldb_reply); + if (!ares) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ares->type = LDB_REPLY_REFERRAL; + ares->referral = talloc_move(ares, &ac->referrals[i]); + + ret = ldb_module_send_referral(ac->req, ares->referral); + if (ret != LDB_SUCCESS) { + return ret; + } + } + + return LDB_SUCCESS; +} + +static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply *ares) +{ + struct sort_context *ac; + int ret; - ac = talloc_get_type(context, struct sort_context); + ac = talloc_get_type(req->context, struct sort_context); - if (ares->type == LDB_REPLY_ENTRY) { + if (!ares) { + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_module_done(ac->req, ares->controls, + ares->response, ares->error); + } + + switch (ares->type) { + case LDB_REPLY_ENTRY: ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2); if (! ac->msgs) { - goto error; + talloc_free(ares); + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ac->msgs[ac->num_msgs + 1] = NULL; - - ac->msgs[ac->num_msgs] = talloc_move(ac->msgs, &ares->message); + ac->msgs[ac->num_msgs] = talloc_steal(ac->msgs, ares->message); ac->num_msgs++; - } + ac->msgs[ac->num_msgs] = NULL; - if (ares->type == LDB_REPLY_REFERRAL) { + break; + + case LDB_REPLY_REFERRAL: ac->referrals = talloc_realloc(ac, ac->referrals, char *, ac->num_refs + 2); if (! ac->referrals) { - goto error; + talloc_free(ares); + ldb_oom(ac->module->ldb); + return ldb_module_done(ac->req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - ac->referrals[ac->num_refs + 1] = NULL; - ac->referrals[ac->num_refs] = talloc_move(ac->referrals, &ares->referral); - + ac->referrals[ac->num_refs] = talloc_steal(ac->referrals, ares->referral); ac->num_refs++; - } + ac->referrals[ac->num_refs] = NULL; - if (ares->type == LDB_REPLY_DONE) { - ac->controls = talloc_move(ac, &ares->controls); + break; + + case LDB_REPLY_DONE: + + ret = server_sort_results(ac); + return ldb_module_done(ac->req, ares->controls, + ares->response, ret); } talloc_free(ares); return LDB_SUCCESS; - -error: - talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; } static int server_sort_search(struct ldb_module *module, struct ldb_request *req) @@ -216,8 +239,9 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req struct ldb_control *control; struct ldb_server_sort_control **sort_ctrls; struct ldb_control **saved_controls; + struct ldb_control **controls; + struct ldb_request *down_req; struct sort_context *ac; - struct ldb_handle *h; int ret; /* check if there's a paged request control */ @@ -227,19 +251,14 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req return ldb_next_request(module, req); } - req->handle = NULL; - - if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, - "Async interface called with NULL callback function or NULL context"); - return LDB_ERR_OPERATIONS_ERROR; - } - - h = init_handle(req, module, req->context, req->callback); - if (!h) { + ac = talloc_zero(req, struct sort_context); + if (ac == NULL) { + ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_get_type(h->private_data, struct sort_context); + + ac->module = module; + ac->req = req; sort_ctrls = talloc_get_type(control->data, struct ldb_server_sort_control *); if (!sort_ctrls) { @@ -251,26 +270,20 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req if (sort_ctrls[1] != NULL) { if (control->critical) { - struct ldb_reply *ares; - - ares = talloc_zero(req, struct ldb_reply); - if (!ares) - return LDB_ERR_OPERATIONS_ERROR; - /* 53 = unwilling to perform */ - ares->type = LDB_REPLY_DONE; - if ((ret = build_response(ares, &ares->controls, 53, "sort control is not complete yet")) != LDB_SUCCESS) { - return ret; + /* callback immediately */ + ret = build_response(req, &controls, + LDB_ERR_UNWILLING_TO_PERFORM, + "sort control is not complete yet"); + if (ret != LDB_SUCCESS) { + return ldb_module_done(req, NULL, NULL, + LDB_ERR_OPERATIONS_ERROR); } - h->status = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; - h->state = LDB_ASYNC_DONE; - ret = ac->up_callback(module->ldb, ac->up_context, ares); - - return ret; + return ldb_module_done(req, controls, NULL, ret); } else { /* just pass the call down and don't do any sorting */ - ldb_next_request(module, req); + return ldb_next_request(module, req); } } @@ -278,181 +291,45 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req ac->orderingRule = sort_ctrls[0]->orderingRule; ac->reverse = sort_ctrls[0]->reverse; - ac->req = talloc(req, struct ldb_request); - if (!ac->req) + ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + req->op.search.attrs, + req->controls, + ac, + server_sort_search_callback, + req); + if (ret != LDB_SUCCESS) { return LDB_ERR_OPERATIONS_ERROR; - - ac->req->operation = req->operation; - ac->req->op.search.base = req->op.search.base; - ac->req->op.search.scope = req->op.search.scope; - ac->req->op.search.tree = req->op.search.tree; - ac->req->op.search.attrs = req->op.search.attrs; - ac->req->controls = req->controls; + } /* save it locally and remove it from the list */ /* we do not need to replace them later as we * are keeping the original req intact */ - if (!save_controls(control, ac->req, &saved_controls)) { + if (!save_controls(control, down_req, &saved_controls)) { return LDB_ERR_OPERATIONS_ERROR; } - ac->req->context = ac; - ac->req->callback = server_sort_search_callback; - ldb_set_timeout_from_prev_req(module->ldb, req, ac->req); - - req->handle = h; - - return ldb_next_request(module, ac->req); -} - -static int server_sort_results(struct ldb_handle *handle) -{ - struct sort_context *ac; - struct ldb_reply *ares; - int i, ret; - - ac = talloc_get_type(handle->private_data, struct sort_context); - - ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName); - ac->sort_result = 0; - - ldb_qsort(ac->msgs, ac->num_msgs, - sizeof(struct ldb_message *), - ac, (ldb_qsort_cmp_fn_t)sort_compare); - - for (i = 0; i < ac->num_msgs; i++) { - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - - ares->type = LDB_REPLY_ENTRY; - ares->message = talloc_move(ares, &ac->msgs[i]); - - handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares); - if (handle->status != LDB_SUCCESS) { - return handle->status; - } - } - - for (i = 0; i < ac->num_refs; i++) { - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - - ares->type = LDB_REPLY_REFERRAL; - ares->referral = talloc_move(ares, &ac->referrals[i]); - - handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares); - if (handle->status != LDB_SUCCESS) { - return handle->status; - } - } - - ares = talloc_zero(ac, struct ldb_reply); - if (!ares) { - handle->status = LDB_ERR_OPERATIONS_ERROR; - return handle->status; - } - - ares->type = LDB_REPLY_DONE; - ares->controls = talloc_move(ares, &ac->controls); - - handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares); - if (handle->status != LDB_SUCCESS) { - return handle->status; - } - - if ((ret = build_response(ac, &ac->controls, ac->sort_result, "sort control is not complete yet")) != LDB_SUCCESS) { - return ret; - } - - return LDB_SUCCESS; -} - -static int server_sort_wait_once(struct ldb_handle *handle) -{ - struct sort_context *ac; - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ac = talloc_get_type(handle->private_data, struct sort_context); - - ret = ldb_wait(ac->req->handle, LDB_WAIT_NONE); - - if (ret != LDB_SUCCESS) { - handle->status = ret; - return ret; - } - - handle->state = ac->req->handle->state; - handle->status = ac->req->handle->status; - - if (handle->status != LDB_SUCCESS) { - return handle->status; - } - - if (handle->state == LDB_ASYNC_DONE) { - ret = server_sort_results(handle); - } - - return ret; -} - -static int server_sort_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ - int ret; - - if (!handle || !handle->private_data) { - return LDB_ERR_OPERATIONS_ERROR; - } - - if (type == LDB_WAIT_ALL) { - while (handle->state != LDB_ASYNC_DONE) { - ret = server_sort_wait_once(handle); - if (ret != LDB_SUCCESS) { - return ret; - } - } - - return handle->status; - } - - return server_sort_wait_once(handle); + return ldb_next_request(module, down_req); } static int server_sort_init(struct ldb_module *module) { - struct ldb_request *req; int ret; - req = talloc(module, struct ldb_request); - if (req == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - - req->operation = LDB_REQ_REGISTER_CONTROL; - req->op.reg_control.oid = LDB_CONTROL_SERVER_SORT_OID; - req->controls = NULL; - - ret = ldb_request(module->ldb, req); + ret = ldb_mod_register_control(module, LDB_CONTROL_SERVER_SORT_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "server_sort: Unable to register control with rootdse!\n"); + ldb_debug(module->ldb, LDB_DEBUG_WARNING, + "server_sort:" + "Unable to register control with rootdse!\n"); } - talloc_free(req); return ldb_next_init(module); } const struct ldb_module_ops ldb_server_sort_module_ops = { .name = "server_sort", .search = server_sort_search, - .wait = server_sort_wait, .init_context = server_sort_init }; diff --git a/source4/lib/ldb/nssldb/ldb-grp.c b/source4/lib/ldb/nssldb/ldb-grp.c index 71e27a9161..5e7556dc73 100644 --- a/source4/lib/ldb/nssldb/ldb-grp.c +++ b/source4/lib/ldb/nssldb/ldb-grp.c @@ -60,11 +60,12 @@ NSS_STATUS _nss_ldb_setgrent(void) } ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &_ldb_nss_ctx->gr_res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - _LDB_NSS_GRENT_FILTER, _ldb_nss_gr_attrs, - &_ldb_nss_ctx->gr_res); + _LDB_NSS_GRENT_FILTER); if (ret != LDB_SUCCESS) { return NSS_STATUS_UNAVAIL; } @@ -178,11 +179,12 @@ NSS_STATUS _nss_ldb_getgrnam_r(const char *name, struct group *result_buf, char /* search the entry */ ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &gr_res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - filter, _ldb_nss_gr_attrs, - &gr_res); + filter); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -275,11 +277,12 @@ NSS_STATUS _nss_ldb_getgrgid_r(gid_t gid, struct group *result_buf, char *buffer /* search the entry */ ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &gr_res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - filter, _ldb_nss_gr_attrs, - &gr_res); + filter); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -367,11 +370,12 @@ NSS_STATUS _nss_ldb_initgroups_dyn(const char *user, gid_t group, long int *star /* search the entry */ ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &uid_res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - filter, attrs, - &uid_res); + filter); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; diff --git a/source4/lib/ldb/nssldb/ldb-pwd.c b/source4/lib/ldb/nssldb/ldb-pwd.c index 44b0ab21ee..6ab103a6fe 100644 --- a/source4/lib/ldb/nssldb/ldb-pwd.c +++ b/source4/lib/ldb/nssldb/ldb-pwd.c @@ -47,11 +47,12 @@ NSS_STATUS _nss_ldb_setpwent(void) } ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &_ldb_nss_ctx->pw_res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - _LDB_NSS_PWENT_FILTER, _ldb_nss_pw_attrs, - &_ldb_nss_ctx->pw_res); + _LDB_NSS_PWENT_FILTER); if (ret != LDB_SUCCESS) { return NSS_STATUS_UNAVAIL; } @@ -137,11 +138,12 @@ NSS_STATUS _nss_ldb_getpwuid_r(uid_t uid, struct passwd *result_buf, char *buffe /* search the entry */ ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - filter, _ldb_nss_pw_attrs, - &res); + filter); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -198,11 +200,12 @@ NSS_STATUS _nss_ldb_getpwnam_r(const char *name, struct passwd *result_buf, char /* search the entry */ ret = ldb_search(_ldb_nss_ctx->ldb, + _ldb_nss_ctx->ldb, + &res, _ldb_nss_ctx->base, LDB_SCOPE_SUBTREE, - filter, _ldb_nss_pw_attrs, - &res); + filter); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py index 99ad1a9e66..4b3501839f 100755 --- a/source4/lib/ldb/tests/python/api.py +++ b/source4/lib/ldb/tests/python/api.py @@ -2,7 +2,7 @@ # Simple tests for the ldb python bindings. # Copyright (C) 2007 Jelmer Vernooij -import sys +import os, sys import unittest # Required for the standalone LDB build @@ -48,6 +48,14 @@ class SimpleLdb(unittest.TestCase): x = ldb.Ldb() x.set_modules_dir("/tmp") + def test_modules_none(self): + x = ldb.Ldb() + self.assertEquals([], x.modules()) + + def test_modules_tdb(self): + x = ldb.Ldb("bar.ldb") + self.assertEquals("[]", repr(x.modules())) + def test_search(self): l = ldb.Ldb("foo.ldb") self.assertEquals(len(l.search()), 1) @@ -451,12 +459,32 @@ class MessageElementTests(unittest.TestCase): x = ldb.MessageElement(["foo"]) self.assertEquals("foo", x) -class ExampleModule: - name = "example" - class ModuleTests(unittest.TestCase): def test_register_module(self): - ldb.register_module(ExampleModule()) + class ExampleModule: + name = "example" + ldb.register_module(ExampleModule) + + def test_use_module(self): + ops = [] + class ExampleModule: + name = "bla" + + def __init__(self, ldb, next): + ops.append("init") + self.next = next + + def search(self, *args, **kwargs): + return self.next.search(*args, **kwargs) + + ldb.register_module(ExampleModule) + if os.path.exists("usemodule.ldb"): + os.unlink("usemodule.ldb") + l = ldb.Ldb("usemodule.ldb") + l.add({"dn": "@MODULES", "@LIST": "bla"}) + self.assertEquals([], ops) + l = ldb.Ldb("usemodule.ldb") + self.assertEquals(["init"], ops) if __name__ == '__main__': import unittest diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py index bc6f80e856..71fd98876e 100755 --- a/source4/lib/ldb/tests/python/ldap.py +++ b/source4/lib/ldb/tests/python/ldap.py @@ -8,6 +8,7 @@ import sys import time sys.path.append("bin/python") +sys.path.append("../lib/subunit/python") import samba.getopt as options @@ -755,7 +756,7 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ ldb.delete(res[0].dn) - attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf"] + attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf", "allowedAttributes", "allowedAttributesEffective"] print "Testing ldb.search for (&(cn=ldaptestUSer2)(objectClass=user))" res = ldb.search(self.base_dn, expression="(&(cn=ldaptestUSer2)(objectClass=user))", scope=SCOPE_SUBTREE, attrs=attrs) self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestUSer2)(objectClass=user))") @@ -767,9 +768,11 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertTrue("objectGUID" in res[0]) self.assertTrue("whenCreated" in res[0]) self.assertTrue("nTSecurityDescriptor" in res[0]) + self.assertTrue("allowedAttributes" in res[0]) + self.assertTrue("allowedAttributesEffective" in res[0]) self.assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + self.base_dn).upper()) - attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"] + attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member", "allowedAttributes", "allowedAttributesEffective"] print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group))" res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs) self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))") @@ -781,7 +784,12 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """ self.assertTrue("objectGuid" not in res[0]) self.assertTrue("whenCreated" in res[0]) self.assertTrue("nTSecurityDescriptor" in res[0]) - self.assertEquals(res[0]["member"][0].upper(), ("CN=ldaptestuser2,CN=Users," + self.base_dn).upper()) + self.assertTrue("allowedAttributes" in res[0]) + self.assertTrue("allowedAttributesEffective" in res[0]) + memberUP = [] + for m in res[0]["member"]: + memberUP.append(m.upper()) + self.assertTrue(("CN=ldaptestuser2,CN=Users," + self.base_dn).upper() in memberUP) ldb.modify_ldif(""" dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """ diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index e66d4fb973..22d4aa6976 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -40,7 +40,7 @@ static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn) const char *attrs[] = { NULL }; struct ldb_result *res; - ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "distinguishedName=*", attrs, &res); + ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_SUBTREE, attrs, "distinguishedName=*"); if (ret != LDB_SUCCESS) return -1; for (i = 0; i < res->count; i++) { diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index e58a5a271e..b2a040cd09 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -303,7 +303,7 @@ int main(int argc, const char **argv) } } - ret = ldb_search(ldb, basedn, options->scope, expression, attrs, &result); + ret = ldb_search(ldb, ldb, &result, basedn, options->scope, attrs, "%s", expression); if (ret != LDB_SUCCESS) { printf("search failed - %s\n", ldb_errstring(ldb)); exit(1); diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index b3d1f934a6..ceabd5cd78 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -56,6 +56,7 @@ static int do_compare_msg(struct ldb_message **el1, } struct search_context { + struct ldb_context *ldb; struct ldb_control **req_ctrls; int sort; @@ -101,7 +102,7 @@ static int store_referral(char *referral, struct search_context *sctx) { return 0; } -static int display_message(struct ldb_context *ldb, struct ldb_message *msg, struct search_context *sctx) { +static int display_message(struct ldb_message *msg, struct search_context *sctx) { struct ldb_ldif ldif; sctx->entries++; @@ -119,7 +120,7 @@ static int display_message(struct ldb_context *ldb, struct ldb_message *msg, str ldb_msg_sort_elements(ldif.msg); } - ldb_ldif_write_file(ldb, stdout, &ldif); + ldb_ldif_write_file(sctx->ldb, stdout, &ldif); return 0; } @@ -133,18 +134,26 @@ static int display_referral(char *referral, struct search_context *sctx) return 0; } -static int search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int search_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct search_context *sctx = talloc_get_type(context, struct search_context); + struct search_context *sctx; int ret; + + sctx = talloc_get_type(req->context, struct search_context); + + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_request_done(req, ares->error); + } switch (ares->type) { - case LDB_REPLY_ENTRY: if (sctx->sort) { ret = store_message(ares->message, sctx); } else { - ret = display_message(ldb, ares->message, sctx); + ret = display_message(ares->message, sctx); } break; @@ -154,6 +163,9 @@ static int search_callback(struct ldb_context *ldb, void *context, struct ldb_re } else { ret = display_referral(ares->referral, sctx); } + if (ret) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } break; case LDB_REPLY_DONE: @@ -161,22 +173,13 @@ static int search_callback(struct ldb_context *ldb, void *context, struct ldb_re if (handle_controls_reply(ares->controls, sctx->req_ctrls) == 1) sctx->pending = 1; } - ret = 0; - break; - - default: - fprintf(stderr, "unknown Reply Type\n"); - return LDB_ERR_OTHER; - } - - if (talloc_free(ares) == -1) { - fprintf(stderr, "talloc_free failed\n"); - sctx->pending = 0; - return LDB_ERR_OPERATIONS_ERROR; + talloc_free(ares); + return ldb_request_done(req, LDB_SUCCESS); } + talloc_free(ares); if (ret) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } return LDB_SUCCESS; @@ -192,12 +195,12 @@ static int do_search(struct ldb_context *ldb, struct search_context *sctx; int ret; - req = talloc(ldb, struct ldb_request); - if (!req) return -1; + req = NULL; - sctx = talloc(req, struct search_context); + sctx = talloc(ldb, struct search_context); if (!sctx) return -1; + sctx->ldb = ldb; sctx->sort = options->sorted; sctx->num_stored = 0; sctx->refs_stored = 0; @@ -214,18 +217,22 @@ static int do_search(struct ldb_context *ldb, basedn = ldb_get_default_basedn(ldb); } - req->operation = LDB_SEARCH; - req->op.search.base = basedn; - req->op.search.scope = options->scope; - req->op.search.tree = ldb_parse_tree(req, expression); - if (req->op.search.tree == NULL) return -1; - req->op.search.attrs = attrs; - req->controls = sctx->req_ctrls; - req->context = sctx; - req->callback = &search_callback; - ldb_set_timeout(ldb, req, 0); /* TODO: make this settable by command line */ - again: + /* free any previous requests */ + if (req) talloc_free(req); + + ret = ldb_build_search_req(&req, ldb, ldb, + basedn, options->scope, + expression, attrs, + sctx->req_ctrls, + sctx, search_callback, + NULL); + if (ret != LDB_SUCCESS) { + talloc_free(sctx); + printf("allocating request failed: %s\n", ldb_errstring(ldb)); + return -1; + } + sctx->pending = 0; ret = ldb_request(ldb, req); @@ -251,7 +258,7 @@ again: ldb, (ldb_qsort_cmp_fn_t)do_compare_msg); } for (i = 0; i < sctx->num_stored; i++) { - display_message(ldb, sctx->store[i], sctx); + display_message(sctx->store[i], sctx); } for (i = 0; i < sctx->refs_stored; i++) { @@ -262,6 +269,7 @@ again: printf("# returned %d records\n# %d entries\n# %d referrals\n", sctx->entries + sctx->refs, sctx->entries, sctx->refs); + talloc_free(sctx); talloc_free(req); return 0; diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index 169ff02da1..f3d6d621a9 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -227,7 +227,7 @@ static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn, int nreco int ret; expr = talloc_asprintf(ldb, "(uid=TEST%d)", uid); - ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, NULL, &res); + ret = ldb_search(ldb, ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, "%s", expr); if (ret != LDB_SUCCESS || (uid < nrecords && res->count != 1)) { printf("Failed to find %s - %s\n", expr, ldb_errstring(ldb)); @@ -354,7 +354,7 @@ static void start_test_index(struct ldb_context **ldb) basedn = ldb_dn_new(*ldb, *ldb, options->basedn); - ret = ldb_search(*ldb, basedn, LDB_SCOPE_SUBTREE, "uid=test", NULL, &res); + ret = ldb_search(*ldb, *ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, "uid=test"); if (ret != LDB_SUCCESS) { printf("Search with (uid=test) filter failed!\n"); exit(1); diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index 6c683a1e33..617371333f 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -71,6 +71,7 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level, static int ldb_wrap_destructor(struct ldb_context *ldb) { size_t *startup_blocks = (size_t *)ldb_get_opaque(ldb, "startup_blocks"); + if (startup_blocks && talloc_total_blocks(ldb) > *startup_blocks + 400) { DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks (startup %lu) %lu bytes\n", @@ -124,15 +125,6 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, "%s/ldb", lp_modulesdir(lp_ctx))); -#if 0 - if (ev) { - ldb_event_sys_op_init(ldb, ev); - } else { - talloc_free(ldb); - return NULL; - } -#endif - if (ldb_set_opaque(ldb, "sessionInfo", session_info)) { talloc_free(ldb); return NULL; @@ -198,6 +190,3 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, return ldb; } - - - diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 4b90e8c4fd..dcc29180cc 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -23,16 +23,15 @@ #include "lib/events/events.h" #include "system/filesys.h" #include "messaging/messaging.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/socket/socket.h" #include "librpc/gen_ndr/ndr_irpc.h" #include "lib/messaging/irpc.h" #include "tdb_wrap.h" -#include "lib/util/unix_privs.h" +#include "../lib/util/unix_privs.h" #include "librpc/rpc/dcerpc.h" -#include "lib/tdb/include/tdb.h" -#include "lib/util/util_tdb.h" -#include "lib/util/util_tdb.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/util_tdb.h" #include "cluster/cluster.h" #include "param/param.h" diff --git a/source4/lib/nss_wrapper/config.m4 b/source4/lib/nss_wrapper/config.m4 deleted file mode 100644 index 58e94f9830..0000000000 --- a/source4/lib/nss_wrapper/config.m4 +++ /dev/null @@ -1,19 +0,0 @@ -AC_ARG_ENABLE(nss-wrapper, -[ --enable-nss-wrapper Turn on nss wrapper library (default=no)]) - -HAVE_NSS_WRAPPER=no - -if eval "test x$developer = xyes"; then - enable_nss_wrapper=yes -fi - -if eval "test x$enable_nss_wrapper = xyes"; then - AC_DEFINE(NSS_WRAPPER,1,[Use nss wrapper library]) - HAVE_NSS_WRAPPER=yes - - # this is only used for samba3 - NSS_WRAPPER_OBJS="lib/nss_wrapper/nss_wrapper.o" -fi - -AC_SUBST(HAVE_NSS_WRAPPER) -AC_SUBST(NSS_WRAPPER_OBJS) diff --git a/source4/lib/nss_wrapper/nss_wrapper.c b/source4/lib/nss_wrapper/nss_wrapper.c deleted file mode 100644 index 5bf7ebda4f..0000000000 --- a/source4/lib/nss_wrapper/nss_wrapper.c +++ /dev/null @@ -1,1130 +0,0 @@ -/* - * Copyright (C) Stefan Metzmacher 2007 - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef _SAMBA_BUILD_ - -#define NSS_WRAPPER_NOT_REPLACE -#include "lib/replace/replace.h" -#include "system/passwd.h" -#include "system/filesys.h" - -#else /* _SAMBA_BUILD_ */ - -#error nss_wrapper_only_supported_in_samba_yet - -#endif - -#ifndef _PUBLIC_ -#define _PUBLIC_ -#endif - -/* not all systems have _r functions... */ -#ifndef HAVE_GETPWNAM_R -#define getpwnam_r(name, pwdst, buf, buflen, pwdstp) ENOSYS -#endif -#ifndef HAVE_GETPWUID_R -#define getpwuid_r(uid, pwdst, buf, buflen, pwdstp) ENOSYS -#endif -#ifndef HAVE_GETPWENT_R -#define getpwent_r(pwdst, buf, buflen, pwdstp) ENOSYS -#endif -#ifndef HAVE_GETGRNAM_R -#define getgrnam_r(name, grdst, buf, buflen, grdstp) ENOSYS -#endif -#ifndef HAVE_GETGRUID_R -#define getgrgid_r(uid, grdst, buf, buflen, grdstp) ENOSYS -#endif -#ifndef HAVE_GETGRENT_R -#define getgrent_r(grdst, buf, buflen, grdstp) ENOSYS -#endif - -/* LD_PRELOAD doesn't work yet, so REWRITE_CALLS is all we support - * for now */ -#define REWRITE_CALLS - -#ifdef REWRITE_CALLS - -#define real_getpwnam getpwnam -#define real_getpwnam_r getpwnam_r -#define real_getpwuid getpwuid -#define real_getpwuid_r getpwuid_r - -#define real_setpwent setpwent -#define real_getpwent getpwent -#define real_getpwent_r getpwent_r -#define real_endpwent endpwent - -/* -#define real_getgrlst getgrlst -#define real_getgrlst_r getgrlst_r -#define real_initgroups_dyn initgroups_dyn -*/ -#define real_initgroups initgroups - -#define real_getgrnam getgrnam -#define real_getgrnam_r getgrnam_r -#define real_getgrgid getgrgid -#define real_getgrgid_r getgrgid_r - -#define real_setgrent setgrent -#define real_getgrent getgrent -#define real_getgrent_r getgrent_r -#define real_endgrent endgrent - -#endif - -#if 0 -# ifdef DEBUG -# define NWRAP_ERROR(args) DEBUG(0, args) -# else -# define NWRAP_ERROR(args) printf args -# endif -#else -#define NWRAP_ERROR(args) -#endif - -#if 0 -# ifdef DEBUG -# define NWRAP_DEBUG(args) DEBUG(0, args) -# else -# define NWRAP_DEBUG(args) printf args -# endif -#else -#define NWRAP_DEBUG(args) -#endif - -#if 0 -# ifdef DEBUG -# define NWRAP_VERBOSE(args) DEBUG(0, args) -# else -# define NWRAP_VERBOSE(args) printf args -# endif -#else -#define NWRAP_VERBOSE(args) -#endif - -struct nwrap_cache { - const char *path; - int fd; - struct stat st; - uint8_t *buf; - void *private_data; - bool (*parse_line)(struct nwrap_cache *, char *line); - void (*unload)(struct nwrap_cache *); -}; - -struct nwrap_pw { - struct nwrap_cache *cache; - - struct passwd *list; - int num; - int idx; -}; - -struct nwrap_cache __nwrap_cache_pw; -struct nwrap_pw nwrap_pw_global; - -static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line); -static void nwrap_pw_unload(struct nwrap_cache *nwrap); - -struct nwrap_gr { - struct nwrap_cache *cache; - - struct group *list; - int num; - int idx; -}; - -struct nwrap_cache __nwrap_cache_gr; -struct nwrap_gr nwrap_gr_global; - -static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line); -static void nwrap_gr_unload(struct nwrap_cache *nwrap); - -static void nwrap_init(void) -{ - static bool initialized; - - if (initialized) return; - initialized = true; - - nwrap_pw_global.cache = &__nwrap_cache_pw; - - nwrap_pw_global.cache->path = getenv("NSS_WRAPPER_PASSWD"); - nwrap_pw_global.cache->fd = -1; - nwrap_pw_global.cache->private_data = &nwrap_pw_global; - nwrap_pw_global.cache->parse_line = nwrap_pw_parse_line; - nwrap_pw_global.cache->unload = nwrap_pw_unload; - - nwrap_gr_global.cache = &__nwrap_cache_gr; - - nwrap_gr_global.cache->path = getenv("NSS_WRAPPER_GROUP"); - nwrap_gr_global.cache->fd = -1; - nwrap_gr_global.cache->private_data = &nwrap_gr_global; - nwrap_gr_global.cache->parse_line = nwrap_gr_parse_line; - nwrap_gr_global.cache->unload = nwrap_gr_unload; -} - -static bool nwrap_enabled(void) -{ - nwrap_init(); - - if (!nwrap_pw_global.cache->path) { - return false; - } - if (nwrap_pw_global.cache->path[0] == '\0') { - return false; - } - if (!nwrap_gr_global.cache->path) { - return false; - } - if (nwrap_gr_global.cache->path[0] == '\0') { - return false; - } - - return true; -} - -static bool nwrap_parse_file(struct nwrap_cache *nwrap) -{ - int ret; - uint8_t *buf = NULL; - char *nline; - - if (nwrap->st.st_size == 0) { - NWRAP_DEBUG(("%s: size == 0\n", - __location__)); - goto done; - } - - if (nwrap->st.st_size > INT32_MAX) { - NWRAP_ERROR(("%s: size[%u] larger than INT32_MAX\n", - __location__, (unsigned)nwrap->st.st_size)); - goto failed; - } - - ret = lseek(nwrap->fd, 0, SEEK_SET); - if (ret != 0) { - NWRAP_ERROR(("%s: lseek - %d\n",__location__,ret)); - goto failed; - } - - buf = malloc(nwrap->st.st_size + 1); - if (!buf) { - NWRAP_ERROR(("%s: malloc failed\n",__location__)); - goto failed; - } - - ret = read(nwrap->fd, buf, nwrap->st.st_size); - if (ret != nwrap->st.st_size) { - NWRAP_ERROR(("%s: read(%u) gave %d\n", - __location__, (unsigned)nwrap->st.st_size, ret)); - goto failed; - } - - buf[nwrap->st.st_size] = '\0'; - - nline = (char *)buf; - while (nline && nline[0]) { - char *line; - char *e; - bool ok; - - line = nline; - nline = NULL; - - e = strchr(line, '\n'); - if (e) { - e[0] = '\0'; - e++; - if (e[0] == '\r') { - e[0] = '\0'; - e++; - } - nline = e; - } - - NWRAP_VERBOSE(("%s:'%s'\n",__location__, line)); - - if (strlen(line) == 0) { - continue; - } - - ok = nwrap->parse_line(nwrap, line); - if (!ok) { - goto failed; - } - } - -done: - nwrap->buf = buf; - return true; - -failed: - if (buf) free(buf); - return false; -} - -static void nwrap_cache_unload(struct nwrap_cache *nwrap) -{ - nwrap->unload(nwrap); - - if (nwrap->buf) free(nwrap->buf); - - nwrap->buf = NULL; -} - -static void nwrap_cache_reload(struct nwrap_cache *nwrap) -{ - struct stat st; - int ret; - bool ok; - bool retried = false; - -reopen: - if (nwrap->fd < 0) { - nwrap->fd = open(nwrap->path, O_RDONLY); - if (nwrap->fd < 0) { - NWRAP_ERROR(("%s: unable to open '%s' readonly %d:%s\n", - __location__, - nwrap->path, nwrap->fd, - strerror(errno))); - return; - } - NWRAP_VERBOSE(("%s: open '%s'\n", __location__, nwrap->path)); - } - - ret = fstat(nwrap->fd, &st); - if (ret != 0) { - NWRAP_ERROR(("%s: fstat(%s) - %d:%s\n", - __location__, - nwrap->path, - ret, strerror(errno))); - return; - } - - if (retried == false && st.st_nlink == 0) { - /* maybe someone has replaced the file... */ - NWRAP_DEBUG(("%s: st_nlink == 0, reopen %s\n", - __location__, nwrap->path)); - retried = true; - memset(&nwrap->st, 0, sizeof(nwrap->st)); - close(nwrap->fd); - nwrap->fd = -1; - goto reopen; - } - - if (st.st_mtime == nwrap->st.st_mtime) { - NWRAP_VERBOSE(("%s: st_mtime[%u] hasn't changed, skip reload\n", - __location__, (unsigned)st.st_mtime)); - return; - } - NWRAP_DEBUG(("%s: st_mtime has changed [%u] => [%u], start reload\n", - __location__, (unsigned)st.st_mtime, - (unsigned)nwrap->st.st_mtime)); - - nwrap->st = st; - - nwrap_cache_unload(nwrap); - - ok = nwrap_parse_file(nwrap); - if (!ok) { - NWRAP_ERROR(("%s: failed to reload %s\n", - __location__, nwrap->path)); - nwrap_cache_unload(nwrap); - } - NWRAP_DEBUG(("%s: reloaded %s\n", - __location__, nwrap->path)); -} - -/* - * the caller has to call nwrap_unload() on failure - */ -static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line) -{ - struct nwrap_pw *nwrap_pw; - char *c; - char *p; - char *e; - struct passwd *pw; - size_t list_size; - - nwrap_pw = (struct nwrap_pw *)nwrap->private_data; - - list_size = sizeof(*nwrap_pw->list) * (nwrap_pw->num+1); - pw = (struct passwd *)realloc(nwrap_pw->list, list_size); - if (!pw) { - NWRAP_ERROR(("%s:realloc(%u) failed\n", - __location__, list_size)); - return false; - } - nwrap_pw->list = pw; - - pw = &nwrap_pw->list[nwrap_pw->num]; - - c = line; - - /* name */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - pw->pw_name = c; - c = p; - - NWRAP_VERBOSE(("name[%s]\n", pw->pw_name)); - - /* password */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - pw->pw_passwd = c; - c = p; - - NWRAP_VERBOSE(("password[%s]\n", pw->pw_passwd)); - - /* uid */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - e = NULL; - pw->pw_uid = (uid_t)strtoul(c, &e, 10); - if (c == e) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - if (e == NULL) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - if (e[0] != '\0') { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - c = p; - - NWRAP_VERBOSE(("uid[%u]\n", pw->pw_uid)); - - /* gid */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - e = NULL; - pw->pw_gid = (gid_t)strtoul(c, &e, 10); - if (c == e) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - if (e == NULL) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - if (e[0] != '\0') { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - c = p; - - NWRAP_VERBOSE(("gid[%u]\n", pw->pw_gid)); - - /* gecos */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - pw->pw_gecos = c; - c = p; - - NWRAP_VERBOSE(("gecos[%s]\n", pw->pw_gecos)); - - /* dir */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:'%s'\n",__location__,c)); - return false; - } - *p = '\0'; - p++; - pw->pw_dir = c; - c = p; - - NWRAP_VERBOSE(("dir[%s]\n", pw->pw_dir)); - - /* shell */ - pw->pw_shell = c; - NWRAP_VERBOSE(("shell[%s]\n", pw->pw_shell)); - - NWRAP_DEBUG(("add user[%s:%s:%u:%u:%s:%s:%s]\n", - pw->pw_name, pw->pw_passwd, - pw->pw_uid, pw->pw_gid, - pw->pw_gecos, pw->pw_dir, pw->pw_shell)); - - nwrap_pw->num++; - return true; -} - -static void nwrap_pw_unload(struct nwrap_cache *nwrap) -{ - struct nwrap_pw *nwrap_pw; - nwrap_pw = (struct nwrap_pw *)nwrap->private_data; - - if (nwrap_pw->list) free(nwrap_pw->list); - - nwrap_pw->list = NULL; - nwrap_pw->num = 0; - nwrap_pw->idx = 0; -} - -static int nwrap_pw_copy_r(const struct passwd *src, struct passwd *dst, - char *buf, size_t buflen, struct passwd **dstp) -{ - char *first; - char *last; - off_t ofs; - - first = src->pw_name; - - last = src->pw_shell; - while (*last) last++; - - ofs = PTR_DIFF(last + 1, first); - - if (ofs > buflen) { - return ERANGE; - } - - memcpy(buf, first, ofs); - - ofs = PTR_DIFF(src->pw_name, first); - dst->pw_name = buf + ofs; - ofs = PTR_DIFF(src->pw_passwd, first); - dst->pw_passwd = buf + ofs; - dst->pw_uid = src->pw_uid; - dst->pw_gid = src->pw_gid; - ofs = PTR_DIFF(src->pw_gecos, first); - dst->pw_gecos = buf + ofs; - ofs = PTR_DIFF(src->pw_dir, first); - dst->pw_dir = buf + ofs; - ofs = PTR_DIFF(src->pw_shell, first); - dst->pw_shell = buf + ofs; - - if (dstp) { - *dstp = dst; - } - - return 0; -} - -/* - * the caller has to call nwrap_unload() on failure - */ -static bool nwrap_gr_parse_line(struct nwrap_cache *nwrap, char *line) -{ - struct nwrap_gr *nwrap_gr; - char *c; - char *p; - char *e; - struct group *gr; - size_t list_size; - unsigned nummem; - - nwrap_gr = (struct nwrap_gr *)nwrap->private_data; - - list_size = sizeof(*nwrap_gr->list) * (nwrap_gr->num+1); - gr = (struct group *)realloc(nwrap_gr->list, list_size); - if (!gr) { - NWRAP_ERROR(("%s:realloc failed\n",__location__)); - return false; - } - nwrap_gr->list = gr; - - gr = &nwrap_gr->list[nwrap_gr->num]; - - c = line; - - /* name */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - gr->gr_name = c; - c = p; - - NWRAP_VERBOSE(("name[%s]\n", gr->gr_name)); - - /* password */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - gr->gr_passwd = c; - c = p; - - NWRAP_VERBOSE(("password[%s]\n", gr->gr_passwd)); - - /* gid */ - p = strchr(c, ':'); - if (!p) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s'\n", - __location__, line, c)); - return false; - } - *p = '\0'; - p++; - e = NULL; - gr->gr_gid = (gid_t)strtoul(c, &e, 10); - if (c == e) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - if (e == NULL) { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - if (e[0] != '\0') { - NWRAP_ERROR(("%s:invalid line[%s]: '%s' - %s\n", - __location__, line, c, strerror(errno))); - return false; - } - c = p; - - NWRAP_VERBOSE(("gid[%u]\n", gr->gr_gid)); - - /* members */ - gr->gr_mem = (char **)malloc(sizeof(char *)); - if (!gr->gr_mem) { - NWRAP_ERROR(("%s:calloc failed\n",__location__)); - return false; - } - gr->gr_mem[0] = NULL; - - for(nummem=0; p; nummem++) { - char **m; - size_t m_size; - c = p; - p = strchr(c, ','); - if (p) { - *p = '\0'; - p++; - } - - if (strlen(c) == 0) { - break; - } - - m_size = sizeof(char *) * (nummem+2); - m = (char **)realloc(gr->gr_mem, m_size); - if (!m) { - NWRAP_ERROR(("%s:realloc(%u) failed\n", - __location__, m_size)); - return false; - } - gr->gr_mem = m; - gr->gr_mem[nummem] = c; - gr->gr_mem[nummem+1] = NULL; - - NWRAP_VERBOSE(("member[%u]: '%s'\n", nummem, gr->gr_mem[nummem])); - } - - NWRAP_DEBUG(("add group[%s:%s:%u:] with %u members\n", - gr->gr_name, gr->gr_passwd, gr->gr_gid, nummem)); - - nwrap_gr->num++; - return true; -} - -static void nwrap_gr_unload(struct nwrap_cache *nwrap) -{ - int i; - struct nwrap_gr *nwrap_gr; - nwrap_gr = (struct nwrap_gr *)nwrap->private_data; - - if (nwrap_gr->list) { - for (i=0; i < nwrap_gr->num; i++) { - if (nwrap_gr->list[i].gr_mem) { - free(nwrap_gr->list[i].gr_mem); - } - } - free(nwrap_gr->list); - } - - nwrap_gr->list = NULL; - nwrap_gr->num = 0; - nwrap_gr->idx = 0; -} - -static int nwrap_gr_copy_r(const struct group *src, struct group *dst, - char *buf, size_t buflen, struct group **dstp) -{ - char *first; - char **lastm; - char *last; - off_t ofsb; - off_t ofsm; - off_t ofs; - unsigned i; - - first = src->gr_name; - - lastm = src->gr_mem; - while (*lastm) lastm++; - - last = *lastm; - while (*last) last++; - - ofsb = PTR_DIFF(last + 1, first); - ofsm = PTR_DIFF(lastm + 1, src->gr_mem); - - if ((ofsb + ofsm) > buflen) { - return ERANGE; - } - - memcpy(buf, first, ofsb); - memcpy(buf + ofsb, src->gr_mem, ofsm); - - ofs = PTR_DIFF(src->gr_name, first); - dst->gr_name = buf + ofs; - ofs = PTR_DIFF(src->gr_passwd, first); - dst->gr_passwd = buf + ofs; - dst->gr_gid = src->gr_gid; - - dst->gr_mem = (char **)(buf + ofsb); - for (i=0; src->gr_mem[i]; i++) { - ofs = PTR_DIFF(src->gr_mem[i], first); - dst->gr_mem[i] = buf + ofs; - } - - if (dstp) { - *dstp = dst; - } - - return 0; -} - -/* user functions */ -_PUBLIC_ struct passwd *nwrap_getpwnam(const char *name) -{ - int i; - - if (!nwrap_enabled()) { - return real_getpwnam(name); - } - - nwrap_cache_reload(nwrap_pw_global.cache); - - for (i=0; i= nwrap_pw_global.num) { - errno = ENOENT; - return NULL; - } - - pw = &nwrap_pw_global.list[nwrap_pw_global.idx++]; - - NWRAP_VERBOSE(("%s: return user[%s] uid[%u]\n", - __location__, pw->pw_name, pw->pw_uid)); - - return pw; -} - -_PUBLIC_ int nwrap_getpwent_r(struct passwd *pwdst, char *buf, - size_t buflen, struct passwd **pwdstp) -{ - struct passwd *pw; - - if (!nwrap_enabled()) { -#ifdef SOLARIS_GETPWENT_R - pw = real_getpwent_r(pwdst, buf, buflen); - if (!pw) { - if (errno == 0) { - return ENOENT; - } - return errno; - } - if (pwdstp) { - *pwdstp = pw; - } - return 0; -#else - return real_getpwent_r(pwdst, buf, buflen, pwdstp); -#endif - } - - pw = nwrap_getpwent(); - if (!pw) { - if (errno == 0) { - return ENOENT; - } - return errno; - } - - return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp); -} - -_PUBLIC_ void nwrap_endpwent(void) -{ - if (!nwrap_enabled()) { - real_endpwent(); - } - - nwrap_pw_global.idx = 0; -} - -/* misc functions */ -_PUBLIC_ int nwrap_initgroups(const char *user, gid_t group) -{ - if (!nwrap_enabled()) { - return real_initgroups(user, group); - } - - /* TODO: maybe we should also fake this... */ - return EPERM; -} - -/* group functions */ -_PUBLIC_ struct group *nwrap_getgrnam(const char *name) -{ - int i; - - if (!nwrap_enabled()) { - return real_getgrnam(name); - } - - nwrap_cache_reload(nwrap_gr_global.cache); - - for (i=0; i= nwrap_gr_global.num) { - errno = ENOENT; - return NULL; - } - - gr = &nwrap_gr_global.list[nwrap_gr_global.idx++]; - - NWRAP_VERBOSE(("%s: return group[%s] gid[%u]\n", - __location__, gr->gr_name, gr->gr_gid)); - - return gr; -} - -_PUBLIC_ int nwrap_getgrent_r(struct group *grdst, char *buf, - size_t buflen, struct group **grdstp) -{ - struct group *gr; - - if (!nwrap_enabled()) { -#ifdef SOLARIS_GETGRENT_R - gr = real_getgrent_r(grdst, buf, buflen); - if (!gr) { - if (errno == 0) { - return ENOENT; - } - return errno; - } - if (grdstp) { - *grdstp = gr; - } - return 0; -#else - return real_getgrent_r(grdst, buf, buflen, grdstp); -#endif - } - - gr = nwrap_getgrent(); - if (!gr) { - if (errno == 0) { - return ENOENT; - } - return errno; - } - - return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp); -} - -_PUBLIC_ void nwrap_endgrent(void) -{ - if (!nwrap_enabled()) { - real_endgrent(); - } - - nwrap_gr_global.idx = 0; -} diff --git a/source4/lib/nss_wrapper/nss_wrapper.h b/source4/lib/nss_wrapper/nss_wrapper.h deleted file mode 100644 index 35a47348a8..0000000000 --- a/source4/lib/nss_wrapper/nss_wrapper.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) Stefan Metzmacher 2007 - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __NSS_WRAPPER_H__ -#define __NSS_WRAPPER_H__ - -struct passwd *nwrap_getpwnam(const char *name); -int nwrap_getpwnam_r(const char *name, struct passwd *pwbuf, - char *buf, size_t buflen, struct passwd **pwbufp); -struct passwd *nwrap_getpwuid(uid_t uid); -int nwrap_getpwuid_r(uid_t uid, struct passwd *pwbuf, - char *buf, size_t buflen, struct passwd **pwbufp); -void nwrap_setpwent(void); -struct passwd *nwrap_getpwent(void); -int nwrap_getpwent_r(struct passwd *pwbuf, char *buf, - size_t buflen, struct passwd **pwbufp); -void nwrap_endpwent(void); -int nwrap_initgroups(const char *user, gid_t group); -struct group *nwrap_getgrnam(const char *name); -int nwrap_getgrnam_r(const char *name, struct group *gbuf, - char *buf, size_t buflen, struct group **gbufp); -struct group *nwrap_getgrgid(gid_t gid); -int nwrap_getgrgid_r(gid_t gid, struct group *gbuf, - char *buf, size_t buflen, struct group **gbufp); -void nwrap_setgrent(void); -struct group *nwrap_getgrent(void); -int nwrap_getgrent_r(struct group *gbuf, char *buf, - size_t buflen, struct group **gbufp); -void nwrap_endgrent(void); - -#ifdef NSS_WRAPPER_REPLACE - -#ifdef getpwnam -#undef getpwnam -#endif -#define getpwnam nwrap_getpwnam - -#ifdef getpwnam_r -#undef getpwnam_r -#endif -#define getpwnam_r nwrap_getpwnam_r - -#ifdef getpwuid -#undef getpwuid -#endif -#define getpwuid nwrap_getpwuid - -#ifdef getpwuid_r -#undef getpwuid_r -#endif -#define getpwuid_r nwrap_getpwuid_r - -#ifdef setpwent -#undef setpwent -#endif -#define setpwent nwrap_setpwent - -#ifdef getpwent -#undef getpwent -#endif -#define getpwent nwrap_getpwent - -#ifdef getpwent_r -#undef getpwent_r -#endif -#define getpwent_r nwrap_getpwent_r - -#ifdef endpwent -#undef endpwent -#endif -#define endpwent nwrap_endpwent - -#ifdef getgrlst -#undef getgrlst -#endif -#define getgrlst __none_nwrap_getgrlst - -#ifdef getgrlst_r -#undef getgrlst_r -#endif -#define getgrlst_r __none_nwrap_getgrlst_r - -#ifdef initgroups_dyn -#undef initgroups_dyn -#endif -#define initgroups_dyn __none_nwrap_initgroups_dyn - -#ifdef initgroups -#undef initgroups -#endif -#define initgroups nwrap_initgroups - -#ifdef getgrnam -#undef getgrnam -#endif -#define getgrnam nwrap_getgrnam - -#ifdef getgrnam_r -#undef getgrnam_r -#endif -#define getgrnam_r nwrap_getgrnam_r - -#ifdef getgrgid -#undef getgrgid -#endif -#define getgrgid nwrap_getgrgid - -#ifdef getgrgid_r -#undef getgrgid_r -#endif -#define getgrgid_r nwrap_getgrgid_r - -#ifdef setgrent -#undef setgrent -#endif -#define setgrent nwrap_setgrent - -#ifdef getgrent -#undef getgrent -#endif -#define getgrent nwrap_getgrent - -#ifdef getgrent_r -#undef getgrent_r -#endif -#define getgrent_r nwrap_getgrent_r - -#ifdef endgrent -#undef endgrent -#endif -#define endgrent nwrap_endgrent - -#endif /* NSS_WRAPPER_REPLACE */ - -#endif /* __NSS_WRAPPER_H__ */ diff --git a/source4/lib/nss_wrapper/nss_wrapper.pl b/source4/lib/nss_wrapper/nss_wrapper.pl deleted file mode 100644 index b1c9be5365..0000000000 --- a/source4/lib/nss_wrapper/nss_wrapper.pl +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/perl -# - -use strict; - -use Getopt::Long; -use Cwd qw(abs_path); - -my $opt_help = 0; -my $opt_path = undef; -my $opt_action = undef; -my $opt_type = undef; -my $opt_name = undef; - -my $passwdfn = undef; -my $groupfn = undef; -my $actionfn = undef; - -sub passwd_add($$); -sub passwd_delete($$); -sub group_add($$); -sub group_delete($$); - -my $result = GetOptions( - 'help|h|?' => \$opt_help, - 'path=s' => \$opt_path, - 'action=s' => \$opt_action, - 'type=s' => \$opt_type, - 'name=s' => \$opt_name -); - -sub usage($;$) -{ - my ($ret, $msg) = @_; - - print $msg."\n\n" if defined($msg); - - print "usage: - - --help|-h|-? Show this help. - - --path Path of the 'passwd' or 'group' file. - - --type Only 'passwd' is supported yet, - but 'group' and maybe 'member' will be added - in future. - - --action 'add' or 'delete'. - - --name The name of the object. -"; - exit($ret); -} - -usage(1) if (not $result); - -usage(0) if ($opt_help); - -if (not defined($opt_path)) { - usage(1, "missing: --path "); -} -if ($opt_path eq "" or $opt_path eq "/") { - usage(1, "invalid: --path : '$opt_path'"); -} -my $opt_fullpath = abs_path($opt_path); -if (not defined($opt_fullpath)) { - usage(1, "invalid: --path : '$opt_path'"); -} - - -if (not defined($opt_action)) { - usage(1, "missing: --action [add|delete]"); -} -if ($opt_action eq "add") { - $passwdfn = \&passwd_add; - $groupfn = \&group_add; -} elsif ($opt_action eq "delete") { - $passwdfn = \&passwd_delete; - $groupfn = \&group_delete; -} else { - usage(1, "invalid: --action [add|delete]: '$opt_action'"); -} - -if (not defined($opt_type)) { - usage(1, "missing: --type [passwd|group]"); -} -if ($opt_type eq "passwd") { - $actionfn = $passwdfn; -} elsif ($opt_type eq "group") { - $actionfn = $groupfn; -} else { - usage(1, "invalid: --type [passwd|group]: '$opt_type'") -} - -if (not defined($opt_name)) { - usage(1, "missing: --name "); -} -if ($opt_name eq "") { - usage(1, "invalid: --name "); -} - -exit $actionfn->($opt_fullpath, $opt_name); - -sub passwd_add_entry($$); - -sub passwd_load($) -{ - my ($path) = @_; - my @lines; - my $passwd = undef; - - open(PWD, "<$path") or die("Unable to open '$path' for read"); - @lines = ; - close(PWD); - - $passwd->{array} = (); - $passwd->{name} = {}; - $passwd->{uid} = {}; - $passwd->{path} = $path; - - foreach my $line (@lines) { - passwd_add_entry($passwd, $line); - } - - return $passwd; -} - -sub passwd_lookup_name($$) -{ - my ($passwd, $name) = @_; - - return undef unless defined($passwd->{name}{$name}); - - return $passwd->{name}{$name}; -} - -sub passwd_lookup_uid($$) -{ - my ($passwd, $uid) = @_; - - return undef unless defined($passwd->{uid}{$uid}); - - return $passwd->{uid}{$uid}; -} - -sub passwd_get_free_uid($) -{ - my ($passwd) = @_; - my $uid = 1000; - - while (passwd_lookup_uid($passwd, $uid)) { - $uid++; - } - - return $uid; -} - -sub passwd_add_entry($$) -{ - my ($passwd, $str) = @_; - - chomp $str; - my @e = split(':', $str); - - push(@{$passwd->{array}}, \@e); - $passwd->{name}{$e[0]} = \@e; - $passwd->{uid}{$e[2]} = \@e; -} - -sub passwd_remove_entry($$) -{ - my ($passwd, $eref) = @_; - - for(my $i; defined($passwd->{array}[$i]); $i++) { - if ($eref == $passwd->{array}[$i]) { - $passwd->{array}[$i] = undef; - } - } - - delete $passwd->{name}{${$eref}[0]}; - delete $passwd->{uid}{${$eref}[2]}; -} - -sub passwd_save($) -{ - my ($passwd) = @_; - my @lines = (); - my $path = $passwd->{path}; - my $tmppath = $path.$$; - - foreach my $eref (@{$passwd->{array}}) { - next unless defined($eref); - - my $line = join(':', @{$eref}); - push(@lines, $line); - } - - open(PWD, ">$tmppath") or die("Unable to open '$tmppath' for write"); - print PWD join("\n", @lines)."\n"; - close(PWD); - rename($tmppath, $path) or die("Unable to rename $tmppath => $path"); -} - -sub passwd_add($$) -{ - my ($path, $name) = @_; - - #print "passwd_add: '$name' in '$path'\n"; - - my $passwd = passwd_load($path); - - my $e = passwd_lookup_name($passwd, $name); - die("account[$name] already exists in '$path'") if defined($e); - - my $uid = passwd_get_free_uid($passwd); - my $gid = 65534;# nogroup gid - - my $pwent = $name.":x:".$uid.":".$gid.":".$name." gecos:/nodir:/bin/false"; - - passwd_add_entry($passwd, $pwent); - - passwd_save($passwd); - - return 0; -} - -sub passwd_delete($$) -{ - my ($path, $name) = @_; - - #print "passwd_delete: '$name' in '$path'\n"; - - my $passwd = passwd_load($path); - - my $e = passwd_lookup_name($passwd, $name); - die("account[$name] does not exists in '$path'") unless defined($e); - - passwd_remove_entry($passwd, $e); - - passwd_save($passwd); - - return 0; -} - -sub group_add($$) -{ - my ($path, $name) = @_; - - #print "group_add: '$name' in '$path'\n"; - - die("group_add: not implemented yet!"); - - return 0; -} - -sub group_delete($$) -{ - my ($path, $name) = @_; - - #print "group_delete: '$name' in '$path'\n"; - - die("group_delete: not implemented yet!"); - - return 0; -} diff --git a/source4/lib/popt/CHANGES b/source4/lib/popt/CHANGES deleted file mode 100644 index db16a5fdd0..0000000000 --- a/source4/lib/popt/CHANGES +++ /dev/null @@ -1,46 +0,0 @@ -1.5 -> 1.6 - - add ability to perform callbacks for every, not just first, match. - -1.3 -> 1.5 - - heavy dose of const's - - poptParseArgvString() now NULL terminates the list - -1.2.3 -> 1.3 - - added support for single - - - misc bug fixes - - portability improvements - -1.2.2 -> 1.2.3 - - fixed memset() in help message generation (Dale Hawkins) - - added extern "C" stuff to popt.h for C++ compilers (Dale Hawkins) - - const'ified poptParseArgvString (Jeff Garzik) - -1.2.1 -> 1.2.2 - - fixed bug in chaind alias happens which seems to have only - affected --triggers in rpm - - added POPT_ARG_VAL - - popt.3 installed by default - -1.2 -> 1.2.1 - - added POPT_ARG_INTL_DOMAIN (Elliot Lee) - - updated Makefile's to be more GNUish (Elliot Lee) - -1.1 -> 1.2 - - added popt.3 man page (Robert Lynch) - - don't use mmap anymore (its lack of portability isn't worth the - trouble) - - added test script - - added support for exec - - removed support for *_POPT_ALIASES env variable -- it was a bad - idea - - reorganized into multiple source files - - added automatic help generation, POPT_AUTOHELP - - added table callbacks - - added table inclusion - - updated man page for new features - - added test scripts - -1.0 -> 1.1 - - moved to autoconf (Fred Fish) - - added STRERROR replacement (Norbert Warmuth) - - added const keywords (Bruce Perens) diff --git a/source4/lib/popt/COPYING b/source4/lib/popt/COPYING deleted file mode 100644 index b4c7ca876c..0000000000 --- a/source4/lib/popt/COPYING +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 1998 Red Hat Software - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. diff --git a/source4/lib/popt/README b/source4/lib/popt/README deleted file mode 100644 index 0b5205bfdd..0000000000 --- a/source4/lib/popt/README +++ /dev/null @@ -1,18 +0,0 @@ -This is the popt command line option parsing library. While it is similiar -to getopt(3), it contains a number of enhancements, including: - - 1) popt is fully reentrant - 2) popt can parse arbitrary argv[] style arrays while - getopt(2) makes this quite difficult - 3) popt allows users to alias command line arguments - 4) popt provides convience functions for parsing strings - into argv[] style arrays - -popt is used by rpm, the Red Hat install program, and many other Red Hat -utilities, all of which provide excellent examples of how to use popt. -Complete documentation on popt is available in popt.ps (included in this -tarball), which is excerpted with permission from the book "Linux -Application Development" by Michael K. Johnson and Erik Troan (availble -from Addison Wesley in May, 1998). - -Comments on popt should be addressed to ewt@redhat.com. diff --git a/source4/lib/popt/findme.c b/source4/lib/popt/findme.c deleted file mode 100644 index a950e50018..0000000000 --- a/source4/lib/popt/findme.c +++ /dev/null @@ -1,50 +0,0 @@ -/** \ingroup popt - * \file popt/findme.c - */ - -/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#include "system.h" -#include "findme.h" - -const char * findProgramPath(const char * argv0) { - char * path = getenv("PATH"); - char * pathbuf; - char * start, * chptr; - char * buf; - - if (argv0 == NULL) return NULL; /* XXX can't happen */ - /* If there is a / in the argv[0], it has to be an absolute path */ - if (strchr(argv0, '/')) - return xstrdup(argv0); - - if (path == NULL) return NULL; - - start = pathbuf = alloca(strlen(path) + 1); - buf = malloc(strlen(path) + strlen(argv0) + sizeof("/")); - if (buf == NULL) return NULL; /* XXX can't happen */ - strcpy(pathbuf, path); - - chptr = NULL; - /*@-branchstate@*/ - do { - if ((chptr = strchr(start, ':'))) - *chptr = '\0'; - sprintf(buf, "%s/%s", start, argv0); - - if (!access(buf, X_OK)) - return buf; - - if (chptr) - start = chptr + 1; - else - start = NULL; - } while (start && *start); - /*@=branchstate@*/ - - free(buf); - - return NULL; -} diff --git a/source4/lib/popt/findme.h b/source4/lib/popt/findme.h deleted file mode 100644 index a016b867ea..0000000000 --- a/source4/lib/popt/findme.h +++ /dev/null @@ -1,20 +0,0 @@ -/** \ingroup popt - * \file popt/findme.h - */ - -/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#ifndef H_FINDME -#define H_FINDME - -/** - * Return absolute path to executable by searching PATH. - * @param argv0 name of executable - * @return (malloc'd) absolute path to executable (or NULL) - */ -/*@null@*/ const char * findProgramPath(/*@null@*/ const char * argv0) - /*@*/; - -#endif diff --git a/source4/lib/popt/popt.c b/source4/lib/popt/popt.c deleted file mode 100644 index 4f1de65e6f..0000000000 --- a/source4/lib/popt/popt.c +++ /dev/null @@ -1,1238 +0,0 @@ -/** \ingroup popt - * \file popt/popt.c - */ - -/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist */ - -#undef MYDEBUG - -#include "system.h" - -#if HAVE_MATH_H -#include -#endif -#if HAVE_FLOAT_H -#include -#endif - -#include "findme.h" -#include "poptint.h" - -#ifdef MYDEBUG -/*@unchecked@*/ -int _popt_debug = 0; -#endif - -#ifndef HAVE_STRERROR -static char * strerror(int errno) { - extern int sys_nerr; - extern char * sys_errlist[]; - - if ((0 <= errno) && (errno < sys_nerr)) - return sys_errlist[errno]; - else - return POPT_("unknown errno"); -} -#endif - -#ifdef MYDEBUG -/*@unused@*/ static void prtcon(const char *msg, poptContext con) -{ - if (msg) fprintf(stderr, "%s", msg); - fprintf(stderr, "\tcon %p os %p nextCharArg \"%s\" nextArg \"%s\" argv[%d] \"%s\"\n", - con, con->os, - (con->os->nextCharArg ? con->os->nextCharArg : ""), - (con->os->nextArg ? con->os->nextArg : ""), - con->os->next, - (con->os->argv && con->os->argv[con->os->next] - ? con->os->argv[con->os->next] : "")); -} -#endif - -void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) -{ - con->execPath = _free(con->execPath); - con->execPath = xstrdup(path); - con->execAbsolute = allowAbsolute; - /*@-nullstate@*/ /* LCL: con->execPath can be NULL? */ - return; - /*@=nullstate@*/ -} - -static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt) - /*@globals internalState@*/ - /*@modifies internalState@*/ -{ - if (opt != NULL) - for (; opt->longName || opt->shortName || opt->arg; opt++) { - if (opt->arg == NULL) continue; /* XXX program error. */ - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - /* Recurse on included sub-tables. */ - invokeCallbacksPRE(con, opt->arg); - } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && - (opt->argInfo & POPT_CBFLAG_PRE)) - { /*@-castfcnptr@*/ - poptCallbackType cb = (poptCallbackType)opt->arg; - /*@=castfcnptr@*/ - /* Perform callback. */ - /*@-moduncon -noeffectuncon @*/ - cb(con, POPT_CALLBACK_REASON_PRE, NULL, NULL, opt->descrip); - /*@=moduncon =noeffectuncon @*/ - } - } -} - -static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt) - /*@globals internalState@*/ - /*@modifies internalState@*/ -{ - if (opt != NULL) - for (; opt->longName || opt->shortName || opt->arg; opt++) { - if (opt->arg == NULL) continue; /* XXX program error. */ - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - /* Recurse on included sub-tables. */ - invokeCallbacksPOST(con, opt->arg); - } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && - (opt->argInfo & POPT_CBFLAG_POST)) - { /*@-castfcnptr@*/ - poptCallbackType cb = (poptCallbackType)opt->arg; - /*@=castfcnptr@*/ - /* Perform callback. */ - /*@-moduncon -noeffectuncon @*/ - cb(con, POPT_CALLBACK_REASON_POST, NULL, NULL, opt->descrip); - /*@=moduncon =noeffectuncon @*/ - } - } -} - -static void invokeCallbacksOPTION(poptContext con, - const struct poptOption * opt, - const struct poptOption * myOpt, - /*@null@*/ const void * myData, int shorty) - /*@globals internalState@*/ - /*@modifies internalState@*/ -{ - const struct poptOption * cbopt = NULL; - - if (opt != NULL) - for (; opt->longName || opt->shortName || opt->arg; opt++) { - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - /* Recurse on included sub-tables. */ - if (opt->arg != NULL) /* XXX program error */ - invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty); - } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK && - !(opt->argInfo & POPT_CBFLAG_SKIPOPTION)) { - /* Save callback info. */ - cbopt = opt; - } else if (cbopt != NULL && - ((myOpt->shortName && opt->shortName && shorty && - myOpt->shortName == opt->shortName) || - (myOpt->longName && opt->longName && - /*@-nullpass@*/ /* LCL: opt->longName != NULL */ - !strcmp(myOpt->longName, opt->longName))) - /*@=nullpass@*/ - ) - { /*@-castfcnptr@*/ - poptCallbackType cb = (poptCallbackType)cbopt->arg; - /*@=castfcnptr@*/ - const void * cbData = (cbopt->descrip ? cbopt->descrip : myData); - /* Perform callback. */ - if (cb != NULL) { /* XXX program error */ - /*@-moduncon -noeffectuncon @*/ - cb(con, POPT_CALLBACK_REASON_OPTION, myOpt, - con->os->nextArg, cbData); - /*@=moduncon =noeffectuncon @*/ - } - /* Terminate (unless explcitly continuing). */ - if (!(cbopt->argInfo & POPT_CBFLAG_CONTINUE)) - return; - } - } -} - -poptContext poptGetContext(const char * name, int argc, const char ** argv, - const struct poptOption * options, int flags) -{ - poptContext con = malloc(sizeof(*con)); - - if (con == NULL) return NULL; /* XXX can't happen */ - memset(con, 0, sizeof(*con)); - - con->os = con->optionStack; - con->os->argc = argc; - /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */ - con->os->argv = argv; - /*@=dependenttrans =assignexpose@*/ - con->os->argb = NULL; - - if (!(flags & POPT_CONTEXT_KEEP_FIRST)) - con->os->next = 1; /* skip argv[0] */ - - con->leftovers = calloc( (argc + 1), sizeof(*con->leftovers) ); - /*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */ - con->options = options; - /*@=dependenttrans =assignexpose@*/ - con->aliases = NULL; - con->numAliases = 0; - con->flags = flags; - con->execs = NULL; - con->numExecs = 0; - con->finalArgvAlloced = argc * 2; - con->finalArgv = calloc( con->finalArgvAlloced, sizeof(*con->finalArgv) ); - con->execAbsolute = 1; - con->arg_strip = NULL; - - if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER")) - con->flags |= POPT_CONTEXT_POSIXMEHARDER; - - if (name) { - char * t = malloc(strlen(name) + 1); - if (t) con->appName = strcpy(t, name); - } - - /*@-internalglobs@*/ - invokeCallbacksPRE(con, con->options); - /*@=internalglobs@*/ - - return con; -} - -static void cleanOSE(/*@special@*/ struct optionStackEntry *os) - /*@uses os @*/ - /*@releases os->nextArg, os->argv, os->argb @*/ - /*@modifies os @*/ -{ - os->nextArg = _free(os->nextArg); - os->argv = _free(os->argv); - os->argb = PBM_FREE(os->argb); -} - -/*@-boundswrite@*/ -void poptResetContext(poptContext con) -{ - int i; - - if (con == NULL) return; - while (con->os > con->optionStack) { - cleanOSE(con->os--); - } - con->os->argb = PBM_FREE(con->os->argb); - con->os->currAlias = NULL; - con->os->nextCharArg = NULL; - con->os->nextArg = NULL; - con->os->next = 1; /* skip argv[0] */ - - con->numLeftovers = 0; - con->nextLeftover = 0; - con->restLeftover = 0; - con->doExec = NULL; - - if (con->finalArgv != NULL) - for (i = 0; i < con->finalArgvCount; i++) { - /*@-unqualifiedtrans@*/ /* FIX: typedef double indirection. */ - con->finalArgv[i] = _free(con->finalArgv[i]); - /*@=unqualifiedtrans@*/ - } - - con->finalArgvCount = 0; - con->arg_strip = PBM_FREE(con->arg_strip); - /*@-nullstate@*/ /* FIX: con->finalArgv != NULL */ - return; - /*@=nullstate@*/ -} -/*@=boundswrite@*/ - -/* Only one of longName, shortName should be set, not both. */ -/*@-boundswrite@*/ -static int handleExec(/*@special@*/ poptContext con, - /*@null@*/ const char * longName, char shortName) - /*@uses con->execs, con->numExecs, con->flags, con->doExec, - con->finalArgv, con->finalArgvAlloced, con->finalArgvCount @*/ - /*@modifies con @*/ -{ - poptItem item; - int i; - - if (con->execs == NULL || con->numExecs <= 0) /* XXX can't happen */ - return 0; - - for (i = con->numExecs - 1; i >= 0; i--) { - item = con->execs + i; - if (longName && !(item->option.longName && - !strcmp(longName, item->option.longName))) - continue; - else if (shortName != item->option.shortName) - continue; - break; - } - if (i < 0) return 0; - - - if (con->flags & POPT_CONTEXT_NO_EXEC) - return 1; - - if (con->doExec == NULL) { - con->doExec = con->execs + i; - return 1; - } - - /* We already have an exec to do; remember this option for next - time 'round */ - if ((con->finalArgvCount + 1) >= (con->finalArgvAlloced)) { - con->finalArgvAlloced += 10; - con->finalArgv = realloc(con->finalArgv, - sizeof(*con->finalArgv) * con->finalArgvAlloced); - } - - i = con->finalArgvCount++; - if (con->finalArgv != NULL) /* XXX can't happen */ - { char *s = malloc((longName ? strlen(longName) : 0) + 3); - if (s != NULL) { /* XXX can't happen */ - if (longName) - sprintf(s, "--%s", longName); - else - sprintf(s, "-%c", shortName); - con->finalArgv[i] = s; - } else - con->finalArgv[i] = NULL; - } - - /*@-nullstate@*/ /* FIX: con->finalArgv[] == NULL */ - return 1; - /*@=nullstate@*/ -} -/*@=boundswrite@*/ - -/* Only one of longName, shortName may be set at a time */ -static int handleAlias(/*@special@*/ poptContext con, - /*@null@*/ const char * longName, char shortName, - /*@exposed@*/ /*@null@*/ const char * nextCharArg) - /*@uses con->aliases, con->numAliases, con->optionStack, con->os, - con->os->currAlias, con->os->currAlias->option.longName @*/ - /*@modifies con @*/ -{ - poptItem item = con->os->currAlias; - int rc; - int i; - - if (item) { - if (longName && (item->option.longName && - !strcmp(longName, item->option.longName))) - return 0; - if (shortName && shortName == item->option.shortName) - return 0; - } - - if (con->aliases == NULL || con->numAliases <= 0) /* XXX can't happen */ - return 0; - - for (i = con->numAliases - 1; i >= 0; i--) { - item = con->aliases + i; - if (longName && !(item->option.longName && - !strcmp(longName, item->option.longName))) - continue; - else if (shortName != item->option.shortName) - continue; - break; - } - if (i < 0) return 0; - - if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH) - return POPT_ERROR_OPTSTOODEEP; - -/*@-boundsread@*/ - if (nextCharArg && *nextCharArg) - con->os->nextCharArg = nextCharArg; -/*@=boundsread@*/ - - con->os++; - con->os->next = 0; - con->os->stuffed = 0; - con->os->nextArg = NULL; - con->os->nextCharArg = NULL; - con->os->currAlias = con->aliases + i; - rc = poptDupArgv(con->os->currAlias->argc, con->os->currAlias->argv, - &con->os->argc, &con->os->argv); - con->os->argb = NULL; - - return (rc ? rc : 1); -} - -/*@-bounds -boundswrite @*/ -static int execCommand(poptContext con) - /*@globals internalState @*/ - /*@modifies internalState @*/ -{ - poptItem item = con->doExec; - const char ** argv; - int argc = 0; - int rc; - - if (item == NULL) /*XXX can't happen*/ - return POPT_ERROR_NOARG; - - if (item->argv == NULL || item->argc < 1 || - (!con->execAbsolute && strchr(item->argv[0], '/'))) - return POPT_ERROR_NOARG; - - argv = malloc(sizeof(*argv) * - (6 + item->argc + con->numLeftovers + con->finalArgvCount)); - if (argv == NULL) return POPT_ERROR_MALLOC; /* XXX can't happen */ - - if (!strchr(item->argv[0], '/') && con->execPath) { - char *s = alloca(strlen(con->execPath) + strlen(item->argv[0]) + sizeof("/")); - sprintf(s, "%s/%s", con->execPath, item->argv[0]); - argv[argc] = s; - } else { - argv[argc] = findProgramPath(item->argv[0]); - } - if (argv[argc++] == NULL) return POPT_ERROR_NOARG; - - if (item->argc > 1) { - memcpy(argv + argc, item->argv + 1, sizeof(*argv) * (item->argc - 1)); - argc += (item->argc - 1); - } - - if (con->finalArgv != NULL && con->finalArgvCount > 0) { - memcpy(argv + argc, con->finalArgv, - sizeof(*argv) * con->finalArgvCount); - argc += con->finalArgvCount; - } - - if (con->leftovers != NULL && con->numLeftovers > 0) { -#if 0 - argv[argc++] = "--"; -#endif - memcpy(argv + argc, con->leftovers, sizeof(*argv) * con->numLeftovers); - argc += con->numLeftovers; - } - - argv[argc] = NULL; - -#ifdef __hpux - rc = setresuid(getuid(), getuid(),-1); - if (rc) return POPT_ERROR_ERRNO; -#else -/* - * XXX " ... on BSD systems setuid() should be preferred over setreuid()" - * XXX sez' Timur Bakeyev - * XXX from Norbert Warmuth - */ -#if defined(HAVE_SETUID) - rc = setuid(getuid()); - if (rc) return POPT_ERROR_ERRNO; -#elif defined (HAVE_SETREUID) - rc = setreuid(getuid(), getuid()); /*hlauer: not portable to hpux9.01 */ - if (rc) return POPT_ERROR_ERRNO; -#else - ; /* Can't drop privileges */ -#endif -#endif - - if (argv[0] == NULL) - return POPT_ERROR_NOARG; - -#ifdef MYDEBUG -if (_popt_debug) - { const char ** avp; - fprintf(stderr, "==> execvp(%s) argv[%d]:", argv[0], argc); - for (avp = argv; *avp; avp++) - fprintf(stderr, " '%s'", *avp); - fprintf(stderr, "\n"); - } -#endif - - rc = execvp(argv[0], (char *const *)argv); - - return POPT_ERROR_ERRNO; -} -/*@=bounds =boundswrite @*/ - -/*@-boundswrite@*/ -/*@observer@*/ /*@null@*/ static const struct poptOption * -findOption(const struct poptOption * opt, /*@null@*/ const char * longName, - char shortName, - /*@null@*/ /*@out@*/ poptCallbackType * callback, - /*@null@*/ /*@out@*/ const void ** callbackData, - int singleDash) - /*@modifies *callback, *callbackData */ -{ - const struct poptOption * cb = NULL; - - /* This happens when a single - is given */ - if (singleDash && !shortName && (longName && *longName == '\0')) - shortName = '-'; - - for (; opt->longName || opt->shortName || opt->arg; opt++) { - - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - const struct poptOption * opt2; - - /* Recurse on included sub-tables. */ - if (opt->arg == NULL) continue; /* XXX program error */ - opt2 = findOption(opt->arg, longName, shortName, callback, - callbackData, singleDash); - if (opt2 == NULL) continue; - /* Sub-table data will be inheirited if no data yet. */ - if (!(callback && *callback)) return opt2; - if (!(callbackData && *callbackData == NULL)) return opt2; - /*@-observertrans -dependenttrans @*/ - *callbackData = opt->descrip; - /*@=observertrans =dependenttrans @*/ - return opt2; - } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) { - cb = opt; - } else if (longName && opt->longName && - (!singleDash || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) && - /*@-nullpass@*/ /* LCL: opt->longName != NULL */ - !strcmp(longName, opt->longName)) - /*@=nullpass@*/ - { - break; - } else if (shortName && shortName == opt->shortName) { - break; - } - } - - if (!opt->longName && !opt->shortName) - return NULL; - /*@-modobserver -mods @*/ - if (callback) *callback = NULL; - if (callbackData) *callbackData = NULL; - if (cb) { - if (callback) - /*@-castfcnptr@*/ - *callback = (poptCallbackType)cb->arg; - /*@=castfcnptr@*/ - if (!(cb->argInfo & POPT_CBFLAG_INC_DATA)) { - if (callbackData) - /*@-observertrans@*/ /* FIX: typedef double indirection. */ - *callbackData = cb->descrip; - /*@=observertrans@*/ - } - } - /*@=modobserver =mods @*/ - - return opt; -} -/*@=boundswrite@*/ - -static const char * findNextArg(/*@special@*/ poptContext con, - unsigned argx, int delete_arg) - /*@uses con->optionStack, con->os, - con->os->next, con->os->argb, con->os->argc, con->os->argv @*/ - /*@modifies con @*/ -{ - struct optionStackEntry * os = con->os; - const char * arg; - - do { - int i; - arg = NULL; - while (os->next == os->argc && os > con->optionStack) os--; - if (os->next == os->argc && os == con->optionStack) break; - if (os->argv != NULL) - for (i = os->next; i < os->argc; i++) { - /*@-sizeoftype@*/ - if (os->argb && PBM_ISSET(i, os->argb)) - /*@innercontinue@*/ continue; - if (*os->argv[i] == '-') - /*@innercontinue@*/ continue; - if (--argx > 0) - /*@innercontinue@*/ continue; - arg = os->argv[i]; - if (delete_arg) { - if (os->argb == NULL) os->argb = PBM_ALLOC(os->argc); - if (os->argb != NULL) /* XXX can't happen */ - PBM_SET(i, os->argb); - } - /*@innerbreak@*/ break; - /*@=sizeoftype@*/ - } - if (os > con->optionStack) os--; - } while (arg == NULL); - return arg; -} - -/*@-boundswrite@*/ -static /*@only@*/ /*@null@*/ const char * -expandNextArg(/*@special@*/ poptContext con, const char * s) - /*@uses con->optionStack, con->os, - con->os->next, con->os->argb, con->os->argc, con->os->argv @*/ - /*@modifies con @*/ -{ - const char * a = NULL; - size_t alen; - char *t, *te; - size_t tn = strlen(s) + 1; - char c; - - te = t = malloc(tn);; - if (t == NULL) return NULL; /* XXX can't happen */ - while ((c = *s++) != '\0') { - switch (c) { -#if 0 /* XXX can't do this */ - case '\\': /* escape */ - c = *s++; - /*@switchbreak@*/ break; -#endif - case '!': - if (!(s[0] == '#' && s[1] == ':' && s[2] == '+')) - /*@switchbreak@*/ break; - /* XXX Make sure that findNextArg deletes only next arg. */ - if (a == NULL) { - if ((a = findNextArg(con, 1, 1)) == NULL) - /*@switchbreak@*/ break; - } - s += 3; - - alen = strlen(a); - tn += alen; - *te = '\0'; - t = realloc(t, tn); - te = t + strlen(t); - strncpy(te, a, alen); te += alen; - continue; - /*@notreached@*/ /*@switchbreak@*/ break; - default: - /*@switchbreak@*/ break; - } - *te++ = c; - } - *te = '\0'; - t = realloc(t, strlen(t) + 1); /* XXX memory leak, hard to plug */ - return t; -} -/*@=boundswrite@*/ - -static void poptStripArg(/*@special@*/ poptContext con, int which) - /*@uses con->arg_strip, con->optionStack @*/ - /*@defines con->arg_strip @*/ - /*@modifies con @*/ -{ - /*@-sizeoftype@*/ - if (con->arg_strip == NULL) - con->arg_strip = PBM_ALLOC(con->optionStack[0].argc); - if (con->arg_strip != NULL) /* XXX can't happen */ - PBM_SET(which, con->arg_strip); - /*@=sizeoftype@*/ - /*@-compdef@*/ /* LCL: con->arg_strip udefined? */ - return; - /*@=compdef@*/ -} - -int poptSaveLong(long * arg, int argInfo, long aLong) -{ - /* XXX Check alignment, may fail on funky platforms. */ - if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1))) - return POPT_ERROR_NULLARG; - - if (argInfo & POPT_ARGFLAG_NOT) - aLong = ~aLong; - switch (argInfo & POPT_ARGFLAG_LOGICALOPS) { - case 0: - *arg = aLong; - break; - case POPT_ARGFLAG_OR: - *arg |= aLong; - break; - case POPT_ARGFLAG_AND: - *arg &= aLong; - break; - case POPT_ARGFLAG_XOR: - *arg ^= aLong; - break; - default: - return POPT_ERROR_BADOPERATION; - /*@notreached@*/ break; - } - return 0; -} - -int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong) -{ - /* XXX Check alignment, may fail on funky platforms. */ - if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1))) - return POPT_ERROR_NULLARG; - - if (argInfo & POPT_ARGFLAG_NOT) - aLong = ~aLong; - switch (argInfo & POPT_ARGFLAG_LOGICALOPS) { - case 0: - *arg = aLong; - break; - case POPT_ARGFLAG_OR: - *arg |= aLong; - break; - case POPT_ARGFLAG_AND: - *arg &= aLong; - break; - case POPT_ARGFLAG_XOR: - *arg ^= aLong; - break; - default: - return POPT_ERROR_BADOPERATION; - /*@notreached@*/ break; - } - return 0; -} - -/*@-boundswrite@*/ -/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */ -int poptGetNextOpt(poptContext con) -{ - const struct poptOption * opt = NULL; - int done = 0; - - if (con == NULL) - return -1; - while (!done) { - const char * origOptString = NULL; - poptCallbackType cb = NULL; - const void * cbData = NULL; - const char * longArg = NULL; - int canstrip = 0; - int shorty = 0; - - while (!con->os->nextCharArg && con->os->next == con->os->argc - && con->os > con->optionStack) { - cleanOSE(con->os--); - } - if (!con->os->nextCharArg && con->os->next == con->os->argc) { - /*@-internalglobs@*/ - invokeCallbacksPOST(con, con->options); - /*@=internalglobs@*/ - if (con->doExec) return execCommand(con); - return -1; - } - - /* Process next long option */ - if (!con->os->nextCharArg) { - char * localOptString, * optString; - int thisopt; - - /*@-sizeoftype@*/ - if (con->os->argb && PBM_ISSET(con->os->next, con->os->argb)) { - con->os->next++; - continue; - } - /*@=sizeoftype@*/ - thisopt = con->os->next; - if (con->os->argv != NULL) /* XXX can't happen */ - origOptString = con->os->argv[con->os->next++]; - - if (origOptString == NULL) /* XXX can't happen */ - return POPT_ERROR_BADOPT; - - if (con->restLeftover || *origOptString != '-') { - if (con->flags & POPT_CONTEXT_POSIXMEHARDER) - con->restLeftover = 1; - if (con->flags & POPT_CONTEXT_ARG_OPTS) { - con->os->nextArg = xstrdup(origOptString); - return 0; - } - if (con->leftovers != NULL) /* XXX can't happen */ - con->leftovers[con->numLeftovers++] = origOptString; - continue; - } - - /* Make a copy we can hack at */ - localOptString = optString = - strcpy(alloca(strlen(origOptString) + 1), origOptString); - - if (optString[0] == '\0') - return POPT_ERROR_BADOPT; - - if (optString[1] == '-' && !optString[2]) { - con->restLeftover = 1; - continue; - } else { - char *oe; - int singleDash; - - optString++; - if (*optString == '-') - singleDash = 0, optString++; - else - singleDash = 1; - - /* XXX aliases with arg substitution need "--alias=arg" */ - if (handleAlias(con, optString, '\0', NULL)) - continue; - - if (handleExec(con, optString, '\0')) - continue; - - /* Check for "--long=arg" option. */ - for (oe = optString; *oe && *oe != '='; oe++) - {}; - if (*oe == '=') { - *oe++ = '\0'; - /* XXX longArg is mapped back to persistent storage. */ - longArg = origOptString + (oe - localOptString); - } - - opt = findOption(con->options, optString, '\0', &cb, &cbData, - singleDash); - if (!opt && !singleDash) - return POPT_ERROR_BADOPT; - } - - if (!opt) { - con->os->nextCharArg = origOptString + 1; - } else { - if (con->os == con->optionStack && - opt->argInfo & POPT_ARGFLAG_STRIP) - { - canstrip = 1; - poptStripArg(con, thisopt); - } - shorty = 0; - } - } - - /* Process next short option */ - /*@-branchstate@*/ /* FIX: W2DO? */ - if (con->os->nextCharArg) { - origOptString = con->os->nextCharArg; - - con->os->nextCharArg = NULL; - - if (handleAlias(con, NULL, *origOptString, origOptString + 1)) - continue; - - if (handleExec(con, NULL, *origOptString)) { - /* Restore rest of short options for further processing */ - origOptString++; - if (*origOptString != '\0') - con->os->nextCharArg = origOptString; - continue; - } - - opt = findOption(con->options, NULL, *origOptString, &cb, - &cbData, 0); - if (!opt) - return POPT_ERROR_BADOPT; - shorty = 1; - - origOptString++; - if (*origOptString != '\0') - con->os->nextCharArg = origOptString; - } - /*@=branchstate@*/ - - if (opt == NULL) return POPT_ERROR_BADOPT; /* XXX can't happen */ - if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) { - if (poptSaveInt((int *)opt->arg, opt->argInfo, 1L)) - return POPT_ERROR_BADOPERATION; - } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) { - if (opt->arg) { - if (poptSaveInt((int *)opt->arg, opt->argInfo, (long)opt->val)) - return POPT_ERROR_BADOPERATION; - } - } else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) { - con->os->nextArg = _free(con->os->nextArg); - /*@-usedef@*/ /* FIX: W2DO? */ - if (longArg) { - /*@=usedef@*/ - longArg = expandNextArg(con, longArg); - con->os->nextArg = longArg; - } else if (con->os->nextCharArg) { - longArg = expandNextArg(con, con->os->nextCharArg); - con->os->nextArg = longArg; - con->os->nextCharArg = NULL; - } else { - while (con->os->next == con->os->argc && - con->os > con->optionStack) { - cleanOSE(con->os--); - } - if (con->os->next == con->os->argc) { - if (!(opt->argInfo & POPT_ARGFLAG_OPTIONAL)) - /*@-compdef@*/ /* FIX: con->os->argv not defined */ - return POPT_ERROR_NOARG; - /*@=compdef@*/ - con->os->nextArg = NULL; - } else { - - /* - * Make sure this isn't part of a short arg or the - * result of an alias expansion. - */ - if (con->os == con->optionStack && - (opt->argInfo & POPT_ARGFLAG_STRIP) && - canstrip) { - poptStripArg(con, con->os->next); - } - - if (con->os->argv != NULL) { /* XXX can't happen */ - /* XXX watchout: subtle side-effects live here. */ - longArg = con->os->argv[con->os->next++]; - longArg = expandNextArg(con, longArg); - con->os->nextArg = longArg; - } - } - } - longArg = NULL; - - if (opt->arg) { - switch (opt->argInfo & POPT_ARG_MASK) { - case POPT_ARG_STRING: - /* XXX memory leak, hard to plug */ - *((const char **) opt->arg) = (con->os->nextArg) - ? xstrdup(con->os->nextArg) : NULL; - /*@switchbreak@*/ break; - - case POPT_ARG_INT: - case POPT_ARG_LONG: - { long aLong = 0; - char *end; - - if (con->os->nextArg) { - aLong = strtol(con->os->nextArg, &end, 0); - if (!(end && *end == '\0')) - return POPT_ERROR_BADNUMBER; - } - - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) { - if (aLong == LONG_MIN || aLong == LONG_MAX) - return POPT_ERROR_OVERFLOW; - if (poptSaveLong((long *)opt->arg, opt->argInfo, aLong)) - return POPT_ERROR_BADOPERATION; - } else { - if (aLong > INT_MAX || aLong < INT_MIN) - return POPT_ERROR_OVERFLOW; - if (poptSaveInt((int *)opt->arg, opt->argInfo, aLong)) - return POPT_ERROR_BADOPERATION; - } - } /*@switchbreak@*/ break; - - case POPT_ARG_FLOAT: - case POPT_ARG_DOUBLE: - { double aDouble = 0.0; - char *end; - - if (con->os->nextArg) { - /*@-mods@*/ - int saveerrno = errno; - errno = 0; - aDouble = strtod(con->os->nextArg, &end); - if (errno == ERANGE) - return POPT_ERROR_OVERFLOW; - errno = saveerrno; - /*@=mods@*/ - if (*end != '\0') - return POPT_ERROR_BADNUMBER; - } - - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) { - *((double *) opt->arg) = aDouble; - } else { -#define _ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a)) - if ((_ABS(aDouble) - FLT_MAX) > DBL_EPSILON) - return POPT_ERROR_OVERFLOW; - if ((FLT_MIN - _ABS(aDouble)) > DBL_EPSILON) - return POPT_ERROR_OVERFLOW; - *((float *) opt->arg) = aDouble; - } - } /*@switchbreak@*/ break; - default: - fprintf(stdout, - POPT_("option type (%d) not implemented in popt\n"), - (opt->argInfo & POPT_ARG_MASK)); - exit(EXIT_FAILURE); - /*@notreached@*/ /*@switchbreak@*/ break; - } - } - } - - if (cb) { - /*@-internalglobs@*/ - invokeCallbacksOPTION(con, con->options, opt, cbData, shorty); - /*@=internalglobs@*/ - } else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL)) - done = 1; - - if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) { - con->finalArgvAlloced += 10; - con->finalArgv = realloc(con->finalArgv, - sizeof(*con->finalArgv) * con->finalArgvAlloced); - } - - if (con->finalArgv != NULL) - { char *s = malloc((opt->longName ? strlen(opt->longName) : 0) + 3); - if (s != NULL) { /* XXX can't happen */ - if (opt->longName) - sprintf(s, "%s%s", - ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"), - opt->longName); - else - sprintf(s, "-%c", opt->shortName); - con->finalArgv[con->finalArgvCount++] = s; - } else - con->finalArgv[con->finalArgvCount++] = NULL; - } - - if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) - /*@-ifempty@*/ ; /*@=ifempty@*/ - else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) - /*@-ifempty@*/ ; /*@=ifempty@*/ - else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) { - if (con->finalArgv != NULL && con->os->nextArg) - con->finalArgv[con->finalArgvCount++] = - /*@-nullpass@*/ /* LCL: con->os->nextArg != NULL */ - xstrdup(con->os->nextArg); - /*@=nullpass@*/ - } - } - - return (opt ? opt->val : -1); /* XXX can't happen */ -} -/*@=boundswrite@*/ - -const char * poptGetOptArg(poptContext con) -{ - const char * ret = NULL; - /*@-branchstate@*/ - if (con) { - ret = con->os->nextArg; - con->os->nextArg = NULL; - } - /*@=branchstate@*/ - return ret; -} - -const char * poptGetArg(poptContext con) -{ - const char * ret = NULL; - if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers) - ret = con->leftovers[con->nextLeftover++]; - return ret; -} - -const char * poptPeekArg(poptContext con) -{ - const char * ret = NULL; - if (con && con->leftovers != NULL && con->nextLeftover < con->numLeftovers) - ret = con->leftovers[con->nextLeftover]; - return ret; -} - -/*@-boundswrite@*/ -const char ** poptGetArgs(poptContext con) -{ - if (con == NULL || - con->leftovers == NULL || con->numLeftovers == con->nextLeftover) - return NULL; - - /* some apps like [like RPM ;-) ] need this NULL terminated */ - con->leftovers[con->numLeftovers] = NULL; - - /*@-nullret -nullstate @*/ /* FIX: typedef double indirection. */ - return (con->leftovers + con->nextLeftover); - /*@=nullret =nullstate @*/ -} -/*@=boundswrite@*/ - -poptContext poptFreeContext(poptContext con) -{ - poptItem item; - int i; - - if (con == NULL) return con; - poptResetContext(con); - con->os->argb = _free(con->os->argb); - - if (con->aliases != NULL) - for (i = 0; i < con->numAliases; i++) { - item = con->aliases + i; - /*@-modobserver -observertrans -dependenttrans@*/ - item->option.longName = _free(item->option.longName); - item->option.descrip = _free(item->option.descrip); - item->option.argDescrip = _free(item->option.argDescrip); - /*@=modobserver =observertrans =dependenttrans@*/ - item->argv = _free(item->argv); - } - con->aliases = _free(con->aliases); - - if (con->execs != NULL) - for (i = 0; i < con->numExecs; i++) { - item = con->execs + i; - /*@-modobserver -observertrans -dependenttrans@*/ - item->option.longName = _free(item->option.longName); - item->option.descrip = _free(item->option.descrip); - item->option.argDescrip = _free(item->option.argDescrip); - /*@=modobserver =observertrans =dependenttrans@*/ - item->argv = _free(item->argv); - } - con->execs = _free(con->execs); - - con->leftovers = _free(con->leftovers); - con->finalArgv = _free(con->finalArgv); - con->appName = _free(con->appName); - con->otherHelp = _free(con->otherHelp); - con->execPath = _free(con->execPath); - con->arg_strip = PBM_FREE(con->arg_strip); - - con = _free(con); - return con; -} - -int poptAddAlias(poptContext con, struct poptAlias alias, - /*@unused@*/ int flags) -{ - poptItem item = alloca(sizeof(*item)); - memset(item, 0, sizeof(*item)); - item->option.longName = alias.longName; - item->option.shortName = alias.shortName; - item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN; - item->option.arg = 0; - item->option.val = 0; - item->option.descrip = NULL; - item->option.argDescrip = NULL; - item->argc = alias.argc; - item->argv = alias.argv; - return poptAddItem(con, item, 0); -} - -/*@-boundswrite@*/ -/*@-mustmod@*/ /* LCL: con not modified? */ -int poptAddItem(poptContext con, poptItem newItem, int flags) -{ - poptItem * items, item; - int * nitems; - - switch (flags) { - case 1: - items = &con->execs; - nitems = &con->numExecs; - break; - case 0: - items = &con->aliases; - nitems = &con->numAliases; - break; - default: - return 1; - /*@notreached@*/ break; - } - - *items = realloc((*items), ((*nitems) + 1) * sizeof(**items)); - if ((*items) == NULL) - return 1; - - item = (*items) + (*nitems); - - item->option.longName = - (newItem->option.longName ? xstrdup(newItem->option.longName) : NULL); - item->option.shortName = newItem->option.shortName; - item->option.argInfo = newItem->option.argInfo; - item->option.arg = newItem->option.arg; - item->option.val = newItem->option.val; - item->option.descrip = - (newItem->option.descrip ? xstrdup(newItem->option.descrip) : NULL); - item->option.argDescrip = - (newItem->option.argDescrip ? xstrdup(newItem->option.argDescrip) : NULL); - item->argc = newItem->argc; - item->argv = newItem->argv; - - (*nitems)++; - - return 0; -} -/*@=mustmod@*/ -/*@=boundswrite@*/ - -const char * poptBadOption(poptContext con, int flags) -{ - struct optionStackEntry * os = NULL; - - if (con != NULL) - os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os; - - /*@-nullderef@*/ /* LCL: os->argv != NULL */ - return (os && os->argv ? os->argv[os->next - 1] : NULL); - /*@=nullderef@*/ -} - -const char *poptStrerror(const int error) -{ - switch (error) { - case POPT_ERROR_NOARG: - return POPT_("missing argument"); - case POPT_ERROR_BADOPT: - return POPT_("unknown option"); - case POPT_ERROR_BADOPERATION: - return POPT_("mutually exclusive logical operations requested"); - case POPT_ERROR_NULLARG: - return POPT_("opt->arg should not be NULL"); - case POPT_ERROR_OPTSTOODEEP: - return POPT_("aliases nested too deeply"); - case POPT_ERROR_BADQUOTE: - return POPT_("error in parameter quoting"); - case POPT_ERROR_BADNUMBER: - return POPT_("invalid numeric value"); - case POPT_ERROR_OVERFLOW: - return POPT_("number too large or too small"); - case POPT_ERROR_MALLOC: - return POPT_("memory allocation failed"); - case POPT_ERROR_ERRNO: - return strerror(errno); - default: - return POPT_("unknown error"); - } -} - -int poptStuffArgs(poptContext con, const char ** argv) -{ - int argc; - int rc; - - if ((con->os - con->optionStack) == POPT_OPTION_DEPTH) - return POPT_ERROR_OPTSTOODEEP; - - for (argc = 0; argv[argc]; argc++) - {}; - - con->os++; - con->os->next = 0; - con->os->nextArg = NULL; - con->os->nextCharArg = NULL; - con->os->currAlias = NULL; - rc = poptDupArgv(argc, argv, &con->os->argc, &con->os->argv); - con->os->argb = NULL; - con->os->stuffed = 1; - - return rc; -} - -const char * poptGetInvocationName(poptContext con) -{ - return (con->os->argv ? con->os->argv[0] : ""); -} - -/*@-boundswrite@*/ -int poptStrippedArgv(poptContext con, int argc, char ** argv) -{ - int numargs = argc; - int j = 1; - int i; - - /*@-sizeoftype@*/ - if (con->arg_strip) - for (i = 1; i < argc; i++) { - if (PBM_ISSET(i, con->arg_strip)) - numargs--; - } - - for (i = 1; i < argc; i++) { - if (con->arg_strip && PBM_ISSET(i, con->arg_strip)) - continue; - argv[j] = (j < numargs) ? argv[i] : NULL; - j++; - } - /*@=sizeoftype@*/ - - return numargs; -} -/*@=boundswrite@*/ diff --git a/source4/lib/popt/popt.h b/source4/lib/popt/popt.h deleted file mode 100644 index 04c9f655ab..0000000000 --- a/source4/lib/popt/popt.h +++ /dev/null @@ -1,541 +0,0 @@ -/** \file popt/popt.h - * \ingroup popt - */ - -/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#ifndef H_POPT -#define H_POPT - -#include /* for FILE * */ - -#define POPT_OPTION_DEPTH 10 - -/** \ingroup popt - * \name Arg type identifiers - */ -/*@{*/ -#define POPT_ARG_NONE 0 /*!< no arg */ -#define POPT_ARG_STRING 1 /*!< arg will be saved as string */ -#define POPT_ARG_INT 2 /*!< arg will be converted to int */ -#define POPT_ARG_LONG 3 /*!< arg will be converted to long */ -#define POPT_ARG_INCLUDE_TABLE 4 /*!< arg points to table */ -#define POPT_ARG_CALLBACK 5 /*!< table-wide callback... must be - set first in table; arg points - to callback, descrip points to - callback data to pass */ -#define POPT_ARG_INTL_DOMAIN 6 /*!< set the translation domain - for this table and any - included tables; arg points - to the domain string */ -#define POPT_ARG_VAL 7 /*!< arg should take value val */ -#define POPT_ARG_FLOAT 8 /*!< arg will be converted to float */ -#define POPT_ARG_DOUBLE 9 /*!< arg will be converted to double */ - -#define POPT_ARG_MASK 0x0000FFFF -/*@}*/ - -/** \ingroup popt - * \name Arg modifiers - */ -/*@{*/ -#define POPT_ARGFLAG_ONEDASH 0x80000000 /*!< allow -longoption */ -#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /*!< don't show in help/usage */ -#define POPT_ARGFLAG_STRIP 0x20000000 /*!< strip this arg from argv(only applies to long args) */ -#define POPT_ARGFLAG_OPTIONAL 0x10000000 /*!< arg may be missing */ - -#define POPT_ARGFLAG_OR 0x08000000 /*!< arg will be or'ed */ -#define POPT_ARGFLAG_NOR 0x09000000 /*!< arg will be nor'ed */ -#define POPT_ARGFLAG_AND 0x04000000 /*!< arg will be and'ed */ -#define POPT_ARGFLAG_NAND 0x05000000 /*!< arg will be nand'ed */ -#define POPT_ARGFLAG_XOR 0x02000000 /*!< arg will be xor'ed */ -#define POPT_ARGFLAG_NOT 0x01000000 /*!< arg will be negated */ -#define POPT_ARGFLAG_LOGICALOPS \ - (POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR) - -#define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR) - /*!< set arg bit(s) */ -#define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND) - /*!< clear arg bit(s) */ - -#define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 /*!< show default value in --help */ - -/*@}*/ - -/** \ingroup popt - * \name Callback modifiers - */ -/*@{*/ -#define POPT_CBFLAG_PRE 0x80000000 /*!< call the callback before parse */ -#define POPT_CBFLAG_POST 0x40000000 /*!< call the callback after parse */ -#define POPT_CBFLAG_INC_DATA 0x20000000 /*!< use data from the include line, - not the subtable */ -#define POPT_CBFLAG_SKIPOPTION 0x10000000 /*!< don't callback with option */ -#define POPT_CBFLAG_CONTINUE 0x08000000 /*!< continue callbacks with option */ -/*@}*/ - -/** \ingroup popt - * \name Error return values - */ -/*@{*/ -#define POPT_ERROR_NOARG -10 /*!< missing argument */ -#define POPT_ERROR_BADOPT -11 /*!< unknown option */ -#define POPT_ERROR_OPTSTOODEEP -13 /*!< aliases nested too deeply */ -#define POPT_ERROR_BADQUOTE -15 /*!< error in paramter quoting */ -#define POPT_ERROR_ERRNO -16 /*!< errno set, use strerror(errno) */ -#define POPT_ERROR_BADNUMBER -17 /*!< invalid numeric value */ -#define POPT_ERROR_OVERFLOW -18 /*!< number too large or too small */ -#define POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logical operations requested */ -#define POPT_ERROR_NULLARG -20 /*!< opt->arg should not be NULL */ -#define POPT_ERROR_MALLOC -21 /*!< memory allocation failed */ -/*@}*/ - -/** \ingroup popt - * \name poptBadOption() flags - */ -/*@{*/ -#define POPT_BADOPTION_NOALIAS (1 << 0) /*!< don't go into an alias */ -/*@}*/ - -/** \ingroup popt - * \name poptGetContext() flags - */ -/*@{*/ -#define POPT_CONTEXT_NO_EXEC (1 << 0) /*!< ignore exec expansions */ -#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /*!< pay attention to argv[0] */ -#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /*!< options can't follow args */ -#define POPT_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with value 0 */ -/*@}*/ - -/** \ingroup popt - */ -struct poptOption { -/*@observer@*/ /*@null@*/ const char * longName; /*!< may be NULL */ - char shortName; /*!< may be '\0' */ - int argInfo; -/*@shared@*/ /*@null@*/ void * arg; /*!< depends on argInfo */ - int val; /*!< 0 means don't return, just update flag */ -/*@observer@*/ /*@null@*/ const char * descrip; /*!< description for autohelp -- may be NULL */ -/*@observer@*/ /*@null@*/ const char * argDescrip; /*!< argument description for autohelp */ -}; - -/** \ingroup popt - * A popt alias argument for poptAddAlias(). - */ -struct poptAlias { -/*@owned@*/ /*@null@*/ const char * longName; /*!< may be NULL */ - char shortName; /*!< may be '\0' */ - int argc; -/*@owned@*/ const char ** argv; /*!< must be free()able */ -}; - -/** \ingroup popt - * A popt alias or exec argument for poptAddItem(). - */ -/*@-exporttype@*/ -typedef struct poptItem_s { - struct poptOption option; /*!< alias/exec name(s) and description. */ - int argc; /*!< (alias) no. of args. */ -/*@owned@*/ const char ** argv; /*!< (alias) args, must be free()able. */ -} * poptItem; -/*@=exporttype@*/ - -/** \ingroup popt - * \name Auto-generated help/usage - */ -/*@{*/ - -/** - * Empty table marker to enable displaying popt alias/exec options. - */ -/*@-exportvar@*/ -/*@unchecked@*/ /*@observer@*/ -extern struct poptOption poptAliasOptions[]; -/*@=exportvar@*/ -#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \ - 0, "Options implemented via popt alias/exec:", NULL }, - -/** - * Auto help table options. - */ -/*@-exportvar@*/ -/*@unchecked@*/ /*@observer@*/ -extern struct poptOption poptHelpOptions[]; -/*@=exportvar@*/ -#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \ - 0, "Help options:", NULL }, - -#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL } -/*@}*/ - -/** \ingroup popt - */ -/*@-exporttype@*/ -typedef /*@abstract@*/ struct poptContext_s * poptContext; -/*@=exporttype@*/ - -/** \ingroup popt - */ -#ifndef __cplusplus -/*@-exporttype -typeuse@*/ -typedef struct poptOption * poptOption; -/*@=exporttype =typeuse@*/ -#endif - -/*@-exportconst@*/ -enum poptCallbackReason { - POPT_CALLBACK_REASON_PRE = 0, - POPT_CALLBACK_REASON_POST = 1, - POPT_CALLBACK_REASON_OPTION = 2 -}; -/*@=exportconst@*/ - -#ifdef __cplusplus -extern "C" { -#endif -/*@-type@*/ - -/** \ingroup popt - * Table callback prototype. - * @param con context - * @param reason reason for callback - * @param opt option that triggered callback - * @param arg @todo Document. - * @param data @todo Document. - */ -typedef void (*poptCallbackType) (poptContext con, - enum poptCallbackReason reason, - /*@null@*/ const struct poptOption * opt, - /*@null@*/ const char * arg, - /*@null@*/ const void * data) - /*@*/; - -/** \ingroup popt - * Initialize popt context. - * @param name - * @param argc no. of arguments - * @param argv argument array - * @param options address of popt option table - * @param flags or'd POPT_CONTEXT_* bits - * @return initialized popt context - */ -/*@only@*/ /*@null@*/ poptContext poptGetContext( - /*@dependent@*/ /*@keep@*/ const char * name, - int argc, /*@dependent@*/ /*@keep@*/ const char ** argv, - /*@dependent@*/ /*@keep@*/ const struct poptOption * options, - int flags) - /*@*/; - -/** \ingroup popt - * Reinitialize popt context. - * @param con context - */ -/*@-exportlocal@*/ -void poptResetContext(/*@null@*/poptContext con) - /*@modifies con @*/; -/*@=exportlocal@*/ - -/** \ingroup popt - * Return value of next option found. - * @param con context - * @return next option val, -1 on last item, POPT_ERROR_* on error - */ -int poptGetNextOpt(/*@null@*/poptContext con) - /*@globals fileSystem, internalState @*/ - /*@modifies con, fileSystem, internalState @*/; - -/*@-redecl@*/ -/** \ingroup popt - * Return next option argument (if any). - * @param con context - * @return option argument, NULL if no more options are available - */ -/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con) - /*@modifies con @*/; - -/** \ingroup popt - * Return current option's argument. - * @param con context - * @return option argument, NULL if no more options are available - */ -/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con) - /*@modifies con @*/; - -/** \ingroup popt - * Peek at current option's argument. - * @param con context - * @return option argument - */ -/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con) - /*@*/; - -/** \ingroup popt - * Return remaining arguments. - * @param con context - * @return argument array, terminated with NULL - */ -/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con) - /*@modifies con @*/; - -/** \ingroup popt - * Return the option which caused the most recent error. - * @param con context - * @param flags - * @return offending option - */ -/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags) - /*@*/; -/*@=redecl@*/ - -/** \ingroup popt - * Destroy context. - * @param con context - * @return NULL always - */ -/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con) - /*@modifies con @*/; - -/** \ingroup popt - * Add arguments to context. - * @param con context - * @param argv argument array, NULL terminated - * @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure - */ -int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv) - /*@modifies con @*/; - -/** \ingroup popt - * Add alias to context. - * @todo Pass alias by reference, not value. - * @deprecated Use poptAddItem instead. - * @param con context - * @param alias alias to add - * @param flags (unused) - * @return 0 on success - */ -/*@unused@*/ -int poptAddAlias(poptContext con, struct poptAlias alias, int flags) - /*@modifies con @*/; - -/** \ingroup popt - * Add alias/exec item to context. - * @param con context - * @param newItem alias/exec item to add - * @param flags 0 for alias, 1 for exec - * @return 0 on success - */ -int poptAddItem(poptContext con, poptItem newItem, int flags) - /*@modifies con @*/; - -/** \ingroup popt - * Read configuration file. - * @param con context - * @param fn file name to read - * @return 0 on success, POPT_ERROR_ERRNO on failure - */ -int poptReadConfigFile(poptContext con, const char * fn) - /*@globals fileSystem, internalState @*/ - /*@modifies con->execs, con->numExecs, - fileSystem, internalState @*/; - -/** \ingroup popt - * Read default configuration from /etc/popt and $HOME/.popt. - * @param con context - * @param useEnv (unused) - * @return 0 on success, POPT_ERROR_ERRNO on failure - */ -int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) - /*@globals fileSystem, internalState @*/ - /*@modifies con->execs, con->numExecs, - fileSystem, internalState @*/; - -/** \ingroup popt - * Duplicate an argument array. - * @note: The argument array is malloc'd as a single area, so only argv must - * be free'd. - * - * @param argc no. of arguments - * @param argv argument array - * @retval argcPtr address of returned no. of arguments - * @retval argvPtr address of returned argument array - * @return 0 on success, POPT_ERROR_NOARG on failure - */ -int poptDupArgv(int argc, /*@null@*/ const char **argv, - /*@null@*/ /*@out@*/ int * argcPtr, - /*@null@*/ /*@out@*/ const char *** argvPtr) - /*@modifies *argcPtr, *argvPtr @*/; - -/** \ingroup popt - * Parse a string into an argument array. - * The parse allows ', ", and \ quoting, but ' is treated the same as " and - * both may include \ quotes. - * @note: The argument array is malloc'd as a single area, so only argv must - * be free'd. - * - * @param s string to parse - * @retval argcPtr address of returned no. of arguments - * @retval argvPtr address of returned argument array - */ -int poptParseArgvString(const char * s, - /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr) - /*@modifies *argcPtr, *argvPtr @*/; - -/** \ingroup popt - * Parses an input configuration file and returns an string that is a - * command line. For use with popt. You must free the return value when done. - * - * Given the file: -\verbatim -# this line is ignored - # this one too -aaa - bbb - ccc -bla=bla - -this_is = fdsafdas - bad_line= - reall bad line - reall bad line = again -5555= 55555 - test = with lots of spaces -\endverbatim -* -* The result is: -\verbatim ---aaa --bbb --ccc --bla="bla" --this_is="fdsafdas" --5555="55555" --test="with lots of spaces" -\endverbatim -* -* Passing this to poptParseArgvString() yields an argv of: -\verbatim -'--aaa' -'--bbb' -'--ccc' -'--bla=bla' -'--this_is=fdsafdas' -'--5555=55555' -'--test=with lots of spaces' -\endverbatim - * - * @bug NULL is returned if file line is too long. - * @bug Silently ignores invalid lines. - * - * @param fp file handle to read - * @param *argstrp return string of options (malloc'd) - * @param flags unused - * @return 0 on success - * @see poptParseArgvString - */ -/*@-fcnuse@*/ -int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags) - /*@globals fileSystem @*/ - /*@modifies *fp, *argstrp, fileSystem @*/; -/*@=fcnuse@*/ - -/** \ingroup popt - * Return formatted error string for popt failure. - * @param error popt error - * @return error string - */ -/*@-redecl@*/ -/*@observer@*/ const char *poptStrerror(const int error) - /*@*/; -/*@=redecl@*/ - -/** \ingroup popt - * Limit search for executables. - * @param con context - * @param path single path to search for executables - * @param allowAbsolute absolute paths only? - */ -void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) - /*@modifies con @*/; - -/** \ingroup popt - * Print detailed description of options. - * @param con context - * @param fp ouput file handle - * @param flags (unused) - */ -void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/; - -/** \ingroup popt - * Print terse description of options. - * @param con context - * @param fp ouput file handle - * @param flags (unused) - */ -void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/; - -/** \ingroup popt - * Provide text to replace default "[OPTION...]" in help/usage output. - * @param con context - * @param text replacement text - */ -/*@-fcnuse@*/ -void poptSetOtherOptionHelp(poptContext con, const char * text) - /*@modifies con @*/; -/*@=fcnuse@*/ - -/** \ingroup popt - * Return argv[0] from context. - * @param con context - * @return argv[0] - */ -/*@-redecl -fcnuse@*/ -/*@observer@*/ const char * poptGetInvocationName(poptContext con) - /*@*/; -/*@=redecl =fcnuse@*/ - -/** \ingroup popt - * Shuffle argv pointers to remove stripped args, returns new argc. - * @param con context - * @param argc no. of args - * @param argv arg vector - * @return new argc - */ -/*@-fcnuse@*/ -int poptStrippedArgv(poptContext con, int argc, char ** argv) - /*@modifies *argv @*/; -/*@=fcnuse@*/ - -/** - * Save a long, performing logical operation with value. - * @warning Alignment check may be too strict on certain platorms. - * @param arg integer pointer, aligned on int boundary. - * @param argInfo logical operation (see POPT_ARGFLAG_*) - * @param aLong value to use - * @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION - */ -/*@-incondefs@*/ -int poptSaveLong(/*@null@*/ long * arg, int argInfo, long aLong) - /*@modifies *arg @*/ - /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/; -/*@=incondefs@*/ - -/** - * Save an integer, performing logical operation with value. - * @warning Alignment check may be too strict on certain platorms. - * @param arg integer pointer, aligned on int boundary. - * @param argInfo logical operation (see POPT_ARGFLAG_*) - * @param aLong value to use - * @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION - */ -/*@-incondefs@*/ -int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong) - /*@modifies *arg @*/ - /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/; -/*@=incondefs@*/ - -/*@=type@*/ -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source4/lib/popt/poptconfig.c b/source4/lib/popt/poptconfig.c deleted file mode 100644 index a600a92905..0000000000 --- a/source4/lib/popt/poptconfig.c +++ /dev/null @@ -1,190 +0,0 @@ -/** \ingroup popt - * \file popt/poptconfig.c - */ - -/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#include "system.h" -#include "poptint.h" - -/*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */ -static void configLine(poptContext con, char * line) - /*@modifies con @*/ -{ - /*@-type@*/ - int nameLength = strlen(con->appName); - /*@=type@*/ - const char * entryType; - const char * opt; - poptItem item = alloca(sizeof(*item)); - int i, j; - -/*@-boundswrite@*/ - memset(item, 0, sizeof(*item)); - - /*@-type@*/ - if (strncmp(line, con->appName, nameLength)) return; - /*@=type@*/ - - line += nameLength; - if (*line == '\0' || !isspace(*line)) return; - - while (*line != '\0' && isspace(*line)) line++; - entryType = line; - while (*line == '\0' || !isspace(*line)) line++; - *line++ = '\0'; - - while (*line != '\0' && isspace(*line)) line++; - if (*line == '\0') return; - opt = line; - while (*line == '\0' || !isspace(*line)) line++; - *line++ = '\0'; - - while (*line != '\0' && isspace(*line)) line++; - if (*line == '\0') return; - - /*@-temptrans@*/ /* FIX: line alias is saved */ - if (opt[0] == '-' && opt[1] == '-') - item->option.longName = opt + 2; - else if (opt[0] == '-' && opt[2] == '\0') - item->option.shortName = opt[1]; - /*@=temptrans@*/ - - if (poptParseArgvString(line, &item->argc, &item->argv)) return; - - /*@-modobserver@*/ - item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN; - for (i = 0, j = 0; i < item->argc; i++, j++) { - const char * f; - if (!strncmp(item->argv[i], "--POPTdesc=", sizeof("--POPTdesc=")-1)) { - f = item->argv[i] + sizeof("--POPTdesc="); - if (f[0] == '$' && f[1] == '"') f++; - item->option.descrip = f; - item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN; - j--; - } else - if (!strncmp(item->argv[i], "--POPTargs=", sizeof("--POPTargs=")-1)) { - f = item->argv[i] + sizeof("--POPTargs="); - if (f[0] == '$' && f[1] == '"') f++; - item->option.argDescrip = f; - item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN; - item->option.argInfo |= POPT_ARG_STRING; - j--; - } else - if (j != i) - item->argv[j] = item->argv[i]; - } - if (j != i) { - item->argv[j] = NULL; - item->argc = j; - } - /*@=modobserver@*/ -/*@=boundswrite@*/ - - /*@-nullstate@*/ /* FIX: item->argv[] may be NULL */ - if (!strcmp(entryType, "alias")) - (void) poptAddItem(con, item, 0); - else if (!strcmp(entryType, "exec")) - (void) poptAddItem(con, item, 1); - /*@=nullstate@*/ -} -/*@=compmempass@*/ - -int poptReadConfigFile(poptContext con, const char * fn) -{ - const char * file, * chptr, * end; - char * buf; -/*@dependent@*/ char * dst; - int fd, rc; - off_t fileLength; - - fd = open(fn, O_RDONLY); - if (fd < 0) - return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO); - - fileLength = lseek(fd, 0, SEEK_END); - if (fileLength == -1 || lseek(fd, 0, 0) == -1) { - rc = errno; - (void) close(fd); - /*@-mods@*/ - errno = rc; - /*@=mods@*/ - return POPT_ERROR_ERRNO; - } - - file = alloca(fileLength + 1); - if (read(fd, (char *)file, fileLength) != fileLength) { - rc = errno; - (void) close(fd); - /*@-mods@*/ - errno = rc; - /*@=mods@*/ - return POPT_ERROR_ERRNO; - } - if (close(fd) == -1) - return POPT_ERROR_ERRNO; - -/*@-boundswrite@*/ - dst = buf = alloca(fileLength + 1); - - chptr = file; - end = (file + fileLength); - /*@-infloops@*/ /* LCL: can't detect chptr++ */ - while (chptr < end) { - switch (*chptr) { - case '\n': - *dst = '\0'; - dst = buf; - while (*dst && isspace(*dst)) dst++; - if (*dst && *dst != '#') - configLine(con, dst); - chptr++; - /*@switchbreak@*/ break; - case '\\': - *dst++ = *chptr++; - if (chptr < end) { - if (*chptr == '\n') - dst--, chptr++; - /* \ at the end of a line does not insert a \n */ - else - *dst++ = *chptr++; - } - /*@switchbreak@*/ break; - default: - *dst++ = *chptr++; - /*@switchbreak@*/ break; - } - } - /*@=infloops@*/ -/*@=boundswrite@*/ - - return 0; -} - -int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) -{ - char * fn, * home; - int rc; - - /*@-type@*/ - if (!con->appName) return 0; - /*@=type@*/ - - rc = poptReadConfigFile(con, "/etc/popt"); - if (rc) return rc; -#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) - if (getuid() != geteuid()) return 0; -#endif - - if ((home = getenv("HOME"))) { - fn = alloca(strlen(home) + 20); - strcpy(fn, home); - strcat(fn, "/.popt"); - rc = poptReadConfigFile(con, fn); - if (rc) return rc; - } - - return 0; -} diff --git a/source4/lib/popt/popthelp.c b/source4/lib/popt/popthelp.c deleted file mode 100644 index 7ae3de7fb5..0000000000 --- a/source4/lib/popt/popthelp.c +++ /dev/null @@ -1,742 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/*@-type@*/ -/** \ingroup popt - * \file popt/popthelp.c - */ - -/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#include "system.h" -#include "poptint.h" - -/** - * Display arguments. - * @param con context - * @param foo (unused) - * @param key option(s) - * @param arg (unused) - * @param data (unused) - */ -static void displayArgs(poptContext con, - /*@unused@*/ enum poptCallbackReason foo, - struct poptOption * key, - /*@unused@*/ const char * arg, /*@unused@*/ void * data) - /*@globals fileSystem@*/ - /*@modifies fileSystem@*/ -{ - if (key->shortName == '?') - poptPrintHelp(con, stdout, 0); - else - poptPrintUsage(con, stdout, 0); - exit(0); -} - -#ifdef NOTYET -/*@unchecked@*/ -static int show_option_defaults = 0; -#endif - -/** - * Empty table marker to enable displaying popt alias/exec options. - */ -/*@observer@*/ /*@unchecked@*/ -struct poptOption poptAliasOptions[] = { - POPT_TABLEEND -}; - -/** - * Auto help table options. - */ -/*@-castfcnptr@*/ -/*@observer@*/ /*@unchecked@*/ -struct poptOption poptHelpOptions[] = { - { NULL, '\0', POPT_ARG_CALLBACK, (void *)&displayArgs, '\0', NULL, NULL }, - { "help", '?', 0, NULL, '?', N_("Show this help message"), NULL }, - { "usage", '\0', 0, NULL, 'u', N_("Display brief usage message"), NULL }, -#ifdef NOTYET - { "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0, - N_("Display option defaults in message"), NULL }, -#endif - POPT_TABLEEND -} ; -/*@=castfcnptr@*/ - -/** - * @param table option(s) - */ -/*@observer@*/ /*@null@*/ static const char *const -getTableTranslationDomain(/*@null@*/ const struct poptOption *table) - /*@*/ -{ - const struct poptOption *opt; - - if (table != NULL) - for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) { - if (opt->argInfo == POPT_ARG_INTL_DOMAIN) - return opt->arg; - } - return NULL; -} - -/** - * @param opt option(s) - * @param translation_domain translation domain - */ -/*@observer@*/ /*@null@*/ static const char *const -getArgDescrip(const struct poptOption * opt, - /*@-paramuse@*/ /* FIX: i18n macros disabled with lclint */ - /*@null@*/ const char * translation_domain) - /*@=paramuse@*/ - /*@*/ -{ - if (!(opt->argInfo & POPT_ARG_MASK)) return NULL; - - if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2)) - if (opt->argDescrip) return POPT_(opt->argDescrip); - - if (opt->argDescrip) return D_(translation_domain, opt->argDescrip); - - switch (opt->argInfo & POPT_ARG_MASK) { - case POPT_ARG_NONE: return POPT_("NONE"); -#ifdef DYING - case POPT_ARG_VAL: return POPT_("VAL"); -#else - case POPT_ARG_VAL: return NULL; -#endif - case POPT_ARG_INT: return POPT_("INT"); - case POPT_ARG_LONG: return POPT_("LONG"); - case POPT_ARG_STRING: return POPT_("STRING"); - case POPT_ARG_FLOAT: return POPT_("FLOAT"); - case POPT_ARG_DOUBLE: return POPT_("DOUBLE"); - default: return POPT_("ARG"); - } -} - -/** - * Display default value for an option. - * @param lineLength - * @param opt option(s) - * @param translation_domain translation domain - * @return - */ -static /*@only@*/ /*@null@*/ char * -singleOptionDefaultValue(int lineLength, - const struct poptOption * opt, - /*@-paramuse@*/ /* FIX: i18n macros disabled with lclint */ - /*@null@*/ const char * translation_domain) - /*@=paramuse@*/ - /*@*/ -{ - const char * defstr = D_(translation_domain, "default"); - char * le = malloc(4*lineLength + 1); - char * l = le; - - if (le == NULL) return NULL; /* XXX can't happen */ -/*@-boundswrite@*/ - *le = '\0'; - *le++ = '('; - strcpy(le, defstr); le += strlen(le); - *le++ = ':'; - *le++ = ' '; - if (opt->arg) /* XXX programmer error */ - switch (opt->argInfo & POPT_ARG_MASK) { - case POPT_ARG_VAL: - case POPT_ARG_INT: - { long aLong = *((int *)opt->arg); - le += sprintf(le, "%ld", aLong); - } break; - case POPT_ARG_LONG: - { long aLong = *((long *)opt->arg); - le += sprintf(le, "%ld", aLong); - } break; - case POPT_ARG_FLOAT: - { double aDouble = *((float *)opt->arg); - le += sprintf(le, "%g", aDouble); - } break; - case POPT_ARG_DOUBLE: - { double aDouble = *((double *)opt->arg); - le += sprintf(le, "%g", aDouble); - } break; - case POPT_ARG_STRING: - { const char * s = *(const char **)opt->arg; - if (s == NULL) { - strcpy(le, "null"); le += strlen(le); - } else { - size_t slen = 4*lineLength - (le - l) - sizeof("\"...\")"); - *le++ = '"'; - strncpy(le, s, slen); le[slen] = '\0'; le += strlen(le); - if (slen < strlen(s)) { - strcpy(le, "..."); le += strlen(le); - } - *le++ = '"'; - } - } break; - case POPT_ARG_NONE: - default: - l = _free(l); - return NULL; - /*@notreached@*/ break; - } - *le++ = ')'; - *le = '\0'; -/*@=boundswrite@*/ - - return l; -} - -/** - * Display help text for an option. - * @param fp output file handle - * @param maxLeftCol - * @param opt option(s) - * @param translation_domain translation domain - */ -static void singleOptionHelp(FILE * fp, int maxLeftCol, - const struct poptOption * opt, - /*@null@*/ const char * translation_domain) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ -{ - int indentLength = maxLeftCol + 5; - int lineLength = 79 - indentLength; - const char * help = D_(translation_domain, opt->descrip); - const char * argDescrip = getArgDescrip(opt, translation_domain); - int helpLength; - char * defs = NULL; - char * left; - int nb = maxLeftCol + 1; - - /* Make sure there's more than enough room in target buffer. */ - if (opt->longName) nb += strlen(opt->longName); - if (argDescrip) nb += strlen(argDescrip); - -/*@-boundswrite@*/ - left = malloc(nb); - if (left == NULL) return; /* XXX can't happen */ - left[0] = '\0'; - left[maxLeftCol] = '\0'; - - if (opt->longName && opt->shortName) - sprintf(left, "-%c, %s%s", opt->shortName, - ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"), - opt->longName); - else if (opt->shortName != '\0') - sprintf(left, "-%c", opt->shortName); - else if (opt->longName) - sprintf(left, "%s%s", - ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"), - opt->longName); - if (!*left) goto out; - - if (argDescrip) { - char * le = left + strlen(left); - - if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) - *le++ = '['; - - /* Choose type of output */ - /*@-branchstate@*/ - if (opt->argInfo & POPT_ARGFLAG_SHOW_DEFAULT) { - defs = singleOptionDefaultValue(lineLength, opt, translation_domain); - if (defs) { - char * t = malloc((help ? strlen(help) : 0) + - strlen(defs) + sizeof(" ")); - if (t) { - char * te = t; - *te = '\0'; - if (help) { - strcpy(te, help); te += strlen(te); - } - *te++ = ' '; - strcpy(te, defs); - defs = _free(defs); - } - defs = t; - } - } - /*@=branchstate@*/ - - if (opt->argDescrip == NULL) { - switch (opt->argInfo & POPT_ARG_MASK) { - case POPT_ARG_NONE: - break; - case POPT_ARG_VAL: -#ifdef NOTNOW /* XXX pug ugly nerdy output */ - { long aLong = opt->val; - int ops = (opt->argInfo & POPT_ARGFLAG_LOGICALOPS); - int negate = (opt->argInfo & POPT_ARGFLAG_NOT); - - /* Don't bother displaying typical values */ - if (!ops && (aLong == 0L || aLong == 1L || aLong == -1L)) - break; - *le++ = '['; - switch (ops) { - case POPT_ARGFLAG_OR: - *le++ = '|'; - /*@innerbreak@*/ break; - case POPT_ARGFLAG_AND: - *le++ = '&'; - /*@innerbreak@*/ break; - case POPT_ARGFLAG_XOR: - *le++ = '^'; - /*@innerbreak@*/ break; - default: - /*@innerbreak@*/ break; - } - *le++ = '='; - if (negate) *le++ = '~'; - /*@-formatconst@*/ - le += sprintf(le, (ops ? "0x%lx" : "%ld"), aLong); - /*@=formatconst@*/ - *le++ = ']'; - } -#endif - break; - case POPT_ARG_INT: - case POPT_ARG_LONG: - case POPT_ARG_FLOAT: - case POPT_ARG_DOUBLE: - case POPT_ARG_STRING: - *le++ = '='; - strcpy(le, argDescrip); le += strlen(le); - break; - default: - break; - } - } else { - *le++ = '='; - strcpy(le, argDescrip); le += strlen(le); - } - if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) - *le++ = ']'; - *le = '\0'; - } -/*@=boundswrite@*/ - - if (help) - fprintf(fp," %-*s ", maxLeftCol, left); - else { - fprintf(fp," %s\n", left); - goto out; - } - - left = _free(left); - if (defs) { - help = defs; defs = NULL; - } - - helpLength = strlen(help); -/*@-boundsread@*/ - while (helpLength > lineLength) { - const char * ch; - char format[16]; - - ch = help + lineLength - 1; - while (ch > help && !isspace(*ch)) ch--; - if (ch == help) break; /* give up */ - while (ch > (help + 1) && isspace(*ch)) ch--; - ch++; - - sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength); - /*@-formatconst@*/ - fprintf(fp, format, help, " "); - /*@=formatconst@*/ - help = ch; - while (isspace(*help) && *help) help++; - helpLength = strlen(help); - } -/*@=boundsread@*/ - - if (helpLength) fprintf(fp, "%s\n", help); - -out: - /*@-dependenttrans@*/ - defs = _free(defs); - /*@=dependenttrans@*/ - left = _free(left); -} - -/** - * @param opt option(s) - * @param translation_domain translation domain - */ -static int maxArgWidth(const struct poptOption * opt, - /*@null@*/ const char * translation_domain) - /*@*/ -{ - int max = 0; - int len = 0; - const char * s; - - if (opt != NULL) - while (opt->longName || opt->shortName || opt->arg) { - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - if (opt->arg) /* XXX program error */ - len = maxArgWidth(opt->arg, translation_domain); - if (len > max) max = len; - } else if (!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) { - len = sizeof(" ")-1; - if (opt->shortName != '\0') len += sizeof("-X")-1; - if (opt->shortName != '\0' && opt->longName) len += sizeof(", ")-1; - if (opt->longName) { - len += ((opt->argInfo & POPT_ARGFLAG_ONEDASH) - ? sizeof("-")-1 : sizeof("--")-1); - len += strlen(opt->longName); - } - - s = getArgDescrip(opt, translation_domain); - if (s) - len += sizeof("=")-1 + strlen(s); - if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) len += sizeof("[]")-1; - if (len > max) max = len; - } - - opt++; - } - - return max; -} - -/** - * Display popt alias and exec help. - * @param fp output file handle - * @param items alias/exec array - * @param nitems no. of alias/exec entries - * @param left - * @param translation_domain translation domain - */ -static void itemHelp(FILE * fp, - /*@null@*/ poptItem items, int nitems, int left, - /*@null@*/ const char * translation_domain) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ -{ - poptItem item; - int i; - - if (items != NULL) - for (i = 0, item = items; i < nitems; i++, item++) { - const struct poptOption * opt; - opt = &item->option; - if ((opt->longName || opt->shortName) && - !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) - singleOptionHelp(fp, left, opt, translation_domain); - } -} - -/** - * Display help text for a table of options. - * @param con context - * @param fp output file handle - * @param table option(s) - * @param left - * @param translation_domain translation domain - */ -static void singleTableHelp(poptContext con, FILE * fp, - /*@null@*/ const struct poptOption * table, int left, - /*@null@*/ const char * translation_domain) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ -{ - const struct poptOption * opt; - const char *sub_transdom; - - if (table == poptAliasOptions) { - itemHelp(fp, con->aliases, con->numAliases, left, NULL); - itemHelp(fp, con->execs, con->numExecs, left, NULL); - return; - } - - if (table != NULL) - for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) { - if ((opt->longName || opt->shortName) && - !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) - singleOptionHelp(fp, left, opt, translation_domain); - } - - if (table != NULL) - for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) { - if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_INCLUDE_TABLE) - continue; - sub_transdom = getTableTranslationDomain(opt->arg); - if (sub_transdom == NULL) - sub_transdom = translation_domain; - - if (opt->descrip) - fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip)); - - singleTableHelp(con, fp, opt->arg, left, sub_transdom); - } -} - -/** - * @param con context - * @param fp output file handle - */ -static int showHelpIntro(poptContext con, FILE * fp) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ -{ - int len = 6; - const char * fn; - - fprintf(fp, POPT_("Usage:")); - if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) { -/*@-boundsread@*/ - /*@-nullderef@*/ /* LCL: wazzup? */ - fn = con->optionStack->argv[0]; - /*@=nullderef@*/ -/*@=boundsread@*/ - if (fn == NULL) return len; - if (strchr(fn, '/')) fn = strrchr(fn, '/') + 1; - fprintf(fp, " %s", fn); - len += strlen(fn) + 1; - } - - return len; -} - -void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags) -{ - int leftColWidth; - - (void) showHelpIntro(con, fp); - if (con->otherHelp) - fprintf(fp, " %s\n", con->otherHelp); - else - fprintf(fp, " %s\n", POPT_("[OPTION...]")); - - leftColWidth = maxArgWidth(con->options, NULL); - singleTableHelp(con, fp, con->options, leftColWidth, NULL); -} - -/** - * @param fp output file handle - * @param cursor - * @param opt option(s) - * @param translation_domain translation domain - */ -static int singleOptionUsage(FILE * fp, int cursor, - const struct poptOption * opt, - /*@null@*/ const char *translation_domain) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ -{ - int len = 4; - char shortStr[2] = { '\0', '\0' }; - const char * item = shortStr; - const char * argDescrip = getArgDescrip(opt, translation_domain); - - if (opt->shortName != '\0' && opt->longName != NULL) { - len += 2; - if (!(opt->argInfo & POPT_ARGFLAG_ONEDASH)) len++; - len += strlen(opt->longName); - } else if (opt->shortName != '\0') { - len++; - shortStr[0] = opt->shortName; - shortStr[1] = '\0'; - } else if (opt->longName) { - len += strlen(opt->longName); - if (!(opt->argInfo & POPT_ARGFLAG_ONEDASH)) len++; - item = opt->longName; - } - - if (len == 4) return cursor; - - if (argDescrip) - len += strlen(argDescrip) + 1; - - if ((cursor + len) > 79) { - fprintf(fp, "\n "); - cursor = 7; - } - - if (opt->longName && opt->shortName) { - fprintf(fp, " [-%c|-%s%s%s%s]", - opt->shortName, ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "" : "-"), - opt->longName, - (argDescrip ? " " : ""), - (argDescrip ? argDescrip : "")); - } else { - fprintf(fp, " [-%s%s%s%s]", - ((opt->shortName || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) ? "" : "-"), - item, - (argDescrip ? (opt->shortName != '\0' ? " " : "=") : ""), - (argDescrip ? argDescrip : "")); - } - - return cursor + len + 1; -} - -/** - * Display popt alias and exec usage. - * @param fp output file handle - * @param cursor - * @param item alias/exec array - * @param nitems no. of ara/exec entries - * @param translation_domain translation domain - */ -static int itemUsage(FILE * fp, int cursor, poptItem item, int nitems, - /*@null@*/ const char * translation_domain) - /*@globals fileSystem @*/ - /*@modifies *fp, fileSystem @*/ -{ - int i; - - /*@-branchstate@*/ /* FIX: W2DO? */ - if (item != NULL) - for (i = 0; i < nitems; i++, item++) { - const struct poptOption * opt; - opt = &item->option; - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) { - translation_domain = (const char *)opt->arg; - } else if ((opt->longName || opt->shortName) && - !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) { - cursor = singleOptionUsage(fp, cursor, opt, translation_domain); - } - } - /*@=branchstate@*/ - - return cursor; -} - -/** - * Keep track of option tables already processed. - */ -typedef struct poptDone_s { - int nopts; - int maxopts; - const void ** opts; -} * poptDone; - -/** - * Display usage text for a table of options. - * @param con context - * @param fp output file handle - * @param cursor - * @param opt option(s) - * @param translation_domain translation domain - * @param done tables already processed - * @return - */ -static int singleTableUsage(poptContext con, FILE * fp, int cursor, - /*@null@*/ const struct poptOption * opt, - /*@null@*/ const char * translation_domain, - /*@null@*/ poptDone done) - /*@globals fileSystem @*/ - /*@modifies *fp, done, fileSystem @*/ -{ - /*@-branchstate@*/ /* FIX: W2DO? */ - if (opt != NULL) - for (; (opt->longName || opt->shortName || opt->arg) ; opt++) { - if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) { - translation_domain = (const char *)opt->arg; - } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { - if (done) { - int i = 0; - for (i = 0; i < done->nopts; i++) { -/*@-boundsread@*/ - const void * that = done->opts[i]; -/*@=boundsread@*/ - if (that == NULL || that != opt->arg) - /*@innercontinue@*/ continue; - /*@innerbreak@*/ break; - } - /* Skip if this table has already been processed. */ - if (opt->arg == NULL || i < done->nopts) - continue; -/*@-boundswrite@*/ - if (done->nopts < done->maxopts) - done->opts[done->nopts++] = (const void *) opt->arg; -/*@=boundswrite@*/ - } - cursor = singleTableUsage(con, fp, cursor, opt->arg, - translation_domain, done); - } else if ((opt->longName || opt->shortName) && - !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) { - cursor = singleOptionUsage(fp, cursor, opt, translation_domain); - } - } - /*@=branchstate@*/ - - return cursor; -} - -/** - * Return concatenated short options for display. - * @todo Sub-tables should be recursed. - * @param opt option(s) - * @param fp output file handle - * @retval str concatenation of short options - * @return length of display string - */ -static int showShortOptions(const struct poptOption * opt, FILE * fp, - /*@null@*/ char * str) - /*@globals fileSystem @*/ - /*@modifies *str, *fp, fileSystem @*/ -{ - char * s = alloca(300); /* larger than the ascii set */ - - s[0] = '\0'; - /*@-branchstate@*/ /* FIX: W2DO? */ - if (str == NULL) { - memset(s, 0, sizeof(s)); - str = s; - } - /*@=branchstate@*/ - -/*@-boundswrite@*/ - if (opt != NULL) - for (; (opt->longName || opt->shortName || opt->arg); opt++) { - if (opt->shortName && !(opt->argInfo & POPT_ARG_MASK)) - str[strlen(str)] = opt->shortName; - else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) - if (opt->arg) /* XXX program error */ - (void) showShortOptions(opt->arg, fp, str); - } -/*@=boundswrite@*/ - - if (s != str || *s != '\0') - return 0; - - fprintf(fp, " [-%s]", s); - return strlen(s) + 4; -} - -void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags) -{ - poptDone done = memset(alloca(sizeof(*done)), 0, sizeof(*done)); - int cursor; - - done->nopts = 0; - done->maxopts = 64; - cursor = done->maxopts * sizeof(*done->opts); -/*@-boundswrite@*/ - done->opts = memset(alloca(cursor), 0, cursor); - done->opts[done->nopts++] = (const void *) con->options; -/*@=boundswrite@*/ - - cursor = showHelpIntro(con, fp); - cursor += showShortOptions(con->options, fp, NULL); - cursor = singleTableUsage(con, fp, cursor, con->options, NULL, done); - cursor = itemUsage(fp, cursor, con->aliases, con->numAliases, NULL); - cursor = itemUsage(fp, cursor, con->execs, con->numExecs, NULL); - - if (con->otherHelp) { - cursor += strlen(con->otherHelp) + 1; - if (cursor > 79) fprintf(fp, "\n "); - fprintf(fp, " %s", con->otherHelp); - } - - fprintf(fp, "\n"); -} - -void poptSetOtherOptionHelp(poptContext con, const char * text) -{ - con->otherHelp = _free(con->otherHelp); - con->otherHelp = xstrdup(text); -} -/*@=type@*/ diff --git a/source4/lib/popt/poptint.h b/source4/lib/popt/poptint.h deleted file mode 100644 index 5d308efe96..0000000000 --- a/source4/lib/popt/poptint.h +++ /dev/null @@ -1,116 +0,0 @@ -/** \ingroup popt - * \file popt/poptint.h - */ - -/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#ifndef H_POPTINT -#define H_POPTINT - -/** - * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. - * @param p memory to free - * @retval NULL always - */ -/*@unused@*/ static inline /*@null@*/ void * -_free(/*@only@*/ /*@null@*/ const void * p) - /*@modifies p @*/ -{ - if (p != NULL) free((void *)p); - return NULL; -} - -/* Bit mask macros. */ -/*@-exporttype -redef @*/ -typedef unsigned int __pbm_bits; -/*@=exporttype =redef @*/ -#define __PBM_NBITS (8 * sizeof (__pbm_bits)) -#define __PBM_IX(d) ((d) / __PBM_NBITS) -#define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS)) -/*@-exporttype -redef @*/ -typedef struct { - __pbm_bits bits[1]; -} pbm_set; -/*@=exporttype =redef @*/ -#define __PBM_BITS(set) ((set)->bits) - -#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits)) -#define PBM_FREE(s) _free(s); -#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d)) -#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d)) -#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0) - -struct optionStackEntry { - int argc; -/*@only@*/ /*@null@*/ - const char ** argv; -/*@only@*/ /*@null@*/ - pbm_set * argb; - int next; -/*@only@*/ /*@null@*/ - const char * nextArg; -/*@observer@*/ /*@null@*/ - const char * nextCharArg; -/*@dependent@*/ /*@null@*/ - poptItem currAlias; - int stuffed; -}; - -struct poptContext_s { - struct optionStackEntry optionStack[POPT_OPTION_DEPTH]; -/*@dependent@*/ - struct optionStackEntry * os; -/*@owned@*/ /*@null@*/ - const char ** leftovers; - int numLeftovers; - int nextLeftover; -/*@keep@*/ - const struct poptOption * options; - int restLeftover; -/*@only@*/ /*@null@*/ - const char * appName; -/*@only@*/ /*@null@*/ - poptItem aliases; - int numAliases; - int flags; -/*@owned@*/ /*@null@*/ - poptItem execs; - int numExecs; -/*@only@*/ /*@null@*/ - const char ** finalArgv; - int finalArgvCount; - int finalArgvAlloced; -/*@dependent@*/ /*@null@*/ - poptItem doExec; -/*@only@*/ - const char * execPath; - int execAbsolute; -/*@only@*/ - const char * otherHelp; -/*@null@*/ - pbm_set * arg_strip; -}; - -#ifdef HAVE_LIBINTL_H -#include -#endif - -#if defined(HAVE_GETTEXT) && !defined(__LCLINT__) -#define _(foo) gettext(foo) -#else -#define _(foo) foo -#endif - -#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__) -#define D_(dom, str) dgettext(dom, str) -#define POPT_(foo) D_("popt", foo) -#else -#define D_(dom, str) str -#define POPT_(foo) foo -#endif - -#define N_(foo) foo - -#endif diff --git a/source4/lib/popt/poptparse.c b/source4/lib/popt/poptparse.c deleted file mode 100644 index a0dea80041..0000000000 --- a/source4/lib/popt/poptparse.c +++ /dev/null @@ -1,227 +0,0 @@ -/** \ingroup popt - * \file popt/poptparse.c - */ - -/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING - file accompanying popt source distributions, available from - ftp://ftp.rpm.org/pub/rpm/dist. */ - -#include "system.h" - -#define POPT_ARGV_ARRAY_GROW_DELTA 5 - -/*@-boundswrite@*/ -int poptDupArgv(int argc, const char **argv, - int * argcPtr, const char *** argvPtr) -{ - size_t nb = (argc + 1) * sizeof(*argv); - const char ** argv2; - char * dst; - int i; - - if (argc <= 0 || argv == NULL) /* XXX can't happen */ - return POPT_ERROR_NOARG; - for (i = 0; i < argc; i++) { - if (argv[i] == NULL) - return POPT_ERROR_NOARG; - nb += strlen(argv[i]) + 1; - } - - dst = malloc(nb); - if (dst == NULL) /* XXX can't happen */ - return POPT_ERROR_MALLOC; - argv2 = (void *) dst; - dst += (argc + 1) * sizeof(*argv); - - /*@-branchstate@*/ - for (i = 0; i < argc; i++) { - argv2[i] = dst; - dst += strlen(strcpy(dst, argv[i])) + 1; - } - /*@=branchstate@*/ - argv2[argc] = NULL; - - if (argvPtr) { - *argvPtr = argv2; - } else { - free(argv2); - argv2 = NULL; - } - if (argcPtr) - *argcPtr = argc; - return 0; -} -/*@=boundswrite@*/ - -/*@-bounds@*/ -int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr) -{ - const char * src; - char quote = '\0'; - int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA; - const char ** argv = malloc(sizeof(*argv) * argvAlloced); - int argc = 0; - int buflen = strlen(s) + 1; - char * buf = memset(alloca(buflen), 0, buflen); - int rc = POPT_ERROR_MALLOC; - - if (argv == NULL) return rc; - argv[argc] = buf; - - for (src = s; *src != '\0'; src++) { - if (quote == *src) { - quote = '\0'; - } else if (quote != '\0') { - if (*src == '\\') { - src++; - if (!*src) { - rc = POPT_ERROR_BADQUOTE; - goto exit; - } - if (*src != quote) *buf++ = '\\'; - } - *buf++ = *src; - } else if (isspace(*src)) { - if (*argv[argc] != '\0') { - buf++, argc++; - if (argc == argvAlloced) { - argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA; - argv = realloc(argv, sizeof(*argv) * argvAlloced); - if (argv == NULL) goto exit; - } - argv[argc] = buf; - } - } else switch (*src) { - case '"': - case '\'': - quote = *src; - /*@switchbreak@*/ break; - case '\\': - src++; - if (!*src) { - rc = POPT_ERROR_BADQUOTE; - goto exit; - } - /*@fallthrough@*/ - default: - *buf++ = *src; - /*@switchbreak@*/ break; - } - } - - if (strlen(argv[argc])) { - argc++, buf++; - } - - rc = poptDupArgv(argc, argv, argcPtr, argvPtr); - -exit: - if (argv) free(argv); - return rc; -} -/*@=bounds@*/ - -/* still in the dev stage. - * return values, perhaps 1== file erro - * 2== line to long - * 3== umm.... more? - */ -int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags) -{ - char line[999]; - char * argstr; - char * p; - char * q; - char * x; - int t; - int argvlen = 0; - size_t maxlinelen = sizeof(line); - size_t linelen; - int maxargvlen = 480; - int linenum = 0; - - *argstrp = NULL; - - /* | this_is = our_line - * p q x - */ - - if (fp == NULL) - return POPT_ERROR_NULLARG; - - argstr = calloc(maxargvlen, sizeof(*argstr)); - if (argstr == NULL) return POPT_ERROR_MALLOC; - - while (fgets(line, (int)maxlinelen, fp) != NULL) { - linenum++; - p = line; - - /* loop until first non-space char or EOL */ - while( *p != '\0' && isspace(*p) ) - p++; - - linelen = strlen(p); - if (linelen >= maxlinelen-1) - return POPT_ERROR_OVERFLOW; /* XXX line too long */ - - if (*p == '\0' || *p == '\n') continue; /* line is empty */ - if (*p == '#') continue; /* comment line */ - - q = p; - - while (*q != '\0' && (!isspace(*q)) && *q != '=') - q++; - - if (isspace(*q)) { - /* a space after the name, find next non space */ - *q++='\0'; - while( *q != '\0' && isspace((int)*q) ) q++; - } - if (*q == '\0') { - /* single command line option (ie, no name=val, just name) */ - q[-1] = '\0'; /* kill off newline from fgets() call */ - argvlen += (t = q - p) + (sizeof(" --")-1); - if (argvlen >= maxargvlen) { - maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2; - argstr = realloc(argstr, maxargvlen); - if (argstr == NULL) return POPT_ERROR_MALLOC; - } - strcat(argstr, " --"); - strcat(argstr, p); - continue; - } - if (*q != '=') - continue; /* XXX for now, silently ignore bogus line */ - - /* *q is an equal sign. */ - *q++ = '\0'; - - /* find next non-space letter of value */ - while (*q != '\0' && isspace(*q)) - q++; - if (*q == '\0') - continue; /* XXX silently ignore missing value */ - - /* now, loop and strip all ending whitespace */ - x = p + linelen; - while (isspace(*--x)) - *x = 0; /* null out last char if space (including fgets() NL) */ - - /* rest of line accept */ - t = x - p; - argvlen += t + (sizeof("' --='")-1); - if (argvlen >= maxargvlen) { - maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2; - argstr = realloc(argstr, maxargvlen); - if (argstr == NULL) return POPT_ERROR_MALLOC; - } - strcat(argstr, " --"); - strcat(argstr, p); - strcat(argstr, "=\""); - strcat(argstr, q); - strcat(argstr, "\""); - } - - *argstrp = argstr; - return 0; -} diff --git a/source4/lib/popt/system.h b/source4/lib/popt/system.h deleted file mode 100644 index 000e23d484..0000000000 --- a/source4/lib/popt/system.h +++ /dev/null @@ -1,74 +0,0 @@ -#include "config.h" - -#if defined (__GLIBC__) && defined(__LCLINT__) -/*@-declundef@*/ -/*@unchecked@*/ -extern __const __int32_t *__ctype_tolower; -/*@unchecked@*/ -extern __const __int32_t *__ctype_toupper; -/*@=declundef@*/ -#endif - -#include - -#include -#include -#include - -#if HAVE_MCHECK_H -#include -#endif - -#include -#include -#include - -#if HAVE_UNISTD_H -#include -#endif - -#ifdef __NeXT -/* access macros are not declared in non posix mode in unistd.h - - don't try to use posix on NeXTstep 3.3 ! */ -#include -#endif - -#if defined(__LCLINT__) -/*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */ -/*@only@*/ void * alloca (size_t __size) - /*@ensures MaxSet(result) == (__size - 1) @*/ - /*@*/; -/*@=declundef =incondefs =redecl@*/ -#endif - -/* AIX requires this to be the first thing in the file. */ -#ifndef __GNUC__ -# if HAVE_ALLOCA_H -# include -# else -# ifdef _AIX -#pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -#elif defined(__GNUC__) && defined(__STRICT_ANSI__) -#define alloca __builtin_alloca -#endif - -/*@-redecl -redef@*/ -/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str) - /*@*/; -/*@=redecl =redef@*/ - -#if HAVE_MCHECK_H && defined(__GNUC__) -#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) -#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) -#else -#define xstrdup(_str) strdup(_str) -#endif /* HAVE_MCHECK_H && defined(__GNUC__) */ - - -#include "popt.h" diff --git a/source4/lib/registry/dir.c b/source4/lib/registry/dir.c index 449ee0f6ee..42946bceec 100644 --- a/source4/lib/registry/dir.c +++ b/source4/lib/registry/dir.c @@ -327,7 +327,7 @@ static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx, size_t size; char *contents; - contents = file_load(path, &size, mem_ctx); + contents = file_load(path, &size, 0, mem_ctx); talloc_free(path); if (contents == NULL) return WERR_BADFILE; diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c index c9b3b06447..81ca2c39bc 100644 --- a/source4/lib/registry/interface.c +++ b/source4/lib/registry/interface.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/registry/registry.h" #include "system/filesys.h" diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 87d066e2de..9c1f59c4df 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -225,7 +225,7 @@ static WERROR cache_subkeys(struct ldb_key_data *kd) struct ldb_result *res; int ret; - ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(key=*)", NULL, &res); + ret = ldb_search(c, c, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "(key=*)"); if (ret != LDB_SUCCESS) { DEBUG(0, ("Error getting subkeys for '%s': %s\n", @@ -246,8 +246,8 @@ static WERROR cache_values(struct ldb_key_data *kd) struct ldb_result *res; int ret; - ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, - "(value=*)", NULL, &res); + ret = ldb_search(c, c, &res, kd->dn, LDB_SCOPE_ONELEVEL, + NULL, "(value=*)"); if (ret != LDB_SUCCESS) { DEBUG(0, ("Error getting values for '%s': %s\n", @@ -373,7 +373,7 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k, } else { /* normal value */ query = talloc_asprintf(mem_ctx, "(value=%s)", name); - ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, query, NULL, &res); + ret = ldb_search(c, kd->dn, &res, LDB_SCOPE_ONELEVEL, query, NULL, "%s", query); talloc_free(query); if (ret != LDB_SUCCESS) { @@ -391,6 +391,7 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k, talloc_free(res); } + talloc_free(res); return WERR_OK; } @@ -406,7 +407,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h, ldap_path = reg_path_to_ldb(mem_ctx, h, name, NULL); - ret = ldb_search(c, ldap_path, LDB_SCOPE_BASE, "(key=*)", NULL, &res); + ret = ldb_search(c, mem_ctx, &res, ldap_path, LDB_SCOPE_BASE, NULL, "(key=*)"); if (ret != LDB_SUCCESS) { DEBUG(3, ("Error opening key '%s': %s\n", @@ -598,8 +599,8 @@ static WERROR ldb_del_key(const struct hive_key *key, const char *name) } /* Search for subkeys */ - ret = ldb_search(c, ldap_path, LDB_SCOPE_ONELEVEL, - "(key=*)", NULL, &res_keys); + ret = ldb_search(c, mem_ctx, &res_keys, ldap_path, LDB_SCOPE_ONELEVEL, + NULL, "(key=*)"); if (ret != LDB_SUCCESS) { DEBUG(0, ("Error getting subkeys for '%s': %s\n", @@ -609,8 +610,8 @@ static WERROR ldb_del_key(const struct hive_key *key, const char *name) } /* Search for values */ - ret = ldb_search(c, ldap_path, LDB_SCOPE_ONELEVEL, - "(value=*)", NULL, &res_vals); + ret = ldb_search(c, mem_ctx, &res_vals, ldap_path, LDB_SCOPE_ONELEVEL, + NULL, "(value=*)"); if (ret != LDB_SUCCESS) { DEBUG(0, ("Error getting values for '%s': %s\n", diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c index 4af95e2dd6..a3aee06b13 100644 --- a/source4/lib/registry/local.c +++ b/source4/lib/registry/local.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/registry/registry.h" #include "system/filesys.h" diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c index 0ede3106f0..a6f947ee78 100644 --- a/source4/lib/registry/patchfile.c +++ b/source4/lib/registry/patchfile.c @@ -4,6 +4,7 @@ Copyright (C) Jelmer Vernooij 2004-2007 Copyright (C) Wilco Baan Hofman 2006 + Copyright (C) Matthias Dieter Wallnöfer 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 @@ -58,8 +59,9 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, &old_num_subkeys, &old_num_values, NULL, NULL, NULL, NULL); if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error occured while getting key info: %s\n", + DEBUG(0, ("Error occurred while getting key info: %s\n", win_errstr(error))); + talloc_free(mem_ctx); return error; } } else { @@ -67,37 +69,46 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, old_num_values = 0; } - /* Subkeys that were deleted */ + /* Subkeys that were changed or deleted */ for (i = 0; i < old_num_subkeys; i++) { error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i, - &keyname1, - NULL, NULL); + &keyname1, NULL, NULL); if (!W_ERROR_IS_OK(error1)) { - DEBUG(0, ("Error occured while getting subkey by index: %s\n", - win_errstr(error2))); + DEBUG(0, ("Error occurred while getting subkey by index: %s\n", + win_errstr(error1))); continue; } if (newkey != NULL) { error2 = reg_open_key(mem_ctx, newkey, keyname1, &t2); - - if (W_ERROR_IS_OK(error2)) - continue; } else { error2 = WERR_BADFILE; t2 = NULL; } - if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) { + if (!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_BADFILE)) { DEBUG(0, ("Error occured while getting subkey by name: %s\n", win_errstr(error2))); talloc_free(mem_ctx); return error2; } - /* newkey didn't have such a subkey, add del diff */ + /* if "error2" is going to be "WERR_BADFILE", then newkey */ + /* didn't have such a subkey and therefore add a del diff */ tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1); - callbacks->del_key(callback_data, tmppath); + if (!W_ERROR_IS_OK(error2)) + callbacks->del_key(callback_data, tmppath); + + /* perform here also the recursive invocation */ + error1 = reg_open_key(mem_ctx, oldkey, keyname1, &t1); + if (!W_ERROR_IS_OK(error1)) { + DEBUG(0, ("Error occured while getting subkey by name: %s\n", + win_errstr(error1))); + talloc_free(mem_ctx); + return error1; + } + reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data); + talloc_free(tmppath); } @@ -106,8 +117,9 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, &new_num_subkeys, &new_num_values, NULL, NULL, NULL, NULL); if (!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Error occured while getting key info: %s\n", + DEBUG(0, ("Error occurred while getting key info: %s\n", win_errstr(error))); + talloc_free(mem_ctx); return error; } } else { @@ -117,11 +129,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, /* Subkeys that were added */ for(i = 0; i < new_num_subkeys; i++) { - error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, - i, &keyname1, - NULL, NULL); + error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i, + &keyname1, NULL, NULL); if (!W_ERROR_IS_OK(error1)) { - DEBUG(0, ("Error occured while getting subkey by index: %s\n", + DEBUG(0, ("Error occurred while getting subkey by index: %s\n", win_errstr(error1))); talloc_free(mem_ctx); return error1; @@ -133,12 +144,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, if (W_ERROR_IS_OK(error2)) continue; } else { + error2 = WERR_BADFILE; t1 = NULL; - error2 = WERR_BADFILE; } if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) { - DEBUG(0, ("Error occured while getting subkey by name: %s\n", + DEBUG(0, ("Error occurred while getting subkey by name: %s\n", win_errstr(error2))); talloc_free(mem_ctx); return error2; @@ -148,15 +159,20 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1); callbacks->add_key(callback_data, tmppath); - W_ERROR_NOT_OK_RETURN( - reg_open_key(mem_ctx, newkey, keyname1, &t2)); + /* perform here also the recursive invocation */ + error1 = reg_open_key(mem_ctx, newkey, keyname1, &t2); + if (!W_ERROR_IS_OK(error1)) { + DEBUG(0, ("Error occured while getting subkey by name: %s\n", + win_errstr(error1))); + talloc_free(mem_ctx); + return error1; + } + reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data); - reg_generate_diff_key(t1, t2, tmppath, - callbacks, callback_data); talloc_free(tmppath); } - /* Values that were changed */ + /* Values that were added or changed */ for(i = 0; i < new_num_values; i++) { const char *name; uint32_t type1, type2; @@ -165,7 +181,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, &name, &type1, &contents1); if (!W_ERROR_IS_OK(error1)) { - DEBUG(0, ("Unable to get key by index: %s\n", + DEBUG(0, ("Unable to get value by index: %s\n", win_errstr(error1))); talloc_free(mem_ctx); return error1; @@ -178,16 +194,17 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, } else error2 = WERR_BADFILE; - if(!W_ERROR_IS_OK(error2) && - !W_ERROR_EQUAL(error2, WERR_BADFILE)) { - DEBUG(0, ("Error occured while getting value by name: %s\n", + if (!W_ERROR_IS_OK(error2) + && !W_ERROR_EQUAL(error2, WERR_BADFILE)) { + DEBUG(0, ("Error occurred while getting value by name: %s\n", win_errstr(error2))); talloc_free(mem_ctx); return error2; } - if (W_ERROR_IS_OK(error2) && - data_blob_cmp(&contents1, &contents2) == 0) + if (W_ERROR_IS_OK(error2) + && (data_blob_cmp(&contents1, &contents2) == 0) + && (type1 == type2)) continue; callbacks->set_value(callback_data, path, name, @@ -197,24 +214,31 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey, /* Values that were deleted */ for (i = 0; i < old_num_values; i++) { const char *name; + uint32_t type; + DATA_BLOB contents; + error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name, - NULL, NULL); + &type, &contents); if (!W_ERROR_IS_OK(error1)) { - DEBUG(0, ("Error ocurred getting value by index: %s\n", + DEBUG(0, ("Unable to get value by index: %s\n", win_errstr(error1))); talloc_free(mem_ctx); return error1; } - error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL, - NULL); + if (newkey != NULL) + error2 = reg_key_get_value_by_name(mem_ctx, newkey, + name, &type, &contents); + else + error2 = WERR_BADFILE; if (W_ERROR_IS_OK(error2)) continue; if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) { - DEBUG(0, ("Error occured while getting value by name: %s\n", + DEBUG(0, ("Error occurred while getting value by name: %s\n", win_errstr(error2))); + talloc_free(mem_ctx); return error2; } @@ -236,27 +260,30 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1, int i; WERROR error; - for(i = HKEY_FIRST; i <= HKEY_LAST; i++) { + for (i = 0; reg_predefined_keys[i].name; i++) { struct registry_key *r1 = NULL, *r2 = NULL; - error = reg_get_predefined_key(ctx1, i, &r1); + + error = reg_get_predefined_key(ctx1, + reg_predefined_keys[i].handle, &r1); if (!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_BADFILE)) { DEBUG(0, ("Unable to open hive %s for backend 1\n", - reg_get_predef_name(i))); + reg_predefined_keys[i].name)); + continue; } - error = reg_get_predefined_key(ctx2, i, &r2); + error = reg_get_predefined_key(ctx2, + reg_predefined_keys[i].handle, &r2); if (!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_BADFILE)) { DEBUG(0, ("Unable to open hive %s for backend 2\n", - reg_get_predef_name(i))); - } - - if (r1 == NULL && r2 == NULL) + reg_predefined_keys[i].name)); continue; + } - error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i), - callbacks, callback_data); + error = reg_generate_diff_key(r1, r2, + reg_predefined_keys[i].name, callbacks, + callback_data); if (!W_ERROR_IS_OK(error)) { DEBUG(0, ("Unable to determine diff: %s\n", win_errstr(error))); @@ -357,14 +384,13 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name) static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name) { struct registry_context *ctx = (struct registry_context *)_ctx; - WERROR error; - error = reg_key_del_abs(ctx, key_name); + /* We can't proof here for success, because a common superkey could */ + /* have been deleted before the subkey's (diff order). This removed */ + /* therefore all childs recursively and the "WERR_BADFILE" result is */ + /* expected. */ - if(!W_ERROR_IS_OK(error)) { - DEBUG(0, ("Unable to delete key '%s'\n", key_name)); - return error; - } + reg_key_del_abs(ctx, key_name); return WERR_OK; } @@ -426,8 +452,7 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name) struct registry_context *ctx = (struct registry_context *)_ctx; struct registry_key *key; WERROR error; - int i; - uint32_t num_values; + const char* value_name; error = reg_open_key_abs(ctx, ctx, key_name, &key); @@ -437,14 +462,15 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name) } W_ERROR_NOT_OK_RETURN(reg_key_get_info(ctx, key, NULL, - NULL, &num_values, NULL, NULL, NULL, NULL)); + NULL, NULL, NULL, NULL, NULL, NULL)); - for (i = 0; i < num_values; i++) { - const char *name; - W_ERROR_NOT_OK_RETURN(reg_key_get_value_by_index(ctx, key, i, - &name, - NULL, NULL)); - W_ERROR_NOT_OK_RETURN(reg_del_value(key, name)); + while (W_ERROR_IS_OK(reg_key_get_value_by_index( + ctx, key, 0, &value_name, NULL, NULL))) { + error = reg_del_value(key, value_name); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Error deleting value '%s'\n", value_name)); + return error; + } } return WERR_OK; diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c index 57a895aa00..dd3ff47b78 100644 --- a/source4/lib/registry/regf.c +++ b/source4/lib/registry/regf.c @@ -2066,7 +2066,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location, pull = tdr_pull_init(regf, regf->iconv_convenience); - pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, regf); + pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, 0, regf); if (pull->data.data == NULL) { DEBUG(0, ("Error reading data\n")); diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h index e134e3e532..e89d6fd55c 100644 --- a/source4/lib/registry/registry.h +++ b/source4/lib/registry/registry.h @@ -29,8 +29,8 @@ struct smb_iconv_convenience; #include "libcli/util/werror.h" #include "librpc/gen_ndr/security.h" #include "libcli/util/ntstatus.h" -#include "util/time.h" -#include "util/data_blob.h" +#include "../lib/util/time.h" +#include "../lib/util/data_blob.h" /** * The hive API. This API is generally used for @@ -508,6 +508,18 @@ WERROR reg_diff_load(const char *filename, const struct reg_diff_callbacks *callbacks, void *callback_data); +WERROR reg_dotreg_diff_load(int fd, + struct smb_iconv_convenience *iconv_convenience, + const struct reg_diff_callbacks *callbacks, + void *callback_data); + +WERROR reg_preg_diff_load(int fd, + struct smb_iconv_convenience *iconv_convenience, + const struct reg_diff_callbacks *callbacks, + void *callback_data); + +WERROR local_get_predefined_key(struct registry_context *ctx, + uint32_t key_id, struct registry_key **key); #endif /* _REGISTRY_H */ diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i index c55197c3d0..fe3a81d889 100644 --- a/source4/lib/registry/registry.i +++ b/source4/lib/registry/registry.i @@ -43,7 +43,7 @@ typedef struct hive_key hive_key; } %import "stdint.i" -%import "../../lib/talloc/talloc.i" +%import "../../../lib/talloc/talloc.i" %import "../../auth/credentials/credentials.i" %import "../../param/param.i" %import "../events/events.i" diff --git a/source4/lib/registry/rpc.c b/source4/lib/registry/rpc.c index 18b7607713..3a16ae1db5 100644 --- a/source4/lib/registry/rpc.c +++ b/source4/lib/registry/rpc.c @@ -2,6 +2,7 @@ Samba Unix/Linux SMB implementation RPC backend for the registry library Copyright (C) 2003-2007 Jelmer Vernooij, jelmer@samba.org + Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer@yahoo.de 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 @@ -20,16 +21,23 @@ #include "registry.h" #include "librpc/gen_ndr/ndr_winreg_c.h" +#define MAX_NAMESIZE 512 +#define MAX_VALSIZE 32768 + struct rpc_key { struct registry_key key; struct policy_handle pol; struct dcerpc_pipe *pipe; - uint32_t num_values; + const char* classname; uint32_t num_subkeys; + uint32_t max_subkeylen; + uint32_t max_classlen; + uint32_t num_values; uint32_t max_valnamelen; - uint32_t max_valdatalen; - uint32_t max_subkeynamelen; + uint32_t max_valbufsize; + uint32_t secdescsize; + NTTIME last_changed_time; }; struct rpc_registry_context { @@ -43,26 +51,22 @@ static struct registry_operations reg_backend_rpc; * This is the RPC backend for the registry library. */ -static void init_winreg_String(struct winreg_String *name, const char *s) -{ - name->name = s; -} - - #define openhive(u) static WERROR open_ ## u(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *hnd) \ { \ struct winreg_Open ## u r; \ NTSTATUS status; \ - \ +\ + ZERO_STRUCT(r); \ r.in.system_name = NULL; \ r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; \ r.out.handle = hnd;\ - \ +\ status = dcerpc_winreg_Open ## u(p, mem_ctx, &r); \ - if (NT_STATUS_IS_ERR(status)) {\ - DEBUG(0,("Error executing open\n"));\ - return ntstatus_to_werror(status);\ - }\ +\ + if (!NT_STATUS_IS_OK(status)) { \ + DEBUG(1, ("OpenHive failed - %s\n", nt_errstr(status))); \ + return ntstatus_to_werror(status); \ + } \ \ return r.out.result;\ } @@ -90,7 +94,7 @@ static struct { { 0, NULL } }; -static WERROR rpc_query_key(const struct registry_key *k); +static WERROR rpc_query_key(TALLOC_CTX *mem_ctx, const struct registry_key *k); static WERROR rpc_get_predefined_key(struct registry_context *ctx, uint32_t hkey_type, @@ -127,15 +131,15 @@ static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k) struct winreg_OpenKey r; struct rpc_key_data *mykeydata; - k->backend_data = mykeydata = talloc(mem_ctx, struct rpc_key_data); + k->backend_data = mykeydata = talloc_zero(mem_ctx, struct rpc_key_data); mykeydata->num_values = -1; mykeydata->num_subkeys = -1; /* Then, open the handle using the hive */ - memset(&r, 0, sizeof(struct winreg_OpenKey)); + ZERO_STRUCT(r); r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol); - init_winreg_String(&r.in.keyname, k->path); + r.in.keyname.name = k->path; r.in.unknown = 0x00000000; r.in.access_mask = 0x02000000; r.out.handle = &mykeydata->pol; @@ -155,8 +159,7 @@ static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h, struct winreg_OpenKey r; NTSTATUS status; - mykeydata = talloc(mem_ctx, struct rpc_key); - + mykeydata = talloc_zero(mem_ctx, struct rpc_key); mykeydata->key.context = parentkeydata->key.context; mykeydata->pipe = talloc_reference(mykeydata, parentkeydata->pipe); mykeydata->num_values = -1; @@ -166,14 +169,15 @@ static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h, /* Then, open the handle using the hive */ ZERO_STRUCT(r); r.in.parent_handle = &parentkeydata->pol; - init_winreg_String(&r.in.keyname, name); + r.in.keyname.name = name; r.in.unknown = 0x00000000; r.in.access_mask = 0x02000000; r.out.handle = &mykeydata->pol; status = dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r); - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0,("Error executing openkey: %s\n", nt_errstr(status))); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("OpenKey failed - %s\n", nt_errstr(status))); return ntstatus_to_werror(status); } @@ -188,47 +192,94 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx, DATA_BLOB *data) { struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key); - WERROR error; struct winreg_EnumValue r; - uint32_t in_type = 0; - NTSTATUS status; struct winreg_StringBuf name; + uint8_t value; + uint32_t val_size = MAX_VALSIZE; uint32_t zero = 0; - - ZERO_STRUCT(r); + WERROR error; + NTSTATUS status; if (mykeydata->num_values == -1) { - error = rpc_query_key(parent); + error = rpc_query_key(mem_ctx, parent); if(!W_ERROR_IS_OK(error)) return error; } - name.length = 0; - name.size = mykeydata->max_valnamelen * 2; - name.name = NULL; + name.name = ""; + name.size = MAX_NAMESIZE; + ZERO_STRUCT(r); r.in.handle = &mykeydata->pol; r.in.enum_index = n; r.in.name = &name; - r.in.type = &in_type; - r.in.value = talloc_zero_array(mem_ctx, uint8_t, 0); + r.in.type = type; + r.in.value = &value; + r.in.size = &val_size; r.in.length = &zero; - r.in.size = &mykeydata->max_valdatalen; r.out.name = &name; r.out.type = type; + r.out.value = &value; + r.out.size = &val_size; + r.out.length = &zero; status = dcerpc_winreg_EnumValue(mykeydata->pipe, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Error in EnumValue: %s\n", nt_errstr(status))); - return WERR_GENERAL_FAILURE; + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("EnumValue failed - %s\n", nt_errstr(status))); + return ntstatus_to_werror(status); } - if(NT_STATUS_IS_OK(status) && - W_ERROR_IS_OK(r.out.result) && r.out.length) { - *value_name = talloc_strdup(mem_ctx, r.out.name->name); - *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length); - return WERR_OK; + *value_name = talloc_reference(mem_ctx, r.out.name->name); + *type = *(r.out.type); + *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length); + + return r.out.result; +} + +static WERROR rpc_get_value_by_name(TALLOC_CTX *mem_ctx, + const struct registry_key *parent, + const char *value_name, + uint32_t *type, + DATA_BLOB *data) +{ + struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key); + struct winreg_QueryValue r; + struct winreg_String name; + uint8_t value; + uint32_t val_size = MAX_VALSIZE; + uint32_t zero = 0; + WERROR error; + NTSTATUS status; + + if (mykeydata->num_values == -1) { + error = rpc_query_key(mem_ctx, parent); + if(!W_ERROR_IS_OK(error)) return error; } + name.name = value_name; + + ZERO_STRUCT(r); + r.in.handle = &mykeydata->pol; + r.in.value_name = &name; + r.in.type = type; + r.in.data = &value; + r.in.data_size = &val_size; + r.in.data_length = &zero; + r.out.type = type; + r.out.data = &value; + r.out.data_size = &val_size; + r.out.data_length = &zero; + + status = dcerpc_winreg_QueryValue(mykeydata->pipe, mem_ctx, &r); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("QueryValue failed - %s\n", nt_errstr(status))); + return ntstatus_to_werror(status); + } + + *type = *(r.out.type); + *data = data_blob_talloc(mem_ctx, r.out.data, *r.out.data_length); + return r.out.result; } @@ -241,34 +292,39 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx, { struct winreg_EnumKey r; struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key); - NTSTATUS status; struct winreg_StringBuf namebuf, classbuf; NTTIME change_time = 0; + NTSTATUS status; - ZERO_STRUCT(r); - - namebuf.length = 0; - namebuf.size = 1024; - namebuf.name = NULL; - classbuf.length = 0; - classbuf.size = 0; - classbuf.name = NULL; + namebuf.name = ""; + namebuf.size = MAX_NAMESIZE; + classbuf.name = NULL; + classbuf.size = 0; + ZERO_STRUCT(r); r.in.handle = &mykeydata->pol; r.in.enum_index = n; r.in.name = &namebuf; r.in.keyclass = &classbuf; r.in.last_changed_time = &change_time; - r.out.name = &namebuf; + r.out.keyclass = &classbuf; + r.out.last_changed_time = &change_time; status = dcerpc_winreg_EnumKey(mykeydata->pipe, mem_ctx, &r); - if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) { - *name = talloc_strdup(mem_ctx, r.out.name->name); - if (keyclass != NULL) - *keyclass = talloc_strdup(mem_ctx, r.out.keyclass->name); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("EnumKey failed - %s\n", nt_errstr(status))); + return ntstatus_to_werror(status); } + if (name != NULL) + *name = talloc_reference(mem_ctx, r.out.name->name); + if (keyclass != NULL) + *keyclass = talloc_reference(mem_ctx, r.out.keyclass->name); + if (last_changed_time != NULL) + *last_changed_time = *(r.out.last_changed_time); + return r.out.result; } @@ -278,19 +334,22 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx, struct security_descriptor *sec, struct registry_key **key) { - NTSTATUS status; struct winreg_CreateKey r; struct rpc_key *parentkd = talloc_get_type(parent, struct rpc_key); struct rpc_key *rpck = talloc(mem_ctx, struct rpc_key); + + NTSTATUS status; - init_winreg_String(&r.in.name, name); - init_winreg_String(&r.in.keyclass, NULL); - + ZERO_STRUCT(r); r.in.handle = &parentkd->pol; - r.out.new_handle = &rpck->pol; + r.in.name.name = name; + r.in.keyclass.name = NULL; r.in.options = 0; - r.in.access_mask = SEC_STD_ALL; + r.in.access_mask = 0x02000000; r.in.secdesc = NULL; + r.in.action_taken = NULL; + r.out.new_handle = &rpck->pol; + r.out.action_taken = NULL; status = dcerpc_winreg_CreateKey(parentkd->pipe, mem_ctx, &r); @@ -300,49 +359,42 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx, return ntstatus_to_werror(status); } - if (W_ERROR_IS_OK(r.out.result)) { - rpck->pipe = talloc_reference(rpck, parentkd->pipe); - *key = (struct registry_key *)rpck; - } + rpck->pipe = talloc_reference(rpck, parentkd->pipe); + *key = (struct registry_key *)rpck; return r.out.result; } -static WERROR rpc_query_key(const struct registry_key *k) +static WERROR rpc_query_key(TALLOC_CTX *mem_ctx, const struct registry_key *k) { - NTSTATUS status; struct winreg_QueryInfoKey r; struct rpc_key *mykeydata = talloc_get_type(k, struct rpc_key); - TALLOC_CTX *mem_ctx = talloc_init("query_key"); - uint32_t max_subkeysize; - uint32_t secdescsize; - NTTIME last_changed_time; + struct winreg_String classname; + NTSTATUS status; - ZERO_STRUCT(r.out); + classname.name = NULL; + ZERO_STRUCT(r); + r.in.handle = &mykeydata->pol; + r.in.classname = &classname; + r.out.classname = &classname; r.out.num_subkeys = &mykeydata->num_subkeys; - r.out.max_subkeylen = &mykeydata->max_subkeynamelen; - r.out.max_valnamelen = &mykeydata->max_valnamelen; - r.out.max_valbufsize = &mykeydata->max_valdatalen; - r.out.max_subkeysize = &max_subkeysize; + r.out.max_subkeylen = &mykeydata->max_subkeylen; + r.out.max_classlen = &mykeydata->max_classlen; r.out.num_values = &mykeydata->num_values; - r.out.secdescsize = &secdescsize; - r.out.last_changed_time = &last_changed_time; - - r.out.classname = r.in.classname = talloc_zero(mem_ctx, struct winreg_String); - init_winreg_String(r.in.classname, NULL); - r.in.handle = &mykeydata->pol; + r.out.max_valnamelen = &mykeydata->max_valnamelen; + r.out.max_valbufsize = &mykeydata->max_valbufsize; + r.out.secdescsize = &mykeydata->secdescsize; + r.out.last_changed_time = &mykeydata->last_changed_time; status = dcerpc_winreg_QueryInfoKey(mykeydata->pipe, mem_ctx, &r); - talloc_free(mem_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("QueryInfoKey failed - %s\n", nt_errstr(status))); return ntstatus_to_werror(status); } - if (W_ERROR_IS_OK(r.out.result)) { - } + mykeydata->classname = talloc_reference(mem_ctx, r.out.classname->name); return r.out.result; } @@ -354,22 +406,28 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name) struct winreg_DeleteKey r; TALLOC_CTX *mem_ctx = talloc_init("del_key"); + ZERO_STRUCT(r); r.in.handle = &mykeydata->pol; - init_winreg_String(&r.in.key, name); + r.in.key.name = name; status = dcerpc_winreg_DeleteKey(mykeydata->pipe, mem_ctx, &r); talloc_free(mem_ctx); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("DeleteKey failed - %s\n", nt_errstr(status))); + return ntstatus_to_werror(status); + } + return r.out.result; } static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key, const char **classname, - uint32_t *numsubkeys, - uint32_t *numvalue, + uint32_t *num_subkeys, + uint32_t *num_values, NTTIME *last_changed_time, - uint32_t *max_subkeynamelen, + uint32_t *max_subkeylen, uint32_t *max_valnamelen, uint32_t *max_valbufsize) { @@ -377,27 +435,30 @@ static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key, WERROR error; if (mykeydata->num_values == -1) { - error = rpc_query_key(key); + error = rpc_query_key(mem_ctx, key); if(!W_ERROR_IS_OK(error)) return error; } - /* FIXME: *classname = talloc_strdup(mem_ctx, mykeydata->classname); */ - /* FIXME: *last_changed_time = mykeydata->last_changed_time */ + if (classname != NULL) + *classname = mykeydata->classname; + + if (num_subkeys != NULL) + *num_subkeys = mykeydata->num_subkeys; - if (numvalue != NULL) - *numvalue = mykeydata->num_values; + if (num_values != NULL) + *num_values = mykeydata->num_values; - if (numsubkeys != NULL) - *numsubkeys = mykeydata->num_subkeys; + if (last_changed_time != NULL) + *last_changed_time = mykeydata->last_changed_time; + + if (max_subkeylen != NULL) + *max_subkeylen = mykeydata->max_subkeylen; if (max_valnamelen != NULL) *max_valnamelen = mykeydata->max_valnamelen; if (max_valbufsize != NULL) - *max_valbufsize = mykeydata->max_valdatalen; - - if (max_subkeynamelen != NULL) - *max_subkeynamelen = mykeydata->max_subkeynamelen; + *max_valbufsize = mykeydata->max_valbufsize; return WERR_OK; } @@ -408,6 +469,7 @@ static struct registry_operations reg_backend_rpc = { .get_predefined_key = rpc_get_predefined_key, .enum_key = rpc_get_subkey_by_index, .enum_value = rpc_get_value_by_index, + .get_value = rpc_get_value_by_name, .create_key = rpc_add_key, .delete_key = rpc_del_key, .get_key_info = rpc_get_info, diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c index 6eae26bc46..2b7eb838ba 100644 --- a/source4/lib/registry/tests/generic.c +++ b/source4/lib/registry/tests/generic.c @@ -53,7 +53,7 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx) static bool test_reg_val_data_string_sz(struct torture_context *ctx) { DATA_BLOB db; - db.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16, + db.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "bla", 3, (void **)&db.data); torture_assert_str_equal(ctx, "bla", reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db), @@ -88,7 +88,7 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx) static bool test_reg_val_description(struct torture_context *ctx) { DATA_BLOB data; - data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16, + data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "stationary traveller", strlen("stationary traveller"), (void **)&data.data); @@ -102,7 +102,7 @@ static bool test_reg_val_description(struct torture_context *ctx) static bool test_reg_val_description_nullname(struct torture_context *ctx) { DATA_BLOB data; - data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UNIX, CH_UTF16, + data.length = convert_string_talloc(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16, "west berlin", strlen("west berlin"), (void **)&data.data); diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index 240c582340..fcf7c26237 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -46,7 +46,7 @@ static struct registry_context *open_backend(poptContext pc, break; case REG_REMOTE: error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx, - remote_host, NULL); + remote_host, ev_ctx); break; case REG_NULL: error = reg_open_local(NULL, &ctx); diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 98f7f02c38..5c308bfbda 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -207,8 +207,8 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) { int i; WERROR error; - uint32_t data_type; - DATA_BLOB data; + uint32_t valuetype; + DATA_BLOB valuedata; const char *name = NULL; for (i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(ctx, @@ -221,19 +221,15 @@ static WERROR cmd_ls(struct regshell_context *ctx, int argc, char **argv) } if (!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { - DEBUG(0, ("Error occured while browsing thru keys: %s\n", - win_errstr(error))); + fprintf(stderr, "Error occured while browsing thru keys: %s\n", + win_errstr(error)); + return error; } for (i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(ctx, - ctx->current, - i, - &name, - &data_type, - &data)); i++) { - printf("V \"%s\" %s %s\n", name, str_regtype(data_type), - reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), data_type, data)); - } + ctx->current, i, &name, &valuetype, &valuedata)); i++) + printf("V \"%s\" %s %s\n", name, str_regtype(valuetype), + reg_val_data_string(ctx, lp_iconv_convenience(cmdline_lp_ctx), valuetype, valuedata)); return WERR_OK; } @@ -250,7 +246,8 @@ static WERROR cmd_mkkey(struct regshell_context *ctx, int argc, char **argv) error = reg_key_add_name(ctx, ctx->current, argv[1], 0, NULL, &tmp); if (!W_ERROR_IS_OK(error)) { - fprintf(stderr, "Error adding new subkey '%s'\n", argv[1]); + fprintf(stderr, "Error adding new subkey '%s': %s\n", argv[1], + win_errstr(error)); return error; } @@ -438,7 +435,7 @@ static char **reg_complete_key(const char *text, int start, int end) len = strlen(text); for(i = 0; j < MAX_COMPLETIONS-1; i++) { status = reg_key_get_subkey_by_index(mem_ctx, base, i, - &subkeyname, NULL, NULL); + &subkeyname, NULL, NULL); if(W_ERROR_IS_OK(status)) { if(!strncmp(text, subkeyname, len)) { matches[j] = strdup(subkeyname); @@ -536,7 +533,8 @@ int main(int argc, char **argv) if (ctx->current == NULL) { int i; - for (i = 0; reg_predefined_keys[i].handle; i++) { + for (i = 0; (reg_predefined_keys[i].handle != 0) && + (ctx->current == NULL); i++) { WERROR err; err = reg_get_predefined_key(ctx->registry, reg_predefined_keys[i].handle, diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index 19e4a010b4..6d55a3eb84 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -38,10 +38,9 @@ static void print_tree(int level, struct registry_key *p, bool fullpath, bool novals) { struct registry_key *subkey; - const char *valuename; - const char *keyname; - uint32_t value_type; - DATA_BLOB value_data; + const char *valuename, *keyname; + uint32_t valuetype; + DATA_BLOB valuedata; struct security_descriptor *sec_desc; WERROR error; int i; @@ -73,18 +72,14 @@ static void print_tree(int level, struct registry_key *p, if (!novals) { mem_ctx = talloc_init("print_tree"); - for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx, - p, - i, - &valuename, - &value_type, - &value_data)); i++) { + for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index( + mem_ctx, p, i, &valuename, &valuetype, &valuedata)); + i++) { int j; - char *desc; for(j = 0; j < level+1; j++) putchar(' '); - desc = reg_val_description(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx), valuename, - value_type, value_data); - printf("%s\n", desc); + printf("%s\n", reg_val_description(mem_ctx, + lp_iconv_convenience(cmdline_lp_ctx), valuename, + valuetype, valuedata)); } talloc_free(mem_ctx); diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index 68efd56a86..b3b6e49ea5 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -140,8 +140,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, break; case REG_BINARY: - *data = strhex_to_data_blob(data_str); - talloc_steal(mem_ctx, data->data); + *data = strhex_to_data_blob(mem_ctx, data_str); break; default: diff --git a/source4/lib/replace/.checker_innocent b/source4/lib/replace/.checker_innocent deleted file mode 100644 index e619176540..0000000000 --- a/source4/lib/replace/.checker_innocent +++ /dev/null @@ -1,4 +0,0 @@ ->>>MISTAKE21_create_files_6a9e68ada99a97cb ->>>MISTAKE21_os2_delete_9b2bfa7f38711d09 ->>>MISTAKE21_os2_delete_2fcc29aaa99a97cb ->>>SECURITY2_os2_delete_9b2bfa7f1c9396ca diff --git a/source4/lib/replace/README b/source4/lib/replace/README deleted file mode 100644 index 4d94317c4b..0000000000 --- a/source4/lib/replace/README +++ /dev/null @@ -1,113 +0,0 @@ -This subsystem ensures that we can always use a certain core set of -functions and types, that are either provided by the OS or by replacement -functions / definitions in this subsystem. The aim is to try to stick -to POSIX functions in here as much as possible. Convenience functions -that are available on no platform at all belong in other subsystems -(such as LIBUTIL). - -The following functions are guaranteed: - -ftruncate -strlcpy -strlcat -mktime -rename -initgroups -memmove -strdup -setlinebuf -vsyslog -timegm -setenv -unsetenv -strndup -strnlen -waitpid -seteuid -setegid -asprintf -snprintf -vasprintf -vsnprintf -opendir -readdir -telldir -seekdir -closedir -dlopen -dlclose -dlsym -dlerror -chroot -bzero -strerror -errno -mkdtemp -mkstemp (a secure one!) -pread -pwrite -getpass -readline (the library) -inet_ntoa -inet_ntop -inet_pton -inet_aton -strtoll -strtoull -socketpair -strptime -getaddrinfo -freeaddrinfo -getnameinfo -gai_strerror -getifaddrs -freeifaddrs -utime -utimes - -Types: -bool -socklen_t -uint_t -uint{8,16,32,64}_t -int{8,16,32,64}_t -intptr_t - -Constants: -PATH_NAME_MAX -UINT{16,32,64}_MAX -INT32_MAX -RTLD_LAZY -HOST_NAME_MAX -UINT16_MAX -UINT32_MAX -UINT64_MAX -CHAR_BIT - -Macros: -va_copy -__FUNCTION__ -__FILE__ -__LINE__ -__LINESTR__ -__location__ -__STRING -__STRINGSTRING -MIN -MAX -QSORT_CAST -ZERO_STRUCT -ZERO_STRUCTP -ZERO_STRUCTPN -ZERO_ARRAY -ARRAY_SIZE -PTR_DIFF - -Headers: -stdint.h -stdbool.h - -Prerequisites: -memset (for bzero) -syslog (for vsyslog) -mktemp (for mkstemp and mkdtemp) diff --git a/source4/lib/replace/aclocal.m4 b/source4/lib/replace/aclocal.m4 deleted file mode 100644 index 5605e476ba..0000000000 --- a/source4/lib/replace/aclocal.m4 +++ /dev/null @@ -1 +0,0 @@ -m4_include(libreplace.m4) diff --git a/source4/lib/replace/autoconf-2.60.m4 b/source4/lib/replace/autoconf-2.60.m4 deleted file mode 100644 index acdcd38efe..0000000000 --- a/source4/lib/replace/autoconf-2.60.m4 +++ /dev/null @@ -1,210 +0,0 @@ -# AC_GNU_SOURCE -# -------------- -AC_DEFUN([AC_GNU_SOURCE], -[AH_VERBATIM([_GNU_SOURCE], -[/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif])dnl -AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl -AC_BEFORE([$0], [AC_RUN_IFELSE])dnl -AC_DEFINE([_GNU_SOURCE]) -]) - -# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, -# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) -# -------------------------------------------------------------- -# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99') -# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails, -# try again with each compiler option in the space-separated OPTION-LIST; if one -# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE, -# else ACTION-IF-UNAVAILABLE. -AC_DEFUN([_AC_C_STD_TRY], -[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C])) -AC_CACHE_VAL(ac_cv_prog_cc_$1, -[ac_cv_prog_cc_$1=no -ac_save_CC=$CC -AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) -for ac_arg in '' $4 -do - CC="$ac_save_CC $ac_arg" - _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg]) - test "x$ac_cv_prog_cc_$1" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -])# AC_CACHE_VAL -case "x$ac_cv_prog_cc_$1" in - x) - AC_MSG_RESULT([none needed]) ;; - xno) - AC_MSG_RESULT([unsupported]) ;; - *) - CC="$CC $ac_cv_prog_cc_$1" - AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;; -esac -AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6]) -])# _AC_C_STD_TRY - -# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) -# ---------------------------------------------------------------- -# If the C compiler is not in ISO C99 mode by default, try to add an -# option to output variable CC to make it so. This macro tries -# various options that select ISO C99 on some system or another. It -# considers the compiler to be in ISO C99 mode if it handles mixed -# code and declarations, _Bool, inline and restrict. -AC_DEFUN([_AC_PROG_CC_C99], -[_AC_C_STD_TRY([c99], -[[#include -#include -#include -#include -#include - -struct incomplete_array -{ - int datasize; - double data[]; -}; - -struct named_init { - int number; - const wchar_t *name; - double average; -}; - -typedef const char *ccp; - -static inline int -test_restrict(ccp restrict text) -{ - // See if C++-style comments work. - // Iterate through items via the restricted pointer. - // Also check for declarations in for loops. - for (unsigned int i = 0; *(text+i) != '\0'; ++i) - continue; - return 0; -} - -// Check varargs and va_copy work. -static void -test_varargs(const char *format, ...) -{ - va_list args; - va_start(args, format); - va_list args_copy; - va_copy(args_copy, args); - - const char *str; - int number; - float fnumber; - - while (*format) - { - switch (*format++) - { - case 's': // string - str = va_arg(args_copy, const char *); - break; - case 'd': // int - number = va_arg(args_copy, int); - break; - case 'f': // float - fnumber = (float) va_arg(args_copy, double); - break; - default: - break; - } - } - va_end(args_copy); - va_end(args); -} -]], -[[ - // Check bool and long long datatypes. - _Bool success = false; - long long int bignum = -1234567890LL; - unsigned long long int ubignum = 1234567890uLL; - - // Check restrict. - if (test_restrict("String literal") != 0) - success = true; - char *restrict newvar = "Another string"; - - // Check varargs. - test_varargs("s, d' f .", "string", 65, 34.234); - - // Check incomplete arrays work. - struct incomplete_array *ia = - malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10)); - ia->datasize = 10; - for (int i = 0; i < ia->datasize; ++i) - ia->data[i] = (double) i * 1.234; - - // Check named initialisers. - struct named_init ni = { - .number = 34, - .name = L"Test wide string", - .average = 543.34343, - }; - - ni.number = 58; - - int dynamic_array[ni.number]; - dynamic_array[43] = 543; - - // work around unused variable warnings - return bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'; -]], -dnl Try -dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) -dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99) -dnl Intel ICC -c99 -dnl IRIX -c99 -dnl Solaris (unused because it causes the compiler to assume C99 semantics for -dnl library functions, and this is invalid before Solaris 10: -xc99) -dnl Tru64 -c99 -dnl with extended modes being tried first. -[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl -])# _AC_PROG_CC_C99 - -# AC_PROG_CC_C99 -# -------------- -AC_DEFUN([AC_PROG_CC_C99], -[ AC_REQUIRE([AC_PROG_CC])dnl - _AC_PROG_CC_C99 -]) - -# AC_USE_SYSTEM_EXTENSIONS -# ------------------------ -# Enable extensions on systems that normally disable them, -# typically due to standards-conformance issues. -AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], -[ - AC_BEFORE([$0], [AC_COMPILE_IFELSE]) - AC_BEFORE([$0], [AC_RUN_IFELSE]) - - AC_REQUIRE([AC_GNU_SOURCE]) - AC_REQUIRE([AC_AIX]) - AC_REQUIRE([AC_MINIX]) - - AH_VERBATIM([__EXTENSIONS__], -[/* Enable extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif]) - AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], - [ac_cv_safe_to_define___extensions__], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([ -# define __EXTENSIONS__ 1 - AC_INCLUDES_DEFAULT])], - [ac_cv_safe_to_define___extensions__=yes], - [ac_cv_safe_to_define___extensions__=no])]) - test $ac_cv_safe_to_define___extensions__ = yes && - AC_DEFINE([__EXTENSIONS__]) - AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) -]) diff --git a/source4/lib/replace/autogen.sh b/source4/lib/replace/autogen.sh deleted file mode 100755 index d46a4279f3..0000000000 --- a/source4/lib/replace/autogen.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -rm -rf autom4te.cache -rm -f configure config.h.in - -autoheader || exit 1 -autoconf || exit 1 - -rm -rf autom4te.cache - -echo "Now run ./configure and then make." -exit 0 - diff --git a/source4/lib/replace/config.guess b/source4/lib/replace/config.guess deleted file mode 100755 index 354dbe175a..0000000000 --- a/source4/lib/replace/config.guess +++ /dev/null @@ -1,1464 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-08-03' - -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/replace/config.sub b/source4/lib/replace/config.sub deleted file mode 100755 index 23cd6fd75c..0000000000 --- a/source4/lib/replace/config.sub +++ /dev/null @@ -1,1577 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-07-08' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | ms1 \ - | msp430 \ - | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m32c) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | ms1-* \ - | msp430-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - m32c-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c deleted file mode 100644 index 3b109d7e40..0000000000 --- a/source4/lib/replace/dlfcn.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba system utilities - Copyright (C) Andrew Tridgell 1992-1998 - Copyright (C) Jeremy Allison 1998-2002 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "replace.h" -#ifdef HAVE_DL_H -#include -#endif - -#ifndef HAVE_DLOPEN -#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS -void *rep_dlopen(const char *name, unsigned int flags) -#else -void *rep_dlopen(const char *name, int flags) -#endif -{ -#ifdef HAVE_SHL_LOAD - if (name == NULL) - return PROG_HANDLE; - return (void *)shl_load(name, flags, 0); -#else - return NULL; -#endif -} -#endif - -#ifndef HAVE_DLSYM -void *rep_dlsym(void *handle, const char *symbol) -{ -#ifdef HAVE_SHL_FINDSYM - void *sym_addr; - if (!shl_findsym((shl_t *)&handle, symbol, TYPE_UNDEFINED, &sym_addr)) - return sym_addr; -#endif - return NULL; -} -#endif - -#ifndef HAVE_DLERROR -char *rep_dlerror(void) -{ - return "dynamic loading of objects not supported on this platform"; -} -#endif - -#ifndef HAVE_DLCLOSE -int rep_dlclose(void *handle) -{ -#ifdef HAVE_SHL_CLOSE - return shl_unload((shl_t)handle); -#else - return 0; -#endif -} -#endif diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 deleted file mode 100644 index 42f56f26be..0000000000 --- a/source4/lib/replace/dlfcn.m4 +++ /dev/null @@ -1,31 +0,0 @@ -dnl dummies provided by dlfcn.c if not available -save_LIBS="$LIBS" -LIBS="" - -libreplace_cv_dlfcn=no -AC_SEARCH_LIBS(dlopen, dl) - -AC_CHECK_HEADERS(dlfcn.h) -AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) - -libreplace_cv_shl=no -AC_SEARCH_LIBS(shl_load, sl) -AC_CHECK_HEADERS(dl.h) -AC_CHECK_FUNCS([shl_load shl_unload shl_findsym],[],[libreplace_cv_shl=yes]) - -AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)], - [ - return 0; - ],[ - AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsigned int flags]) - ],[],[ - #include - ]) - -if test x"${libreplace_cv_dlfcn}" = x"yes";then - LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" -fi - -LIBDL="$LIBS" -AC_SUBST(LIBDL) -LIBS="$save_LIBS" diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c deleted file mode 100644 index c5cd52be93..0000000000 --- a/source4/lib/replace/getaddrinfo.c +++ /dev/null @@ -1,497 +0,0 @@ -/* -PostgreSQL Database Management System -(formerly known as Postgres, then as Postgres95) - -Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group - -Portions Copyright (c) 1994, The Regents of the University of California - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose, without fee, and without a written agreement -is hereby granted, provided that the above copyright notice and this paragraph -and the following two paragraphs appear in all copies. - -IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING -LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, -EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS -TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - -*/ - -/*------------------------------------------------------------------------- - * - * getaddrinfo.c - * Support getaddrinfo() on platforms that don't have it. - * - * We also supply getnameinfo() here, assuming that the platform will have - * it if and only if it has getaddrinfo(). If this proves false on some - * platform, we'll need to split this file and provide a separate configure - * test for getnameinfo(). - * - * Copyright (c) 2003-2007, PostgreSQL Global Development Group - * - * Copyright (C) 2007 Jeremy Allison. - * Modified to return multiple IPv4 addresses for Samba. - * - *------------------------------------------------------------------------- - */ - -#include "replace.h" -#include "system/network.h" - -#ifndef SMB_MALLOC -#define SMB_MALLOC(s) malloc(s) -#endif - -#ifndef SMB_STRDUP -#define SMB_STRDUP(s) strdup(s) -#endif - -static int check_hostent_err(struct hostent *hp) -{ - if (!hp) { - switch (h_errno) { - case HOST_NOT_FOUND: - case NO_DATA: - return EAI_NONAME; - case TRY_AGAIN: - return EAI_AGAIN; - case NO_RECOVERY: - default: - return EAI_FAIL; - } - } - if (!hp->h_name || hp->h_addrtype != AF_INET) { - return EAI_FAIL; - } - return 0; -} - -static char *canon_name_from_hostent(struct hostent *hp, - int *perr) -{ - char *ret = NULL; - - *perr = check_hostent_err(hp); - if (*perr) { - return NULL; - } - ret = SMB_STRDUP(hp->h_name); - if (!ret) { - *perr = EAI_MEMORY; - } - return ret; -} - -static char *get_my_canon_name(int *perr) -{ - char name[HOST_NAME_MAX+1]; - - if (gethostname(name, HOST_NAME_MAX) == -1) { - *perr = EAI_FAIL; - return NULL; - } - /* Ensure null termination. */ - name[HOST_NAME_MAX] = '\0'; - return canon_name_from_hostent(gethostbyname(name), perr); -} - -static char *get_canon_name_from_addr(struct in_addr ip, - int *perr) -{ - return canon_name_from_hostent( - gethostbyaddr(&ip, sizeof(ip), AF_INET), - perr); -} - -static struct addrinfo *alloc_entry(const struct addrinfo *hints, - struct in_addr ip, - unsigned short port) -{ - struct sockaddr_in *psin = NULL; - struct addrinfo *ai = SMB_MALLOC(sizeof(*ai)); - - if (!ai) { - return NULL; - } - memset(ai, '\0', sizeof(*ai)); - - psin = SMB_MALLOC(sizeof(*psin)); - if (!psin) { - free(ai); - return NULL; - } - - memset(psin, '\0', sizeof(*psin)); - - psin->sin_family = AF_INET; - psin->sin_port = htons(port); - psin->sin_addr = ip; - - ai->ai_flags = 0; - ai->ai_family = AF_INET; - ai->ai_socktype = hints->ai_socktype; - ai->ai_protocol = hints->ai_protocol; - ai->ai_addrlen = sizeof(*psin); - ai->ai_addr = (struct sockaddr *) psin; - ai->ai_canonname = NULL; - ai->ai_next = NULL; - - return ai; -} - -/* - * get address info for a single ipv4 address. - * - * Bugs: - servname can only be a number, not text. - */ - -static int getaddr_info_single_addr(const char *service, - uint32_t addr, - const struct addrinfo *hints, - struct addrinfo **res) -{ - - struct addrinfo *ai = NULL; - struct in_addr ip; - unsigned short port = 0; - - if (service) { - port = (unsigned short)atoi(service); - } - ip.s_addr = htonl(addr); - - ai = alloc_entry(hints, ip, port); - if (!ai) { - return EAI_MEMORY; - } - - /* If we're asked for the canonical name, - * make sure it returns correctly. */ - if (!(hints->ai_flags & AI_NUMERICSERV) && - hints->ai_flags & AI_CANONNAME) { - int err; - if (addr == INADDR_LOOPBACK || addr == INADDR_ANY) { - ai->ai_canonname = get_my_canon_name(&err); - } else { - ai->ai_canonname = - get_canon_name_from_addr(ip,&err); - } - if (ai->ai_canonname == NULL) { - freeaddrinfo(ai); - return err; - } - } - - *res = ai; - return 0; -} - -/* - * get address info for multiple ipv4 addresses. - * - * Bugs: - servname can only be a number, not text. - */ - -static int getaddr_info_name(const char *node, - const char *service, - const struct addrinfo *hints, - struct addrinfo **res) -{ - struct addrinfo *listp = NULL, *prevp = NULL; - char **pptr = NULL; - int err; - struct hostent *hp = NULL; - unsigned short port = 0; - - if (service) { - port = (unsigned short)atoi(service); - } - - hp = gethostbyname(node); - err = check_hostent_err(hp); - if (err) { - return err; - } - - for(pptr = hp->h_addr_list; *pptr; pptr++) { - struct in_addr ip = *(struct in_addr *)*pptr; - struct addrinfo *ai = alloc_entry(hints, ip, port); - - if (!ai) { - freeaddrinfo(listp); - return EAI_MEMORY; - } - - if (!listp) { - listp = ai; - prevp = ai; - ai->ai_canonname = SMB_STRDUP(hp->h_name); - if (!ai->ai_canonname) { - freeaddrinfo(listp); - return EAI_MEMORY; - } - } else { - prevp->ai_next = ai; - prevp = ai; - } - } - *res = listp; - return 0; -} - -/* - * get address info for ipv4 sockets. - * - * Bugs: - servname can only be a number, not text. - */ - -int rep_getaddrinfo(const char *node, - const char *service, - const struct addrinfo * hintp, - struct addrinfo ** res) -{ - struct addrinfo hints; - - /* Setup the hints struct. */ - if (hintp == NULL) { - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - } else { - memcpy(&hints, hintp, sizeof(hints)); - } - - if (hints.ai_family != AF_INET && hints.ai_family != AF_UNSPEC) { - return EAI_FAMILY; - } - - if (hints.ai_socktype == 0) { - hints.ai_socktype = SOCK_STREAM; - } - - if (!node && !service) { - return EAI_NONAME; - } - - if (node) { - if (node[0] == '\0') { - return getaddr_info_single_addr(service, - INADDR_ANY, - &hints, - res); - } else if (hints.ai_flags & AI_NUMERICHOST) { - struct in_addr ip; - if (!inet_aton(node, &ip)) { - return EAI_FAIL; - } - return getaddr_info_single_addr(service, - ntohl(ip.s_addr), - &hints, - res); - } else { - return getaddr_info_name(node, - service, - &hints, - res); - } - } else if (hints.ai_flags & AI_PASSIVE) { - return getaddr_info_single_addr(service, - INADDR_ANY, - &hints, - res); - } - return getaddr_info_single_addr(service, - INADDR_LOOPBACK, - &hints, - res); -} - - -void rep_freeaddrinfo(struct addrinfo *res) -{ - struct addrinfo *next = NULL; - - for (;res; res = next) { - next = res->ai_next; - if (res->ai_canonname) { - free(res->ai_canonname); - } - if (res->ai_addr) { - free(res->ai_addr); - } - free(res); - } -} - - -const char *rep_gai_strerror(int errcode) -{ -#ifdef HAVE_HSTRERROR - int hcode; - - switch (errcode) - { - case EAI_NONAME: - hcode = HOST_NOT_FOUND; - break; - case EAI_AGAIN: - hcode = TRY_AGAIN; - break; - case EAI_FAIL: - default: - hcode = NO_RECOVERY; - break; - } - - return hstrerror(hcode); -#else /* !HAVE_HSTRERROR */ - - switch (errcode) - { - case EAI_NONAME: - return "Unknown host"; - case EAI_AGAIN: - return "Host name lookup failure"; -#ifdef EAI_BADFLAGS - case EAI_BADFLAGS: - return "Invalid argument"; -#endif -#ifdef EAI_FAMILY - case EAI_FAMILY: - return "Address family not supported"; -#endif -#ifdef EAI_MEMORY - case EAI_MEMORY: - return "Not enough memory"; -#endif -#ifdef EAI_NODATA - case EAI_NODATA: - return "No host data of that type was found"; -#endif -#ifdef EAI_SERVICE - case EAI_SERVICE: - return "Class type not found"; -#endif -#ifdef EAI_SOCKTYPE - case EAI_SOCKTYPE: - return "Socket type not supported"; -#endif - default: - return "Unknown server error"; - } -#endif /* HAVE_HSTRERROR */ -} - -static int gethostnameinfo(const struct sockaddr *sa, - char *node, - size_t nodelen, - int flags) -{ - int ret = -1; - char *p = NULL; - - if (!(flags & NI_NUMERICHOST)) { - struct hostent *hp = gethostbyaddr( - &((struct sockaddr_in *)sa)->sin_addr, - sizeof(struct in_addr), - sa->sa_family); - ret = check_hostent_err(hp); - if (ret == 0) { - /* Name looked up successfully. */ - ret = snprintf(node, nodelen, "%s", hp->h_name); - if (ret < 0 || (size_t)ret >= nodelen) { - return EAI_MEMORY; - } - if (flags & NI_NOFQDN) { - p = strchr(node,'.'); - if (p) { - *p = '\0'; - } - } - return 0; - } - - if (flags & NI_NAMEREQD) { - /* If we require a name and didn't get one, - * automatically fail. */ - return ret; - } - /* Otherwise just fall into the numeric host code... */ - } - p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr); - ret = snprintf(node, nodelen, "%s", p); - if (ret < 0 || (size_t)ret >= nodelen) { - return EAI_MEMORY; - } - return 0; -} - -static int getservicenameinfo(const struct sockaddr *sa, - char *service, - size_t servicelen, - int flags) -{ - int ret = -1; - int port = ntohs(((struct sockaddr_in *)sa)->sin_port); - - if (!(flags & NI_NUMERICSERV)) { - struct servent *se = getservbyport( - port, - (flags & NI_DGRAM) ? "udp" : "tcp"); - if (se && se->s_name) { - /* Service name looked up successfully. */ - ret = snprintf(service, servicelen, "%s", se->s_name); - if (ret < 0 || (size_t)ret >= servicelen) { - return EAI_MEMORY; - } - return 0; - } - /* Otherwise just fall into the numeric service code... */ - } - ret = snprintf(service, servicelen, "%d", port); - if (ret < 0 || (size_t)ret >= servicelen) { - return EAI_MEMORY; - } - return 0; -} - -/* - * Convert an ipv4 address to a hostname. - * - * Bugs: - No IPv6 support. - */ -int rep_getnameinfo(const struct sockaddr *sa, socklen_t salen, - char *node, size_t nodelen, - char *service, size_t servicelen, int flags) -{ - - /* Invalid arguments. */ - if (sa == NULL || (node == NULL && service == NULL)) { - return EAI_FAIL; - } - - if (sa->sa_family != AF_INET) { - return EAI_FAIL; - } - - if (salen < sizeof(struct sockaddr_in)) { - return EAI_FAIL; - } - - if (node) { - return gethostnameinfo(sa, node, nodelen, flags); - } - - if (service) { - return getservicenameinfo(sa, service, servicelen, flags); - } - return 0; -} diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h deleted file mode 100644 index dddd699b62..0000000000 --- a/source4/lib/replace/getaddrinfo.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -PostgreSQL Database Management System -(formerly known as Postgres, then as Postgres95) - -Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group - -Portions Copyright (c) 1994, The Regents of the University of California - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose, without fee, and without a written agreement -is hereby granted, provided that the above copyright notice and this paragraph -and the following two paragraphs appear in all copies. - -IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING -LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, -EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS -TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - -*/ - -/*------------------------------------------------------------------------- - * - * getaddrinfo.h - * Support getaddrinfo() on platforms that don't have it. - * - * Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO, - * whether or not the library routine getaddrinfo() can be found. This - * policy is needed because on some platforms a manually installed libbind.a - * may provide getaddrinfo(), yet the system headers may not provide the - * struct definitions needed to call it. To avoid conflict with the libbind - * definition in such cases, we rename our routines to pg_xxx() via macros. - * - -in lib/replace we use rep_xxx() - - * This code will also work on platforms where struct addrinfo is defined - * in the system headers but no getaddrinfo() can be located. - * - * Copyright (c) 2003-2007, PostgreSQL Global Development Group - * - *------------------------------------------------------------------------- - */ -#ifndef GETADDRINFO_H -#define GETADDRINFO_H - -#ifndef HAVE_GETADDRINFO - -/* Rename private copies per comments above */ -#ifdef getaddrinfo -#undef getaddrinfo -#endif -#define getaddrinfo rep_getaddrinfo -#define HAVE_GETADDRINFO - -#ifdef freeaddrinfo -#undef freeaddrinfo -#endif -#define freeaddrinfo rep_freeaddrinfo -#define HAVE_FREEADDRINFO - -#ifdef gai_strerror -#undef gai_strerror -#endif -#define gai_strerror rep_gai_strerror -#define HAVE_GAI_STRERROR - -#ifdef getnameinfo -#undef getnameinfo -#endif -#define getnameinfo rep_getnameinfo -#define HAVE_GETNAMEINFO - -extern int rep_getaddrinfo(const char *node, const char *service, - const struct addrinfo * hints, struct addrinfo ** res); -extern void rep_freeaddrinfo(struct addrinfo * res); -extern const char *rep_gai_strerror(int errcode); -extern int rep_getnameinfo(const struct sockaddr * sa, socklen_t salen, - char *node, size_t nodelen, - char *service, size_t servicelen, int flags); -#endif /* HAVE_GETADDRINFO */ - -#endif /* GETADDRINFO_H */ diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c deleted file mode 100644 index f6f0ec080c..0000000000 --- a/source4/lib/replace/getifaddrs.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - Copyright (C) Andrew Tridgell 1998 - Copyright (C) Jeremy Allison 2007 - Copyright (C) Jelmer Vernooij 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 . -*/ - -#define SOCKET_WRAPPER_NOT_REPLACE - -#include "replace.h" -#include "system/network.h" - -#include -#include -#include - -#ifdef HAVE_SYS_TIME_H -#include -#endif - -#ifndef SIOCGIFCONF -#ifdef HAVE_SYS_SOCKIO_H -#include -#endif -#endif - -#ifdef HAVE_IFACE_GETIFADDRS -#define _FOUND_IFACE_ANY -#else - -void rep_freeifaddrs(struct ifaddrs *ifp) -{ - if (ifp != NULL) { - free(ifp->ifa_name); - free(ifp->ifa_addr); - free(ifp->ifa_netmask); - free(ifp->ifa_dstaddr); - freeifaddrs(ifp->ifa_next); - free(ifp); - } -} - -static struct sockaddr *sockaddr_dup(struct sockaddr *sa) -{ - struct sockaddr *ret; - socklen_t socklen; -#ifdef HAVE_SOCKADDR_SA_LEN - socklen = sa->sa_len; -#else - socklen = sizeof(struct sockaddr_storage); -#endif - ret = calloc(1, socklen); - if (ret == NULL) - return NULL; - memcpy(ret, sa, socklen); - return ret; -} -#endif - -#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. */ - -int rep_getifaddrs(struct ifaddrs **ifap) -{ - struct ifconf ifc; - char buff[8192]; - int fd, i, n; - struct ifreq *ifr=NULL; - struct in_addr ipaddr; - struct in_addr nmask; - char *iname; - struct ifaddrs *curif; - struct ifaddrs *lastif = NULL; - - *ifap = NULL; - - 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; i--) { - if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) == -1) { - freeifaddrs(*ifap); - return -1; - } - - curif = calloc(1, sizeof(struct ifaddrs)); - curif->ifa_name = strdup(ifr[i].ifr_name); - curif->ifa_flags = ifr[i].ifr_flags; - curif->ifa_dstaddr = NULL; - curif->ifa_data = NULL; - curif->ifa_next = NULL; - - curif->ifa_addr = NULL; - if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) { - curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); - } - - curif->ifa_netmask = NULL; - if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != -1) { - curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); - } - - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = curif; - } - lastif = curif; - } - - close(fd); - - return 0; -} - -#define _FOUND_IFACE_ANY -#endif /* HAVE_IFACE_IFCONF */ -#ifdef HAVE_IFACE_IFREQ - -#ifndef I_STR -#include -#endif - -/**************************************************************************** -this should cover most of the streams based systems -Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code -****************************************************************************/ -int rep_getifaddrs(struct ifaddrs **ifap) -{ - struct ifreq ifreq; - struct strioctl strioctl; - char buff[8192]; - int fd, i, n; - struct ifreq *ifr=NULL; - struct in_addr ipaddr; - struct in_addr nmask; - char *iname; - struct ifaddrs *curif; - struct ifaddrs *lastif = NULL; - - *ifap = NULL; - - 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; iifa_next = curif; - } - - strioctl.ic_cmd = SIOCGIFFLAGS; - strioctl.ic_dp = (char *)&ifreq; - strioctl.ic_len = sizeof(struct ifreq); - if (ioctl(fd, I_STR, &strioctl) != 0) { - freeifaddrs(*ifap); - return -1; - } - - curif->ifa_flags = ifreq.ifr_flags; - - strioctl.ic_cmd = SIOCGIFADDR; - strioctl.ic_dp = (char *)&ifreq; - strioctl.ic_len = sizeof(struct ifreq); - if (ioctl(fd, I_STR, &strioctl) != 0) { - freeifaddrs(*ifap); - return -1; - } - - curif->ifa_name = strdup(ifreq.ifr_name); - curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr); - curif->ifa_dstaddr = NULL; - curif->ifa_data = NULL; - curif->ifa_next = NULL; - curif->ifa_netmask = NULL; - - strioctl.ic_cmd = SIOCGIFNETMASK; - strioctl.ic_dp = (char *)&ifreq; - strioctl.ic_len = sizeof(struct ifreq); - if (ioctl(fd, I_STR, &strioctl) != 0) { - freeifaddrs(*ifap); - return -1; - } - - curif->ifa_netmask = sockaddr_dup(&ifreq.ifr_addr); - - lastif = curif; - } - - close(fd); - - return 0; -} - -#define _FOUND_IFACE_ANY -#endif /* HAVE_IFACE_IFREQ */ -#ifdef HAVE_IFACE_AIX - -/**************************************************************************** -this one is for AIX (tested on 4.2) -****************************************************************************/ -int rep_getifaddrs(struct ifaddrs **ifap) -{ - char buff[8192]; - int fd, i; - struct ifconf ifc; - struct ifreq *ifr=NULL; - struct in_addr ipaddr; - struct in_addr nmask; - char *iname; - struct ifaddrs *curif; - struct ifaddrs *lastif = NULL; - - *ifap = NULL; - - 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) { - uint_t inc; - - inc = ifr->ifr_addr.sa_len; - - if (ioctl(fd, SIOCGIFADDR, ifr) != 0) { - freeaddrinfo(*ifap); - return -1; - } - - curif = calloc(1, sizeof(struct ifaddrs)); - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = curif; - } - - curif->ifa_name = strdup(ifr->ifr_name); - curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); - curif->ifa_dstaddr = NULL; - curif->ifa_data = NULL; - curif->ifa_netmask = NULL; - curif->ifa_next = NULL; - - if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) { - freeaddrinfo(*ifap); - return -1; - } - - curif->ifa_flags = ifr->ifr_flags; - - if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { - freeaddrinfo(*ifap); - return -1; - } - - curif->ifa_netmask = sockaddr_dup(&ifr->ifr_addr); - - lastif = curif; - - 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 0; -} - -#define _FOUND_IFACE_ANY -#endif /* HAVE_IFACE_AIX */ -#ifndef _FOUND_IFACE_ANY -int rep_getifaddrs(struct ifaddrs **ifap) -{ - errno = ENOSYS; - return -1; -} -#endif diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c deleted file mode 100644 index 0be618fc91..0000000000 --- a/source4/lib/replace/getpass.c +++ /dev/null @@ -1,222 +0,0 @@ -/* Copyright (C) 1992-1998 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation; either version 3 of the -License, or (at your option) any later version. - -The GNU C Library 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 -Library General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, see . */ - -/* Modified to use with samba by Jeremy Allison, 8th July 1995. */ - -#include "replace.h" -#include "system/filesys.h" -#include "system/wait.h" -#include "system/terminal.h" -#include "system/passwd.h" - -/* - * Define additional missing types - */ -#ifndef HAVE_SIG_ATOMIC_T_TYPE -typedef int sig_atomic_t; -#endif - -#ifndef SIGCLD -#define SIGCLD SIGCHLD -#endif - -#ifndef SIGNAL_CAST -#define SIGNAL_CAST (RETSIGTYPE (*)(int)) -#endif - -#ifdef SYSV_TERMIO - -/* SYSTEM V TERMIO HANDLING */ - -static struct termio t; - -#define ECHO_IS_ON(t) ((t).c_lflag & ECHO) -#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO) -#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO) - -#ifndef TCSAFLUSH -#define TCSAFLUSH 1 -#endif - -#ifndef TCSANOW -#define TCSANOW 0 -#endif - -static int tcgetattr(int fd, struct termio *_t) -{ - return ioctl(fd, TCGETA, _t); -} - -static int tcsetattr(int fd, int flags, struct termio *_t) -{ - if(flags & TCSAFLUSH) - ioctl(fd, TCFLSH, TCIOFLUSH); - return ioctl(fd, TCSETS, _t); -} - -#elif !defined(TCSAFLUSH) - -/* BSD TERMIO HANDLING */ - -static struct sgttyb t; - -#define ECHO_IS_ON(t) ((t).sg_flags & ECHO) -#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO) -#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO) - -#define TCSAFLUSH 1 -#define TCSANOW 0 - -static int tcgetattr(int fd, struct sgttyb *_t) -{ - return ioctl(fd, TIOCGETP, (char *)_t); -} - -static int tcsetattr(int fd, int flags, struct sgttyb *_t) -{ - return ioctl(fd, TIOCSETP, (char *)_t); -} - -#else /* POSIX TERMIO HANDLING */ -#define ECHO_IS_ON(t) ((t).c_lflag & ECHO) -#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO) -#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO) - -static struct termios t; -#endif /* SYSV_TERMIO */ - -static void catch_signal(int signum,void (*handler)(int )) -{ -#ifdef HAVE_SIGACTION - struct sigaction act; - struct sigaction oldact; - - memset(&act, 0, sizeof(act)); - - act.sa_handler = handler; -#ifdef SA_RESTART - /* - * We *want* SIGALRM to interrupt a system call. - */ - if(signum != SIGALRM) - act.sa_flags = SA_RESTART; -#endif - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask,signum); - sigaction(signum,&act,&oldact); -#else /* !HAVE_SIGACTION */ - /* FIXME: need to handle sigvec and systems with broken signal() */ - signal(signum, handler); -#endif -} - -static sig_atomic_t gotintr; -static int in_fd = -1; - -/*************************************************************** - Signal function to tell us were ^C'ed. -****************************************************************/ - -static void gotintr_sig(void) -{ - gotintr = 1; - if (in_fd != -1) - close(in_fd); /* Safe way to force a return. */ - in_fd = -1; -} - -char *rep_getpass(const char *prompt) -{ - FILE *in, *out; - int echo_off; - static char buf[256]; - static size_t bufsize = sizeof(buf); - size_t nread; - - /* Catch problematic signals */ - catch_signal(SIGINT, SIGNAL_CAST gotintr_sig); - - /* Try to write to and read from the terminal if we can. - If we can't open the terminal, use stderr and stdin. */ - - in = fopen ("/dev/tty", "w+"); - if (in == NULL) { - in = stdin; - out = stderr; - } else { - out = in; - } - - setvbuf(in, NULL, _IONBF, 0); - - /* Turn echoing off if it is on now. */ - - if (tcgetattr (fileno (in), &t) == 0) { - if (ECHO_IS_ON(t)) { - TURN_ECHO_OFF(t); - echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0; - TURN_ECHO_ON(t); - } else { - echo_off = 0; - } - } else { - echo_off = 0; - } - - /* Write the prompt. */ - fputs(prompt, out); - fflush(out); - - /* Read the password. */ - buf[0] = 0; - if (!gotintr) { - in_fd = fileno(in); - if (fgets(buf, bufsize, in) == NULL) { - buf[0] = 0; - } - } - nread = strlen(buf); - if (nread) { - if (buf[nread - 1] == '\n') - buf[nread - 1] = '\0'; - } - - /* Restore echoing. */ - if (echo_off) { - if (gotintr && in_fd == -1) { - in = fopen ("/dev/tty", "w+"); - } - if (in != NULL) - tcsetattr (fileno (in), TCSANOW, &t); - } - - fprintf(out, "\n"); - fflush(out); - - if (in && in != stdin) /* We opened the terminal; now close it. */ - fclose(in); - - /* Catch problematic signals */ - catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); - - if (gotintr) { - printf("Interupted by signal.\n"); - fflush(stdout); - exit(1); - } - return buf; -} diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 deleted file mode 100644 index b93817f9d3..0000000000 --- a/source4/lib/replace/getpass.m4 +++ /dev/null @@ -1,24 +0,0 @@ -AC_CHECK_FUNC(getpass, libreplace_cv_HAVE_GETPASS=yes) -AC_CHECK_FUNC(getpassphrase, libreplace_cv_HAVE_GETPASSPHRASE=yes) -if test x"$libreplace_cv_HAVE_GETPASS" = x"yes" -a x"$libreplace_cv_HAVE_GETPASSPHRASE" = x"yes"; then - AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars]) - AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" -else - -AC_CACHE_CHECK([whether getpass should be replaced],libreplace_cv_REPLACE_GETPASS,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I$libreplacedir/" -AC_TRY_COMPILE([ -#include "confdefs.h" -#define NO_CONFIG_H -#include "$libreplacedir/getpass.c" -],[],libreplace_cv_REPLACE_GETPASS=yes,libreplace_cv_REPLACE_GETPASS=no) -CPPFLAGS="$SAVE_CPPFLAGS" -]) -if test x"$libreplace_cv_REPLACE_GETPASS" = x"yes"; then - AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" -fi - -fi diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c deleted file mode 100644 index c6b3bb11a7..0000000000 --- a/source4/lib/replace/inet_aton.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * replacement functions - * Copyright (C) Michael Adam 2008 - * - * ** NOTE! The following LGPL license applies to the replace - * ** library. This does NOT imply that all of Samba is released - * ** under the LGPL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "replace.h" -#include "system/network.h" - -/** - * We know that we have inet_pton from earlier libreplace checks. - */ -int rep_inet_aton(const char *src, struct in_addr *dst) -{ - return (inet_pton(AF_INET, src, dst) > 0) ? 1 : 0; -} diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c deleted file mode 100644 index e3b80ebef8..0000000000 --- a/source4/lib/replace/inet_ntoa.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * replacement routines for broken systems - * Copyright (C) Andrew Tridgell 2003 - * Copyright (C) Michael Adam 2008 - * - * ** NOTE! The following LGPL license applies to the replace - * ** library. This does NOT imply that all of Samba is released - * ** under the LGPL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "replace.h" -#include "system/network.h" - -/** - * NOTE: this is not thread safe, but it can't be, either - * since it returns a pointer to static memory. - */ -char *rep_inet_ntoa(struct in_addr ip) -{ - uint8_t *p = (uint8_t *)&ip.s_addr; - static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", - (int)p[0], (int)p[1], (int)p[2], (int)p[3]); - return buf; -} diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c deleted file mode 100644 index fb3d8e90c8..0000000000 --- a/source4/lib/replace/inet_ntop.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 1996-2001 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include "replace.h" -#include "system/network.h" - -#define NS_INT16SZ 2 -#define NS_IN6ADDRSZ 16 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4(const unsigned char *src, char *dst, - socklen_t size); - -#ifdef AF_INET6 -static const char *inet_ntop6(const unsigned char *src, char *dst, - socklen_t size); -#endif - -/* char * - * isc_net_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -rep_inet_ntop(int af, const void *src, char *dst, socklen_t size) -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); -#ifdef AF_INET6 - case AF_INET6: - return (inet_ntop6(src, dst, size)); -#endif - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a unsigned char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(const unsigned char *src, char *dst, socklen_t size) -{ - static const char *fmt = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - size_t len; - - len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]); - if (len >= size) { - errno = ENOSPC; - return (NULL); - } - memcpy(dst, tmp, len + 1); - - return (dst); -} - -/* const char * - * isc_inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -#ifdef AF_INET6 -static const char * -inet_ntop6(const unsigned char *src, char *dst, socklen_t size) -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; - struct { int base, len; } best, cur; - unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i, inc; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < NS_IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - best.len = 0; - cur.base = -1; - cur.len = 0; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) - return (NULL); - tp += strlen(tp); - break; - } - inc = snprintf(tp, 5, "%x", words[i]); - if (inc >= 5) { - abort(); - } - tp += inc; - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == - (NS_IN6ADDRSZ / NS_INT16SZ)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - memcpy(dst, tmp, tp - tmp); - return (dst); -} -#endif /* AF_INET6 */ diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c deleted file mode 100644 index 80e4865ef4..0000000000 --- a/source4/lib/replace/inet_pton.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 1996-2001 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "replace.h" -#include "system/network.h" - -#define NS_INT16SZ 2 -#define NS_INADDRSZ 4 -#define NS_IN6ADDRSZ 16 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4(const char *src, unsigned char *dst); -#ifdef AF_INET6 -static int inet_pton6(const char *src, unsigned char *dst); -#endif - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -int -rep_inet_pton(int af, - const char *src, - void *dst) -{ - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); -#ifdef AF_INET6 - case AF_INET6: - return (inet_pton6(src, dst)); -#endif - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(src, dst) - const char *src; - unsigned char *dst; -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[NS_INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int new = *tp * 10 + (pch - digits); - - if (new > 255) - return (0); - *tp = new; - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - memcpy(dst, tmp, NS_INADDRSZ); - return (1); -} - -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -#ifdef AF_INET6 -static int -inet_pton6(src, dst) - const char *src; - unsigned char *dst; -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - unsigned int val; - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += NS_INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); - return (1); -} -#endif diff --git a/source4/lib/replace/install-sh b/source4/lib/replace/install-sh deleted file mode 100755 index 58719246f0..0000000000 --- a/source4/lib/replace/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 deleted file mode 100644 index 30c63f2f05..0000000000 --- a/source4/lib/replace/libreplace_cc.m4 +++ /dev/null @@ -1,182 +0,0 @@ - -AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START, -[ -echo "LIBREPLACE_CC_CHECKS: START" -]) - -AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END, -[ -echo "LIBREPLACE_CC_CHECKS: END" -]) - -dnl -dnl -dnl AC_LIBREPLACE_CC_CHECKS -dnl -dnl Note: we need to use m4_define instead of AC_DEFUN because -dnl of the ordering of tests -dnl -dnl -m4_define(AC_LIBREPLACE_CC_CHECKS, -[ -AC__LIBREPLACE_ONLY_CC_CHECKS_START - -dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it -dnl which conflicts with C99 on HPUX -ac_cv_prog_cc_Ae=no - -savedCFLAGS=$CFLAGS -AC_PROG_CC -CFLAGS=$savedCFLAGS - -dnl don't try for C99 if we are using gcc, as otherwise we -dnl lose immediate structure constants -if test x"$GCC" != x"yes" ; then -AC_PROG_CC_C99 -fi - -if test x"$GCC" = x"yes" ; then - AC_MSG_CHECKING([for version of gcc]) - GCC_VERSION=`$CC -dumpversion` - AC_MSG_RESULT(${GCC_VERSION}) -fi -AC_USE_SYSTEM_EXTENSIONS -AC_C_BIGENDIAN -AC_C_INLINE -LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])]) - -AC_PROG_INSTALL - -AC_ISC_POSIX -AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) - -AC_SYS_LARGEFILE - -dnl Add #include for broken IRIX header files -case "$host_os" in - *irix6*) AC_ADD_INCLUDE() - ;; - *hpux*) - # mmap on HPUX is completely broken... - AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) - if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then - AC_MSG_WARN([Enabling HPUX 11.00/11.11 header bug workaround]) - CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64" - fi - if test "`uname -r`" = "B.11.23"; then - AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) - CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED" - fi - ;; - *aix*) - AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) - AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken]) - if test "${GCC}" != "yes"; then - ## for funky AIX compiler using strncpy() - CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" - fi - ;; - *osf*) - # this brings in socklen_t - AC_N_DEFINE(_XOPEN_SOURCE,600) - AC_N_DEFINE(_OSF_SOURCE) - ;; - # - # VOS may need to have POSIX support and System V compatibility enabled. - # - *vos*) - case "$CFLAGS" in - *-D_POSIX_C_SOURCE*);; - *) - CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L" - AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support]) - ;; - esac - case "$CFLAGS" in - *-D_SYSV*|*-D_SVID_SOURCE*);; - *) - CFLAGS="$CFLAGS -D_SYSV" - AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility]) - ;; - esac - ;; -esac - - - -AC_CHECK_HEADERS([standards.h]) - -# Solaris needs HAVE_LONG_LONG defined -AC_CHECK_TYPES(long long) - -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(char) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(long long) - -AC_CHECK_TYPE(uint_t, unsigned int) -AC_CHECK_TYPE(int8_t, char) -AC_CHECK_TYPE(uint8_t, unsigned char) -AC_CHECK_TYPE(int16_t, short) -AC_CHECK_TYPE(uint16_t, unsigned short) - -if test $ac_cv_sizeof_int -eq 4 ; then -AC_CHECK_TYPE(int32_t, int) -AC_CHECK_TYPE(uint32_t, unsigned int) -elif test $ac_cv_size_long -eq 4 ; then -AC_CHECK_TYPE(int32_t, long) -AC_CHECK_TYPE(uint32_t, unsigned long) -else -AC_MSG_ERROR([LIBREPLACE no 32-bit type found]) -fi - -AC_CHECK_TYPE(int64_t, long long) -AC_CHECK_TYPE(uint64_t, unsigned long long) - -AC_CHECK_TYPE(size_t, unsigned int) -AC_CHECK_TYPE(ssize_t, int) - -AC_CHECK_SIZEOF(off_t) -AC_CHECK_SIZEOF(size_t) -AC_CHECK_SIZEOF(ssize_t) - -AC_CHECK_TYPE(intptr_t, long long) -AC_CHECK_TYPE(uintptr_t, unsigned long long) -AC_CHECK_TYPE(ptrdiff_t, unsigned long long) - -if test x"$ac_cv_type_long_long" != x"yes";then - AC_MSG_ERROR([LIBREPLACE needs type 'long long']) -fi -if test $ac_cv_sizeof_long_long -lt 8;then - AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8]) -fi - -############################################ -# check if the compiler can do immediate structures -AC_SUBST(libreplace_cv_immediate_structures) -AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[ - AC_TRY_COMPILE([ - #include - ],[ - typedef struct {unsigned x;} FOOBAR; - #define X_FOOBAR(x) ((FOOBAR) { x }) - #define FOO_ONE X_FOOBAR(1) - FOOBAR f = FOO_ONE; - static const struct { - FOOBAR y; - } f2[] = { - {FOO_ONE} - }; - static const FOOBAR f3[] = {FOO_ONE}; - ], - libreplace_cv_immediate_structures=yes, - libreplace_cv_immediate_structures=no, - libreplace_cv_immediate_structures=cross) -]) -if test x"$libreplace_cv_immediate_structures" = x"yes"; then - AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) -fi - -AC__LIBREPLACE_ONLY_CC_CHECKS_END -]) dnl end AC_LIBREPLACE_CC_CHECKS diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 deleted file mode 100644 index 81bde46219..0000000000 --- a/source4/lib/replace/libreplace_ld.m4 +++ /dev/null @@ -1,319 +0,0 @@ -# -# This offers a nice overview how to build shared libraries on all platforms -# http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html -# - -AC_DEFUN([AC_LIBREPLACE_STLD], -[ - AC_PATH_PROG(PROG_AR, ar) - - STLD=${PROG_AR} - - AC_SUBST(STLD) -]) - -AC_DEFUN([AC_LIBREPLACE_STLD_FLAGS], -[ - STLD_FLAGS="-rcs" - AC_SUBST(STLD_FLAGS) -]) - -AC_DEFUN([AC_LD_EXPORT_DYNAMIC], -[ -saved_LDFLAGS="$LDFLAGS" -if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 | grep "GNU ld" >/dev/null]); then - LD_EXPORT_DYNAMIC="-Wl,-export-dynamic" -else - case "$host_os" in - hpux* ) - LD_EXPORT_DYNAMIC="-Wl,-E" - ;; - *) - LD_EXPORT_DYNAMIC="" - ;; - esac -fi -AC_SUBST(LD_EXPORT_DYNAMIC) -LDFLAGS="$saved_LDFLAGS" -]) - -AC_DEFUN([AC_LD_PICFLAG], -[ -case "$host_os" in - *linux*) - PICFLAG="-fPIC" - ;; - *solaris*) - if test "${GCC}" = "yes"; then - PICFLAG="-fPIC" - else - PICFLAG="-KPIC" - fi - ;; - *sunos*) - PICFLAG="-KPIC" # Is this correct for SunOS - ;; - *netbsd* | *freebsd* | *dragonfly* ) - PICFLAG="-fPIC -DPIC" - ;; - *openbsd*) - PICFLAG="-fPIC" - ;; - *irix*) - if test "${GCC}" = "yes"; then - PICFLAG="-fPIC" - else - PICFLAG="-KPIC" - fi - ;; - *aix*) - # as AIX code is always position independent... - PICFLAG="-O2" - ;; - *hpux*) - if test $ac_cv_prog_cc_Ae = yes; then - PICFLAG="+z +ESnolit" - elif test "${GCC}" = "yes"; then - PICFLAG="-fPIC" - fi - if test "$host_cpu" = "ia64"; then - PICFLAG="+z" - fi - ;; - *osf*) - PICFLAG="-fPIC" - ;; - *unixware*) - PICFLAG="-KPIC" - ;; - *darwin*) - PICFLAG="-fno-common" - ;; -esac -AC_SUBST(PICFLAG) -]) - -AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_LINKER], -[ - LD_SHLIB_LINKER="${CC}" - - case "$host_os" in - *irix*) - LD_SHLIB_LINKER="${PROG_LD}" - ;; - esac - - AC_SUBST(LD_SHLIB_LINKER) -]) - -AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS], -[ - LD_SHLIB_FLAGS="-shared" - - case "$host_os" in - *linux*) - LD_SHLIB_FLAGS="-shared -Wl,-Bsymbolic" - ;; - *solaris*) - LD_SHLIB_FLAGS="-G" - if test "${GCC}" = "no"; then - ## ${CFLAGS} added for building 64-bit shared - ## libs using Sun's Compiler - LD_SHLIB_FLAGS="-G \${CFLAGS}" - fi - ;; - *sunos*) - LD_SHLIB_FLAGS="-G" - ;; - *irix*) - LD_SHLIB_FLAGS="-shared" - ;; - *aix*) - LD_SHLIB_FLAGS="-Wl,-G,-bexpall,-bbigtoc" - ;; - *hpux*) - if test "${GCC}" = "yes"; then - LD_SHLIB_FLAGS="-shared" - else - LD_SHLIB_FLAGS="-b" - fi - ;; - *osf*) - LD_SHLIB_FLAGS="-shared" - ;; - *darwin*) - LD_SHLIB_FLAGS="-dynamiclib -Wl,-search_paths_first" - ;; - esac - - AC_SUBST(LD_SHLIB_FLAGS) -]) - -AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG], -[ - LD_SHLIB_DISALLOW_UNDEF_FLAG="" - - # - # TODO: enforce error not only warnings - # - # NOTE: -Wl,--no-allow-shlib-undefined isn't what we want... - # as it bails out on broken system libraries - # - case "$host_os" in - *osf*) - LD_SHLIB_DISALLOW_UNDEF_FLAG="-warning_unresolved" - ;; - *darwin*) - LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined error" - ;; - esac - - AC_SUBST(LD_SHLIB_DISALLOW_UNDEF_FLAG) -]) - -AC_DEFUN([AC_LIBREPLACE_SHLD], -[ - AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER]) - SHLD="$LD_SHLIB_LINKER" - AC_SUBST(SHLD) -]) - -AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS], -[ - AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS]) - AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG]) - SHLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_DISALLOW_UNDEF_FLAG" - AC_SUBST(SHLD_FLAGS) -]) - -AC_DEFUN([AC_LD_SHLIBEXT], -[ - SHLIBEXT="so" - case "$host_os" in - *hpux*) - if test "$host_cpu" = "ia64"; then - SHLIBEXT="so" - else - SHLIBEXT="sl" - fi - ;; - *darwin*) - SHLIBEXT="dylib" - ;; - esac - AC_SUBST(SHLIBEXT) -]) - -AC_DEFUN([AC_LD_SONAMEFLAG], -[ - AC_SUBST(SONAMEFLAG) - SONAMEFLAG="" - case "$host_os" in - *linux*) - SONAMEFLAG="-Wl,-soname=" - ;; - *solaris*) - SONAMEFLAG="-h " - if test "${GCC}" = "yes"; then - SONAMEFLAG="-Wl,-soname=" - fi - ;; - *sunos*) - SONAMEFLAG="-Wl,-h," - ;; - *netbsd* | *freebsd* | *dragonfly* ) - SONAMEFLAG="-Wl,-soname," - ;; - *openbsd*) - SONAMEFLAG="-Wl,-soname," - ;; - *irix*) - SONAMEFLAG="-Wl,-soname," - ;; - *hpux*) - SONAMEFLAG="-Wl,+h," - ;; - *osf*) - SONAMEFLAG="-Wl,-soname," - ;; - *unixware*) - SONAMEFLAG="-Wl,-soname," - ;; - *darwin*) - SONAMEFLAG="#" - ;; - *aix*) - # Not supported - SONAMEFLAG="#" - ;; - esac -]) - -AC_DEFUN([AC_LIBREPLACE_MDLD], -[ - AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER]) - MDLD="$LD_SHLIB_LINKER" - AC_SUBST(MDLD) -]) - -AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], -[ - LD_ALLOW_SHLIB_UNDEF_FLAG="" - - case "$host_os" in - *linux*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined" - ;; - *osf*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\"" - ;; - *darwin*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" - ;; - *aix*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-bnoentry" - ;; - esac - - AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG) -]) - -AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], -[ - AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS]) - AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG]) - MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_ALLOW_UNDEF_FLAG" - AC_SUBST(MDLD_FLAGS) -]) - -AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR], -[ - case "$host_os" in - *linux*) - LIB_PATH_VAR=LD_LIBRARY_PATH - ;; - *netbsd*) - LIB_PATH_VAR=LD_LIBRARY_PATH - ;; - *solaris*) - LIB_PATH_VAR=LD_LIBRARY_PATH - ;; - *hpux*) - LIB_PATH_VAR=SHLIB_PATH - ;; - *osf*) - LIB_PATH_VAR=LD_LIBRARY_PATH - ;; - *aix*) - LIB_PATH_VAR=LIB_PATH - ;; - *irix*) - LIB_PATH_VAR=LD_LIBRARY_PATH - ;; - *darwin*) - LIB_PATH_VAR=DYLD_LIBRARY_PATH - ;; - esac - - AC_SUBST(LIB_PATH_VAR) -]) diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 deleted file mode 100644 index 1856eacf66..0000000000 --- a/source4/lib/replace/libreplace_macros.m4 +++ /dev/null @@ -1,332 +0,0 @@ -# -# This is a collection of useful autoconf macros -# - -############################################ -# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags -# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action) -# changes CFLAGS to add -AC99 or -c99 if needed -AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT], -[ -saved_CFLAGS="$CFLAGS"; -c99_init=no -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers) - CFLAGS="$saved_CFLAGS"; - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers with -AC99) - CFLAGS="$saved_CFLAGS -AC99"; - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=extc99) - CFLAGS="$saved_CFLAGS -qlanglvl=extc99"; - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=stdc99) - CFLAGS="$saved_CFLAGS -qlanglvl=stdc99"; - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers with -c99) - CFLAGS="$saved_CFLAGS -c99" - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi - -if test "`uname`" = "HP-UX"; then - if test "$ac_cv_c_compiler_gnu" = no; then - # special override for broken HP-UX compiler - I can't find a way to test - # this properly (its a compiler bug) - CFLAGS="$CFLAGS -AC99"; - c99_init=yes; - fi -fi - -if test x"$c99_init" = x"yes"; then - saved_CFLAGS="" - $1 -else - CFLAGS="$saved_CFLAGS" - saved_CFLAGS="" - $2 -fi -]) - -dnl AC_PROG_CC_FLAG(flag) -AC_DEFUN(AC_PROG_CC_FLAG, -[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1, -[echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then - ac_cv_prog_cc_$1=yes -else - ac_cv_prog_cc_$1=no -fi -rm -f conftest* -])]) - -dnl see if a declaration exists for a function or variable -dnl defines HAVE_function_DECL if it exists -dnl AC_HAVE_DECL(var, includes) -AC_DEFUN(AC_HAVE_DECL, -[ - AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[ - AC_TRY_COMPILE([$2],[int i = (int)$1], - ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)]) - if test x"$ac_cv_have_$1_decl" = x"yes"; then - AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available]) - fi -]) - - -# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION], -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], -# [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES]) -# ------------------------------------------------------ -# -# Use a cache variable name containing both the library and function name, -# because the test really is for library $1 defining function $3, not -# just for library $1. Separate tests with the same $1 and different $3s -# may have different results. -# -# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3]) -# is asking for trouble, since AC_CHECK_LIB($lib, fun) would give -# ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence -# the AS_LITERAL_IF indirection. -# -# FIXME: This macro is extremely suspicious. It DEFINEs unconditionally, -# whatever the FUNCTION, in addition to not being a *S macro. Note -# that the cache does depend upon the function we are looking for. -# -# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just -# `ac_save_LIBS': there are many macros which don't want to see `LIBS' -# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'. -# And ``ac_save_LIBS' is too tempting a name, so let's leave them some -# freedom. -AC_DEFUN([AC_CHECK_LIB_EXT], -[ -AH_CHECK_LIB_EXT([$1]) -ac_check_lib_ext_save_LIBS=$LIBS -LIBS="-l$1 $$2 $7 $LIBS" -AS_LITERAL_IF([$1], - [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])], - [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl - -m4_ifval([$3], - [ - AH_CHECK_FUNC_EXT([$3]) - AS_LITERAL_IF([$1], - [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])], - [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl - AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func, - [AC_TRY_LINK_FUNC($3, - [AS_VAR_SET(ac_Lib_func, yes); - AS_VAR_SET(ac_Lib_ext, yes)], - [AS_VAR_SET(ac_Lib_func, no); - AS_VAR_SET(ac_Lib_ext, no)]) - ]) - AS_IF([test AS_VAR_GET(ac_Lib_func) = yes], - [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl - AS_VAR_POPDEF([ac_Lib_func])dnl - ],[ - AC_CACHE_CHECK([for -l$1], ac_Lib_ext, - [AC_TRY_LINK_FUNC([main], - [AS_VAR_SET(ac_Lib_ext, yes)], - [AS_VAR_SET(ac_Lib_ext, no)]) - ]) - ]) -LIBS=$ac_check_lib_ext_save_LIBS - -AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes], - [m4_default([$4], - [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) - case "$$2" in - *-l$1*) - ;; - *) - $2="-l$1 $$2" - ;; - esac]) - [$6] - ], - [$5])dnl -AS_VAR_POPDEF([ac_Lib_ext])dnl -])# AC_CHECK_LIB_EXT - -# AH_CHECK_LIB_EXT(LIBNAME) -# --------------------- -m4_define([AH_CHECK_LIB_EXT], -[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1), - [Define to 1 if you have the `]$1[' library (-l]$1[).])]) - -dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS, -dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], -dnl [OTHER-LIBRARIES]) -dnl -------------------------------------------------------- -dnl Search for a library defining FUNC, if it's not already available. -AC_DEFUN([AC_SEARCH_LIBS_EXT], -[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1], -[ -ac_func_search_ext_save_LIBS=$LIBS -ac_cv_search_ext_$1=no -AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], - [ac_cv_search_ext_$1="none required"]) -if test "$ac_cv_search_ext_$1" = no; then - for ac_lib in $2; do - LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS" - AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], - [ac_cv_search_ext_$1="-l$ac_lib" -break]) - done -fi -LIBS=$ac_func_search_ext_save_LIBS]) -AS_IF([test "$ac_cv_search_ext_$1" != no], - [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3" - $4], - [$5])dnl -]) - -dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable. -dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE) -AC_DEFUN([AC_CHECK_FUNC_EXT], -[ - AH_CHECK_FUNC_EXT($1) - ac_check_func_ext_save_LIBS=$LIBS - LIBS="$2 $LIBS" - AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl - AC_CACHE_CHECK([for $1], ac_var, - [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])], - [AS_VAR_SET(ac_var, yes)], - [AS_VAR_SET(ac_var, no)])]) - LIBS=$ac_check_func_ext_save_LIBS - AS_IF([test AS_VAR_GET(ac_var) = yes], - [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], - [$4])dnl -AS_VAR_POPDEF([ac_var])dnl -])# AC_CHECK_FUNC - -# AH_CHECK_FUNC_EXT(FUNCNAME) -# --------------------- -m4_define([AH_CHECK_FUNC_EXT], -[AH_TEMPLATE(AS_TR_CPP(HAVE_$1), - [Define to 1 if you have the `]$1[' function.])]) - -dnl Define an AC_DEFINE with ifndef guard. -dnl AC_N_DEFINE(VARIABLE [, VALUE]) -AC_DEFUN([AC_N_DEFINE], -[ -AH_VERBATIM([$1], [ -#ifndef $1 -# undef $1 -#endif -]) - - cat >>confdefs.h <<\EOF -#ifndef $1 -[#define] $1 m4_if($#, 1, 1, [$2]) -#endif -EOF -]) - -dnl Add an #include -dnl AC_ADD_INCLUDE(VARIABLE) -define(AC_ADD_INCLUDE, -[cat >> confdefs.h <<\EOF -[#include] $1 -EOF -]) - -dnl remove an #include -dnl AC_REMOVE_INCLUDE(VARIABLE) -define(AC_REMOVE_INCLUDE, -[ -grep -v '[#include] $1' confdefs.h >confdefs.h.tmp -cat confdefs.h.tmp > confdefs.h -rm confdefs.h.tmp -]) - -dnl remove an #define -dnl AC_REMOVE_DEFINE(VARIABLE) -define(AC_REMOVE_DEFINE, -[ -grep -v '[#define] $1 ' confdefs.h |grep -v '[#define] $1[$]'>confdefs.h.tmp -cat confdefs.h.tmp > confdefs.h -rm confdefs.h.tmp -]) - -dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is deprecated -dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already -dnl defined. -m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))]) - -dnl check if the prototype in the header matches the given one -dnl AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders]) -AC_DEFUN(AC_VERIFY_C_PROTOTYPE, -[AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]), - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - AC_INCLUDES_DEFAULT - $5 - $1 - { - $2 - } - ])],[ - AS_TR_SH([ac_cv_c_prototype_$1])=yes - ],[ - AS_TR_SH([ac_cv_c_prototype_$1])=no - ]) -) -AS_IF([test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4]) -]) - -AC_DEFUN(LIBREPLACE_PROVIDE_HEADER, -[AC_CHECK_HEADER([$1], - [ AC_CONFIG_COMMANDS(rm-$1, [rm -f $libreplacedir/$1], [libreplacedir=$libreplacedir]) ], - [ AC_CONFIG_COMMANDS(mk-$1, [echo "#include \"replace.h\"" > $libreplacedir/$1], [libreplacedir=$libreplacedir]) ] - ) -]) - -dnl AC_HAVE_TYPE(TYPE,INCLUDES) -AC_DEFUN([AC_HAVE_TYPE], [ -AC_REQUIRE([AC_HEADER_STDC]) -cv=`echo "$1" | sed 'y%./+- %__p__%'` -AC_MSG_CHECKING(for $1) -AC_CACHE_VAL([ac_cv_type_$cv], -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -AC_INCLUDES_DEFAULT -$2]], -[[$1 foo;]])], -[eval "ac_cv_type_$cv=yes"], -[eval "ac_cv_type_$cv=no"]))dnl -ac_foo=`eval echo \\$ac_cv_type_$cv` -AC_MSG_RESULT($ac_foo) -if test "$ac_foo" = yes; then - ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'` -if false; then - AC_CHECK_TYPES($1) -fi - AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1']) -fi -]) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 deleted file mode 100644 index 4edb55c03a..0000000000 --- a/source4/lib/replace/libreplace_network.m4 +++ /dev/null @@ -1,377 +0,0 @@ -AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, -[ -echo "LIBREPLACE_NETWORK_CHECKS: START" - -AC_DEFINE(LIBREPLACE_NETWORK_CHECKS, 1, [LIBREPLACE_NETWORK_CHECKS were used]) -LIBREPLACE_NETWORK_OBJS="" -LIBREPLACE_NETWORK_LIBS="" - -AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) -AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) -AC_CHECK_HEADERS(sys/sockio.h sys/un.h) - -dnl we need to check that net/if.h really can be used, to cope with hpux -dnl where including it always fails -AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - AC_INCLUDES_DEFAULT - #if HAVE_SYS_SOCKET_H - # include - #endif - #include - int main(void) {return 0;}])], - [libreplace_cv_USABLE_NET_IF_H=yes], - [libreplace_cv_USABLE_NET_IF_H=no] - ) -]) -if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then - AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) -fi - -AC_HAVE_TYPE([socklen_t],[#include ]) -AC_HAVE_TYPE([sa_family_t],[#include ]) -AC_HAVE_TYPE([struct addrinfo], [#include ]) -AC_HAVE_TYPE([struct sockaddr], [#include ]) -AC_HAVE_TYPE([struct sockaddr_storage], [ -#include -#include -#include -]) -AC_HAVE_TYPE([struct sockaddr_in6], [ -#include -#include -#include -]) - -if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then -AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, - AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, - [ -#include -#include -#include - ]) - -if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then -AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, - AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, - [ -#include -#include -#include - ]) -fi -fi - -AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[ - AC_TRY_COMPILE( - [ -#include -#include -#include - ],[ -struct sockaddr_in sock; sock.sin_len = sizeof(sock); - ],[ - libreplace_cv_HAVE_SOCK_SIN_LEN=yes - ],[ - libreplace_cv_HAVE_SOCK_SIN_LEN=no - ]) -]) -if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then - AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property]) -fi - -############################################ -# check for unix domain sockets -AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[ - AC_TRY_COMPILE([ -#include -#include -#include -#include -#include - ],[ -struct sockaddr_un sunaddr; -sunaddr.sun_family = AF_UNIX; - ],[ - libreplace_cv_HAVE_UNIXSOCKET=yes - ],[ - libreplace_cv_HAVE_UNIXSOCKET=no - ]) -]) -if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then - AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support]) -fi - -dnl The following test is roughl taken from the cvs sources. -dnl -dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. -dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has -dnl libsocket.so which has a bad implementation of gethostbyname (it -dnl only looks in /etc/hosts), so we only look for -lsocket if we need -dnl it. -AC_CHECK_FUNCS(connect) -if test x"$ac_cv_func_connect" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) - AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) - AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) - AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) - dnl We can't just call AC_CHECK_FUNCS(connect) here, - dnl because the value has been cached. - if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || - test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || - test x"$ac_cv_lib_ext_socket_connect" = x"yes" || - test x"$ac_cv_lib_ext_inet_connect" = x"yes" - then - AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) - fi -fi - -AC_CHECK_FUNCS(gethostbyname) -if test x"$ac_cv_func_gethostbyname" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) - dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, - dnl because the value has been cached. - if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || - test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" || - test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes" - then - AC_DEFINE(HAVE_GETHOSTBYNAME,1, - [Whether the system has gethostbyname()]) - fi -fi - -dnl HP-UX has if_nametoindex in -lipv6 -AC_CHECK_FUNCS(if_nametoindex) -if test x"$ac_cv_func_if_nametoindex" = x"no"; then - AC_CHECK_LIB_EXT(ipv6, LIBREPLACE_NETWORK_LIBS, if_nametoindex) - dnl We can't just call AC_CHECK_FUNCS(if_nametoindex) here, - dnl because the value has been cached. - if test x"$ac_cv_lib_ext_ipv6_if_nametoindex" = x"yes" - then - AC_DEFINE(HAVE_IF_NAMETOINDEX, 1, - [Whether the system has if_nametoindex()]) - fi -fi - -# The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" -old_LIBS=$LIBS -LIBS="${LIBREPLACE_NETWORK_LIBS}" -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I$libreplacedir" - -AC_CHECK_FUNCS(socketpair,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} socketpair.o"]) - -AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ -AC_TRY_RUN([ -#include -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -main() { struct in_addr ip; ip.s_addr = 0x12345678; -if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } -exit(1);}], - libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) - -AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes]) -if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then - AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) - LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntoa.o" -fi - -AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_aton.o"]) - -AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntop.o"]) - -AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_pton.o"]) - -dnl test for getaddrinfo/getnameinfo -AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ -AC_TRY_LINK([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include -#include ], -[ -struct sockaddr sa; -struct addrinfo *ai = NULL; -int ret = getaddrinfo(NULL, NULL, NULL, &ai); -if (ret != 0) { - const char *es = gai_strerror(ret); -} -freeaddrinfo(ai); -ret = getnameinfo(&sa, sizeof(sa), - NULL, 0, - NULL, 0, 0); - -], -libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)]) -if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then - AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo]) - AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo]) - AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) - AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) -else - LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getaddrinfo.o" -fi - -AC_CHECK_HEADERS([ifaddrs.h]) - -dnl Used when getifaddrs is not available -AC_CHECK_MEMBERS([struct sockaddr.sa_len], - [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], - [], - [#include ]) - -dnl test for getifaddrs and freeifaddrs -AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ -AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include -#include -#include -#include -#include ], -[ -struct ifaddrs *ifp = NULL; -int ret = getifaddrs (&ifp); -freeifaddrs(ifp); -], -libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) -if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then - AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) - AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) - AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) -fi - -################## -# look for a method of finding the list of network interfaces -iface=no; -AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ -AC_TRY_RUN([ -#define HAVE_IFACE_GETIFADDRS 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) -else - LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getifaddrs.o" -fi - - -if test $iface = no; then -AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ -AC_TRY_RUN([ -#define HAVE_IFACE_AIX 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#undef _XOPEN_SOURCE_EXTENDED -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) -fi -fi - - -if test $iface = no; then -AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ -AC_TRY_RUN([ -#define HAVE_IFACE_IFCONF 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) -fi -fi - -if test $iface = no; then -AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ -AC_TRY_RUN([ -#define HAVE_IFACE_IFREQ 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) -fi -fi - -dnl test for ipv6 -AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[ - AC_TRY_LINK([ -#include /* for NULL */ -#include -#include -#include - ], - [ -struct sockaddr_storage sa_store; -struct addrinfo *ai = NULL; -struct in6_addr in6addr; -int idx = if_nametoindex("iface1"); -int s = socket(AF_INET6, SOCK_STREAM, 0); -int ret = getaddrinfo(NULL, NULL, NULL, &ai); -if (ret != 0) { - const char *es = gai_strerror(ret); -} -freeaddrinfo(ai); - ],[ - libreplace_cv_HAVE_IPV6=yes - ],[ - libreplace_cv_HAVE_IPV6=no - ]) -]) -if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then - AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support]) -fi - -LIBS=$old_LIBS -CPPFLAGS="$SAVE_CPPFLAGS" - -LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}" - -echo "LIBREPLACE_NETWORK_CHECKS: END" -]) dnl end AC_LIBREPLACE_NETWORK_CHECKS diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 deleted file mode 100644 index f53a4c2974..0000000000 --- a/source4/lib/replace/repdir.m4 +++ /dev/null @@ -1,78 +0,0 @@ -AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[ - AC_TRY_RUN([ -#define test_readdir_os2_delete main -#include "$libreplacedir/test/os2_delete.c"], - [libreplace_cv_READDIR_NEEDED=no], - [libreplace_cv_READDIR_NEEDED=yes], - [libreplace_cv_READDIR_NEEDED="assuming not"]) -]) - -# -# try to replace with getdirentries() if needed -# -if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then -AC_CHECK_FUNCS(getdirentries) -AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)], - [ - return 0; - ],[ - AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer]) - ],[],[ - #include - ]) - -AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)], - [ - return 0; - ],[ - AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int]) - ],[],[ - #include - ]) -AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_cv_READDIR_GETDIRENTRIES,[ - AC_TRY_RUN([ -#define _LIBREPLACE_REPLACE_H -#include "$libreplacedir/repdir_getdirentries.c" -#define test_readdir_os2_delete main -#include "$libreplacedir/test/os2_delete.c"], - [libreplace_cv_READDIR_GETDIRENTRIES=yes], - [libreplace_cv_READDIR_GETDIRENTRIES=no]) -]) -fi -if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then - AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) - AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o" - libreplace_cv_READDIR_NEEDED=no -fi - -# -# try to replace with getdents() if needed -# -if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then -AC_CHECK_FUNCS(getdents) -AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[ - AC_TRY_RUN([ -#define _LIBREPLACE_REPLACE_H -#error _donot_use_getdents_replacement_anymore -#include "$libreplacedir/repdir_getdents.c" -#define test_readdir_os2_delete main -#include "$libreplacedir/test/os2_delete.c"], - [libreplace_cv_READDIR_GETDENTS=yes], - [libreplace_cv_READDIR_GETDENTS=no]) -]) -fi -if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then - AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) - AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o" - libreplace_cv_READDIR_NEEDED=no -fi - -AC_MSG_CHECKING([a usable readdir()]) -if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then - AC_MSG_RESULT(no) - AC_MSG_WARN([the provided readdir() is broken]) -else - AC_MSG_RESULT(yes) -fi diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c deleted file mode 100644 index afc634a796..0000000000 --- a/source4/lib/replace/repdir_getdents.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Andrew Tridgell 2005 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ -/* - 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 -#include -#include -#include -#include -#include - -#define DIR_BUF_BITS 9 -#define DIR_BUF_SIZE (1<fd = open(dname, O_RDONLY); - if (d->fd == -1) { - free(d); - return NULL; - } - if (fstat(d->fd, &sb) < 0) { - close(d->fd); - free(d); - return NULL; - } - if (!S_ISDIR(sb.st_mode)) { - close(d->fd); - free(d); - errno = ENOTDIR; - return NULL; - } - d->ofs = 0; - d->seekpos = 0; - d->nbytes = 0; - return (DIR *)d; -} - -struct dirent *readdir(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - struct dirent *de; - - if (d->ofs >= d->nbytes) { - d->seekpos = lseek(d->fd, 0, SEEK_CUR); - d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); - d->ofs = 0; - } - if (d->ofs >= d->nbytes) { - return NULL; - } - de = (struct dirent *)&d->buf[d->ofs]; - d->ofs += de->d_reclen; - return de; -} - -long telldir(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - if (d->ofs >= d->nbytes) { - d->seekpos = lseek(d->fd, 0, SEEK_CUR); - 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; -} - -void seekdir(DIR *dir, long ofs) -{ - struct dir_buf *d = (struct dir_buf *)dir; - d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); - d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); - d->ofs = 0; - while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { - if (readdir(dir) == NULL) break; - } -} - -void rewinddir(DIR *dir) -{ - seekdir(dir, 0); -} - -int closedir(DIR *dir) -{ - 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(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - return d->fd; -} -#endif diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c deleted file mode 100644 index 197e5931fc..0000000000 --- a/source4/lib/replace/repdir_getdirentries.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Andrew Tridgell 2005 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ -/* - a replacement for opendir/readdir/telldir/seekdir/closedir for BSD - systems using getdirentries - - 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 - getdirentries() 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 "replace.h" -#include -#include -#include -#include -#include -#include -#include - -#define DIR_BUF_BITS 9 -#define DIR_BUF_SIZE (1<fd = open(dname, O_RDONLY); - if (d->fd == -1) { - free(d); - return NULL; - } - if (fstat(d->fd, &sb) < 0) { - close(d->fd); - free(d); - return NULL; - } - if (!S_ISDIR(sb.st_mode)) { - close(d->fd); - free(d); - errno = ENOTDIR; - return NULL; - } - d->ofs = 0; - d->seekpos = 0; - d->nbytes = 0; - return (DIR *)d; -} - -struct dirent *readdir(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - struct dirent *de; - - if (d->ofs >= d->nbytes) { - long pos; - d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos); - d->seekpos = pos; - d->ofs = 0; - } - if (d->ofs >= d->nbytes) { - return NULL; - } - de = (struct dirent *)&d->buf[d->ofs]; - d->ofs += de->d_reclen; - return de; -} - -#ifdef TELLDIR_TAKES_CONST_DIR -long telldir(const DIR *dir) -#else -long telldir(DIR *dir) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; - if (d->ofs >= d->nbytes) { - d->seekpos = lseek(d->fd, 0, SEEK_CUR); - 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; -} - -#ifdef SEEKDIR_RETURNS_INT -int seekdir(DIR *dir, long ofs) -#else -void seekdir(DIR *dir, long ofs) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; - long pos; - d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); - d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos); - d->ofs = 0; - while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { - if (readdir(dir) == NULL) break; - } -#ifdef SEEKDIR_RETURNS_INT - return -1; -#endif -} - -void rewinddir(DIR *dir) -{ - seekdir(dir, 0); -} - -int closedir(DIR *dir) -{ - 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(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - return d->fd; -} -#endif - - diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c deleted file mode 100644 index 98d799b07e..0000000000 --- a/source4/lib/replace/replace.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - Unix SMB/CIFS implementation. - replacement routines for broken systems - Copyright (C) Andrew Tridgell 1992-1998 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "replace.h" - -#include "system/filesys.h" -#include "system/time.h" -#include "system/passwd.h" -#include "system/syslog.h" -#include "system/locale.h" -#include "system/wait.h" - -void replace_dummy(void); -void replace_dummy(void) {} - -#ifndef HAVE_FTRUNCATE - /******************************************************************* -ftruncate for operating systems that don't have it -********************************************************************/ -int rep_ftruncate(int f, off_t l) -{ -#ifdef HAVE_CHSIZE - return chsize(f,l); -#elif defined(F_FREESP) - struct flock fl; - - fl.l_whence = 0; - fl.l_len = 0; - fl.l_start = l; - fl.l_type = F_WRLCK; - return fcntl(f, F_FREESP, &fl); -#else -#error "you must have a ftruncate function" -#endif -} -#endif /* HAVE_FTRUNCATE */ - - -#ifndef HAVE_STRLCPY -/* like strncpy but does not 0 fill the buffer and always null - terminates. bufsize is the size of the destination buffer */ -size_t rep_strlcpy(char *d, const char *s, size_t bufsize) -{ - size_t len = strlen(s); - size_t ret = len; - if (bufsize <= 0) return 0; - if (len >= bufsize) len = bufsize-1; - memcpy(d, s, len); - d[len] = 0; - return ret; -} -#endif - -#ifndef HAVE_STRLCAT -/* like strncat but does not 0 fill the buffer and always null - terminates. bufsize is the length of the buffer, which should - be one more than the maximum resulting string length */ -size_t rep_strlcat(char *d, const char *s, size_t bufsize) -{ - size_t len1 = strlen(d); - size_t len2 = strlen(s); - size_t ret = len1 + len2; - - if (len1+len2 >= bufsize) { - if (bufsize < (len1+1)) { - return ret; - } - len2 = bufsize - (len1+1); - } - if (len2 > 0) { - memcpy(d+len1, s, len2); - d[len1+len2] = 0; - } - return ret; -} -#endif - -#ifndef HAVE_MKTIME -/******************************************************************* -a mktime() replacement for those who don't have it - contributed by -C.A. Lademann -Corrections by richard.kettlewell@kewill.com -********************************************************************/ - -#define MINUTE 60 -#define HOUR 60*MINUTE -#define DAY 24*HOUR -#define YEAR 365*DAY -time_t rep_mktime(struct tm *t) -{ - struct tm *u; - time_t epoch = 0; - int n; - int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - y, m, i; - - if(t->tm_year < 70) - return((time_t)-1); - - n = t->tm_year + 1900 - 1; - epoch = (t->tm_year - 70) * YEAR + - ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY; - - y = t->tm_year + 1900; - m = 0; - - for(i = 0; i < t->tm_mon; i++) { - epoch += mon [m] * DAY; - if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) - epoch += DAY; - - if(++m > 11) { - m = 0; - y++; - } - } - - epoch += (t->tm_mday - 1) * DAY; - epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec; - - if((u = localtime(&epoch)) != NULL) { - t->tm_sec = u->tm_sec; - t->tm_min = u->tm_min; - t->tm_hour = u->tm_hour; - t->tm_mday = u->tm_mday; - t->tm_mon = u->tm_mon; - t->tm_year = u->tm_year; - t->tm_wday = u->tm_wday; - t->tm_yday = u->tm_yday; - t->tm_isdst = u->tm_isdst; - } - - return(epoch); -} -#endif /* !HAVE_MKTIME */ - - -#ifndef HAVE_INITGROUPS -/**************************************************************************** - some systems don't have an initgroups call -****************************************************************************/ -int rep_initgroups(char *name, gid_t id) -{ -#ifndef HAVE_SETGROUPS - /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ - errno = ENOSYS; - return -1; -#else /* HAVE_SETGROUPS */ - -#include - - gid_t *grouplst = NULL; - int max_gr = NGROUPS_MAX; - int ret; - int i,j; - struct group *g; - char *gr; - - if((grouplst = malloc(sizeof(gid_t) * max_gr)) == NULL) { - errno = ENOMEM; - return -1; - } - - grouplst[0] = id; - i = 1; - while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) { - if (g->gr_gid == id) - continue; - j = 0; - gr = g->gr_mem[0]; - while (gr && (*gr != (char)NULL)) { - if (strcmp(name,gr) == 0) { - grouplst[i] = g->gr_gid; - i++; - gr = (char *)NULL; - break; - } - gr = g->gr_mem[++j]; - } - } - endgrent(); - ret = setgroups(i, grouplst); - free(grouplst); - return ret; -#endif /* HAVE_SETGROUPS */ -} -#endif /* HAVE_INITGROUPS */ - - -#if (defined(SecureWare) && defined(SCO)) -/* This is needed due to needing the nap() function but we don't want - to include the Xenix libraries since that will break other things... - BTW: system call # 0x0c28 is the same as calling nap() */ -long nap(long milliseconds) { - return syscall(0x0c28, milliseconds); - } -#endif - - -#ifndef HAVE_MEMMOVE -/******************************************************************* -safely copies memory, ensuring no overlap problems. -this is only used if the machine does not have its own memmove(). -this is not the fastest algorithm in town, but it will do for our -needs. -********************************************************************/ -void *rep_memmove(void *dest,const void *src,int size) -{ - unsigned long d,s; - int i; - if (dest==src || !size) return(dest); - - d = (unsigned long)dest; - s = (unsigned long)src; - - if ((d >= (s+size)) || (s >= (d+size))) { - /* no overlap */ - memcpy(dest,src,size); - return(dest); - } - - if (d < s) { - /* we can forward copy */ - if (s-d >= sizeof(int) && - !(s%sizeof(int)) && - !(d%sizeof(int)) && - !(size%sizeof(int))) { - /* do it all as words */ - int *idest = (int *)dest; - int *isrc = (int *)src; - size /= sizeof(int); - for (i=0;i= sizeof(int) && - !(s%sizeof(int)) && - !(d%sizeof(int)) && - !(size%sizeof(int))) { - /* do it all as words */ - int *idest = (int *)dest; - int *isrc = (int *)src; - size /= sizeof(int); - for (i=size-1;i>=0;i--) idest[i] = isrc[i]; - } else { - /* simplest */ - char *cdest = (char *)dest; - char *csrc = (char *)src; - for (i=size-1;i>=0;i--) cdest[i] = csrc[i]; - } - } - return(dest); -} -#endif /* HAVE_MEMMOVE */ - -#ifndef HAVE_STRDUP -/**************************************************************************** -duplicate a string -****************************************************************************/ -char *rep_strdup(const char *s) -{ - size_t len; - char *ret; - - if (!s) return(NULL); - - len = strlen(s)+1; - ret = (char *)malloc(len); - if (!ret) return(NULL); - memcpy(ret,s,len); - return(ret); -} -#endif /* HAVE_STRDUP */ - -#ifndef HAVE_SETLINEBUF -void rep_setlinebuf(FILE *stream) -{ - setvbuf(stream, (char *)NULL, _IOLBF, 0); -} -#endif /* HAVE_SETLINEBUF */ - -#ifndef HAVE_VSYSLOG -#ifdef HAVE_SYSLOG -void rep_vsyslog (int facility_priority, const char *format, va_list arglist) -{ - char *msg = NULL; - vasprintf(&msg, format, arglist); - if (!msg) - return; - syslog(facility_priority, "%s", msg); - free(msg); -} -#endif /* HAVE_SYSLOG */ -#endif /* HAVE_VSYSLOG */ - -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - size_t rep_strnlen(const char *s, size_t max) -{ - size_t len; - - for (len = 0; len < max; len++) { - if (s[len] == '\0') { - break; - } - } - return len; -} -#endif - -#ifndef HAVE_STRNDUP -/** - Some platforms don't have strndup. -**/ -char *rep_strndup(const char *s, size_t n) -{ - char *ret; - - n = strnlen(s, n); - ret = malloc(n+1); - if (!ret) - return NULL; - memcpy(ret, s, n); - ret[n] = 0; - - return ret; -} -#endif - -#ifndef HAVE_WAITPID -int rep_waitpid(pid_t pid,int *status,int options) -{ - return wait4(pid, status, options, NULL); -} -#endif - -#ifndef HAVE_SETEUID -int rep_seteuid(uid_t euid) -{ -#ifdef HAVE_SETRESUID - return setresuid(-1, euid, -1); -#else -# error "You need a seteuid function" -#endif -} -#endif - -#ifndef HAVE_SETEGID -int rep_setegid(gid_t egid) -{ -#ifdef HAVE_SETRESGID - return setresgid(-1, egid, -1); -#else -# error "You need a setegid function" -#endif -} -#endif - -/******************************************************************* -os/2 also doesn't have chroot -********************************************************************/ -#ifndef HAVE_CHROOT -int rep_chroot(const char *dname) -{ - errno = ENOSYS; - return -1; -} -#endif - -/***************************************************************** - Possibly replace mkstemp if it is broken. -*****************************************************************/ - -#ifndef HAVE_SECURE_MKSTEMP -int rep_mkstemp(char *template) -{ - /* have a reasonable go at emulating it. Hope that - the system mktemp() isn't completly hopeless */ - char *p = mktemp(template); - if (!p) - return -1; - return open(p, O_CREAT|O_EXCL|O_RDWR, 0600); -} -#endif - -#ifndef HAVE_MKDTEMP -char *rep_mkdtemp(char *template) -{ - char *dname; - - if ((dname = mktemp(template))) { - if (mkdir(dname, 0700) >= 0) { - return dname; - } - } - - return NULL; -} -#endif - -/***************************************************************** - Watch out: this is not thread safe. -*****************************************************************/ - -#ifndef HAVE_PREAD -ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) -{ - if (lseek(__fd, __offset, SEEK_SET) != __offset) { - return -1; - } - return read(__fd, __buf, __nbytes); -} -#endif - -/***************************************************************** - Watch out: this is not thread safe. -*****************************************************************/ - -#ifndef HAVE_PWRITE -ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) -{ - if (lseek(__fd, __offset, SEEK_SET) != __offset) { - return -1; - } - return write(__fd, __buf, __nbytes); -} -#endif - -#ifndef HAVE_STRCASESTR -char *rep_strcasestr(const char *haystack, const char *needle) -{ - const char *s; - size_t nlen = strlen(needle); - for (s=haystack;*s;s++) { - if (toupper(*needle) == toupper(*s) && - strncasecmp(s, needle, nlen) == 0) { - return (char *)((uintptr_t)s); - } - } - return NULL; -} -#endif - -#ifndef HAVE_STRTOK_R -/* based on GLIBC version, copyright Free Software Foundation */ -char *rep_strtok_r(char *s, const char *delim, char **save_ptr) -{ - char *token; - - if (s == NULL) s = *save_ptr; - - s += strspn(s, delim); - if (*s == '\0') { - *save_ptr = s; - return NULL; - } - - token = s; - s = strpbrk(token, delim); - if (s == NULL) { - *save_ptr = token + strlen(token); - } else { - *s = '\0'; - *save_ptr = s + 1; - } - - return token; -} -#endif - -#ifndef HAVE_STRTOLL -long long int rep_strtoll(const char *str, char **endptr, int base) -{ -#ifdef HAVE_STRTOQ - return strtoq(str, endptr, base); -#elif defined(HAVE___STRTOLL) - return __strtoll(str, endptr, base); -#elif SIZEOF_LONG == SIZEOF_LONG_LONG - return (long long int) strtol(str, endptr, base); -#else -# error "You need a strtoll function" -#endif -} -#endif - - -#ifndef HAVE_STRTOULL -unsigned long long int rep_strtoull(const char *str, char **endptr, int base) -{ -#ifdef HAVE_STRTOUQ - return strtouq(str, endptr, base); -#elif defined(HAVE___STRTOULL) - return __strtoull(str, endptr, base); -#elif SIZEOF_LONG == SIZEOF_LONG_LONG - return (unsigned long long int) strtoul(str, endptr, base); -#else -# error "You need a strtoull function" -#endif -} -#endif - -#ifndef HAVE_SETENV -int rep_setenv(const char *name, const char *value, int overwrite) -{ - char *p; - size_t l1, l2; - int ret; - - if (!overwrite && getenv(name)) { - return 0; - } - - l1 = strlen(name); - l2 = strlen(value); - - p = malloc(l1+l2+2); - if (p == NULL) { - return -1; - } - memcpy(p, name, l1); - p[l1] = '='; - memcpy(p+l1+1, value, l2); - p[l1+l2+1] = 0; - - ret = putenv(p); - if (ret != 0) { - free(p); - } - - return ret; -} -#endif - -#ifndef HAVE_UNSETENV -int rep_unsetenv(const char *name) -{ - extern char **environ; - size_t len = strlen(name); - size_t i, count; - - if (environ == NULL || getenv(name) == NULL) { - return 0; - } - - for (i=0;environ[i];i++) /* noop */ ; - - count=i; - - for (i=0;i -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STRINGS_H -#include -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#if STDC_HEADERS -#include -#include -#endif - -#ifndef HAVE_STRERROR -extern char *sys_errlist[]; -#define strerror(i) sys_errlist[i] -#endif - -#ifndef HAVE_ERRNO_DECL -extern int errno; -#endif - -#ifndef HAVE_STRDUP -#define strdup rep_strdup -char *rep_strdup(const char *s); -#endif - -#ifndef HAVE_MEMMOVE -#define memmove rep_memmove -void *rep_memmove(void *dest,const void *src,int size); -#endif - -#ifndef HAVE_MKTIME -#define mktime rep_mktime -/* prototype is in "system/time.h" */ -#endif - -#ifndef HAVE_TIMEGM -#define timegm rep_timegm -/* prototype is in "system/time.h" */ -#endif - -#ifndef HAVE_UTIME -#define utime rep_utime -/* prototype is in "system/time.h" */ -#endif - -#ifndef HAVE_UTIMES -#define utimes rep_utimes -/* prototype is in "system/time.h" */ -#endif - -#ifndef HAVE_STRLCPY -#define strlcpy rep_strlcpy -size_t rep_strlcpy(char *d, const char *s, size_t bufsize); -#endif - -#ifndef HAVE_STRLCAT -#define strlcat rep_strlcat -size_t rep_strlcat(char *d, const char *s, size_t bufsize); -#endif - -#if (defined(BROKEN_STRNDUP) || !defined(HAVE_STRNDUP)) -#undef HAVE_STRNDUP -#define strndup rep_strndup -char *rep_strndup(const char *s, size_t n); -#endif - -#if (defined(BROKEN_STRNLEN) || !defined(HAVE_STRNLEN)) -#undef HAVE_STRNLEN -#define strnlen rep_strnlen -size_t rep_strnlen(const char *s, size_t n); -#endif - -#ifndef HAVE_SETENV -#define setenv rep_setenv -int rep_setenv(const char *name, const char *value, int overwrite); -#else -#ifndef HAVE_SETENV_DECL -int setenv(const char *name, const char *value, int overwrite); -#endif -#endif - -#ifndef HAVE_UNSETENV -#define unsetenv rep_unsetenv -int rep_unsetenv(const char *name); -#endif - -#ifndef HAVE_SETEUID -#define seteuid rep_seteuid -int rep_seteuid(uid_t); -#endif - -#ifndef HAVE_SETEGID -#define setegid rep_setegid -int rep_setegid(gid_t); -#endif - -#ifndef HAVE_SETLINEBUF -#define setlinebuf rep_setlinebuf -void rep_setlinebuf(FILE *); -#endif - -#ifndef HAVE_STRCASESTR -#define strcasestr rep_strcasestr -char *rep_strcasestr(const char *haystack, const char *needle); -#endif - -#ifndef HAVE_STRTOK_R -#define strtok_r rep_strtok_r -char *rep_strtok_r(char *s, const char *delim, char **save_ptr); -#endif - -#ifndef HAVE_STRTOLL -#define strtoll rep_strtoll -long long int rep_strtoll(const char *str, char **endptr, int base); -#endif - -#ifndef HAVE_STRTOULL -#define strtoull rep_strtoull -unsigned long long int rep_strtoull(const char *str, char **endptr, int base); -#endif - -#ifndef HAVE_FTRUNCATE -#define ftruncate rep_ftruncate -int rep_ftruncate(int,off_t); -#endif - -#ifndef HAVE_INITGROUPS -#define initgroups rep_initgroups -int rep_initgroups(char *name, gid_t id); -#endif - -#if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) -#define bzero(a,b) memset((a),'\0',(b)) -#endif - -#ifndef HAVE_DLERROR -#define dlerror rep_dlerror -char *rep_dlerror(void); -#endif - -#ifndef HAVE_DLOPEN -#define dlopen rep_dlopen -#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS -void *rep_dlopen(const char *name, unsigned int flags); -#else -void *rep_dlopen(const char *name, int flags); -#endif -#endif - -#ifndef HAVE_DLSYM -#define dlsym rep_dlsym -void *rep_dlsym(void *handle, const char *symbol); -#endif - -#ifndef HAVE_DLCLOSE -#define dlclose rep_dlclose -int rep_dlclose(void *handle); -#endif - -#ifndef HAVE_SOCKETPAIR -#define socketpair rep_socketpair -/* prototype is in system/network.h */ -#endif - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -#ifndef _DEPRECATED_ -#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) -#define _DEPRECATED_ __attribute__ ((deprecated)) -#else -#define _DEPRECATED_ -#endif -#endif - -#ifndef HAVE_VASPRINTF -#define vasprintf rep_vasprintf -int rep_vasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0); -#endif - -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) -#define snprintf rep_snprintf -int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); -#endif - -#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) -#define vsnprintf rep_vsnprintf -int rep_vsnprintf(char *,size_t ,const char *, va_list ap) PRINTF_ATTRIBUTE(3,0); -#endif - -#ifndef HAVE_ASPRINTF -#define asprintf rep_asprintf -int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); -#endif - -#ifndef HAVE_VSYSLOG -#ifdef HAVE_SYSLOG -#define vsyslog rep_vsyslog -void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PRINTF_ATTRIBUTE(2,0); -#endif -#endif - -/* we used to use these fns, but now we have good replacements - for snprintf and vsnprintf */ -#define slprintf snprintf - - -#ifndef HAVE_VA_COPY -#undef va_copy -#ifdef HAVE___VA_COPY -#define va_copy(dest, src) __va_copy(dest, src) -#else -#define va_copy(dest, src) (dest) = (src) -#endif -#endif - -#ifndef HAVE_VOLATILE -#define volatile -#endif - -#ifndef HAVE_COMPARISON_FN_T -typedef int (*comparison_fn_t)(const void *, const void *); -#endif - -#ifdef REPLACE_STRPTIME -#define strptime rep_strptime -struct tm; -char *rep_strptime(const char *buf, const char *format, struct tm *tm); -#endif - -/* Load header file for dynamic linking stuff */ -#ifdef HAVE_DLFCN_H -#include -#endif - -#ifndef RTLD_LAZY -#define RTLD_LAZY 0 -#endif -#ifndef RTLD_NOW -#define RTLD_NOW 0 -#endif -#ifndef RTLD_GLOBAL -#define RTLD_GLOBAL 0 -#endif - -#ifndef HAVE_SECURE_MKSTEMP -#define mkstemp(path) rep_mkstemp(path) -int rep_mkstemp(char *temp); -#endif - -#ifndef HAVE_MKDTEMP -#define mkdtemp rep_mkdtemp -char *rep_mkdtemp(char *template); -#endif - -#ifndef HAVE_PREAD -#define pread rep_pread -ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); -#endif - -#ifndef HAVE_PWRITE -#define pwrite rep_pwrite -ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); -#endif - -#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) -#define inet_ntoa rep_inet_ntoa -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_INET_PTON -#define inet_pton rep_inet_pton -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_INET_NTOP -#define inet_ntop rep_inet_ntop -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_INET_ATON -#define inet_aton rep_inet_aton -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_CONNECT -#define connect rep_connect -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_GETHOSTBYNAME -#define gethostbyname rep_gethostbyname -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_GETIFADDRS -#define getifaddrs rep_getifaddrs -/* prototype is in "system/network.h" */ -#endif - -#ifndef HAVE_FREEIFADDRS -#define freeifaddrs rep_freeifaddrs -/* prototype is in "system/network.h" */ -#endif - -#ifdef HAVE_LIMITS_H -#include -#endif - -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -/* The extra casts work around common compiler bugs. */ -#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. - It is necessary at least when t == time_t. */ -#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) -#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t))) - -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 255 -#endif - -/* - * Some older systems seem not to have MAXHOSTNAMELEN - * defined. - */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN HOST_NAME_MAX -#endif - -#ifndef UINT16_MAX -#define UINT16_MAX 65535 -#endif - -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef UINT64_MAX -#define UINT64_MAX ((uint64_t)-1) -#endif - -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - -#ifndef INT32_MAX -#define INT32_MAX _TYPE_MAXIMUM(int32_t) -#endif - -#ifdef HAVE_STDBOOL_H -#include -#endif - -#if !defined(HAVE_BOOL) -#ifdef HAVE__Bool -#define bool _Bool -#else -typedef int bool; -#endif -#endif - -/* - * to prevent from doing a redefine of 'bool' - * - * IRIX, HPUX, MacOS 10 and Solaris need BOOL_DEFINED - * Tru64 needs _BOOL_EXISTS - * AIX needs _BOOL,_TRUE,_FALSE - */ -#ifndef BOOL_DEFINED -#define BOOL_DEFINED -#endif -#ifndef _BOOL_EXISTS -#define _BOOL_EXISTS -#endif -#ifndef _BOOL -#define _BOOL -#endif - -#ifndef __bool_true_false_are_defined -#define __bool_true_false_are_defined -#endif - -#ifndef true -#define true (1) -#endif -#ifndef false -#define false (0) -#endif - -#ifndef _TRUE -#define _TRUE true -#endif -#ifndef _FALSE -#define _FALSE false -#endif - -#ifndef HAVE_FUNCTION_MACRO -#ifdef HAVE_func_MACRO -#define __FUNCTION__ __func__ -#else -#define __FUNCTION__ ("") -#endif -#endif - - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#if !defined(HAVE_VOLATILE) -#define volatile -#endif - -/** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) - -/** Type-safe version of discard_const */ -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) - -#ifndef __STRING -#define __STRING(x) #x -#endif - -#ifndef __STRINGSTRING -#define __STRINGSTRING(x) __STRING(x) -#endif - -#ifndef __LINESTR__ -#define __LINESTR__ __STRINGSTRING(__LINE__) -#endif - -#ifndef __location__ -#define __location__ __FILE__ ":" __LINESTR__ -#endif - -/** - * zero a structure - */ -#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) - -/** - * zero a structure given a pointer to the structure - */ -#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) - -/** - * zero a structure given a pointer to the structure - no zero check - */ -#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) - -/* zero an array - note that sizeof(array) must work - ie. it must not be a - pointer */ -#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) - -/** - * work out how many elements there are in a static array - */ -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) - -/** - * pointer difference macro - */ -#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) - -#if MMAP_BLACKLIST -#undef HAVE_MMAP -#endif - -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#ifndef MAX_DNS_NAME_LENGTH -#define MAX_DNS_NAME_LENGTH 256 /* Actually 255 but +1 for terminating null. */ -#endif - -#endif /* _LIBREPLACE_REPLACE_H */ diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c deleted file mode 100644 index c54d721ce5..0000000000 --- a/source4/lib/replace/snprintf.c +++ /dev/null @@ -1,1530 +0,0 @@ -/* - * NOTE: If you change this file, please merge it into rsync, samba, etc. - */ - -/* - * Copyright Patrick Powell 1995 - * This code is based on code written by Patrick Powell (papowell@astart.com) - * It may be used for any purpose as long as this notice remains intact - * on all source code distributions - */ - -/************************************************************** - * Original: - * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 - * A bombproof version of doprnt (dopr) included. - * Sigh. This sort of thing is always nasty do deal with. Note that - * the version here does not include floating point... - * - * snprintf() is used instead of sprintf() as it does limit checks - * for string length. This covers a nasty loophole. - * - * The other functions are there to prevent NULL pointers from - * causing nast effects. - * - * More Recently: - * Brandon Long 9/15/96 for mutt 0.43 - * This was ugly. It is still ugly. I opted out of floating point - * numbers, but the formatter understands just about everything - * from the normal C string format, at least as far as I can tell from - * the Solaris 2.5 printf(3S) man page. - * - * Brandon Long 10/22/97 for mutt 0.87.1 - * Ok, added some minimal floating point support, which means this - * probably requires libm on most operating systems. Don't yet - * support the exponent (e,E) and sigfig (g,G). Also, fmtint() - * was pretty badly broken, it just wasn't being exercised in ways - * which showed it, so that's been fixed. Also, formated the code - * to mutt conventions, and removed dead code left over from the - * original. Also, there is now a builtin-test, just compile with: - * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm - * and run snprintf for results. - * - * Thomas Roessler 01/27/98 for mutt 0.89i - * The PGP code was using unsigned hexadecimal formats. - * Unfortunately, unsigned formats simply didn't work. - * - * Michael Elkins 03/05/98 for mutt 0.90.8 - * The original code assumed that both snprintf() and vsnprintf() were - * missing. Some systems only have snprintf() but not vsnprintf(), so - * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. - * - * Andrew Tridgell (tridge@samba.org) Oct 1998 - * fixed handling of %.0f - * added test for HAVE_LONG_DOUBLE - * - * tridge@samba.org, idra@samba.org, April 2001 - * got rid of fcvt code (twas buggy and made testing harder) - * added C99 semantics - * - * date: 2002/12/19 19:56:31; author: herb; state: Exp; lines: +2 -0 - * actually print args for %g and %e - * - * date: 2002/06/03 13:37:52; author: jmcd; state: Exp; lines: +8 -0 - * Since includes.h isn't included here, VA_COPY has to be defined here. I don't - * see any include file that is guaranteed to be here, so I'm defining it - * locally. Fixes AIX and Solaris builds. - * - * date: 2002/06/03 03:07:24; author: tridge; state: Exp; lines: +5 -13 - * put the ifdef for HAVE_VA_COPY in one place rather than in lots of - * functions - * - * date: 2002/05/17 14:51:22; author: jmcd; state: Exp; lines: +21 -4 - * Fix usage of va_list passed as an arg. Use __va_copy before using it - * when it exists. - * - * date: 2002/04/16 22:38:04; author: idra; state: Exp; lines: +20 -14 - * Fix incorrect zpadlen handling in fmtfp. - * Thanks to Ollie Oldham for spotting it. - * few mods to make it easier to compile the tests. - * addedd the "Ollie" test to the floating point ones. - * - * Martin Pool (mbp@samba.org) April 2003 - * Remove NO_CONFIG_H so that the test case can be built within a source - * tree with less trouble. - * Remove unnecessary SAFE_FREE() definition. - * - * Martin Pool (mbp@samba.org) May 2003 - * Put in a prototype for dummy_snprintf() to quiet compiler warnings. - * - * Move #endif to make sure VA_COPY, LDOUBLE, etc are defined even - * if the C library has some snprintf functions already. - * - * Darren Tucker (dtucker@zip.com.au) 2005 - * Fix bug allowing read overruns of the source string with "%.*s" - * Usually harmless unless the read runs outside the process' allocation - * (eg if your malloc does guard pages) in which case it will segfault. - * From OpenSSH. Also added test for same. - * - * Simo Sorce (idra@samba.org) Jan 2006 - * - * Add support for position independent parameters - * fix fmtstr now it conforms to sprintf wrt min.max - * - **************************************************************/ - -#include "replace.h" -#include "system/locale.h" - -#ifdef TEST_SNPRINTF /* need math library headers for testing */ - -/* In test mode, we pretend that this system doesn't have any snprintf - * functions, regardless of what config.h says. */ -# undef HAVE_SNPRINTF -# undef HAVE_VSNPRINTF -# undef HAVE_C99_VSNPRINTF -# undef HAVE_ASPRINTF -# undef HAVE_VASPRINTF -# include -#endif /* TEST_SNPRINTF */ - -#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) -/* only include stdio.h if we are not re-defining snprintf or vsnprintf */ -#include - /* make the compiler happy with an empty file */ - void dummy_snprintf(void); - void dummy_snprintf(void) {} -#endif /* HAVE_SNPRINTF, etc */ - -/* yes this really must be a ||. Don't muck with this (tridge) */ -#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) - -#ifdef HAVE_LONG_DOUBLE -#define LDOUBLE long double -#else -#define LDOUBLE double -#endif - -#ifdef HAVE_LONG_LONG -#define LLONG long long -#else -#define LLONG long -#endif - -#ifndef VA_COPY -#ifdef HAVE_VA_COPY -#define VA_COPY(dest, src) va_copy(dest, src) -#else -#ifdef HAVE___VA_COPY -#define VA_COPY(dest, src) __va_copy(dest, src) -#else -#define VA_COPY(dest, src) (dest) = (src) -#endif -#endif - -/* - * dopr(): poor man's version of doprintf - */ - -/* format read states */ -#define DP_S_DEFAULT 0 -#define DP_S_FLAGS 1 -#define DP_S_MIN 2 -#define DP_S_DOT 3 -#define DP_S_MAX 4 -#define DP_S_MOD 5 -#define DP_S_CONV 6 -#define DP_S_DONE 7 - -/* format flags - Bits */ -#define DP_F_MINUS (1 << 0) -#define DP_F_PLUS (1 << 1) -#define DP_F_SPACE (1 << 2) -#define DP_F_NUM (1 << 3) -#define DP_F_ZERO (1 << 4) -#define DP_F_UP (1 << 5) -#define DP_F_UNSIGNED (1 << 6) - -/* Conversion Flags */ -#define DP_C_CHAR 1 -#define DP_C_SHORT 2 -#define DP_C_LONG 3 -#define DP_C_LDOUBLE 4 -#define DP_C_LLONG 5 -#define DP_C_SIZET 6 - -/* Chunk types */ -#define CNK_FMT_STR 0 -#define CNK_INT 1 -#define CNK_OCTAL 2 -#define CNK_UINT 3 -#define CNK_HEX 4 -#define CNK_FLOAT 5 -#define CNK_CHAR 6 -#define CNK_STRING 7 -#define CNK_PTR 8 -#define CNK_NUM 9 -#define CNK_PRCNT 10 - -#define char_to_int(p) ((p)- '0') -#ifndef MAX -#define MAX(p,q) (((p) >= (q)) ? (p) : (q)) -#endif - -struct pr_chunk { - int type; /* chunk type */ - int num; /* parameter number */ - int min; - int max; - int flags; - int cflags; - int start; - int len; - LLONG value; - LDOUBLE fvalue; - char *strvalue; - void *pnum; - struct pr_chunk *min_star; - struct pr_chunk *max_star; - struct pr_chunk *next; -}; - -struct pr_chunk_x { - struct pr_chunk **chunks; - int num; -}; - -static int dopr(char *buffer, size_t maxlen, const char *format, - va_list args_in); -static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max); -static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - LLONG value, int base, int min, int max, int flags); -static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags); -static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); -static struct pr_chunk *new_chunk(void); -static int add_cnk_list_entry(struct pr_chunk_x **list, - int max_num, struct pr_chunk *chunk); - -static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) -{ - char ch; - int state; - int pflag; - int pnum; - int pfirst; - size_t currlen; - va_list args; - const char *base; - struct pr_chunk *chunks = NULL; - struct pr_chunk *cnk = NULL; - struct pr_chunk_x *clist = NULL; - int max_pos; - int ret = -1; - - VA_COPY(args, args_in); - - state = DP_S_DEFAULT; - pfirst = 1; - pflag = 0; - pnum = 0; - - max_pos = 0; - base = format; - ch = *format++; - - /* retrieve the string structure as chunks */ - while (state != DP_S_DONE) { - if (ch == '\0') - state = DP_S_DONE; - - switch(state) { - case DP_S_DEFAULT: - - if (cnk) { - cnk->next = new_chunk(); - cnk = cnk->next; - } else { - cnk = new_chunk(); - } - if (!cnk) goto done; - if (!chunks) chunks = cnk; - - if (ch == '%') { - state = DP_S_FLAGS; - ch = *format++; - } else { - cnk->type = CNK_FMT_STR; - cnk->start = format - base -1; - while ((ch != '\0') && (ch != '%')) ch = *format++; - cnk->len = format - base - cnk->start -1; - } - break; - case DP_S_FLAGS: - switch (ch) { - case '-': - cnk->flags |= DP_F_MINUS; - ch = *format++; - break; - case '+': - cnk->flags |= DP_F_PLUS; - ch = *format++; - break; - case ' ': - cnk->flags |= DP_F_SPACE; - ch = *format++; - break; - case '#': - cnk->flags |= DP_F_NUM; - ch = *format++; - break; - case '0': - cnk->flags |= DP_F_ZERO; - ch = *format++; - break; - case 'I': - /* internationalization not supported yet */ - ch = *format++; - break; - default: - state = DP_S_MIN; - break; - } - break; - case DP_S_MIN: - if (isdigit((unsigned char)ch)) { - cnk->min = 10 * cnk->min + char_to_int (ch); - ch = *format++; - } else if (ch == '$') { - if (!pfirst && !pflag) { - /* parameters must be all positioned or none */ - goto done; - } - if (pfirst) { - pfirst = 0; - pflag = 1; - } - if (cnk->min == 0) /* what ?? */ - goto done; - cnk->num = cnk->min; - cnk->min = 0; - ch = *format++; - } else if (ch == '*') { - if (pfirst) pfirst = 0; - cnk->min_star = new_chunk(); - if (!cnk->min_star) /* out of memory :-( */ - goto done; - cnk->min_star->type = CNK_INT; - if (pflag) { - int num; - ch = *format++; - if (!isdigit((unsigned char)ch)) { - /* parameters must be all positioned or none */ - goto done; - } - for (num = 0; isdigit((unsigned char)ch); ch = *format++) { - num = 10 * num + char_to_int(ch); - } - cnk->min_star->num = num; - if (ch != '$') /* what ?? */ - goto done; - } else { - cnk->min_star->num = ++pnum; - } - max_pos = add_cnk_list_entry(&clist, max_pos, cnk->min_star); - if (max_pos == 0) /* out of memory :-( */ - goto done; - ch = *format++; - state = DP_S_DOT; - } else { - if (pfirst) pfirst = 0; - state = DP_S_DOT; - } - break; - case DP_S_DOT: - if (ch == '.') { - state = DP_S_MAX; - ch = *format++; - } else { - state = DP_S_MOD; - } - break; - case DP_S_MAX: - if (isdigit((unsigned char)ch)) { - if (cnk->max < 0) - cnk->max = 0; - cnk->max = 10 * cnk->max + char_to_int (ch); - ch = *format++; - } else if (ch == '$') { - if (!pfirst && !pflag) { - /* parameters must be all positioned or none */ - goto done; - } - if (cnk->max <= 0) /* what ?? */ - goto done; - cnk->num = cnk->max; - cnk->max = -1; - ch = *format++; - } else if (ch == '*') { - cnk->max_star = new_chunk(); - if (!cnk->max_star) /* out of memory :-( */ - goto done; - cnk->max_star->type = CNK_INT; - if (pflag) { - int num; - ch = *format++; - if (!isdigit((unsigned char)ch)) { - /* parameters must be all positioned or none */ - goto done; - } - for (num = 0; isdigit((unsigned char)ch); ch = *format++) { - num = 10 * num + char_to_int(ch); - } - cnk->max_star->num = num; - if (ch != '$') /* what ?? */ - goto done; - } else { - cnk->max_star->num = ++pnum; - } - max_pos = add_cnk_list_entry(&clist, max_pos, cnk->max_star); - if (max_pos == 0) /* out of memory :-( */ - goto done; - - ch = *format++; - state = DP_S_MOD; - } else { - state = DP_S_MOD; - } - break; - case DP_S_MOD: - switch (ch) { - case 'h': - cnk->cflags = DP_C_SHORT; - ch = *format++; - if (ch == 'h') { - cnk->cflags = DP_C_CHAR; - ch = *format++; - } - break; - case 'l': - cnk->cflags = DP_C_LONG; - ch = *format++; - if (ch == 'l') { /* It's a long long */ - cnk->cflags = DP_C_LLONG; - ch = *format++; - } - break; - case 'L': - cnk->cflags = DP_C_LDOUBLE; - ch = *format++; - break; - case 'z': - cnk->cflags = DP_C_SIZET; - ch = *format++; - break; - default: - break; - } - state = DP_S_CONV; - break; - case DP_S_CONV: - if (cnk->num == 0) cnk->num = ++pnum; - max_pos = add_cnk_list_entry(&clist, max_pos, cnk); - if (max_pos == 0) /* out of memory :-( */ - goto done; - - switch (ch) { - case 'd': - case 'i': - cnk->type = CNK_INT; - break; - case 'o': - cnk->type = CNK_OCTAL; - cnk->flags |= DP_F_UNSIGNED; - break; - case 'u': - cnk->type = CNK_UINT; - cnk->flags |= DP_F_UNSIGNED; - break; - case 'X': - cnk->flags |= DP_F_UP; - case 'x': - cnk->type = CNK_HEX; - cnk->flags |= DP_F_UNSIGNED; - break; - case 'A': - /* hex float not supported yet */ - case 'E': - case 'G': - case 'F': - cnk->flags |= DP_F_UP; - case 'a': - /* hex float not supported yet */ - case 'e': - case 'f': - case 'g': - cnk->type = CNK_FLOAT; - break; - case 'c': - cnk->type = CNK_CHAR; - break; - case 's': - cnk->type = CNK_STRING; - break; - case 'p': - cnk->type = CNK_PTR; - break; - case 'n': - cnk->type = CNK_NUM; - break; - case '%': - cnk->type = CNK_PRCNT; - break; - default: - /* Unknown, bail out*/ - goto done; - } - ch = *format++; - state = DP_S_DEFAULT; - break; - case DP_S_DONE: - break; - default: - /* hmm? */ - break; /* some picky compilers need this */ - } - } - - /* retrieve the format arguments */ - for (pnum = 0; pnum < max_pos; pnum++) { - int i; - - if (clist[pnum].num == 0) { - /* ignoring a parameter should not be permitted - * all parameters must be matched at least once - * BUT seem some system ignore this rule ... - * at least my glibc based system does --SSS - */ -#ifdef DEBUG_SNPRINTF - printf("parameter at position %d not used\n", pnum+1); -#endif - /* eat the parameter */ - va_arg (args, int); - continue; - } - for (i = 1; i < clist[pnum].num; i++) { - if (clist[pnum].chunks[0]->type != clist[pnum].chunks[i]->type) { - /* nooo noo no! - * all the references to a parameter - * must be of the same type - */ - goto done; - } - } - cnk = clist[pnum].chunks[0]; - switch (cnk->type) { - case CNK_INT: - if (cnk->cflags == DP_C_SHORT) - cnk->value = va_arg (args, int); - else if (cnk->cflags == DP_C_LONG) - cnk->value = va_arg (args, long int); - else if (cnk->cflags == DP_C_LLONG) - cnk->value = va_arg (args, LLONG); - else if (cnk->cflags == DP_C_SIZET) - cnk->value = va_arg (args, ssize_t); - else - cnk->value = va_arg (args, int); - - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->value = cnk->value; - } - break; - - case CNK_OCTAL: - case CNK_UINT: - case CNK_HEX: - if (cnk->cflags == DP_C_SHORT) - cnk->value = va_arg (args, unsigned int); - else if (cnk->cflags == DP_C_LONG) - cnk->value = (unsigned long int)va_arg (args, unsigned long int); - else if (cnk->cflags == DP_C_LLONG) - cnk->value = (LLONG)va_arg (args, unsigned LLONG); - else if (cnk->cflags == DP_C_SIZET) - cnk->value = (size_t)va_arg (args, size_t); - else - cnk->value = (unsigned int)va_arg (args, unsigned int); - - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->value = cnk->value; - } - break; - - case CNK_FLOAT: - if (cnk->cflags == DP_C_LDOUBLE) - cnk->fvalue = va_arg (args, LDOUBLE); - else - cnk->fvalue = va_arg (args, double); - - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->fvalue = cnk->fvalue; - } - break; - - case CNK_CHAR: - cnk->value = va_arg (args, int); - - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->value = cnk->value; - } - break; - - case CNK_STRING: - cnk->strvalue = va_arg (args, char *); - if (!cnk->strvalue) cnk->strvalue = "(NULL)"; - - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->strvalue = cnk->strvalue; - } - break; - - case CNK_PTR: - cnk->strvalue = va_arg (args, void *); - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->strvalue = cnk->strvalue; - } - break; - - case CNK_NUM: - if (cnk->cflags == DP_C_CHAR) - cnk->pnum = va_arg (args, char *); - else if (cnk->cflags == DP_C_SHORT) - cnk->pnum = va_arg (args, short int *); - else if (cnk->cflags == DP_C_LONG) - cnk->pnum = va_arg (args, long int *); - else if (cnk->cflags == DP_C_LLONG) - cnk->pnum = va_arg (args, LLONG *); - else if (cnk->cflags == DP_C_SIZET) - cnk->pnum = va_arg (args, ssize_t *); - else - cnk->pnum = va_arg (args, int *); - - for (i = 1; i < clist[pnum].num; i++) { - clist[pnum].chunks[i]->pnum = cnk->pnum; - } - break; - - case CNK_PRCNT: - break; - - default: - /* what ?? */ - goto done; - } - } - /* print out the actual string from chunks */ - currlen = 0; - cnk = chunks; - while (cnk) { - int len, min, max; - - if (cnk->min_star) min = cnk->min_star->value; - else min = cnk->min; - if (cnk->max_star) max = cnk->max_star->value; - else max = cnk->max; - - switch (cnk->type) { - - case CNK_FMT_STR: - if (maxlen != 0 && maxlen > currlen) { - if (maxlen > (currlen + cnk->len)) len = cnk->len; - else len = maxlen - currlen; - - memcpy(&(buffer[currlen]), &(base[cnk->start]), len); - } - currlen += cnk->len; - - break; - - case CNK_INT: - case CNK_UINT: - fmtint (buffer, &currlen, maxlen, cnk->value, 10, min, max, cnk->flags); - break; - - case CNK_OCTAL: - fmtint (buffer, &currlen, maxlen, cnk->value, 8, min, max, cnk->flags); - break; - - case CNK_HEX: - fmtint (buffer, &currlen, maxlen, cnk->value, 16, min, max, cnk->flags); - break; - - case CNK_FLOAT: - fmtfp (buffer, &currlen, maxlen, cnk->fvalue, min, max, cnk->flags); - break; - - case CNK_CHAR: - dopr_outch (buffer, &currlen, maxlen, cnk->value); - break; - - case CNK_STRING: - if (max == -1) { - max = strlen(cnk->strvalue); - } - fmtstr (buffer, &currlen, maxlen, cnk->strvalue, cnk->flags, min, max); - break; - - case CNK_PTR: - fmtint (buffer, &currlen, maxlen, (long)(cnk->strvalue), 16, min, max, cnk->flags); - break; - - case CNK_NUM: - if (cnk->cflags == DP_C_CHAR) - *((char *)(cnk->pnum)) = (char)currlen; - else if (cnk->cflags == DP_C_SHORT) - *((short int *)(cnk->pnum)) = (short int)currlen; - else if (cnk->cflags == DP_C_LONG) - *((long int *)(cnk->pnum)) = (long int)currlen; - else if (cnk->cflags == DP_C_LLONG) - *((LLONG *)(cnk->pnum)) = (LLONG)currlen; - else if (cnk->cflags == DP_C_SIZET) - *((ssize_t *)(cnk->pnum)) = (ssize_t)currlen; - else - *((int *)(cnk->pnum)) = (int)currlen; - break; - - case CNK_PRCNT: - dopr_outch (buffer, &currlen, maxlen, '%'); - break; - - default: - /* what ?? */ - goto done; - } - cnk = cnk->next; - } - if (maxlen != 0) { - if (currlen < maxlen - 1) - buffer[currlen] = '\0'; - else if (maxlen > 0) - buffer[maxlen - 1] = '\0'; - } - ret = currlen; - -done: - va_end(args); - - while (chunks) { - cnk = chunks->next; - free(chunks); - chunks = cnk; - } - if (clist) { - for (pnum = 0; pnum < max_pos; pnum++) { - if (clist[pnum].chunks) free(clist[pnum].chunks); - } - free(clist); - } - return ret; -} - -static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max) -{ - int padlen, strln; /* amount to pad */ - int cnt = 0; - -#ifdef DEBUG_SNPRINTF - printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); -#endif - if (value == 0) { - value = ""; - } - - for (strln = 0; strln < max && value[strln]; ++strln); /* strlen */ - padlen = min - strln; - if (padlen < 0) - padlen = 0; - if (flags & DP_F_MINUS) - padlen = -padlen; /* Left Justify */ - - while (padlen > 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - --padlen; - } - while (*value && (cnt < max)) { - dopr_outch (buffer, currlen, maxlen, *value++); - ++cnt; - } - while (padlen < 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - ++padlen; - } -} - -/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ - -static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - LLONG value, int base, int min, int max, int flags) -{ - int signvalue = 0; - unsigned LLONG uvalue; - char convert[20]; - int place = 0; - int spadlen = 0; /* amount to space pad */ - int zpadlen = 0; /* amount to zero pad */ - int caps = 0; - - if (max < 0) - max = 0; - - uvalue = value; - - if(!(flags & DP_F_UNSIGNED)) { - if( value < 0 ) { - signvalue = '-'; - uvalue = -value; - } else { - if (flags & DP_F_PLUS) /* Do a sign (+/i) */ - signvalue = '+'; - else if (flags & DP_F_SPACE) - signvalue = ' '; - } - } - - if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ - - do { - convert[place++] = - (caps? "0123456789ABCDEF":"0123456789abcdef") - [uvalue % (unsigned)base ]; - uvalue = (uvalue / (unsigned)base ); - } while(uvalue && (place < 20)); - if (place == 20) place--; - convert[place] = 0; - - zpadlen = max - place; - spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); - if (zpadlen < 0) zpadlen = 0; - if (spadlen < 0) spadlen = 0; - if (flags & DP_F_ZERO) { - zpadlen = MAX(zpadlen, spadlen); - spadlen = 0; - } - if (flags & DP_F_MINUS) - spadlen = -spadlen; /* Left Justifty */ - -#ifdef DEBUG_SNPRINTF - printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", - zpadlen, spadlen, min, max, place); -#endif - - /* Spaces */ - while (spadlen > 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - --spadlen; - } - - /* Sign */ - if (signvalue) - dopr_outch (buffer, currlen, maxlen, signvalue); - - /* Zeros */ - if (zpadlen > 0) { - while (zpadlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --zpadlen; - } - } - - /* Digits */ - while (place > 0) - dopr_outch (buffer, currlen, maxlen, convert[--place]); - - /* Left Justified spaces */ - while (spadlen < 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - ++spadlen; - } -} - -static LDOUBLE abs_val(LDOUBLE value) -{ - LDOUBLE result = value; - - if (value < 0) - result = -value; - - return result; -} - -static LDOUBLE POW10(int exp) -{ - LDOUBLE result = 1; - - while (exp) { - result *= 10; - exp--; - } - - return result; -} - -static LLONG ROUND(LDOUBLE value) -{ - LLONG intpart; - - intpart = (LLONG)value; - value = value - intpart; - if (value >= 0.5) intpart++; - - return intpart; -} - -/* a replacement for modf that doesn't need the math library. Should - be portable, but slow */ -static double my_modf(double x0, double *iptr) -{ - int i; - LLONG l=0; - double x = x0; - double f = 1.0; - - for (i=0;i<100;i++) { - l = (long)x; - if (l <= (x+1) && l >= (x-1)) break; - x *= 0.1; - f *= 10.0; - } - - if (i == 100) { - /* yikes! the number is beyond what we can handle. What do we do? */ - (*iptr) = 0; - return 0; - } - - if (i != 0) { - double i2; - double ret; - - ret = my_modf(x0-l*f, &i2); - (*iptr) = l*f + i2; - return ret; - } - - (*iptr) = l; - return x - (*iptr); -} - - -static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags) -{ - int signvalue = 0; - double ufvalue; - char iconvert[311]; - char fconvert[311]; - int iplace = 0; - int fplace = 0; - int padlen = 0; /* amount to pad */ - int zpadlen = 0; - int caps = 0; - int idx; - double intpart; - double fracpart; - double temp; - - /* - * AIX manpage says the default is 0, but Solaris says the default - * is 6, and sprintf on AIX defaults to 6 - */ - if (max < 0) - max = 6; - - ufvalue = abs_val (fvalue); - - if (fvalue < 0) { - signvalue = '-'; - } else { - if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ - signvalue = '+'; - } else { - if (flags & DP_F_SPACE) - signvalue = ' '; - } - } - -#if 0 - if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ -#endif - -#if 0 - if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ -#endif - - /* - * Sorry, we only support 9 digits past the decimal because of our - * conversion method - */ - if (max > 9) - max = 9; - - /* We "cheat" by converting the fractional part to integer by - * multiplying by a factor of 10 - */ - - temp = ufvalue; - my_modf(temp, &intpart); - - fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); - - if (fracpart >= POW10(max)) { - intpart++; - fracpart -= POW10(max); - } - - - /* Convert integer part */ - do { - temp = intpart*0.1; - my_modf(temp, &intpart); - idx = (int) ((temp -intpart +0.05)* 10.0); - /* idx = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ - /* printf ("%llf, %f, %x\n", temp, intpart, idx); */ - iconvert[iplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[idx]; - } while (intpart && (iplace < 311)); - if (iplace == 311) iplace--; - iconvert[iplace] = 0; - - /* Convert fractional part */ - if (fracpart) - { - do { - temp = fracpart*0.1; - my_modf(temp, &fracpart); - idx = (int) ((temp -fracpart +0.05)* 10.0); - /* idx = (int) ((((temp/10) -fracpart) +0.05) *10); */ - /* printf ("%lf, %lf, %ld\n", temp, fracpart, idx ); */ - fconvert[fplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[idx]; - } while(fracpart && (fplace < 311)); - if (fplace == 311) fplace--; - } - fconvert[fplace] = 0; - - /* -1 for decimal point, another -1 if we are printing a sign */ - padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); - zpadlen = max - fplace; - if (zpadlen < 0) zpadlen = 0; - if (padlen < 0) - padlen = 0; - if (flags & DP_F_MINUS) - padlen = -padlen; /* Left Justifty */ - - if ((flags & DP_F_ZERO) && (padlen > 0)) { - if (signvalue) { - dopr_outch (buffer, currlen, maxlen, signvalue); - --padlen; - signvalue = 0; - } - while (padlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --padlen; - } - } - while (padlen > 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - --padlen; - } - if (signvalue) - dopr_outch (buffer, currlen, maxlen, signvalue); - - while (iplace > 0) - dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); - -#ifdef DEBUG_SNPRINTF - printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); -#endif - - /* - * Decimal point. This should probably use locale to find the correct - * char to print out. - */ - if (max > 0) { - dopr_outch (buffer, currlen, maxlen, '.'); - - while (zpadlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --zpadlen; - } - - while (fplace > 0) - dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); - } - - while (padlen < 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - ++padlen; - } -} - -static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) -{ - if (*currlen < maxlen) { - buffer[(*currlen)] = c; - } - (*currlen)++; -} - -static struct pr_chunk *new_chunk(void) { - struct pr_chunk *new_c = (struct pr_chunk *)malloc(sizeof(struct pr_chunk)); - - if (!new_c) - return NULL; - - new_c->type = 0; - new_c->num = 0; - new_c->min = 0; - new_c->min_star = NULL; - new_c->max = -1; - new_c->max_star = NULL; - new_c->flags = 0; - new_c->cflags = 0; - new_c->start = 0; - new_c->len = 0; - new_c->value = 0; - new_c->fvalue = 0; - new_c->strvalue = NULL; - new_c->pnum = NULL; - new_c->next = NULL; - - return new_c; -} - -static int add_cnk_list_entry(struct pr_chunk_x **list, - int max_num, struct pr_chunk *chunk) { - struct pr_chunk_x *l; - struct pr_chunk **c; - int max; - int cnum; - int i, pos; - - if (chunk->num > max_num) { - max = chunk->num; - - if (*list == NULL) { - l = (struct pr_chunk_x *)malloc(sizeof(struct pr_chunk_x) * max); - pos = 0; - } else { - l = (struct pr_chunk_x *)realloc(*list, sizeof(struct pr_chunk_x) * max); - pos = max_num; - } - if (l == NULL) { - for (i = 0; i < max; i++) { - if ((*list)[i].chunks) free((*list)[i].chunks); - } - return 0; - } - for (i = pos; i < max; i++) { - l[i].chunks = NULL; - l[i].num = 0; - } - } else { - l = *list; - max = max_num; - } - - i = chunk->num - 1; - cnum = l[i].num + 1; - if (l[i].chunks == NULL) { - c = (struct pr_chunk **)malloc(sizeof(struct pr_chunk *) * cnum); - } else { - c = (struct pr_chunk **)realloc(l[i].chunks, sizeof(struct pr_chunk *) * cnum); - } - if (c == NULL) { - for (i = 0; i < max; i++) { - if (l[i].chunks) free(l[i].chunks); - } - return 0; - } - c[l[i].num] = chunk; - l[i].chunks = c; - l[i].num = cnum; - - *list = l; - return max; -} - - int vsnprintf (char *str, size_t count, const char *fmt, va_list args) -{ - return dopr(str, count, fmt, args); -} -#endif - -/* yes this really must be a ||. Don't muck with this (tridge) - * - * The logic for these two is that we need our own definition if the - * OS *either* has no definition of *sprintf, or if it does have one - * that doesn't work properly according to the autoconf test. - */ -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) - int snprintf(char *str,size_t count,const char *fmt,...) -{ - size_t ret; - va_list ap; - - va_start(ap, fmt); - ret = vsnprintf(str, count, fmt, ap); - va_end(ap); - return ret; -} -#endif - -#ifndef HAVE_C99_VSNPRINTF - int printf(const char *fmt, ...) -{ - va_list ap; - int ret; - char *s; - - s = NULL; - va_start(ap, fmt); - ret = vasprintf(&s, fmt, ap); - va_end(ap); - - if (s) { - fwrite(s, 1, strlen(s), stdout); - } - free(s); - - return ret; -} -#endif - -#ifndef HAVE_C99_VSNPRINTF - int fprintf(FILE *stream, const char *fmt, ...) -{ - va_list ap; - int ret; - char *s; - - s = NULL; - va_start(ap, fmt); - ret = vasprintf(&s, fmt, ap); - va_end(ap); - - if (s) { - fwrite(s, 1, strlen(s), stream); - } - free(s); - - return ret; -} -#endif - -#endif - -#ifndef HAVE_VASPRINTF - int vasprintf(char **ptr, const char *format, va_list ap) -{ - int ret; - va_list ap2; - - VA_COPY(ap2, ap); - ret = vsnprintf(NULL, 0, format, ap2); - va_end(ap2); - if (ret < 0) return ret; - - (*ptr) = (char *)malloc(ret+1); - if (!*ptr) return -1; - - VA_COPY(ap2, ap); - ret = vsnprintf(*ptr, ret+1, format, ap2); - va_end(ap2); - - return ret; -} -#endif - - -#ifndef HAVE_ASPRINTF - int asprintf(char **ptr, const char *format, ...) -{ - va_list ap; - int ret; - - *ptr = NULL; - va_start(ap, format); - ret = vasprintf(ptr, format, ap); - va_end(ap); - - return ret; -} -#endif - -#ifdef TEST_SNPRINTF - - int sprintf(char *str,const char *fmt,...); - int printf(const char *fmt,...); - - int main (void) -{ - char buf1[1024]; - char buf2[1024]; - char *buf3; - char *fp_fmt[] = { - "%1.1f", - "%-1.5f", - "%1.5f", - "%123.9f", - "%10.5f", - "% 10.5f", - "%+22.9f", - "%+4.9f", - "%01.3f", - "%4f", - "%3.1f", - "%3.2f", - "%.0f", - "%f", - "%-8.8f", - "%-9.9f", - NULL - }; - double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 203.9, 0.96, 0.996, - 0.9996, 1.996, 4.136, 5.030201, 0.00205, - /* END LIST */ 0}; - char *int_fmt[] = { - "%-1.5d", - "%1.5d", - "%123.9d", - "%5.5d", - "%10.5d", - "% 10.5d", - "%+22.33d", - "%01.3d", - "%4d", - "%d", - NULL - }; - long int_nums[] = { -1, 134, 91340, 341, 0203, 1234567890, 0}; - char *str_fmt[] = { - "%10.5s", - "%-10.5s", - "%5.10s", - "%-5.10s", - "%10.1s", - "%0.10s", - "%10.0s", - "%1.10s", - "%s", - "%.1s", - "%.10s", - "%10s", - NULL - }; - char *str_vals[] = {"hello", "a", "", "a longer string", NULL}; -#ifdef HAVE_LONG_LONG - char *ll_fmt[] = { - "%llu", - NULL - }; - LLONG ll_nums[] = { 134, 91340, 341, 0203, 1234567890, 128006186140000000LL, 0}; -#endif - int x, y; - int fail = 0; - int num = 0; - int l1, l2; - char *ss_fmt[] = { - "%zd", - "%zu", - NULL - }; - size_t ss_nums[] = {134, 91340, 123456789, 0203, 1234567890, 0}; - - printf ("Testing snprintf format codes against system sprintf...\n"); - - for (x = 0; fp_fmt[x] ; x++) { - for (y = 0; fp_nums[y] != 0 ; y++) { - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); - l2 = sprintf (buf2, fp_fmt[x], fp_nums[y]); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp (buf1, buf2) || (l1 != l2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - fp_fmt[x], l1, buf1, l2, buf2); - fail++; - } - num++; - } - } - - for (x = 0; int_fmt[x] ; x++) { - for (y = 0; int_nums[y] != 0 ; y++) { - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); - l2 = sprintf (buf2, int_fmt[x], int_nums[y]); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp (buf1, buf2) || (l1 != l2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - int_fmt[x], l1, buf1, l2, buf2); - fail++; - } - num++; - } - } - - for (x = 0; str_fmt[x] ; x++) { - for (y = 0; str_vals[y] != 0 ; y++) { - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); - l2 = sprintf (buf2, str_fmt[x], str_vals[y]); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp (buf1, buf2) || (l1 != l2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - str_fmt[x], l1, buf1, l2, buf2); - fail++; - } - num++; - } - } - -#ifdef HAVE_LONG_LONG - for (x = 0; ll_fmt[x] ; x++) { - for (y = 0; ll_nums[y] != 0 ; y++) { - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), ll_fmt[x], ll_nums[y]); - l2 = sprintf (buf2, ll_fmt[x], ll_nums[y]); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp (buf1, buf2) || (l1 != l2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - ll_fmt[x], l1, buf1, l2, buf2); - fail++; - } - num++; - } - } -#endif - -#define BUFSZ 2048 - - buf1[0] = buf2[0] = '\0'; - if ((buf3 = malloc(BUFSZ)) == NULL) { - fail++; - } else { - num++; - memset(buf3, 'a', BUFSZ); - snprintf(buf1, sizeof(buf1), "%.*s", 1, buf3); - buf1[1023] = '\0'; - if (strcmp(buf1, "a") != 0) { - printf("length limit buf1 '%s' expected 'a'\n", buf1); - fail++; - } - } - - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9); - l2 = sprintf(buf2, "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp(buf1, buf2) || (l1 != l2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); - fail++; - } - - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9); - l2 = sprintf(buf2, "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp(buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); - fail++; - } - - for (x = 0; ss_fmt[x] ; x++) { - for (y = 0; ss_nums[y] != 0 ; y++) { - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), ss_fmt[x], ss_nums[y]); - l2 = sprintf (buf2, ss_fmt[x], ss_nums[y]); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp (buf1, buf2) || (l1 != l2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - ss_fmt[x], l1, buf1, l2, buf2); - fail++; - } - num++; - } - } -#if 0 - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890); - l2 = sprintf(buf2, "%lld", (LLONG)1234567890); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp(buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - "%lld", l1, buf1, l2, buf2); - fail++; - } - - buf1[0] = buf2[0] = '\0'; - l1 = snprintf(buf1, sizeof(buf1), "%Lf", (LDOUBLE)890.1234567890123); - l2 = sprintf(buf2, "%Lf", (LDOUBLE)890.1234567890123); - buf1[1023] = buf2[1023] = '\0'; - if (strcmp(buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", - "%Lf", l1, buf1, l2, buf2); - fail++; - } -#endif - printf ("%d tests failed out of %d.\n", fail, num); - - printf("seeing how many digits we support\n"); - { - double v0 = 0.12345678901234567890123456789012345678901; - for (x=0; x<100; x++) { - double p = pow(10, x); - double r = v0*p; - snprintf(buf1, sizeof(buf1), "%1.1f", r); - sprintf(buf2, "%1.1f", r); - if (strcmp(buf1, buf2)) { - printf("we seem to support %d digits\n", x-1); - break; - } - } - } - - return 0; -} -#endif /* TEST_SNPRINTF */ diff --git a/source4/lib/replace/socket.c b/source4/lib/replace/socket.c deleted file mode 100644 index 35e975fce7..0000000000 --- a/source4/lib/replace/socket.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * - * Dummy replacements for socket functions. - * - * 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 . - */ - -#include "replace.h" -#include "system/network.h" - -int rep_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) -{ - errno = ENOSYS; - return -1; -} - -struct hostent *rep_gethostbyname(const char *name) -{ - errno = ENOSYS; - return NULL; -} diff --git a/source4/lib/replace/socketpair.c b/source4/lib/replace/socketpair.c deleted file mode 100644 index c775730952..0000000000 --- a/source4/lib/replace/socketpair.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * replacement routines for broken systems - * Copyright (C) Jelmer Vernooij 2006 - * Copyright (C) Michael Adam 2008 - * - * ** NOTE! The following LGPL license applies to the replace - * ** library. This does NOT imply that all of Samba is released - * ** under the LGPL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "replace.h" -#include "system/network.h" - -int rep_socketpair(int d, int type, int protocol, int sv[2]) -{ - if (d != AF_UNIX) { - errno = EAFNOSUPPORT; - return -1; - } - - if (protocol != 0) { - errno = EPROTONOSUPPORT; - return -1; - } - - if (type != SOCK_STREAM) { - errno = EOPNOTSUPP; - return -1; - } - - return pipe(sv); -} diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c deleted file mode 100644 index 0e40f7561a..0000000000 --- a/source4/lib/replace/strptime.c +++ /dev/null @@ -1,990 +0,0 @@ -/* Convert a string representation of time to a time value. - Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1996. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 3 of the - License, or (at your option) any later version. - - The GNU C Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - see . */ - -/* XXX This version of the implementation is not really complete. - Some of the fields cannot add information alone. But if seeing - some of them in the same format (such as year, week and weekday) - this is enough information for determining the date. */ - -#include "replace.h" -#include "system/locale.h" -#include "system/time.h" - -#ifndef __P -# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) -# define __P(args) args -# else -# define __P(args) () -# endif /* GCC. */ -#endif /* Not __P. */ - -#if ! HAVE_LOCALTIME_R && ! defined localtime_r -# ifdef _LIBC -# define localtime_r __localtime_r -# else -/* Approximate localtime_r as best we can in its absence. */ -# define localtime_r my_localtime_r -static struct tm *localtime_r __P ((const time_t *, struct tm *)); -static struct tm * -localtime_r (t, tp) - const time_t *t; - struct tm *tp; -{ - struct tm *l = localtime (t); - if (! l) - return 0; - *tp = *l; - return tp; -} -# endif /* ! _LIBC */ -#endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */ - - -#define match_char(ch1, ch2) if (ch1 != ch2) return NULL -#if defined __GNUC__ && __GNUC__ >= 2 -# define match_string(cs1, s2) \ - ({ size_t len = strlen (cs1); \ - int result = strncasecmp ((cs1), (s2), len) == 0; \ - if (result) (s2) += len; \ - result; }) -#else -/* Oh come on. Get a reasonable compiler. */ -# define match_string(cs1, s2) \ - (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) -#endif -/* We intentionally do not use isdigit() for testing because this will - lead to problems with the wide character version. */ -#define get_number(from, to, n) \ - do { \ - int __n = n; \ - val = 0; \ - while (*rp == ' ') \ - ++rp; \ - if (*rp < '0' || *rp > '9') \ - return NULL; \ - do { \ - val *= 10; \ - val += *rp++ - '0'; \ - } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9'); \ - if (val < from || val > to) \ - return NULL; \ - } while (0) -#ifdef _NL_CURRENT -# define get_alt_number(from, to, n) \ - ({ \ - __label__ do_normal; \ - if (*decided != raw) \ - { \ - const char *alts = _NL_CURRENT (LC_TIME, ALT_DIGITS); \ - int __n = n; \ - int any = 0; \ - while (*rp == ' ') \ - ++rp; \ - val = 0; \ - do { \ - val *= 10; \ - while (*alts != '\0') \ - { \ - size_t len = strlen (alts); \ - if (strncasecmp (alts, rp, len) == 0) \ - break; \ - alts += len + 1; \ - ++val; \ - } \ - if (*alts == '\0') \ - { \ - if (*decided == not && ! any) \ - goto do_normal; \ - /* If we haven't read anything it's an error. */ \ - if (! any) \ - return NULL; \ - /* Correct the premature multiplication. */ \ - val /= 10; \ - break; \ - } \ - else \ - *decided = loc; \ - } while (--__n > 0 && val * 10 <= to); \ - if (val < from || val > to) \ - return NULL; \ - } \ - else \ - { \ - do_normal: \ - get_number (from, to, n); \ - } \ - 0; \ - }) -#else -# define get_alt_number(from, to, n) \ - /* We don't have the alternate representation. */ \ - get_number(from, to, n) -#endif -#define recursive(new_fmt) \ - (*(new_fmt) != '\0' \ - && (rp = strptime_internal (rp, (new_fmt), tm, decided, era_cnt)) != NULL) - - -#ifdef _LIBC -/* This is defined in locale/C-time.c in the GNU libc. */ -extern const struct locale_data _nl_C_LC_TIME; -extern const unsigned short int __mon_yday[2][13]; - -# define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string) -# define ab_weekday_name \ - (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string) -# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string) -# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) -# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) -# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) -# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) -# define HERE_PM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (PM_STR)].string) -# define HERE_T_FMT_AMPM \ - (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string) -# define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string) - -# define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n) -#else -static char const weekday_name[][10] = - { - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" - }; -static char const ab_weekday_name[][4] = - { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" - }; -static char const month_name[][10] = - { - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - }; -static char const ab_month_name[][4] = - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; -# define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y" -# define HERE_D_FMT "%m/%d/%y" -# define HERE_AM_STR "AM" -# define HERE_PM_STR "PM" -# define HERE_T_FMT_AMPM "%I:%M:%S %p" -# define HERE_T_FMT "%H:%M:%S" - -static const unsigned short int __mon_yday[2][13] = - { - /* Normal years. */ - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, - /* Leap years. */ - { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } - }; -#endif - -/* Status of lookup: do we use the locale data or the raw data? */ -enum locale_status { not, loc, raw }; - - -#ifndef __isleap -/* Nonzero if YEAR is a leap year (every 4 years, - except every 100th isn't, and every 400th is). */ -# define __isleap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) -#endif - -/* Compute the day of the week. */ -static void -day_of_the_week (struct tm *tm) -{ - /* We know that January 1st 1970 was a Thursday (= 4). Compute the - the difference between this data in the one on TM and so determine - the weekday. */ - int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2); - int wday = (-473 - + (365 * (tm->tm_year - 70)) - + (corr_year / 4) - - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0) - + (((corr_year / 4) / 25) / 4) - + __mon_yday[0][tm->tm_mon] - + tm->tm_mday - 1); - tm->tm_wday = ((wday % 7) + 7) % 7; -} - -/* Compute the day of the year. */ -static void -day_of_the_year (struct tm *tm) -{ - tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon] - + (tm->tm_mday - 1)); -} - -static char * -#ifdef _LIBC -internal_function -#endif -strptime_internal __P ((const char *rp, const char *fmt, struct tm *tm, - enum locale_status *decided, int era_cnt)); - -static char * -#ifdef _LIBC -internal_function -#endif -strptime_internal (rp, fmt, tm, decided, era_cnt) - const char *rp; - const char *fmt; - struct tm *tm; - enum locale_status *decided; - int era_cnt; -{ - const char *rp_backup; - int cnt; - size_t val; - int have_I, is_pm; - int century, want_century; - int want_era; - int have_wday, want_xday; - int have_yday; - int have_mon, have_mday; -#ifdef _NL_CURRENT - size_t num_eras; -#endif - struct era_entry *era; - - have_I = is_pm = 0; - century = -1; - want_century = 0; - want_era = 0; - era = NULL; - - have_wday = want_xday = have_yday = have_mon = have_mday = 0; - - while (*fmt != '\0') - { - /* A white space in the format string matches 0 more or white - space in the input string. */ - if (isspace (*fmt)) - { - while (isspace (*rp)) - ++rp; - ++fmt; - continue; - } - - /* Any character but `%' must be matched by the same character - in the iput string. */ - if (*fmt != '%') - { - match_char (*fmt++, *rp++); - continue; - } - - ++fmt; -#ifndef _NL_CURRENT - /* We need this for handling the `E' modifier. */ - start_over: -#endif - - /* Make back up of current processing pointer. */ - rp_backup = rp; - - switch (*fmt++) - { - case '%': - /* Match the `%' character itself. */ - match_char ('%', *rp++); - break; - case 'a': - case 'A': - /* Match day of week. */ - for (cnt = 0; cnt < 7; ++cnt) - { -#ifdef _NL_CURRENT - if (*decided !=raw) - { - if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp)) - { - if (*decided == not - && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt), - weekday_name[cnt])) - *decided = loc; - break; - } - if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp)) - { - if (*decided == not - && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), - ab_weekday_name[cnt])) - *decided = loc; - break; - } - } -#endif - if (*decided != loc - && (match_string (weekday_name[cnt], rp) - || match_string (ab_weekday_name[cnt], rp))) - { - *decided = raw; - break; - } - } - if (cnt == 7) - /* Does not match a weekday name. */ - return NULL; - tm->tm_wday = cnt; - have_wday = 1; - break; - case 'b': - case 'B': - case 'h': - /* Match month name. */ - for (cnt = 0; cnt < 12; ++cnt) - { -#ifdef _NL_CURRENT - if (*decided !=raw) - { - if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp)) - { - if (*decided == not - && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt), - month_name[cnt])) - *decided = loc; - break; - } - if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp)) - { - if (*decided == not - && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), - ab_month_name[cnt])) - *decided = loc; - break; - } - } -#endif - if (match_string (month_name[cnt], rp) - || match_string (ab_month_name[cnt], rp)) - { - *decided = raw; - break; - } - } - if (cnt == 12) - /* Does not match a month name. */ - return NULL; - tm->tm_mon = cnt; - want_xday = 1; - break; - case 'c': - /* Match locale's date and time format. */ -#ifdef _NL_CURRENT - if (*decided != raw) - { - if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT))) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (*decided == not && - strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT)) - *decided = loc; - want_xday = 1; - break; - } - *decided = raw; - } -#endif - if (!recursive (HERE_D_T_FMT)) - return NULL; - want_xday = 1; - break; - case 'C': - /* Match century number. */ -#ifdef _NL_CURRENT - match_century: -#endif - get_number (0, 99, 2); - century = val; - want_xday = 1; - break; - case 'd': - case 'e': - /* Match day of month. */ - get_number (1, 31, 2); - tm->tm_mday = val; - have_mday = 1; - want_xday = 1; - break; - case 'F': - if (!recursive ("%Y-%m-%d")) - return NULL; - want_xday = 1; - break; - case 'x': -#ifdef _NL_CURRENT - if (*decided != raw) - { - if (!recursive (_NL_CURRENT (LC_TIME, D_FMT))) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (*decided == not - && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT)) - *decided = loc; - want_xday = 1; - break; - } - *decided = raw; - } -#endif - /* Fall through. */ - case 'D': - /* Match standard day format. */ - if (!recursive (HERE_D_FMT)) - return NULL; - want_xday = 1; - break; - case 'k': - case 'H': - /* Match hour in 24-hour clock. */ - get_number (0, 23, 2); - tm->tm_hour = val; - have_I = 0; - break; - case 'I': - /* Match hour in 12-hour clock. */ - get_number (1, 12, 2); - tm->tm_hour = val % 12; - have_I = 1; - break; - case 'j': - /* Match day number of year. */ - get_number (1, 366, 3); - tm->tm_yday = val - 1; - have_yday = 1; - break; - case 'm': - /* Match number of month. */ - get_number (1, 12, 2); - tm->tm_mon = val - 1; - have_mon = 1; - want_xday = 1; - break; - case 'M': - /* Match minute. */ - get_number (0, 59, 2); - tm->tm_min = val; - break; - case 'n': - case 't': - /* Match any white space. */ - while (isspace (*rp)) - ++rp; - break; - case 'p': - /* Match locale's equivalent of AM/PM. */ -#ifdef _NL_CURRENT - if (*decided != raw) - { - if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp)) - { - if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR)) - *decided = loc; - break; - } - if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp)) - { - if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR)) - *decided = loc; - is_pm = 1; - break; - } - *decided = raw; - } -#endif - if (!match_string (HERE_AM_STR, rp)) { - if (match_string (HERE_PM_STR, rp)) { - is_pm = 1; - } else { - return NULL; - } - } - break; - case 'r': -#ifdef _NL_CURRENT - if (*decided != raw) - { - if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM))) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (*decided == not && - strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM), - HERE_T_FMT_AMPM)) - *decided = loc; - break; - } - *decided = raw; - } -#endif - if (!recursive (HERE_T_FMT_AMPM)) - return NULL; - break; - case 'R': - if (!recursive ("%H:%M")) - return NULL; - break; - case 's': - { - /* The number of seconds may be very high so we cannot use - the `get_number' macro. Instead read the number - character for character and construct the result while - doing this. */ - time_t secs = 0; - if (*rp < '0' || *rp > '9') - /* We need at least one digit. */ - return NULL; - - do - { - secs *= 10; - secs += *rp++ - '0'; - } - while (*rp >= '0' && *rp <= '9'); - - if (localtime_r (&secs, tm) == NULL) - /* Error in function. */ - return NULL; - } - break; - case 'S': - get_number (0, 61, 2); - tm->tm_sec = val; - break; - case 'X': -#ifdef _NL_CURRENT - if (*decided != raw) - { - if (!recursive (_NL_CURRENT (LC_TIME, T_FMT))) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT)) - *decided = loc; - break; - } - *decided = raw; - } -#endif - /* Fall through. */ - case 'T': - if (!recursive (HERE_T_FMT)) - return NULL; - break; - case 'u': - get_number (1, 7, 1); - tm->tm_wday = val % 7; - have_wday = 1; - break; - case 'g': - get_number (0, 99, 2); - /* XXX This cannot determine any field in TM. */ - break; - case 'G': - if (*rp < '0' || *rp > '9') - return NULL; - /* XXX Ignore the number since we would need some more - information to compute a real date. */ - do - ++rp; - while (*rp >= '0' && *rp <= '9'); - break; - case 'U': - case 'V': - case 'W': - get_number (0, 53, 2); - /* XXX This cannot determine any field in TM without some - information. */ - break; - case 'w': - /* Match number of weekday. */ - get_number (0, 6, 1); - tm->tm_wday = val; - have_wday = 1; - break; - case 'y': -#ifdef _NL_CURRENT - match_year_in_century: -#endif - /* Match year within century. */ - get_number (0, 99, 2); - /* The "Year 2000: The Millennium Rollover" paper suggests that - values in the range 69-99 refer to the twentieth century. */ - tm->tm_year = val >= 69 ? val : val + 100; - /* Indicate that we want to use the century, if specified. */ - want_century = 1; - want_xday = 1; - break; - case 'Y': - /* Match year including century number. */ - get_number (0, 9999, 4); - tm->tm_year = val - 1900; - want_century = 0; - want_xday = 1; - break; - case 'Z': - /* XXX How to handle this? */ - break; - case 'E': -#ifdef _NL_CURRENT - switch (*fmt++) - { - case 'c': - /* Match locale's alternate date and time format. */ - if (*decided != raw) - { - const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT); - - if (*fmt == '\0') - fmt = _NL_CURRENT (LC_TIME, D_T_FMT); - - if (!recursive (fmt)) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (strcmp (fmt, HERE_D_T_FMT)) - *decided = loc; - want_xday = 1; - break; - } - *decided = raw; - } - /* The C locale has no era information, so use the - normal representation. */ - if (!recursive (HERE_D_T_FMT)) - return NULL; - want_xday = 1; - break; - case 'C': - if (*decided != raw) - { - if (era_cnt >= 0) - { - era = _nl_select_era_entry (era_cnt); - if (match_string (era->era_name, rp)) - { - *decided = loc; - break; - } - else - return NULL; - } - else - { - num_eras = _NL_CURRENT_WORD (LC_TIME, - _NL_TIME_ERA_NUM_ENTRIES); - for (era_cnt = 0; era_cnt < (int) num_eras; - ++era_cnt, rp = rp_backup) - { - era = _nl_select_era_entry (era_cnt); - if (match_string (era->era_name, rp)) - { - *decided = loc; - break; - } - } - if (era_cnt == (int) num_eras) - { - era_cnt = -1; - if (*decided == loc) - return NULL; - } - else - break; - } - - *decided = raw; - } - /* The C locale has no era information, so use the - normal representation. */ - goto match_century; - case 'y': - if (*decided == raw) - goto match_year_in_century; - - get_number(0, 9999, 4); - tm->tm_year = val; - want_era = 1; - want_xday = 1; - break; - case 'Y': - if (*decided != raw) - { - num_eras = _NL_CURRENT_WORD (LC_TIME, - _NL_TIME_ERA_NUM_ENTRIES); - for (era_cnt = 0; era_cnt < (int) num_eras; - ++era_cnt, rp = rp_backup) - { - era = _nl_select_era_entry (era_cnt); - if (recursive (era->era_format)) - break; - } - if (era_cnt == (int) num_eras) - { - era_cnt = -1; - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - *decided = loc; - era_cnt = -1; - break; - } - - *decided = raw; - } - get_number (0, 9999, 4); - tm->tm_year = val - 1900; - want_century = 0; - want_xday = 1; - break; - case 'x': - if (*decided != raw) - { - const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT); - - if (*fmt == '\0') - fmt = _NL_CURRENT (LC_TIME, D_FMT); - - if (!recursive (fmt)) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (strcmp (fmt, HERE_D_FMT)) - *decided = loc; - break; - } - *decided = raw; - } - if (!recursive (HERE_D_FMT)) - return NULL; - break; - case 'X': - if (*decided != raw) - { - const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT); - - if (*fmt == '\0') - fmt = _NL_CURRENT (LC_TIME, T_FMT); - - if (!recursive (fmt)) - { - if (*decided == loc) - return NULL; - else - rp = rp_backup; - } - else - { - if (strcmp (fmt, HERE_T_FMT)) - *decided = loc; - break; - } - *decided = raw; - } - if (!recursive (HERE_T_FMT)) - return NULL; - break; - default: - return NULL; - } - break; -#else - /* We have no information about the era format. Just use - the normal format. */ - if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y' - && *fmt != 'x' && *fmt != 'X') - /* This is an illegal format. */ - return NULL; - - goto start_over; -#endif - case 'O': - switch (*fmt++) - { - case 'd': - case 'e': - /* Match day of month using alternate numeric symbols. */ - get_alt_number (1, 31, 2); - tm->tm_mday = val; - have_mday = 1; - want_xday = 1; - break; - case 'H': - /* Match hour in 24-hour clock using alternate numeric - symbols. */ - get_alt_number (0, 23, 2); - tm->tm_hour = val; - have_I = 0; - break; - case 'I': - /* Match hour in 12-hour clock using alternate numeric - symbols. */ - get_alt_number (1, 12, 2); - tm->tm_hour = val - 1; - have_I = 1; - break; - case 'm': - /* Match month using alternate numeric symbols. */ - get_alt_number (1, 12, 2); - tm->tm_mon = val - 1; - have_mon = 1; - want_xday = 1; - break; - case 'M': - /* Match minutes using alternate numeric symbols. */ - get_alt_number (0, 59, 2); - tm->tm_min = val; - break; - case 'S': - /* Match seconds using alternate numeric symbols. */ - get_alt_number (0, 61, 2); - tm->tm_sec = val; - break; - case 'U': - case 'V': - case 'W': - get_alt_number (0, 53, 2); - /* XXX This cannot determine any field in TM without - further information. */ - break; - case 'w': - /* Match number of weekday using alternate numeric symbols. */ - get_alt_number (0, 6, 1); - tm->tm_wday = val; - have_wday = 1; - break; - case 'y': - /* Match year within century using alternate numeric symbols. */ - get_alt_number (0, 99, 2); - tm->tm_year = val >= 69 ? val : val + 100; - want_xday = 1; - break; - default: - return NULL; - } - break; - default: - return NULL; - } - } - - if (have_I && is_pm) - tm->tm_hour += 12; - - if (century != -1) - { - if (want_century) - tm->tm_year = tm->tm_year % 100 + (century - 19) * 100; - else - /* Only the century, but not the year. Strange, but so be it. */ - tm->tm_year = (century - 19) * 100; - } - -#ifdef _NL_CURRENT - if (era_cnt != -1) - { - era = _nl_select_era_entry(era_cnt); - if (want_era) - tm->tm_year = (era->start_date[0] - + ((tm->tm_year - era->offset) - * era->absolute_direction)); - else - /* Era start year assumed. */ - tm->tm_year = era->start_date[0]; - } - else -#endif - if (want_era) - return NULL; - - if (want_xday && !have_wday) - { - if ( !(have_mon && have_mday) && have_yday) - { - /* We don't have tm_mon and/or tm_mday, compute them. */ - int t_mon = 0; - while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday) - t_mon++; - if (!have_mon) - tm->tm_mon = t_mon - 1; - if (!have_mday) - tm->tm_mday = - (tm->tm_yday - - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); - } - day_of_the_week (tm); - } - if (want_xday && !have_yday) - day_of_the_year (tm); - - return discard_const_p(char, rp); -} - - -char *rep_strptime(const char *buf, const char *format, struct tm *tm) -{ - enum locale_status decided; - -#ifdef _NL_CURRENT - decided = not; -#else - decided = raw; -#endif - return strptime_internal (buf, format, tm, &decided, -1); -} diff --git a/source4/lib/replace/strptime.m4 b/source4/lib/replace/strptime.m4 deleted file mode 100644 index da22fc5a97..0000000000 --- a/source4/lib/replace/strptime.m4 +++ /dev/null @@ -1,13 +0,0 @@ -AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_OK,[ - AC_TRY_RUN([ - #define LIBREPLACE_CONFIGURE_TEST_STRPTIME - #include "$libreplacedir/test/strptime.c" - ], - [libreplace_cv_STRPTIME_OK=yes], - [libreplace_cv_STRPTIME_OK=no], - [libreplace_cv_STRPTIME_OK="assuming not"]) -]) -if test x"$libreplace_cv_STRPTIME_OK" != x"yes"; then - AC_DEFINE(REPLACE_STRPTIME,1,[Whether strptime should be replaced]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} strptime.o" -fi diff --git a/source4/lib/replace/system/README b/source4/lib/replace/system/README deleted file mode 100644 index 69a2b80b56..0000000000 --- a/source4/lib/replace/system/README +++ /dev/null @@ -1,4 +0,0 @@ -This directory contains wrappers around logical groups of system -include files. The idea is to avoid #ifdef blocks in the main code, -and instead put all the necessary conditional includes in subsystem -specific header files in this directory. diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h deleted file mode 100644 index 784d77fa28..0000000000 --- a/source4/lib/replace/system/aio.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _system_aio_h -#define _system_aio_h -/* - Unix SMB/CIFS implementation. - - AIO system include wrappers - - Copyright (C) Andrew Tridgell 2006 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#ifdef HAVE_LIBAIO_H -#include -#endif - -#endif diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h deleted file mode 100644 index a7b78f0275..0000000000 --- a/source4/lib/replace/system/capability.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _system_capability_h -#define _system_capability_h -/* - Unix SMB/CIFS implementation. - - capability system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#ifdef HAVE_SYS_CAPABILITY_H - -#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) && !defined(_PPC_STATFS_H) -#define _I386_STATFS_H -#define _PPC_STATFS_H -#define BROKEN_REDHAT_7_STATFS_WORKAROUND -#endif - -#if defined(BROKEN_RHEL5_SYS_CAP_HEADER) && !defined(_LINUX_TYPES_H) -#define BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND -#endif - -#include - -#ifdef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND -#undef _LINUX_TYPES_H -#undef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND -#endif - -#ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND -#undef _PPC_STATFS_H -#undef _I386_STATFS_H -#undef BROKEN_REDHAT_7_STATFS_WORKAROUND -#endif - -#endif - -#endif diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 deleted file mode 100644 index 5c9b53d5c5..0000000000 --- a/source4/lib/replace/system/config.m4 +++ /dev/null @@ -1,130 +0,0 @@ -# filesys -AC_HEADER_DIRENT -AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/resource.h sys/ioctl.h sys/mode.h sys/filio.h sys/fs/s5param.h sys/filsys.h) -AC_CHECK_HEADERS(sys/acl.h acl/libacl.h) - -# select -AC_CHECK_HEADERS(sys/select.h) - -# time -AC_CHECK_HEADERS(sys/time.h utime.h) -AC_HEADER_TIME -AC_CHECK_FUNCS(utime utimes) - -# wait -AC_HEADER_SYS_WAIT - -# capability -AC_CHECK_HEADERS(sys/capability.h) - -case "$host_os" in -*linux*) -AC_CACHE_CHECK([for broken RedHat 7.2 system header files],libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ -AC_TRY_COMPILE([ - #ifdef HAVE_SYS_VFS_H - #include - #endif - #ifdef HAVE_SYS_CAPABILITY_H - #include - #endif - ],[ - int i; - ], - libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, - libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes -)]) -if test x"$libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then - AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) -fi - -AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ -AC_TRY_COMPILE([ - #ifdef HAVE_SYS_CAPABILITY_H - #include - #endif - #include - ],[ - __s8 i; - ], - libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, - libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes -)]) -if test x"$libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then - AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h]) -fi -;; -esac - -# passwd -AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h) -AC_CHECK_FUNCS(getpwnam_r getpwuid_r getpwent_r) -AC_HAVE_DECL(getpwent_r, [ - #include - #include - ]) -AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)], - [ - #ifndef HAVE_GETPWENT_R_DECL - #error missing getpwent_r prototype - #endif - return NULL; - ],[ - AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r solaris function prototype]) - ],[],[ - #include - #include - ]) -AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, size_t buflen)], - [ - #ifndef HAVE_GETPWENT_R_DECL - #error missing getpwent_r prototype - #endif - return NULL; - ],[ - AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r irix (similar to solaris) function prototype]) - ],[],[ - #include - #include - ]) -AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r) -AC_HAVE_DECL(getgrent_r, [ - #include - #include - ]) -AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, int buflen)], - [ - #ifndef HAVE_GETGRENT_R_DECL - #error missing getgrent_r prototype - #endif - return NULL; - ],[ - AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r solaris function prototype]) - ],[],[ - #include - #include - ]) - -AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, size_t buflen)], - [ - #ifndef HAVE_GETGRENT_R_DECL - #error missing getgrent_r prototype - #endif - return NULL; - ],[ - AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r irix (similar to solaris) function prototype]) - ],[],[ - #include - #include - ]) - -# locale -AC_CHECK_HEADERS(ctype.h locale.h) - -# glob -AC_CHECK_HEADERS(fnmatch.h) - -# shmem -AC_CHECK_HEADERS(sys/ipc.h sys/mman.h sys/shm.h ) - -# terminal -AC_CHECK_HEADERS(termios.h termio.h sys/termio.h ) diff --git a/source4/lib/replace/system/dir.h b/source4/lib/replace/system/dir.h deleted file mode 100644 index dec2d54649..0000000000 --- a/source4/lib/replace/system/dir.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _system_dir_h -#define _system_dir_h -/* - Unix SMB/CIFS implementation. - - directory system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#if HAVE_DIRENT_H -# include -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -# define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen -# if HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -#endif - -#ifndef HAVE_MKDIR_MODE -#define mkdir(dir, mode) mkdir(dir) -#endif - -/* Test whether a file name is the "." or ".." directory entries. - * These really should be inline functions. - */ -#ifndef ISDOT -#define ISDOT(path) ( \ - *((const char *)(path)) == '.' && \ - *(((const char *)(path)) + 1) == '\0' \ - ) -#endif - -#ifndef ISDOTDOT -#define ISDOTDOT(path) ( \ - *((const char *)(path)) == '.' && \ - *(((const char *)(path)) + 1) == '.' && \ - *(((const char *)(path)) + 2) == '\0' \ - ) -#endif - -#endif diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h deleted file mode 100644 index 4bf1f64865..0000000000 --- a/source4/lib/replace/system/filesys.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef _system_filesys_h -#define _system_filesys_h -/* - Unix SMB/CIFS implementation. - - filesystem system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#include -#include - -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -#ifdef HAVE_SYS_MOUNT_H -#include -#endif - -#ifdef HAVE_MNTENT_H -#include -#endif - -#ifdef HAVE_SYS_VFS_H -#include -#endif - -#ifdef HAVE_SYS_ACL_H -#include -#endif - -#ifdef HAVE_ACL_LIBACL_H -#include -#endif - -#ifdef HAVE_SYS_FS_S5PARAM_H -#include -#endif - -#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY) -#include -#endif - -#ifdef HAVE_SYS_STATFS_H -# include -#endif - -#ifdef HAVE_DUSTAT_H -#include -#endif - -#ifdef HAVE_SYS_STATVFS_H -#include -#endif - -#ifdef HAVE_SYS_FILIO_H -#include -#endif - -#include - -#ifdef HAVE_FCNTL_H -#include -#else -#ifdef HAVE_SYS_FCNTL_H -#include -#endif -#endif - -#ifdef HAVE_SYS_MODE_H -/* apparently AIX needs this for S_ISLNK */ -#ifndef S_ISLNK -#include -#endif -#endif - -#ifdef HAVE_SYS_IOCTL_H -#include -#endif - -/* - * Veritas File System. Often in addition to native. - * Quotas different. - */ -#if defined(HAVE_SYS_FS_VX_QUOTA_H) -#define VXFS_QUOTA -#endif - -#if HAVE_SYS_ATTRIBUTES_H -#include -#endif - -/* mutually exclusive (SuSE 8.2) */ -#if HAVE_ATTR_XATTR_H -#include -#elif HAVE_SYS_XATTR_H -#include -#endif - - -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif - -/* Some POSIX definitions for those without */ - -#ifndef S_IFDIR -#define S_IFDIR 0x4000 -#endif -#ifndef S_ISDIR -#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR) -#endif -#ifndef S_IRWXU -#define S_IRWXU 00700 /* read, write, execute: owner */ -#endif -#ifndef S_IRUSR -#define S_IRUSR 00400 /* read permission: owner */ -#endif -#ifndef S_IWUSR -#define S_IWUSR 00200 /* write permission: owner */ -#endif -#ifndef S_IXUSR -#define S_IXUSR 00100 /* execute permission: owner */ -#endif -#ifndef S_IRWXG -#define S_IRWXG 00070 /* read, write, execute: group */ -#endif -#ifndef S_IRGRP -#define S_IRGRP 00040 /* read permission: group */ -#endif -#ifndef S_IWGRP -#define S_IWGRP 00020 /* write permission: group */ -#endif -#ifndef S_IXGRP -#define S_IXGRP 00010 /* execute permission: group */ -#endif -#ifndef S_IRWXO -#define S_IRWXO 00007 /* read, write, execute: other */ -#endif -#ifndef S_IROTH -#define S_IROTH 00004 /* read permission: other */ -#endif -#ifndef S_IWOTH -#define S_IWOTH 00002 /* write permission: other */ -#endif -#ifndef S_IXOTH -#define S_IXOTH 00001 /* execute permission: other */ -#endif - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -#ifndef MAXPATHLEN -#define MAXPATHLEN 256 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#endif diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h deleted file mode 100644 index 3c8a71f2f7..0000000000 --- a/source4/lib/replace/system/iconv.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _system_iconv_h -#define _system_iconv_h -/* - Unix SMB/CIFS implementation. - - iconv memory system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#if !defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -#define HAVE_ICONV -#endif - -#if !defined(HAVE_GICONV) && defined(HAVE_GICONV_H) -#define HAVE_GICONV -#endif - -#if !defined(HAVE_BICONV) && defined(HAVE_BICONV_H) -#define HAVE_BICONV -#endif - -#ifdef HAVE_NATIVE_ICONV -#if defined(HAVE_ICONV) -#include -#elif defined(HAVE_GICONV) -#include -#elif defined(HAVE_BICONV) -#include -#endif -#endif /* HAVE_NATIVE_ICONV */ - -/* needed for some systems without iconv. Doesn't really matter - what error code we use */ -#ifndef EILSEQ -#define EILSEQ EIO -#endif - -#endif diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h deleted file mode 100644 index 2981024bee..0000000000 --- a/source4/lib/replace/system/kerberos.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef _system_kerberos_h -#define _system_kerberos_h - -/* - Unix SMB/CIFS implementation. - - kerberos system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef HAVE_KRB5 -/* Whether the krb5_address struct has a addrtype property */ -/* #undef HAVE_ADDRTYPE_IN_KRB5_ADDRESS */ -/* Whether the krb5_address struct has a addr_type property */ -#define HAVE_ADDR_TYPE_IN_KRB5_ADDRESS 1 -/* Define to 1 if you have the `gsskrb5_extract_authz_data_from_sec_context' */ -#define HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT 1 -/* Define to 1 if you have the `gsskrb5_get_initiator_subkey' function. */ -#define HAVE_GSSKRB5_GET_INITIATOR_SUBKEY 1 -/* Define to 1 if you have the `gsskrb5_register_acceptor_identity' function. */ -#define HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY 1 -/* Define to 1 if you have the `gss_krb5_ccache_name' function. */ -#define HAVE_GSS_KRB5_CCACHE_NAME 1 -/* Define to 1 if you have the `krb5_addlog_func' function. */ -#define HAVE_KRB5_ADDLOG_FUNC 1 -/* Define to 1 if you have the `krb5_auth_con_setkey' function. */ -#define HAVE_KRB5_AUTH_CON_SETKEY 1 -/* Define to 1 if you have the `krb5_auth_con_setuseruserkey' function. */ -/* #undef HAVE_KRB5_AUTH_CON_SETUSERUSERKEY */ -/* Define to 1 if you have the `krb5_c_enctype_compare' function. */ -#define HAVE_KRB5_C_ENCTYPE_COMPARE 1 -/* Define to 1 if you have the `krb5_c_verify_checksum' function. */ -#define HAVE_KRB5_C_VERIFY_CHECKSUM 1 -/* Whether the type krb5_encrypt_block exists */ -/* #undef HAVE_KRB5_ENCRYPT_BLOCK */ -/* Define to 1 if you have the `krb5_encrypt_data' function. */ -/* #undef HAVE_KRB5_ENCRYPT_DATA */ -/* Define to 1 if you have the `krb5_enctypes_compatible_keys' function. */ -#define HAVE_KRB5_ENCTYPES_COMPATIBLE_KEYS 1 -/* Define to 1 if you have the `krb5_free_data_contents' function. */ -#define HAVE_KRB5_FREE_DATA_CONTENTS 1 -/* Define to 1 if you have the `krb5_free_error_string' function. */ -#define HAVE_KRB5_FREE_ERROR_STRING 1 -/* Define to 1 if you have the `krb5_free_keytab_entry_contents' function. */ -/* #undef HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS */ -/* Define to 1 if you have the `krb5_free_ktypes' function. */ -/* #undef HAVE_KRB5_FREE_KTYPES */ -/* Define to 1 if you have the `krb5_free_unparsed_name' function. */ -/* #undef HAVE_KRB5_FREE_UNPARSED_NAME */ -/* Define to 1 if you have the `krb5_get_default_in_tkt_etypes' function. */ -#define HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES 1 -/* Define to 1 if you have the `krb5_get_error_string' function. */ -#define HAVE_KRB5_GET_ERROR_STRING 1 -/* Define to 1 if you have the `krb5_get_permitted_enctypes' function. */ -/* #undef HAVE_KRB5_GET_PERMITTED_ENCTYPES */ -/* Define to 1 if you have the `krb5_get_pw_salt' function. */ -#define HAVE_KRB5_GET_PW_SALT 1 -/* Define to 1 if you have the header file. */ -#define HAVE_KRB5_H 1 -/* Define to 1 if you have the `krb5_initlog' function. */ -#define HAVE_KRB5_INITLOG 1 -/* Define to 1 if you have the `krb5_kdc_default_config' function. */ -#define HAVE_KRB5_KDC_DEFAULT_CONFIG 1 -/* Whether the krb5_creds struct has a keyblock property */ -/* #undef HAVE_KRB5_KEYBLOCK_IN_CREDS */ -/* Whether the krb5_keyblock struct has a keyvalue property */ -#define HAVE_KRB5_KEYBLOCK_KEYVALUE 1 -/* Whether krb5_keytab_entry has key member */ -/* #undef HAVE_KRB5_KEYTAB_ENTRY_KEY */ -/* Whether krb5_keytab_entry has keyblock member */ -#define HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK 1 -/* Define to 1 if you have the `krb5_krbhst_get_addrinfo' function. */ -#define HAVE_KRB5_KRBHST_GET_ADDRINFO 1 -/* Define to 1 if you have the `krb5_kt_compare' function. */ -#define HAVE_KRB5_KT_COMPARE 1 -/* Define to 1 if you have the `krb5_kt_free_entry' function. */ -#define HAVE_KRB5_KT_FREE_ENTRY 1 -/* Whether the type krb5_log_facility exists */ -#define HAVE_KRB5_LOG_FACILITY 1 -/* Define to 1 if you have the `krb5_mk_req_extended' function. */ -#define HAVE_KRB5_MK_REQ_EXTENDED 1 -/* Define to 1 if you have the `krb5_principal2salt' function. */ -/* #undef HAVE_KRB5_PRINCIPAL2SALT */ -/* Define to 1 if you have the `krb5_principal_get_comp_string' function. */ -#define HAVE_KRB5_PRINCIPAL_GET_COMP_STRING 1 -/* Whether krb5_princ_component is available */ -/* #undef HAVE_KRB5_PRINC_COMPONENT */ -/* Whether the krb5_creds struct has a session property */ -#define HAVE_KRB5_SESSION_IN_CREDS 1 -/* Define to 1 if you have the `krb5_set_default_in_tkt_etypes' function. */ -#define HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES 1 -/* Define to 1 if you have the `krb5_set_default_tgs_ktypes' function. */ -/* #undef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES */ -/* Define to 1 if you have the `krb5_set_real_time' function. */ -#define HAVE_KRB5_SET_REAL_TIME 1 -/* Define to 1 if you have the `krb5_set_warn_dest' function. */ -#define HAVE_KRB5_SET_WARN_DEST 1 -/* Define to 1 if you have the `krb5_string_to_key' function. */ -#define HAVE_KRB5_STRING_TO_KEY 1 -/* Define to 1 if you have the `krb5_string_to_key_salt' function. */ -#define HAVE_KRB5_STRING_TO_KEY_SALT 1 -/* Define to 1 if you have the `krb5_ticket_get_authorization_data_type' */ -#define HAVE_KRB5_TICKET_GET_AUTHORIZATION_DATA_TYPE 1 -/* Whether the krb5_ticket struct has a enc_part2 property */ -/* #undef HAVE_KRB5_TKT_ENC_PART2 */ -/* Define to 1 if you have the `krb5_use_enctype' function. */ -/* #undef HAVE_KRB5_USE_ENCTYPE */ -/* Define to 1 if you have the `krb5_verify_checksum' function. */ -#define HAVE_KRB5_VERIFY_CHECKSUM 1 -/* Whether krb5_princ_realm returns krb5_realm or krb5_data */ -#define KRB5_PRINC_REALM_RETURNS_REALM 1 - -#include -#include - -#endif - -#endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h deleted file mode 100644 index 077892a54e..0000000000 --- a/source4/lib/replace/system/network.h +++ /dev/null @@ -1,332 +0,0 @@ -#ifndef _system_network_h -#define _system_network_h -/* - Unix SMB/CIFS implementation. - - networking system include wrappers - - Copyright (C) Andrew Tridgell 2004 - Copyright (C) Jelmer Vernooij 2007 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifndef LIBREPLACE_NETWORK_CHECKS -#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure" -#endif - -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -#ifdef HAVE_UNIXSOCKET -#include -#endif - -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif - -#ifdef HAVE_NETDB_H -#include -#endif - -#ifdef HAVE_NETINET_TCP_H -#include -#endif - -/* - * The next three defines are needed to access the IPTOS_* options - * on some systems. - */ - -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif - -#ifdef HAVE_NETINET_IN_IP_H -#include -#endif - -#ifdef HAVE_NETINET_IP_H -#include -#endif - -#ifdef HAVE_NET_IF_H -#include -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_SYS_IOCTL_H -#include -#endif - -#ifdef HAVE_STROPTS_H -#include -#endif - -#ifndef HAVE_SOCKLEN_T -#define HAVE_SOCKLEN_T -typedef int socklen_t; -#endif - -#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) -/* define is in "replace.h" */ -char *rep_inet_ntoa(struct in_addr ip); -#endif - -#ifndef HAVE_INET_PTON -/* define is in "replace.h" */ -int rep_inet_pton(int af, const char *src, void *dst); -#endif - -#ifndef HAVE_INET_NTOP -/* define is in "replace.h" */ -const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); -#endif - -#ifndef HAVE_INET_ATON -/* define is in "replace.h" */ -int rep_inet_aton(const char *src, struct in_addr *dst); -#endif - -#ifndef HAVE_CONNECT -/* define is in "replace.h" */ -int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -#endif - -#ifndef HAVE_GETHOSTBYNAME -/* define is in "replace.h" */ -struct hostent *rep_gethostbyname(const char *name); -#endif - -#ifdef HAVE_IFADDRS_H -#include -#endif - -#ifndef HAVE_STRUCT_IFADDRS -struct ifaddrs { - struct ifaddrs *ifa_next; /* Pointer to next struct */ - char *ifa_name; /* Interface name */ - unsigned int ifa_flags; /* Interface flags */ - struct sockaddr *ifa_addr; /* Interface address */ - struct sockaddr *ifa_netmask; /* Interface netmask */ -#undef ifa_dstaddr - struct sockaddr *ifa_dstaddr; /* P2P interface destination */ - void *ifa_data; /* Address specific data */ -}; -#endif - -#ifndef HAVE_GETIFADDRS -int rep_getifaddrs(struct ifaddrs **); -#endif - -#ifndef HAVE_FREEIFADDRS -void rep_freeifaddrs(struct ifaddrs *); -#endif - -#ifndef HAVE_SOCKETPAIR -/* define is in "replace.h" */ -int rep_socketpair(int d, int type, int protocol, int sv[2]); -#endif - -/* - * Some systems have getaddrinfo but not the - * defines needed to use it. - */ - -/* Various macros that ought to be in , but might not be */ - -#ifndef EAI_FAIL -#define EAI_BADFLAGS (-1) -#define EAI_NONAME (-2) -#define EAI_AGAIN (-3) -#define EAI_FAIL (-4) -#define EAI_FAMILY (-6) -#define EAI_SOCKTYPE (-7) -#define EAI_SERVICE (-8) -#define EAI_MEMORY (-10) -#define EAI_SYSTEM (-11) -#endif /* !EAI_FAIL */ - -#ifndef AI_PASSIVE -#define AI_PASSIVE 0x0001 -#endif - -#ifndef AI_CANONNAME -#define AI_CANONNAME 0x0002 -#endif - -#ifndef AI_NUMERICHOST -/* - * some platforms don't support AI_NUMERICHOST; define as zero if using - * the system version of getaddrinfo... - */ -#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) -#define AI_NUMERICHOST 0 -#else -#define AI_NUMERICHOST 0x0004 -#endif -#endif - -#ifndef AI_ADDRCONFIG -/* - * logic copied from AI_NUMERICHOST - */ -#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) -#define AI_ADDRCONFIG 0 -#else -#define AI_ADDRCONFIG 0x0020 -#endif -#endif - -#ifndef AI_NUMERICSERV -/* - * logic copied from AI_NUMERICHOST - */ -#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) -#define AI_NUMERICSERV 0 -#else -#define AI_NUMERICSERV 0x0400 -#endif -#endif - -#ifndef NI_NUMERICHOST -#define NI_NUMERICHOST 1 -#endif - -#ifndef NI_NUMERICSERV -#define NI_NUMERICSERV 2 -#endif - -#ifndef NI_NOFQDN -#define NI_NOFQDN 4 -#endif - -#ifndef NI_NAMEREQD -#define NI_NAMEREQD 8 -#endif - -#ifndef NI_DGRAM -#define NI_DGRAM 16 -#endif - - -#ifndef NI_MAXHOST -#define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -#define NI_MAXSERV 32 -#endif - -/* - * glibc on linux doesn't seem to have MSG_WAITALL - * defined. I think the kernel has it though.. - */ -#ifndef MSG_WAITALL -#define MSG_WAITALL 0 -#endif - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001 -#endif - -#ifndef INADDR_NONE -#define INADDR_NONE 0xffffffff -#endif - -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT EINVAL -#endif - -#ifndef INET_ADDRSTRLEN -#define INET_ADDRSTRLEN 16 -#endif - -#ifndef INET6_ADDRSTRLEN -#define INET6_ADDRSTRLEN 46 -#endif - -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 256 -#endif - -#ifndef HAVE_SA_FAMILY_T -#define HAVE_SA_FAMILY_T -typedef unsigned short int sa_family_t; -#endif - -#ifndef HAVE_STRUCT_SOCKADDR_STORAGE -#define HAVE_STRUCT_SOCKADDR_STORAGE -#ifdef HAVE_STRUCT_SOCKADDR_IN6 -#define sockaddr_storage sockaddr_in6 -#define ss_family sin6_family -#define HAVE_SS_FAMILY 1 -#else -#define sockaddr_storage sockaddr_in -#define ss_family sin_family -#define HAVE_SS_FAMILY 1 -#endif -#endif - -#ifndef HAVE_SS_FAMILY -#ifdef HAVE___SS_FAMILY -#define ss_family __ss_family -#define HAVE_SS_FAMILY 1 -#endif -#endif - -#ifndef HAVE_STRUCT_ADDRINFO -#define HAVE_STRUCT_ADDRINFO -struct addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - socklen_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; -#endif /* HAVE_STRUCT_ADDRINFO */ - -#if !defined(HAVE_GETADDRINFO) -#include "getaddrinfo.h" -#endif - -/* Needed for some systems that don't define it (Solaris). */ -#ifndef ifr_netmask -#define ifr_netmask ifr_addr -#endif - -#ifdef SOCKET_WRAPPER -#ifndef SOCKET_WRAPPER_NOT_REPLACE -#define SOCKET_WRAPPER_REPLACE -#endif -#include "lib/socket_wrapper/socket_wrapper.h" -#endif - -#endif diff --git a/source4/lib/replace/system/readline.h b/source4/lib/replace/system/readline.h deleted file mode 100644 index ba34dc6a61..0000000000 --- a/source4/lib/replace/system/readline.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _system_readline_h -#define _system_readline_h -/* - Unix SMB/CIFS implementation. - - Readline wrappers - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef HAVE_LIBREADLINE -# ifdef HAVE_READLINE_READLINE_H -# include -# ifdef HAVE_READLINE_HISTORY_H -# include -# endif -# else -# ifdef HAVE_READLINE_H -# include -# ifdef HAVE_HISTORY_H -# include -# endif -# else -# undef HAVE_LIBREADLINE -# endif -# endif -#endif - -#ifdef HAVE_NEW_LIBREADLINE -# define RL_COMPLETION_CAST (rl_completion_func_t *) -#else -/* This type is missing from libreadline<4.0 (approximately) */ -# define RL_COMPLETION_CAST -#endif /* HAVE_NEW_LIBREADLINE */ - -#endif diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h deleted file mode 100644 index da18de0cfc..0000000000 --- a/source4/lib/replace/system/select.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _system_select_h -#define _system_select_h -/* - Unix SMB/CIFS implementation. - - select system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef HAVE_SYS_SELECT_H -#include -#endif - -#ifdef HAVE_SYS_EPOLL_H -#include -#endif - -#ifndef SELECT_CAST -#define SELECT_CAST -#endif - -#endif diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h deleted file mode 100644 index 64fe39b6cb..0000000000 --- a/source4/lib/replace/system/shmem.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _system_shmem_h -#define _system_shmem_h -/* - Unix SMB/CIFS implementation. - - shared memory system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#if defined(HAVE_SYS_IPC_H) -#include -#endif /* HAVE_SYS_IPC_H */ - -#if defined(HAVE_SYS_SHM_H) -#include -#endif /* HAVE_SYS_SHM_H */ - -#ifdef HAVE_SYS_MMAN_H -#include -#endif - -/* NetBSD doesn't have these */ -#ifndef SHM_R -#define SHM_R 0400 -#endif - -#ifndef SHM_W -#define SHM_W 0200 -#endif - - -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#endif diff --git a/source4/lib/replace/system/syslog.h b/source4/lib/replace/system/syslog.h deleted file mode 100644 index 104be1df84..0000000000 --- a/source4/lib/replace/system/syslog.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _system_syslog_h -#define _system_syslog_h -/* - Unix SMB/CIFS implementation. - - syslog system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef HAVE_SYSLOG_H -#include -#else -#ifdef HAVE_SYS_SYSLOG_H -#include -#endif -#endif - -/* For sys_adminlog(). */ -#ifndef LOG_EMERG -#define LOG_EMERG 0 /* system is unusable */ -#endif - -#ifndef LOG_ALERT -#define LOG_ALERT 1 /* action must be taken immediately */ -#endif - -#ifndef LOG_CRIT -#define LOG_CRIT 2 /* critical conditions */ -#endif - -#ifndef LOG_ERR -#define LOG_ERR 3 /* error conditions */ -#endif - -#ifndef LOG_WARNING -#define LOG_WARNING 4 /* warning conditions */ -#endif - -#ifndef LOG_NOTICE -#define LOG_NOTICE 5 /* normal but significant condition */ -#endif - -#ifndef LOG_INFO -#define LOG_INFO 6 /* informational */ -#endif - -#ifndef LOG_DEBUG -#define LOG_DEBUG 7 /* debug-level messages */ -#endif - -#endif diff --git a/source4/lib/replace/system/terminal.h b/source4/lib/replace/system/terminal.h deleted file mode 100644 index 9ad601ace0..0000000000 --- a/source4/lib/replace/system/terminal.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _system_terminal_h -#define _system_terminal_h -/* - Unix SMB/CIFS implementation. - - terminal system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef SUNOS4 -/* on SUNOS4 termios.h conflicts with sys/ioctl.h */ -#undef HAVE_TERMIOS_H -#endif - - -#if defined(HAVE_TERMIOS_H) -/* POSIX terminal handling. */ -#include -#elif defined(HAVE_TERMIO_H) -/* Older SYSV terminal handling - don't use if we can avoid it. */ -#include -#elif defined(HAVE_SYS_TERMIO_H) -/* Older SYSV terminal handling - don't use if we can avoid it. */ -#include -#endif - -#endif diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h deleted file mode 100644 index 4abf295d1a..0000000000 --- a/source4/lib/replace/system/time.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _system_time_h -#define _system_time_h -/* - Unix SMB/CIFS implementation. - - time system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else -#ifdef HAVE_SYS_TIME_H -#include -#else -#include -#endif -#endif - -#ifdef HAVE_UTIME_H -#include -#else -struct utimbuf { - time_t actime; /* access time */ - time_t modtime; /* modification time */ -}; -#endif - -#ifndef HAVE_MKTIME -/* define is in "replace.h" */ -time_t rep_mktime(struct tm *t); -#endif - -#ifndef HAVE_TIMEGM -/* define is in "replace.h" */ -time_t rep_timegm(struct tm *tm); -#endif - -#ifndef HAVE_UTIME -/* define is in "replace.h" */ -int rep_utime(const char *filename, const struct utimbuf *buf); -#endif - -#ifndef HAVE_UTIMES -/* define is in "replace.h" */ -int rep_utimes(const char *filename, const struct timeval tv[2]); -#endif - -#endif diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h deleted file mode 100644 index 5784b1ae92..0000000000 --- a/source4/lib/replace/system/wait.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _system_wait_h -#define _system_wait_h -/* - Unix SMB/CIFS implementation. - - waitpid system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef HAVE_SYS_WAIT_H -#include -#endif - -#include - -#ifndef SIGCLD -#define SIGCLD SIGCHLD -#endif - -#ifndef SIGNAL_CAST -#define SIGNAL_CAST (RETSIGTYPE (*)(int)) -#endif - -#ifdef HAVE_SETJMP_H -#include -#endif - -#ifndef SA_RESETHAND -#define SA_RESETHAND SA_ONESHOT -#endif - -#if !defined(HAVE_SIG_ATOMIC_T_TYPE) -typedef int sig_atomic_t; -#endif - -#endif diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c deleted file mode 100644 index 8b00ac2f40..0000000000 --- a/source4/lib/replace/test/getifaddrs.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * - * libreplace getifaddrs test - * - * 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 . - */ - -#ifndef AUTOCONF_TEST -#include "replace.h" -#include "system/network.h" -#endif - -#ifdef HAVE_INET_NTOP -#define rep_inet_ntop inet_ntop -#endif - -static const char *format_sockaddr(struct sockaddr *addr, - char *addrstring, - socklen_t addrlen) -{ - const char *result = NULL; - - if (addr->sa_family == AF_INET) { - result = rep_inet_ntop(AF_INET, - &((struct sockaddr_in *)addr)->sin_addr, - addrstring, - addrlen); -#ifdef HAVE_STRUCT_SOCKADDR_IN6 - } else if (addr->sa_family == AF_INET6) { - result = rep_inet_ntop(AF_INET6, - &((struct sockaddr_in6 *)addr)->sin6_addr, - addrstring, - addrlen); -#endif - } - return result; -} - -int getifaddrs_test(void) -{ - struct ifaddrs *ifs = NULL; - struct ifaddrs *ifs_head = NULL; - int ret; - - ret = getifaddrs(&ifs); - ifs_head = ifs; - if (ret != 0) { - fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno)); - return 1; - } - - while (ifs) { - printf("%-10s ", ifs->ifa_name); - if (ifs->ifa_addr != NULL) { - char addrstring[INET6_ADDRSTRLEN]; - const char *result; - - result = format_sockaddr(ifs->ifa_addr, - addrstring, - sizeof(addrstring)); - if (result != NULL) { - printf("IP=%s ", addrstring); - } - - if (ifs->ifa_netmask != NULL) { - result = format_sockaddr(ifs->ifa_netmask, - addrstring, - sizeof(addrstring)); - if (result != NULL) { - printf("NETMASK=%s", addrstring); - } - } else { - printf("AF=%d ", ifs->ifa_addr->sa_family); - } - } else { - printf(""); - } - - printf("\n"); - ifs = ifs->ifa_next; - } - - freeifaddrs(ifs_head); - - return 0; -} diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c deleted file mode 100644 index b45c135355..0000000000 --- a/source4/lib/replace/test/os2_delete.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -static int test_readdir_os2_delete_ret; - -#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files(void) -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - system("rm -rf " TESTDIR); - - return test_readdir_os2_delete_ret; -} diff --git a/source4/lib/replace/test/shared_mmap.c b/source4/lib/replace/test/shared_mmap.c deleted file mode 100644 index 50dad8d696..0000000000 --- a/source4/lib/replace/test/shared_mmap.c +++ /dev/null @@ -1,68 +0,0 @@ -/* this tests whether we can use a shared writeable mmap on a file - - as needed for the mmap variant of FAST_SHARE_MODES */ - -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include -#include -#include - -#define DATA "conftest.mmap" - -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif - -main() -{ - int *buf; - int i; - int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); - int count=7; - - if (fd == -1) exit(1); - - for (i=0;i<10000;i++) { - write(fd,&i,sizeof(i)); - } - - close(fd); - - if (fork() == 0) { - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - while (count-- && buf[9124] != 55732) sleep(1); - - if (count <= 0) exit(1); - - buf[1763] = 7268; - exit(0); - } - - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - if (buf == (int *)-1) exit(1); - - buf[9124] = 55732; - - while (count-- && buf[1763] != 7268) sleep(1); - - unlink(DATA); - - if (count > 0) exit(0); - exit(1); -} diff --git a/source4/lib/replace/test/strptime.c b/source4/lib/replace/test/strptime.c deleted file mode 100644 index fade3ecc57..0000000000 --- a/source4/lib/replace/test/strptime.c +++ /dev/null @@ -1,172 +0,0 @@ - -#ifdef LIBREPLACE_CONFIGURE_TEST_STRPTIME - -#include -#include -#include - -#define true 1 -#define false 0 - -#ifndef __STRING -#define __STRING(x) #x -#endif - -/* make printf a no-op */ -#define printf if(0) printf - -#else /* LIBREPLACE_CONFIGURE_TEST_STRPTIME */ - -#include "replace.h" -#include "system/time.h" - -#endif /* LIBREPLACE_CONFIGURE_TEST_STRPTIME */ - -int libreplace_test_strptime(void) -{ - const char *s = "20070414101546Z"; - char *ret; - struct tm t, t2; - - memset(&t, 0, sizeof(t)); - memset(&t2, 0, sizeof(t2)); - - printf("test: strptime\n"); - - ret = strptime(s, "%Y%m%d%H%M%S", &t); - if ( ret == NULL ) { - printf("failure: strptime [\n" - "returned NULL\n" - "]\n"); - return false; - } - - if ( *ret != 'Z' ) { - printf("failure: strptime [\n" - "ret doesn't point to 'Z'\n" - "]\n"); - return false; - } - - ret = strptime(s, "%Y%m%d%H%M%SZ", &t2); - if ( ret == NULL ) { - printf("failure: strptime [\n" - "returned NULL with Z\n" - "]\n"); - return false; - } - - if ( *ret != '\0' ) { - printf("failure: strptime [\n" - "ret doesn't point to '\\0'\n" - "]\n"); - return false; - } - -#define CMP_TM_ELEMENT(t1,t2,elem) \ - if (t1.elem != t2.elem) { \ - printf("failure: strptime [\n" \ - "result differs if the format string has a 'Z' at the end\n" \ - "element: %s %d != %d\n" \ - "]\n", \ - __STRING(elen), t1.elem, t2.elem); \ - return false; \ - } - - CMP_TM_ELEMENT(t,t2,tm_sec); - CMP_TM_ELEMENT(t,t2,tm_min); - CMP_TM_ELEMENT(t,t2,tm_hour); - CMP_TM_ELEMENT(t,t2,tm_mday); - CMP_TM_ELEMENT(t,t2,tm_mon); - CMP_TM_ELEMENT(t,t2,tm_year); - CMP_TM_ELEMENT(t,t2,tm_wday); - CMP_TM_ELEMENT(t,t2,tm_yday); - CMP_TM_ELEMENT(t,t2,tm_isdst); - - if (t.tm_sec != 46) { - printf("failure: strptime [\n" - "tm_sec: expected: 46, got: %d\n" - "]\n", - t.tm_sec); - return false; - } - - if (t.tm_min != 15) { - printf("failure: strptime [\n" - "tm_min: expected: 15, got: %d\n" - "]\n", - t.tm_min); - return false; - } - - if (t.tm_hour != 10) { - printf("failure: strptime [\n" - "tm_hour: expected: 10, got: %d\n" - "]\n", - t.tm_hour); - return false; - } - - if (t.tm_mday != 14) { - printf("failure: strptime [\n" - "tm_mday: expected: 14, got: %d\n" - "]\n", - t.tm_mday); - return false; - } - - if (t.tm_mon != 3) { - printf("failure: strptime [\n" - "tm_mon: expected: 3, got: %d\n" - "]\n", - t.tm_mon); - return false; - } - - if (t.tm_year != 107) { - printf("failure: strptime [\n" - "tm_year: expected: 107, got: %d\n" - "]\n", - t.tm_year); - return false; - } - - if (t.tm_wday != 6) { /* saturday */ - printf("failure: strptime [\n" - "tm_wday: expected: 6, got: %d\n" - "]\n", - t.tm_wday); - return false; - } - - if (t.tm_yday != 103) { - printf("failure: strptime [\n" - "tm_yday: expected: 103, got: %d\n" - "]\n", - t.tm_yday); - return false; - } - - /* we don't test this as it depends on the host configuration - if (t.tm_isdst != 0) { - printf("failure: strptime [\n" - "tm_isdst: expected: 0, got: %d\n" - "]\n", - t.tm_isdst); - return false; - }*/ - - printf("success: strptime\n"); - - return true; -} - -#ifdef LIBREPLACE_CONFIGURE_TEST_STRPTIME -int main (void) -{ - int ret; - ret = libreplace_test_strptime(); - if (ret == false) return 1; - return 0; -} -#endif diff --git a/source4/lib/replace/timegm.m4 b/source4/lib/replace/timegm.m4 deleted file mode 100644 index 59f3ae0521..0000000000 --- a/source4/lib/replace/timegm.m4 +++ /dev/null @@ -1 +0,0 @@ -AC_CHECK_FUNCS(timegm,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} timegm.o"]) diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4 deleted file mode 100644 index eb364e2cb9..0000000000 --- a/source4/lib/replace/win32.m4 +++ /dev/null @@ -1,20 +0,0 @@ -AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) - -####################################### -# Check for mkdir mode -AC_CACHE_CHECK( [whether mkdir supports mode], libreplace_cv_mkdir_has_mode, - AC_TRY_COMPILE([ - #include - #ifdef HAVE_DIRECT_H - #include - #endif],[ - mkdir("foo",0777); - return 0; - ], - libreplace_cv_mkdir_has_mode="yes", - libreplace_cv_mkdir_has_mode="no") ) - -if test "$libreplace_cv_mkdir_has_mode" = "yes" -then - AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) -fi diff --git a/source4/lib/replace/win32_replace.h b/source4/lib/replace/win32_replace.h deleted file mode 100644 index 9901e72f6e..0000000000 --- a/source4/lib/replace/win32_replace.h +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef _WIN32_REPLACE_H -#define _WIN32_REPLACE_H - -#ifdef HAVE_WINSOCK2_H -#include -#endif - -#ifdef HAVE_WS2TCPIP_H -#include -#endif - -#ifdef HAVE_WINDOWS_H -#include -#endif - -/* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */ - -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#define ECONNREFUSED WSAECONNREFUSED -#define EINPROGRESS WSAEINPROGRESS -#define EMSGSIZE WSAEMSGSIZE -#define ENOBUFS WSAENOBUFS -#define ENOTSOCK WSAENOTSOCK -#define ENETUNREACH WSAENETUNREACH -#define ENOPROTOOPT WSAENOPROTOOPT -#define ENOTCONN WSAENOTCONN -#define ENOTSUP 134 - -/* We undefine the following constants due to conflicts with the w32api headers - * and the Windows Platform SDK/DDK. - */ - -#undef interface - -#undef ERROR_INVALID_PARAMETER -#undef ERROR_INSUFFICIENT_BUFFER -#undef ERROR_INVALID_DATATYPE - -#undef FILE_GENERIC_READ -#undef FILE_GENERIC_WRITE -#undef FILE_GENERIC_EXECUTE -#undef FILE_ATTRIBUTE_READONLY -#undef FILE_ATTRIBUTE_HIDDEN -#undef FILE_ATTRIBUTE_SYSTEM -#undef FILE_ATTRIBUTE_DIRECTORY -#undef FILE_ATTRIBUTE_ARCHIVE -#undef FILE_ATTRIBUTE_DEVICE -#undef FILE_ATTRIBUTE_NORMAL -#undef FILE_ATTRIBUTE_TEMPORARY -#undef FILE_ATTRIBUTE_REPARSE_POINT -#undef FILE_ATTRIBUTE_COMPRESSED -#undef FILE_ATTRIBUTE_OFFLINE -#undef FILE_ATTRIBUTE_ENCRYPTED -#undef FILE_FLAG_WRITE_THROUGH -#undef FILE_FLAG_NO_BUFFERING -#undef FILE_FLAG_RANDOM_ACCESS -#undef FILE_FLAG_SEQUENTIAL_SCAN -#undef FILE_FLAG_DELETE_ON_CLOSE -#undef FILE_FLAG_BACKUP_SEMANTICS -#undef FILE_FLAG_POSIX_SEMANTICS -#undef FILE_TYPE_DISK -#undef FILE_TYPE_UNKNOWN -#undef FILE_CASE_SENSITIVE_SEARCH -#undef FILE_CASE_PRESERVED_NAMES -#undef FILE_UNICODE_ON_DISK -#undef FILE_PERSISTENT_ACLS -#undef FILE_FILE_COMPRESSION -#undef FILE_VOLUME_QUOTAS -#undef FILE_VOLUME_IS_COMPRESSED -#undef FILE_NOTIFY_CHANGE_FILE_NAME -#undef FILE_NOTIFY_CHANGE_DIR_NAME -#undef FILE_NOTIFY_CHANGE_ATTRIBUTES -#undef FILE_NOTIFY_CHANGE_SIZE -#undef FILE_NOTIFY_CHANGE_LAST_WRITE -#undef FILE_NOTIFY_CHANGE_LAST_ACCESS -#undef FILE_NOTIFY_CHANGE_CREATION -#undef FILE_NOTIFY_CHANGE_EA -#undef FILE_NOTIFY_CHANGE_SECURITY -#undef FILE_NOTIFY_CHANGE_STREAM_NAME -#undef FILE_NOTIFY_CHANGE_STREAM_SIZE -#undef FILE_NOTIFY_CHANGE_STREAM_WRITE -#undef FILE_NOTIFY_CHANGE_NAME - -#undef PRINTER_ATTRIBUTE_QUEUED -#undef PRINTER_ATTRIBUTE_DIRECT -#undef PRINTER_ATTRIBUTE_DEFAULT -#undef PRINTER_ATTRIBUTE_SHARED -#undef PRINTER_ATTRIBUTE_NETWORK -#undef PRINTER_ATTRIBUTE_HIDDEN -#undef PRINTER_ATTRIBUTE_LOCAL -#undef PRINTER_ATTRIBUTE_ENABLE_DEVQ -#undef PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS -#undef PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST -#undef PRINTER_ATTRIBUTE_WORK_OFFLINE -#undef PRINTER_ATTRIBUTE_ENABLE_BIDI -#undef PRINTER_ATTRIBUTE_RAW_ONLY -#undef PRINTER_ATTRIBUTE_PUBLISHED -#undef PRINTER_ENUM_DEFAULT -#undef PRINTER_ENUM_LOCAL -#undef PRINTER_ENUM_CONNECTIONS -#undef PRINTER_ENUM_FAVORITE -#undef PRINTER_ENUM_NAME -#undef PRINTER_ENUM_REMOTE -#undef PRINTER_ENUM_SHARED -#undef PRINTER_ENUM_NETWORK -#undef PRINTER_ENUM_EXPAND -#undef PRINTER_ENUM_CONTAINER -#undef PRINTER_ENUM_ICON1 -#undef PRINTER_ENUM_ICON2 -#undef PRINTER_ENUM_ICON3 -#undef PRINTER_ENUM_ICON4 -#undef PRINTER_ENUM_ICON5 -#undef PRINTER_ENUM_ICON6 -#undef PRINTER_ENUM_ICON7 -#undef PRINTER_ENUM_ICON8 -#undef PRINTER_STATUS_PAUSED -#undef PRINTER_STATUS_ERROR -#undef PRINTER_STATUS_PENDING_DELETION -#undef PRINTER_STATUS_PAPER_JAM -#undef PRINTER_STATUS_PAPER_OUT -#undef PRINTER_STATUS_MANUAL_FEED -#undef PRINTER_STATUS_PAPER_PROBLEM -#undef PRINTER_STATUS_OFFLINE -#undef PRINTER_STATUS_IO_ACTIVE -#undef PRINTER_STATUS_BUSY -#undef PRINTER_STATUS_PRINTING -#undef PRINTER_STATUS_OUTPUT_BIN_FULL -#undef PRINTER_STATUS_NOT_AVAILABLE -#undef PRINTER_STATUS_WAITING -#undef PRINTER_STATUS_PROCESSING -#undef PRINTER_STATUS_INITIALIZING -#undef PRINTER_STATUS_WARMING_UP -#undef PRINTER_STATUS_TONER_LOW -#undef PRINTER_STATUS_NO_TONER -#undef PRINTER_STATUS_PAGE_PUNT -#undef PRINTER_STATUS_USER_INTERVENTION -#undef PRINTER_STATUS_OUT_OF_MEMORY -#undef PRINTER_STATUS_DOOR_OPEN -#undef PRINTER_STATUS_SERVER_UNKNOWN -#undef PRINTER_STATUS_POWER_SAVE - -#undef DWORD -#undef HKEY_CLASSES_ROOT -#undef HKEY_CURRENT_USER -#undef HKEY_LOCAL_MACHINE -#undef HKEY_USERS -#undef HKEY_PERFORMANCE_DATA -#undef HKEY_CURRENT_CONFIG -#undef HKEY_DYN_DATA -#undef REG_DWORD -#undef REG_QWORD - -#undef SERVICE_STATE_ALL - -#undef SE_GROUP_MANDATORY -#undef SE_GROUP_ENABLED_BY_DEFAULT -#undef SE_GROUP_ENABLED - -#endif /* _WIN32_REPLACE_H */ diff --git a/source4/lib/samba3/config.mk b/source4/lib/samba3/config.mk index e089149393..365347fe21 100644 --- a/source4/lib/samba3/config.mk +++ b/source4/lib/samba3/config.mk @@ -6,5 +6,3 @@ PRIVATE_DEPENDENCIES = CHARSET LIBSAMBA-UTIL ################################################ SMBPASSWD_OBJ_FILES = $(libsrcdir)/samba3/smbpasswd.o - -$(eval $(call proto_header_template,$(libsrcdir)/samba3/samba3_smbpasswd_proto.h,$(SMBPASSWD_OBJ_FILES:.o=.c))) diff --git a/source4/lib/samba3/samba3.h b/source4/lib/samba3/samba3.h index aea87dac14..1a0ce04143 100644 --- a/source4/lib/samba3/samba3.h +++ b/source4/lib/samba3/samba3.h @@ -24,191 +24,9 @@ #include "librpc/gen_ndr/samr.h" #include "param/param.h" -struct samba3_samaccount { - uint32_t logon_time, - logoff_time, - kickoff_time, - bad_password_time, - pass_last_set_time, - pass_can_change_time, - pass_must_change_time; - char *username; - char *domain; - char *nt_username; - char *dir_drive; - char *unknown_str; - char *munged_dial; - char *fullname; - char *homedir; - char *logon_script; - char *profile_path; - char *acct_desc; - char *workstations; - uint32_t user_rid, group_rid, hours_len, unknown_6; - uint16_t acct_ctrl, logon_divs; - uint16_t bad_password_count, logon_count; - struct samr_Password lm_pw, nt_pw; - uint8_t *nt_pw_hist_ptr; - uint8_t *hours; -}; - -struct samba3_groupmapping { - gid_t gid; - struct dom_sid *sid; - int sid_name_use; - const char *nt_name; - const char *comment; -}; - -struct samba3_alias { - struct dom_sid *sid; - uint32_t member_count; - struct dom_sid **members; -}; - -struct samba3_groupdb { - uint32_t groupmap_count; - struct samba3_groupmapping *groupmappings; - - uint32_t alias_count; - struct samba3_alias *aliases; -}; - -struct samba3_idmap_mapping -{ - enum { IDMAP_GROUP, IDMAP_USER } type; - uint32_t unix_id; - struct dom_sid *sid; -}; - -struct samba3_idmapdb -{ - /* High water marks */ - uint32_t user_hwm; - uint32_t group_hwm; - - uint32_t mapping_count; - struct samba3_idmap_mapping *mappings; -}; - -struct samba3_winsdb_entry -{ - char *name; - int nb_flags; - int type; - time_t ttl; - uint32_t ip_count; - struct in_addr *ips; -}; - -struct samba3_policy -{ - uint32_t min_password_length; - uint32_t password_history; - uint32_t user_must_logon_to_change_password; - uint32_t maximum_password_age; - uint32_t minimum_password_age; - uint32_t lockout_duration; - uint32_t reset_count_minutes; - uint32_t bad_lockout_minutes; - uint32_t disconnect_time; - uint32_t refuse_machine_password_change; -}; - -struct samba3_regval { - char *name; - uint16_t type; - DATA_BLOB data; -}; - -struct samba3_regkey { - char *name; - - uint32_t value_count; - struct samba3_regval *values; - - uint32_t subkey_count; - char **subkeys; -}; - -struct samba3_regdb -{ - uint32_t key_count; - struct samba3_regkey *keys; -}; - -struct samba3_secrets -{ - struct cli_credentials *ipc_cred; - - uint32_t ldappw_count; - struct samba3_ldappw - { - char *dn; - char *password; - } *ldappws; - - uint32_t domain_count; - struct samba3_domainsecrets - { - char *name; - struct dom_sid sid; - struct GUID guid; - char *plaintext_pw; - time_t last_change_time; - struct { - uint8_t hash[16]; - time_t mod_time; - } hash_pw; - int sec_channel_type; - } *domains; - - uint32_t trusted_domain_count; - struct samba3_trusted_dom_pass { - uint32_t uni_name_len; - const char *uni_name[32]; /* unicode domain name */ - const char *pass; /* trust relationship's password */ - time_t mod_time; - struct dom_sid domain_sid; /* remote domain's sid */ - } *trusted_domains; - - uint32_t afs_keyfile_count; - - struct samba3_afs_keyfile { - uint32_t nkeys; - struct { - uint32_t kvno; - char key[8]; - } entry[8]; - char *cell; - } *afs_keyfiles; -}; - -struct samba3_share_info { - char *name; - struct security_descriptor secdesc; -}; - -struct samba3 -{ - struct param_context *configuration; - - uint32_t winsdb_count; - struct samba3_winsdb_entry *winsdb_entries; - - uint32_t samaccount_count; - struct samba3_samaccount *samaccounts; - - uint32_t share_count; - struct samba3_share_info *shares; - - struct samba3_secrets secrets; - struct samba3_groupdb group; - struct samba3_idmapdb idmap; - struct samba3_policy policy; - struct samba3_regdb registry; -}; - -#include "lib/samba3/samba3_smbpasswd_proto.h" +struct samr_Password *smbpasswd_gethexpwd(TALLOC_CTX *mem_ctx, const char *p); +char *smbpasswd_sethexpwd(TALLOC_CTX *mem_ctx, struct samr_Password *pwd, uint16_t acb_info); +uint16_t smbpasswd_decode_acb_info(const char *p); +char *smbpasswd_encode_acb_info(TALLOC_CTX *mem_ctx, uint16_t acb_info); #endif /* _SAMBA3_H */ diff --git a/source4/lib/smbreadline/smbreadline.c b/source4/lib/smbreadline/smbreadline.c index a85f335b8a..5fb3bf4fae 100644 --- a/source4/lib/smbreadline/smbreadline.c +++ b/source4/lib/smbreadline/smbreadline.c @@ -29,7 +29,7 @@ This is what sys_select() used to do in Samba. ********************************************************************/ -int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval) +static int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval) { int ret; fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf; @@ -82,7 +82,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) int fd = STDIN_FILENO; char *ret; - do_debug("%s", prompt); + printf("%s", prompt); line = (char *)malloc(BUFSIZ); if (!line) { diff --git a/source4/lib/socket/interface.c b/source4/lib/socket/interface.c index c327f02bbd..b4e7c2bf32 100644 --- a/source4/lib/socket/interface.c +++ b/source4/lib/socket/interface.c @@ -22,7 +22,7 @@ #include "includes.h" #include "system/network.h" #include "lib/socket/netif.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" /** used for network interfaces */ diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 92f0a44005..0c3d032068 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -491,7 +491,7 @@ static const struct { **/ _PUBLIC_ void set_socket_options(int fd, const char *options) { - const char **options_list = str_list_make(NULL, options, " \t,"); + const char **options_list = (const char **)str_list_make(NULL, options, " \t,"); int j; if (!options_list) diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk deleted file mode 100644 index 60cfb3209a..0000000000 --- a/source4/lib/socket_wrapper/config.mk +++ /dev/null @@ -1,8 +0,0 @@ -############################## -# Start SUBSYSTEM SOCKET_WRAPPER -[SUBSYSTEM::SOCKET_WRAPPER] -PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK -# End SUBSYSTEM SOCKET_WRAPPER -############################## - -SOCKET_WRAPPER_OBJ_FILES = $(socketwrappersrcdir)/socket_wrapper.o diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c deleted file mode 100644 index 336179d837..0000000000 --- a/source4/lib/socket_wrapper/socket_wrapper.c +++ /dev/null @@ -1,1841 +0,0 @@ -/* - * Copyright (C) Jelmer Vernooij 2005,2008 - * Copyright (C) Stefan Metzmacher 2006 - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - Socket wrapper library. Passes all socket communication over - unix domain sockets if the environment variable SOCKET_WRAPPER_DIR - is set. -*/ - -#ifdef _SAMBA_BUILD_ - -#define SOCKET_WRAPPER_NOT_REPLACE -#include "lib/replace/replace.h" -#include "system/network.h" -#include "system/filesys.h" -#include "system/time.h" - -#else /* _SAMBA_BUILD_ */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif - -#ifndef _PUBLIC_ -#define _PUBLIC_ -#endif - -#define SWRAP_DLIST_ADD(list,item) do { \ - if (!(list)) { \ - (item)->prev = NULL; \ - (item)->next = NULL; \ - (list) = (item); \ - } else { \ - (item)->prev = NULL; \ - (item)->next = (list); \ - (list)->prev = (item); \ - (list) = (item); \ - } \ -} while (0) - -#define SWRAP_DLIST_REMOVE(list,item) do { \ - if ((list) == (item)) { \ - (list) = (item)->next; \ - if (list) { \ - (list)->prev = NULL; \ - } \ - } else { \ - if ((item)->prev) { \ - (item)->prev->next = (item)->next; \ - } \ - if ((item)->next) { \ - (item)->next->prev = (item)->prev; \ - } \ - } \ - (item)->prev = NULL; \ - (item)->next = NULL; \ -} while (0) - -/* LD_PRELOAD doesn't work yet, so REWRITE_CALLS is all we support - * for now */ -#define REWRITE_CALLS - -#ifdef REWRITE_CALLS -#define real_accept accept -#define real_connect connect -#define real_bind bind -#define real_listen listen -#define real_getpeername getpeername -#define real_getsockname getsockname -#define real_getsockopt getsockopt -#define real_setsockopt setsockopt -#define real_recvfrom recvfrom -#define real_sendto sendto -#define real_ioctl ioctl -#define real_recv recv -#define real_send send -#define real_socket socket -#define real_close close -#endif - -#ifdef HAVE_GETTIMEOFDAY_TZ -#define swrapGetTimeOfDay(tval) gettimeofday(tval,NULL) -#else -#define swrapGetTimeOfDay(tval) gettimeofday(tval) -#endif - -/* we need to use a very terse format here as IRIX 6.4 silently - truncates names to 16 chars, so if we use a longer name then we - can't tell which port a packet came from with recvfrom() - - with this format we have 8 chars left for the directory name -*/ -#define SOCKET_FORMAT "%c%02X%04X" -#define SOCKET_TYPE_CHAR_TCP 'T' -#define SOCKET_TYPE_CHAR_UDP 'U' -#define SOCKET_TYPE_CHAR_TCP_V6 'X' -#define SOCKET_TYPE_CHAR_UDP_V6 'Y' - -#define MAX_WRAPPED_INTERFACES 16 - -#define SW_IPV6_ADDRESS 1 - -static struct sockaddr *sockaddr_dup(const void *data, socklen_t len) -{ - struct sockaddr *ret = (struct sockaddr *)malloc(len); - memcpy(ret, data, len); - return ret; -} - -static void set_port(int family, int prt, struct sockaddr *addr) -{ - switch (family) { - case AF_INET: - ((struct sockaddr_in *)addr)->sin_port = htons(prt); - break; -#ifdef HAVE_IPV6 - case AF_INET6: - ((struct sockaddr_in6 *)addr)->sin6_port = htons(prt); - break; -#endif - } -} - -static size_t socket_length(int family) -{ - switch (family) { - case AF_INET: - return sizeof(struct sockaddr_in); -#ifdef HAVE_IPV6 - case AF_INET6: - return sizeof(struct sockaddr_in6); -#endif - } - return 0; -} - - - -struct socket_info -{ - int fd; - - int family; - int type; - int protocol; - int bound; - int bcast; - int is_server; - - char *path; - char *tmp_path; - - struct sockaddr *myname; - socklen_t myname_len; - - struct sockaddr *peername; - socklen_t peername_len; - - struct { - unsigned long pck_snd; - unsigned long pck_rcv; - } io; - - struct socket_info *prev, *next; -}; - -static struct socket_info *sockets; - -const char *socket_wrapper_dir(void) -{ - const char *s = getenv("SOCKET_WRAPPER_DIR"); - if (s == NULL) { - return NULL; - } - if (strncmp(s, "./", 2) == 0) { - s += 2; - } - return s; -} - -unsigned int socket_wrapper_default_iface(void) -{ - const char *s = getenv("SOCKET_WRAPPER_DEFAULT_IFACE"); - if (s) { - unsigned int iface; - if (sscanf(s, "%u", &iface) == 1) { - if (iface >= 1 && iface <= MAX_WRAPPED_INTERFACES) { - return iface; - } - } - } - - return 1;/* 127.0.0.1 */ -} - -static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, socklen_t *len) -{ - unsigned int iface; - unsigned int prt; - const char *p; - char type; - - p = strrchr(un->sun_path, '/'); - if (p) p++; else p = un->sun_path; - - if (sscanf(p, SOCKET_FORMAT, &type, &iface, &prt) != 3) { - errno = EINVAL; - return -1; - } - - if (iface == 0 || iface > MAX_WRAPPED_INTERFACES) { - errno = EINVAL; - return -1; - } - - if (prt > 0xFFFF) { - errno = EINVAL; - return -1; - } - - switch(type) { - case SOCKET_TYPE_CHAR_TCP: - case SOCKET_TYPE_CHAR_UDP: { - struct sockaddr_in *in2 = (struct sockaddr_in *)in; - - if ((*len) < sizeof(*in2)) { - errno = EINVAL; - return -1; - } - - memset(in2, 0, sizeof(*in2)); - in2->sin_family = AF_INET; - in2->sin_addr.s_addr = htonl((127<<24) | iface); - in2->sin_port = htons(prt); - - *len = sizeof(*in2); - break; - } -#ifdef HAVE_IPV6 - case SOCKET_TYPE_CHAR_TCP_V6: - case SOCKET_TYPE_CHAR_UDP_V6: { - struct sockaddr_in6 *in2 = (struct sockaddr_in6 *)in; - - if ((*len) < sizeof(*in2)) { - errno = EINVAL; - return -1; - } - - memset(in2, 0, sizeof(*in2)); - in2->sin6_family = AF_INET6; - in2->sin6_addr.s6_addr[0] = SW_IPV6_ADDRESS; - in2->sin6_port = htons(prt); - - *len = sizeof(*in2); - break; - } -#endif - default: - errno = EINVAL; - return -1; - } - - return 0; -} - -static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *inaddr, struct sockaddr_un *un, - int *bcast) -{ - char type = '\0'; - unsigned int prt; - unsigned int iface; - int is_bcast = 0; - - if (bcast) *bcast = 0; - - switch (si->family) { - case AF_INET: { - const struct sockaddr_in *in = - (const struct sockaddr_in *)inaddr; - unsigned int addr = ntohl(in->sin_addr.s_addr); - char u_type = '\0'; - char b_type = '\0'; - char a_type = '\0'; - - switch (si->type) { - case SOCK_STREAM: - u_type = SOCKET_TYPE_CHAR_TCP; - break; - case SOCK_DGRAM: - u_type = SOCKET_TYPE_CHAR_UDP; - a_type = SOCKET_TYPE_CHAR_UDP; - b_type = SOCKET_TYPE_CHAR_UDP; - break; - } - - prt = ntohs(in->sin_port); - if (a_type && addr == 0xFFFFFFFF) { - /* 255.255.255.255 only udp */ - is_bcast = 2; - type = a_type; - iface = socket_wrapper_default_iface(); - } else if (b_type && addr == 0x7FFFFFFF) { - /* 127.255.255.255 only udp */ - is_bcast = 1; - type = b_type; - iface = socket_wrapper_default_iface(); - } else if ((addr & 0xFFFFFF00) == 0x7F000000) { - /* 127.0.0.X */ - is_bcast = 0; - type = u_type; - iface = (addr & 0x000000FF); - } else { - errno = ENETUNREACH; - return -1; - } - if (bcast) *bcast = is_bcast; - break; - } -#ifdef HAVE_IPV6 - case AF_INET6: { - const struct sockaddr_in6 *in = - (const struct sockaddr_in6 *)inaddr; - - switch (si->type) { - case SOCK_STREAM: - type = SOCKET_TYPE_CHAR_TCP_V6; - break; - case SOCK_DGRAM: - type = SOCKET_TYPE_CHAR_UDP_V6; - break; - } - - /* XXX no multicast/broadcast */ - - prt = ntohs(in->sin6_port); - iface = SW_IPV6_ADDRESS; - - break; - } -#endif - default: - errno = ENETUNREACH; - return -1; - } - - if (prt == 0) { - errno = EINVAL; - return -1; - } - - if (is_bcast) { - snprintf(un->sun_path, sizeof(un->sun_path), "%s/EINVAL", - socket_wrapper_dir()); - /* the caller need to do more processing */ - return 0; - } - - snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT, - socket_wrapper_dir(), type, iface, prt); - - return 0; -} - -static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *inaddr, struct sockaddr_un *un, - int *bcast) -{ - char type = '\0'; - unsigned int prt; - unsigned int iface; - struct stat st; - int is_bcast = 0; - - if (bcast) *bcast = 0; - - switch (si->family) { - case AF_INET: { - const struct sockaddr_in *in = - (const struct sockaddr_in *)inaddr; - unsigned int addr = ntohl(in->sin_addr.s_addr); - char u_type = '\0'; - char d_type = '\0'; - char b_type = '\0'; - char a_type = '\0'; - - prt = ntohs(in->sin_port); - - switch (si->type) { - case SOCK_STREAM: - u_type = SOCKET_TYPE_CHAR_TCP; - d_type = SOCKET_TYPE_CHAR_TCP; - break; - case SOCK_DGRAM: - u_type = SOCKET_TYPE_CHAR_UDP; - d_type = SOCKET_TYPE_CHAR_UDP; - a_type = SOCKET_TYPE_CHAR_UDP; - b_type = SOCKET_TYPE_CHAR_UDP; - break; - } - - if (addr == 0) { - /* 0.0.0.0 */ - is_bcast = 0; - type = d_type; - iface = socket_wrapper_default_iface(); - } else if (a_type && addr == 0xFFFFFFFF) { - /* 255.255.255.255 only udp */ - is_bcast = 2; - type = a_type; - iface = socket_wrapper_default_iface(); - } else if (b_type && addr == 0x7FFFFFFF) { - /* 127.255.255.255 only udp */ - is_bcast = 1; - type = b_type; - iface = socket_wrapper_default_iface(); - } else if ((addr & 0xFFFFFF00) == 0x7F000000) { - /* 127.0.0.X */ - is_bcast = 0; - type = u_type; - iface = (addr & 0x000000FF); - } else { - errno = EADDRNOTAVAIL; - return -1; - } - break; - } -#ifdef HAVE_IPV6 - case AF_INET6: { - const struct sockaddr_in6 *in = - (const struct sockaddr_in6 *)inaddr; - - switch (si->type) { - case SOCK_STREAM: - type = SOCKET_TYPE_CHAR_TCP_V6; - break; - case SOCK_DGRAM: - type = SOCKET_TYPE_CHAR_UDP_V6; - break; - } - - /* XXX no multicast/broadcast */ - - prt = ntohs(in->sin6_port); - iface = SW_IPV6_ADDRESS; - - break; - } -#endif - default: - errno = ENETUNREACH; - return -1; - } - - - if (bcast) *bcast = is_bcast; - - if (prt == 0) { - /* handle auto-allocation of ephemeral ports */ - for (prt = 5001; prt < 10000; prt++) { - snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT, - socket_wrapper_dir(), type, iface, prt); - if (stat(un->sun_path, &st) == 0) continue; - - set_port(si->family, prt, si->myname); - break; - } - if (prt == 10000) { - errno = ENFILE; - return -1; - } - } - - snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT, - socket_wrapper_dir(), type, iface, prt); - return 0; -} - -static struct socket_info *find_socket_info(int fd) -{ - struct socket_info *i; - for (i = sockets; i; i = i->next) { - if (i->fd == fd) - return i; - } - - return NULL; -} - -static int sockaddr_convert_to_un(struct socket_info *si, const struct sockaddr *in_addr, socklen_t in_len, - struct sockaddr_un *out_addr, int alloc_sock, int *bcast) -{ - if (!out_addr) - return 0; - - out_addr->sun_family = AF_UNIX; - - switch (in_addr->sa_family) { - case AF_INET: -#ifdef HAVE_IPV6 - case AF_INET6: -#endif - switch (si->type) { - case SOCK_STREAM: - case SOCK_DGRAM: - break; - default: - errno = ESOCKTNOSUPPORT; - return -1; - } - if (alloc_sock) { - return convert_in_un_alloc(si, in_addr, out_addr, bcast); - } else { - return convert_in_un_remote(si, in_addr, out_addr, bcast); - } - default: - break; - } - - errno = EAFNOSUPPORT; - return -1; -} - -static int sockaddr_convert_from_un(const struct socket_info *si, - const struct sockaddr_un *in_addr, - socklen_t un_addrlen, - int family, - struct sockaddr *out_addr, - socklen_t *out_addrlen) -{ - if (out_addr == NULL || out_addrlen == NULL) - return 0; - - if (un_addrlen == 0) { - *out_addrlen = 0; - return 0; - } - - switch (family) { - case AF_INET: -#ifdef HAVE_IPV6 - case AF_INET6: -#endif - switch (si->type) { - case SOCK_STREAM: - case SOCK_DGRAM: - break; - default: - errno = ESOCKTNOSUPPORT; - return -1; - } - return convert_un_in(in_addr, out_addr, out_addrlen); - default: - break; - } - - errno = EAFNOSUPPORT; - return -1; -} - -enum swrap_packet_type { - SWRAP_CONNECT_SEND, - SWRAP_CONNECT_UNREACH, - SWRAP_CONNECT_RECV, - SWRAP_CONNECT_ACK, - SWRAP_ACCEPT_SEND, - SWRAP_ACCEPT_RECV, - SWRAP_ACCEPT_ACK, - SWRAP_RECVFROM, - SWRAP_SENDTO, - SWRAP_SENDTO_UNREACH, - SWRAP_PENDING_RST, - SWRAP_RECV, - SWRAP_RECV_RST, - SWRAP_SEND, - SWRAP_SEND_RST, - SWRAP_CLOSE_SEND, - SWRAP_CLOSE_RECV, - SWRAP_CLOSE_ACK -}; - -struct swrap_file_hdr { - uint32_t magic; - uint16_t version_major; - uint16_t version_minor; - int32_t timezone; - uint32_t sigfigs; - uint32_t frame_max_len; -#define SWRAP_FRAME_LENGTH_MAX 0xFFFF - uint32_t link_type; -}; -#define SWRAP_FILE_HDR_SIZE 24 - -struct swrap_packet { - struct { - uint32_t seconds; - uint32_t micro_seconds; - uint32_t recorded_length; - uint32_t full_length; - } frame; -#define SWRAP_PACKET__FRAME_SIZE 16 - - struct { - struct { - uint8_t ver_hdrlen; - uint8_t tos; - uint16_t packet_length; - uint16_t identification; - uint8_t flags; - uint8_t fragment; - uint8_t ttl; - uint8_t protocol; - uint16_t hdr_checksum; - uint32_t src_addr; - uint32_t dest_addr; - } hdr; -#define SWRAP_PACKET__IP_HDR_SIZE 20 - - union { - struct { - uint16_t source_port; - uint16_t dest_port; - uint32_t seq_num; - uint32_t ack_num; - uint8_t hdr_length; - uint8_t control; - uint16_t window; - uint16_t checksum; - uint16_t urg; - } tcp; -#define SWRAP_PACKET__IP_P_TCP_SIZE 20 - struct { - uint16_t source_port; - uint16_t dest_port; - uint16_t length; - uint16_t checksum; - } udp; -#define SWRAP_PACKET__IP_P_UDP_SIZE 8 - struct { - uint8_t type; - uint8_t code; - uint16_t checksum; - uint32_t unused; - } icmp; -#define SWRAP_PACKET__IP_P_ICMP_SIZE 8 - } p; - } ip; -}; -#define SWRAP_PACKET_SIZE 56 - -static const char *socket_wrapper_pcap_file(void) -{ - static int initialized = 0; - static const char *s = NULL; - static const struct swrap_file_hdr h = { 0, }; - static const struct swrap_packet p = { { 0, }, { { 0, }, { { 0, } } } }; - - if (initialized == 1) { - return s; - } - initialized = 1; - - /* - * TODO: don't use the structs use plain buffer offsets - * and PUSH_U8(), PUSH_U16() and PUSH_U32() - * - * for now make sure we disable PCAP support - * if the struct has alignment! - */ - if (sizeof(h) != SWRAP_FILE_HDR_SIZE) { - return NULL; - } - if (sizeof(p) != SWRAP_PACKET_SIZE) { - return NULL; - } - if (sizeof(p.frame) != SWRAP_PACKET__FRAME_SIZE) { - return NULL; - } - if (sizeof(p.ip.hdr) != SWRAP_PACKET__IP_HDR_SIZE) { - return NULL; - } - if (sizeof(p.ip.p.tcp) != SWRAP_PACKET__IP_P_TCP_SIZE) { - return NULL; - } - if (sizeof(p.ip.p.udp) != SWRAP_PACKET__IP_P_UDP_SIZE) { - return NULL; - } - if (sizeof(p.ip.p.icmp) != SWRAP_PACKET__IP_P_ICMP_SIZE) { - return NULL; - } - - s = getenv("SOCKET_WRAPPER_PCAP_FILE"); - if (s == NULL) { - return NULL; - } - if (strncmp(s, "./", 2) == 0) { - s += 2; - } - return s; -} - -static struct swrap_packet *swrap_packet_init(struct timeval *tval, - const struct sockaddr_in *src_addr, - const struct sockaddr_in *dest_addr, - int socket_type, - const unsigned char *payload, - size_t payload_len, - unsigned long tcp_seq, - unsigned long tcp_ack, - unsigned char tcp_ctl, - int unreachable, - size_t *_packet_len) -{ - struct swrap_packet *ret; - struct swrap_packet *packet; - size_t packet_len; - size_t alloc_len; - size_t nonwire_len = sizeof(packet->frame); - size_t wire_hdr_len = 0; - size_t wire_len = 0; - size_t icmp_hdr_len = 0; - size_t icmp_truncate_len = 0; - unsigned char protocol = 0, icmp_protocol = 0; - unsigned short src_port = src_addr->sin_port; - unsigned short dest_port = dest_addr->sin_port; - - switch (socket_type) { - case SOCK_STREAM: - protocol = 0x06; /* TCP */ - wire_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.tcp); - wire_len = wire_hdr_len + payload_len; - break; - - case SOCK_DGRAM: - protocol = 0x11; /* UDP */ - wire_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.udp); - wire_len = wire_hdr_len + payload_len; - break; - - default: - return NULL; - } - - if (unreachable) { - icmp_protocol = protocol; - protocol = 0x01; /* ICMP */ - if (wire_len > 64 ) { - icmp_truncate_len = wire_len - 64; - } - icmp_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.icmp); - wire_hdr_len += icmp_hdr_len; - wire_len += icmp_hdr_len; - } - - packet_len = nonwire_len + wire_len; - alloc_len = packet_len; - if (alloc_len < sizeof(struct swrap_packet)) { - alloc_len = sizeof(struct swrap_packet); - } - ret = (struct swrap_packet *)malloc(alloc_len); - if (!ret) return NULL; - - packet = ret; - - packet->frame.seconds = tval->tv_sec; - packet->frame.micro_seconds = tval->tv_usec; - packet->frame.recorded_length = wire_len - icmp_truncate_len; - packet->frame.full_length = wire_len - icmp_truncate_len; - - packet->ip.hdr.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */ - packet->ip.hdr.tos = 0x00; - packet->ip.hdr.packet_length = htons(wire_len - icmp_truncate_len); - packet->ip.hdr.identification = htons(0xFFFF); - packet->ip.hdr.flags = 0x40; /* BIT 1 set - means don't fraqment */ - packet->ip.hdr.fragment = htons(0x0000); - packet->ip.hdr.ttl = 0xFF; - packet->ip.hdr.protocol = protocol; - packet->ip.hdr.hdr_checksum = htons(0x0000); - packet->ip.hdr.src_addr = src_addr->sin_addr.s_addr; - packet->ip.hdr.dest_addr = dest_addr->sin_addr.s_addr; - - if (unreachable) { - packet->ip.p.icmp.type = 0x03; /* destination unreachable */ - packet->ip.p.icmp.code = 0x01; /* host unreachable */ - packet->ip.p.icmp.checksum = htons(0x0000); - packet->ip.p.icmp.unused = htonl(0x00000000); - - /* set the ip header in the ICMP payload */ - packet = (struct swrap_packet *)(((unsigned char *)ret) + icmp_hdr_len); - packet->ip.hdr.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */ - packet->ip.hdr.tos = 0x00; - packet->ip.hdr.packet_length = htons(wire_len - icmp_hdr_len); - packet->ip.hdr.identification = htons(0xFFFF); - packet->ip.hdr.flags = 0x40; /* BIT 1 set - means don't fraqment */ - packet->ip.hdr.fragment = htons(0x0000); - packet->ip.hdr.ttl = 0xFF; - packet->ip.hdr.protocol = icmp_protocol; - packet->ip.hdr.hdr_checksum = htons(0x0000); - packet->ip.hdr.src_addr = dest_addr->sin_addr.s_addr; - packet->ip.hdr.dest_addr = src_addr->sin_addr.s_addr; - - src_port = dest_addr->sin_port; - dest_port = src_addr->sin_port; - } - - switch (socket_type) { - case SOCK_STREAM: - packet->ip.p.tcp.source_port = src_port; - packet->ip.p.tcp.dest_port = dest_port; - packet->ip.p.tcp.seq_num = htonl(tcp_seq); - packet->ip.p.tcp.ack_num = htonl(tcp_ack); - packet->ip.p.tcp.hdr_length = 0x50; /* 5 * 32 bit words */ - packet->ip.p.tcp.control = tcp_ctl; - packet->ip.p.tcp.window = htons(0x7FFF); - packet->ip.p.tcp.checksum = htons(0x0000); - packet->ip.p.tcp.urg = htons(0x0000); - - break; - - case SOCK_DGRAM: - packet->ip.p.udp.source_port = src_addr->sin_port; - packet->ip.p.udp.dest_port = dest_addr->sin_port; - packet->ip.p.udp.length = htons(8 + payload_len); - packet->ip.p.udp.checksum = htons(0x0000); - - break; - } - - if (payload && payload_len > 0) { - unsigned char *p = (unsigned char *)ret; - p += nonwire_len; - p += wire_hdr_len; - memcpy(p, payload, payload_len); - } - - *_packet_len = packet_len - icmp_truncate_len; - return ret; -} - -static int swrap_get_pcap_fd(const char *fname) -{ - static int fd = -1; - - if (fd != -1) return fd; - - fd = open(fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0644); - if (fd != -1) { - struct swrap_file_hdr file_hdr; - file_hdr.magic = 0xA1B2C3D4; - file_hdr.version_major = 0x0002; - file_hdr.version_minor = 0x0004; - file_hdr.timezone = 0x00000000; - file_hdr.sigfigs = 0x00000000; - file_hdr.frame_max_len = SWRAP_FRAME_LENGTH_MAX; - file_hdr.link_type = 0x0065; /* 101 RAW IP */ - - write(fd, &file_hdr, sizeof(file_hdr)); - return fd; - } - - fd = open(fname, O_WRONLY|O_APPEND, 0644); - - return fd; -} - -static struct swrap_packet *swrap_marshall_packet(struct socket_info *si, - const struct sockaddr *addr, - enum swrap_packet_type type, - const void *buf, size_t len, - size_t *packet_len) -{ - const struct sockaddr_in *src_addr; - const struct sockaddr_in *dest_addr; - unsigned long tcp_seq = 0; - unsigned long tcp_ack = 0; - unsigned char tcp_ctl = 0; - int unreachable = 0; - - struct timeval tv; - - switch (si->family) { - case AF_INET: - break; - default: - return NULL; - } - - switch (type) { - case SWRAP_CONNECT_SEND: - if (si->type != SOCK_STREAM) return NULL; - - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)addr; - - tcp_seq = si->io.pck_snd; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x02; /* SYN */ - - si->io.pck_snd += 1; - - break; - - case SWRAP_CONNECT_RECV: - if (si->type != SOCK_STREAM) return NULL; - - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)addr; - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x12; /** SYN,ACK */ - - si->io.pck_rcv += 1; - - break; - - case SWRAP_CONNECT_UNREACH: - if (si->type != SOCK_STREAM) return NULL; - - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)addr; - - /* Unreachable: resend the data of SWRAP_CONNECT_SEND */ - tcp_seq = si->io.pck_snd - 1; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x02; /* SYN */ - unreachable = 1; - - break; - - case SWRAP_CONNECT_ACK: - if (si->type != SOCK_STREAM) return NULL; - - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)addr; - - tcp_seq = si->io.pck_snd; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x10; /* ACK */ - - break; - - case SWRAP_ACCEPT_SEND: - if (si->type != SOCK_STREAM) return NULL; - - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)addr; - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x02; /* SYN */ - - si->io.pck_rcv += 1; - - break; - - case SWRAP_ACCEPT_RECV: - if (si->type != SOCK_STREAM) return NULL; - - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)addr; - - tcp_seq = si->io.pck_snd; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x12; /* SYN,ACK */ - - si->io.pck_snd += 1; - - break; - - case SWRAP_ACCEPT_ACK: - if (si->type != SOCK_STREAM) return NULL; - - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)addr; - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x10; /* ACK */ - - break; - - case SWRAP_SEND: - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)si->peername; - - tcp_seq = si->io.pck_snd; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x18; /* PSH,ACK */ - - si->io.pck_snd += len; - - break; - - case SWRAP_SEND_RST: - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)si->peername; - - if (si->type == SOCK_DGRAM) { - return swrap_marshall_packet(si, si->peername, - SWRAP_SENDTO_UNREACH, - buf, len, packet_len); - } - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x14; /** RST,ACK */ - - break; - - case SWRAP_PENDING_RST: - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)si->peername; - - if (si->type == SOCK_DGRAM) { - return NULL; - } - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x14; /* RST,ACK */ - - break; - - case SWRAP_RECV: - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)si->peername; - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x18; /* PSH,ACK */ - - si->io.pck_rcv += len; - - break; - - case SWRAP_RECV_RST: - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)si->peername; - - if (si->type == SOCK_DGRAM) { - return NULL; - } - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x14; /* RST,ACK */ - - break; - - case SWRAP_SENDTO: - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)addr; - - si->io.pck_snd += len; - - break; - - case SWRAP_SENDTO_UNREACH: - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)addr; - - unreachable = 1; - - break; - - case SWRAP_RECVFROM: - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)addr; - - si->io.pck_rcv += len; - - break; - - case SWRAP_CLOSE_SEND: - if (si->type != SOCK_STREAM) return NULL; - - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)si->peername; - - tcp_seq = si->io.pck_snd; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x11; /* FIN, ACK */ - - si->io.pck_snd += 1; - - break; - - case SWRAP_CLOSE_RECV: - if (si->type != SOCK_STREAM) return NULL; - - dest_addr = (const struct sockaddr_in *)si->myname; - src_addr = (const struct sockaddr_in *)si->peername; - - tcp_seq = si->io.pck_rcv; - tcp_ack = si->io.pck_snd; - tcp_ctl = 0x11; /* FIN,ACK */ - - si->io.pck_rcv += 1; - - break; - - case SWRAP_CLOSE_ACK: - if (si->type != SOCK_STREAM) return NULL; - - src_addr = (const struct sockaddr_in *)si->myname; - dest_addr = (const struct sockaddr_in *)si->peername; - - tcp_seq = si->io.pck_snd; - tcp_ack = si->io.pck_rcv; - tcp_ctl = 0x10; /* ACK */ - - break; - default: - return NULL; - } - - swrapGetTimeOfDay(&tv); - - return swrap_packet_init(&tv, src_addr, dest_addr, si->type, - (const unsigned char *)buf, len, - tcp_seq, tcp_ack, tcp_ctl, unreachable, - packet_len); -} - -static void swrap_dump_packet(struct socket_info *si, - const struct sockaddr *addr, - enum swrap_packet_type type, - const void *buf, size_t len) -{ - const char *file_name; - struct swrap_packet *packet; - size_t packet_len = 0; - int fd; - - file_name = socket_wrapper_pcap_file(); - if (!file_name) { - return; - } - - packet = swrap_marshall_packet(si, addr, type, buf, len, &packet_len); - if (!packet) { - return; - } - - fd = swrap_get_pcap_fd(file_name); - if (fd != -1) { - write(fd, packet, packet_len); - } - - free(packet); -} - -_PUBLIC_ int swrap_socket(int family, int type, int protocol) -{ - struct socket_info *si; - int fd; - - if (!socket_wrapper_dir()) { - return real_socket(family, type, protocol); - } - - switch (family) { - case AF_INET: -#ifdef HAVE_IPV6 - case AF_INET6: -#endif - break; - case AF_UNIX: - return real_socket(family, type, protocol); - default: - errno = EAFNOSUPPORT; - return -1; - } - - switch (type) { - case SOCK_STREAM: - break; - case SOCK_DGRAM: - break; - default: - errno = EPROTONOSUPPORT; - return -1; - } - - switch (protocol) { - case 0: - break; - case 6: - if (type == SOCK_STREAM) { - break; - } - /*fall through*/ - case 17: - if (type == SOCK_DGRAM) { - break; - } - /*fall through*/ - default: - errno = EPROTONOSUPPORT; - return -1; - } - - fd = real_socket(AF_UNIX, type, 0); - - if (fd == -1) return -1; - - si = (struct socket_info *)calloc(1, sizeof(struct socket_info)); - - si->family = family; - si->type = type; - si->protocol = protocol; - si->fd = fd; - - SWRAP_DLIST_ADD(sockets, si); - - return si->fd; -} - -_PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen) -{ - struct socket_info *parent_si, *child_si; - int fd; - struct sockaddr_un un_addr; - socklen_t un_addrlen = sizeof(un_addr); - struct sockaddr_un un_my_addr; - socklen_t un_my_addrlen = sizeof(un_my_addr); - struct sockaddr *my_addr; - socklen_t my_addrlen, len; - int ret; - - parent_si = find_socket_info(s); - if (!parent_si) { - return real_accept(s, addr, addrlen); - } - - /* - * assume out sockaddr have the same size as the in parent - * socket family - */ - my_addrlen = socket_length(parent_si->family); - if (my_addrlen <= 0) { - errno = EINVAL; - return -1; - } - - my_addr = (struct sockaddr *)malloc(my_addrlen); - if (my_addr == NULL) { - return -1; - } - - memset(&un_addr, 0, sizeof(un_addr)); - memset(&un_my_addr, 0, sizeof(un_my_addr)); - - ret = real_accept(s, (struct sockaddr *)&un_addr, &un_addrlen); - if (ret == -1) { - free(my_addr); - return ret; - } - - fd = ret; - - len = my_addrlen; - ret = sockaddr_convert_from_un(parent_si, &un_addr, un_addrlen, - parent_si->family, my_addr, &len); - if (ret == -1) { - free(my_addr); - close(fd); - return ret; - } - - child_si = (struct socket_info *)malloc(sizeof(struct socket_info)); - memset(child_si, 0, sizeof(*child_si)); - - child_si->fd = fd; - child_si->family = parent_si->family; - child_si->type = parent_si->type; - child_si->protocol = parent_si->protocol; - child_si->bound = 1; - child_si->is_server = 1; - - child_si->peername_len = len; - child_si->peername = sockaddr_dup(my_addr, len); - - if (addr != NULL && addrlen != NULL) { - *addrlen = len; - if (*addrlen >= len) - memcpy(addr, my_addr, len); - *addrlen = 0; - } - - ret = real_getsockname(fd, (struct sockaddr *)&un_my_addr, &un_my_addrlen); - if (ret == -1) { - free(child_si); - close(fd); - return ret; - } - - len = my_addrlen; - ret = sockaddr_convert_from_un(child_si, &un_my_addr, un_my_addrlen, - child_si->family, my_addr, &len); - if (ret == -1) { - free(child_si); - free(my_addr); - close(fd); - return ret; - } - - child_si->myname_len = len; - child_si->myname = sockaddr_dup(my_addr, len); - free(my_addr); - - SWRAP_DLIST_ADD(sockets, child_si); - - swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_SEND, NULL, 0); - swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_RECV, NULL, 0); - swrap_dump_packet(child_si, addr, SWRAP_ACCEPT_ACK, NULL, 0); - - return fd; -} - -static int autobind_start_init; -static int autobind_start; - -/* using sendto() or connect() on an unbound socket would give the - recipient no way to reply, as unlike UDP and TCP, a unix domain - socket can't auto-assign emphemeral port numbers, so we need to - assign it here */ -static int swrap_auto_bind(struct socket_info *si) -{ - struct sockaddr_un un_addr; - int i; - char type; - int ret; - int port; - struct stat st; - - if (autobind_start_init != 1) { - autobind_start_init = 1; - autobind_start = getpid(); - autobind_start %= 50000; - autobind_start += 10000; - } - - un_addr.sun_family = AF_UNIX; - - switch (si->family) { - case AF_INET: { - struct sockaddr_in in; - - switch (si->type) { - case SOCK_STREAM: - type = SOCKET_TYPE_CHAR_TCP; - break; - case SOCK_DGRAM: - type = SOCKET_TYPE_CHAR_UDP; - break; - default: - errno = ESOCKTNOSUPPORT; - return -1; - } - - memset(&in, 0, sizeof(in)); - in.sin_family = AF_INET; - in.sin_addr.s_addr = htonl(127<<24 | - socket_wrapper_default_iface()); - - si->myname_len = sizeof(in); - si->myname = sockaddr_dup(&in, si->myname_len); - break; - } -#ifdef HAVE_IPV6 - case AF_INET6: { - struct sockaddr_in6 in6; - - switch (si->type) { - case SOCK_STREAM: - type = SOCKET_TYPE_CHAR_TCP_V6; - break; - case SOCK_DGRAM: - type = SOCKET_TYPE_CHAR_UDP_V6; - break; - default: - errno = ESOCKTNOSUPPORT; - return -1; - } - - memset(&in6, 0, sizeof(in6)); - in6.sin6_family = AF_INET6; - in6.sin6_addr.s6_addr[0] = SW_IPV6_ADDRESS; - si->myname_len = sizeof(in6); - si->myname = sockaddr_dup(&in6, si->myname_len); - break; - } -#endif - default: - errno = ESOCKTNOSUPPORT; - return -1; - } - - if (autobind_start > 60000) { - autobind_start = 10000; - } - - for (i=0;i<1000;i++) { - port = autobind_start + i; - snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), - "%s/"SOCKET_FORMAT, socket_wrapper_dir(), - type, socket_wrapper_default_iface(), port); - if (stat(un_addr.sun_path, &st) == 0) continue; - - ret = real_bind(si->fd, (struct sockaddr *)&un_addr, sizeof(un_addr)); - if (ret == -1) return ret; - - si->tmp_path = strdup(un_addr.sun_path); - si->bound = 1; - autobind_start = port + 1; - break; - } - if (i == 1000) { - errno = ENFILE; - return -1; - } - - set_port(si->family, port, si->myname); - - return 0; -} - - -_PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen) -{ - int ret; - struct sockaddr_un un_addr; - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_connect(s, serv_addr, addrlen); - } - - if (si->bound == 0) { - ret = swrap_auto_bind(si); - if (ret == -1) return -1; - } - - if (si->family != serv_addr->sa_family) { - errno = EINVAL; - return -1; - } - - ret = sockaddr_convert_to_un(si, (const struct sockaddr *)serv_addr, addrlen, &un_addr, 0, NULL); - if (ret == -1) return -1; - - swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_SEND, NULL, 0); - - ret = real_connect(s, (struct sockaddr *)&un_addr, - sizeof(struct sockaddr_un)); - - /* to give better errors */ - if (ret == -1 && errno == ENOENT) { - errno = EHOSTUNREACH; - } - - if (ret == 0) { - si->peername_len = addrlen; - si->peername = sockaddr_dup(serv_addr, addrlen); - - swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_RECV, NULL, 0); - swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_ACK, NULL, 0); - } else { - swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_UNREACH, NULL, 0); - } - - return ret; -} - -_PUBLIC_ int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen) -{ - int ret; - struct sockaddr_un un_addr; - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_bind(s, myaddr, addrlen); - } - - si->myname_len = addrlen; - si->myname = sockaddr_dup(myaddr, addrlen); - - ret = sockaddr_convert_to_un(si, (const struct sockaddr *)myaddr, addrlen, &un_addr, 1, &si->bcast); - if (ret == -1) return -1; - - unlink(un_addr.sun_path); - - ret = real_bind(s, (struct sockaddr *)&un_addr, - sizeof(struct sockaddr_un)); - - if (ret == 0) { - si->bound = 1; - } - - return ret; -} - -_PUBLIC_ int swrap_listen(int s, int backlog) -{ - int ret; - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_listen(s, backlog); - } - - ret = real_listen(s, backlog); - - return ret; -} - -_PUBLIC_ int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen) -{ - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_getpeername(s, name, addrlen); - } - - if (!si->peername) - { - errno = ENOTCONN; - return -1; - } - - memcpy(name, si->peername, si->peername_len); - *addrlen = si->peername_len; - - return 0; -} - -_PUBLIC_ int swrap_getsockname(int s, struct sockaddr *name, socklen_t *addrlen) -{ - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_getsockname(s, name, addrlen); - } - - memcpy(name, si->myname, si->myname_len); - *addrlen = si->myname_len; - - return 0; -} - -_PUBLIC_ int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) -{ - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_getsockopt(s, level, optname, optval, optlen); - } - - if (level == SOL_SOCKET) { - return real_getsockopt(s, level, optname, optval, optlen); - } - - errno = ENOPROTOOPT; - return -1; -} - -_PUBLIC_ int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) -{ - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_setsockopt(s, level, optname, optval, optlen); - } - - if (level == SOL_SOCKET) { - return real_setsockopt(s, level, optname, optval, optlen); - } - - switch (si->family) { - case AF_INET: - return 0; - default: - errno = ENOPROTOOPT; - return -1; - } -} - -_PUBLIC_ ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) -{ - struct sockaddr_un un_addr; - socklen_t un_addrlen = sizeof(un_addr); - int ret; - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_recvfrom(s, buf, len, flags, from, fromlen); - } - - len = MIN(len, 1500); - - /* irix 6.4 forgets to null terminate the sun_path string :-( */ - memset(&un_addr, 0, sizeof(un_addr)); - ret = real_recvfrom(s, buf, len, flags, (struct sockaddr *)&un_addr, &un_addrlen); - if (ret == -1) - return ret; - - if (sockaddr_convert_from_un(si, &un_addr, un_addrlen, - si->family, from, fromlen) == -1) { - return -1; - } - - swrap_dump_packet(si, from, SWRAP_RECVFROM, buf, ret); - - return ret; -} - - -_PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) -{ - struct sockaddr_un un_addr; - int ret; - struct socket_info *si = find_socket_info(s); - int bcast = 0; - - if (!si) { - return real_sendto(s, buf, len, flags, to, tolen); - } - - len = MIN(len, 1500); - - switch (si->type) { - case SOCK_STREAM: - ret = real_send(s, buf, len, flags); - break; - case SOCK_DGRAM: - if (si->bound == 0) { - ret = swrap_auto_bind(si); - if (ret == -1) return -1; - } - - ret = sockaddr_convert_to_un(si, to, tolen, &un_addr, 0, &bcast); - if (ret == -1) return -1; - - if (bcast) { - struct stat st; - unsigned int iface; - unsigned int prt = ntohs(((const struct sockaddr_in *)to)->sin_port); - char type; - - type = SOCKET_TYPE_CHAR_UDP; - - for(iface=0; iface <= MAX_WRAPPED_INTERFACES; iface++) { - snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s/"SOCKET_FORMAT, - socket_wrapper_dir(), type, iface, prt); - if (stat(un_addr.sun_path, &st) != 0) continue; - - /* ignore the any errors in broadcast sends */ - real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr)); - } - - swrap_dump_packet(si, to, SWRAP_SENDTO, buf, len); - - return len; - } - - ret = real_sendto(s, buf, len, flags, (struct sockaddr *)&un_addr, sizeof(un_addr)); - break; - default: - ret = -1; - errno = EHOSTUNREACH; - break; - } - - /* to give better errors */ - if (ret == -1 && errno == ENOENT) { - errno = EHOSTUNREACH; - } - - if (ret == -1) { - swrap_dump_packet(si, to, SWRAP_SENDTO, buf, len); - swrap_dump_packet(si, to, SWRAP_SENDTO_UNREACH, buf, len); - } else { - swrap_dump_packet(si, to, SWRAP_SENDTO, buf, ret); - } - - return ret; -} - -_PUBLIC_ int swrap_ioctl(int s, int r, void *p) -{ - int ret; - struct socket_info *si = find_socket_info(s); - int value; - - if (!si) { - return real_ioctl(s, r, p); - } - - ret = real_ioctl(s, r, p); - - switch (r) { - case FIONREAD: - value = *((int *)p); - if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) { - swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0); - } else if (value == 0) { /* END OF FILE */ - swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0); - } - break; - } - - return ret; -} - -_PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags) -{ - int ret; - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_recv(s, buf, len, flags); - } - - len = MIN(len, 1500); - - ret = real_recv(s, buf, len, flags); - if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) { - swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0); - } else if (ret == 0) { /* END OF FILE */ - swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0); - } else { - swrap_dump_packet(si, NULL, SWRAP_RECV, buf, ret); - } - - return ret; -} - - -_PUBLIC_ ssize_t swrap_send(int s, const void *buf, size_t len, int flags) -{ - int ret; - struct socket_info *si = find_socket_info(s); - - if (!si) { - return real_send(s, buf, len, flags); - } - - len = MIN(len, 1500); - - ret = real_send(s, buf, len, flags); - - if (ret == -1) { - swrap_dump_packet(si, NULL, SWRAP_SEND, buf, len); - swrap_dump_packet(si, NULL, SWRAP_SEND_RST, NULL, 0); - } else { - swrap_dump_packet(si, NULL, SWRAP_SEND, buf, ret); - } - - return ret; -} - -_PUBLIC_ int swrap_close(int fd) -{ - struct socket_info *si = find_socket_info(fd); - int ret; - - if (!si) { - return real_close(fd); - } - - SWRAP_DLIST_REMOVE(sockets, si); - - if (si->myname && si->peername) { - swrap_dump_packet(si, NULL, SWRAP_CLOSE_SEND, NULL, 0); - } - - ret = real_close(fd); - - if (si->myname && si->peername) { - swrap_dump_packet(si, NULL, SWRAP_CLOSE_RECV, NULL, 0); - swrap_dump_packet(si, NULL, SWRAP_CLOSE_ACK, NULL, 0); - } - - if (si->path) free(si->path); - if (si->myname) free(si->myname); - if (si->peername) free(si->peername); - if (si->tmp_path) { - unlink(si->tmp_path); - free(si->tmp_path); - } - free(si); - - return ret; -} diff --git a/source4/lib/socket_wrapper/socket_wrapper.h b/source4/lib/socket_wrapper/socket_wrapper.h deleted file mode 100644 index cc8b937608..0000000000 --- a/source4/lib/socket_wrapper/socket_wrapper.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) Jelmer Vernooij 2005 - * Copyright (C) Stefan Metzmacher 2006 - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef __SOCKET_WRAPPER_H__ -#define __SOCKET_WRAPPER_H__ - -const char *socket_wrapper_dir(void); -unsigned int socket_wrapper_default_iface(void); -int swrap_socket(int family, int type, int protocol); -int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen); -int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen); -int swrap_listen(int s, int backlog); -int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen); -int swrap_getsockname(int s, struct sockaddr *name, socklen_t *addrlen); -int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen); -int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen); -ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); -ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); -int swrap_ioctl(int s, int req, void *ptr); -ssize_t swrap_recv(int s, void *buf, size_t len, int flags); -ssize_t swrap_send(int s, const void *buf, size_t len, int flags); -int swrap_close(int); - -#ifdef SOCKET_WRAPPER_REPLACE - -#ifdef accept -#undef accept -#endif -#define accept(s,addr,addrlen) swrap_accept(s,addr,addrlen) - -#ifdef connect -#undef connect -#endif -#define connect(s,serv_addr,addrlen) swrap_connect(s,serv_addr,addrlen) - -#ifdef bind -#undef bind -#endif -#define bind(s,myaddr,addrlen) swrap_bind(s,myaddr,addrlen) - -#ifdef listen -#undef listen -#endif -#define listen(s,blog) swrap_listen(s,blog) - -#ifdef getpeername -#undef getpeername -#endif -#define getpeername(s,name,addrlen) swrap_getpeername(s,name,addrlen) - -#ifdef getsockname -#undef getsockname -#endif -#define getsockname(s,name,addrlen) swrap_getsockname(s,name,addrlen) - -#ifdef getsockopt -#undef getsockopt -#endif -#define getsockopt(s,level,optname,optval,optlen) swrap_getsockopt(s,level,optname,optval,optlen) - -#ifdef setsockopt -#undef setsockopt -#endif -#define setsockopt(s,level,optname,optval,optlen) swrap_setsockopt(s,level,optname,optval,optlen) - -#ifdef recvfrom -#undef recvfrom -#endif -#define recvfrom(s,buf,len,flags,from,fromlen) swrap_recvfrom(s,buf,len,flags,from,fromlen) - -#ifdef sendto -#undef sendto -#endif -#define sendto(s,buf,len,flags,to,tolen) swrap_sendto(s,buf,len,flags,to,tolen) - -#ifdef ioctl -#undef ioctl -#endif -#define ioctl(s,req,ptr) swrap_ioctl(s,req,ptr) - -#ifdef recv -#undef recv -#endif -#define recv(s,buf,len,flags) swrap_recv(s,buf,len,flags) - -#ifdef send -#undef send -#endif -#define send(s,buf,len,flags) swrap_send(s,buf,len,flags) - -#ifdef socket -#undef socket -#endif -#define socket(domain,type,protocol) swrap_socket(domain,type,protocol) - -#ifdef close -#undef close -#endif -#define close(s) swrap_close(s) -#endif - - -#endif /* __SOCKET_WRAPPER_H__ */ diff --git a/source4/lib/socket_wrapper/testsuite.c b/source4/lib/socket_wrapper/testsuite.c deleted file mode 100644 index 8877418e4c..0000000000 --- a/source4/lib/socket_wrapper/testsuite.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - local testing of the socket wrapper - - Copyright (C) Jelmer Vernooij 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 . -*/ - -#include "includes.h" -#include "system/network.h" -#include "lib/socket_wrapper/socket_wrapper.h" -#include "torture/torture.h" - -static char *old_dir = NULL; -static char *old_iface = NULL; - -static void backup_env(void) -{ - old_dir = getenv("SOCKET_WRAPPER_DIR"); - old_iface = getenv("SOCKET_WRAPPER_DEFAULT_IFACE"); -} - -static void restore_env(void) -{ - if (old_dir == NULL) - unsetenv("SOCKET_WRAPPER_DIR"); - else - setenv("SOCKET_WRAPPER_DIR", old_dir, 1); - if (old_iface == NULL) - unsetenv("SOCKET_WRAPPER_DEFAULT_IFACE"); - else - setenv("SOCKET_WRAPPER_DEFAULT_IFACE", old_iface, 1); -} - -static bool test_socket_wrapper_dir(struct torture_context *tctx) -{ - backup_env(); - - setenv("SOCKET_WRAPPER_DIR", "foo", 1); - torture_assert_str_equal(tctx, socket_wrapper_dir(), "foo", "setting failed"); - setenv("SOCKET_WRAPPER_DIR", "./foo", 1); - torture_assert_str_equal(tctx, socket_wrapper_dir(), "foo", "setting failed"); - unsetenv("SOCKET_WRAPPER_DIR"); - torture_assert_str_equal(tctx, socket_wrapper_dir(), NULL, "resetting failed"); - - restore_env(); - - return true; -} - -static bool test_swrap_socket(struct torture_context *tctx) -{ - backup_env(); - setenv("SOCKET_WRAPPER_DIR", "foo", 1); - - torture_assert_int_equal(tctx, swrap_socket(1337, 1337, 0), -1, "unknown address family fails"); - torture_assert_int_equal(tctx, errno, EAFNOSUPPORT, "correct errno set"); - torture_assert_int_equal(tctx, swrap_socket(AF_INET, 1337, 0), -1, "unknown type fails"); - torture_assert_int_equal(tctx, errno, EPROTONOSUPPORT, "correct errno set"); - torture_assert_int_equal(tctx, swrap_socket(AF_INET, SOCK_DGRAM, 10), -1, "unknown protocol fails"); - torture_assert_int_equal(tctx, errno, EPROTONOSUPPORT, "correct errno set"); - - restore_env(); - - return true; -} - -unsigned int socket_wrapper_default_iface(void); -static bool test_socket_wrapper_default_iface(struct torture_context *tctx) -{ - backup_env(); - unsetenv("SOCKET_WRAPPER_DEFAULT_IFACE"); - torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 1, "unset"); - setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "2", 1); - torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 2, "unset"); - setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "bla", 1); - torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 1, "unset"); - restore_env(); - return true; -} - -struct torture_suite *torture_local_socket_wrapper(TALLOC_CTX *mem_ctx) -{ - struct torture_suite *suite = torture_suite_create(mem_ctx, - "SOCKET-WRAPPER"); - - torture_suite_add_simple_test(suite, "socket_wrapper_dir", test_socket_wrapper_dir); - torture_suite_add_simple_test(suite, "socket", test_swrap_socket); - torture_suite_add_simple_test(suite, "socket_wrapper_default_iface", test_socket_wrapper_default_iface); - - return suite; -} diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c index 92fa0e5a54..72a7e6485c 100644 --- a/source4/lib/stream/packet.c +++ b/source4/lib/stream/packet.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" #include "lib/socket/socket.h" #include "lib/stream/packet.h" diff --git a/source4/lib/talloc/NEWS b/source4/lib/talloc/NEWS deleted file mode 100644 index e5b3aa0731..0000000000 --- a/source4/lib/talloc/NEWS +++ /dev/null @@ -1,13 +0,0 @@ -1.0.1 26 May 2007 - - BUGS - - * Set name of correctly when using talloc_append_string() (metze) - - LICENSE - - * Change license of files in lib/replace to LGPL (was GPL). (jelmer) - -1.0.0 30 April 2007 - - Initial release. diff --git a/source4/lib/talloc/aclocal.m4 b/source4/lib/talloc/aclocal.m4 deleted file mode 100644 index 5605e476ba..0000000000 --- a/source4/lib/talloc/aclocal.m4 +++ /dev/null @@ -1 +0,0 @@ -m4_include(libreplace.m4) diff --git a/source4/lib/talloc/autogen.sh b/source4/lib/talloc/autogen.sh deleted file mode 100755 index bf84eeee19..0000000000 --- a/source4/lib/talloc/autogen.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -rm -rf autom4te.cache -rm -f configure config.h.in - -IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace" -autoconf $IPATHS || exit 1 -autoheader $IPATHS || exit 1 - -rm -rf autom4te.cache - -echo "Now run ./configure and then make." -exit 0 - diff --git a/source4/lib/talloc/config.guess b/source4/lib/talloc/config.guess deleted file mode 100755 index 354dbe175a..0000000000 --- a/source4/lib/talloc/config.guess +++ /dev/null @@ -1,1464 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-08-03' - -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk deleted file mode 100644 index c13e1b79ab..0000000000 --- a/source4/lib/talloc/config.mk +++ /dev/null @@ -1,7 +0,0 @@ -[LIBRARY::LIBTALLOC] -OUTPUT_TYPE = MERGED_OBJ -CFLAGS = -Ilib/talloc - -LIBTALLOC_OBJ_FILES = lib/talloc/talloc.o - -MANPAGES += $(tallocdir)/talloc.3 diff --git a/source4/lib/talloc/config.sub b/source4/lib/talloc/config.sub deleted file mode 100755 index 23cd6fd75c..0000000000 --- a/source4/lib/talloc/config.sub +++ /dev/null @@ -1,1577 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-07-08' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | ms1 \ - | msp430 \ - | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m32c) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | ms1-* \ - | msp430-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - m32c-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/talloc/install-sh b/source4/lib/talloc/install-sh deleted file mode 100755 index 58719246f0..0000000000 --- a/source4/lib/talloc/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/source4/lib/talloc/rules.mk b/source4/lib/talloc/rules.mk deleted file mode 100644 index 6cee126529..0000000000 --- a/source4/lib/talloc/rules.mk +++ /dev/null @@ -1,18 +0,0 @@ -.SUFFIXES: .c .o .3 .3.xml .xml .html - -showflags:: - @echo 'talloc will be compiled with flags:' - @echo ' CFLAGS = $(CFLAGS)' - @echo ' LIBS = $(LIBS)' - -.c.o: - $(CC) $(PICFLAG) -o $@ -c $< $(CFLAGS) - -.3.xml.3: - -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< - -.xml.html: - -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $< - -distclean:: - rm -f *~ */*~ diff --git a/source4/lib/talloc/talloc.3.xml b/source4/lib/talloc/talloc.3.xml deleted file mode 100644 index 67de15bfc8..0000000000 --- a/source4/lib/talloc/talloc.3.xml +++ /dev/null @@ -1,738 +0,0 @@ - - - - - talloc - 3 - - - talloc -hierarchical reference counted memory pool system with destructors - - -#include <talloc/talloc.h> - - DESCRIPTION - - If you are used to talloc from Samba3 then please read this - carefully, as talloc has changed a lot. - - - The new talloc is a hierarchical, reference counted memory pool - system with destructors. Quite a mouthful really, but not too bad - once you get used to it. - - - Perhaps the biggest change from Samba3 is that there is no - distinction between a "talloc context" and a "talloc pointer". Any - pointer returned from talloc() is itself a valid talloc context. - This means you can do this: - - - struct foo *X = talloc(mem_ctx, struct foo); - X->name = talloc_strdup(X, "foo"); - - - and the pointer X->name - would be a "child" of the talloc context X which is itself a child of - mem_ctx. So if you do - talloc_free(mem_ctx) then - it is all destroyed, whereas if you do talloc_free(X) then just X and X->name are destroyed, and if - you do talloc_free(X->name) then just - the name element of X is - destroyed. - - - If you think about this, then what this effectively gives you is an - n-ary tree, where you can free any part of the tree with - talloc_free(). - - - If you find this confusing, then I suggest you run the testsuite program to watch talloc - in action. You may also like to add your own tests to testsuite.c to clarify how some - particular situation is handled. - - - TALLOC API - - The following is a complete guide to the talloc API. Read it all at - least twice. - - (type *)talloc(const void *ctx, type); - - The talloc() macro is the core of the talloc library. It takes a - memory ctx and a type, and returns a pointer to a new - area of memory of the given type. - - - The returned pointer is itself a talloc context, so you can use - it as the ctx argument to more - calls to talloc() if you wish. - - - The returned pointer is a "child" of the supplied context. This - means that if you talloc_free() the ctx then the new child disappears as - well. Alternatively you can free just the child. - - - The ctx argument to talloc() - can be NULL, in which case a new top level context is created. - - - void *talloc_size(const void *ctx, size_t size); - - The function talloc_size() should be used when you don't have a - convenient type to pass to talloc(). Unlike talloc(), it is not - type safe (as it returns a void *), so you are on your own for - type checking. - - - (typeof(ptr)) talloc_ptrtype(const void *ctx, ptr); - - The talloc_ptrtype() macro should be used when you have a pointer and - want to allocate memory to point at with this pointer. When compiling - with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_size() - and talloc_get_name() will return the current location in the source file. - and not the type. - - - int talloc_free(void *ptr); - - The talloc_free() function frees a piece of talloc memory, and - all its children. You can call talloc_free() on any pointer - returned by talloc(). - - - The return value of talloc_free() indicates success or failure, - with 0 returned for success and -1 for failure. The only - possible failure condition is if ptr had a destructor attached to it and - the destructor returned -1. See talloc_set_destructor() - for details on destructors. - - - If this pointer has an additional parent when talloc_free() is - called then the memory is not actually released, but instead the - most recently established parent is destroyed. See talloc_reference() - for details on establishing additional parents. - - - For more control on which parent is removed, see talloc_unlink(). - - - talloc_free() operates recursively on its children. - - - void *talloc_reference(const void *ctx, const void *ptr); - - The talloc_reference() function makes ctx an additional parent of ptr. - - - The return value of talloc_reference() is always the original - pointer ptr, unless talloc ran - out of memory in creating the reference in which case it will - return NULL (each additional reference consumes around 48 bytes - of memory on intel x86 platforms). - - - If ptr is NULL, then the - function is a no-op, and simply returns NULL. - - - After creating a reference you can free it in one of the - following ways: - - - - - - you can talloc_free() any parent of the original pointer. - That will reduce the number of parents of this pointer by 1, - and will cause this pointer to be freed if it runs out of - parents. - - - - - you can talloc_free() the pointer itself. That will destroy - the most recently established parent to the pointer and leave - the pointer as a child of its current parent. - - - - - - For more control on which parent to remove, see talloc_unlink(). - - - int talloc_unlink(const void *ctx, const void *ptr); - - The talloc_unlink() function removes a specific parent from - ptr. The ctx passed must either be a context used - in talloc_reference() with this pointer, or must be a direct - parent of ptr. - - - Note that if the parent has already been removed using - talloc_free() then this function will fail and will return -1. - Likewise, if ptr is NULL, then - the function will make no modifications and return -1. - - - Usually you can just use talloc_free() instead of - talloc_unlink(), but sometimes it is useful to have the - additional control on which parent is removed. - - - void talloc_set_destructor(const void *ptr, int (*destructor)(void *)); - - The function talloc_set_destructor() sets the destructor for the pointer ptr. A destructor is a function that is called - when the memory used by a pointer is about to be released. The - destructor receives ptr as an - argument, and should return 0 for success and -1 for failure. - - - The destructor can do anything - it wants to, including freeing other pieces of memory. A common - use for destructors is to clean up operating system resources - (such as open file descriptors) contained in the structure the - destructor is placed on. - - - You can only place one destructor on a pointer. If you need more - than one destructor then you can create a zero-length child of - the pointer and place an additional destructor on that. - - - To remove a destructor call talloc_set_destructor() with NULL for - the destructor. - - - If your destructor attempts to talloc_free() the pointer that it - is the destructor for then talloc_free() will return -1 and the - free will be ignored. This would be a pointless operation - anyway, as the destructor is only called when the memory is just - about to go away. - - - int talloc_increase_ref_count(const void *<emphasis role="italic">ptr</emphasis>); - - The talloc_increase_ref_count(ptr) function is exactly equivalent to: - - talloc_reference(NULL, ptr); - - You can use either syntax, depending on which you think is - clearer in your code. - - - It returns 0 on success and -1 on failure. - - - size_t talloc_reference_count(const void *<emphasis role="italic">ptr</emphasis>); - - Return the number of references to the pointer. - - - void talloc_set_name(const void *ptr, const char *fmt, ...); - - Each talloc pointer has a "name". The name is used principally - for debugging purposes, although it is also possible to set and - get the name on a pointer in as a way of "marking" pointers in - your code. - - - The main use for names on pointer is for "talloc reports". See - talloc_report_depth_cb(), - talloc_report_depth_file(), - talloc_report() - talloc_report() - and talloc_report_full() - for details. Also see talloc_enable_leak_report() - and talloc_enable_leak_report_full(). - - - The talloc_set_name() function allocates memory as a child of the - pointer. It is logically equivalent to: - - talloc_set_name_const(ptr, talloc_asprintf(ptr, fmt, ...)); - - Note that multiple calls to talloc_set_name() will allocate more - memory without releasing the name. All of the memory is released - when the ptr is freed using talloc_free(). - - - void talloc_set_name_const(const void *<emphasis role="italic">ptr</emphasis>, const char *<emphasis role="italic">name</emphasis>); - - The function talloc_set_name_const() is just like - talloc_set_name(), but it takes a string constant, and is much - faster. It is extensively used by the "auto naming" macros, such - as talloc_p(). - - - This function does not allocate any memory. It just copies the - supplied pointer into the internal representation of the talloc - ptr. This means you must not pass a name pointer to memory that will - disappear before ptr is freed - with talloc_free(). - - - void *talloc_named(const void *<emphasis role="italic">ctx</emphasis>, size_t <emphasis role="italic">size</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, ...); - - The talloc_named() function creates a named talloc pointer. It - is equivalent to: - - ptr = talloc_size(ctx, size); -talloc_set_name(ptr, fmt, ....); - - void *talloc_named_const(const void *<emphasis role="italic">ctx</emphasis>, size_t <emphasis role="italic">size</emphasis>, const char *<emphasis role="italic">name</emphasis>); - - This is equivalent to: - - ptr = talloc_size(ctx, size); -talloc_set_name_const(ptr, name); - - const char *talloc_get_name(const void *<emphasis role="italic">ptr</emphasis>); - - This returns the current name for the given talloc pointer, - ptr. See talloc_set_name() - for details. - - - void *talloc_init(const char *<emphasis role="italic">fmt</emphasis>, ...); - - This function creates a zero length named talloc context as a top - level context. It is equivalent to: - - talloc_named(NULL, 0, fmt, ...); - - void *talloc_new(void *<emphasis role="italic">ctx</emphasis>); - - This is a utility macro that creates a new memory context hanging - off an exiting context, automatically naming it "talloc_new: - __location__" where __location__ is the source line it is called - from. It is particularly useful for creating a new temporary - working context. - - - (<emphasis role="italic">type</emphasis> *)talloc_realloc(const void *<emphasis role="italic">ctx</emphasis>, void *<emphasis role="italic">ptr</emphasis>, <emphasis role="italic">type</emphasis>, <emphasis role="italic">count</emphasis>); - - The talloc_realloc() macro changes the size of a talloc pointer. - It has the following equivalences: - - talloc_realloc(ctx, NULL, type, 1) ==> talloc(ctx, type); -talloc_realloc(ctx, ptr, type, 0) ==> talloc_free(ptr); - - The ctx argument is only used - if ptr is not NULL, otherwise - it is ignored. - - - talloc_realloc() returns the new pointer, or NULL on failure. - The call will fail either due to a lack of memory, or because the - pointer has more than one parent (see talloc_reference()). - - - void *talloc_realloc_size(const void *ctx, void *ptr, size_t size); - - the talloc_realloc_size() function is useful when the type is not - known so the type-safe talloc_realloc() cannot be used. - - - TYPE *talloc_steal(const void *<emphasis role="italic">new_ctx</emphasis>, const TYPE *<emphasis role="italic">ptr</emphasis>); - - The talloc_steal() function changes the parent context of a - talloc pointer. It is typically used when the context that the - pointer is currently a child of is going to be freed and you wish - to keep the memory for a longer time. - - - The talloc_steal() function returns the pointer that you pass it. - It does not have any failure modes. - - - NOTE: It is possible to produce loops in the parent/child - relationship if you are not careful with talloc_steal(). No - guarantees are provided as to your sanity or the safety of your - data if you do this. - - - TYPE *talloc_move(const void *<emphasis role="italic">new_ctx</emphasis>, TYPE **<emphasis role="italic">ptr</emphasis>); - - The talloc_move() function is a wrapper around - talloc_steal() which zeros the source pointer after the - move. This avoids a potential source of bugs where a - programmer leaves a pointer in two structures, and uses the - pointer from the old structure after it has been moved to a - new one. - - - size_t talloc_total_size(const void *<emphasis role="italic">ptr</emphasis>); - - The talloc_total_size() function returns the total size in bytes - used by this pointer and all child pointers. Mostly useful for - debugging. - - - Passing NULL is allowed, but it will only give a meaningful - result if talloc_enable_leak_report() or - talloc_enable_leak_report_full() has been called. - - - size_t talloc_total_blocks(const void *<emphasis role="italic">ptr</emphasis>); - - The talloc_total_blocks() function returns the total memory block - count used by this pointer and all child pointers. Mostly useful - for debugging. - - - Passing NULL is allowed, but it will only give a meaningful - result if talloc_enable_leak_report() or - talloc_enable_leak_report_full() has been called. - - - void talloc_report(const void *ptr, FILE *f); - - The talloc_report() function prints a summary report of all - memory used by ptr. One line - of report is printed for each immediate child of ptr, showing the - total memory and number of blocks used by that child. - - - You can pass NULL for the pointer, in which case a report is - printed for the top level memory context, but only if - talloc_enable_leak_report() or talloc_enable_leak_report_full() - has been called. - - - void talloc_report_full(const void *<emphasis role="italic">ptr</emphasis>, FILE *<emphasis role="italic">f</emphasis>); - - This provides a more detailed report than talloc_report(). It - will recursively print the entire tree of memory referenced by - the pointer. References in the tree are shown by giving the name - of the pointer that is referenced. - - - You can pass NULL for the pointer, in which case a report is - printed for the top level memory context, but only if - talloc_enable_leak_report() or talloc_enable_leak_report_full() - has been called. - - - - - void talloc_report_depth_cb - const void *ptr - int depth - int max_depth - void (*callback)(const void *ptr, int depth, int max_depth, int is_ref, void *priv) - void *priv - - - This provides a more flexible reports than talloc_report(). It - will recursively call the callback for the entire tree of memory - referenced by the pointer. References in the tree are passed with - is_ref = 1 and the pointer that is referenced. - - - You can pass NULL for the pointer, in which case a report is - printed for the top level memory context, but only if - talloc_enable_leak_report() or talloc_enable_leak_report_full() - has been called. - - - The recursion is stopped when depth >= max_depth. - max_depth = -1 means only stop at leaf nodes. - - - - - void talloc_report_depth_file - const void *ptr - int depth - int max_depth - FILE *f - - - This provides a more flexible reports than talloc_report(). It - will let you specify the depth and max_depth. - - - void talloc_enable_leak_report(void); - - This enables calling of talloc_report(NULL, stderr) when the - program exits. In Samba4 this is enabled by using the - --leak-report command line option. - - - For it to be useful, this function must be called before any - other talloc function as it establishes a "null context" that - acts as the top of the tree. If you don't call this function - first then passing NULL to talloc_report() or - talloc_report_full() won't give you the full tree printout. - - - Here is a typical talloc report: - - talloc report on 'null_context' (total 267 bytes in 15 blocks) -libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks -libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks -iconv(UTF8,CP850) contains 42 bytes in 2 blocks -libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks -iconv(CP850,UTF8) contains 42 bytes in 2 blocks -iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks -iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks - - - void talloc_enable_leak_report_full(void); - - This enables calling of talloc_report_full(NULL, stderr) when the - program exits. In Samba4 this is enabled by using the - --leak-report-full command line option. - - - For it to be useful, this function must be called before any - other talloc function as it establishes a "null context" that - acts as the top of the tree. If you don't call this function - first then passing NULL to talloc_report() or - talloc_report_full() won't give you the full tree printout. - - - Here is a typical full report: - - full talloc report on 'root' (total 18 bytes in 8 blocks) -p1 contains 18 bytes in 7 blocks (ref 0) - r1 contains 13 bytes in 2 blocks (ref 0) - reference to: p2 - p2 contains 1 bytes in 1 blocks (ref 1) - x3 contains 1 bytes in 1 blocks (ref 0) - x2 contains 1 bytes in 1 blocks (ref 0) - x1 contains 1 bytes in 1 blocks (ref 0) - - - (<emphasis role="italic">type</emphasis> *)talloc_zero(const void *<emphasis role="italic">ctx</emphasis>, <emphasis role="italic">type</emphasis>); - - The talloc_zero() macro is equivalent to: - - ptr = talloc(ctx, type); -if (ptr) memset(ptr, 0, sizeof(type)); - - void *talloc_zero_size(const void *<emphasis role="italic">ctx</emphasis>, size_t <emphasis role="italic">size</emphasis>) - - The talloc_zero_size() function is useful when you don't have a - known type. - - - void *talloc_memdup(const void *<emphasis role="italic">ctx</emphasis>, const void *<emphasis role="italic">p</emphasis>, size_t size); - - The talloc_memdup() function is equivalent to: - - ptr = talloc_size(ctx, size); -if (ptr) memcpy(ptr, p, size); - - char *talloc_strdup(const void *<emphasis role="italic">ctx</emphasis>, const char *<emphasis role="italic">p</emphasis>); - - The talloc_strdup() function is equivalent to: - - ptr = talloc_size(ctx, strlen(p)+1); -if (ptr) memcpy(ptr, p, strlen(p)+1); - - This function sets the name of the new pointer to the passed - string. This is equivalent to: - - talloc_set_name_const(ptr, ptr) - - char *talloc_strndup(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">p</emphasis>, size_t <emphasis role="italic">n</emphasis>); - - The talloc_strndup() function is the talloc equivalent of the C - library function strndup(3). - - - This function sets the name of the new pointer to the passed - string. This is equivalent to: - - talloc_set_name_const(ptr, ptr) - - char *talloc_append_string(const void *<emphasis role="italic">t</emphasis>, char *<emphasis role="italic">orig</emphasis>, const char *<emphasis role="italic">append</emphasis>); - - The talloc_append_string() function appends the given formatted - string to the given string. - - - This function sets the name of the new pointer to the new - string. This is equivalent to: - - talloc_set_name_const(ptr, ptr) - - char *talloc_vasprintf(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, va_list <emphasis role="italic">ap</emphasis>); - - The talloc_vasprintf() function is the talloc equivalent of the C - library function vasprintf(3). - - - This function sets the name of the new pointer to the new - string. This is equivalent to: - - talloc_set_name_const(ptr, ptr) - - char *talloc_asprintf(const void *<emphasis role="italic">t</emphasis>, const char *<emphasis role="italic">fmt</emphasis>, ...); - - The talloc_asprintf() function is the talloc equivalent of the C - library function asprintf(3). - - - This function sets the name of the new pointer to the passed - string. This is equivalent to: - - talloc_set_name_const(ptr, ptr) - - char *talloc_asprintf_append(char *s, const char *fmt, ...); - - The talloc_asprintf_append() function appends the given formatted - string to the given string. - - - This function sets the name of the new pointer to the new - string. This is equivalent to: - - talloc_set_name_const(ptr, ptr) - - (type *)talloc_array(const void *ctx, type, uint_t count); - - The talloc_array() macro is equivalent to: - - (type *)talloc_size(ctx, sizeof(type) * count); - - except that it provides integer overflow protection for the - multiply, returning NULL if the multiply overflows. - - - void *talloc_array_size(const void *ctx, size_t size, uint_t count); - - The talloc_array_size() function is useful when the type is not - known. It operates in the same way as talloc_array(), but takes a - size instead of a type. - - - (typeof(ptr)) talloc_array_ptrtype(const void *ctx, ptr, uint_t count); - - The talloc_ptrtype() macro should be used when you have a pointer to an array - and want to allocate memory of an array to point at with this pointer. When compiling - with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size() - and talloc_get_name() will return the current location in the source file. - and not the type. - - - void *talloc_realloc_fn(const void *ctx, void *ptr, size_t size) - - This is a non-macro version of talloc_realloc(), which is useful - as libraries sometimes want a realloc function pointer. A - realloc(3) implementation encapsulates the functionality of - malloc(3), free(3) and realloc(3) in one call, which is why it is - useful to be able to pass around a single function pointer. - - - void *talloc_autofree_context(void); - - This is a handy utility function that returns a talloc context - which will be automatically freed on program exit. This can be - used to reduce the noise in memory leak reports. - - - void *talloc_check_name(const void *ptr, const char *name); - - This function checks if a pointer has the specified name. If it does then the pointer is - returned. It it doesn't then NULL is returned. - - - (type *)talloc_get_type(const void *ptr, type); - - This macro allows you to do type checking on talloc pointers. It - is particularly useful for void* private pointers. It is - equivalent to this: - - (type *)talloc_check_name(ptr, #type) - - talloc_set_type(const void *ptr, type); - - This macro allows you to force the name of a pointer to be a - particular type. This can be - used in conjunction with talloc_get_type() to do type checking on - void* pointers. - - - It is equivalent to this: - - talloc_set_name_const(ptr, #type) - - - PERFORMANCE - - All the additional features of talloc(3) over malloc(3) do come at a - price. We have a simple performance test in Samba4 that measures - talloc() versus malloc() performance, and it seems that talloc() is - about 10% slower than malloc() on my x86 Debian Linux box. For - Samba, the great reduction in code complexity that we get by using - talloc makes this worthwhile, especially as the total overhead of - talloc/malloc in Samba is already quite small. - - - SEE ALSO - - malloc(3), strndup(3), vasprintf(3), asprintf(3), - - - - COPYRIGHT/LICENSE - - Copyright (C) Andrew Tridgell 2004 - - - 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/. - - - diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c deleted file mode 100644 index 1f7e52439f..0000000000 --- a/source4/lib/talloc/talloc.c +++ /dev/null @@ -1,1732 +0,0 @@ -/* - Samba Unix SMB/CIFS implementation. - - Samba trivial allocation library - new interface - - NOTE: Please read talloc_guide.txt for full documentation - - Copyright (C) Andrew Tridgell 2004 - Copyright (C) Stefan Metzmacher 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -/* - inspired by http://swapped.cc/halloc/ -*/ - -#ifdef _SAMBA_BUILD_ -#include "version.h" -#if (SAMBA_VERSION_MAJOR<4) -#include "includes.h" -/* This is to circumvent SAMBA3's paranoid malloc checker. Here in this file - * we trust ourselves... */ -#ifdef malloc -#undef malloc -#endif -#ifdef realloc -#undef realloc -#endif -#define _TALLOC_SAMBA3 -#endif /* (SAMBA_VERSION_MAJOR<4) */ -#endif /* _SAMBA_BUILD_ */ - -#ifndef _TALLOC_SAMBA3 -#include "replace.h" -#include "talloc.h" -#endif /* not _TALLOC_SAMBA3 */ - -/* use this to force every realloc to change the pointer, to stress test - code that might not cope */ -#define ALWAYS_REALLOC 0 - - -#define MAX_TALLOC_SIZE 0x10000000 -#define TALLOC_MAGIC 0xe814ec70 -#define TALLOC_FLAG_FREE 0x01 -#define TALLOC_FLAG_LOOP 0x02 -#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */ -#define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */ -#define TALLOC_MAGIC_REFERENCE ((const char *)1) - -/* by default we abort when given a bad pointer (such as when talloc_free() is called - on a pointer that came from malloc() */ -#ifndef TALLOC_ABORT -#define TALLOC_ABORT(reason) abort() -#endif - -#ifndef discard_const_p -#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) -# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr))) -#else -# define discard_const_p(type, ptr) ((type *)(ptr)) -#endif -#endif - -/* these macros gain us a few percent of speed on gcc */ -#if (__GNUC__ >= 3) -/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1 - as its first argument */ -#ifndef likely -#define likely(x) __builtin_expect(!!(x), 1) -#endif -#ifndef unlikely -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif -#else -#ifndef likely -#define likely(x) (x) -#endif -#ifndef unlikely -#define unlikely(x) (x) -#endif -#endif - -/* this null_context is only used if talloc_enable_leak_report() or - talloc_enable_leak_report_full() is called, otherwise it remains - NULL -*/ -static void *null_context; -static void *autofree_context; - -struct talloc_reference_handle { - struct talloc_reference_handle *next, *prev; - void *ptr; -}; - -typedef int (*talloc_destructor_t)(void *); - -struct talloc_chunk { - struct talloc_chunk *next, *prev; - struct talloc_chunk *parent, *child; - struct talloc_reference_handle *refs; - talloc_destructor_t destructor; - const char *name; - size_t size; - unsigned flags; - - /* - * "pool" has dual use: - * - * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool" - * marks the end of the currently allocated area. - * - * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool" - * is a pointer to the struct talloc_chunk of the pool that it was - * allocated from. This way children can quickly find the pool to chew - * from. - */ - void *pool; -}; - -/* 16 byte alignment seems to keep everyone happy */ -#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15) -#define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc)) - -static void talloc_abort_double_free(void) -{ - TALLOC_ABORT("Bad talloc magic value - double free"); -} - -static void talloc_abort_unknown_value(void) -{ - TALLOC_ABORT("Bad talloc magic value - unknown value"); -} - -/* panic if we get a bad magic value */ -static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) -{ - const char *pp = (const char *)ptr; - struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); - if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) { - if (tc->flags & TALLOC_FLAG_FREE) { - talloc_abort_double_free(); - } else { - talloc_abort_unknown_value(); - } - } - return tc; -} - -/* hook into the front of the list */ -#define _TLIST_ADD(list, p) \ -do { \ - if (!(list)) { \ - (list) = (p); \ - (p)->next = (p)->prev = NULL; \ - } else { \ - (list)->prev = (p); \ - (p)->next = (list); \ - (p)->prev = NULL; \ - (list) = (p); \ - }\ -} while (0) - -/* remove an element from a list - element doesn't have to be in list. */ -#define _TLIST_REMOVE(list, p) \ -do { \ - if ((p) == (list)) { \ - (list) = (p)->next; \ - if (list) (list)->prev = NULL; \ - } else { \ - if ((p)->prev) (p)->prev->next = (p)->next; \ - if ((p)->next) (p)->next->prev = (p)->prev; \ - } \ - if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \ -} while (0) - - -/* - return the parent chunk of a pointer -*/ -static inline struct talloc_chunk *talloc_parent_chunk(const void *ptr) -{ - struct talloc_chunk *tc; - - if (unlikely(ptr == NULL)) { - return NULL; - } - - tc = talloc_chunk_from_ptr(ptr); - while (tc->prev) tc=tc->prev; - - return tc->parent; -} - -void *talloc_parent(const void *ptr) -{ - struct talloc_chunk *tc = talloc_parent_chunk(ptr); - return tc? TC_PTR_FROM_CHUNK(tc) : NULL; -} - -/* - find parents name -*/ -const char *talloc_parent_name(const void *ptr) -{ - struct talloc_chunk *tc = talloc_parent_chunk(ptr); - return tc? tc->name : NULL; -} - -/* - A pool carries an in-pool object count count in the first 16 bytes. - bytes. This is done to support talloc_steal() to a parent outside of the - pool. The count includes the pool itself, so a talloc_free() on a pool will - only destroy the pool if the count has dropped to zero. A talloc_free() of a - pool member will reduce the count, and eventually also call free(3) on the - pool memory. - - The object count is not put into "struct talloc_chunk" because it is only - relevant for talloc pools and the alignment to 16 bytes would increase the - memory footprint of each talloc chunk by those 16 bytes. -*/ - -#define TALLOC_POOL_HDR_SIZE 16 - -static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc) -{ - return (unsigned int *)((char *)tc + sizeof(struct talloc_chunk)); -} - -/* - Allocate from a pool -*/ - -static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent, - size_t size) -{ - struct talloc_chunk *pool_ctx = NULL; - size_t space_left; - struct talloc_chunk *result; - size_t chunk_size; - - if (parent == NULL) { - return NULL; - } - - if (parent->flags & TALLOC_FLAG_POOL) { - pool_ctx = parent; - } - else if (parent->flags & TALLOC_FLAG_POOLMEM) { - pool_ctx = (struct talloc_chunk *)parent->pool; - } - - if (pool_ctx == NULL) { - return NULL; - } - - space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size) - - ((char *)pool_ctx->pool); - - /* - * Align size to 16 bytes - */ - chunk_size = ((size + 15) & ~15); - - if (space_left < chunk_size) { - return NULL; - } - - result = (struct talloc_chunk *)pool_ctx->pool; - -#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED) - VALGRIND_MAKE_MEM_UNDEFINED(result, size); -#endif - - pool_ctx->pool = (void *)((char *)result + chunk_size); - - result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM; - result->pool = pool_ctx; - - *talloc_pool_objectcount(pool_ctx) += 1; - - return result; -} - -/* - Allocate a bit of memory as a child of an existing pointer -*/ -static inline void *__talloc(const void *context, size_t size) -{ - struct talloc_chunk *tc = NULL; - - if (unlikely(context == NULL)) { - context = null_context; - } - - if (unlikely(size >= MAX_TALLOC_SIZE)) { - return NULL; - } - - if (context != NULL) { - tc = talloc_alloc_pool(talloc_chunk_from_ptr(context), - TC_HDR_SIZE+size); - } - - if (tc == NULL) { - tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size); - if (unlikely(tc == NULL)) return NULL; - tc->flags = TALLOC_MAGIC; - tc->pool = NULL; - } - - tc->size = size; - tc->destructor = NULL; - tc->child = NULL; - tc->name = NULL; - tc->refs = NULL; - - if (likely(context)) { - struct talloc_chunk *parent = talloc_chunk_from_ptr(context); - - if (parent->child) { - parent->child->parent = NULL; - tc->next = parent->child; - tc->next->prev = tc; - } else { - tc->next = NULL; - } - tc->parent = parent; - tc->prev = NULL; - parent->child = tc; - } else { - tc->next = tc->prev = tc->parent = NULL; - } - - return TC_PTR_FROM_CHUNK(tc); -} - -/* - * Create a talloc pool - */ - -void *talloc_pool(const void *context, size_t size) -{ - void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE); - struct talloc_chunk *tc; - - if (unlikely(result == NULL)) { - return NULL; - } - - tc = talloc_chunk_from_ptr(result); - - tc->flags |= TALLOC_FLAG_POOL; - tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE; - - *talloc_pool_objectcount(tc) = 1; - -#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS) - VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size); -#endif - - return result; -} - -/* - setup a destructor to be called on free of a pointer - the destructor should return 0 on success, or -1 on failure. - if the destructor fails then the free is failed, and the memory can - be continued to be used -*/ -void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)) -{ - struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); - tc->destructor = destructor; -} - -/* - increase the reference count on a piece of memory. -*/ -int talloc_increase_ref_count(const void *ptr) -{ - if (unlikely(!talloc_reference(null_context, ptr))) { - return -1; - } - return 0; -} - -/* - helper for talloc_reference() - - this is referenced by a function pointer and should not be inline -*/ -static int talloc_reference_destructor(struct talloc_reference_handle *handle) -{ - struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr); - _TLIST_REMOVE(ptr_tc->refs, handle); - return 0; -} - -/* - more efficient way to add a name to a pointer - the name must point to a - true string constant -*/ -static inline void _talloc_set_name_const(const void *ptr, const char *name) -{ - struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); - tc->name = name; -} - -/* - internal talloc_named_const() -*/ -static inline void *_talloc_named_const(const void *context, size_t size, const char *name) -{ - void *ptr; - - ptr = __talloc(context, size); - if (unlikely(ptr == NULL)) { - return NULL; - } - - _talloc_set_name_const(ptr, name); - - return ptr; -} - -/* - make a secondary reference to a pointer, hanging off the given context. - the pointer remains valid until both the original caller and this given - context are freed. - - the major use for this is when two different structures need to reference the - same underlying data, and you want to be able to free the two instances separately, - and in either order -*/ -void *_talloc_reference(const void *context, const void *ptr) -{ - struct talloc_chunk *tc; - struct talloc_reference_handle *handle; - if (unlikely(ptr == NULL)) return NULL; - - tc = talloc_chunk_from_ptr(ptr); - handle = (struct talloc_reference_handle *)_talloc_named_const(context, - sizeof(struct talloc_reference_handle), - TALLOC_MAGIC_REFERENCE); - if (unlikely(handle == NULL)) return NULL; - - /* note that we hang the destructor off the handle, not the - main context as that allows the caller to still setup their - own destructor on the context if they want to */ - talloc_set_destructor(handle, talloc_reference_destructor); - handle->ptr = discard_const_p(void, ptr); - _TLIST_ADD(tc->refs, handle); - return handle->ptr; -} - - -/* - internal talloc_free call -*/ -static inline int _talloc_free(void *ptr) -{ - struct talloc_chunk *tc; - - if (unlikely(ptr == NULL)) { - return -1; - } - - tc = talloc_chunk_from_ptr(ptr); - - if (unlikely(tc->refs)) { - int is_child; - /* check this is a reference from a child or grantchild - * back to it's parent or grantparent - * - * in that case we need to remove the reference and - * call another instance of talloc_free() on the current - * pointer. - */ - is_child = talloc_is_parent(tc->refs, ptr); - _talloc_free(tc->refs); - if (is_child) { - return _talloc_free(ptr); - } - return -1; - } - - if (unlikely(tc->flags & TALLOC_FLAG_LOOP)) { - /* we have a free loop - stop looping */ - return 0; - } - - if (unlikely(tc->destructor)) { - talloc_destructor_t d = tc->destructor; - if (d == (talloc_destructor_t)-1) { - return -1; - } - tc->destructor = (talloc_destructor_t)-1; - if (d(ptr) == -1) { - tc->destructor = d; - return -1; - } - tc->destructor = NULL; - } - - if (tc->parent) { - _TLIST_REMOVE(tc->parent->child, tc); - if (tc->parent->child) { - tc->parent->child->parent = tc->parent; - } - } else { - if (tc->prev) tc->prev->next = tc->next; - if (tc->next) tc->next->prev = tc->prev; - } - - tc->flags |= TALLOC_FLAG_LOOP; - - while (tc->child) { - /* we need to work out who will own an abandoned child - if it cannot be freed. In priority order, the first - choice is owner of any remaining reference to this - pointer, the second choice is our parent, and the - final choice is the null context. */ - void *child = TC_PTR_FROM_CHUNK(tc->child); - const void *new_parent = null_context; - if (unlikely(tc->child->refs)) { - struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); - if (p) new_parent = TC_PTR_FROM_CHUNK(p); - } - if (unlikely(_talloc_free(child) == -1)) { - if (new_parent == null_context) { - struct talloc_chunk *p = talloc_parent_chunk(ptr); - if (p) new_parent = TC_PTR_FROM_CHUNK(p); - } - talloc_steal(new_parent, child); - } - } - - tc->flags |= TALLOC_FLAG_FREE; - - if (tc->flags & (TALLOC_FLAG_POOL|TALLOC_FLAG_POOLMEM)) { - struct talloc_chunk *pool; - unsigned int *pool_object_count; - - pool = (tc->flags & TALLOC_FLAG_POOL) - ? tc : (struct talloc_chunk *)tc->pool; - - pool_object_count = talloc_pool_objectcount(pool); - - if (*pool_object_count == 0) { - TALLOC_ABORT("Pool object count zero!"); - } - - *pool_object_count -= 1; - - if (*pool_object_count == 0) { - free(pool); - } - } - else { - free(tc); - } - return 0; -} - -/* - move a lump of memory from one talloc context to another return the - ptr on success, or NULL if it could not be transferred. - passing NULL as ptr will always return NULL with no side effects. -*/ -void *_talloc_steal(const void *new_ctx, const void *ptr) -{ - struct talloc_chunk *tc, *new_tc; - - if (unlikely(!ptr)) { - return NULL; - } - - if (unlikely(new_ctx == NULL)) { - new_ctx = null_context; - } - - tc = talloc_chunk_from_ptr(ptr); - - if (unlikely(new_ctx == NULL)) { - if (tc->parent) { - _TLIST_REMOVE(tc->parent->child, tc); - if (tc->parent->child) { - tc->parent->child->parent = tc->parent; - } - } else { - if (tc->prev) tc->prev->next = tc->next; - if (tc->next) tc->next->prev = tc->prev; - } - - tc->parent = tc->next = tc->prev = NULL; - return discard_const_p(void, ptr); - } - - new_tc = talloc_chunk_from_ptr(new_ctx); - - if (unlikely(tc == new_tc || tc->parent == new_tc)) { - return discard_const_p(void, ptr); - } - - if (tc->parent) { - _TLIST_REMOVE(tc->parent->child, tc); - if (tc->parent->child) { - tc->parent->child->parent = tc->parent; - } - } else { - if (tc->prev) tc->prev->next = tc->next; - if (tc->next) tc->next->prev = tc->prev; - } - - tc->parent = new_tc; - if (new_tc->child) new_tc->child->parent = NULL; - _TLIST_ADD(new_tc->child, tc); - - return discard_const_p(void, ptr); -} - - - -/* - remove a secondary reference to a pointer. This undo's what - talloc_reference() has done. The context and pointer arguments - must match those given to a talloc_reference() -*/ -static inline int talloc_unreference(const void *context, const void *ptr) -{ - struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); - struct talloc_reference_handle *h; - - if (unlikely(context == NULL)) { - context = null_context; - } - - for (h=tc->refs;h;h=h->next) { - struct talloc_chunk *p = talloc_parent_chunk(h); - if (p == NULL) { - if (context == NULL) break; - } else if (TC_PTR_FROM_CHUNK(p) == context) { - break; - } - } - if (h == NULL) { - return -1; - } - - return _talloc_free(h); -} - -/* - remove a specific parent context from a pointer. This is a more - controlled varient of talloc_free() -*/ -int talloc_unlink(const void *context, void *ptr) -{ - struct talloc_chunk *tc_p, *new_p; - void *new_parent; - - if (ptr == NULL) { - return -1; - } - - if (context == NULL) { - context = null_context; - } - - if (talloc_unreference(context, ptr) == 0) { - return 0; - } - - if (context == NULL) { - if (talloc_parent_chunk(ptr) != NULL) { - return -1; - } - } else { - if (talloc_chunk_from_ptr(context) != talloc_parent_chunk(ptr)) { - return -1; - } - } - - tc_p = talloc_chunk_from_ptr(ptr); - - if (tc_p->refs == NULL) { - return _talloc_free(ptr); - } - - new_p = talloc_parent_chunk(tc_p->refs); - if (new_p) { - new_parent = TC_PTR_FROM_CHUNK(new_p); - } else { - new_parent = NULL; - } - - if (talloc_unreference(new_parent, ptr) != 0) { - return -1; - } - - talloc_steal(new_parent, ptr); - - return 0; -} - -/* - add a name to an existing pointer - va_list version -*/ -static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); - -static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) -{ - struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); - tc->name = talloc_vasprintf(ptr, fmt, ap); - if (likely(tc->name)) { - _talloc_set_name_const(tc->name, ".name"); - } - return tc->name; -} - -/* - add a name to an existing pointer -*/ -const char *talloc_set_name(const void *ptr, const char *fmt, ...) -{ - const char *name; - va_list ap; - va_start(ap, fmt); - name = talloc_set_name_v(ptr, fmt, ap); - va_end(ap); - return name; -} - - -/* - create a named talloc pointer. Any talloc pointer can be named, and - talloc_named() operates just like talloc() except that it allows you - to name the pointer. -*/ -void *talloc_named(const void *context, size_t size, const char *fmt, ...) -{ - va_list ap; - void *ptr; - const char *name; - - ptr = __talloc(context, size); - if (unlikely(ptr == NULL)) return NULL; - - va_start(ap, fmt); - name = talloc_set_name_v(ptr, fmt, ap); - va_end(ap); - - if (unlikely(name == NULL)) { - _talloc_free(ptr); - return NULL; - } - - return ptr; -} - -/* - return the name of a talloc ptr, or "UNNAMED" -*/ -const char *talloc_get_name(const void *ptr) -{ - struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); - if (unlikely(tc->name == TALLOC_MAGIC_REFERENCE)) { - return ".reference"; - } - if (likely(tc->name)) { - return tc->name; - } - return "UNNAMED"; -} - - -/* - check if a pointer has the given name. If it does, return the pointer, - otherwise return NULL -*/ -void *talloc_check_name(const void *ptr, const char *name) -{ - const char *pname; - if (unlikely(ptr == NULL)) return NULL; - pname = talloc_get_name(ptr); - if (likely(pname == name || strcmp(pname, name) == 0)) { - return discard_const_p(void, ptr); - } - return NULL; -} - - -/* - this is for compatibility with older versions of talloc -*/ -void *talloc_init(const char *fmt, ...) -{ - va_list ap; - void *ptr; - const char *name; - - /* - * samba3 expects talloc_report_depth_cb(NULL, ...) - * reports all talloc'ed memory, so we need to enable - * null_tracking - */ - talloc_enable_null_tracking(); - - ptr = __talloc(NULL, 0); - if (unlikely(ptr == NULL)) return NULL; - - va_start(ap, fmt); - name = talloc_set_name_v(ptr, fmt, ap); - va_end(ap); - - if (unlikely(name == NULL)) { - _talloc_free(ptr); - return NULL; - } - - return ptr; -} - -/* - this is a replacement for the Samba3 talloc_destroy_pool functionality. It - should probably not be used in new code. It's in here to keep the talloc - code consistent across Samba 3 and 4. -*/ -void talloc_free_children(void *ptr) -{ - struct talloc_chunk *tc; - - if (unlikely(ptr == NULL)) { - return; - } - - tc = talloc_chunk_from_ptr(ptr); - - while (tc->child) { - /* we need to work out who will own an abandoned child - if it cannot be freed. In priority order, the first - choice is owner of any remaining reference to this - pointer, the second choice is our parent, and the - final choice is the null context. */ - void *child = TC_PTR_FROM_CHUNK(tc->child); - const void *new_parent = null_context; - if (unlikely(tc->child->refs)) { - struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); - if (p) new_parent = TC_PTR_FROM_CHUNK(p); - } - if (unlikely(_talloc_free(child) == -1)) { - if (new_parent == null_context) { - struct talloc_chunk *p = talloc_parent_chunk(ptr); - if (p) new_parent = TC_PTR_FROM_CHUNK(p); - } - talloc_steal(new_parent, child); - } - } - - if ((tc->flags & TALLOC_FLAG_POOL) - && (*talloc_pool_objectcount(tc) == 1)) { - tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE); -#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS) - VALGRIND_MAKE_MEM_NOACCESS( - tc->pool, tc->size - TALLOC_POOL_HDR_SIZE); -#endif - } -} - -/* - Allocate a bit of memory as a child of an existing pointer -*/ -void *_talloc(const void *context, size_t size) -{ - return __talloc(context, size); -} - -/* - externally callable talloc_set_name_const() -*/ -void talloc_set_name_const(const void *ptr, const char *name) -{ - _talloc_set_name_const(ptr, name); -} - -/* - create a named talloc pointer. Any talloc pointer can be named, and - talloc_named() operates just like talloc() except that it allows you - to name the pointer. -*/ -void *talloc_named_const(const void *context, size_t size, const char *name) -{ - return _talloc_named_const(context, size, name); -} - -/* - free a talloc pointer. This also frees all child pointers of this - pointer recursively - - return 0 if the memory is actually freed, otherwise -1. The memory - will not be freed if the ref_count is > 1 or the destructor (if - any) returns non-zero -*/ -int talloc_free(void *ptr) -{ - return _talloc_free(ptr); -} - - - -/* - A talloc version of realloc. The context argument is only used if - ptr is NULL -*/ -void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name) -{ - struct talloc_chunk *tc; - void *new_ptr; - bool malloced = false; - - /* size zero is equivalent to free() */ - if (unlikely(size == 0)) { - _talloc_free(ptr); - return NULL; - } - - if (unlikely(size >= MAX_TALLOC_SIZE)) { - return NULL; - } - - /* realloc(NULL) is equivalent to malloc() */ - if (ptr == NULL) { - return _talloc_named_const(context, size, name); - } - - tc = talloc_chunk_from_ptr(ptr); - - /* don't allow realloc on referenced pointers */ - if (unlikely(tc->refs)) { - return NULL; - } - - /* don't shrink if we have less than 1k to gain */ - if ((size < tc->size) && ((tc->size - size) < 1024)) { - tc->size = size; - return ptr; - } - - /* by resetting magic we catch users of the old memory */ - tc->flags |= TALLOC_FLAG_FREE; - -#if ALWAYS_REALLOC - new_ptr = malloc(size + TC_HDR_SIZE); - if (new_ptr) { - memcpy(new_ptr, tc, tc->size + TC_HDR_SIZE); - free(tc); - } -#else - if (tc->flags & TALLOC_FLAG_POOLMEM) { - - new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE); - *talloc_pool_objectcount((struct talloc_chunk *) - (tc->pool)) -= 1; - - if (new_ptr == NULL) { - new_ptr = malloc(TC_HDR_SIZE+size); - malloced = true; - } - - if (new_ptr) { - memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE); - } - } - else { - new_ptr = realloc(tc, size + TC_HDR_SIZE); - } -#endif - if (unlikely(!new_ptr)) { - tc->flags &= ~TALLOC_FLAG_FREE; - return NULL; - } - - tc = (struct talloc_chunk *)new_ptr; - tc->flags &= ~TALLOC_FLAG_FREE; - if (malloced) { - tc->flags &= ~TALLOC_FLAG_POOLMEM; - } - if (tc->parent) { - tc->parent->child = tc; - } - if (tc->child) { - tc->child->parent = tc; - } - - if (tc->prev) { - tc->prev->next = tc; - } - if (tc->next) { - tc->next->prev = tc; - } - - tc->size = size; - _talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name); - - return TC_PTR_FROM_CHUNK(tc); -} - -/* - a wrapper around talloc_steal() for situations where you are moving a pointer - between two structures, and want the old pointer to be set to NULL -*/ -void *_talloc_move(const void *new_ctx, const void *_pptr) -{ - const void **pptr = discard_const_p(const void *,_pptr); - void *ret = _talloc_steal(new_ctx, *pptr); - (*pptr) = NULL; - return ret; -} - -/* - return the total size of a talloc pool (subtree) -*/ -size_t talloc_total_size(const void *ptr) -{ - size_t total = 0; - struct talloc_chunk *c, *tc; - - if (ptr == NULL) { - ptr = null_context; - } - if (ptr == NULL) { - return 0; - } - - tc = talloc_chunk_from_ptr(ptr); - - if (tc->flags & TALLOC_FLAG_LOOP) { - return 0; - } - - tc->flags |= TALLOC_FLAG_LOOP; - - total = tc->size; - for (c=tc->child;c;c=c->next) { - total += talloc_total_size(TC_PTR_FROM_CHUNK(c)); - } - - tc->flags &= ~TALLOC_FLAG_LOOP; - - return total; -} - -/* - return the total number of blocks in a talloc pool (subtree) -*/ -size_t talloc_total_blocks(const void *ptr) -{ - size_t total = 0; - struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); - - if (tc->flags & TALLOC_FLAG_LOOP) { - return 0; - } - - tc->flags |= TALLOC_FLAG_LOOP; - - total++; - for (c=tc->child;c;c=c->next) { - total += talloc_total_blocks(TC_PTR_FROM_CHUNK(c)); - } - - tc->flags &= ~TALLOC_FLAG_LOOP; - - return total; -} - -/* - return the number of external references to a pointer -*/ -size_t talloc_reference_count(const void *ptr) -{ - struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); - struct talloc_reference_handle *h; - size_t ret = 0; - - for (h=tc->refs;h;h=h->next) { - ret++; - } - return ret; -} - -/* - report on memory usage by all children of a pointer, giving a full tree view -*/ -void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, - void (*callback)(const void *ptr, - int depth, int max_depth, - int is_ref, - void *private_data), - void *private_data) -{ - struct talloc_chunk *c, *tc; - - if (ptr == NULL) { - ptr = null_context; - } - if (ptr == NULL) return; - - tc = talloc_chunk_from_ptr(ptr); - - if (tc->flags & TALLOC_FLAG_LOOP) { - return; - } - - callback(ptr, depth, max_depth, 0, private_data); - - if (max_depth >= 0 && depth >= max_depth) { - return; - } - - tc->flags |= TALLOC_FLAG_LOOP; - for (c=tc->child;c;c=c->next) { - if (c->name == TALLOC_MAGIC_REFERENCE) { - struct talloc_reference_handle *h = (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c); - callback(h->ptr, depth + 1, max_depth, 1, private_data); - } else { - talloc_report_depth_cb(TC_PTR_FROM_CHUNK(c), depth + 1, max_depth, callback, private_data); - } - } - tc->flags &= ~TALLOC_FLAG_LOOP; -} - -static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f) -{ - const char *name = talloc_get_name(ptr); - FILE *f = (FILE *)_f; - - if (is_ref) { - fprintf(f, "%*sreference to: %s\n", depth*4, "", name); - return; - } - - if (depth == 0) { - fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n", - (max_depth < 0 ? "full " :""), name, - (unsigned long)talloc_total_size(ptr), - (unsigned long)talloc_total_blocks(ptr)); - return; - } - - fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n", - depth*4, "", - name, - (unsigned long)talloc_total_size(ptr), - (unsigned long)talloc_total_blocks(ptr), - (int)talloc_reference_count(ptr), ptr); - -#if 0 - fprintf(f, "content: "); - if (talloc_total_size(ptr)) { - int tot = talloc_total_size(ptr); - int i; - - for (i = 0; i < tot; i++) { - if ((((char *)ptr)[i] > 31) && (((char *)ptr)[i] < 126)) { - fprintf(f, "%c", ((char *)ptr)[i]); - } else { - fprintf(f, "~%02x", ((char *)ptr)[i]); - } - } - } - fprintf(f, "\n"); -#endif -} - -/* - report on memory usage by all children of a pointer, giving a full tree view -*/ -void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f) -{ - talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f); - fflush(f); -} - -/* - report on memory usage by all children of a pointer, giving a full tree view -*/ -void talloc_report_full(const void *ptr, FILE *f) -{ - talloc_report_depth_file(ptr, 0, -1, f); -} - -/* - report on memory usage by all children of a pointer -*/ -void talloc_report(const void *ptr, FILE *f) -{ - talloc_report_depth_file(ptr, 0, 1, f); -} - -/* - report on any memory hanging off the null context -*/ -static void talloc_report_null(void) -{ - if (talloc_total_size(null_context) != 0) { - talloc_report(null_context, stderr); - } -} - -/* - report on any memory hanging off the null context -*/ -static void talloc_report_null_full(void) -{ - if (talloc_total_size(null_context) != 0) { - talloc_report_full(null_context, stderr); - } -} - -/* - enable tracking of the NULL context -*/ -void talloc_enable_null_tracking(void) -{ - if (null_context == NULL) { - null_context = _talloc_named_const(NULL, 0, "null_context"); - } -} - -/* - disable tracking of the NULL context -*/ -void talloc_disable_null_tracking(void) -{ - _talloc_free(null_context); - null_context = NULL; -} - -/* - enable leak reporting on exit -*/ -void talloc_enable_leak_report(void) -{ - talloc_enable_null_tracking(); - atexit(talloc_report_null); -} - -/* - enable full leak reporting on exit -*/ -void talloc_enable_leak_report_full(void) -{ - talloc_enable_null_tracking(); - atexit(talloc_report_null_full); -} - -/* - talloc and zero memory. -*/ -void *_talloc_zero(const void *ctx, size_t size, const char *name) -{ - void *p = _talloc_named_const(ctx, size, name); - - if (p) { - memset(p, '\0', size); - } - - return p; -} - -/* - memdup with a talloc. -*/ -void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name) -{ - void *newp = _talloc_named_const(t, size, name); - - if (likely(newp)) { - memcpy(newp, p, size); - } - - return newp; -} - -static inline char *__talloc_strlendup(const void *t, const char *p, size_t len) -{ - char *ret; - - ret = (char *)__talloc(t, len + 1); - if (unlikely(!ret)) return NULL; - - memcpy(ret, p, len); - ret[len] = 0; - - _talloc_set_name_const(ret, ret); - return ret; -} - -/* - strdup with a talloc -*/ -char *talloc_strdup(const void *t, const char *p) -{ - if (unlikely(!p)) return NULL; - return __talloc_strlendup(t, p, strlen(p)); -} - -/* - strndup with a talloc -*/ -char *talloc_strndup(const void *t, const char *p, size_t n) -{ - if (unlikely(!p)) return NULL; - return __talloc_strlendup(t, p, strnlen(p, n)); -} - -static inline char *__talloc_strlendup_append(char *s, size_t slen, - const char *a, size_t alen) -{ - char *ret; - - ret = talloc_realloc(NULL, s, char, slen + alen + 1); - if (unlikely(!ret)) return NULL; - - /* append the string and the trailing \0 */ - memcpy(&ret[slen], a, alen); - ret[slen+alen] = 0; - - _talloc_set_name_const(ret, ret); - return ret; -} - -/* - * Appends at the end of the string. - */ -char *talloc_strdup_append(char *s, const char *a) -{ - if (unlikely(!s)) { - return talloc_strdup(NULL, a); - } - - if (unlikely(!a)) { - return s; - } - - return __talloc_strlendup_append(s, strlen(s), a, strlen(a)); -} - -/* - * Appends at the end of the talloc'ed buffer, - * not the end of the string. - */ -char *talloc_strdup_append_buffer(char *s, const char *a) -{ - size_t slen; - - if (unlikely(!s)) { - return talloc_strdup(NULL, a); - } - - if (unlikely(!a)) { - return s; - } - - slen = talloc_get_size(s); - if (likely(slen > 0)) { - slen--; - } - - return __talloc_strlendup_append(s, slen, a, strlen(a)); -} - -/* - * Appends at the end of the string. - */ -char *talloc_strndup_append(char *s, const char *a, size_t n) -{ - if (unlikely(!s)) { - return talloc_strdup(NULL, a); - } - - if (unlikely(!a)) { - return s; - } - - return __talloc_strlendup_append(s, strlen(s), a, strnlen(a, n)); -} - -/* - * Appends at the end of the talloc'ed buffer, - * not the end of the string. - */ -char *talloc_strndup_append_buffer(char *s, const char *a, size_t n) -{ - size_t slen; - - if (unlikely(!s)) { - return talloc_strdup(NULL, a); - } - - if (unlikely(!a)) { - return s; - } - - slen = talloc_get_size(s); - if (likely(slen > 0)) { - slen--; - } - - return __talloc_strlendup_append(s, slen, a, strnlen(a, n)); -} - -#ifndef HAVE_VA_COPY -#ifdef HAVE___VA_COPY -#define va_copy(dest, src) __va_copy(dest, src) -#else -#define va_copy(dest, src) (dest) = (src) -#endif -#endif - -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) -{ - int len; - char *ret; - va_list ap2; - char c; - - /* this call looks strange, but it makes it work on older solaris boxes */ - va_copy(ap2, ap); - len = vsnprintf(&c, 1, fmt, ap2); - va_end(ap2); - if (unlikely(len < 0)) { - return NULL; - } - - ret = (char *)__talloc(t, len+1); - if (unlikely(!ret)) return NULL; - - va_copy(ap2, ap); - vsnprintf(ret, len+1, fmt, ap2); - va_end(ap2); - - _talloc_set_name_const(ret, ret); - return ret; -} - - -/* - Perform string formatting, and return a pointer to newly allocated - memory holding the result, inside a memory pool. - */ -char *talloc_asprintf(const void *t, const char *fmt, ...) -{ - va_list ap; - char *ret; - - va_start(ap, fmt); - ret = talloc_vasprintf(t, fmt, ap); - va_end(ap); - return ret; -} - -static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, - const char *fmt, va_list ap) - PRINTF_ATTRIBUTE(3,0); - -static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, - const char *fmt, va_list ap) -{ - ssize_t alen; - va_list ap2; - char c; - - va_copy(ap2, ap); - alen = vsnprintf(&c, 1, fmt, ap2); - va_end(ap2); - - if (alen <= 0) { - /* Either the vsnprintf failed or the format resulted in - * no characters being formatted. In the former case, we - * ought to return NULL, in the latter we ought to return - * the original string. Most current callers of this - * function expect it to never return NULL. - */ - return s; - } - - s = talloc_realloc(NULL, s, char, slen + alen + 1); - if (!s) return NULL; - - va_copy(ap2, ap); - vsnprintf(s + slen, alen + 1, fmt, ap2); - va_end(ap2); - - _talloc_set_name_const(s, s); - return s; -} - -/** - * Realloc @p s to append the formatted result of @p fmt and @p ap, - * and return @p s, which may have moved. Good for gradually - * accumulating output into a string buffer. Appends at the end - * of the string. - **/ -char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) -{ - if (unlikely(!s)) { - return talloc_vasprintf(NULL, fmt, ap); - } - - return __talloc_vaslenprintf_append(s, strlen(s), fmt, ap); -} - -/** - * Realloc @p s to append the formatted result of @p fmt and @p ap, - * and return @p s, which may have moved. Always appends at the - * end of the talloc'ed buffer, not the end of the string. - **/ -char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) -{ - size_t slen; - - if (unlikely(!s)) { - return talloc_vasprintf(NULL, fmt, ap); - } - - slen = talloc_get_size(s); - if (likely(slen > 0)) { - slen--; - } - - return __talloc_vaslenprintf_append(s, slen, fmt, ap); -} - -/* - Realloc @p s to append the formatted result of @p fmt and return @p - s, which may have moved. Good for gradually accumulating output - into a string buffer. - */ -char *talloc_asprintf_append(char *s, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - s = talloc_vasprintf_append(s, fmt, ap); - va_end(ap); - return s; -} - -/* - Realloc @p s to append the formatted result of @p fmt and return @p - s, which may have moved. Good for gradually accumulating output - into a buffer. - */ -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - s = talloc_vasprintf_append_buffer(s, fmt, ap); - va_end(ap); - return s; -} - -/* - alloc an array, checking for integer overflow in the array size -*/ -void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name) -{ - if (count >= MAX_TALLOC_SIZE/el_size) { - return NULL; - } - return _talloc_named_const(ctx, el_size * count, name); -} - -/* - alloc an zero array, checking for integer overflow in the array size -*/ -void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name) -{ - if (count >= MAX_TALLOC_SIZE/el_size) { - return NULL; - } - return _talloc_zero(ctx, el_size * count, name); -} - -/* - realloc an array, checking for integer overflow in the array size -*/ -void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name) -{ - if (count >= MAX_TALLOC_SIZE/el_size) { - return NULL; - } - return _talloc_realloc(ctx, ptr, el_size * count, name); -} - -/* - a function version of talloc_realloc(), so it can be passed as a function pointer - to libraries that want a realloc function (a realloc function encapsulates - all the basic capabilities of an allocation library, which is why this is useful) -*/ -void *talloc_realloc_fn(const void *context, void *ptr, size_t size) -{ - return _talloc_realloc(context, ptr, size, NULL); -} - - -static int talloc_autofree_destructor(void *ptr) -{ - autofree_context = NULL; - return 0; -} - -static void talloc_autofree(void) -{ - _talloc_free(autofree_context); -} - -/* - return a context which will be auto-freed on exit - this is useful for reducing the noise in leak reports -*/ -void *talloc_autofree_context(void) -{ - if (autofree_context == NULL) { - autofree_context = _talloc_named_const(NULL, 0, "autofree_context"); - talloc_set_destructor(autofree_context, talloc_autofree_destructor); - atexit(talloc_autofree); - } - return autofree_context; -} - -size_t talloc_get_size(const void *context) -{ - struct talloc_chunk *tc; - - if (context == NULL) - return 0; - - tc = talloc_chunk_from_ptr(context); - - return tc->size; -} - -/* - find a parent of this context that has the given name, if any -*/ -void *talloc_find_parent_byname(const void *context, const char *name) -{ - struct talloc_chunk *tc; - - if (context == NULL) { - return NULL; - } - - tc = talloc_chunk_from_ptr(context); - while (tc) { - if (tc->name && strcmp(tc->name, name) == 0) { - return TC_PTR_FROM_CHUNK(tc); - } - while (tc && tc->prev) tc = tc->prev; - if (tc) { - tc = tc->parent; - } - } - return NULL; -} - -/* - show the parentage of a context -*/ -void talloc_show_parents(const void *context, FILE *file) -{ - struct talloc_chunk *tc; - - if (context == NULL) { - fprintf(file, "talloc no parents for NULL\n"); - return; - } - - tc = talloc_chunk_from_ptr(context); - fprintf(file, "talloc parents of '%s'\n", talloc_get_name(context)); - while (tc) { - fprintf(file, "\t'%s'\n", talloc_get_name(TC_PTR_FROM_CHUNK(tc))); - while (tc && tc->prev) tc = tc->prev; - if (tc) { - tc = tc->parent; - } - } - fflush(file); -} - -/* - return 1 if ptr is a parent of context -*/ -int talloc_is_parent(const void *context, const void *ptr) -{ - struct talloc_chunk *tc; - - if (context == NULL) { - return 0; - } - - tc = talloc_chunk_from_ptr(context); - while (tc) { - if (TC_PTR_FROM_CHUNK(tc) == ptr) return 1; - while (tc && tc->prev) tc = tc->prev; - if (tc) { - tc = tc->parent; - } - } - return 0; -} diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h deleted file mode 100644 index 5431971655..0000000000 --- a/source4/lib/talloc/talloc.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef _TALLOC_H_ -#define _TALLOC_H_ -/* - Unix SMB/CIFS implementation. - Samba temporary memory allocation functions - - Copyright (C) Andrew Tridgell 2004-2005 - Copyright (C) Stefan Metzmacher 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include -#include -#include - -/* this is only needed for compatibility with the old talloc */ -typedef void TALLOC_CTX; - -/* - this uses a little trick to allow __LINE__ to be stringified -*/ -#ifndef __location__ -#define __TALLOC_STRING_LINE1__(s) #s -#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) -#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) -#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ -#endif - -#ifndef TALLOC_DEPRECATED -#define TALLOC_DEPRECATED 0 -#endif - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -/* try to make talloc_set_destructor() and talloc_steal() type safe, - if we have a recent gcc */ -#if (__GNUC__ >= 3) -#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) -#define talloc_set_destructor(ptr, function) \ - do { \ - int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ - _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ - } while(0) -/* this extremely strange macro is to avoid some braindamaged warning - stupidity in gcc 4.1.x */ -#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) -#else -#define talloc_set_destructor(ptr, function) \ - _talloc_set_destructor((ptr), (int (*)(void *))(function)) -#define _TALLOC_TYPEOF(ptr) void * -#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) -#endif - -#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) -#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) - -/* useful macros for creating type checked pointers */ -#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) - -#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) - -#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) - -#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) -#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) -#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) -#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) - -#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) -#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) - -#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) - -#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) -#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) - -#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) - -#if TALLOC_DEPRECATED -#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) -#define talloc_p(ctx, type) talloc(ctx, type) -#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) -#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) -#define talloc_destroy(ctx) talloc_free(ctx) -#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) -#endif - -/* The following definitions come from talloc.c */ -void *_talloc(const void *context, size_t size); -void *talloc_pool(const void *context, size_t size); -void _talloc_set_destructor(const void *ptr, int (*destructor)(void *)); -int talloc_increase_ref_count(const void *ptr); -size_t talloc_reference_count(const void *ptr); -void *_talloc_reference(const void *context, const void *ptr); -int talloc_unlink(const void *context, void *ptr); -const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void talloc_set_name_const(const void *ptr, const char *name); -void *talloc_named(const void *context, size_t size, - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -void *talloc_named_const(const void *context, size_t size, const char *name); -const char *talloc_get_name(const void *ptr); -void *talloc_check_name(const void *ptr, const char *name); -void *talloc_parent(const void *ptr); -const char *talloc_parent_name(const void *ptr); -void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -int talloc_free(void *ptr); -void talloc_free_children(void *ptr); -void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -void *_talloc_steal(const void *new_ctx, const void *ptr); -void *_talloc_move(const void *new_ctx, const void *pptr); -size_t talloc_total_size(const void *ptr); -size_t talloc_total_blocks(const void *ptr); -void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, - void (*callback)(const void *ptr, - int depth, int max_depth, - int is_ref, - void *private_data), - void *private_data); -void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); -void talloc_report_full(const void *ptr, FILE *f); -void talloc_report(const void *ptr, FILE *f); -void talloc_enable_null_tracking(void); -void talloc_disable_null_tracking(void); -void talloc_enable_leak_report(void); -void talloc_enable_leak_report_full(void); -void *_talloc_zero(const void *ctx, size_t size, const char *name); -void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -void *talloc_realloc_fn(const void *context, void *ptr, size_t size); -void *talloc_autofree_context(void); -size_t talloc_get_size(const void *ctx); -void *talloc_find_parent_byname(const void *ctx, const char *name); -void talloc_show_parents(const void *context, FILE *file); -int talloc_is_parent(const void *context, const void *ptr); - -char *talloc_strdup(const void *t, const char *p); -char *talloc_strdup_append(char *s, const char *a); -char *talloc_strdup_append_buffer(char *s, const char *a); - -char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_strndup_append(char *s, const char *a, size_t n); -char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); - -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); - -char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); - -#endif diff --git a/source4/lib/talloc/talloc.i b/source4/lib/talloc/talloc.i deleted file mode 100644 index a9afb97ed7..0000000000 --- a/source4/lib/talloc/talloc.i +++ /dev/null @@ -1,31 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Copyright (C) Jelmer Vernooij 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 . -*/ - -/* Don't expose talloc contexts in Python code. Python does reference - counting for us, so just create a new top-level talloc context. - */ -%typemap(in, numinputs=0, noblock=1) TALLOC_CTX * { - $1 = NULL; -} - -%define %talloctype(TYPE) -%nodefaultctor TYPE; -%extend TYPE { - ~TYPE() { talloc_free($self); } -} -%enddef diff --git a/source4/lib/talloc/talloc.pc.in b/source4/lib/talloc/talloc.pc.in deleted file mode 100644 index 459cce70b1..0000000000 --- a/source4/lib/talloc/talloc.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: talloc -Description: A hierarchical pool based memory system with destructors -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -ltalloc -Cflags: -I${includedir} -URL: http://talloc.samba.org/ diff --git a/source4/lib/talloc/talloc_guide.txt b/source4/lib/talloc/talloc_guide.txt deleted file mode 100644 index 18663b370d..0000000000 --- a/source4/lib/talloc/talloc_guide.txt +++ /dev/null @@ -1,685 +0,0 @@ -Using talloc in Samba4 ----------------------- - -Andrew Tridgell -September 2004 - -The most current version of this document is available at - http://samba.org/ftp/unpacked/samba4/source/lib/talloc/talloc_guide.txt - -If you are used to the "old" talloc from Samba3 before 3.0.20 then please read -this carefully, as talloc has changed a lot. With 3.0.20 (or 3.0.14?) the -Samba4 talloc has been ported back to Samba3, so this guide applies to both. - -The new talloc is a hierarchical, reference counted memory pool system -with destructors. Quite a mouthful really, but not too bad once you -get used to it. - -Perhaps the biggest change from Samba3 is that there is no distinction -between a "talloc context" and a "talloc pointer". Any pointer -returned from talloc() is itself a valid talloc context. This means -you can do this: - - struct foo *X = talloc(mem_ctx, struct foo); - X->name = talloc_strdup(X, "foo"); - -and the pointer X->name would be a "child" of the talloc context "X" -which is itself a child of mem_ctx. So if you do talloc_free(mem_ctx) -then it is all destroyed, whereas if you do talloc_free(X) then just X -and X->name are destroyed, and if you do talloc_free(X->name) then -just the name element of X is destroyed. - -If you think about this, then what this effectively gives you is an -n-ary tree, where you can free any part of the tree with -talloc_free(). - -If you find this confusing, then I suggest you run the testsuite to -watch talloc in action. You may also like to add your own tests to -testsuite.c to clarify how some particular situation is handled. - - -Performance ------------ - -All the additional features of talloc() over malloc() do come at a -price. We have a simple performance test in Samba4 that measures -talloc() versus malloc() performance, and it seems that talloc() is -about 4% slower than malloc() on my x86 Debian Linux box. For Samba, -the great reduction in code complexity that we get by using talloc -makes this worthwhile, especially as the total overhead of -talloc/malloc in Samba is already quite small. - - -talloc API ----------- - -The following is a complete guide to the talloc API. Read it all at -least twice. - -Multi-threading ---------------- - -talloc itself does not deal with threads. It is thread-safe (assuming -the underlying "malloc" is), as long as each thread uses different -memory contexts. -If two threads uses the same context then they need to synchronize in -order to be safe. In particular: -- when using talloc_enable_leak_report(), giving directly NULL as a -parent context implicitly refers to a hidden "null context" global -variable, so this should not be used in a multi-threaded environment -without proper synchronization ; -- the context returned by talloc_autofree_context() is also global so -shouldn't be used by several threads simultaneously without -synchronization. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(type *)talloc(const void *context, type); - -The talloc() macro is the core of the talloc library. It takes a -memory context and a type, and returns a pointer to a new area of -memory of the given type. - -The returned pointer is itself a talloc context, so you can use it as -the context argument to more calls to talloc if you wish. - -The returned pointer is a "child" of the supplied context. This means -that if you talloc_free() the context then the new child disappears as -well. Alternatively you can free just the child. - -The context argument to talloc() can be NULL, in which case a new top -level context is created. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_size(const void *context, size_t size); - -The function talloc_size() should be used when you don't have a -convenient type to pass to talloc(). Unlike talloc(), it is not type -safe (as it returns a void *), so you are on your own for type checking. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(typeof(ptr)) talloc_ptrtype(const void *ctx, ptr); - -The talloc_ptrtype() macro should be used when you have a pointer and -want to allocate memory to point at with this pointer. When compiling -with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_size() -and talloc_get_name() will return the current location in the source file. -and not the type. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -int talloc_free(void *ptr); - -The talloc_free() function frees a piece of talloc memory, and all its -children. You can call talloc_free() on any pointer returned by -talloc(). - -The return value of talloc_free() indicates success or failure, with 0 -returned for success and -1 for failure. The only possible failure -condition is if the pointer had a destructor attached to it and the -destructor returned -1. See talloc_set_destructor() for details on -destructors. - -If this pointer has an additional parent when talloc_free() is called -then the memory is not actually released, but instead the most -recently established parent is destroyed. See talloc_reference() for -details on establishing additional parents. - -For more control on which parent is removed, see talloc_unlink() - -talloc_free() operates recursively on its children. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -int talloc_free_children(void *ptr); - -The talloc_free_children() walks along the list of all children of a -talloc context and talloc_free()s only the children, not the context -itself. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_reference(const void *context, const void *ptr); - -The talloc_reference() function makes "context" an additional parent -of "ptr". - -The return value of talloc_reference() is always the original pointer -"ptr", unless talloc ran out of memory in creating the reference in -which case it will return NULL (each additional reference consumes -around 48 bytes of memory on intel x86 platforms). - -If "ptr" is NULL, then the function is a no-op, and simply returns NULL. - -After creating a reference you can free it in one of the following -ways: - - - you can talloc_free() any parent of the original pointer. That - will reduce the number of parents of this pointer by 1, and will - cause this pointer to be freed if it runs out of parents. - - - you can talloc_free() the pointer itself. That will destroy the - most recently established parent to the pointer and leave the - pointer as a child of its current parent. - -For more control on which parent to remove, see talloc_unlink() - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -int talloc_unlink(const void *context, const void *ptr); - -The talloc_unlink() function removes a specific parent from ptr. The -context passed must either be a context used in talloc_reference() -with this pointer, or must be a direct parent of ptr. - -Note that if the parent has already been removed using talloc_free() -then this function will fail and will return -1. Likewise, if "ptr" -is NULL, then the function will make no modifications and return -1. - -Usually you can just use talloc_free() instead of talloc_unlink(), but -sometimes it is useful to have the additional control on which parent -is removed. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_set_destructor(const void *ptr, int (*destructor)(void *)); - -The function talloc_set_destructor() sets the "destructor" for the -pointer "ptr". A destructor is a function that is called when the -memory used by a pointer is about to be released. The destructor -receives the pointer as an argument, and should return 0 for success -and -1 for failure. - -The destructor can do anything it wants to, including freeing other -pieces of memory. A common use for destructors is to clean up -operating system resources (such as open file descriptors) contained -in the structure the destructor is placed on. - -You can only place one destructor on a pointer. If you need more than -one destructor then you can create a zero-length child of the pointer -and place an additional destructor on that. - -To remove a destructor call talloc_set_destructor() with NULL for the -destructor. - -If your destructor attempts to talloc_free() the pointer that it is -the destructor for then talloc_free() will return -1 and the free will -be ignored. This would be a pointless operation anyway, as the -destructor is only called when the memory is just about to go away. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -int talloc_increase_ref_count(const void *ptr); - -The talloc_increase_ref_count(ptr) function is exactly equivalent to: - - talloc_reference(NULL, ptr); - -You can use either syntax, depending on which you think is clearer in -your code. - -It returns 0 on success and -1 on failure. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -size_t talloc_reference_count(const void *ptr); - -Return the number of references to the pointer. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_set_name(const void *ptr, const char *fmt, ...); - -Each talloc pointer has a "name". The name is used principally for -debugging purposes, although it is also possible to set and get the -name on a pointer in as a way of "marking" pointers in your code. - -The main use for names on pointer is for "talloc reports". See -talloc_report() and talloc_report_full() for details. Also see -talloc_enable_leak_report() and talloc_enable_leak_report_full(). - -The talloc_set_name() function allocates memory as a child of the -pointer. It is logically equivalent to: - talloc_set_name_const(ptr, talloc_asprintf(ptr, fmt, ...)); - -Note that multiple calls to talloc_set_name() will allocate more -memory without releasing the name. All of the memory is released when -the ptr is freed using talloc_free(). - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_set_name_const(const void *ptr, const char *name); - -The function talloc_set_name_const() is just like talloc_set_name(), -but it takes a string constant, and is much faster. It is extensively -used by the "auto naming" macros, such as talloc_p(). - -This function does not allocate any memory. It just copies the -supplied pointer into the internal representation of the talloc -ptr. This means you must not pass a name pointer to memory that will -disappear before the ptr is freed with talloc_free(). - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_named(const void *context, size_t size, const char *fmt, ...); - -The talloc_named() function creates a named talloc pointer. It is -equivalent to: - - ptr = talloc_size(context, size); - talloc_set_name(ptr, fmt, ....); - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_named_const(const void *context, size_t size, const char *name); - -This is equivalent to: - - ptr = talloc_size(context, size); - talloc_set_name_const(ptr, name); - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -const char *talloc_get_name(const void *ptr); - -This returns the current name for the given talloc pointer. See -talloc_set_name() for details. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_init(const char *fmt, ...); - -This function creates a zero length named talloc context as a top -level context. It is equivalent to: - - talloc_named(NULL, 0, fmt, ...); - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_new(void *ctx); - -This is a utility macro that creates a new memory context hanging -off an exiting context, automatically naming it "talloc_new: __location__" -where __location__ is the source line it is called from. It is -particularly useful for creating a new temporary working context. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(type *)talloc_realloc(const void *context, void *ptr, type, count); - -The talloc_realloc() macro changes the size of a talloc -pointer. The "count" argument is the number of elements of type "type" -that you want the resulting pointer to hold. - -talloc_realloc() has the following equivalences: - - talloc_realloc(context, NULL, type, 1) ==> talloc(context, type); - talloc_realloc(context, NULL, type, N) ==> talloc_array(context, type, N); - talloc_realloc(context, ptr, type, 0) ==> talloc_free(ptr); - -The "context" argument is only used if "ptr" is NULL, otherwise it is -ignored. - -talloc_realloc() returns the new pointer, or NULL on failure. The call -will fail either due to a lack of memory, or because the pointer has -more than one parent (see talloc_reference()). - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_realloc_size(const void *context, void *ptr, size_t size); - -the talloc_realloc_size() function is useful when the type is not -known so the typesafe talloc_realloc() cannot be used. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_steal(const void *new_ctx, const void *ptr); - -The talloc_steal() function changes the parent context of a talloc -pointer. It is typically used when the context that the pointer is -currently a child of is going to be freed and you wish to keep the -memory for a longer time. - -The talloc_steal() function returns the pointer that you pass it. It -does not have any failure modes. - -NOTE: It is possible to produce loops in the parent/child relationship -if you are not careful with talloc_steal(). No guarantees are provided -as to your sanity or the safety of your data if you do this. - -talloc_steal (new_ctx, NULL) will return NULL with no sideeffects. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -size_t talloc_total_size(const void *ptr); - -The talloc_total_size() function returns the total size in bytes used -by this pointer and all child pointers. Mostly useful for debugging. - -Passing NULL is allowed, but it will only give a meaningful result if -talloc_enable_leak_report() or talloc_enable_leak_report_full() has -been called. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -size_t talloc_total_blocks(const void *ptr); - -The talloc_total_blocks() function returns the total memory block -count used by this pointer and all child pointers. Mostly useful for -debugging. - -Passing NULL is allowed, but it will only give a meaningful result if -talloc_enable_leak_report() or talloc_enable_leak_report_full() has -been called. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, - void (*callback)(const void *ptr, - int depth, int max_depth, - int is_ref, - void *priv), - void *priv); - -This provides a more flexible reports than talloc_report(). It -will recursively call the callback for the entire tree of memory -referenced by the pointer. References in the tree are passed with -is_ref = 1 and the pointer that is referenced. - -You can pass NULL for the pointer, in which case a report is -printed for the top level memory context, but only if -talloc_enable_leak_report() or talloc_enable_leak_report_full() -has been called. - -The recursion is stopped when depth >= max_depth. -max_depth = -1 means only stop at leaf nodes. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); - -This provides a more flexible reports than talloc_report(). It -will let you specify the depth and max_depth. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_report(const void *ptr, FILE *f); - -The talloc_report() function prints a summary report of all memory -used by ptr. One line of report is printed for each immediate child of -ptr, showing the total memory and number of blocks used by that child. - -You can pass NULL for the pointer, in which case a report is printed -for the top level memory context, but only if -talloc_enable_leak_report() or talloc_enable_leak_report_full() has -been called. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_report_full(const void *ptr, FILE *f); - -This provides a more detailed report than talloc_report(). It will -recursively print the ensire tree of memory referenced by the -pointer. References in the tree are shown by giving the name of the -pointer that is referenced. - -You can pass NULL for the pointer, in which case a report is printed -for the top level memory context, but only if -talloc_enable_leak_report() or talloc_enable_leak_report_full() has -been called. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_enable_leak_report(void); - -This enables calling of talloc_report(NULL, stderr) when the program -exits. In Samba4 this is enabled by using the --leak-report command -line option. - -For it to be useful, this function must be called before any other -talloc function as it establishes a "null context" that acts as the -top of the tree. If you don't call this function first then passing -NULL to talloc_report() or talloc_report_full() won't give you the -full tree printout. - -Here is a typical talloc report: - -talloc report on 'null_context' (total 267 bytes in 15 blocks) - libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks - libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks - iconv(UTF8,CP850) contains 42 bytes in 2 blocks - libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks - iconv(CP850,UTF8) contains 42 bytes in 2 blocks - iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks - iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_enable_leak_report_full(void); - -This enables calling of talloc_report_full(NULL, stderr) when the -program exits. In Samba4 this is enabled by using the ---leak-report-full command line option. - -For it to be useful, this function must be called before any other -talloc function as it establishes a "null context" that acts as the -top of the tree. If you don't call this function first then passing -NULL to talloc_report() or talloc_report_full() won't give you the -full tree printout. - -Here is a typical full report: - -full talloc report on 'root' (total 18 bytes in 8 blocks) - p1 contains 18 bytes in 7 blocks (ref 0) - r1 contains 13 bytes in 2 blocks (ref 0) - reference to: p2 - p2 contains 1 bytes in 1 blocks (ref 1) - x3 contains 1 bytes in 1 blocks (ref 0) - x2 contains 1 bytes in 1 blocks (ref 0) - x1 contains 1 bytes in 1 blocks (ref 0) - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_enable_null_tracking(void); - -This enables tracking of the NULL memory context without enabling leak -reporting on exit. Useful for when you want to do your own leak -reporting call via talloc_report_null_full(); - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void talloc_disable_null_tracking(void); - -This disables tracking of the NULL memory context. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(type *)talloc_zero(const void *ctx, type); - -The talloc_zero() macro is equivalent to: - - ptr = talloc(ctx, type); - if (ptr) memset(ptr, 0, sizeof(type)); - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_zero_size(const void *ctx, size_t size) - -The talloc_zero_size() function is useful when you don't have a known type - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_memdup(const void *ctx, const void *p, size_t size); - -The talloc_memdup() function is equivalent to: - - ptr = talloc_size(ctx, size); - if (ptr) memcpy(ptr, p, size); - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_strdup(const void *ctx, const char *p); - -The talloc_strdup() function is equivalent to: - - ptr = talloc_size(ctx, strlen(p)+1); - if (ptr) memcpy(ptr, p, strlen(p)+1); - -This functions sets the name of the new pointer to the passed -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_strndup(const void *t, const char *p, size_t n); - -The talloc_strndup() function is the talloc equivalent of the C -library function strndup() - -This functions sets the name of the new pointer to the passed -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_append_string(const void *t, char *orig, const char *append); - -The talloc_append_string() function appends the given formatted -string to the given string. - -This function sets the name of the new pointer to the new -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap); - -The talloc_vasprintf() function is the talloc equivalent of the C -library function vasprintf() - -This functions sets the name of the new pointer to the new -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_asprintf(const void *t, const char *fmt, ...); - -The talloc_asprintf() function is the talloc equivalent of the C -library function asprintf() - -This functions sets the name of the new pointer to the new -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_asprintf_append(char *s, const char *fmt, ...); - -The talloc_asprintf_append() function appends the given formatted -string to the given string. -Use this varient when the string in the current talloc buffer may -have been truncated in length. - -This functions sets the name of the new pointer to the new -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...); - -The talloc_asprintf_append() function appends the given formatted -string to the end of the currently allocated talloc buffer. -Use this varient when the string in the current talloc buffer has -not been changed. - -This functions sets the name of the new pointer to the new -string. This is equivalent to: - talloc_set_name_const(ptr, ptr) - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -((type *)talloc_array(const void *ctx, type, uint_t count); - -The talloc_array() macro is equivalent to: - - (type *)talloc_size(ctx, sizeof(type) * count); - -except that it provides integer overflow protection for the multiply, -returning NULL if the multiply overflows. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_array_size(const void *ctx, size_t size, uint_t count); - -The talloc_array_size() function is useful when the type is not -known. It operates in the same way as talloc_array(), but takes a size -instead of a type. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(typeof(ptr)) talloc_array_ptrtype(const void *ctx, ptr, uint_t count); - -The talloc_ptrtype() macro should be used when you have a pointer to an array -and want to allocate memory of an array to point at with this pointer. When compiling -with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size() -and talloc_get_name() will return the current location in the source file. -and not the type. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_realloc_fn(const void *ctx, void *ptr, size_t size); - -This is a non-macro version of talloc_realloc(), which is useful -as libraries sometimes want a ralloc function pointer. A realloc() -implementation encapsulates the functionality of malloc(), free() and -realloc() in one call, which is why it is useful to be able to pass -around a single function pointer. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_autofree_context(void); - -This is a handy utility function that returns a talloc context -which will be automatically freed on program exit. This can be used -to reduce the noise in memory leak reports. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_check_name(const void *ptr, const char *name); - -This function checks if a pointer has the specified name. If it does -then the pointer is returned. It it doesn't then NULL is returned. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(type *)talloc_get_type(const void *ptr, type); - -This macro allows you to do type checking on talloc pointers. It is -particularly useful for void* private pointers. It is equivalent to -this: - - (type *)talloc_check_name(ptr, #type) - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -talloc_set_type(const void *ptr, type); - -This macro allows you to force the name of a pointer to be a -particular type. This can be used in conjunction with -talloc_get_type() to do type checking on void* pointers. - -It is equivalent to this: - talloc_set_name_const(ptr, #type) - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -talloc_get_size(const void *ctx); - -This function lets you know the amount of memory alloced so far by -this context. It does NOT account for subcontext memory. -This can be used to calculate the size of an array. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -void *talloc_find_parent_byname(const void *ctx, const char *name); - -Find a parent memory context of the current context that has the given -name. This can be very useful in complex programs where it may be -difficult to pass all information down to the level you need, but you -know the structure you want is a parent of another context. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -(type *)talloc_find_parent_bytype(ctx, type); - -Like talloc_find_parent_byname() but takes a type, making it typesafe. - diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c deleted file mode 100644 index 3f06eee566..0000000000 --- a/source4/lib/talloc/testsuite.c +++ /dev/null @@ -1,1152 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - local testing of talloc routines. - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "replace.h" -#include "system/time.h" -#include "talloc.h" - -static struct timeval timeval_current(void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv; -} - -static double timeval_elapsed(struct timeval *tv) -{ - struct timeval tv2 = timeval_current(); - return (tv2.tv_sec - tv->tv_sec) + - (tv2.tv_usec - tv->tv_usec)*1.0e-6; -} - -#define torture_assert(test, expr, str) if (!(expr)) { \ - printf("failure: %s [\n%s: Expression %s failed: %s\n]\n", \ - test, __location__, #expr, str); \ - return false; \ -} - -#define torture_assert_str_equal(test, arg1, arg2, desc) \ - if (arg1 == NULL && arg2 == NULL) { \ - } else if (strcmp(arg1, arg2)) { \ - printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \ - test, __location__, arg1, arg2, desc); \ - return false; \ - } - -#if _SAMBA_BUILD_==3 -#ifdef malloc -#undef malloc -#endif -#ifdef strdup -#undef strdup -#endif -#endif - -#define CHECK_SIZE(test, ptr, tsize) do { \ - if (talloc_total_size(ptr) != (tsize)) { \ - printf("failed: %s [\nwrong '%s' tree size: got %u expected %u\n]\n", \ - test, #ptr, \ - (unsigned)talloc_total_size(ptr), \ - (unsigned)tsize); \ - talloc_report_full(ptr, stdout); \ - return false; \ - } \ -} while (0) - -#define CHECK_BLOCKS(test, ptr, tblocks) do { \ - if (talloc_total_blocks(ptr) != (tblocks)) { \ - printf("failed: %s [\nwrong '%s' tree blocks: got %u expected %u\n]\n", \ - test, #ptr, \ - (unsigned)talloc_total_blocks(ptr), \ - (unsigned)tblocks); \ - talloc_report_full(ptr, stdout); \ - return false; \ - } \ -} while (0) - -#define CHECK_PARENT(test, ptr, parent) do { \ - if (talloc_parent(ptr) != (parent)) { \ - printf("failed: %s [\n'%s' has wrong parent: got %p expected %p\n]\n", \ - test, #ptr, \ - talloc_parent(ptr), \ - (parent)); \ - talloc_report_full(ptr, stdout); \ - talloc_report_full(parent, stdout); \ - talloc_report_full(NULL, stdout); \ - return false; \ - } \ -} while (0) - - -/* - test references -*/ -static bool test_ref1(void) -{ - void *root, *p1, *p2, *ref, *r1; - - printf("test: ref1\n# SINGLE REFERENCE FREE\n"); - - root = talloc_named_const(NULL, 0, "root"); - p1 = talloc_named_const(root, 1, "p1"); - p2 = talloc_named_const(p1, 1, "p2"); - talloc_named_const(p1, 1, "x1"); - talloc_named_const(p1, 2, "x2"); - talloc_named_const(p1, 3, "x3"); - - r1 = talloc_named_const(root, 1, "r1"); - ref = talloc_reference(r1, p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref1", p1, 5); - CHECK_BLOCKS("ref1", p2, 1); - CHECK_BLOCKS("ref1", r1, 2); - - fprintf(stderr, "Freeing p2\n"); - talloc_free(p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref1", p1, 5); - CHECK_BLOCKS("ref1", p2, 1); - CHECK_BLOCKS("ref1", r1, 1); - - fprintf(stderr, "Freeing p1\n"); - talloc_free(p1); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref1", r1, 1); - - fprintf(stderr, "Freeing r1\n"); - talloc_free(r1); - talloc_report_full(NULL, stderr); - - fprintf(stderr, "Testing NULL\n"); - if (talloc_reference(root, NULL)) { - return false; - } - - CHECK_BLOCKS("ref1", root, 1); - - CHECK_SIZE("ref1", root, 0); - - talloc_free(root); - printf("success: ref1\n"); - return true; -} - -/* - test references -*/ -static bool test_ref2(void) -{ - void *root, *p1, *p2, *ref, *r1; - - printf("test: ref2\n# DOUBLE REFERENCE FREE\n"); - root = talloc_named_const(NULL, 0, "root"); - p1 = talloc_named_const(root, 1, "p1"); - talloc_named_const(p1, 1, "x1"); - talloc_named_const(p1, 1, "x2"); - talloc_named_const(p1, 1, "x3"); - p2 = talloc_named_const(p1, 1, "p2"); - - r1 = talloc_named_const(root, 1, "r1"); - ref = talloc_reference(r1, p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref2", p1, 5); - CHECK_BLOCKS("ref2", p2, 1); - CHECK_BLOCKS("ref2", r1, 2); - - fprintf(stderr, "Freeing ref\n"); - talloc_free(ref); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref2", p1, 5); - CHECK_BLOCKS("ref2", p2, 1); - CHECK_BLOCKS("ref2", r1, 1); - - fprintf(stderr, "Freeing p2\n"); - talloc_free(p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref2", p1, 4); - CHECK_BLOCKS("ref2", r1, 1); - - fprintf(stderr, "Freeing p1\n"); - talloc_free(p1); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref2", r1, 1); - - fprintf(stderr, "Freeing r1\n"); - talloc_free(r1); - talloc_report_full(root, stderr); - - CHECK_SIZE("ref2", root, 0); - - talloc_free(root); - printf("success: ref2\n"); - return true; -} - -/* - test references -*/ -static bool test_ref3(void) -{ - void *root, *p1, *p2, *ref, *r1; - - printf("test: ref3\n# PARENT REFERENCE FREE\n"); - - root = talloc_named_const(NULL, 0, "root"); - p1 = talloc_named_const(root, 1, "p1"); - p2 = talloc_named_const(root, 1, "p2"); - r1 = talloc_named_const(p1, 1, "r1"); - ref = talloc_reference(p2, r1); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref3", p1, 2); - CHECK_BLOCKS("ref3", p2, 2); - CHECK_BLOCKS("ref3", r1, 1); - - fprintf(stderr, "Freeing p1\n"); - talloc_free(p1); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref3", p2, 2); - CHECK_BLOCKS("ref3", r1, 1); - - fprintf(stderr, "Freeing p2\n"); - talloc_free(p2); - talloc_report_full(root, stderr); - - CHECK_SIZE("ref3", root, 0); - - talloc_free(root); - - printf("success: ref3\n"); - return true; -} - -/* - test references -*/ -static bool test_ref4(void) -{ - void *root, *p1, *p2, *ref, *r1; - - printf("test: ref4\n# REFERRER REFERENCE FREE\n"); - - root = talloc_named_const(NULL, 0, "root"); - p1 = talloc_named_const(root, 1, "p1"); - talloc_named_const(p1, 1, "x1"); - talloc_named_const(p1, 1, "x2"); - talloc_named_const(p1, 1, "x3"); - p2 = talloc_named_const(p1, 1, "p2"); - - r1 = talloc_named_const(root, 1, "r1"); - ref = talloc_reference(r1, p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref4", p1, 5); - CHECK_BLOCKS("ref4", p2, 1); - CHECK_BLOCKS("ref4", r1, 2); - - fprintf(stderr, "Freeing r1\n"); - talloc_free(r1); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref4", p1, 5); - CHECK_BLOCKS("ref4", p2, 1); - - fprintf(stderr, "Freeing p2\n"); - talloc_free(p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("ref4", p1, 4); - - fprintf(stderr, "Freeing p1\n"); - talloc_free(p1); - talloc_report_full(root, stderr); - - CHECK_SIZE("ref4", root, 0); - - talloc_free(root); - - printf("success: ref4\n"); - return true; -} - - -/* - test references -*/ -static bool test_unlink1(void) -{ - void *root, *p1, *p2, *ref, *r1; - - printf("test: unlink\n# UNLINK\n"); - - root = talloc_named_const(NULL, 0, "root"); - p1 = talloc_named_const(root, 1, "p1"); - talloc_named_const(p1, 1, "x1"); - talloc_named_const(p1, 1, "x2"); - talloc_named_const(p1, 1, "x3"); - p2 = talloc_named_const(p1, 1, "p2"); - - r1 = talloc_named_const(p1, 1, "r1"); - ref = talloc_reference(r1, p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("unlink", p1, 7); - CHECK_BLOCKS("unlink", p2, 1); - CHECK_BLOCKS("unlink", r1, 2); - - fprintf(stderr, "Unreferencing r1\n"); - talloc_unlink(r1, p2); - talloc_report_full(root, stderr); - - CHECK_BLOCKS("unlink", p1, 6); - CHECK_BLOCKS("unlink", p2, 1); - CHECK_BLOCKS("unlink", r1, 1); - - fprintf(stderr, "Freeing p1\n"); - talloc_free(p1); - talloc_report_full(root, stderr); - - CHECK_SIZE("unlink", root, 0); - - talloc_free(root); - - printf("success: unlink\n"); - return true; -} - -static int fail_destructor(void *ptr) -{ - return -1; -} - -/* - miscellaneous tests to try to get a higher test coverage percentage -*/ -static bool test_misc(void) -{ - void *root, *p1; - char *p2; - double *d; - const char *name; - - printf("test: misc\n# MISCELLANEOUS\n"); - - root = talloc_new(NULL); - - p1 = talloc_size(root, 0x7fffffff); - torture_assert("misc", !p1, "failed: large talloc allowed\n"); - - p1 = talloc_strdup(root, "foo"); - talloc_increase_ref_count(p1); - talloc_increase_ref_count(p1); - talloc_increase_ref_count(p1); - CHECK_BLOCKS("misc", p1, 1); - CHECK_BLOCKS("misc", root, 2); - talloc_free(p1); - CHECK_BLOCKS("misc", p1, 1); - CHECK_BLOCKS("misc", root, 2); - talloc_unlink(NULL, p1); - CHECK_BLOCKS("misc", p1, 1); - CHECK_BLOCKS("misc", root, 2); - p2 = talloc_strdup(p1, "foo"); - torture_assert("misc", talloc_unlink(root, p2) == -1, - "failed: talloc_unlink() of non-reference context should return -1\n"); - torture_assert("misc", talloc_unlink(p1, p2) == 0, - "failed: talloc_unlink() of parent should succeed\n"); - talloc_free(p1); - CHECK_BLOCKS("misc", p1, 1); - CHECK_BLOCKS("misc", root, 2); - - name = talloc_set_name(p1, "my name is %s", "foo"); - torture_assert_str_equal("misc", talloc_get_name(p1), "my name is foo", - "failed: wrong name after talloc_set_name(my name is foo)"); - CHECK_BLOCKS("misc", p1, 2); - CHECK_BLOCKS("misc", root, 3); - - talloc_set_name_const(p1, NULL); - torture_assert_str_equal ("misc", talloc_get_name(p1), "UNNAMED", - "failed: wrong name after talloc_set_name(NULL)"); - CHECK_BLOCKS("misc", p1, 2); - CHECK_BLOCKS("misc", root, 3); - - torture_assert("misc", talloc_free(NULL) == -1, - "talloc_free(NULL) should give -1\n"); - - talloc_set_destructor(p1, fail_destructor); - torture_assert("misc", talloc_free(p1) == -1, - "Failed destructor should cause talloc_free to fail\n"); - talloc_set_destructor(p1, NULL); - - talloc_report(root, stderr); - - - p2 = (char *)talloc_zero_size(p1, 20); - torture_assert("misc", p2[19] == 0, "Failed to give zero memory\n"); - talloc_free(p2); - - torture_assert("misc", talloc_strdup(root, NULL) == NULL, - "failed: strdup on NULL should give NULL\n"); - - p2 = talloc_strndup(p1, "foo", 2); - torture_assert("misc", strcmp("fo", p2) == 0, - "strndup doesn't work\n"); - p2 = talloc_asprintf_append_buffer(p2, "o%c", 'd'); - torture_assert("misc", strcmp("food", p2) == 0, - "talloc_asprintf_append_buffer doesn't work\n"); - CHECK_BLOCKS("misc", p2, 1); - CHECK_BLOCKS("misc", p1, 3); - - p2 = talloc_asprintf_append_buffer(NULL, "hello %s", "world"); - torture_assert("misc", strcmp("hello world", p2) == 0, - "talloc_asprintf_append_buffer doesn't work\n"); - CHECK_BLOCKS("misc", p2, 1); - CHECK_BLOCKS("misc", p1, 3); - talloc_free(p2); - - d = talloc_array(p1, double, 0x20000000); - torture_assert("misc", !d, "failed: integer overflow not detected\n"); - - d = talloc_realloc(p1, d, double, 0x20000000); - torture_assert("misc", !d, "failed: integer overflow not detected\n"); - - talloc_free(p1); - CHECK_BLOCKS("misc", root, 1); - - p1 = talloc_named(root, 100, "%d bytes", 100); - CHECK_BLOCKS("misc", p1, 2); - CHECK_BLOCKS("misc", root, 3); - talloc_unlink(root, p1); - - p1 = talloc_init("%d bytes", 200); - p2 = talloc_asprintf(p1, "my test '%s'", "string"); - torture_assert_str_equal("misc", p2, "my test 'string'", - "failed: talloc_asprintf(\"my test '%%s'\", \"string\") gave: \"%s\""); - CHECK_BLOCKS("misc", p1, 3); - CHECK_SIZE("misc", p2, 17); - CHECK_BLOCKS("misc", root, 1); - talloc_unlink(NULL, p1); - - p1 = talloc_named_const(root, 10, "p1"); - p2 = (char *)talloc_named_const(root, 20, "p2"); - (void)talloc_reference(p1, p2); - talloc_report_full(root, stderr); - talloc_unlink(root, p2); - talloc_report_full(root, stderr); - CHECK_BLOCKS("misc", p2, 1); - CHECK_BLOCKS("misc", p1, 2); - CHECK_BLOCKS("misc", root, 3); - talloc_unlink(p1, p2); - talloc_unlink(root, p1); - - p1 = talloc_named_const(root, 10, "p1"); - p2 = (char *)talloc_named_const(root, 20, "p2"); - (void)talloc_reference(NULL, p2); - talloc_report_full(root, stderr); - talloc_unlink(root, p2); - talloc_report_full(root, stderr); - CHECK_BLOCKS("misc", p2, 1); - CHECK_BLOCKS("misc", p1, 1); - CHECK_BLOCKS("misc", root, 2); - talloc_unlink(NULL, p2); - talloc_unlink(root, p1); - - /* Test that talloc_unlink is a no-op */ - - torture_assert("misc", talloc_unlink(root, NULL) == -1, - "failed: talloc_unlink(root, NULL) == -1\n"); - - talloc_report(root, stderr); - talloc_report(NULL, stderr); - - CHECK_SIZE("misc", root, 0); - - talloc_free(root); - - CHECK_SIZE("misc", NULL, 0); - - talloc_enable_leak_report(); - talloc_enable_leak_report_full(); - - printf("success: misc\n"); - - return true; -} - - -/* - test realloc -*/ -static bool test_realloc(void) -{ - void *root, *p1, *p2; - - printf("test: realloc\n# REALLOC\n"); - - root = talloc_new(NULL); - - p1 = talloc_size(root, 10); - CHECK_SIZE("realloc", p1, 10); - - p1 = talloc_realloc_size(NULL, p1, 20); - CHECK_SIZE("realloc", p1, 20); - - talloc_new(p1); - - p2 = talloc_realloc_size(p1, NULL, 30); - - talloc_new(p1); - - p2 = talloc_realloc_size(p1, p2, 40); - - CHECK_SIZE("realloc", p2, 40); - CHECK_SIZE("realloc", root, 60); - CHECK_BLOCKS("realloc", p1, 4); - - p1 = talloc_realloc_size(NULL, p1, 20); - CHECK_SIZE("realloc", p1, 60); - - talloc_increase_ref_count(p2); - torture_assert("realloc", talloc_realloc_size(NULL, p2, 5) == NULL, - "failed: talloc_realloc() on a referenced pointer should fail\n"); - CHECK_BLOCKS("realloc", p1, 4); - - talloc_realloc_size(NULL, p2, 0); - talloc_realloc_size(NULL, p2, 0); - CHECK_BLOCKS("realloc", p1, 3); - - torture_assert("realloc", talloc_realloc_size(NULL, p1, 0x7fffffff) == NULL, - "failed: oversize talloc should fail\n"); - - talloc_realloc_size(NULL, p1, 0); - - CHECK_BLOCKS("realloc", root, 1); - CHECK_SIZE("realloc", root, 0); - - talloc_free(root); - - printf("success: realloc\n"); - - return true; -} - -/* - test realloc with a child -*/ -static bool test_realloc_child(void) -{ - void *root; - struct el2 { - const char *name; - } *el2; - struct el1 { - int count; - struct el2 **list, **list2, **list3; - } *el1; - - printf("test: REALLOC WITH CHILD\n"); - - root = talloc_new(NULL); - - el1 = talloc(root, struct el1); - el1->list = talloc(el1, struct el2 *); - el1->list[0] = talloc(el1->list, struct el2); - el1->list[0]->name = talloc_strdup(el1->list[0], "testing"); - - el1->list2 = talloc(el1, struct el2 *); - el1->list2[0] = talloc(el1->list2, struct el2); - el1->list2[0]->name = talloc_strdup(el1->list2[0], "testing2"); - - el1->list3 = talloc(el1, struct el2 *); - el1->list3[0] = talloc(el1->list3, struct el2); - el1->list3[0]->name = talloc_strdup(el1->list3[0], "testing2"); - - el2 = talloc(el1->list, struct el2); - el2 = talloc(el1->list2, struct el2); - el2 = talloc(el1->list3, struct el2); - - el1->list = talloc_realloc(el1, el1->list, struct el2 *, 100); - el1->list2 = talloc_realloc(el1, el1->list2, struct el2 *, 200); - el1->list3 = talloc_realloc(el1, el1->list3, struct el2 *, 300); - - talloc_free(root); - - printf("success: REALLOC WITH CHILD\n"); - return true; -} - -/* - test type checking -*/ -static bool test_type(void) -{ - void *root; - struct el1 { - int count; - }; - struct el2 { - int count; - }; - struct el1 *el1; - - printf("test: type\n# talloc type checking\n"); - - root = talloc_new(NULL); - - el1 = talloc(root, struct el1); - - el1->count = 1; - - torture_assert("type", talloc_get_type(el1, struct el1) == el1, - "type check failed on el1\n"); - torture_assert("type", talloc_get_type(el1, struct el2) == NULL, - "type check failed on el1 with el2\n"); - talloc_set_type(el1, struct el2); - torture_assert("type", talloc_get_type(el1, struct el2) == (struct el2 *)el1, - "type set failed on el1 with el2\n"); - - talloc_free(root); - - printf("success: type\n"); - return true; -} - -/* - test steal -*/ -static bool test_steal(void) -{ - void *root, *p1, *p2; - - printf("test: steal\n# STEAL\n"); - - root = talloc_new(NULL); - - p1 = talloc_array(root, char, 10); - CHECK_SIZE("steal", p1, 10); - - p2 = talloc_realloc(root, NULL, char, 20); - CHECK_SIZE("steal", p1, 10); - CHECK_SIZE("steal", root, 30); - - torture_assert("steal", talloc_steal(p1, NULL) == NULL, - "failed: stealing NULL should give NULL\n"); - - torture_assert("steal", talloc_steal(p1, p1) == p1, - "failed: stealing to ourselves is a nop\n"); - CHECK_BLOCKS("steal", root, 3); - CHECK_SIZE("steal", root, 30); - - talloc_steal(NULL, p1); - talloc_steal(NULL, p2); - CHECK_BLOCKS("steal", root, 1); - CHECK_SIZE("steal", root, 0); - - talloc_free(p1); - talloc_steal(root, p2); - CHECK_BLOCKS("steal", root, 2); - CHECK_SIZE("steal", root, 20); - - talloc_free(p2); - - CHECK_BLOCKS("steal", root, 1); - CHECK_SIZE("steal", root, 0); - - talloc_free(root); - - p1 = talloc_size(NULL, 3); - talloc_report_full(NULL, stderr); - CHECK_SIZE("steal", NULL, 3); - talloc_free(p1); - - printf("success: steal\n"); - return true; -} - -/* - test move -*/ -static bool test_move(void) -{ - void *root; - struct t_move { - char *p; - int *x; - } *t1, *t2; - - printf("test: move\n# MOVE\n"); - - root = talloc_new(NULL); - - t1 = talloc(root, struct t_move); - t2 = talloc(root, struct t_move); - t1->p = talloc_strdup(t1, "foo"); - t1->x = talloc(t1, int); - *t1->x = 42; - - t2->p = talloc_move(t2, &t1->p); - t2->x = talloc_move(t2, &t1->x); - torture_assert("move", t1->p == NULL && t1->x == NULL && - strcmp(t2->p, "foo") == 0 && *t2->x == 42, - "talloc move failed"); - - talloc_free(root); - - printf("success: move\n"); - - return true; -} - -/* - test talloc_realloc_fn -*/ -static bool test_realloc_fn(void) -{ - void *root, *p1; - - printf("test: realloc_fn\n# talloc_realloc_fn\n"); - - root = talloc_new(NULL); - - p1 = talloc_realloc_fn(root, NULL, 10); - CHECK_BLOCKS("realloc_fn", root, 2); - CHECK_SIZE("realloc_fn", root, 10); - p1 = talloc_realloc_fn(root, p1, 20); - CHECK_BLOCKS("realloc_fn", root, 2); - CHECK_SIZE("realloc_fn", root, 20); - p1 = talloc_realloc_fn(root, p1, 0); - CHECK_BLOCKS("realloc_fn", root, 1); - CHECK_SIZE("realloc_fn", root, 0); - - talloc_free(root); - - printf("success: realloc_fn\n"); - return true; -} - - -static bool test_unref_reparent(void) -{ - void *root, *p1, *p2, *c1; - - printf("test: unref_reparent\n# UNREFERENCE AFTER PARENT FREED\n"); - - root = talloc_named_const(NULL, 0, "root"); - p1 = talloc_named_const(root, 1, "orig parent"); - p2 = talloc_named_const(root, 1, "parent by reference"); - - c1 = talloc_named_const(p1, 1, "child"); - talloc_reference(p2, c1); - - CHECK_PARENT("unref_reparent", c1, p1); - - talloc_free(p1); - - CHECK_PARENT("unref_reparent", c1, p2); - - talloc_unlink(p2, c1); - - CHECK_SIZE("unref_reparent", root, 1); - - talloc_free(p2); - talloc_free(root); - - printf("success: unref_reparent\n"); - return true; -} - -/* - measure the speed of talloc versus malloc -*/ -static bool test_speed(void) -{ - void *ctx = talloc_new(NULL); - unsigned count; - const int loop = 1000; - int i; - struct timeval tv; - - printf("test: speed\n# TALLOC VS MALLOC SPEED\n"); - - tv = timeval_current(); - count = 0; - do { - void *p1, *p2, *p3; - for (i=0;ireq2 = talloc_strdup(req1, "req2"); - talloc_set_destructor(req1->req2, test_loop_destructor); - req1->req3 = talloc_strdup(req1, "req3"); - (void)talloc_reference(req1->req3, req1); - talloc_report_full(top, stderr); - talloc_free(parent); - talloc_report_full(top, stderr); - talloc_report_full(NULL, stderr); - talloc_free(top); - - torture_assert("loop", loop_destructor_count == 1, - "FAILED TO FIRE LOOP DESTRUCTOR\n"); - loop_destructor_count = 0; - - printf("success: loop\n"); - return true; -} - -static int fail_destructor_str(char *ptr) -{ - return -1; -} - -static bool test_free_parent_deny_child(void) -{ - void *top = talloc_new(NULL); - char *level1; - char *level2; - char *level3; - - printf("test: free_parent_deny_child\n# TALLOC FREE PARENT DENY CHILD\n"); - - level1 = talloc_strdup(top, "level1"); - level2 = talloc_strdup(level1, "level2"); - level3 = talloc_strdup(level2, "level3"); - - talloc_set_destructor(level3, fail_destructor_str); - talloc_free(level1); - talloc_set_destructor(level3, NULL); - - CHECK_PARENT("free_parent_deny_child", level3, top); - - talloc_free(top); - - printf("success: free_parent_deny_child\n"); - return true; -} - -static bool test_talloc_ptrtype(void) -{ - void *top = talloc_new(NULL); - struct struct1 { - int foo; - int bar; - } *s1, *s2, **s3, ***s4; - const char *location1; - const char *location2; - const char *location3; - const char *location4; - - printf("test: ptrtype\n# TALLOC PTRTYPE\n"); - - s1 = talloc_ptrtype(top, s1);location1 = __location__; - - if (talloc_get_size(s1) != sizeof(struct struct1)) { - printf("failure: ptrtype [\n" - "talloc_ptrtype() allocated the wrong size %lu (should be %lu)\n" - "]\n", (unsigned long)talloc_get_size(s1), - (unsigned long)sizeof(struct struct1)); - return false; - } - - if (strcmp(location1, talloc_get_name(s1)) != 0) { - printf("failure: ptrtype [\n" - "talloc_ptrtype() sets the wrong name '%s' (should be '%s')\n]\n", - talloc_get_name(s1), location1); - return false; - } - - s2 = talloc_array_ptrtype(top, s2, 10);location2 = __location__; - - if (talloc_get_size(s2) != (sizeof(struct struct1) * 10)) { - printf("failure: ptrtype [\n" - "talloc_array_ptrtype() allocated the wrong size " - "%lu (should be %lu)\n]\n", - (unsigned long)talloc_get_size(s2), - (unsigned long)(sizeof(struct struct1)*10)); - return false; - } - - if (strcmp(location2, talloc_get_name(s2)) != 0) { - printf("failure: ptrtype [\n" - "talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n]\n", - talloc_get_name(s2), location2); - return false; - } - - s3 = talloc_array_ptrtype(top, s3, 10);location3 = __location__; - - if (talloc_get_size(s3) != (sizeof(struct struct1 *) * 10)) { - printf("failure: ptrtype [\n" - "talloc_array_ptrtype() allocated the wrong size " - "%lu (should be %lu)\n]\n", - (unsigned long)talloc_get_size(s3), - (unsigned long)(sizeof(struct struct1 *)*10)); - return false; - } - - torture_assert_str_equal("ptrtype", location3, talloc_get_name(s3), - "talloc_array_ptrtype() sets the wrong name"); - - s4 = talloc_array_ptrtype(top, s4, 10);location4 = __location__; - - if (talloc_get_size(s4) != (sizeof(struct struct1 **) * 10)) { - printf("failure: ptrtype [\n" - "talloc_array_ptrtype() allocated the wrong size " - "%lu (should be %lu)\n]\n", - (unsigned long)talloc_get_size(s4), - (unsigned long)(sizeof(struct struct1 **)*10)); - return false; - } - - torture_assert_str_equal("ptrtype", location4, talloc_get_name(s4), - "talloc_array_ptrtype() sets the wrong name"); - - talloc_free(top); - - printf("success: ptrtype\n"); - return true; -} - -static int _test_talloc_free_in_destructor(void **ptr) -{ - talloc_free(*ptr); - return 0; -} - -static bool test_talloc_free_in_destructor(void) -{ - void *level0; - void *level1; - void *level2; - void *level3; - void *level4; - void **level5; - - printf("test: free_in_destructor\n# TALLOC FREE IN DESTRUCTOR\n"); - - level0 = talloc_new(NULL); - level1 = talloc_new(level0); - level2 = talloc_new(level1); - level3 = talloc_new(level2); - level4 = talloc_new(level3); - level5 = talloc(level4, void *); - - *level5 = level3; - (void)talloc_reference(level0, level3); - (void)talloc_reference(level3, level3); - (void)talloc_reference(level5, level3); - - talloc_set_destructor(level5, _test_talloc_free_in_destructor); - - talloc_free(level1); - - talloc_free(level0); - - printf("success: free_in_destructor\n"); - return true; -} - -static bool test_autofree(void) -{ -#if _SAMBA_BUILD_ < 4 - /* autofree test would kill smbtorture */ - void *p; - printf("test: autofree\n# TALLOC AUTOFREE CONTEXT\n"); - - p = talloc_autofree_context(); - talloc_free(p); - - p = talloc_autofree_context(); - talloc_free(p); - - printf("success: autofree\n"); -#endif - return true; -} - -static bool test_pool(void) -{ - void *pool; - void *p1, *p2, *p3, *p4; - - pool = talloc_pool(NULL, 1024); - - p1 = talloc_size(pool, 80); - p2 = talloc_size(pool, 20); - p3 = talloc_size(p1, 50); - p4 = talloc_size(p3, 1000); - - talloc_free(pool); - - return true; -} - -struct torture_context; -bool torture_local_talloc(struct torture_context *tctx) -{ - bool ret = true; - - setlinebuf(stdout); - - talloc_disable_null_tracking(); - talloc_enable_null_tracking(); - - ret &= test_ref1(); - ret &= test_ref2(); - ret &= test_ref3(); - ret &= test_ref4(); - ret &= test_unlink1(); - ret &= test_misc(); - ret &= test_realloc(); - ret &= test_realloc_child(); - ret &= test_steal(); - ret &= test_move(); - ret &= test_unref_reparent(); - ret &= test_realloc_fn(); - ret &= test_type(); - ret &= test_lifeless(); - ret &= test_loop(); - ret &= test_free_parent_deny_child(); - ret &= test_talloc_ptrtype(); - ret &= test_talloc_free_in_destructor(); - ret &= test_pool(); - - if (ret) { - ret &= test_speed(); - } - ret &= test_autofree(); - - return ret; -} - -#if _SAMBA_BUILD_ < 4 -int main(void) -{ - bool ret = torture_local_talloc(NULL); - if (!ret) - return -1; - return 0; -} -#endif diff --git a/source4/lib/talloc/web/index.html b/source4/lib/talloc/web/index.html deleted file mode 100644 index 5deab93665..0000000000 --- a/source4/lib/talloc/web/index.html +++ /dev/null @@ -1,46 +0,0 @@ - - - -talloc - - - -

talloc

- -talloc is a hierarchical pool based memory allocator with -destructors. It is the core memory allocator used in Samba4, and has -made a huge difference in many aspects of Samba4 development.

- -To get started with talloc, I would recommend you read the talloc guide. - -

Discussion and bug reports

- -talloc does not currently have its own mailing list or bug tracking -system. For now, please use the samba-technical -mailing list, and the Samba -bugzilla bug tracking system. - -

Download

- -You can download the latest release either via rsync or git.
-
-To fetch via git see the following guide:
-Using Git for Samba Development
-Once you have cloned the tree switch to the v4-0-test branch and cd into the source/lib/talloc directory.
-
-To fetch via rsync use this command: - -
-  rsync -Pavz samba.org::ftp/unpacked/talloc .
-
- -
- -Andrew Tridgell
-talloc AT tridgell.net -
- - - diff --git a/source4/lib/tdb/Makefile.in b/source4/lib/tdb/Makefile.in deleted file mode 100644 index 090bb6e2dc..0000000000 --- a/source4/lib/tdb/Makefile.in +++ /dev/null @@ -1,59 +0,0 @@ -#!gmake -# -# Makefile for tdb directory -# - -CC = @CC@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = @bindir@ -includedir = @includedir@ -libdir = @libdir@ -VPATH = @srcdir@:@libreplacedir@ -srcdir = @srcdir@ -builddir = @builddir@ -CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -CFLAGS = $(CPPFLAGS) @CFLAGS@ -LDFLAGS = @LDFLAGS@ -EXEEXT = @EXEEXT@ -SHLD = @SHLD@ -SHLD_FLAGS = @SHLD_FLAGS@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PICFLAG = @PICFLAG@ -SHLIBEXT = @SHLIBEXT@ -SWIG = swig -PYTHON = @PYTHON@ -PYTHON_CONFIG = @PYTHON_CONFIG@ -PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@ -PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@ -PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@ -LIB_PATH_VAR = @LIB_PATH_VAR@ -tdbdir = @tdbdir@ - -TDB_OBJ = @TDB_OBJ@ @LIBREPLACEOBJ@ - -default: all - -include $(tdbdir)/tdb.mk -include $(tdbdir)/rules.mk - -all:: showflags dirs $(PROGS) $(TDB_SOLIB) libtdb.a $(PYTHON_BUILD_TARGET) - -install:: all -$(TDB_SOLIB): $(TDB_OBJ) - $(SHLD) $(SHLD_FLAGS) -o $@ $(TDB_OBJ) @SONAMEFLAG@$(TDB_SONAME) - -check: test - -test:: $(PYTHON_CHECK_TARGET) -installcheck:: test install - -clean:: - rm -f *.o *.a */*.o - -distclean:: clean - rm -f config.log config.status include/config.h config.cache - rm -f Makefile - -realdistclean:: distclean - rm -f configure include/config.h.in diff --git a/source4/lib/tdb/aclocal.m4 b/source4/lib/tdb/aclocal.m4 deleted file mode 100644 index 5605e476ba..0000000000 --- a/source4/lib/tdb/aclocal.m4 +++ /dev/null @@ -1 +0,0 @@ -m4_include(libreplace.m4) diff --git a/source4/lib/tdb/autogen.sh b/source4/lib/tdb/autogen.sh deleted file mode 100755 index 88ac4cfcf7..0000000000 --- a/source4/lib/tdb/autogen.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -rm -rf autom4te.cache -rm -f configure config.h.in - -IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace" -autoconf $IPATHS || exit 1 -autoheader $IPATHS || exit 1 - -rm -rf autom4te.cache - -swig -O -Wall -python -keyword tdb.i # Ignore errors for now - -echo "Now run ./configure and then make." -exit 0 - diff --git a/source4/lib/tdb/common/dump.c b/source4/lib/tdb/common/dump.c deleted file mode 100644 index d1c902ddfd..0000000000 --- a/source4/lib/tdb/common/dump.c +++ /dev/null @@ -1,137 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash, - tdb_off_t offset) -{ - struct list_struct rec; - tdb_off_t tailer_ofs, tailer; - - if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, - sizeof(rec), DOCONV()) == -1) { - printf("ERROR: failed to read record at %u\n", offset); - return 0; - } - - printf(" rec: hash=%d offset=0x%08x next=0x%08x rec_len=%d " - "key_len=%d data_len=%d full_hash=0x%x magic=0x%x\n", - hash, offset, rec.next, rec.rec_len, rec.key_len, rec.data_len, - rec.full_hash, rec.magic); - - tailer_ofs = offset + sizeof(rec) + rec.rec_len - sizeof(tdb_off_t); - - if (tdb_ofs_read(tdb, tailer_ofs, &tailer) == -1) { - printf("ERROR: failed to read tailer at %u\n", tailer_ofs); - return rec.next; - } - - if (tailer != rec.rec_len + sizeof(rec)) { - printf("ERROR: tailer does not match record! tailer=%u totalsize=%u\n", - (unsigned int)tailer, (unsigned int)(rec.rec_len + sizeof(rec))); - } - return rec.next; -} - -static int tdb_dump_chain(struct tdb_context *tdb, int i) -{ - tdb_off_t rec_ptr, top; - - top = TDB_HASH_TOP(i); - - if (tdb_lock(tdb, i, F_WRLCK) != 0) - return -1; - - if (tdb_ofs_read(tdb, top, &rec_ptr) == -1) - return tdb_unlock(tdb, i, F_WRLCK); - - if (rec_ptr) - printf("hash=%d\n", i); - - while (rec_ptr) { - rec_ptr = tdb_dump_record(tdb, i, rec_ptr); - } - - return tdb_unlock(tdb, i, F_WRLCK); -} - -void tdb_dump_all(struct tdb_context *tdb) -{ - int i; - for (i=0;iheader.hash_size;i++) { - tdb_dump_chain(tdb, i); - } - printf("freelist:\n"); - tdb_dump_chain(tdb, -1); -} - -int tdb_printfreelist(struct tdb_context *tdb) -{ - int ret; - long total_free = 0; - tdb_off_t offset, rec_ptr; - struct list_struct rec; - - if ((ret = tdb_lock(tdb, -1, F_WRLCK)) != 0) - return ret; - - offset = FREELIST_TOP; - - /* read in the freelist top */ - if (tdb_ofs_read(tdb, offset, &rec_ptr) == -1) { - tdb_unlock(tdb, -1, F_WRLCK); - return 0; - } - - printf("freelist top=[0x%08x]\n", rec_ptr ); - while (rec_ptr) { - if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec, - sizeof(rec), DOCONV()) == -1) { - tdb_unlock(tdb, -1, F_WRLCK); - return -1; - } - - if (rec.magic != TDB_FREE_MAGIC) { - printf("bad magic 0x%08x in free list\n", rec.magic); - tdb_unlock(tdb, -1, F_WRLCK); - return -1; - } - - printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n", - rec_ptr, rec.rec_len, rec.rec_len, rec_ptr + rec.rec_len); - total_free += rec.rec_len; - - /* move to the next record */ - rec_ptr = rec.next; - } - printf("total rec_len = [0x%08x (%d)]\n", (int)total_free, - (int)total_free); - - return tdb_unlock(tdb, -1, F_WRLCK); -} - diff --git a/source4/lib/tdb/common/error.c b/source4/lib/tdb/common/error.c deleted file mode 100644 index 195ab23815..0000000000 --- a/source4/lib/tdb/common/error.c +++ /dev/null @@ -1,57 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -enum TDB_ERROR tdb_error(struct tdb_context *tdb) -{ - return tdb->ecode; -} - -static struct tdb_errname { - enum TDB_ERROR ecode; const char *estring; -} emap[] = { {TDB_SUCCESS, "Success"}, - {TDB_ERR_CORRUPT, "Corrupt database"}, - {TDB_ERR_IO, "IO Error"}, - {TDB_ERR_LOCK, "Locking error"}, - {TDB_ERR_OOM, "Out of memory"}, - {TDB_ERR_EXISTS, "Record exists"}, - {TDB_ERR_NOLOCK, "Lock exists on other keys"}, - {TDB_ERR_EINVAL, "Invalid parameter"}, - {TDB_ERR_NOEXIST, "Record does not exist"}, - {TDB_ERR_RDONLY, "write not permitted"} }; - -/* Error string for the last tdb error */ -const char *tdb_errorstr(struct tdb_context *tdb) -{ - uint32_t i; - for (i = 0; i < sizeof(emap) / sizeof(struct tdb_errname); i++) - if (tdb->ecode == emap[i].ecode) - return emap[i].estring; - return "Invalid error code"; -} - diff --git a/source4/lib/tdb/common/freelist.c b/source4/lib/tdb/common/freelist.c deleted file mode 100644 index 2f2a4c379b..0000000000 --- a/source4/lib/tdb/common/freelist.c +++ /dev/null @@ -1,382 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -/* 'right' merges can involve O(n^2) cost when combined with a - traverse, so they are disabled until we find a way to do them in - O(1) time -*/ -#define USE_RIGHT_MERGES 0 - -/* read a freelist record and check for simple errors */ -int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list_struct *rec) -{ - if (tdb->methods->tdb_read(tdb, off, rec, sizeof(*rec),DOCONV()) == -1) - return -1; - - if (rec->magic == TDB_MAGIC) { - /* this happens when a app is showdown while deleting a record - we should - not completely fail when this happens */ - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read non-free magic 0x%x at offset=%d - fixing\n", - rec->magic, off)); - rec->magic = TDB_FREE_MAGIC; - if (tdb->methods->tdb_write(tdb, off, rec, sizeof(*rec)) == -1) - return -1; - } - - if (rec->magic != TDB_FREE_MAGIC) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_CORRUPT; - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read bad magic 0x%x at offset=%d\n", - rec->magic, off)); - return TDB_ERRCODE(TDB_ERR_CORRUPT, -1); - } - if (tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0) != 0) - return -1; - return 0; -} - - -#if USE_RIGHT_MERGES -/* Remove an element from the freelist. Must have alloc lock. */ -static int remove_from_freelist(struct tdb_context *tdb, tdb_off_t off, tdb_off_t next) -{ - tdb_off_t last_ptr, i; - - /* read in the freelist top */ - last_ptr = FREELIST_TOP; - while (tdb_ofs_read(tdb, last_ptr, &i) != -1 && i != 0) { - if (i == off) { - /* We've found it! */ - return tdb_ofs_write(tdb, last_ptr, &next); - } - /* Follow chain (next offset is at start of record) */ - last_ptr = i; - } - TDB_LOG((tdb, TDB_DEBUG_FATAL,"remove_from_freelist: not on list at off=%d\n", off)); - return TDB_ERRCODE(TDB_ERR_CORRUPT, -1); -} -#endif - - -/* update a record tailer (must hold allocation lock) */ -static int update_tailer(struct tdb_context *tdb, tdb_off_t offset, - const struct list_struct *rec) -{ - tdb_off_t totalsize; - - /* Offset of tailer from record header */ - totalsize = sizeof(*rec) + rec->rec_len; - return tdb_ofs_write(tdb, offset + totalsize - sizeof(tdb_off_t), - &totalsize); -} - -/* Add an element into the freelist. Merge adjacent records if - neccessary. */ -int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec) -{ - /* Allocation and tailer lock */ - if (tdb_lock(tdb, -1, F_WRLCK) != 0) - return -1; - - /* set an initial tailer, so if we fail we don't leave a bogus record */ - if (update_tailer(tdb, offset, rec) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed!\n")); - goto fail; - } - -#if USE_RIGHT_MERGES - /* Look right first (I'm an Australian, dammit) */ - if (offset + sizeof(*rec) + rec->rec_len + sizeof(*rec) <= tdb->map_size) { - tdb_off_t right = offset + sizeof(*rec) + rec->rec_len; - struct list_struct r; - - if (tdb->methods->tdb_read(tdb, right, &r, sizeof(r), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: right read failed at %u\n", right)); - goto left; - } - - /* If it's free, expand to include it. */ - if (r.magic == TDB_FREE_MAGIC) { - if (remove_from_freelist(tdb, right, r.next) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: right free failed at %u\n", right)); - goto left; - } - rec->rec_len += sizeof(r) + r.rec_len; - if (update_tailer(tdb, offset, rec) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset)); - goto fail; - } - } - } -left: -#endif - - /* Look left */ - if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) { - tdb_off_t left = offset - sizeof(tdb_off_t); - struct list_struct l; - tdb_off_t leftsize; - - /* Read in tailer and jump back to header */ - if (tdb_ofs_read(tdb, left, &leftsize) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left offset read failed at %u\n", left)); - goto update; - } - - /* it could be uninitialised data */ - if (leftsize == 0 || leftsize == TDB_PAD_U32) { - goto update; - } - - left = offset - leftsize; - - if (leftsize > offset || - left < TDB_DATA_START(tdb->header.hash_size)) { - goto update; - } - - /* Now read in the left record */ - if (tdb->methods->tdb_read(tdb, left, &l, sizeof(l), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left read failed at %u (%u)\n", left, leftsize)); - goto update; - } - - /* If it's free, expand to include it. */ - if (l.magic == TDB_FREE_MAGIC) { - /* we now merge the new record into the left record, rather than the other - way around. This makes the operation O(1) instead of O(n). This change - prevents traverse from being O(n^2) after a lot of deletes */ - l.rec_len += sizeof(*rec) + rec->rec_len; - if (tdb_rec_write(tdb, left, &l) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_left failed at %u\n", left)); - goto fail; - } - if (update_tailer(tdb, left, &l) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset)); - goto fail; - } - tdb_unlock(tdb, -1, F_WRLCK); - return 0; - } - } - -update: - - /* Now, prepend to free list */ - rec->magic = TDB_FREE_MAGIC; - - if (tdb_ofs_read(tdb, FREELIST_TOP, &rec->next) == -1 || - tdb_rec_write(tdb, offset, rec) == -1 || - tdb_ofs_write(tdb, FREELIST_TOP, &offset) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free record write failed at offset=%d\n", offset)); - goto fail; - } - - /* And we're done. */ - tdb_unlock(tdb, -1, F_WRLCK); - return 0; - - fail: - tdb_unlock(tdb, -1, F_WRLCK); - return -1; -} - - - -/* - the core of tdb_allocate - called when we have decided which - free list entry to use - - Note that we try to allocate by grabbing data from the end of an existing record, - not the beginning. This is so the left merge in a free is more likely to be - able to free up the record without fragmentation - */ -static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, - tdb_len_t length, tdb_off_t rec_ptr, - struct list_struct *rec, tdb_off_t last_ptr) -{ -#define MIN_REC_SIZE (sizeof(struct list_struct) + sizeof(tdb_off_t) + 8) - - if (rec->rec_len < length + MIN_REC_SIZE) { - /* we have to grab the whole record */ - - /* unlink it from the previous record */ - if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) { - return 0; - } - - /* mark it not free */ - rec->magic = TDB_MAGIC; - if (tdb_rec_write(tdb, rec_ptr, rec) == -1) { - return 0; - } - return rec_ptr; - } - - /* we're going to just shorten the existing record */ - rec->rec_len -= (length + sizeof(*rec)); - if (tdb_rec_write(tdb, rec_ptr, rec) == -1) { - return 0; - } - if (update_tailer(tdb, rec_ptr, rec) == -1) { - return 0; - } - - /* and setup the new record */ - rec_ptr += sizeof(*rec) + rec->rec_len; - - memset(rec, '\0', sizeof(*rec)); - rec->rec_len = length; - rec->magic = TDB_MAGIC; - - if (tdb_rec_write(tdb, rec_ptr, rec) == -1) { - return 0; - } - - if (update_tailer(tdb, rec_ptr, rec) == -1) { - return 0; - } - - return rec_ptr; -} - -/* allocate some space from the free list. The offset returned points - to a unconnected list_struct within the database with room for at - least length bytes of total data - - 0 is returned if the space could not be allocated - */ -tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_struct *rec) -{ - tdb_off_t rec_ptr, last_ptr, newrec_ptr; - struct { - tdb_off_t rec_ptr, last_ptr; - tdb_len_t rec_len; - } bestfit; - float multiplier = 1.0; - - if (tdb_lock(tdb, -1, F_WRLCK) == -1) - return 0; - - /* Extra bytes required for tailer */ - length += sizeof(tdb_off_t); - length = TDB_ALIGN(length, TDB_ALIGNMENT); - - again: - last_ptr = FREELIST_TOP; - - /* read in the freelist top */ - if (tdb_ofs_read(tdb, FREELIST_TOP, &rec_ptr) == -1) - goto fail; - - bestfit.rec_ptr = 0; - bestfit.last_ptr = 0; - bestfit.rec_len = 0; - - /* - this is a best fit allocation strategy. Originally we used - a first fit strategy, but it suffered from massive fragmentation - issues when faced with a slowly increasing record size. - */ - while (rec_ptr) { - if (tdb_rec_free_read(tdb, rec_ptr, rec) == -1) { - goto fail; - } - - if (rec->rec_len >= length) { - if (bestfit.rec_ptr == 0 || - rec->rec_len < bestfit.rec_len) { - bestfit.rec_len = rec->rec_len; - bestfit.rec_ptr = rec_ptr; - bestfit.last_ptr = last_ptr; - } - } - - /* move to the next record */ - last_ptr = rec_ptr; - rec_ptr = rec->next; - - /* if we've found a record that is big enough, then - stop searching if its also not too big. The - definition of 'too big' changes as we scan - through */ - if (bestfit.rec_len > 0 && - bestfit.rec_len < length * multiplier) { - break; - } - - /* this multiplier means we only extremely rarely - search more than 50 or so records. At 50 records we - accept records up to 11 times larger than what we - want */ - multiplier *= 1.05; - } - - if (bestfit.rec_ptr != 0) { - if (tdb_rec_free_read(tdb, bestfit.rec_ptr, rec) == -1) { - goto fail; - } - - newrec_ptr = tdb_allocate_ofs(tdb, length, bestfit.rec_ptr, - rec, bestfit.last_ptr); - tdb_unlock(tdb, -1, F_WRLCK); - return newrec_ptr; - } - - /* we didn't find enough space. See if we can expand the - database and if we can then try again */ - if (tdb_expand(tdb, length + sizeof(*rec)) == 0) - goto again; - fail: - tdb_unlock(tdb, -1, F_WRLCK); - return 0; -} - - - -/* - return the size of the freelist - used to decide if we should repack -*/ -int tdb_freelist_size(struct tdb_context *tdb) -{ - tdb_off_t ptr; - int count=0; - - if (tdb_lock(tdb, -1, F_RDLCK) == -1) { - return -1; - } - - ptr = FREELIST_TOP; - while (tdb_ofs_read(tdb, ptr, &ptr) == 0 && ptr != 0) { - count++; - } - - tdb_unlock(tdb, -1, F_RDLCK); - return count; -} diff --git a/source4/lib/tdb/common/freelistcheck.c b/source4/lib/tdb/common/freelistcheck.c deleted file mode 100644 index efc050df9c..0000000000 --- a/source4/lib/tdb/common/freelistcheck.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Jeremy Allison 2006 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -/* Check the freelist is good and contains no loops. - Very memory intensive - only do this as a consistency - checker. Heh heh - uses an in memory tdb as the storage - for the "seen" record list. For some reason this strikes - me as extremely clever as I don't have to write another tree - data structure implementation :-). - */ - -static int seen_insert(struct tdb_context *mem_tdb, tdb_off_t rec_ptr) -{ - TDB_DATA key, data; - - memset(&data, '\0', sizeof(data)); - key.dptr = (unsigned char *)&rec_ptr; - key.dsize = sizeof(rec_ptr); - return tdb_store(mem_tdb, key, data, TDB_INSERT); -} - -int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries) -{ - struct tdb_context *mem_tdb = NULL; - struct list_struct rec; - tdb_off_t rec_ptr, last_ptr; - int ret = -1; - - *pnum_entries = 0; - - mem_tdb = tdb_open("flval", tdb->header.hash_size, - TDB_INTERNAL, O_RDWR, 0600); - if (!mem_tdb) { - return -1; - } - - if (tdb_lock(tdb, -1, F_WRLCK) == -1) { - tdb_close(mem_tdb); - return 0; - } - - last_ptr = FREELIST_TOP; - - /* Store the FREELIST_TOP record. */ - if (seen_insert(mem_tdb, last_ptr) == -1) { - ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1); - goto fail; - } - - /* read in the freelist top */ - if (tdb_ofs_read(tdb, FREELIST_TOP, &rec_ptr) == -1) { - goto fail; - } - - while (rec_ptr) { - - /* If we can't store this record (we've seen it - before) then the free list has a loop and must - be corrupt. */ - - if (seen_insert(mem_tdb, rec_ptr)) { - ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1); - goto fail; - } - - if (tdb_rec_free_read(tdb, rec_ptr, &rec) == -1) { - goto fail; - } - - /* move to the next record */ - last_ptr = rec_ptr; - rec_ptr = rec.next; - *pnum_entries += 1; - } - - ret = 0; - - fail: - - tdb_close(mem_tdb); - tdb_unlock(tdb, -1, F_WRLCK); - return ret; -} diff --git a/source4/lib/tdb/common/io.c b/source4/lib/tdb/common/io.c deleted file mode 100644 index 661f761489..0000000000 --- a/source4/lib/tdb/common/io.c +++ /dev/null @@ -1,473 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - - -#include "tdb_private.h" - -/* check for an out of bounds access - if it is out of bounds then - see if the database has been expanded by someone else and expand - if necessary - note that "len" is the minimum length needed for the db -*/ -static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe) -{ - struct stat st; - if (len <= tdb->map_size) - return 0; - if (tdb->flags & TDB_INTERNAL) { - if (!probe) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_oob len %d beyond internal malloc size %d\n", - (int)len, (int)tdb->map_size)); - } - return TDB_ERRCODE(TDB_ERR_IO, -1); - } - - if (fstat(tdb->fd, &st) == -1) { - return TDB_ERRCODE(TDB_ERR_IO, -1); - } - - if (st.st_size < (size_t)len) { - if (!probe) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_oob len %d beyond eof at %d\n", - (int)len, (int)st.st_size)); - } - return TDB_ERRCODE(TDB_ERR_IO, -1); - } - - /* Unmap, update size, remap */ - if (tdb_munmap(tdb) == -1) - return TDB_ERRCODE(TDB_ERR_IO, -1); - tdb->map_size = st.st_size; - tdb_mmap(tdb); - return 0; -} - -/* write a lump of data at a specified offset */ -static int tdb_write(struct tdb_context *tdb, tdb_off_t off, - const void *buf, tdb_len_t len) -{ - if (len == 0) { - return 0; - } - - if (tdb->read_only || tdb->traverse_read) { - tdb->ecode = TDB_ERR_RDONLY; - return -1; - } - - if (tdb->methods->tdb_oob(tdb, off + len, 0) != 0) - return -1; - - if (tdb->map_ptr) { - memcpy(off + (char *)tdb->map_ptr, buf, len); - } else { - ssize_t written = pwrite(tdb->fd, buf, len, off); - if ((written != (ssize_t)len) && (written != -1)) { - /* try once more */ - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only " - "%d of %d bytes at %d, trying once more\n", - (int)written, len, off)); - errno = ENOSPC; - written = pwrite(tdb->fd, (const void *)((const char *)buf+written), - len-written, - off+written); - } - if (written == -1) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d " - "len=%d (%s)\n", off, len, strerror(errno))); - return TDB_ERRCODE(TDB_ERR_IO, -1); - } else if (written != (ssize_t)len) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: failed to " - "write %d bytes at %d in two attempts\n", - len, off)); - errno = ENOSPC; - return TDB_ERRCODE(TDB_ERR_IO, -1); - } - } - return 0; -} - -/* Endian conversion: we only ever deal with 4 byte quantities */ -void *tdb_convert(void *buf, uint32_t size) -{ - uint32_t i, *p = (uint32_t *)buf; - for (i = 0; i < size / 4; i++) - p[i] = TDB_BYTEREV(p[i]); - return buf; -} - - -/* read a lump of data at a specified offset, maybe convert */ -static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, - tdb_len_t len, int cv) -{ - if (tdb->methods->tdb_oob(tdb, off + len, 0) != 0) { - return -1; - } - - if (tdb->map_ptr) { - memcpy(buf, off + (char *)tdb->map_ptr, len); - } else { - ssize_t ret = pread(tdb->fd, buf, len, off); - if (ret != (ssize_t)len) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_read failed at %d " - "len=%d ret=%d (%s) map_size=%d\n", - (int)off, (int)len, (int)ret, strerror(errno), - (int)tdb->map_size)); - return TDB_ERRCODE(TDB_ERR_IO, -1); - } - } - if (cv) { - tdb_convert(buf, len); - } - return 0; -} - - - -/* - do an unlocked scan of the hash table heads to find the next non-zero head. The value - will then be confirmed with the lock held -*/ -static void tdb_next_hash_chain(struct tdb_context *tdb, uint32_t *chain) -{ - uint32_t h = *chain; - if (tdb->map_ptr) { - for (;h < tdb->header.hash_size;h++) { - if (0 != *(uint32_t *)(TDB_HASH_TOP(h) + (unsigned char *)tdb->map_ptr)) { - break; - } - } - } else { - uint32_t off=0; - for (;h < tdb->header.hash_size;h++) { - if (tdb_ofs_read(tdb, TDB_HASH_TOP(h), &off) != 0 || off != 0) { - break; - } - } - } - (*chain) = h; -} - - -int tdb_munmap(struct tdb_context *tdb) -{ - if (tdb->flags & TDB_INTERNAL) - return 0; - -#ifdef HAVE_MMAP - if (tdb->map_ptr) { - int ret; - - ret = munmap(tdb->map_ptr, tdb->map_size); - if (ret != 0) - return ret; - } -#endif - tdb->map_ptr = NULL; - return 0; -} - -void tdb_mmap(struct tdb_context *tdb) -{ - if (tdb->flags & TDB_INTERNAL) - return; - -#ifdef HAVE_MMAP - if (!(tdb->flags & TDB_NOMMAP)) { - tdb->map_ptr = mmap(NULL, tdb->map_size, - PROT_READ|(tdb->read_only? 0:PROT_WRITE), - MAP_SHARED|MAP_FILE, tdb->fd, 0); - - /* - * NB. When mmap fails it returns MAP_FAILED *NOT* NULL !!!! - */ - - if (tdb->map_ptr == MAP_FAILED) { - tdb->map_ptr = NULL; - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n", - tdb->map_size, strerror(errno))); - } - } else { - tdb->map_ptr = NULL; - } -#else - tdb->map_ptr = NULL; -#endif -} - -/* expand a file. we prefer to use ftruncate, as that is what posix - says to use for mmap expansion */ -static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t addition) -{ - char buf[8192]; - - if (tdb->read_only || tdb->traverse_read) { - tdb->ecode = TDB_ERR_RDONLY; - return -1; - } - - if (ftruncate(tdb->fd, size+addition) == -1) { - char b = 0; - ssize_t written = pwrite(tdb->fd, &b, 1, (size+addition) - 1); - if (written == 0) { - /* try once more, potentially revealing errno */ - written = pwrite(tdb->fd, &b, 1, (size+addition) - 1); - } - if (written == 0) { - /* again - give up, guessing errno */ - errno = ENOSPC; - } - if (written != 1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n", - size+addition, strerror(errno))); - return -1; - } - } - - /* now fill the file with something. This ensures that the - file isn't sparse, which would be very bad if we ran out of - disk. This must be done with write, not via mmap */ - memset(buf, TDB_PAD_BYTE, sizeof(buf)); - while (addition) { - size_t n = addition>sizeof(buf)?sizeof(buf):addition; - ssize_t written = pwrite(tdb->fd, buf, n, size); - if (written == 0) { - /* prevent infinite loops: try _once_ more */ - written = pwrite(tdb->fd, buf, n, size); - } - if (written == 0) { - /* give up, trying to provide a useful errno */ - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write " - "returned 0 twice: giving up!\n")); - errno = ENOSPC; - return -1; - } else if (written == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of " - "%d bytes failed (%s)\n", (int)n, - strerror(errno))); - return -1; - } else if (written != n) { - TDB_LOG((tdb, TDB_DEBUG_WARNING, "expand_file: wrote " - "only %d of %d bytes - retrying\n", (int)written, - (int)n)); - } - addition -= written; - size += written; - } - return 0; -} - - -/* expand the database at least size bytes by expanding the underlying - file and doing the mmap again if necessary */ -int tdb_expand(struct tdb_context *tdb, tdb_off_t size) -{ - struct list_struct rec; - tdb_off_t offset, new_size; - - if (tdb_lock(tdb, -1, F_WRLCK) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "lock failed in tdb_expand\n")); - return -1; - } - - /* must know about any previous expansions by another process */ - tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1); - - /* always make room for at least 100 more records, and at - least 25% more space. Round the database up to a multiple - of the page size */ - new_size = MAX(tdb->map_size + size*100, tdb->map_size * 1.25); - size = TDB_ALIGN(new_size, tdb->page_size) - tdb->map_size; - - if (!(tdb->flags & TDB_INTERNAL)) - tdb_munmap(tdb); - - /* - * We must ensure the file is unmapped before doing this - * to ensure consistency with systems like OpenBSD where - * writes and mmaps are not consistent. - */ - - /* expand the file itself */ - if (!(tdb->flags & TDB_INTERNAL)) { - if (tdb->methods->tdb_expand_file(tdb, tdb->map_size, size) != 0) - goto fail; - } - - tdb->map_size += size; - - if (tdb->flags & TDB_INTERNAL) { - char *new_map_ptr = (char *)realloc(tdb->map_ptr, - tdb->map_size); - if (!new_map_ptr) { - tdb->map_size -= size; - goto fail; - } - tdb->map_ptr = new_map_ptr; - } else { - /* - * We must ensure the file is remapped before adding the space - * to ensure consistency with systems like OpenBSD where - * writes and mmaps are not consistent. - */ - - /* We're ok if the mmap fails as we'll fallback to read/write */ - tdb_mmap(tdb); - } - - /* form a new freelist record */ - memset(&rec,'\0',sizeof(rec)); - rec.rec_len = size - sizeof(rec); - - /* link it into the free list */ - offset = tdb->map_size - size; - if (tdb_free(tdb, offset, &rec) == -1) - goto fail; - - tdb_unlock(tdb, -1, F_WRLCK); - return 0; - fail: - tdb_unlock(tdb, -1, F_WRLCK); - return -1; -} - -/* read/write a tdb_off_t */ -int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d) -{ - return tdb->methods->tdb_read(tdb, offset, (char*)d, sizeof(*d), DOCONV()); -} - -int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d) -{ - tdb_off_t off = *d; - return tdb->methods->tdb_write(tdb, offset, CONVERT(off), sizeof(*d)); -} - - -/* read a lump of data, allocating the space for it */ -unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len) -{ - unsigned char *buf; - - /* some systems don't like zero length malloc */ - if (len == 0) { - len = 1; - } - - if (!(buf = (unsigned char *)malloc(len))) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_OOM; - TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%d (%s)\n", - len, strerror(errno))); - return TDB_ERRCODE(TDB_ERR_OOM, buf); - } - if (tdb->methods->tdb_read(tdb, offset, buf, len, 0) == -1) { - SAFE_FREE(buf); - return NULL; - } - return buf; -} - -/* Give a piece of tdb data to a parser */ - -int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key, - tdb_off_t offset, tdb_len_t len, - int (*parser)(TDB_DATA key, TDB_DATA data, - void *private_data), - void *private_data) -{ - TDB_DATA data; - int result; - - data.dsize = len; - - if ((tdb->transaction == NULL) && (tdb->map_ptr != NULL)) { - /* - * Optimize by avoiding the malloc/memcpy/free, point the - * parser directly at the mmap area. - */ - if (tdb->methods->tdb_oob(tdb, offset+len, 0) != 0) { - return -1; - } - data.dptr = offset + (unsigned char *)tdb->map_ptr; - return parser(key, data, private_data); - } - - if (!(data.dptr = tdb_alloc_read(tdb, offset, len))) { - return -1; - } - - result = parser(key, data, private_data); - free(data.dptr); - return result; -} - -/* read/write a record */ -int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec) -{ - if (tdb->methods->tdb_read(tdb, offset, rec, sizeof(*rec),DOCONV()) == -1) - return -1; - if (TDB_BAD_MAGIC(rec)) { - /* Ensure ecode is set for log fn. */ - tdb->ecode = TDB_ERR_CORRUPT; - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_rec_read bad magic 0x%x at offset=%d\n", rec->magic, offset)); - return TDB_ERRCODE(TDB_ERR_CORRUPT, -1); - } - return tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0); -} - -int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec) -{ - struct list_struct r = *rec; - return tdb->methods->tdb_write(tdb, offset, CONVERT(r), sizeof(r)); -} - -static const struct tdb_methods io_methods = { - tdb_read, - tdb_write, - tdb_next_hash_chain, - tdb_oob, - tdb_expand_file, - tdb_brlock -}; - -/* - initialise the default methods table -*/ -void tdb_io_init(struct tdb_context *tdb) -{ - tdb->methods = &io_methods; -} diff --git a/source4/lib/tdb/common/lock.c b/source4/lib/tdb/common/lock.c deleted file mode 100644 index f156c0fa7b..0000000000 --- a/source4/lib/tdb/common/lock.c +++ /dev/null @@ -1,553 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -#define TDB_MARK_LOCK 0x80000000 - -void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *ptr) -{ - tdb->interrupt_sig_ptr = ptr; -} - -/* a byte range locking function - return 0 on success - this functions locks/unlocks 1 byte at the specified offset. - - On error, errno is also set so that errors are passed back properly - through tdb_open(). - - note that a len of zero means lock to end of file -*/ -int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, - int rw_type, int lck_type, int probe, size_t len) -{ - struct flock fl; - int ret; - - if (tdb->flags & TDB_NOLOCK) { - return 0; - } - - if ((rw_type == F_WRLCK) && (tdb->read_only || tdb->traverse_read)) { - tdb->ecode = TDB_ERR_RDONLY; - return -1; - } - - fl.l_type = rw_type; - fl.l_whence = SEEK_SET; - fl.l_start = offset; - fl.l_len = len; - fl.l_pid = 0; - - do { - ret = fcntl(tdb->fd,lck_type,&fl); - - /* Check for a sigalarm break. */ - if (ret == -1 && errno == EINTR && - tdb->interrupt_sig_ptr && - *tdb->interrupt_sig_ptr) { - break; - } - } while (ret == -1 && errno == EINTR); - - if (ret == -1) { - /* Generic lock error. errno set by fcntl. - * EAGAIN is an expected return from non-blocking - * locks. */ - if (!probe && lck_type != F_SETLK) { - /* Ensure error code is set for log fun to examine. */ - tdb->ecode = TDB_ERR_LOCK; - TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d\n", - tdb->fd, offset, rw_type, lck_type, (int)len)); - } - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - return 0; -} - - -/* - upgrade a read lock to a write lock. This needs to be handled in a - special way as some OSes (such as solaris) have too conservative - deadlock detection and claim a deadlock when progress can be - made. For those OSes we may loop for a while. -*/ -int tdb_brlock_upgrade(struct tdb_context *tdb, tdb_off_t offset, size_t len) -{ - int count = 1000; - while (count--) { - struct timeval tv; - if (tdb_brlock(tdb, offset, F_WRLCK, F_SETLKW, 1, len) == 0) { - return 0; - } - if (errno != EDEADLK) { - break; - } - /* sleep for as short a time as we can - more portable than usleep() */ - tv.tv_sec = 0; - tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); - } - TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock_upgrade failed at offset %d\n", offset)); - return -1; -} - - -/* lock a list in the database. list -1 is the alloc list */ -static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op) -{ - struct tdb_lock_type *new_lck; - int i; - bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK); - - ltype &= ~TDB_MARK_LOCK; - - /* a global lock allows us to avoid per chain locks */ - if (tdb->global_lock.count && - (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) { - return 0; - } - - if (tdb->global_lock.count) { - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - - if (list < -1 || list >= (int)tdb->header.hash_size) { - TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid list %d for ltype=%d\n", - list, ltype)); - return -1; - } - if (tdb->flags & TDB_NOLOCK) - return 0; - - for (i=0; inum_lockrecs; i++) { - if (tdb->lockrecs[i].list == list) { - if (tdb->lockrecs[i].count == 0) { - /* - * Can't happen, see tdb_unlock(). It should - * be an assert. - */ - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_lock: " - "lck->count == 0 for list %d", list)); - } - /* - * Just increment the in-memory struct, posix locks - * don't stack. - */ - tdb->lockrecs[i].count++; - return 0; - } - } - - new_lck = (struct tdb_lock_type *)realloc( - tdb->lockrecs, - sizeof(*tdb->lockrecs) * (tdb->num_lockrecs+1)); - if (new_lck == NULL) { - errno = ENOMEM; - return -1; - } - tdb->lockrecs = new_lck; - - /* Since fcntl locks don't nest, we do a lock for the first one, - and simply bump the count for future ones */ - if (!mark_lock && - tdb->methods->tdb_brlock(tdb,FREELIST_TOP+4*list, ltype, op, - 0, 1)) { - return -1; - } - - tdb->num_locks++; - - tdb->lockrecs[tdb->num_lockrecs].list = list; - tdb->lockrecs[tdb->num_lockrecs].count = 1; - tdb->lockrecs[tdb->num_lockrecs].ltype = ltype; - tdb->num_lockrecs += 1; - - return 0; -} - -/* lock a list in the database. list -1 is the alloc list */ -int tdb_lock(struct tdb_context *tdb, int list, int ltype) -{ - int ret; - ret = _tdb_lock(tdb, list, ltype, F_SETLKW); - if (ret) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_lock failed on list %d " - "ltype=%d (%s)\n", list, ltype, strerror(errno))); - } - return ret; -} - -/* lock a list in the database. list -1 is the alloc list. non-blocking lock */ -int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype) -{ - return _tdb_lock(tdb, list, ltype, F_SETLK); -} - - -/* unlock the database: returns void because it's too late for errors. */ - /* changed to return int it may be interesting to know there - has been an error --simo */ -int tdb_unlock(struct tdb_context *tdb, int list, int ltype) -{ - int ret = -1; - int i; - struct tdb_lock_type *lck = NULL; - bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK); - - ltype &= ~TDB_MARK_LOCK; - - /* a global lock allows us to avoid per chain locks */ - if (tdb->global_lock.count && - (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) { - return 0; - } - - if (tdb->global_lock.count) { - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - - if (tdb->flags & TDB_NOLOCK) - return 0; - - /* Sanity checks */ - if (list < -1 || list >= (int)tdb->header.hash_size) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: list %d invalid (%d)\n", list, tdb->header.hash_size)); - return ret; - } - - for (i=0; inum_lockrecs; i++) { - if (tdb->lockrecs[i].list == list) { - lck = &tdb->lockrecs[i]; - break; - } - } - - if ((lck == NULL) || (lck->count == 0)) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: count is 0\n")); - return -1; - } - - if (lck->count > 1) { - lck->count--; - return 0; - } - - /* - * This lock has count==1 left, so we need to unlock it in the - * kernel. We don't bother with decrementing the in-memory array - * element, we're about to overwrite it with the last array element - * anyway. - */ - - if (mark_lock) { - ret = 0; - } else { - ret = tdb->methods->tdb_brlock(tdb, FREELIST_TOP+4*list, F_UNLCK, - F_SETLKW, 0, 1); - } - tdb->num_locks--; - - /* - * Shrink the array by overwriting the element just unlocked with the - * last array element. - */ - - if (tdb->num_lockrecs > 1) { - *lck = tdb->lockrecs[tdb->num_lockrecs-1]; - } - tdb->num_lockrecs -= 1; - - /* - * We don't bother with realloc when the array shrinks, but if we have - * a completely idle tdb we should get rid of the locked array. - */ - - if (tdb->num_lockrecs == 0) { - SAFE_FREE(tdb->lockrecs); - } - - if (ret) - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: An error occurred unlocking!\n")); - return ret; -} - -/* - get the transaction lock - */ -int tdb_transaction_lock(struct tdb_context *tdb, int ltype) -{ - if (tdb->have_transaction_lock || tdb->global_lock.count) { - return 0; - } - if (tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, ltype, - F_SETLKW, 0, 1) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_lock: failed to get transaction lock\n")); - tdb->ecode = TDB_ERR_LOCK; - return -1; - } - tdb->have_transaction_lock = 1; - return 0; -} - -/* - release the transaction lock - */ -int tdb_transaction_unlock(struct tdb_context *tdb) -{ - int ret; - if (!tdb->have_transaction_lock) { - return 0; - } - ret = tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, F_UNLCK, F_SETLKW, 0, 1); - if (ret == 0) { - tdb->have_transaction_lock = 0; - } - return ret; -} - - - - -/* lock/unlock entire database */ -static int _tdb_lockall(struct tdb_context *tdb, int ltype, int op) -{ - bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK); - - ltype &= ~TDB_MARK_LOCK; - - /* There are no locks on read-only dbs */ - if (tdb->read_only || tdb->traverse_read) - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - - if (tdb->global_lock.count && tdb->global_lock.ltype == ltype) { - tdb->global_lock.count++; - return 0; - } - - if (tdb->global_lock.count) { - /* a global lock of a different type exists */ - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - - if (tdb->num_locks != 0) { - /* can't combine global and chain locks */ - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - - if (!mark_lock && - tdb->methods->tdb_brlock(tdb, FREELIST_TOP, ltype, op, - 0, 4*tdb->header.hash_size)) { - if (op == F_SETLKW) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_lockall failed (%s)\n", strerror(errno))); - } - return -1; - } - - tdb->global_lock.count = 1; - tdb->global_lock.ltype = ltype; - - return 0; -} - - - -/* unlock entire db */ -static int _tdb_unlockall(struct tdb_context *tdb, int ltype) -{ - bool mark_lock = ((ltype & TDB_MARK_LOCK) == TDB_MARK_LOCK); - - ltype &= ~TDB_MARK_LOCK; - - /* There are no locks on read-only dbs */ - if (tdb->read_only || tdb->traverse_read) { - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - - if (tdb->global_lock.ltype != ltype || tdb->global_lock.count == 0) { - return TDB_ERRCODE(TDB_ERR_LOCK, -1); - } - - if (tdb->global_lock.count > 1) { - tdb->global_lock.count--; - return 0; - } - - if (!mark_lock && - tdb->methods->tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, - 0, 4*tdb->header.hash_size)) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlockall failed (%s)\n", strerror(errno))); - return -1; - } - - tdb->global_lock.count = 0; - tdb->global_lock.ltype = 0; - - return 0; -} - -/* lock entire database with write lock */ -int tdb_lockall(struct tdb_context *tdb) -{ - return _tdb_lockall(tdb, F_WRLCK, F_SETLKW); -} - -/* lock entire database with write lock - mark only */ -int tdb_lockall_mark(struct tdb_context *tdb) -{ - return _tdb_lockall(tdb, F_WRLCK | TDB_MARK_LOCK, F_SETLKW); -} - -/* unlock entire database with write lock - unmark only */ -int tdb_lockall_unmark(struct tdb_context *tdb) -{ - return _tdb_unlockall(tdb, F_WRLCK | TDB_MARK_LOCK); -} - -/* lock entire database with write lock - nonblocking varient */ -int tdb_lockall_nonblock(struct tdb_context *tdb) -{ - return _tdb_lockall(tdb, F_WRLCK, F_SETLK); -} - -/* unlock entire database with write lock */ -int tdb_unlockall(struct tdb_context *tdb) -{ - return _tdb_unlockall(tdb, F_WRLCK); -} - -/* lock entire database with read lock */ -int tdb_lockall_read(struct tdb_context *tdb) -{ - return _tdb_lockall(tdb, F_RDLCK, F_SETLKW); -} - -/* lock entire database with read lock - nonblock varient */ -int tdb_lockall_read_nonblock(struct tdb_context *tdb) -{ - return _tdb_lockall(tdb, F_RDLCK, F_SETLK); -} - -/* unlock entire database with read lock */ -int tdb_unlockall_read(struct tdb_context *tdb) -{ - return _tdb_unlockall(tdb, F_RDLCK); -} - -/* lock/unlock one hash chain. This is meant to be used to reduce - contention - it cannot guarantee how many records will be locked */ -int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK); -} - -/* lock/unlock one hash chain, non-blocking. This is meant to be used - to reduce contention - it cannot guarantee how many records will be - locked */ -int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_lock_nonblock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK); -} - -/* mark a chain as locked without actually locking it. Warning! use with great caution! */ -int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK | TDB_MARK_LOCK); -} - -/* unmark a chain as locked without actually locking it. Warning! use with great caution! */ -int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK | TDB_MARK_LOCK); -} - -int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_WRLCK); -} - -int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_lock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK); -} - -int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key) -{ - return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK); -} - - - -/* record lock stops delete underneath */ -int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off) -{ - if (tdb->global_lock.count) { - return 0; - } - return off ? tdb->methods->tdb_brlock(tdb, off, F_RDLCK, F_SETLKW, 0, 1) : 0; -} - -/* - Write locks override our own fcntl readlocks, so check it here. - Note this is meant to be F_SETLK, *not* F_SETLKW, as it's not - an error to fail to get the lock here. -*/ -int tdb_write_lock_record(struct tdb_context *tdb, tdb_off_t off) -{ - struct tdb_traverse_lock *i; - for (i = &tdb->travlocks; i; i = i->next) - if (i->off == off) - return -1; - return tdb->methods->tdb_brlock(tdb, off, F_WRLCK, F_SETLK, 1, 1); -} - -/* - Note this is meant to be F_SETLK, *not* F_SETLKW, as it's not - an error to fail to get the lock here. -*/ -int tdb_write_unlock_record(struct tdb_context *tdb, tdb_off_t off) -{ - return tdb->methods->tdb_brlock(tdb, off, F_UNLCK, F_SETLK, 0, 1); -} - -/* fcntl locks don't stack: avoid unlocking someone else's */ -int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off) -{ - struct tdb_traverse_lock *i; - uint32_t count = 0; - - if (tdb->global_lock.count) { - return 0; - } - - if (off == 0) - return 0; - for (i = &tdb->travlocks; i; i = i->next) - if (i->off == off) - count++; - return (count == 1 ? tdb->methods->tdb_brlock(tdb, off, F_UNLCK, F_SETLKW, 0, 1) : 0); -} diff --git a/source4/lib/tdb/common/open.c b/source4/lib/tdb/common/open.c deleted file mode 100644 index b19e4cea29..0000000000 --- a/source4/lib/tdb/common/open.c +++ /dev/null @@ -1,488 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -/* all contexts, to ensure no double-opens (fcntl locks don't nest!) */ -static struct tdb_context *tdbs = NULL; - - -/* This is based on the hash algorithm from gdbm */ -static unsigned int default_tdb_hash(TDB_DATA *key) -{ - uint32_t value; /* Used to compute the hash value. */ - uint32_t i; /* Used to cycle through random values. */ - - /* Set the initial value from the key size. */ - for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++) - value = (value + (key->dptr[i] << (i*5 % 24))); - - return (1103515243 * value + 12345); -} - - -/* initialise a new database with a specified hash size */ -static int tdb_new_database(struct tdb_context *tdb, int hash_size) -{ - struct tdb_header *newdb; - size_t size; - int ret = -1; - ssize_t written; - - /* We make it up in memory, then write it out if not internal */ - size = sizeof(struct tdb_header) + (hash_size+1)*sizeof(tdb_off_t); - if (!(newdb = (struct tdb_header *)calloc(size, 1))) - return TDB_ERRCODE(TDB_ERR_OOM, -1); - - /* Fill in the header */ - newdb->version = TDB_VERSION; - newdb->hash_size = hash_size; - if (tdb->flags & TDB_INTERNAL) { - tdb->map_size = size; - tdb->map_ptr = (char *)newdb; - memcpy(&tdb->header, newdb, sizeof(tdb->header)); - /* Convert the `ondisk' version if asked. */ - CONVERT(*newdb); - return 0; - } - if (lseek(tdb->fd, 0, SEEK_SET) == -1) - goto fail; - - if (ftruncate(tdb->fd, 0) == -1) - goto fail; - - /* This creates an endian-converted header, as if read from disk */ - CONVERT(*newdb); - memcpy(&tdb->header, newdb, sizeof(tdb->header)); - /* Don't endian-convert the magic food! */ - memcpy(newdb->magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1); - /* we still have "ret == -1" here */ - written = write(tdb->fd, newdb, size); - if (written == size) { - ret = 0; - } else if (written != -1) { - /* call write once again, this usually should return -1 and - * set errno appropriately */ - size -= written; - written = write(tdb->fd, newdb+written, size); - if (written == size) { - ret = 0; - } else if (written >= 0) { - /* a second incomplete write - we give up. - * guessing the errno... */ - errno = ENOSPC; - } - } - - fail: - SAFE_FREE(newdb); - return ret; -} - - - -static int tdb_already_open(dev_t device, - ino_t ino) -{ - struct tdb_context *i; - - for (i = tdbs; i; i = i->next) { - if (i->device == device && i->inode == ino) { - return 1; - } - } - - return 0; -} - -/* open the database, creating it if necessary - - The open_flags and mode are passed straight to the open call on the - database file. A flags value of O_WRONLY is invalid. The hash size - is advisory, use zero for a default value. - - Return is NULL on error, in which case errno is also set. Don't - try to call tdb_error or tdb_errname, just do strerror(errno). - - @param name may be NULL for internal databases. */ -struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode) -{ - return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL, NULL); -} - -/* a default logging function */ -static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) -{ -} - - -struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode, - const struct tdb_logging_context *log_ctx, - tdb_hash_func hash_fn) -{ - struct tdb_context *tdb; - struct stat st; - int rev = 0, locked = 0; - unsigned char *vp; - uint32_t vertest; - unsigned v; - - if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) { - /* Can't log this */ - errno = ENOMEM; - goto fail; - } - tdb_io_init(tdb); - tdb->fd = -1; - tdb->name = NULL; - tdb->map_ptr = NULL; - tdb->flags = tdb_flags; - tdb->open_flags = open_flags; - if (log_ctx) { - tdb->log = *log_ctx; - } else { - tdb->log.log_fn = null_log_fn; - tdb->log.log_private = NULL; - } - tdb->hash_fn = hash_fn ? hash_fn : default_tdb_hash; - - /* cache the page size */ - tdb->page_size = getpagesize(); - if (tdb->page_size <= 0) { - tdb->page_size = 0x2000; - } - - tdb->max_dead_records = (tdb_flags & TDB_VOLATILE) ? 5 : 0; - - if ((open_flags & O_ACCMODE) == O_WRONLY) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: can't open tdb %s write-only\n", - name)); - errno = EINVAL; - goto fail; - } - - if (hash_size == 0) - hash_size = DEFAULT_HASH_SIZE; - if ((open_flags & O_ACCMODE) == O_RDONLY) { - tdb->read_only = 1; - /* read only databases don't do locking or clear if first */ - tdb->flags |= TDB_NOLOCK; - tdb->flags &= ~TDB_CLEAR_IF_FIRST; - } - - /* internal databases don't mmap or lock, and start off cleared */ - if (tdb->flags & TDB_INTERNAL) { - tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP); - tdb->flags &= ~TDB_CLEAR_IF_FIRST; - if (tdb_new_database(tdb, hash_size) != 0) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: tdb_new_database failed!")); - goto fail; - } - goto internal; - } - - if ((tdb->fd = open(name, open_flags, mode)) == -1) { - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_open_ex: could not open file %s: %s\n", - name, strerror(errno))); - goto fail; /* errno set by open(2) */ - } - - /* on exec, don't inherit the fd */ - v = fcntl(tdb->fd, F_GETFD, 0); - fcntl(tdb->fd, F_SETFD, v | FD_CLOEXEC); - - /* ensure there is only one process initialising at once */ - if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_WRLCK, F_SETLKW, 0, 1) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to get global lock on %s: %s\n", - name, strerror(errno))); - goto fail; /* errno set by tdb_brlock */ - } - - /* we need to zero database if we are the only one with it open */ - if ((tdb_flags & TDB_CLEAR_IF_FIRST) && - (!tdb->read_only) && - (locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0))) { - open_flags |= O_CREAT; - if (ftruncate(tdb->fd, 0) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: " - "failed to truncate %s: %s\n", - name, strerror(errno))); - goto fail; /* errno set by ftruncate */ - } - } - - errno = 0; - if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != sizeof(tdb->header) - || strcmp(tdb->header.magic_food, TDB_MAGIC_FOOD) != 0 - || (tdb->header.version != TDB_VERSION - && !(rev = (tdb->header.version==TDB_BYTEREV(TDB_VERSION))))) { - /* its not a valid database - possibly initialise it */ - if (!(open_flags & O_CREAT) || tdb_new_database(tdb, hash_size) == -1) { - if (errno == 0) { - errno = EIO; /* ie bad format or something */ - } - goto fail; - } - rev = (tdb->flags & TDB_CONVERT); - } - vp = (unsigned char *)&tdb->header.version; - vertest = (((uint32_t)vp[0]) << 24) | (((uint32_t)vp[1]) << 16) | - (((uint32_t)vp[2]) << 8) | (uint32_t)vp[3]; - tdb->flags |= (vertest==TDB_VERSION) ? TDB_BIGENDIAN : 0; - if (!rev) - tdb->flags &= ~TDB_CONVERT; - else { - tdb->flags |= TDB_CONVERT; - tdb_convert(&tdb->header, sizeof(tdb->header)); - } - if (fstat(tdb->fd, &st) == -1) - goto fail; - - if (tdb->header.rwlocks != 0) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no longer supported\n")); - goto fail; - } - - /* Is it already in the open list? If so, fail. */ - if (tdb_already_open(st.st_dev, st.st_ino)) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: " - "%s (%d,%d) is already open in this process\n", - name, (int)st.st_dev, (int)st.st_ino)); - errno = EBUSY; - goto fail; - } - - if (!(tdb->name = (char *)strdup(name))) { - errno = ENOMEM; - goto fail; - } - - tdb->map_size = st.st_size; - tdb->device = st.st_dev; - tdb->inode = st.st_ino; - tdb_mmap(tdb); - if (locked) { - if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: " - "failed to take ACTIVE_LOCK on %s: %s\n", - name, strerror(errno))); - goto fail; - } - - } - - /* We always need to do this if the CLEAR_IF_FIRST flag is set, even if - we didn't get the initial exclusive lock as we need to let all other - users know we're using it. */ - - if (tdb_flags & TDB_CLEAR_IF_FIRST) { - /* leave this lock in place to indicate it's in use */ - if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1) - goto fail; - } - - /* if needed, run recovery */ - if (tdb_transaction_recover(tdb) == -1) { - goto fail; - } - - internal: - /* Internal (memory-only) databases skip all the code above to - * do with disk files, and resume here by releasing their - * global lock and hooking into the active list. */ - if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1) == -1) - goto fail; - tdb->next = tdbs; - tdbs = tdb; - return tdb; - - fail: - { int save_errno = errno; - - if (!tdb) - return NULL; - - if (tdb->map_ptr) { - if (tdb->flags & TDB_INTERNAL) - SAFE_FREE(tdb->map_ptr); - else - tdb_munmap(tdb); - } - SAFE_FREE(tdb->name); - if (tdb->fd != -1) - if (close(tdb->fd) != 0) - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to close tdb->fd on error!\n")); - SAFE_FREE(tdb); - errno = save_errno; - return NULL; - } -} - -/* - * Set the maximum number of dead records per hash chain - */ - -void tdb_set_max_dead(struct tdb_context *tdb, int max_dead) -{ - tdb->max_dead_records = max_dead; -} - -/** - * Close a database. - * - * @returns -1 for error; 0 for success. - **/ -int tdb_close(struct tdb_context *tdb) -{ - struct tdb_context **i; - int ret = 0; - - if (tdb->transaction) { - tdb_transaction_cancel(tdb); - } - - if (tdb->map_ptr) { - if (tdb->flags & TDB_INTERNAL) - SAFE_FREE(tdb->map_ptr); - else - tdb_munmap(tdb); - } - SAFE_FREE(tdb->name); - if (tdb->fd != -1) - ret = close(tdb->fd); - SAFE_FREE(tdb->lockrecs); - - /* Remove from contexts list */ - for (i = &tdbs; *i; i = &(*i)->next) { - if (*i == tdb) { - *i = tdb->next; - break; - } - } - - memset(tdb, 0, sizeof(*tdb)); - SAFE_FREE(tdb); - - return ret; -} - -/* register a loging function */ -void tdb_set_logging_function(struct tdb_context *tdb, - const struct tdb_logging_context *log_ctx) -{ - tdb->log = *log_ctx; -} - -void *tdb_get_logging_private(struct tdb_context *tdb) -{ - return tdb->log.log_private; -} - -/* reopen a tdb - this can be used after a fork to ensure that we have an independent - seek pointer from our parent and to re-establish locks */ -int tdb_reopen(struct tdb_context *tdb) -{ - struct stat st; - - if (tdb->flags & TDB_INTERNAL) { - return 0; /* Nothing to do. */ - } - - if (tdb->num_locks != 0 || tdb->global_lock.count) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_reopen: reopen not allowed with locks held\n")); - goto fail; - } - - if (tdb->transaction != 0) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_reopen: reopen not allowed inside a transaction\n")); - goto fail; - } - - if (tdb_munmap(tdb) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: munmap failed (%s)\n", strerror(errno))); - goto fail; - } - if (close(tdb->fd) != 0) - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: WARNING closing tdb->fd failed!\n")); - tdb->fd = open(tdb->name, tdb->open_flags & ~(O_CREAT|O_TRUNC), 0); - if (tdb->fd == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: open failed (%s)\n", strerror(errno))); - goto fail; - } - if ((tdb->flags & TDB_CLEAR_IF_FIRST) && - (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: failed to obtain active lock\n")); - goto fail; - } - if (fstat(tdb->fd, &st) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: fstat failed (%s)\n", strerror(errno))); - goto fail; - } - if (st.st_ino != tdb->inode || st.st_dev != tdb->device) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: file dev/inode has changed!\n")); - goto fail; - } - tdb_mmap(tdb); - - return 0; - -fail: - tdb_close(tdb); - return -1; -} - -/* reopen all tdb's */ -int tdb_reopen_all(int parent_longlived) -{ - struct tdb_context *tdb; - - for (tdb=tdbs; tdb; tdb = tdb->next) { - /* - * If the parent is longlived (ie. a - * parent daemon architecture), we know - * it will keep it's active lock on a - * tdb opened with CLEAR_IF_FIRST. Thus - * for child processes we don't have to - * add an active lock. This is essential - * to improve performance on systems that - * keep POSIX locks as a non-scalable data - * structure in the kernel. - */ - if (parent_longlived) { - /* Ensure no clear-if-first. */ - tdb->flags &= ~TDB_CLEAR_IF_FIRST; - } - - if (tdb_reopen(tdb) != 0) - return -1; - } - - return 0; -} diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c deleted file mode 100644 index c7cec297f6..0000000000 --- a/source4/lib/tdb/common/tdb.c +++ /dev/null @@ -1,802 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -TDB_DATA tdb_null; - -/* - non-blocking increment of the tdb sequence number if the tdb has been opened using - the TDB_SEQNUM flag -*/ -void tdb_increment_seqnum_nonblock(struct tdb_context *tdb) -{ - tdb_off_t seqnum=0; - - if (!(tdb->flags & TDB_SEQNUM)) { - return; - } - - /* we ignore errors from this, as we have no sane way of - dealing with them. - */ - tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum); - seqnum++; - tdb_ofs_write(tdb, TDB_SEQNUM_OFS, &seqnum); -} - -/* - increment the tdb sequence number if the tdb has been opened using - the TDB_SEQNUM flag -*/ -static void tdb_increment_seqnum(struct tdb_context *tdb) -{ - if (!(tdb->flags & TDB_SEQNUM)) { - return; - } - - if (tdb_brlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, F_SETLKW, 1, 1) != 0) { - return; - } - - tdb_increment_seqnum_nonblock(tdb); - - tdb_brlock(tdb, TDB_SEQNUM_OFS, F_UNLCK, F_SETLKW, 1, 1); -} - -static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data) -{ - return memcmp(data.dptr, key.dptr, data.dsize); -} - -/* Returns 0 on fail. On success, return offset of record, and fills - in rec */ -static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, - struct list_struct *r) -{ - tdb_off_t rec_ptr; - - /* read in the hash top */ - if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) - return 0; - - /* keep looking until we find the right record */ - while (rec_ptr) { - if (tdb_rec_read(tdb, rec_ptr, r) == -1) - return 0; - - if (!TDB_DEAD(r) && hash==r->full_hash - && key.dsize==r->key_len - && tdb_parse_data(tdb, key, rec_ptr + sizeof(*r), - r->key_len, tdb_key_compare, - NULL) == 0) { - return rec_ptr; - } - rec_ptr = r->next; - } - return TDB_ERRCODE(TDB_ERR_NOEXIST, 0); -} - -/* As tdb_find, but if you succeed, keep the lock */ -tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype, - struct list_struct *rec) -{ - uint32_t rec_ptr; - - if (tdb_lock(tdb, BUCKET(hash), locktype) == -1) - return 0; - if (!(rec_ptr = tdb_find(tdb, key, hash, rec))) - tdb_unlock(tdb, BUCKET(hash), locktype); - return rec_ptr; -} - - -/* update an entry in place - this only works if the new data size - is <= the old data size and the key exists. - on failure return -1. -*/ -static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, TDB_DATA dbuf) -{ - struct list_struct rec; - tdb_off_t rec_ptr; - - /* find entry */ - if (!(rec_ptr = tdb_find(tdb, key, hash, &rec))) - return -1; - - /* must be long enough key, data and tailer */ - if (rec.rec_len < key.dsize + dbuf.dsize + sizeof(tdb_off_t)) { - tdb->ecode = TDB_SUCCESS; /* Not really an error */ - return -1; - } - - if (tdb->methods->tdb_write(tdb, rec_ptr + sizeof(rec) + rec.key_len, - dbuf.dptr, dbuf.dsize) == -1) - return -1; - - if (dbuf.dsize != rec.data_len) { - /* update size */ - rec.data_len = dbuf.dsize; - return tdb_rec_write(tdb, rec_ptr, &rec); - } - - return 0; -} - -/* find an entry in the database given a key */ -/* If an entry doesn't exist tdb_err will be set to - * TDB_ERR_NOEXIST. If a key has no data attached - * then the TDB_DATA will have zero length but - * a non-zero pointer - */ -TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key) -{ - tdb_off_t rec_ptr; - struct list_struct rec; - TDB_DATA ret; - uint32_t hash; - - /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); - if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) - return tdb_null; - - ret.dptr = tdb_alloc_read(tdb, rec_ptr + sizeof(rec) + rec.key_len, - rec.data_len); - ret.dsize = rec.data_len; - tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK); - return ret; -} - -/* - * Find an entry in the database and hand the record's data to a parsing - * function. The parsing function is executed under the chain read lock, so it - * should be fast and should not block on other syscalls. - * - * DONT CALL OTHER TDB CALLS FROM THE PARSER, THIS MIGHT LEAD TO SEGFAULTS. - * - * For mmapped tdb's that do not have a transaction open it points the parsing - * function directly at the mmap area, it avoids the malloc/memcpy in this - * case. If a transaction is open or no mmap is available, it has to do - * malloc/read/parse/free. - * - * This is interesting for all readers of potentially large data structures in - * the tdb records, ldb indexes being one example. - */ - -int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, - int (*parser)(TDB_DATA key, TDB_DATA data, - void *private_data), - void *private_data) -{ - tdb_off_t rec_ptr; - struct list_struct rec; - int ret; - uint32_t hash; - - /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); - - if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) { - return TDB_ERRCODE(TDB_ERR_NOEXIST, 0); - } - - ret = tdb_parse_data(tdb, key, rec_ptr + sizeof(rec) + rec.key_len, - rec.data_len, parser, private_data); - - tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK); - - return ret; -} - -/* check if an entry in the database exists - - note that 1 is returned if the key is found and 0 is returned if not found - this doesn't match the conventions in the rest of this module, but is - compatible with gdbm -*/ -static int tdb_exists_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash) -{ - struct list_struct rec; - - if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0) - return 0; - tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK); - return 1; -} - -int tdb_exists(struct tdb_context *tdb, TDB_DATA key) -{ - uint32_t hash = tdb->hash_fn(&key); - return tdb_exists_hash(tdb, key, hash); -} - -/* actually delete an entry in the database given the offset */ -int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec) -{ - tdb_off_t last_ptr, i; - struct list_struct lastrec; - - if (tdb->read_only || tdb->traverse_read) return -1; - - if (((tdb->traverse_write != 0) && (!TDB_DEAD(rec))) || - tdb_write_lock_record(tdb, rec_ptr) == -1) { - /* Someone traversing here: mark it as dead */ - rec->magic = TDB_DEAD_MAGIC; - return tdb_rec_write(tdb, rec_ptr, rec); - } - if (tdb_write_unlock_record(tdb, rec_ptr) != 0) - return -1; - - /* find previous record in hash chain */ - if (tdb_ofs_read(tdb, TDB_HASH_TOP(rec->full_hash), &i) == -1) - return -1; - for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next) - if (tdb_rec_read(tdb, i, &lastrec) == -1) - return -1; - - /* unlink it: next ptr is at start of record. */ - if (last_ptr == 0) - last_ptr = TDB_HASH_TOP(rec->full_hash); - if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) - return -1; - - /* recover the space */ - if (tdb_free(tdb, rec_ptr, rec) == -1) - return -1; - return 0; -} - -static int tdb_count_dead(struct tdb_context *tdb, uint32_t hash) -{ - int res = 0; - tdb_off_t rec_ptr; - struct list_struct rec; - - /* read in the hash top */ - if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) - return 0; - - while (rec_ptr) { - if (tdb_rec_read(tdb, rec_ptr, &rec) == -1) - return 0; - - if (rec.magic == TDB_DEAD_MAGIC) { - res += 1; - } - rec_ptr = rec.next; - } - return res; -} - -/* - * Purge all DEAD records from a hash chain - */ -static int tdb_purge_dead(struct tdb_context *tdb, uint32_t hash) -{ - int res = -1; - struct list_struct rec; - tdb_off_t rec_ptr; - - if (tdb_lock(tdb, -1, F_WRLCK) == -1) { - return -1; - } - - /* read in the hash top */ - if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) - goto fail; - - while (rec_ptr) { - tdb_off_t next; - - if (tdb_rec_read(tdb, rec_ptr, &rec) == -1) { - goto fail; - } - - next = rec.next; - - if (rec.magic == TDB_DEAD_MAGIC - && tdb_do_delete(tdb, rec_ptr, &rec) == -1) { - goto fail; - } - rec_ptr = next; - } - res = 0; - fail: - tdb_unlock(tdb, -1, F_WRLCK); - return res; -} - -/* delete an entry in the database given a key */ -static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash) -{ - tdb_off_t rec_ptr; - struct list_struct rec; - int ret; - - if (tdb->max_dead_records != 0) { - - /* - * Allow for some dead records per hash chain, mainly for - * tdb's with a very high create/delete rate like locking.tdb. - */ - - if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1) - return -1; - - if (tdb_count_dead(tdb, hash) >= tdb->max_dead_records) { - /* - * Don't let the per-chain freelist grow too large, - * delete all existing dead records - */ - tdb_purge_dead(tdb, hash); - } - - if (!(rec_ptr = tdb_find(tdb, key, hash, &rec))) { - tdb_unlock(tdb, BUCKET(hash), F_WRLCK); - return -1; - } - - /* - * Just mark the record as dead. - */ - rec.magic = TDB_DEAD_MAGIC; - ret = tdb_rec_write(tdb, rec_ptr, &rec); - } - else { - if (!(rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK, - &rec))) - return -1; - - ret = tdb_do_delete(tdb, rec_ptr, &rec); - } - - if (ret == 0) { - tdb_increment_seqnum(tdb); - } - - if (tdb_unlock(tdb, BUCKET(rec.full_hash), F_WRLCK) != 0) - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_delete: WARNING tdb_unlock failed!\n")); - return ret; -} - -int tdb_delete(struct tdb_context *tdb, TDB_DATA key) -{ - uint32_t hash = tdb->hash_fn(&key); - return tdb_delete_hash(tdb, key, hash); -} - -/* - * See if we have a dead record around with enough space - */ -static tdb_off_t tdb_find_dead(struct tdb_context *tdb, uint32_t hash, - struct list_struct *r, tdb_len_t length) -{ - tdb_off_t rec_ptr; - - /* read in the hash top */ - if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) - return 0; - - /* keep looking until we find the right record */ - while (rec_ptr) { - if (tdb_rec_read(tdb, rec_ptr, r) == -1) - return 0; - - if (TDB_DEAD(r) && r->rec_len >= length) { - /* - * First fit for simple coding, TODO: change to best - * fit - */ - return rec_ptr; - } - rec_ptr = r->next; - } - return 0; -} - -/* store an element in the database, replacing any existing element - with the same key - - return 0 on success, -1 on failure -*/ -int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) -{ - struct list_struct rec; - uint32_t hash; - tdb_off_t rec_ptr; - char *p = NULL; - int ret = -1; - - if (tdb->read_only || tdb->traverse_read) { - tdb->ecode = TDB_ERR_RDONLY; - return -1; - } - - /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); - if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1) - return -1; - - /* check for it existing, on insert. */ - if (flag == TDB_INSERT) { - if (tdb_exists_hash(tdb, key, hash)) { - tdb->ecode = TDB_ERR_EXISTS; - goto fail; - } - } else { - /* first try in-place update, on modify or replace. */ - if (tdb_update_hash(tdb, key, hash, dbuf) == 0) { - goto done; - } - if (tdb->ecode == TDB_ERR_NOEXIST && - flag == TDB_MODIFY) { - /* if the record doesn't exist and we are in TDB_MODIFY mode then - we should fail the store */ - goto fail; - } - } - /* reset the error code potentially set by the tdb_update() */ - tdb->ecode = TDB_SUCCESS; - - /* delete any existing record - if it doesn't exist we don't - care. Doing this first reduces fragmentation, and avoids - coalescing with `allocated' block before it's updated. */ - if (flag != TDB_INSERT) - tdb_delete_hash(tdb, key, hash); - - /* Copy key+value *before* allocating free space in case malloc - fails and we are left with a dead spot in the tdb. */ - - if (!(p = (char *)malloc(key.dsize + dbuf.dsize))) { - tdb->ecode = TDB_ERR_OOM; - goto fail; - } - - memcpy(p, key.dptr, key.dsize); - if (dbuf.dsize) - memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize); - - if (tdb->max_dead_records != 0) { - /* - * Allow for some dead records per hash chain, look if we can - * find one that can hold the new record. We need enough space - * for key, data and tailer. If we find one, we don't have to - * consult the central freelist. - */ - rec_ptr = tdb_find_dead( - tdb, hash, &rec, - key.dsize + dbuf.dsize + sizeof(tdb_off_t)); - - if (rec_ptr != 0) { - rec.key_len = key.dsize; - rec.data_len = dbuf.dsize; - rec.full_hash = hash; - rec.magic = TDB_MAGIC; - if (tdb_rec_write(tdb, rec_ptr, &rec) == -1 - || tdb->methods->tdb_write( - tdb, rec_ptr + sizeof(rec), - p, key.dsize + dbuf.dsize) == -1) { - goto fail; - } - goto done; - } - } - - /* - * We have to allocate some space from the freelist, so this means we - * have to lock it. Use the chance to purge all the DEAD records from - * the hash chain under the freelist lock. - */ - - if (tdb_lock(tdb, -1, F_WRLCK) == -1) { - goto fail; - } - - if ((tdb->max_dead_records != 0) - && (tdb_purge_dead(tdb, hash) == -1)) { - tdb_unlock(tdb, -1, F_WRLCK); - goto fail; - } - - /* we have to allocate some space */ - rec_ptr = tdb_allocate(tdb, key.dsize + dbuf.dsize, &rec); - - tdb_unlock(tdb, -1, F_WRLCK); - - if (rec_ptr == 0) { - goto fail; - } - - /* Read hash top into next ptr */ - if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec.next) == -1) - goto fail; - - rec.key_len = key.dsize; - rec.data_len = dbuf.dsize; - rec.full_hash = hash; - rec.magic = TDB_MAGIC; - - /* write out and point the top of the hash chain at it */ - if (tdb_rec_write(tdb, rec_ptr, &rec) == -1 - || tdb->methods->tdb_write(tdb, rec_ptr+sizeof(rec), p, key.dsize+dbuf.dsize)==-1 - || tdb_ofs_write(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) { - /* Need to tdb_unallocate() here */ - goto fail; - } - - done: - ret = 0; - fail: - if (ret == 0) { - tdb_increment_seqnum(tdb); - } - - SAFE_FREE(p); - tdb_unlock(tdb, BUCKET(hash), F_WRLCK); - return ret; -} - - -/* Append to an entry. Create if not exist. */ -int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf) -{ - uint32_t hash; - TDB_DATA dbuf; - int ret = -1; - - /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); - if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1) - return -1; - - dbuf = tdb_fetch(tdb, key); - - if (dbuf.dptr == NULL) { - dbuf.dptr = (unsigned char *)malloc(new_dbuf.dsize); - } else { - unsigned char *new_dptr = (unsigned char *)realloc(dbuf.dptr, - dbuf.dsize + new_dbuf.dsize); - if (new_dptr == NULL) { - free(dbuf.dptr); - } - dbuf.dptr = new_dptr; - } - - if (dbuf.dptr == NULL) { - tdb->ecode = TDB_ERR_OOM; - goto failed; - } - - memcpy(dbuf.dptr + dbuf.dsize, new_dbuf.dptr, new_dbuf.dsize); - dbuf.dsize += new_dbuf.dsize; - - ret = tdb_store(tdb, key, dbuf, 0); - -failed: - tdb_unlock(tdb, BUCKET(hash), F_WRLCK); - SAFE_FREE(dbuf.dptr); - return ret; -} - - -/* - return the name of the current tdb file - useful for external logging functions -*/ -const char *tdb_name(struct tdb_context *tdb) -{ - return tdb->name; -} - -/* - return the underlying file descriptor being used by tdb, or -1 - useful for external routines that want to check the device/inode - of the fd -*/ -int tdb_fd(struct tdb_context *tdb) -{ - return tdb->fd; -} - -/* - return the current logging function - useful for external tdb routines that wish to log tdb errors -*/ -tdb_log_func tdb_log_fn(struct tdb_context *tdb) -{ - return tdb->log.log_fn; -} - - -/* - get the tdb sequence number. Only makes sense if the writers opened - with TDB_SEQNUM set. Note that this sequence number will wrap quite - quickly, so it should only be used for a 'has something changed' - test, not for code that relies on the count of the number of changes - made. If you want a counter then use a tdb record. - - The aim of this sequence number is to allow for a very lightweight - test of a possible tdb change. -*/ -int tdb_get_seqnum(struct tdb_context *tdb) -{ - tdb_off_t seqnum=0; - - tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum); - return seqnum; -} - -int tdb_hash_size(struct tdb_context *tdb) -{ - return tdb->header.hash_size; -} - -size_t tdb_map_size(struct tdb_context *tdb) -{ - return tdb->map_size; -} - -int tdb_get_flags(struct tdb_context *tdb) -{ - return tdb->flags; -} - -void tdb_add_flags(struct tdb_context *tdb, unsigned flags) -{ - tdb->flags |= flags; -} - -void tdb_remove_flags(struct tdb_context *tdb, unsigned flags) -{ - tdb->flags &= ~flags; -} - - -/* - enable sequence number handling on an open tdb -*/ -void tdb_enable_seqnum(struct tdb_context *tdb) -{ - tdb->flags |= TDB_SEQNUM; -} - - -/* - add a region of the file to the freelist. Length is the size of the region in bytes, - which includes the free list header that needs to be added - */ -static int tdb_free_region(struct tdb_context *tdb, tdb_off_t offset, ssize_t length) -{ - struct list_struct rec; - if (length <= sizeof(rec)) { - /* the region is not worth adding */ - return 0; - } - if (length + offset > tdb->map_size) { - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_free_region: adding region beyond end of file\n")); - return -1; - } - memset(&rec,'\0',sizeof(rec)); - rec.rec_len = length - sizeof(rec); - if (tdb_free(tdb, offset, &rec) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_free_region: failed to add free record\n")); - return -1; - } - return 0; -} - -/* - wipe the entire database, deleting all records. This can be done - very fast by using a global lock. The entire data portion of the - file becomes a single entry in the freelist. - - This code carefully steps around the recovery area, leaving it alone - */ -int tdb_wipe_all(struct tdb_context *tdb) -{ - int i; - tdb_off_t offset = 0; - ssize_t data_len; - tdb_off_t recovery_head; - tdb_len_t recovery_size = 0; - - if (tdb_lockall(tdb) != 0) { - return -1; - } - - /* see if the tdb has a recovery area, and remember its size - if so. We don't want to lose this as otherwise each - tdb_wipe_all() in a transaction will increase the size of - the tdb by the size of the recovery area */ - if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_wipe_all: failed to read recovery head\n")); - goto failed; - } - - if (recovery_head != 0) { - struct list_struct rec; - if (tdb->methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_wipe_all: failed to read recovery record\n")); - return -1; - } - recovery_size = rec.rec_len + sizeof(rec); - } - - /* wipe the hashes */ - for (i=0;iheader.hash_size;i++) { - if (tdb_ofs_write(tdb, TDB_HASH_TOP(i), &offset) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write hash %d\n", i)); - goto failed; - } - } - - /* wipe the freelist */ - if (tdb_ofs_write(tdb, FREELIST_TOP, &offset) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write freelist\n")); - goto failed; - } - - /* add all the rest of the file to the freelist, possibly leaving a gap - for the recovery area */ - if (recovery_size == 0) { - /* the simple case - the whole file can be used as a freelist */ - data_len = (tdb->map_size - TDB_DATA_START(tdb->header.hash_size)); - if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) { - goto failed; - } - } else { - /* we need to add two freelist entries - one on either - side of the recovery area - - Note that we cannot shift the recovery area during - this operation. Only the transaction.c code may - move the recovery area or we risk subtle data - corruption - */ - data_len = (recovery_head - TDB_DATA_START(tdb->header.hash_size)); - if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) { - goto failed; - } - /* and the 2nd free list entry after the recovery area - if any */ - data_len = tdb->map_size - (recovery_head+recovery_size); - if (tdb_free_region(tdb, recovery_head+recovery_size, data_len) != 0) { - goto failed; - } - } - - if (tdb_unlockall(tdb) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to unlock\n")); - goto failed; - } - - return 0; - -failed: - tdb_unlockall(tdb); - return -1; -} diff --git a/source4/lib/tdb/common/tdb_private.h b/source4/lib/tdb/common/tdb_private.h deleted file mode 100644 index ffac89ff0e..0000000000 --- a/source4/lib/tdb/common/tdb_private.h +++ /dev/null @@ -1,213 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - private includes - - Copyright (C) Andrew Tridgell 2005 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "replace.h" -#include "system/filesys.h" -#include "system/time.h" -#include "system/shmem.h" -#include "system/select.h" -#include "system/wait.h" -#include "tdb.h" - -#ifndef HAVE_GETPAGESIZE -#define getpagesize() 0x2000 -#endif - -typedef uint32_t tdb_len_t; -typedef uint32_t tdb_off_t; - -#ifndef offsetof -#define offsetof(t,f) ((unsigned int)&((t *)0)->f) -#endif - -#define TDB_MAGIC_FOOD "TDB file\n" -#define TDB_VERSION (0x26011967 + 6) -#define TDB_MAGIC (0x26011999U) -#define TDB_FREE_MAGIC (~TDB_MAGIC) -#define TDB_DEAD_MAGIC (0xFEE1DEAD) -#define TDB_RECOVERY_MAGIC (0xf53bc0e7U) -#define TDB_ALIGNMENT 4 -#define DEFAULT_HASH_SIZE 131 -#define FREELIST_TOP (sizeof(struct tdb_header)) -#define TDB_ALIGN(x,a) (((x) + (a)-1) & ~((a)-1)) -#define TDB_BYTEREV(x) (((((x)&0xff)<<24)|((x)&0xFF00)<<8)|(((x)>>8)&0xFF00)|((x)>>24)) -#define TDB_DEAD(r) ((r)->magic == TDB_DEAD_MAGIC) -#define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r)) -#define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t)) -#define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t)) -#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + sizeof(tdb_off_t)) -#define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start) -#define TDB_SEQNUM_OFS offsetof(struct tdb_header, sequence_number) -#define TDB_PAD_BYTE 0x42 -#define TDB_PAD_U32 0x42424242 - -/* NB assumes there is a local variable called "tdb" that is the - * current context, also takes doubly-parenthesized print-style - * argument. */ -#define TDB_LOG(x) tdb->log.log_fn x - -/* lock offsets */ -#define GLOBAL_LOCK 0 -#define ACTIVE_LOCK 4 -#define TRANSACTION_LOCK 8 - -/* free memory if the pointer is valid and zero the pointer */ -#ifndef SAFE_FREE -#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0) -#endif - -#define BUCKET(hash) ((hash) % tdb->header.hash_size) - -#define DOCONV() (tdb->flags & TDB_CONVERT) -#define CONVERT(x) (DOCONV() ? tdb_convert(&x, sizeof(x)) : &x) - - -/* the body of the database is made of one list_struct for the free space - plus a separate data list for each hash value */ -struct list_struct { - tdb_off_t next; /* offset of the next record in the list */ - tdb_len_t rec_len; /* total byte length of record */ - tdb_len_t key_len; /* byte length of key */ - tdb_len_t data_len; /* byte length of data */ - uint32_t full_hash; /* the full 32 bit hash of the key */ - uint32_t magic; /* try to catch errors */ - /* the following union is implied: - union { - char record[rec_len]; - struct { - char key[key_len]; - char data[data_len]; - } - uint32_t totalsize; (tailer) - } - */ -}; - - -/* this is stored at the front of every database */ -struct tdb_header { - char magic_food[32]; /* for /etc/magic */ - uint32_t version; /* version of the code */ - uint32_t hash_size; /* number of hash entries */ - tdb_off_t rwlocks; /* obsolete - kept to detect old formats */ - tdb_off_t recovery_start; /* offset of transaction recovery region */ - tdb_off_t sequence_number; /* used when TDB_SEQNUM is set */ - tdb_off_t reserved[29]; -}; - -struct tdb_lock_type { - int list; - uint32_t count; - uint32_t ltype; -}; - -struct tdb_traverse_lock { - struct tdb_traverse_lock *next; - uint32_t off; - uint32_t hash; - int lock_rw; -}; - - -struct tdb_methods { - int (*tdb_read)(struct tdb_context *, tdb_off_t , void *, tdb_len_t , int ); - int (*tdb_write)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t); - void (*next_hash_chain)(struct tdb_context *, uint32_t *); - int (*tdb_oob)(struct tdb_context *, tdb_off_t , int ); - int (*tdb_expand_file)(struct tdb_context *, tdb_off_t , tdb_off_t ); - int (*tdb_brlock)(struct tdb_context *, tdb_off_t , int, int, int, size_t); -}; - -struct tdb_context { - char *name; /* the name of the database */ - void *map_ptr; /* where it is currently mapped */ - int fd; /* open file descriptor for the database */ - tdb_len_t map_size; /* how much space has been mapped */ - int read_only; /* opened read-only */ - int traverse_read; /* read-only traversal */ - int traverse_write; /* read-write traversal */ - struct tdb_lock_type global_lock; - int num_lockrecs; - struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */ - enum TDB_ERROR ecode; /* error code for last tdb error */ - struct tdb_header header; /* a cached copy of the header */ - uint32_t flags; /* the flags passed to tdb_open */ - struct tdb_traverse_lock travlocks; /* current traversal locks */ - struct tdb_context *next; /* all tdbs to avoid multiple opens */ - dev_t device; /* uniquely identifies this tdb */ - ino_t inode; /* uniquely identifies this tdb */ - struct tdb_logging_context log; - unsigned int (*hash_fn)(TDB_DATA *key); - int open_flags; /* flags used in the open - needed by reopen */ - unsigned int num_locks; /* number of chain locks held */ - const struct tdb_methods *methods; - struct tdb_transaction *transaction; - int page_size; - int max_dead_records; - bool have_transaction_lock; - volatile sig_atomic_t *interrupt_sig_ptr; -}; - - -/* - internal prototypes -*/ -int tdb_munmap(struct tdb_context *tdb); -void tdb_mmap(struct tdb_context *tdb); -int tdb_lock(struct tdb_context *tdb, int list, int ltype); -int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype); -int tdb_unlock(struct tdb_context *tdb, int list, int ltype); -int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len); -int tdb_transaction_lock(struct tdb_context *tdb, int ltype); -int tdb_transaction_unlock(struct tdb_context *tdb); -int tdb_brlock_upgrade(struct tdb_context *tdb, tdb_off_t offset, size_t len); -int tdb_write_lock_record(struct tdb_context *tdb, tdb_off_t off); -int tdb_write_unlock_record(struct tdb_context *tdb, tdb_off_t off); -int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d); -int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d); -void *tdb_convert(void *buf, uint32_t size); -int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec); -tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_struct *rec); -int tdb_ofs_read(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d); -int tdb_ofs_write(struct tdb_context *tdb, tdb_off_t offset, tdb_off_t *d); -int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off); -int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off); -int tdb_rec_read(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec); -int tdb_rec_write(struct tdb_context *tdb, tdb_off_t offset, struct list_struct *rec); -int tdb_do_delete(struct tdb_context *tdb, tdb_off_t rec_ptr, struct list_struct *rec); -unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len); -int tdb_parse_data(struct tdb_context *tdb, TDB_DATA key, - tdb_off_t offset, tdb_len_t len, - int (*parser)(TDB_DATA key, TDB_DATA data, - void *private_data), - void *private_data); -tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash, int locktype, - struct list_struct *rec); -void tdb_io_init(struct tdb_context *tdb); -int tdb_expand(struct tdb_context *tdb, tdb_off_t size); -int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, - struct list_struct *rec); - - diff --git a/source4/lib/tdb/common/transaction.c b/source4/lib/tdb/common/transaction.c deleted file mode 100644 index 7acda640c8..0000000000 --- a/source4/lib/tdb/common/transaction.c +++ /dev/null @@ -1,1119 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 2005 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -/* - transaction design: - - - only allow a single transaction at a time per database. This makes - using the transaction API simpler, as otherwise the caller would - have to cope with temporary failures in transactions that conflict - with other current transactions - - - keep the transaction recovery information in the same file as the - database, using a special 'transaction recovery' record pointed at - by the header. This removes the need for extra journal files as - used by some other databases - - - dynamically allocated the transaction recover record, re-using it - for subsequent transactions. If a larger record is needed then - tdb_free() the old record to place it on the normal tdb freelist - before allocating the new record - - - during transactions, keep a linked list of writes all that have - been performed by intercepting all tdb_write() calls. The hooked - transaction versions of tdb_read() and tdb_write() check this - linked list and try to use the elements of the list in preference - to the real database. - - - don't allow any locks to be held when a transaction starts, - otherwise we can end up with deadlock (plus lack of lock nesting - in posix locks would mean the lock is lost) - - - if the caller gains a lock during the transaction but doesn't - release it then fail the commit - - - allow for nested calls to tdb_transaction_start(), re-using the - existing transaction record. If the inner transaction is cancelled - then a subsequent commit will fail - - - keep a mirrored copy of the tdb hash chain heads to allow for the - fast hash heads scan on traverse, updating the mirrored copy in - the transaction version of tdb_write - - - allow callers to mix transaction and non-transaction use of tdb, - although once a transaction is started then an exclusive lock is - gained until the transaction is committed or cancelled - - - the commit stategy involves first saving away all modified data - into a linearised buffer in the transaction recovery area, then - marking the transaction recovery area with a magic value to - indicate a valid recovery record. In total 4 fsync/msync calls are - needed per commit to prevent race conditions. It might be possible - to reduce this to 3 or even 2 with some more work. - - - check for a valid recovery record on open of the tdb, while the - global lock is held. Automatically recover from the transaction - recovery area if needed, then continue with the open as - usual. This allows for smooth crash recovery with no administrator - intervention. - - - if TDB_NOSYNC is passed to flags in tdb_open then transactions are - still available, but no transaction recovery area is used and no - fsync/msync calls are made. - -*/ - - -/* - hold the context of any current transaction -*/ -struct tdb_transaction { - /* we keep a mirrored copy of the tdb hash heads here so - tdb_next_hash_chain() can operate efficiently */ - uint32_t *hash_heads; - - /* the original io methods - used to do IOs to the real db */ - const struct tdb_methods *io_methods; - - /* the list of transaction blocks. When a block is first - written to, it gets created in this list */ - uint8_t **blocks; - uint32_t num_blocks; - uint32_t block_size; /* bytes in each block */ - uint32_t last_block_size; /* number of valid bytes in the last block */ - - /* non-zero when an internal transaction error has - occurred. All write operations will then fail until the - transaction is ended */ - int transaction_error; - - /* when inside a transaction we need to keep track of any - nested tdb_transaction_start() calls, as these are allowed, - but don't create a new transaction */ - int nesting; - - /* old file size before transaction */ - tdb_len_t old_map_size; -}; - - -/* - read while in a transaction. We need to check first if the data is in our list - of transaction elements, then if not do a real read -*/ -static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, - tdb_len_t len, int cv) -{ - uint32_t blk; - - /* break it down into block sized ops */ - while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) { - tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size); - if (transaction_read(tdb, off, buf, len2, cv) != 0) { - return -1; - } - len -= len2; - off += len2; - buf = (void *)(len2 + (char *)buf); - } - - if (len == 0) { - return 0; - } - - blk = off / tdb->transaction->block_size; - - /* see if we have it in the block list */ - if (tdb->transaction->num_blocks <= blk || - tdb->transaction->blocks[blk] == NULL) { - /* nope, do a real read */ - if (tdb->transaction->io_methods->tdb_read(tdb, off, buf, len, cv) != 0) { - goto fail; - } - return 0; - } - - /* it is in the block list. Now check for the last block */ - if (blk == tdb->transaction->num_blocks-1) { - if (len > tdb->transaction->last_block_size) { - goto fail; - } - } - - /* now copy it out of this block */ - memcpy(buf, tdb->transaction->blocks[blk] + (off % tdb->transaction->block_size), len); - if (cv) { - tdb_convert(buf, len); - } - return 0; - -fail: - TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_read: failed at off=%d len=%d\n", off, len)); - tdb->ecode = TDB_ERR_IO; - tdb->transaction->transaction_error = 1; - return -1; -} - - -/* - write while in a transaction -*/ -static int transaction_write(struct tdb_context *tdb, tdb_off_t off, - const void *buf, tdb_len_t len) -{ - uint32_t blk; - - /* if the write is to a hash head, then update the transaction - hash heads */ - if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP && - off < FREELIST_TOP+TDB_HASHTABLE_SIZE(tdb)) { - uint32_t chain = (off-FREELIST_TOP) / sizeof(tdb_off_t); - memcpy(&tdb->transaction->hash_heads[chain], buf, len); - } - - /* break it up into block sized chunks */ - while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) { - tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size); - if (transaction_write(tdb, off, buf, len2) != 0) { - return -1; - } - len -= len2; - off += len2; - if (buf != NULL) { - buf = (const void *)(len2 + (const char *)buf); - } - } - - if (len == 0) { - return 0; - } - - blk = off / tdb->transaction->block_size; - off = off % tdb->transaction->block_size; - - if (tdb->transaction->num_blocks <= blk) { - uint8_t **new_blocks; - /* expand the blocks array */ - if (tdb->transaction->blocks == NULL) { - new_blocks = (uint8_t **)malloc( - (blk+1)*sizeof(uint8_t *)); - } else { - new_blocks = (uint8_t **)realloc( - tdb->transaction->blocks, - (blk+1)*sizeof(uint8_t *)); - } - if (new_blocks == NULL) { - tdb->ecode = TDB_ERR_OOM; - goto fail; - } - memset(&new_blocks[tdb->transaction->num_blocks], 0, - (1+(blk - tdb->transaction->num_blocks))*sizeof(uint8_t *)); - tdb->transaction->blocks = new_blocks; - tdb->transaction->num_blocks = blk+1; - tdb->transaction->last_block_size = 0; - } - - /* allocate and fill a block? */ - if (tdb->transaction->blocks[blk] == NULL) { - tdb->transaction->blocks[blk] = (uint8_t *)calloc(tdb->transaction->block_size, 1); - if (tdb->transaction->blocks[blk] == NULL) { - tdb->ecode = TDB_ERR_OOM; - tdb->transaction->transaction_error = 1; - return -1; - } - if (tdb->transaction->old_map_size > blk * tdb->transaction->block_size) { - tdb_len_t len2 = tdb->transaction->block_size; - if (len2 + (blk * tdb->transaction->block_size) > tdb->transaction->old_map_size) { - len2 = tdb->transaction->old_map_size - (blk * tdb->transaction->block_size); - } - if (tdb->transaction->io_methods->tdb_read(tdb, blk * tdb->transaction->block_size, - tdb->transaction->blocks[blk], - len2, 0) != 0) { - SAFE_FREE(tdb->transaction->blocks[blk]); - tdb->ecode = TDB_ERR_IO; - goto fail; - } - if (blk == tdb->transaction->num_blocks-1) { - tdb->transaction->last_block_size = len2; - } - } - } - - /* overwrite part of an existing block */ - if (buf == NULL) { - memset(tdb->transaction->blocks[blk] + off, 0, len); - } else { - memcpy(tdb->transaction->blocks[blk] + off, buf, len); - } - if (blk == tdb->transaction->num_blocks-1) { - if (len + off > tdb->transaction->last_block_size) { - tdb->transaction->last_block_size = len + off; - } - } - - return 0; - -fail: - TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n", - (blk*tdb->transaction->block_size) + off, len)); - tdb->transaction->transaction_error = 1; - return -1; -} - - -/* - write while in a transaction - this varient never expands the transaction blocks, it only - updates existing blocks. This means it cannot change the recovery size -*/ -static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off, - const void *buf, tdb_len_t len) -{ - uint32_t blk; - - /* break it up into block sized chunks */ - while (len + (off % tdb->transaction->block_size) > tdb->transaction->block_size) { - tdb_len_t len2 = tdb->transaction->block_size - (off % tdb->transaction->block_size); - if (transaction_write_existing(tdb, off, buf, len2) != 0) { - return -1; - } - len -= len2; - off += len2; - if (buf != NULL) { - buf = (const void *)(len2 + (const char *)buf); - } - } - - if (len == 0) { - return 0; - } - - blk = off / tdb->transaction->block_size; - off = off % tdb->transaction->block_size; - - if (tdb->transaction->num_blocks <= blk || - tdb->transaction->blocks[blk] == NULL) { - return 0; - } - - if (blk == tdb->transaction->num_blocks-1 && - off + len > tdb->transaction->last_block_size) { - if (off >= tdb->transaction->last_block_size) { - return 0; - } - len = tdb->transaction->last_block_size - off; - } - - /* overwrite part of an existing block */ - memcpy(tdb->transaction->blocks[blk] + off, buf, len); - - return 0; -} - - -/* - accelerated hash chain head search, using the cached hash heads -*/ -static void transaction_next_hash_chain(struct tdb_context *tdb, uint32_t *chain) -{ - uint32_t h = *chain; - for (;h < tdb->header.hash_size;h++) { - /* the +1 takes account of the freelist */ - if (0 != tdb->transaction->hash_heads[h+1]) { - break; - } - } - (*chain) = h; -} - -/* - out of bounds check during a transaction -*/ -static int transaction_oob(struct tdb_context *tdb, tdb_off_t len, int probe) -{ - if (len <= tdb->map_size) { - return 0; - } - return TDB_ERRCODE(TDB_ERR_IO, -1); -} - -/* - transaction version of tdb_expand(). -*/ -static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, - tdb_off_t addition) -{ - /* add a write to the transaction elements, so subsequent - reads see the zero data */ - if (transaction_write(tdb, size, NULL, addition) != 0) { - return -1; - } - - return 0; -} - -/* - brlock during a transaction - ignore them -*/ -static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset, - int rw_type, int lck_type, int probe, size_t len) -{ - return 0; -} - -static const struct tdb_methods transaction_methods = { - transaction_read, - transaction_write, - transaction_next_hash_chain, - transaction_oob, - transaction_expand_file, - transaction_brlock -}; - - -/* - start a tdb transaction. No token is returned, as only a single - transaction is allowed to be pending per tdb_context -*/ -int tdb_transaction_start(struct tdb_context *tdb) -{ - /* some sanity checks */ - if (tdb->read_only || (tdb->flags & TDB_INTERNAL) || tdb->traverse_read) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction on a read-only or internal db\n")); - tdb->ecode = TDB_ERR_EINVAL; - return -1; - } - - /* cope with nested tdb_transaction_start() calls */ - if (tdb->transaction != NULL) { - tdb->transaction->nesting++; - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", - tdb->transaction->nesting)); - return 0; - } - - if (tdb->num_locks != 0 || tdb->global_lock.count) { - /* the caller must not have any locks when starting a - transaction as otherwise we'll be screwed by lack - of nested locks in posix */ - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction with locks held\n")); - tdb->ecode = TDB_ERR_LOCK; - return -1; - } - - if (tdb->travlocks.next != NULL) { - /* you cannot use transactions inside a traverse (although you can use - traverse inside a transaction) as otherwise you can end up with - deadlock */ - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: cannot start a transaction within a traverse\n")); - tdb->ecode = TDB_ERR_LOCK; - return -1; - } - - tdb->transaction = (struct tdb_transaction *) - calloc(sizeof(struct tdb_transaction), 1); - if (tdb->transaction == NULL) { - tdb->ecode = TDB_ERR_OOM; - return -1; - } - - /* a page at a time seems like a reasonable compromise between compactness and efficiency */ - tdb->transaction->block_size = tdb->page_size; - - /* get the transaction write lock. This is a blocking lock. As - discussed with Volker, there are a number of ways we could - make this async, which we will probably do in the future */ - if (tdb_transaction_lock(tdb, F_WRLCK) == -1) { - SAFE_FREE(tdb->transaction->blocks); - SAFE_FREE(tdb->transaction); - return -1; - } - - /* get a read lock from the freelist to the end of file. This - is upgraded to a write lock during the commit */ - if (tdb_brlock(tdb, FREELIST_TOP, F_RDLCK, F_SETLKW, 0, 0) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: failed to get hash locks\n")); - tdb->ecode = TDB_ERR_LOCK; - goto fail; - } - - /* setup a copy of the hash table heads so the hash scan in - traverse can be fast */ - tdb->transaction->hash_heads = (uint32_t *) - calloc(tdb->header.hash_size+1, sizeof(uint32_t)); - if (tdb->transaction->hash_heads == NULL) { - tdb->ecode = TDB_ERR_OOM; - goto fail; - } - if (tdb->methods->tdb_read(tdb, FREELIST_TOP, tdb->transaction->hash_heads, - TDB_HASHTABLE_SIZE(tdb), 0) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_start: failed to read hash heads\n")); - tdb->ecode = TDB_ERR_IO; - goto fail; - } - - /* make sure we know about any file expansions already done by - anyone else */ - tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1); - tdb->transaction->old_map_size = tdb->map_size; - - /* finally hook the io methods, replacing them with - transaction specific methods */ - tdb->transaction->io_methods = tdb->methods; - tdb->methods = &transaction_methods; - - return 0; - -fail: - tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0); - tdb_transaction_unlock(tdb); - SAFE_FREE(tdb->transaction->blocks); - SAFE_FREE(tdb->transaction->hash_heads); - SAFE_FREE(tdb->transaction); - return -1; -} - - -/* - cancel the current transaction -*/ -int tdb_transaction_cancel(struct tdb_context *tdb) -{ - int i; - - if (tdb->transaction == NULL) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_cancel: no transaction\n")); - return -1; - } - - if (tdb->transaction->nesting != 0) { - tdb->transaction->transaction_error = 1; - tdb->transaction->nesting--; - return 0; - } - - tdb->map_size = tdb->transaction->old_map_size; - - /* free all the transaction blocks */ - for (i=0;itransaction->num_blocks;i++) { - if (tdb->transaction->blocks[i] != NULL) { - free(tdb->transaction->blocks[i]); - } - } - SAFE_FREE(tdb->transaction->blocks); - - /* remove any global lock created during the transaction */ - if (tdb->global_lock.count != 0) { - tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 4*tdb->header.hash_size); - tdb->global_lock.count = 0; - } - - /* remove any locks created during the transaction */ - if (tdb->num_locks != 0) { - for (i=0;inum_lockrecs;i++) { - tdb_brlock(tdb,FREELIST_TOP+4*tdb->lockrecs[i].list, - F_UNLCK,F_SETLKW, 0, 1); - } - tdb->num_locks = 0; - tdb->num_lockrecs = 0; - SAFE_FREE(tdb->lockrecs); - } - - /* restore the normal io methods */ - tdb->methods = tdb->transaction->io_methods; - - tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0); - tdb_transaction_unlock(tdb); - SAFE_FREE(tdb->transaction->hash_heads); - SAFE_FREE(tdb->transaction); - - return 0; -} - -/* - sync to disk -*/ -static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t length) -{ - if (fsync(tdb->fd) != 0) { - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n")); - return -1; - } -#ifdef HAVE_MMAP - if (tdb->map_ptr) { - tdb_off_t moffset = offset & ~(tdb->page_size-1); - if (msync(moffset + (char *)tdb->map_ptr, - length + (offset - moffset), MS_SYNC) != 0) { - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: msync failed - %s\n", - strerror(errno))); - return -1; - } - } -#endif - return 0; -} - - -/* - work out how much space the linearised recovery data will consume -*/ -static tdb_len_t tdb_recovery_size(struct tdb_context *tdb) -{ - tdb_len_t recovery_size = 0; - int i; - - recovery_size = sizeof(uint32_t); - for (i=0;itransaction->num_blocks;i++) { - if (i * tdb->transaction->block_size >= tdb->transaction->old_map_size) { - break; - } - if (tdb->transaction->blocks[i] == NULL) { - continue; - } - recovery_size += 2*sizeof(tdb_off_t); - if (i == tdb->transaction->num_blocks-1) { - recovery_size += tdb->transaction->last_block_size; - } else { - recovery_size += tdb->transaction->block_size; - } - } - - return recovery_size; -} - -/* - allocate the recovery area, or use an existing recovery area if it is - large enough -*/ -static int tdb_recovery_allocate(struct tdb_context *tdb, - tdb_len_t *recovery_size, - tdb_off_t *recovery_offset, - tdb_len_t *recovery_max_size) -{ - struct list_struct rec; - const struct tdb_methods *methods = tdb->transaction->io_methods; - tdb_off_t recovery_head; - - if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to read recovery head\n")); - return -1; - } - - rec.rec_len = 0; - - if (recovery_head != 0 && - methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to read recovery record\n")); - return -1; - } - - *recovery_size = tdb_recovery_size(tdb); - - if (recovery_head != 0 && *recovery_size <= rec.rec_len) { - /* it fits in the existing area */ - *recovery_max_size = rec.rec_len; - *recovery_offset = recovery_head; - return 0; - } - - /* we need to free up the old recovery area, then allocate a - new one at the end of the file. Note that we cannot use - tdb_allocate() to allocate the new one as that might return - us an area that is being currently used (as of the start of - the transaction) */ - if (recovery_head != 0) { - if (tdb_free(tdb, recovery_head, &rec) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to free previous recovery area\n")); - return -1; - } - } - - /* the tdb_free() call might have increased the recovery size */ - *recovery_size = tdb_recovery_size(tdb); - - /* round up to a multiple of page size */ - *recovery_max_size = TDB_ALIGN(sizeof(rec) + *recovery_size, tdb->page_size) - sizeof(rec); - *recovery_offset = tdb->map_size; - recovery_head = *recovery_offset; - - if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, - (tdb->map_size - tdb->transaction->old_map_size) + - sizeof(rec) + *recovery_max_size) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to create recovery area\n")); - return -1; - } - - /* remap the file (if using mmap) */ - methods->tdb_oob(tdb, tdb->map_size + 1, 1); - - /* we have to reset the old map size so that we don't try to expand the file - again in the transaction commit, which would destroy the recovery area */ - tdb->transaction->old_map_size = tdb->map_size; - - /* write the recovery header offset and sync - we can sync without a race here - as the magic ptr in the recovery record has not been set */ - CONVERT(recovery_head); - if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD, - &recovery_head, sizeof(tdb_off_t)) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n")); - return -1; - } - if (transaction_write_existing(tdb, TDB_RECOVERY_HEAD, &recovery_head, sizeof(tdb_off_t)) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n")); - return -1; - } - - return 0; -} - - -/* - setup the recovery data that will be used on a crash during commit -*/ -static int transaction_setup_recovery(struct tdb_context *tdb, - tdb_off_t *magic_offset) -{ - tdb_len_t recovery_size; - unsigned char *data, *p; - const struct tdb_methods *methods = tdb->transaction->io_methods; - struct list_struct *rec; - tdb_off_t recovery_offset, recovery_max_size; - tdb_off_t old_map_size = tdb->transaction->old_map_size; - uint32_t magic, tailer; - int i; - - /* - check that the recovery area has enough space - */ - if (tdb_recovery_allocate(tdb, &recovery_size, - &recovery_offset, &recovery_max_size) == -1) { - return -1; - } - - data = (unsigned char *)malloc(recovery_size + sizeof(*rec)); - if (data == NULL) { - tdb->ecode = TDB_ERR_OOM; - return -1; - } - - rec = (struct list_struct *)data; - memset(rec, 0, sizeof(*rec)); - - rec->magic = 0; - rec->data_len = recovery_size; - rec->rec_len = recovery_max_size; - rec->key_len = old_map_size; - CONVERT(rec); - - /* build the recovery data into a single blob to allow us to do a single - large write, which should be more efficient */ - p = data + sizeof(*rec); - for (i=0;itransaction->num_blocks;i++) { - tdb_off_t offset; - tdb_len_t length; - - if (tdb->transaction->blocks[i] == NULL) { - continue; - } - - offset = i * tdb->transaction->block_size; - length = tdb->transaction->block_size; - if (i == tdb->transaction->num_blocks-1) { - length = tdb->transaction->last_block_size; - } - - if (offset >= old_map_size) { - continue; - } - if (offset + length > tdb->transaction->old_map_size) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: transaction data over new region boundary\n")); - free(data); - tdb->ecode = TDB_ERR_CORRUPT; - return -1; - } - memcpy(p, &offset, 4); - memcpy(p+4, &length, 4); - if (DOCONV()) { - tdb_convert(p, 8); - } - /* the recovery area contains the old data, not the - new data, so we have to call the original tdb_read - method to get it */ - if (methods->tdb_read(tdb, offset, p + 8, length, 0) != 0) { - free(data); - tdb->ecode = TDB_ERR_IO; - return -1; - } - p += 8 + length; - } - - /* and the tailer */ - tailer = sizeof(*rec) + recovery_max_size; - memcpy(p, &tailer, 4); - CONVERT(p); - - /* write the recovery data to the recovery area */ - if (methods->tdb_write(tdb, recovery_offset, data, sizeof(*rec) + recovery_size) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write recovery data\n")); - free(data); - tdb->ecode = TDB_ERR_IO; - return -1; - } - if (transaction_write_existing(tdb, recovery_offset, data, sizeof(*rec) + recovery_size) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write secondary recovery data\n")); - free(data); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - /* as we don't have ordered writes, we have to sync the recovery - data before we update the magic to indicate that the recovery - data is present */ - if (transaction_sync(tdb, recovery_offset, sizeof(*rec) + recovery_size) == -1) { - free(data); - return -1; - } - - free(data); - - magic = TDB_RECOVERY_MAGIC; - CONVERT(magic); - - *magic_offset = recovery_offset + offsetof(struct list_struct, magic); - - if (methods->tdb_write(tdb, *magic_offset, &magic, sizeof(magic)) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write recovery magic\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - if (transaction_write_existing(tdb, *magic_offset, &magic, sizeof(magic)) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_setup_recovery: failed to write secondary recovery magic\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - /* ensure the recovery magic marker is on disk */ - if (transaction_sync(tdb, *magic_offset, sizeof(magic)) == -1) { - return -1; - } - - return 0; -} - -/* - commit the current transaction -*/ -int tdb_transaction_commit(struct tdb_context *tdb) -{ - const struct tdb_methods *methods; - tdb_off_t magic_offset = 0; - uint32_t zero = 0; - int i; - - if (tdb->transaction == NULL) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: no transaction\n")); - return -1; - } - - if (tdb->transaction->transaction_error) { - tdb->ecode = TDB_ERR_IO; - tdb_transaction_cancel(tdb); - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: transaction error pending\n")); - return -1; - } - - - if (tdb->transaction->nesting != 0) { - tdb->transaction->nesting--; - return 0; - } - - /* check for a null transaction */ - if (tdb->transaction->blocks == NULL) { - tdb_transaction_cancel(tdb); - return 0; - } - - methods = tdb->transaction->io_methods; - - /* if there are any locks pending then the caller has not - nested their locks properly, so fail the transaction */ - if (tdb->num_locks || tdb->global_lock.count) { - tdb->ecode = TDB_ERR_LOCK; - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: locks pending on commit\n")); - tdb_transaction_cancel(tdb); - return -1; - } - - /* upgrade the main transaction lock region to a write lock */ - if (tdb_brlock_upgrade(tdb, FREELIST_TOP, 0) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_start: failed to upgrade hash locks\n")); - tdb->ecode = TDB_ERR_LOCK; - tdb_transaction_cancel(tdb); - return -1; - } - - /* get the global lock - this prevents new users attaching to the database - during the commit */ - if (tdb_brlock(tdb, GLOBAL_LOCK, F_WRLCK, F_SETLKW, 0, 1) == -1) { - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: failed to get global lock\n")); - tdb->ecode = TDB_ERR_LOCK; - tdb_transaction_cancel(tdb); - return -1; - } - - if (!(tdb->flags & TDB_NOSYNC)) { - /* write the recovery data to the end of the file */ - if (transaction_setup_recovery(tdb, &magic_offset) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: failed to setup recovery data\n")); - tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); - tdb_transaction_cancel(tdb); - return -1; - } - } - - /* expand the file to the new size if needed */ - if (tdb->map_size != tdb->transaction->old_map_size) { - if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, - tdb->map_size - - tdb->transaction->old_map_size) == -1) { - tdb->ecode = TDB_ERR_IO; - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: expansion failed\n")); - tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); - tdb_transaction_cancel(tdb); - return -1; - } - tdb->map_size = tdb->transaction->old_map_size; - methods->tdb_oob(tdb, tdb->map_size + 1, 1); - } - - /* perform all the writes */ - for (i=0;itransaction->num_blocks;i++) { - tdb_off_t offset; - tdb_len_t length; - - if (tdb->transaction->blocks[i] == NULL) { - continue; - } - - offset = i * tdb->transaction->block_size; - length = tdb->transaction->block_size; - if (i == tdb->transaction->num_blocks-1) { - length = tdb->transaction->last_block_size; - } - - if (methods->tdb_write(tdb, offset, tdb->transaction->blocks[i], length) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed during commit\n")); - - /* we've overwritten part of the data and - possibly expanded the file, so we need to - run the crash recovery code */ - tdb->methods = methods; - tdb_transaction_recover(tdb); - - tdb_transaction_cancel(tdb); - tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); - - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed\n")); - return -1; - } - SAFE_FREE(tdb->transaction->blocks[i]); - } - - SAFE_FREE(tdb->transaction->blocks); - tdb->transaction->num_blocks = 0; - - if (!(tdb->flags & TDB_NOSYNC)) { - /* ensure the new data is on disk */ - if (transaction_sync(tdb, 0, tdb->map_size) == -1) { - return -1; - } - - /* remove the recovery marker */ - if (methods->tdb_write(tdb, magic_offset, &zero, 4) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: failed to remove recovery magic\n")); - return -1; - } - - /* ensure the recovery marker has been removed on disk */ - if (transaction_sync(tdb, magic_offset, 4) == -1) { - return -1; - } - } - - tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); - - /* - TODO: maybe write to some dummy hdr field, or write to magic - offset without mmap, before the last sync, instead of the - utime() call - */ - - /* on some systems (like Linux 2.6.x) changes via mmap/msync - don't change the mtime of the file, this means the file may - not be backed up (as tdb rounding to block sizes means that - file size changes are quite rare too). The following forces - mtime changes when a transaction completes */ -#ifdef HAVE_UTIME - utime(tdb->name, NULL); -#endif - - /* use a transaction cancel to free memory and remove the - transaction locks */ - tdb_transaction_cancel(tdb); - - return 0; -} - - -/* - recover from an aborted transaction. Must be called with exclusive - database write access already established (including the global - lock to prevent new processes attaching) -*/ -int tdb_transaction_recover(struct tdb_context *tdb) -{ - tdb_off_t recovery_head, recovery_eof; - unsigned char *data, *p; - uint32_t zero = 0; - struct list_struct rec; - - /* find the recovery area */ - if (tdb_ofs_read(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery head\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - if (recovery_head == 0) { - /* we have never allocated a recovery record */ - return 0; - } - - /* read the recovery record */ - if (tdb->methods->tdb_read(tdb, recovery_head, &rec, - sizeof(rec), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - if (rec.magic != TDB_RECOVERY_MAGIC) { - /* there is no valid recovery data */ - return 0; - } - - if (tdb->read_only) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: attempt to recover read only database\n")); - tdb->ecode = TDB_ERR_CORRUPT; - return -1; - } - - recovery_eof = rec.key_len; - - data = (unsigned char *)malloc(rec.data_len); - if (data == NULL) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n")); - tdb->ecode = TDB_ERR_OOM; - return -1; - } - - /* read the full recovery data */ - if (tdb->methods->tdb_read(tdb, recovery_head + sizeof(rec), data, - rec.data_len, 0) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - /* recover the file data */ - p = data; - while (p+8 < data + rec.data_len) { - uint32_t ofs, len; - if (DOCONV()) { - tdb_convert(p, 8); - } - memcpy(&ofs, p, 4); - memcpy(&len, p+4, 4); - - if (tdb->methods->tdb_write(tdb, ofs, p+8, len) == -1) { - free(data); - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to recover %d bytes at offset %d\n", len, ofs)); - tdb->ecode = TDB_ERR_IO; - return -1; - } - p += 8 + len; - } - - free(data); - - if (transaction_sync(tdb, 0, tdb->map_size) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to sync recovery\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - /* if the recovery area is after the recovered eof then remove it */ - if (recovery_eof <= recovery_head) { - if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &zero) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery head\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - } - - /* remove the recovery magic */ - if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic), - &zero) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery magic\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - /* reduce the file size to the old size */ - tdb_munmap(tdb); - if (ftruncate(tdb->fd, recovery_eof) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to reduce to recovery size\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - tdb->map_size = recovery_eof; - tdb_mmap(tdb); - - if (transaction_sync(tdb, 0, recovery_eof) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to sync2 recovery\n")); - tdb->ecode = TDB_ERR_IO; - return -1; - } - - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n", - recovery_eof)); - - /* all done */ - return 0; -} diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c deleted file mode 100644 index 69c81e6e98..0000000000 --- a/source4/lib/tdb/common/traverse.c +++ /dev/null @@ -1,348 +0,0 @@ - /* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2005 - Copyright (C) Paul `Rusty' Russell 2000 - Copyright (C) Jeremy Allison 2000-2003 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#include "tdb_private.h" - -/* Uses traverse lock: 0 = finish, -1 = error, other = record offset */ -static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tlock, - struct list_struct *rec) -{ - int want_next = (tlock->off != 0); - - /* Lock each chain from the start one. */ - for (; tlock->hash < tdb->header.hash_size; tlock->hash++) { - if (!tlock->off && tlock->hash != 0) { - /* this is an optimisation for the common case where - the hash chain is empty, which is particularly - common for the use of tdb with ldb, where large - hashes are used. In that case we spend most of our - time in tdb_brlock(), locking empty hash chains. - - To avoid this, we do an unlocked pre-check to see - if the hash chain is empty before starting to look - inside it. If it is empty then we can avoid that - hash chain. If it isn't empty then we can't believe - the value we get back, as we read it without a - lock, so instead we get the lock and re-fetch the - value below. - - Notice that not doing this optimisation on the - first hash chain is critical. We must guarantee - that we have done at least one fcntl lock at the - start of a search to guarantee that memory is - coherent on SMP systems. If records are added by - others during the search then thats OK, and we - could possibly miss those with this trick, but we - could miss them anyway without this trick, so the - semantics don't change. - - With a non-indexed ldb search this trick gains us a - factor of around 80 in speed on a linux 2.6.x - system (testing using ldbtest). - */ - tdb->methods->next_hash_chain(tdb, &tlock->hash); - if (tlock->hash == tdb->header.hash_size) { - continue; - } - } - - if (tdb_lock(tdb, tlock->hash, tlock->lock_rw) == -1) - return -1; - - /* No previous record? Start at top of chain. */ - if (!tlock->off) { - if (tdb_ofs_read(tdb, TDB_HASH_TOP(tlock->hash), - &tlock->off) == -1) - goto fail; - } else { - /* Otherwise unlock the previous record. */ - if (tdb_unlock_record(tdb, tlock->off) != 0) - goto fail; - } - - if (want_next) { - /* We have offset of old record: grab next */ - if (tdb_rec_read(tdb, tlock->off, rec) == -1) - goto fail; - tlock->off = rec->next; - } - - /* Iterate through chain */ - while( tlock->off) { - tdb_off_t current; - if (tdb_rec_read(tdb, tlock->off, rec) == -1) - goto fail; - - /* Detect infinite loops. From "Shlomi Yaakobovich" . */ - if (tlock->off == rec->next) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_next_lock: loop detected.\n")); - goto fail; - } - - if (!TDB_DEAD(rec)) { - /* Woohoo: we found one! */ - if (tdb_lock_record(tdb, tlock->off) != 0) - goto fail; - return tlock->off; - } - - /* Try to clean dead ones from old traverses */ - current = tlock->off; - tlock->off = rec->next; - if (!(tdb->read_only || tdb->traverse_read) && - tdb_do_delete(tdb, current, rec) != 0) - goto fail; - } - tdb_unlock(tdb, tlock->hash, tlock->lock_rw); - want_next = 0; - } - /* We finished iteration without finding anything */ - return TDB_ERRCODE(TDB_SUCCESS, 0); - - fail: - tlock->off = 0; - if (tdb_unlock(tdb, tlock->hash, tlock->lock_rw) != 0) - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_next_lock: On error unlock failed!\n")); - return -1; -} - -/* traverse the entire database - calling fn(tdb, key, data) on each element. - return -1 on error or the record count traversed - if fn is NULL then it is not called - a non-zero return value from fn() indicates that the traversal should stop - */ -static int tdb_traverse_internal(struct tdb_context *tdb, - tdb_traverse_func fn, void *private_data, - struct tdb_traverse_lock *tl) -{ - TDB_DATA key, dbuf; - struct list_struct rec; - int ret, count = 0; - - /* This was in the initializaton, above, but the IRIX compiler - * did not like it. crh - */ - tl->next = tdb->travlocks.next; - - /* fcntl locks don't stack: beware traverse inside traverse */ - tdb->travlocks.next = tl; - - /* tdb_next_lock places locks on the record returned, and its chain */ - while ((ret = tdb_next_lock(tdb, tl, &rec)) > 0) { - count++; - /* now read the full record */ - key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec), - rec.key_len + rec.data_len); - if (!key.dptr) { - ret = -1; - if (tdb_unlock(tdb, tl->hash, tl->lock_rw) != 0) - goto out; - if (tdb_unlock_record(tdb, tl->off) != 0) - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_traverse: key.dptr == NULL and unlock_record failed!\n")); - goto out; - } - key.dsize = rec.key_len; - dbuf.dptr = key.dptr + rec.key_len; - dbuf.dsize = rec.data_len; - - /* Drop chain lock, call out */ - if (tdb_unlock(tdb, tl->hash, tl->lock_rw) != 0) { - ret = -1; - SAFE_FREE(key.dptr); - goto out; - } - if (fn && fn(tdb, key, dbuf, private_data)) { - /* They want us to terminate traversal */ - ret = count; - if (tdb_unlock_record(tdb, tl->off) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_traverse: unlock_record failed!\n"));; - ret = -1; - } - SAFE_FREE(key.dptr); - goto out; - } - SAFE_FREE(key.dptr); - } -out: - tdb->travlocks.next = tl->next; - if (ret < 0) - return -1; - else - return count; -} - - -/* - a write style traverse - temporarily marks the db read only -*/ -int tdb_traverse_read(struct tdb_context *tdb, - tdb_traverse_func fn, void *private_data) -{ - struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK }; - int ret; - bool in_transaction = (tdb->transaction != NULL); - - /* we need to get a read lock on the transaction lock here to - cope with the lock ordering semantics of solaris10 */ - if (!in_transaction) { - if (tdb_transaction_lock(tdb, F_RDLCK)) { - return -1; - } - } - - tdb->traverse_read++; - ret = tdb_traverse_internal(tdb, fn, private_data, &tl); - tdb->traverse_read--; - - if (!in_transaction) { - tdb_transaction_unlock(tdb); - } - - return ret; -} - -/* - a write style traverse - needs to get the transaction lock to - prevent deadlocks - - WARNING: The data buffer given to the callback fn does NOT meet the - alignment restrictions malloc gives you. -*/ -int tdb_traverse(struct tdb_context *tdb, - tdb_traverse_func fn, void *private_data) -{ - struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; - int ret; - bool in_transaction = (tdb->transaction != NULL); - - if (tdb->read_only || tdb->traverse_read) { - return tdb_traverse_read(tdb, fn, private_data); - } - - if (!in_transaction) { - if (tdb_transaction_lock(tdb, F_WRLCK)) { - return -1; - } - } - - tdb->traverse_write++; - ret = tdb_traverse_internal(tdb, fn, private_data, &tl); - tdb->traverse_write--; - - if (!in_transaction) { - tdb_transaction_unlock(tdb); - } - - return ret; -} - - -/* find the first entry in the database and return its key */ -TDB_DATA tdb_firstkey(struct tdb_context *tdb) -{ - TDB_DATA key; - struct list_struct rec; - - /* release any old lock */ - if (tdb_unlock_record(tdb, tdb->travlocks.off) != 0) - return tdb_null; - tdb->travlocks.off = tdb->travlocks.hash = 0; - tdb->travlocks.lock_rw = F_RDLCK; - - /* Grab first record: locks chain and returned record. */ - if (tdb_next_lock(tdb, &tdb->travlocks, &rec) <= 0) - return tdb_null; - /* now read the key */ - key.dsize = rec.key_len; - key.dptr =tdb_alloc_read(tdb,tdb->travlocks.off+sizeof(rec),key.dsize); - - /* Unlock the hash chain of the record we just read. */ - if (tdb_unlock(tdb, tdb->travlocks.hash, tdb->travlocks.lock_rw) != 0) - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_firstkey: error occurred while tdb_unlocking!\n")); - return key; -} - -/* find the next entry in the database, returning its key */ -TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA oldkey) -{ - uint32_t oldhash; - TDB_DATA key = tdb_null; - struct list_struct rec; - unsigned char *k = NULL; - - /* Is locked key the old key? If so, traverse will be reliable. */ - if (tdb->travlocks.off) { - if (tdb_lock(tdb,tdb->travlocks.hash,tdb->travlocks.lock_rw)) - return tdb_null; - if (tdb_rec_read(tdb, tdb->travlocks.off, &rec) == -1 - || !(k = tdb_alloc_read(tdb,tdb->travlocks.off+sizeof(rec), - rec.key_len)) - || memcmp(k, oldkey.dptr, oldkey.dsize) != 0) { - /* No, it wasn't: unlock it and start from scratch */ - if (tdb_unlock_record(tdb, tdb->travlocks.off) != 0) { - SAFE_FREE(k); - return tdb_null; - } - if (tdb_unlock(tdb, tdb->travlocks.hash, tdb->travlocks.lock_rw) != 0) { - SAFE_FREE(k); - return tdb_null; - } - tdb->travlocks.off = 0; - } - - SAFE_FREE(k); - } - - if (!tdb->travlocks.off) { - /* No previous element: do normal find, and lock record */ - tdb->travlocks.off = tdb_find_lock_hash(tdb, oldkey, tdb->hash_fn(&oldkey), tdb->travlocks.lock_rw, &rec); - if (!tdb->travlocks.off) - return tdb_null; - tdb->travlocks.hash = BUCKET(rec.full_hash); - if (tdb_lock_record(tdb, tdb->travlocks.off) != 0) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: lock_record failed (%s)!\n", strerror(errno))); - return tdb_null; - } - } - oldhash = tdb->travlocks.hash; - - /* Grab next record: locks chain and returned record, - unlocks old record */ - if (tdb_next_lock(tdb, &tdb->travlocks, &rec) > 0) { - key.dsize = rec.key_len; - key.dptr = tdb_alloc_read(tdb, tdb->travlocks.off+sizeof(rec), - key.dsize); - /* Unlock the chain of this new record */ - if (tdb_unlock(tdb, tdb->travlocks.hash, tdb->travlocks.lock_rw) != 0) - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: WARNING tdb_unlock failed!\n")); - } - /* Unlock the chain of old record */ - if (tdb_unlock(tdb, BUCKET(oldhash), tdb->travlocks.lock_rw) != 0) - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_nextkey: WARNING tdb_unlock failed!\n")); - return key; -} - diff --git a/source4/lib/tdb/config.guess b/source4/lib/tdb/config.guess deleted file mode 100755 index 354dbe175a..0000000000 --- a/source4/lib/tdb/config.guess +++ /dev/null @@ -1,1464 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-08-03' - -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/tdb/config.sub b/source4/lib/tdb/config.sub deleted file mode 100755 index 23cd6fd75c..0000000000 --- a/source4/lib/tdb/config.sub +++ /dev/null @@ -1,1577 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - -timestamp='2005-07-08' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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 . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | ms1 \ - | msp430 \ - | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m32c) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | ms1-* \ - | msp430-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - m32c-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac deleted file mode 100644 index eaf70d30b4..0000000000 --- a/source4/lib/tdb/configure.ac +++ /dev/null @@ -1,30 +0,0 @@ -AC_PREREQ(2.50) -AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) -AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) -AC_DEFUN([SMB_ENABLE], [echo -n ""]) -AC_INIT(tdb, 1.1.2) -AC_CONFIG_SRCDIR([common/tdb.c]) -AC_CONFIG_HEADER(include/config.h) -AC_LIBREPLACE_ALL_CHECKS -AC_LD_SONAMEFLAG -AC_LD_PICFLAG -AC_LD_SHLIBEXT -AC_LIBREPLACE_SHLD -AC_LIBREPLACE_SHLD_FLAGS -AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR -m4_include(libtdb.m4) -AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) -AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python]) - -PYTHON_BUILD_TARGET="build-python" -PYTHON_INSTALL_TARGET="install-python" -PYTHON_CHECK_TARGET="check-python" -AC_SUBST(PYTHON_BUILD_TARGET) -AC_SUBST(PYTHON_INSTALL_TARGET) -AC_SUBST(PYTHON_CHECK_TARGET) -if test -z "$PYTHON_CONFIG"; then - PYTHON_BUILD_TARGET="" - PYTHON_INSTALL_TARGET="" - PYTHON_CHECK_TARGET="" -fi -AC_OUTPUT(Makefile tdb.pc) diff --git a/source4/lib/tdb/docs/README b/source4/lib/tdb/docs/README deleted file mode 100644 index 63fcf5e049..0000000000 --- a/source4/lib/tdb/docs/README +++ /dev/null @@ -1,238 +0,0 @@ -tdb - a trivial database system -tridge@linuxcare.com December 1999 -================================== - -This is a simple database API. It was inspired by the realisation that -in Samba we have several ad-hoc bits of code that essentially -implement small databases for sharing structures between parts of -Samba. As I was about to add another I realised that a generic -database module was called for to replace all the ad-hoc bits. - -I based the interface on gdbm. I couldn't use gdbm as we need to be -able to have multiple writers to the databases at one time. - -Compilation ------------ - -add HAVE_MMAP=1 to use mmap instead of read/write -add NOLOCK=1 to disable locking code - -Testing -------- - -Compile tdbtest.c and link with gdbm for testing. tdbtest will perform -identical operations via tdb and gdbm then make sure the result is the -same - -Also included is tdbtool, which allows simple database manipulation -on the commandline. - -tdbtest and tdbtool are not built as part of Samba, but are included -for completeness. - -Interface ---------- - -The interface is very similar to gdbm except for the following: - -- different open interface. The tdb_open call is more similar to a - traditional open() -- no tdbm_reorganise() function -- no tdbm_sync() function. No operations are cached in the library anyway -- added a tdb_traverse() function for traversing the whole database -- added transactions support - -A general rule for using tdb is that the caller frees any returned -TDB_DATA structures. Just call free(p.dptr) to free a TDB_DATA -return value called p. This is the same as gdbm. - -here is a full list of tdb functions with brief descriptions. - - ----------------------------------------------------------------------- -TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode) - - open the database, creating it if necessary - - The open_flags and mode are passed straight to the open call on the database - file. A flags value of O_WRONLY is invalid - - The hash size is advisory, use zero for a default value. - - return is NULL on error - - possible tdb_flags are: - TDB_CLEAR_IF_FIRST - clear database if we are the only one with it open - TDB_INTERNAL - don't use a file, instaed store the data in - memory. The filename is ignored in this case. - TDB_NOLOCK - don't do any locking - TDB_NOMMAP - don't use mmap - TDB_NOSYNC - don't synchronise transactions to disk - ----------------------------------------------------------------------- -TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode, - tdb_log_func log_fn, - tdb_hash_func hash_fn) - -This is like tdb_open(), but allows you to pass an initial logging and -hash function. Be careful when passing a hash function - all users of -the database must use the same hash function or you will get data -corruption. - - ----------------------------------------------------------------------- -char *tdb_error(TDB_CONTEXT *tdb); - - return a error string for the last tdb error - ----------------------------------------------------------------------- -int tdb_close(TDB_CONTEXT *tdb); - - close a database - ----------------------------------------------------------------------- -int tdb_update(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf); - - update an entry in place - this only works if the new data size - is <= the old data size and the key exists. - on failure return -1 - ----------------------------------------------------------------------- -TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); - - fetch an entry in the database given a key - if the return value has a null dptr then a error occurred - - caller must free the resulting data - ----------------------------------------------------------------------- -int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); - - check if an entry in the database exists - - note that 1 is returned if the key is found and 0 is returned if not found - this doesn't match the conventions in the rest of this module, but is - compatible with gdbm - ----------------------------------------------------------------------- -int tdb_traverse(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb, - TDB_DATA key, TDB_DATA dbuf, void *state), void *state); - - traverse the entire database - calling fn(tdb, key, data, state) on each - element. - - return -1 on error or the record count traversed - - if fn is NULL then it is not called - - a non-zero return value from fn() indicates that the traversal - should stop. Traversal callbacks may not start transactions. - - WARNING: The data buffer given to the callback fn does NOT meet the - alignment restrictions malloc gives you. - ----------------------------------------------------------------------- -int tdb_traverse_read(TDB_CONTEXT *tdb, int (*fn)(TDB_CONTEXT *tdb, - TDB_DATA key, TDB_DATA dbuf, void *state), void *state); - - traverse the entire database - calling fn(tdb, key, data, state) on - each element, but marking the database read only during the - traversal, so any write operations will fail. This allows tdb to - use read locks, which increases the parallelism possible during the - traversal. - - return -1 on error or the record count traversed - - if fn is NULL then it is not called - - a non-zero return value from fn() indicates that the traversal - should stop. Traversal callbacks may not start transactions. - ----------------------------------------------------------------------- -TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); - - find the first entry in the database and return its key - - the caller must free the returned data - ----------------------------------------------------------------------- -TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); - - find the next entry in the database, returning its key - - the caller must free the returned data - ----------------------------------------------------------------------- -int tdb_delete(TDB_CONTEXT *tdb, TDB_DATA key); - - delete an entry in the database given a key - ----------------------------------------------------------------------- -int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); - - store an element in the database, replacing any existing element - with the same key - - If flag==TDB_INSERT then don't overwrite an existing entry - If flag==TDB_MODIFY then don't create a new entry - - return 0 on success, -1 on failure - ----------------------------------------------------------------------- -int tdb_writelock(TDB_CONTEXT *tdb); - - lock the database. If we already have it locked then don't do anything - ----------------------------------------------------------------------- -int tdb_writeunlock(TDB_CONTEXT *tdb); - unlock the database - ----------------------------------------------------------------------- -int tdb_lockchain(TDB_CONTEXT *tdb, TDB_DATA key); - - lock one hash chain. This is meant to be used to reduce locking - contention - it cannot guarantee how many records will be locked - ----------------------------------------------------------------------- -int tdb_unlockchain(TDB_CONTEXT *tdb, TDB_DATA key); - - unlock one hash chain - ----------------------------------------------------------------------- -int tdb_transaction_start(TDB_CONTEXT *tdb) - - start a transaction. All operations after the transaction start can - either be committed with tdb_transaction_commit() or cancelled with - tdb_transaction_cancel(). - - If you call tdb_transaction_start() again on the same tdb context - while a transaction is in progress, then the same transaction - buffer is re-used. The number of tdb_transaction_{commit,cancel} - operations must match the number of successful - tdb_transaction_start() calls. - - Note that transactions are by default disk synchronous, and use a - recover area in the database to automatically recover the database - on the next open if the system crashes during a transaction. You - can disable the synchronous transaction recovery setup using the - TDB_NOSYNC flag, which will greatly speed up operations at the risk - of corrupting your database if the system crashes. - - Operations made within a transaction are not visible to other users - of the database until a successful commit. - ----------------------------------------------------------------------- -int tdb_transaction_cancel(TDB_CONTEXT *tdb) - - cancel a current transaction, discarding all write and lock - operations that have been made since the transaction started. - - ----------------------------------------------------------------------- -int tdb_transaction_commit(TDB_CONTEXT *tdb) - - commit a current transaction, updating the database and releasing - the transaction locks. - diff --git a/source4/lib/tdb/docs/tdb.magic b/source4/lib/tdb/docs/tdb.magic deleted file mode 100644 index f5619e7327..0000000000 --- a/source4/lib/tdb/docs/tdb.magic +++ /dev/null @@ -1,10 +0,0 @@ -# Magic file(1) information about tdb files. -# -# Install this into /etc/magic or the corresponding location for your -# system, or pass as a -m argument to file(1). - -# You may use and redistribute this file without restriction. - -0 string TDB\ file TDB database ->32 lelong =0x2601196D version 6, little-endian ->>36 lelong x hash size %d bytes diff --git a/source4/lib/tdb/include/tdb.h b/source4/lib/tdb/include/tdb.h deleted file mode 100644 index 0008085de5..0000000000 --- a/source4/lib/tdb/include/tdb.h +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef __TDB_H__ -#define __TDB_H__ - -/* - Unix SMB/CIFS implementation. - - trivial database library - - Copyright (C) Andrew Tridgell 1999-2004 - - ** NOTE! The following LGPL license applies to the tdb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . -*/ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* flags to tdb_store() */ -#define TDB_REPLACE 1 /* Unused */ -#define TDB_INSERT 2 /* Don't overwrite an existing entry */ -#define TDB_MODIFY 3 /* Don't create an existing entry */ - -/* flags for tdb_open() */ -#define TDB_DEFAULT 0 /* just a readability place holder */ -#define TDB_CLEAR_IF_FIRST 1 -#define TDB_INTERNAL 2 /* don't store on disk */ -#define TDB_NOLOCK 4 /* don't do any locking */ -#define TDB_NOMMAP 8 /* don't use mmap */ -#define TDB_CONVERT 16 /* convert endian (internal use) */ -#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */ -#define TDB_NOSYNC 64 /* don't use synchronous transactions */ -#define TDB_SEQNUM 128 /* maintain a sequence number */ -#define TDB_VOLATILE 256 /* Activate the per-hashchain freelist, default 5 */ - -#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) - -/* error codes */ -enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, - TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, - TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY}; - -/* debugging uses one of the following levels */ -enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, - TDB_DEBUG_WARNING, TDB_DEBUG_TRACE}; - -typedef struct TDB_DATA { - unsigned char *dptr; - size_t dsize; -} TDB_DATA; - -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - -/* this is the context structure that is returned from a db open */ -typedef struct tdb_context TDB_CONTEXT; - -typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *); -typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4); -typedef unsigned int (*tdb_hash_func)(TDB_DATA *key); - -struct tdb_logging_context { - tdb_log_func log_fn; - void *log_private; -}; - -struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode); -struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode, - const struct tdb_logging_context *log_ctx, - tdb_hash_func hash_fn); -void tdb_set_max_dead(struct tdb_context *tdb, int max_dead); - -int tdb_reopen(struct tdb_context *tdb); -int tdb_reopen_all(int parent_longlived); -void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx); -enum TDB_ERROR tdb_error(struct tdb_context *tdb); -const char *tdb_errorstr(struct tdb_context *tdb); -TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key); -int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, - int (*parser)(TDB_DATA key, TDB_DATA data, - void *private_data), - void *private_data); -int tdb_delete(struct tdb_context *tdb, TDB_DATA key); -int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); -int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf); -int tdb_close(struct tdb_context *tdb); -TDB_DATA tdb_firstkey(struct tdb_context *tdb); -TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key); -int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *); -int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *); -int tdb_exists(struct tdb_context *tdb, TDB_DATA key); -int tdb_lockall(struct tdb_context *tdb); -int tdb_lockall_nonblock(struct tdb_context *tdb); -int tdb_unlockall(struct tdb_context *tdb); -int tdb_lockall_read(struct tdb_context *tdb); -int tdb_lockall_read_nonblock(struct tdb_context *tdb); -int tdb_unlockall_read(struct tdb_context *tdb); -int tdb_lockall_mark(struct tdb_context *tdb); -int tdb_lockall_unmark(struct tdb_context *tdb); -const char *tdb_name(struct tdb_context *tdb); -int tdb_fd(struct tdb_context *tdb); -tdb_log_func tdb_log_fn(struct tdb_context *tdb); -void *tdb_get_logging_private(struct tdb_context *tdb); -int tdb_transaction_start(struct tdb_context *tdb); -int tdb_transaction_commit(struct tdb_context *tdb); -int tdb_transaction_cancel(struct tdb_context *tdb); -int tdb_transaction_recover(struct tdb_context *tdb); -int tdb_get_seqnum(struct tdb_context *tdb); -int tdb_hash_size(struct tdb_context *tdb); -size_t tdb_map_size(struct tdb_context *tdb); -int tdb_get_flags(struct tdb_context *tdb); -void tdb_add_flags(struct tdb_context *tdb, unsigned flag); -void tdb_remove_flags(struct tdb_context *tdb, unsigned flag); -void tdb_enable_seqnum(struct tdb_context *tdb); -void tdb_increment_seqnum_nonblock(struct tdb_context *tdb); - -/* Low level locking functions: use with care */ -int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); -int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key); -int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key); -int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key); -int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); -int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key); -int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key); - -void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr); - -/* Debug functions. Not used in production. */ -void tdb_dump_all(struct tdb_context *tdb); -int tdb_printfreelist(struct tdb_context *tdb); -int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries); -int tdb_wipe_all(struct tdb_context *tdb); -int tdb_freelist_size(struct tdb_context *tdb); - -extern TDB_DATA tdb_null; - -#ifdef __cplusplus -} -#endif - -#endif /* tdb.h */ diff --git a/source4/lib/tdb/install-sh b/source4/lib/tdb/install-sh deleted file mode 100755 index 58719246f0..0000000000 --- a/source4/lib/tdb/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/source4/lib/tdb/python.mk b/source4/lib/tdb/python.mk deleted file mode 100644 index 12e8217df9..0000000000 --- a/source4/lib/tdb/python.mk +++ /dev/null @@ -1,10 +0,0 @@ -[PYTHON::swig_tdb] -LIBRARY_REALNAME = _tdb.$(SHLIBEXT) -PUBLIC_DEPENDENCIES = LIBTDB DYNCONFIG - -swig_tdb_OBJ_FILES = $(tdbsrcdir)/tdb_wrap.o - -$(eval $(call python_py_module_template,tdb.py,$(tdbsrcdir)/tdb.py)) - -$(swig_tdb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) - diff --git a/source4/lib/tdb/python/tdbdump.py b/source4/lib/tdb/python/tdbdump.py deleted file mode 100644 index d759d771c8..0000000000 --- a/source4/lib/tdb/python/tdbdump.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/python -# Trivial reimplementation of tdbdump in Python - -import tdb, sys - -if len(sys.argv) < 2: - print "Usage: tdbdump.py " - sys.exit(1) - -db = tdb.Tdb(sys.argv[1]) -for (k, v) in db.iteritems(): - print "{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v) diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py deleted file mode 100644 index 7147718c91..0000000000 --- a/source4/lib/tdb/python/tests/simple.py +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/python -# Some simple tests for the Python bindings for TDB -# Note that this tests the interface of the Python bindings -# It does not test tdb itself. -# -# Copyright (C) 2007-2008 Jelmer Vernooij -# Published under the GNU LGPLv3 or later - -import tdb -from unittest import TestCase -import os, tempfile - - -class OpenTdbTests(TestCase): - def test_nonexistant_read(self): - self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, tdb.DEFAULT, os.O_RDWR) - - -class SimpleTdbTests(TestCase): - def setUp(self): - super(SimpleTdbTests, self).setUp() - self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR) - self.assertNotEqual(None, self.tdb) - - def tearDown(self): - del self.tdb - - def test_repr(self): - self.assertTrue(repr(self.tdb).startswith("Tdb('")) - - def test_lockall(self): - self.tdb.lock_all() - - def test_max_dead(self): - self.tdb.max_dead = 20 - - def test_unlockall(self): - self.tdb.lock_all() - self.tdb.unlock_all() - - def test_lockall_read(self): - self.tdb.read_lock_all() - self.tdb.read_unlock_all() - - def test_reopen(self): - self.tdb.reopen() - - def test_store(self): - self.tdb.store("bar", "bla") - self.assertEquals("bla", self.tdb.get("bar")) - - def test_getitem(self): - self.tdb["bar"] = "foo" - self.tdb.reopen() - self.assertEquals("foo", self.tdb["bar"]) - - def test_delete(self): - self.tdb["bar"] = "foo" - del self.tdb["bar"] - self.assertRaises(KeyError, lambda: self.tdb["bar"]) - - def test_contains(self): - self.tdb["bla"] = "bloe" - self.assertTrue("bla" in self.tdb) - - def test_keyerror(self): - self.assertRaises(KeyError, lambda: self.tdb["bla"]) - - def test_hash_size(self): - self.tdb.hash_size - - def test_map_size(self): - self.tdb.map_size - - def test_name(self): - self.tdb.name - - def test_iterator(self): - self.tdb["bla"] = "1" - self.tdb["brainslug"] = "2" - self.assertEquals(["bla", "brainslug"], list(self.tdb)) - - def test_items(self): - self.tdb["bla"] = "1" - self.tdb["brainslug"] = "2" - self.assertEquals([("bla", "1"), ("brainslug", "2")], self.tdb.items()) - - def test_iteritems(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "25" - i = self.tdb.iteritems() - self.assertEquals(set([("bla", "25"), ("bloe", "2")]), - set([i.next(), i.next()])) - - def test_transaction_cancel(self): - self.tdb["bloe"] = "2" - self.tdb.transaction_start() - self.tdb["bloe"] = "1" - self.tdb.transaction_cancel() - self.assertEquals("2", self.tdb["bloe"]) - - def test_transaction_commit(self): - self.tdb["bloe"] = "2" - self.tdb.transaction_start() - self.tdb["bloe"] = "1" - self.tdb.transaction_commit() - self.assertEquals("1", self.tdb["bloe"]) - - def test_iterator(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "hoi" - i = iter(self.tdb) - self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()])) - - def test_keys(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "25" - self.assertEquals(["bla", "bloe"], self.tdb.keys()) - - def test_iterkeys(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "25" - i = self.tdb.iterkeys() - self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()])) - - def test_values(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "25" - self.assertEquals(["25", "2"], self.tdb.values()) - - def test_itervalues(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "25" - i = self.tdb.itervalues() - self.assertEquals(set(["25", "2"]), set([i.next(), i.next()])) - - def test_clear(self): - self.tdb["bloe"] = "2" - self.tdb["bla"] = "25" - self.assertEquals(2, len(self.tdb)) - self.tdb.clear() - self.assertEquals(0, len(self.tdb)) - - def test_len(self): - self.assertEquals(0, len(self.tdb)) - self.tdb["entry"] = "value" - self.assertEquals(1, len(self.tdb)) - - -if __name__ == '__main__': - import unittest - unittest.TestProgram() diff --git a/source4/lib/tdb/rules.mk b/source4/lib/tdb/rules.mk deleted file mode 100644 index 7b765625df..0000000000 --- a/source4/lib/tdb/rules.mk +++ /dev/null @@ -1,21 +0,0 @@ -.SUFFIXES: .i _wrap.c - -.i_wrap.c: - $(SWIG) -O -Wall -python -keyword $< - -showflags:: - @echo 'tdb will be compiled with flags:' - @echo ' CFLAGS = $(CFLAGS)' - @echo ' CPPFLAGS = $(CPPFLAGS)' - @echo ' LDFLAGS = $(LDFLAGS)' - @echo ' LIBS = $(LIBS)' - -.SUFFIXES: .c .o - -.c.o: - @echo Compiling $*.c - @mkdir -p `dirname $@` - @$(CC) $(PICFLAG) $(CFLAGS) -c $< -o $@ - -distclean:: - rm -f *~ */*~ diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk deleted file mode 100644 index fa8db6d34c..0000000000 --- a/source4/lib/tdb/tdb.mk +++ /dev/null @@ -1,86 +0,0 @@ -dirs:: - @mkdir -p bin common tools - -PROGS = bin/tdbtool$(EXEEXT) bin/tdbdump$(EXEEXT) bin/tdbbackup$(EXEEXT) -PROGS_NOINSTALL = bin/tdbtest$(EXEEXT) bin/tdbtorture$(EXEEXT) -ALL_PROGS = $(PROGS) $(PROGS_NOINSTALL) - -TDB_SONAME = libtdb.$(SHLIBEXT).1 -TDB_SOLIB = libtdb.$(SHLIBEXT).$(PACKAGE_VERSION) - -TDB_LIB = libtdb.a - -bin/tdbtest$(EXEEXT): tools/tdbtest.o $(TDB_LIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm - -bin/tdbtool$(EXEEXT): tools/tdbtool.o $(TDB_LIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb - -bin/tdbtorture$(EXEEXT): tools/tdbtorture.o $(TDB_LIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. -ltdb - -bin/tdbdump$(EXEEXT): tools/tdbdump.o $(TDB_LIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb - -bin/tdbbackup$(EXEEXT): tools/tdbbackup.o $(TDB_LIB) - $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb - -test:: bin/tdbtorture$(EXEEXT) $(TDB_SONAME) - $(LIB_PATH_VAR)=. bin/tdbtorture$(EXEEXT) - -clean:: - rm -f test.db test.tdb torture.tdb test.gdbm - rm -f $(TDB_SONAME) $(TDB_SOLIB) libtdb.a libtdb.$(SHLIBEXT) - rm -f $(ALL_PROGS) tdb.pc - -build-python:: _tdb.$(SHLIBEXT) - -tdb_wrap.o: $(tdbdir)/tdb_wrap.c - $(CC) $(PICFLAG) -c $(tdbdir)/tdb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` - -_tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o - $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --ldflags` - -install:: installdirs installbin installheaders installlibs \ - $(PYTHON_INSTALL_TARGET) - -install-python:: build-python - mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \ - $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` - cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` - cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"` - -check-python:: build-python $(TDB_SONAME) - $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py - -install-swig:: - mkdir -p $(DESTDIR)`$(SWIG) -swiglib` - cp tdb.i $(DESTDIR)`$(SWIG) -swiglib` - -clean:: - rm -f _tdb.$(SHLIBEXT) - -installdirs:: - mkdir -p $(DESTDIR)$(bindir) - mkdir -p $(DESTDIR)$(includedir) - mkdir -p $(DESTDIR)$(libdir) - mkdir -p $(DESTDIR)$(libdir)/pkgconfig - -installbin:: all installdirs - cp $(PROGS) $(DESTDIR)$(bindir) - -installheaders:: installdirs - cp $(srcdir)/include/tdb.h $(DESTDIR)$(includedir) - -installlibs:: all installdirs - cp tdb.pc $(DESTDIR)$(libdir)/pkgconfig - cp libtdb.a $(TDB_SOLIB) $(DESTDIR)$(libdir) - -libtdb.a: $(TDB_OBJ) - ar -rv libtdb.a $(TDB_OBJ) - -libtdb.$(SHLIBEXT): $(TDB_SOLIB) - ln -fs $< $@ - -$(TDB_SONAME): $(TDB_SOLIB) - ln -fs $< $@ diff --git a/source4/lib/tdb/tdb.pc.in b/source4/lib/tdb/tdb.pc.in deleted file mode 100644 index 6f8f553736..0000000000 --- a/source4/lib/tdb/tdb.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: tdb -Description: A trivial database -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -ltdb -Cflags: -I${includedir} -URL: http://tdb.samba.org/ diff --git a/source4/lib/tdb/tools/tdbbackup.c b/source4/lib/tdb/tools/tdbbackup.c deleted file mode 100644 index 6f3ca48314..0000000000 --- a/source4/lib/tdb/tools/tdbbackup.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - Unix SMB/CIFS implementation. - low level tdb backup and restore utility - Copyright (C) Andrew Tridgell 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 . -*/ - -/* - - This program is meant for backup/restore of tdb databases. Typical usage would be: - tdbbackup *.tdb - when Samba shuts down cleanly, which will make a backup of all the local databases - to *.bak files. Then on Samba startup you would use: - tdbbackup -v *.tdb - and this will check the databases for corruption and if corruption is detected then - the backup will be restored. - - You may also like to do a backup on a regular basis while Samba is - running, perhaps using cron. - - The reason this program is needed is to cope with power failures - while Samba is running. A power failure could lead to database - corruption and Samba will then not start correctly. - - Note that many of the databases in Samba are transient and thus - don't need to be backed up, so you can optimise the above a little - by only running the backup on the critical databases. - - */ - -#include "replace.h" -#include "system/locale.h" -#include "system/time.h" -#include "system/filesys.h" -#include "system/wait.h" -#include "tdb.h" - -#ifdef HAVE_GETOPT_H -#include -#endif - -static int failed; - -static char *add_suffix(const char *name, const char *suffix) -{ - char *ret; - int len = strlen(name) + strlen(suffix) + 1; - ret = (char *)malloc(len); - if (!ret) { - fprintf(stderr,"Out of memory!\n"); - exit(1); - } - snprintf(ret, len, "%s%s", name, suffix); - return ret; -} - -static int copy_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - TDB_CONTEXT *tdb_new = (TDB_CONTEXT *)state; - - if (tdb_store(tdb_new, key, dbuf, TDB_INSERT) != 0) { - fprintf(stderr,"Failed to insert into %s\n", tdb_name(tdb_new)); - failed = 1; - return 1; - } - return 0; -} - - -static int test_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - return 0; -} - -/* - carefully backup a tdb, validating the contents and - only doing the backup if its OK - this function is also used for restore -*/ -static int backup_tdb(const char *old_name, const char *new_name, int hash_size) -{ - TDB_CONTEXT *tdb; - TDB_CONTEXT *tdb_new; - char *tmp_name; - struct stat st; - int count1, count2; - - tmp_name = add_suffix(new_name, ".tmp"); - - /* stat the old tdb to find its permissions */ - if (stat(old_name, &st) != 0) { - perror(old_name); - free(tmp_name); - return 1; - } - - /* open the old tdb */ - tdb = tdb_open(old_name, 0, 0, O_RDWR, 0); - if (!tdb) { - printf("Failed to open %s\n", old_name); - free(tmp_name); - return 1; - } - - /* create the new tdb */ - unlink(tmp_name); - tdb_new = tdb_open(tmp_name, - hash_size ? hash_size : tdb_hash_size(tdb), - TDB_DEFAULT, O_RDWR|O_CREAT|O_EXCL, - st.st_mode & 0777); - if (!tdb_new) { - perror(tmp_name); - free(tmp_name); - return 1; - } - - /* lock the old tdb */ - if (tdb_lockall(tdb) != 0) { - fprintf(stderr,"Failed to lock %s\n", old_name); - tdb_close(tdb); - tdb_close(tdb_new); - unlink(tmp_name); - free(tmp_name); - return 1; - } - - failed = 0; - - /* traverse and copy */ - count1 = tdb_traverse(tdb, copy_fn, (void *)tdb_new); - if (count1 < 0 || failed) { - fprintf(stderr,"failed to copy %s\n", old_name); - tdb_close(tdb); - tdb_close(tdb_new); - unlink(tmp_name); - free(tmp_name); - return 1; - } - - /* close the old tdb */ - tdb_close(tdb); - - /* close the new tdb and re-open read-only */ - tdb_close(tdb_new); - tdb_new = tdb_open(tmp_name, 0, TDB_DEFAULT, O_RDONLY, 0); - if (!tdb_new) { - fprintf(stderr,"failed to reopen %s\n", tmp_name); - unlink(tmp_name); - perror(tmp_name); - free(tmp_name); - return 1; - } - - /* traverse the new tdb to confirm */ - count2 = tdb_traverse(tdb_new, test_fn, NULL); - if (count2 != count1) { - fprintf(stderr,"failed to copy %s\n", old_name); - tdb_close(tdb_new); - unlink(tmp_name); - free(tmp_name); - return 1; - } - - /* make sure the new tdb has reached stable storage */ - fsync(tdb_fd(tdb_new)); - - /* close the new tdb and rename it to .bak */ - tdb_close(tdb_new); - if (rename(tmp_name, new_name) != 0) { - perror(new_name); - free(tmp_name); - return 1; - } - - free(tmp_name); - - return 0; -} - -/* - verify a tdb and if it is corrupt then restore from *.bak -*/ -static int verify_tdb(const char *fname, const char *bak_name) -{ - TDB_CONTEXT *tdb; - int count = -1; - - /* open the tdb */ - tdb = tdb_open(fname, 0, 0, O_RDONLY, 0); - - /* traverse the tdb, then close it */ - if (tdb) { - count = tdb_traverse(tdb, test_fn, NULL); - tdb_close(tdb); - } - - /* count is < 0 means an error */ - if (count < 0) { - printf("restoring %s\n", fname); - return backup_tdb(bak_name, fname, 0); - } - - printf("%s : %d records\n", fname, count); - - return 0; -} - -/* - see if one file is newer than another -*/ -static int file_newer(const char *fname1, const char *fname2) -{ - struct stat st1, st2; - if (stat(fname1, &st1) != 0) { - return 0; - } - if (stat(fname2, &st2) != 0) { - return 1; - } - return (st1.st_mtime > st2.st_mtime); -} - -static void usage(void) -{ - printf("Usage: tdbbackup [options] \n\n"); - printf(" -h this help message\n"); - printf(" -s suffix set the backup suffix\n"); - printf(" -v verify mode (restore if corrupt)\n"); - printf(" -n hashsize set the new hash size for the backup\n"); -} - - - int main(int argc, char *argv[]) -{ - int i; - int ret = 0; - int c; - int verify = 0; - int hashsize = 0; - const char *suffix = ".bak"; - - while ((c = getopt(argc, argv, "vhs:n:")) != -1) { - switch (c) { - case 'h': - usage(); - exit(0); - case 'v': - verify = 1; - break; - case 's': - suffix = optarg; - break; - case 'n': - hashsize = atoi(optarg); - break; - } - } - - argc -= optind; - argv += optind; - - if (argc < 1) { - usage(); - exit(1); - } - - for (i=0; i. -*/ - -#include "replace.h" -#include "system/locale.h" -#include "system/time.h" -#include "system/filesys.h" -#include "system/wait.h" -#include "tdb.h" - -static void print_data(TDB_DATA d) -{ - unsigned char *p = (unsigned char *)d.dptr; - int len = d.dsize; - while (len--) { - if (isprint(*p) && !strchr("\"\\", *p)) { - fputc(*p, stdout); - } else { - printf("\\%02X", *p); - } - p++; - } -} - -static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - printf("{\n"); - printf("key(%d) = \"", (int)key.dsize); - print_data(key); - printf("\"\n"); - printf("data(%d) = \"", (int)dbuf.dsize); - print_data(dbuf); - printf("\"\n"); - printf("}\n"); - return 0; -} - -static int dump_tdb(const char *fname, const char *keyname) -{ - TDB_CONTEXT *tdb; - TDB_DATA key, value; - - tdb = tdb_open(fname, 0, 0, O_RDONLY, 0); - if (!tdb) { - printf("Failed to open %s\n", fname); - return 1; - } - - if (!keyname) { - tdb_traverse(tdb, traverse_fn, NULL); - } else { - key.dptr = discard_const_p(uint8_t,keyname); - key.dsize = strlen( keyname); - value = tdb_fetch(tdb, key); - if (!value.dptr) { - return 1; - } else { - print_data(value); - free(value.dptr); - } - } - - return 0; -} - -static void usage( void) -{ - printf( "Usage: tdbdump [options] \n\n"); - printf( " -h this help message\n"); - printf( " -k keyname dumps value of keyname\n"); -} - - int main(int argc, char *argv[]) -{ - char *fname, *keyname=NULL; - int c; - - if (argc < 2) { - printf("Usage: tdbdump \n"); - exit(1); - } - - while ((c = getopt( argc, argv, "hk:")) != -1) { - switch (c) { - case 'h': - usage(); - exit( 0); - case 'k': - keyname = optarg; - break; - default: - usage(); - exit( 1); - } - } - - fname = argv[optind]; - - return dump_tdb(fname, keyname); -} diff --git a/source4/lib/tdb/tools/tdbtest.c b/source4/lib/tdb/tools/tdbtest.c deleted file mode 100644 index 416bc50a5b..0000000000 --- a/source4/lib/tdb/tools/tdbtest.c +++ /dev/null @@ -1,265 +0,0 @@ -/* a test program for tdb - the trivial database */ - -#include "replace.h" -#include "tdb.h" -#include "system/filesys.h" -#include "system/time.h" - -#include - - -#define DELETE_PROB 7 -#define STORE_PROB 5 - -static struct tdb_context *db; -static GDBM_FILE gdbm; - -struct timeval tp1,tp2; - -static void _start_timer(void) -{ - gettimeofday(&tp1,NULL); -} - -static double _end_timer(void) -{ - gettimeofday(&tp2,NULL); - return((tp2.tv_sec - tp1.tv_sec) + - (tp2.tv_usec - tp1.tv_usec)*1.0e-6); -} - -static void fatal(const char *why) -{ - perror(why); - exit(1); -} - -#ifdef PRINTF_ATTRIBUTE -static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4); -#endif -static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - vfprintf(stdout, format, ap); - va_end(ap); - fflush(stdout); -} - -static void compare_db(void) -{ - TDB_DATA d, key, nextkey; - datum gd, gkey, gnextkey; - - key = tdb_firstkey(db); - while (key.dptr) { - d = tdb_fetch(db, key); - gkey.dptr = key.dptr; - gkey.dsize = key.dsize; - - gd = gdbm_fetch(gdbm, gkey); - - if (!gd.dptr) fatal("key not in gdbm"); - if (gd.dsize != d.dsize) fatal("data sizes differ"); - if (memcmp(gd.dptr, d.dptr, d.dsize)) { - fatal("data differs"); - } - - nextkey = tdb_nextkey(db, key); - free(key.dptr); - free(d.dptr); - free(gd.dptr); - key = nextkey; - } - - gkey = gdbm_firstkey(gdbm); - while (gkey.dptr) { - gd = gdbm_fetch(gdbm, gkey); - key.dptr = gkey.dptr; - key.dsize = gkey.dsize; - - d = tdb_fetch(db, key); - - if (!d.dptr) fatal("key not in db"); - if (d.dsize != gd.dsize) fatal("data sizes differ"); - if (memcmp(d.dptr, gd.dptr, gd.dsize)) { - fatal("data differs"); - } - - gnextkey = gdbm_nextkey(gdbm, gkey); - free(gkey.dptr); - free(gd.dptr); - free(d.dptr); - gkey = gnextkey; - } -} - -static char *randbuf(int len) -{ - char *buf; - int i; - buf = (char *)malloc(len+1); - - for (i=0;i. -*/ - -#include "replace.h" -#include "system/locale.h" -#include "system/time.h" -#include "system/filesys.h" -#include "system/wait.h" -#include "tdb.h" - -static int do_command(void); -const char *cmdname; -char *arg1, *arg2; -size_t arg1len, arg2len; -int bIterate = 0; -char *line; -TDB_DATA iterate_kbuf; -char cmdline[1024]; -static int disable_mmap; - -enum commands { - CMD_CREATE_TDB, - CMD_OPEN_TDB, - CMD_ERASE, - CMD_DUMP, - CMD_INSERT, - CMD_MOVE, - CMD_STORE, - CMD_SHOW, - CMD_KEYS, - CMD_HEXKEYS, - CMD_DELETE, - CMD_LIST_HASH_FREE, - CMD_LIST_FREE, - CMD_INFO, - CMD_MMAP, - CMD_SPEED, - CMD_FIRST, - CMD_NEXT, - CMD_SYSTEM, - CMD_QUIT, - CMD_HELP -}; - -typedef struct { - const char *name; - enum commands cmd; -} COMMAND_TABLE; - -COMMAND_TABLE cmd_table[] = { - {"create", CMD_CREATE_TDB}, - {"open", CMD_OPEN_TDB}, - {"erase", CMD_ERASE}, - {"dump", CMD_DUMP}, - {"insert", CMD_INSERT}, - {"move", CMD_MOVE}, - {"store", CMD_STORE}, - {"show", CMD_SHOW}, - {"keys", CMD_KEYS}, - {"hexkeys", CMD_HEXKEYS}, - {"delete", CMD_DELETE}, - {"list", CMD_LIST_HASH_FREE}, - {"free", CMD_LIST_FREE}, - {"info", CMD_INFO}, - {"speed", CMD_SPEED}, - {"mmap", CMD_MMAP}, - {"first", CMD_FIRST}, - {"1", CMD_FIRST}, - {"next", CMD_NEXT}, - {"n", CMD_NEXT}, - {"quit", CMD_QUIT}, - {"q", CMD_QUIT}, - {"!", CMD_SYSTEM}, - {NULL, CMD_HELP} -}; - -struct timeval tp1,tp2; - -static void _start_timer(void) -{ - gettimeofday(&tp1,NULL); -} - -static double _end_timer(void) -{ - gettimeofday(&tp2,NULL); - return((tp2.tv_sec - tp1.tv_sec) + - (tp2.tv_usec - tp1.tv_usec)*1.0e-6); -} - -/* a tdb tool for manipulating a tdb database */ - -static TDB_CONTEXT *tdb; - -static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); -static int print_key(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); -static int print_hexkey(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); - -static void print_asc(const char *buf,int len) -{ - int i; - - /* We're probably printing ASCII strings so don't try to display - the trailing NULL character. */ - - if (buf[len - 1] == 0) - len--; - - for (i=0;i8) printf(" "); - while (n--) printf(" "); - - n = i%16; - if (n > 8) n = 8; - print_asc(&buf[i-(i%16)],n); printf(" "); - n = (i%16) - n; - if (n>0) print_asc(&buf[i-n],n); - printf("\n"); - } -} - -static void help(void) -{ - printf("\n" -"tdbtool: \n" -" create dbname : create a database\n" -" open dbname : open an existing database\n" -" erase : erase the database\n" -" dump : dump the database as strings\n" -" keys : dump the database keys as strings\n" -" hexkeys : dump the database keys as hex values\n" -" info : print summary info about the database\n" -" insert key data : insert a record\n" -" move key file : move a record to a destination tdb\n" -" store key data : store a record (replace)\n" -" show key : show a record by key\n" -" delete key : delete a record by key\n" -" list : print the database hash table and freelist\n" -" free : print the database freelist\n" -" ! command : execute system command\n" -" 1 | first : print the first record\n" -" n | next : print the next record\n" -" q | quit : terminate\n" -" \\n : repeat 'next' command\n" -"\n"); -} - -static void terror(const char *why) -{ - printf("%s\n", why); -} - -static void create_tdb(const char *tdbname) -{ - if (tdb) tdb_close(tdb); - tdb = tdb_open(tdbname, 0, TDB_CLEAR_IF_FIRST | (disable_mmap?TDB_NOMMAP:0), - O_RDWR | O_CREAT | O_TRUNC, 0600); - if (!tdb) { - printf("Could not create %s: %s\n", tdbname, strerror(errno)); - } -} - -static void open_tdb(const char *tdbname) -{ - if (tdb) tdb_close(tdb); - tdb = tdb_open(tdbname, 0, disable_mmap?TDB_NOMMAP:0, O_RDWR, 0600); - if (!tdb) { - printf("Could not open %s: %s\n", tdbname, strerror(errno)); - } -} - -static void insert_tdb(char *keyname, size_t keylen, char* data, size_t datalen) -{ - TDB_DATA key, dbuf; - - if ((keyname == NULL) || (keylen == 0)) { - terror("need key"); - return; - } - - key.dptr = (unsigned char *)keyname; - key.dsize = keylen; - dbuf.dptr = (unsigned char *)data; - dbuf.dsize = datalen; - - if (tdb_store(tdb, key, dbuf, TDB_INSERT) == -1) { - terror("insert failed"); - } -} - -static void store_tdb(char *keyname, size_t keylen, char* data, size_t datalen) -{ - TDB_DATA key, dbuf; - - if ((keyname == NULL) || (keylen == 0)) { - terror("need key"); - return; - } - - if ((data == NULL) || (datalen == 0)) { - terror("need data"); - return; - } - - key.dptr = (unsigned char *)keyname; - key.dsize = keylen; - dbuf.dptr = (unsigned char *)data; - dbuf.dsize = datalen; - - printf("Storing key:\n"); - print_rec(tdb, key, dbuf, NULL); - - if (tdb_store(tdb, key, dbuf, TDB_REPLACE) == -1) { - terror("store failed"); - } -} - -static void show_tdb(char *keyname, size_t keylen) -{ - TDB_DATA key, dbuf; - - if ((keyname == NULL) || (keylen == 0)) { - terror("need key"); - return; - } - - key.dptr = (unsigned char *)keyname; - key.dsize = keylen; - - dbuf = tdb_fetch(tdb, key); - if (!dbuf.dptr) { - terror("fetch failed"); - return; - } - - print_rec(tdb, key, dbuf, NULL); - - free( dbuf.dptr ); - - return; -} - -static void delete_tdb(char *keyname, size_t keylen) -{ - TDB_DATA key; - - if ((keyname == NULL) || (keylen == 0)) { - terror("need key"); - return; - } - - key.dptr = (unsigned char *)keyname; - key.dsize = keylen; - - if (tdb_delete(tdb, key) != 0) { - terror("delete failed"); - } -} - -static void move_rec(char *keyname, size_t keylen, char* tdbname) -{ - TDB_DATA key, dbuf; - TDB_CONTEXT *dst_tdb; - - if ((keyname == NULL) || (keylen == 0)) { - terror("need key"); - return; - } - - if ( !tdbname ) { - terror("need destination tdb name"); - return; - } - - key.dptr = (unsigned char *)keyname; - key.dsize = keylen; - - dbuf = tdb_fetch(tdb, key); - if (!dbuf.dptr) { - terror("fetch failed"); - return; - } - - print_rec(tdb, key, dbuf, NULL); - - dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600); - if ( !dst_tdb ) { - terror("unable to open destination tdb"); - return; - } - - if ( tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) == -1 ) { - terror("failed to move record"); - } - else - printf("record moved\n"); - - tdb_close( dst_tdb ); - - return; -} - -static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - printf("\nkey %d bytes\n", (int)key.dsize); - print_asc((const char *)key.dptr, key.dsize); - printf("\ndata %d bytes\n", (int)dbuf.dsize); - print_data((const char *)dbuf.dptr, dbuf.dsize); - return 0; -} - -static int print_key(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - printf("key %d bytes: ", (int)key.dsize); - print_asc((const char *)key.dptr, key.dsize); - printf("\n"); - return 0; -} - -static int print_hexkey(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - printf("key %d bytes\n", (int)key.dsize); - print_data((const char *)key.dptr, key.dsize); - printf("\n"); - return 0; -} - -static int total_bytes; - -static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state) -{ - total_bytes += dbuf.dsize; - return 0; -} - -static void info_tdb(void) -{ - int count; - total_bytes = 0; - if ((count = tdb_traverse(tdb, traverse_fn, NULL)) == -1) - printf("Error = %s\n", tdb_errorstr(tdb)); - else - printf("%d records totalling %d bytes\n", count, total_bytes); -} - -static void speed_tdb(const char *tlimit) -{ - unsigned timelimit = tlimit?atoi(tlimit):0; - double t; - int ops=0; - if (timelimit == 0) timelimit = 10; - printf("Testing traverse speed for %u seconds\n", timelimit); - _start_timer(); - while ((t=_end_timer()) < timelimit) { - tdb_traverse(tdb, traverse_fn, NULL); - printf("%10.3f ops/sec\r", (++ops)/t); - } - printf("\n"); -} - -static void toggle_mmap(void) -{ - disable_mmap = !disable_mmap; - if (disable_mmap) { - printf("mmap is disabled\n"); - } else { - printf("mmap is enabled\n"); - } -} - -static char *tdb_getline(const char *prompt) -{ - static char thisline[1024]; - char *p; - fputs(prompt, stdout); - thisline[0] = 0; - p = fgets(thisline, sizeof(thisline)-1, stdin); - if (p) p = strchr(p, '\n'); - if (p) *p = 0; - return p?thisline:NULL; -} - -static int do_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, - void *state) -{ - return tdb_delete(the_tdb, key); -} - -static void first_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey) -{ - TDB_DATA dbuf; - *pkey = tdb_firstkey(the_tdb); - - dbuf = tdb_fetch(the_tdb, *pkey); - if (!dbuf.dptr) terror("fetch failed"); - else { - print_rec(the_tdb, *pkey, dbuf, NULL); - } -} - -static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey) -{ - TDB_DATA dbuf; - *pkey = tdb_nextkey(the_tdb, *pkey); - - dbuf = tdb_fetch(the_tdb, *pkey); - if (!dbuf.dptr) - terror("fetch failed"); - else - print_rec(the_tdb, *pkey, dbuf, NULL); -} - -static int do_command(void) -{ - COMMAND_TABLE *ctp = cmd_table; - enum commands mycmd = CMD_HELP; - int cmd_len; - - if (cmdname && strlen(cmdname) == 0) { - mycmd = CMD_NEXT; - } else { - while (ctp->name) { - cmd_len = strlen(ctp->name); - if (strncmp(ctp->name,cmdname,cmd_len) == 0) { - mycmd = ctp->cmd; - break; - } - ctp++; - } - } - - switch (mycmd) { - case CMD_CREATE_TDB: - bIterate = 0; - create_tdb(arg1); - return 0; - case CMD_OPEN_TDB: - bIterate = 0; - open_tdb(arg1); - return 0; - case CMD_SYSTEM: - /* Shell command */ - system(arg1); - return 0; - case CMD_QUIT: - return 1; - default: - /* all the rest require a open database */ - if (!tdb) { - bIterate = 0; - terror("database not open"); - help(); - return 0; - } - switch (mycmd) { - case CMD_ERASE: - bIterate = 0; - tdb_traverse(tdb, do_delete_fn, NULL); - return 0; - case CMD_DUMP: - bIterate = 0; - tdb_traverse(tdb, print_rec, NULL); - return 0; - case CMD_INSERT: - bIterate = 0; - insert_tdb(arg1, arg1len,arg2,arg2len); - return 0; - case CMD_MOVE: - bIterate = 0; - move_rec(arg1,arg1len,arg2); - return 0; - case CMD_STORE: - bIterate = 0; - store_tdb(arg1,arg1len,arg2,arg2len); - return 0; - case CMD_SHOW: - bIterate = 0; - show_tdb(arg1, arg1len); - return 0; - case CMD_KEYS: - tdb_traverse(tdb, print_key, NULL); - return 0; - case CMD_HEXKEYS: - tdb_traverse(tdb, print_hexkey, NULL); - return 0; - case CMD_DELETE: - bIterate = 0; - delete_tdb(arg1,arg1len); - return 0; - case CMD_LIST_HASH_FREE: - tdb_dump_all(tdb); - return 0; - case CMD_LIST_FREE: - tdb_printfreelist(tdb); - return 0; - case CMD_INFO: - info_tdb(); - return 0; - case CMD_SPEED: - speed_tdb(arg1); - return 0; - case CMD_MMAP: - toggle_mmap(); - return 0; - case CMD_FIRST: - bIterate = 1; - first_record(tdb, &iterate_kbuf); - return 0; - case CMD_NEXT: - if (bIterate) - next_record(tdb, &iterate_kbuf); - return 0; - case CMD_HELP: - help(); - return 0; - case CMD_CREATE_TDB: - case CMD_OPEN_TDB: - case CMD_SYSTEM: - case CMD_QUIT: - /* - * unhandled commands. cases included here to avoid compiler - * warnings. - */ - return 0; - } - } - - return 0; -} - -static char *convert_string(char *instring, size_t *sizep) -{ - size_t length = 0; - char *outp, *inp; - char temp[3]; - - - outp = inp = instring; - - while (*inp) { - if (*inp == '\\') { - inp++; - if (*inp && strchr("0123456789abcdefABCDEF",(int)*inp)) { - temp[0] = *inp++; - temp[1] = '\0'; - if (*inp && strchr("0123456789abcdefABCDEF",(int)*inp)) { - temp[1] = *inp++; - temp[2] = '\0'; - } - *outp++ = (char)strtol((const char *)temp,NULL,16); - } else { - *outp++ = *inp++; - } - } else { - *outp++ = *inp++; - } - length++; - } - *sizep = length; - return instring; -} - -int main(int argc, char *argv[]) -{ - cmdname = ""; - arg1 = NULL; - arg1len = 0; - arg2 = NULL; - arg2len = 0; - - if (argv[1]) { - cmdname = "open"; - arg1 = argv[1]; - do_command(); - cmdname = ""; - arg1 = NULL; - } - - switch (argc) { - case 1: - case 2: - /* Interactive mode */ - while ((cmdname = tdb_getline("tdb> "))) { - arg2 = arg1 = NULL; - if ((arg1 = strchr((const char *)cmdname,' ')) != NULL) { - arg1++; - arg2 = arg1; - while (*arg2) { - if (*arg2 == ' ') { - *arg2++ = '\0'; - break; - } - if ((*arg2++ == '\\') && (*arg2 == ' ')) { - arg2++; - } - } - } - if (arg1) arg1 = convert_string(arg1,&arg1len); - if (arg2) arg2 = convert_string(arg2,&arg2len); - if (do_command()) break; - } - break; - case 5: - arg2 = convert_string(argv[4],&arg2len); - case 4: - arg1 = convert_string(argv[3],&arg1len); - case 3: - cmdname = argv[2]; - default: - do_command(); - break; - } - - if (tdb) tdb_close(tdb); - - return 0; -} diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c deleted file mode 100644 index 9265cf07aa..0000000000 --- a/source4/lib/tdb/tools/tdbtorture.c +++ /dev/null @@ -1,318 +0,0 @@ -/* this tests tdb by doing lots of ops from several simultaneous - writers - that stresses the locking code. -*/ - -#include "replace.h" -#include "system/time.h" -#include "system/wait.h" -#include "system/filesys.h" -#include "tdb.h" - -#ifdef HAVE_GETOPT_H -#include -#endif - - -#define REOPEN_PROB 30 -#define DELETE_PROB 8 -#define STORE_PROB 4 -#define APPEND_PROB 6 -#define TRANSACTION_PROB 10 -#define LOCKSTORE_PROB 5 -#define TRAVERSE_PROB 20 -#define TRAVERSE_READ_PROB 20 -#define CULL_PROB 100 -#define KEYLEN 3 -#define DATALEN 100 - -static struct tdb_context *db; -static int in_transaction; -static int error_count; - -#ifdef PRINTF_ATTRIBUTE -static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...) PRINTF_ATTRIBUTE(3,4); -#endif -static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...) -{ - va_list ap; - - error_count++; - - va_start(ap, format); - vfprintf(stdout, format, ap); - va_end(ap); - fflush(stdout); -#if 0 - { - char *ptr; - asprintf(&ptr,"xterm -e gdb /proc/%d/exe %d", getpid(), getpid()); - system(ptr); - free(ptr); - } -#endif -} - -static void fatal(const char *why) -{ - perror(why); - error_count++; -} - -static char *randbuf(int len) -{ - char *buf; - int i; - buf = (char *)malloc(len+1); - - for (i=0;i - - -ldb - - - -

tdb

- -TDB is a Trivial Database. In concept, it is very much like GDBM, and BSD's DB -except that it allows multiple simultaneous writers and uses locking -internally to keep writers from trampling on each other. TDB is also extremely -small. - -

Discussion and bug reports

- -tdb does not currently have its own mailing list or bug tracking -system. For now, please use the samba-technical -mailing list, and the Samba -bugzilla bug tracking system. - -

Download

- -You can download the latest release either via rsync or git.
-
-To fetch via git see the following guide:
-Using Git for Samba Development
-Once you have cloned the tree switch to the v4-0-test branch and cd into the source/lib/tdb directory.
-
-To fetch via rsync use these commands: - -
-  rsync -Pavz samba.org::ftp/unpacked/tdb .
-  rsync -Pavz samba.org::ftp/unpacked/libreplace .
-
- -and build in tdb. It will find the replace library in the directory -above automatically. - - - diff --git a/source4/lib/tdb_wrap.c b/source4/lib/tdb_wrap.c index 37095dff2c..da27803b06 100644 --- a/source4/lib/tdb_wrap.c +++ b/source4/lib/tdb_wrap.c @@ -20,8 +20,8 @@ */ #include "includes.h" -#include "lib/tdb/include/tdb.h" -#include "lib/util/dlinklist.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/dlinklist.h" #include "tdb_wrap.h" #include "tdb.h" @@ -46,7 +46,7 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, { va_list ap; char *ptr = NULL; - int debug_level; + int dl; va_start(ap, format); vasprintf(&ptr, format, ap); @@ -54,24 +54,24 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, switch (level) { case TDB_DEBUG_FATAL: - debug_level = 0; + dl = 0; break; case TDB_DEBUG_ERROR: - debug_level = 1; + dl = 1; break; case TDB_DEBUG_WARNING: - debug_level = 2; + dl = 2; break; case TDB_DEBUG_TRACE: - debug_level = 5; + dl = 5; break; default: - debug_level = 0; + dl = 0; } if (ptr != NULL) { const char *name = tdb_name(tdb); - DEBUG(debug_level, ("tdb(%s): %s", name ? name : "unnamed", ptr)); + DEBUG(dl, ("tdb(%s): %s", name ? name : "unnamed", ptr)); free(ptr); } } diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c index b298fb10cf..f72aafe542 100644 --- a/source4/lib/tls/tls.c +++ b/source4/lib/tls/tls.c @@ -363,7 +363,6 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context * const char *crlfile = private_path(tmp_ctx, lp_ctx, lp_tls_crlfile(lp_ctx)); const char *dhpfile = private_path(tmp_ctx, lp_ctx, lp_tls_dhpfile(lp_ctx)); void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *); - params = talloc(mem_ctx, struct tls_params); if (params == NULL) { talloc_free(tmp_ctx); @@ -421,7 +420,7 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context * if (dhpfile && *dhpfile) { gnutls_datum_t dhparms; size_t size; - dhparms.data = (uint8_t *)file_load(dhpfile, &size, mem_ctx); + dhparms.data = (uint8_t *)file_load(dhpfile, &size, 0, mem_ctx); if (!dhparms.data) { DEBUG(0,("Failed to read DH Parms from %s\n", dhpfile)); diff --git a/source4/lib/tls/tlscert.c b/source4/lib/tls/tlscert.c index 240ae056c1..f2e79f2a89 100644 --- a/source4/lib/tls/tlscert.c +++ b/source4/lib/tls/tlscert.c @@ -31,6 +31,10 @@ #define LIFETIME 700*24*60*60 #define DH_BITS 1024 +void tls_cert_generate(TALLOC_CTX *mem_ctx, + const char *keyfile, const char *certfile, + const char *cafile); + /* auto-generate a set of self signed certificates */ diff --git a/source4/lib/torture/torture.c b/source4/lib/torture/torture.c index 33959ded16..ba7168f3fe 100644 --- a/source4/lib/torture/torture.c +++ b/source4/lib/torture/torture.c @@ -20,7 +20,7 @@ #include "includes.h" #include "torture/torture.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" #include "system/filesys.h" @@ -235,19 +235,6 @@ void torture_ui_test_start(struct torture_context *context, context->ui_ops->test_start(context, tcase, test); } -int str_list_match(const char *name, char **list) -{ - int i, ret = 0; - if (list == NULL) - return 0; - - for (i = 0; list[i]; i++) { - if (gen_fnmatch(list[i], name) == 0) - ret++; - } - return ret; -} - void torture_ui_test_result(struct torture_context *context, enum torture_result result, const char *comment) diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h index f023f319ff..0f966a52d1 100644 --- a/source4/lib/torture/torture.h +++ b/source4/lib/torture/torture.h @@ -267,7 +267,7 @@ void torture_result(struct torture_context *test, char *__got; \ const char *__expected = (expected); \ size_t __size; \ - __got = file_load(filename, &__size, torture_ctx); \ + __got = file_load(filename, &__size, 0, torture_ctx); \ if (__got == NULL) { \ torture_result(torture_ctx, TORTURE_FAIL, \ __location__": unable to open %s: %s\n", \ @@ -288,7 +288,7 @@ void torture_result(struct torture_context *test, #define torture_assert_file_contains(torture_ctx,filename,expected,cmt)\ do { const char *__got, *__expected = (expected); \ size_t __size; \ - __got = file_load(filename, *size, torture_ctx); \ + __got = file_load(filename, *size, 0, torture_ctx); \ if (strcmp_safe(__got, __expected) != 0) { \ torture_result(torture_ctx, TORTURE_FAIL, \ __location__": %s contained:\n%sExpected: %s%s\n", \ diff --git a/source4/lib/util/dlinklist.h b/source4/lib/util/dlinklist.h deleted file mode 100644 index 5624124459..0000000000 --- a/source4/lib/util/dlinklist.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - Unix SMB/CIFS implementation. - some simple double linked list macros - Copyright (C) Andrew Tridgell 1998 - - 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 . -*/ - -/* To use these macros you must have a structure containing a next and - prev pointer */ - -#ifndef _DLINKLIST_H -#define _DLINKLIST_H - - -/* hook into the front of the list */ -#define DLIST_ADD(list, p) \ -do { \ - if (!(list)) { \ - (list) = (p); \ - (p)->next = (p)->prev = NULL; \ - } else { \ - (list)->prev = (p); \ - (p)->next = (list); \ - (p)->prev = NULL; \ - (list) = (p); \ - }\ -} while (0) - -/* remove an element from a list - element doesn't have to be in list. */ -#define DLIST_REMOVE(list, p) \ -do { \ - if ((p) == (list)) { \ - (list) = (p)->next; \ - if (list) (list)->prev = NULL; \ - } else { \ - if ((p)->prev) (p)->prev->next = (p)->next; \ - if ((p)->next) (p)->next->prev = (p)->prev; \ - } \ - if ((p) != (list)) (p)->next = (p)->prev = NULL; \ -} while (0) - -/* promote an element to the top of the list */ -#define DLIST_PROMOTE(list, p) \ -do { \ - DLIST_REMOVE(list, p); \ - DLIST_ADD(list, p); \ -} while (0) - -/* hook into the end of the list - needs a tmp pointer */ -#define DLIST_ADD_END(list, p, type) \ -do { \ - if (!(list)) { \ - (list) = (p); \ - (p)->next = (p)->prev = NULL; \ - } else { \ - type tmp; \ - for (tmp = (list); tmp->next; tmp = tmp->next) ; \ - tmp->next = (p); \ - (p)->next = NULL; \ - (p)->prev = tmp; \ - } \ -} while (0) - -/* insert 'p' after the given element 'el' in a list. If el is NULL then - this is the same as a DLIST_ADD() */ -#define DLIST_ADD_AFTER(list, p, el) \ -do { \ - if (!(list) || !(el)) { \ - DLIST_ADD(list, p); \ - } else { \ - p->prev = el; \ - p->next = el->next; \ - el->next = p; \ - if (p->next) p->next->prev = p; \ - }\ -} while (0) - -/* demote an element to the end of the list, needs a tmp pointer */ -#define DLIST_DEMOTE(list, p, tmp) \ -do { \ - DLIST_REMOVE(list, p); \ - DLIST_ADD_END(list, p, tmp); \ -} while (0) - -/* concatenate two lists - putting all elements of the 2nd list at the - end of the first list */ -#define DLIST_CONCATENATE(list1, list2, type) \ -do { \ - if (!(list1)) { \ - (list1) = (list2); \ - } else { \ - type tmp; \ - for (tmp = (list1); tmp->next; tmp = tmp->next) ; \ - tmp->next = (list2); \ - if (list2) { \ - (list2)->prev = tmp; \ - } \ - } \ -} while (0) - -#endif /* _DLINKLIST_H */ diff --git a/source4/lib/util/util_str.c b/source4/lib/util/util_str.c deleted file mode 100644 index 9ea6403c52..0000000000 --- a/source4/lib/util/util_str.c +++ /dev/null @@ -1,790 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - - Copyright (C) Andrew Tridgell 1992-2001 - Copyright (C) Simo Sorce 2001-2002 - Copyright (C) Martin Pool 2003 - Copyright (C) James Peach 2005 - - 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 . -*/ - -#include "includes.h" -#include "libcli/raw/smb.h" -#include "system/locale.h" - -/** - * @file - * @brief String utilities. - **/ - - -/** - Trim the specified elements off the front and back of a string. -**/ -_PUBLIC_ bool trim_string(char *s, const char *front, const char *back) -{ - bool ret = false; - size_t front_len; - size_t back_len; - size_t len; - - /* Ignore null or empty strings. */ - if (!s || (s[0] == '\0')) - return false; - - front_len = front? strlen(front) : 0; - back_len = back? strlen(back) : 0; - - len = strlen(s); - - if (front_len) { - while (len && strncmp(s, front, front_len)==0) { - /* Must use memmove here as src & dest can - * easily overlap. Found by valgrind. JRA. */ - memmove(s, s+front_len, (len-front_len)+1); - len -= front_len; - ret=true; - } - } - - if (back_len) { - while ((len >= back_len) && strncmp(s+len-back_len,back,back_len)==0) { - s[len-back_len]='\0'; - len -= back_len; - ret=true; - } - } - return ret; -} - -/** - Find the number of 'c' chars in a string -**/ -_PUBLIC_ _PURE_ size_t count_chars(const char *s, char c) -{ - size_t count = 0; - - while (*s) { - if (*s == c) count++; - s ++; - } - - return count; -} - - - -/** - Safe string copy into a known length string. maxlength does not - include the terminating zero. -**/ -_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength) -{ - size_t len; - - if (!dest) { - DEBUG(0,("ERROR: NULL dest in safe_strcpy\n")); - return NULL; - } - -#ifdef DEVELOPER - /* We intentionally write out at the extremity of the destination - * string. If the destination is too short (e.g. pstrcpy into mallocd - * or fstring) then this should cause an error under a memory - * checker. */ - dest[maxlength] = '\0'; - if (PTR_DIFF(&len, dest) > 0) { /* check if destination is on the stack, ok if so */ - log_suspicious_usage("safe_strcpy", src); - } -#endif - - if (!src) { - *dest = 0; - return dest; - } - - len = strlen(src); - - if (len > maxlength) { - DEBUG(0,("ERROR: string overflow by %u (%u - %u) in safe_strcpy [%.50s]\n", - (uint_t)(len-maxlength), (unsigned)len, (unsigned)maxlength, src)); - len = maxlength; - } - - memmove(dest, src, len); - dest[len] = 0; - return dest; -} - -/** - Safe string cat into a string. maxlength does not - include the terminating zero. -**/ -_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength) -{ - size_t src_len, dest_len; - - if (!dest) { - DEBUG(0,("ERROR: NULL dest in safe_strcat\n")); - return NULL; - } - - if (!src) - return dest; - -#ifdef DEVELOPER - if (PTR_DIFF(&src_len, dest) > 0) { /* check if destination is on the stack, ok if so */ - log_suspicious_usage("safe_strcat", src); - } -#endif - src_len = strlen(src); - dest_len = strlen(dest); - - if (src_len + dest_len > maxlength) { - DEBUG(0,("ERROR: string overflow by %d in safe_strcat [%.50s]\n", - (int)(src_len + dest_len - maxlength), src)); - if (maxlength > dest_len) { - memcpy(&dest[dest_len], src, maxlength - dest_len); - } - dest[maxlength] = 0; - return NULL; - } - - memcpy(&dest[dest_len], src, src_len); - dest[dest_len + src_len] = 0; - return dest; -} - -/** - Routine to get hex characters and turn them into a 16 byte array. - the array can be variable length, and any non-hex-numeric - characters are skipped. "0xnn" or "0Xnn" is specially catered - for. - - valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n" - - -**/ -_PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex) -{ - size_t i; - size_t num_chars = 0; - uint8_t lonybble, hinybble; - const char *hexchars = "0123456789ABCDEF"; - char *p1 = NULL, *p2 = NULL; - - for (i = 0; i < len && strhex[i] != 0; i++) { - if (strncasecmp(hexchars, "0x", 2) == 0) { - i++; /* skip two chars */ - continue; - } - - if (!(p1 = strchr(hexchars, toupper((unsigned char)strhex[i])))) - break; - - i++; /* next hex digit */ - - if (!(p2 = strchr(hexchars, toupper((unsigned char)strhex[i])))) - break; - - /* get the two nybbles */ - hinybble = PTR_DIFF(p1, hexchars); - lonybble = PTR_DIFF(p2, hexchars); - - p[num_chars] = (hinybble << 4) | lonybble; - num_chars++; - - p1 = NULL; - p2 = NULL; - } - return num_chars; -} - -/** - * Parse a hex string and return a data blob. - */ -_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex) -{ - DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1); - - ret_blob.length = strhex_to_str((char *)ret_blob.data, - strlen(strhex), - strhex); - - return ret_blob; -} - - -/** - * Routine to print a buffer as HEX digits, into an allocated string. - */ -_PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) -{ - int i; - char *hex_buffer; - - *out_hex_buffer = malloc_array_p(char, (len*2)+1); - hex_buffer = *out_hex_buffer; - - for (i = 0; i < len; i++) - slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); -} - -/** - * talloc version of hex_encode() - */ -_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len) -{ - int i; - char *hex_buffer; - - hex_buffer = talloc_array(mem_ctx, char, (len*2)+1); - - for (i = 0; i < len; i++) - slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); - - return hex_buffer; -} - -/** - Substitute a string for a pattern in another string. Make sure there is - enough room! - - This routine looks for pattern in s and replaces it with - insert. It may do multiple replacements. - - Any of " ; ' $ or ` in the insert string are replaced with _ - if len==0 then the string cannot be extended. This is different from the old - use of len==0 which was for no length checks to be done. -**/ - -_PUBLIC_ void string_sub(char *s, const char *pattern, const char *insert, size_t len) -{ - char *p; - ssize_t ls, lp, li, i; - - if (!insert || !pattern || !*pattern || !s) - return; - - ls = (ssize_t)strlen(s); - lp = (ssize_t)strlen(pattern); - li = (ssize_t)strlen(insert); - - if (len == 0) - len = ls + 1; /* len is number of *bytes* */ - - while (lp <= ls && (p = strstr(s, pattern))) { - if (ls + (li-lp) >= len) { - DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n", - (int)(ls + (li-lp) - len), - pattern, (int)len)); - break; - } - if (li != lp) { - memmove(p+li,p+lp,strlen(p+lp)+1); - } - for (i=0;i= len) { - DEBUG(0,("ERROR: string overflow by %d in all_string_sub(%.50s, %d)\n", - (int)(ls + (li-lp) - len), - pattern, (int)len)); - break; - } - if (li != lp) { - memmove(p+li,p+lp,strlen(p+lp)+1); - } - memcpy(p, insert, li); - s = p + li; - ls += (li-lp); - } -} - - - -/** - Unescape a URL encoded string, in place. -**/ - -_PUBLIC_ void rfc1738_unescape(char *buf) -{ - char *p=buf; - - while ((p=strchr(p,'+'))) - *p = ' '; - - p = buf; - - while (p && *p && (p=strchr(p,'%'))) { - int c1 = p[1]; - int c2 = p[2]; - - if (c1 >= '0' && c1 <= '9') - c1 = c1 - '0'; - else if (c1 >= 'A' && c1 <= 'F') - c1 = 10 + c1 - 'A'; - else if (c1 >= 'a' && c1 <= 'f') - c1 = 10 + c1 - 'a'; - else {p++; continue;} - - if (c2 >= '0' && c2 <= '9') - c2 = c2 - '0'; - else if (c2 >= 'A' && c2 <= 'F') - c2 = 10 + c2 - 'A'; - else if (c2 >= 'a' && c2 <= 'f') - c2 = 10 + c2 - 'a'; - else {p++; continue;} - - *p = (c1<<4) | c2; - - memmove(p+1, p+3, strlen(p+3)+1); - p++; - } -} - -#ifdef VALGRIND -size_t valgrind_strlen(const char *s) -{ - size_t count; - for(count = 0; *s++; count++) - ; - return count; -} -#endif - - -/** - format a string into length-prefixed dotted domain format, as used in NBT - and in some ADS structures -**/ -_PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) -{ - char *ret; - int i; - if (!s || !*s) { - return talloc_strdup(mem_ctx, ""); - } - ret = talloc_array(mem_ctx, char, strlen(s)+2); - if (!ret) { - return ret; - } - - memcpy(ret+1, s, strlen(s)+1); - ret[0] = '.'; - - for (i=0;ret[i];i++) { - if (ret[i] == '.') { - char *p = strchr(ret+i+1, '.'); - if (p) { - ret[i] = p-(ret+i+1); - } else { - ret[i] = strlen(ret+i+1); - } - } - } - - return ret; -} - -/** - * Add a string to an array of strings. - * - * num should be a pointer to an integer that holds the current - * number of elements in strings. It will be updated by this function. - */ -_PUBLIC_ bool add_string_to_array(TALLOC_CTX *mem_ctx, - const char *str, const char ***strings, int *num) -{ - char *dup_str = talloc_strdup(mem_ctx, str); - - *strings = talloc_realloc(mem_ctx, - *strings, - const char *, ((*num)+1)); - - if ((*strings == NULL) || (dup_str == NULL)) - return false; - - (*strings)[*num] = dup_str; - *num += 1; - - return true; -} - - - -/** - varient of strcmp() that handles NULL ptrs -**/ -_PUBLIC_ int strcmp_safe(const char *s1, const char *s2) -{ - if (s1 == s2) { - return 0; - } - if (s1 == NULL || s2 == NULL) { - return s1?-1:1; - } - return strcmp(s1, s2); -} - - -/** -return the number of bytes occupied by a buffer in ASCII format -the result includes the null termination -limited by 'n' bytes -**/ -_PUBLIC_ size_t ascii_len_n(const char *src, size_t n) -{ - size_t len; - - len = strnlen(src, n); - if (len+1 <= n) { - len += 1; - } - - return len; -} - - -/** - Return a string representing a CIFS attribute for a file. -**/ -_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) -{ - int i, len; - const struct { - char c; - uint16_t attr; - } attr_strs[] = { - {'V', FILE_ATTRIBUTE_VOLUME}, - {'D', FILE_ATTRIBUTE_DIRECTORY}, - {'A', FILE_ATTRIBUTE_ARCHIVE}, - {'H', FILE_ATTRIBUTE_HIDDEN}, - {'S', FILE_ATTRIBUTE_SYSTEM}, - {'N', FILE_ATTRIBUTE_NORMAL}, - {'R', FILE_ATTRIBUTE_READONLY}, - {'d', FILE_ATTRIBUTE_DEVICE}, - {'t', FILE_ATTRIBUTE_TEMPORARY}, - {'s', FILE_ATTRIBUTE_SPARSE}, - {'r', FILE_ATTRIBUTE_REPARSE_POINT}, - {'c', FILE_ATTRIBUTE_COMPRESSED}, - {'o', FILE_ATTRIBUTE_OFFLINE}, - {'n', FILE_ATTRIBUTE_NONINDEXED}, - {'e', FILE_ATTRIBUTE_ENCRYPTED} - }; - char *ret; - - ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1); - if (!ret) { - return NULL; - } - - for (len=i=0; i + Copyright (C) 2008 Jelmer Vernooij + + 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" +#include "lib/cmdline/popt_common.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/gen_ndr/ndr_oxidresolver.h" +#include "librpc/gen_ndr/ndr_oxidresolver_c.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/gen_ndr/ndr_dcom_c.h" +#include "librpc/gen_ndr/ndr_remact_c.h" +#include "librpc/gen_ndr/ndr_epmapper_c.h" +#include "librpc/gen_ndr/com_dcom.h" + +#include "lib/com/dcom/dcom.h" +#include "lib/com/com.h" + +#include "lib/wmi/wmi.h" + +struct program_args { + char *hostname; + char *query; + char *ns; +}; + +static void parse_args(int argc, char *argv[], struct program_args *pmyargs) +{ + poptContext pc; + int opt, i; + + int argc_new; + char **argv_new; + + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + {"namespace", 0, POPT_ARG_STRING, &pmyargs->ns, 0, + "WMI namespace, default to root\\cimv2", 0}, + POPT_TABLEEND + }; + + pc = poptGetContext("wmi", argc, (const char **) argv, + long_options, POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, "//host query\n\nExample: wmic -U [domain/]adminuser%password //host \"select * from Win32_ComputerSystem\""); + + while ((opt = poptGetNextOpt(pc)) != -1) { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + argv_new = discard_const_p(char *, poptGetArgs(pc)); + + argc_new = argc; + for (i = 0; i < argc; i++) { + if (argv_new[i] == NULL) { + argc_new = i; + break; + } + } + + if (argc_new != 3 || argv_new[1][0] != '/' + || argv_new[1][1] != '/') { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + pmyargs->hostname = argv_new[1] + 2; + pmyargs->query = argv_new[2]; + poptFreeContext(pc); +} + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(0, ("ERROR: %s\n", msg)); \ + goto error; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } + +#define RETURN_CVAR_ARRAY_STR(fmt, arr) {\ + uint32_t i;\ + char *r;\ +\ + if (!arr) {\ + return talloc_strdup(mem_ctx, "NULL");\ + }\ + r = talloc_strdup(mem_ctx, "(");\ + for (i = 0; i < arr->count; ++i) {\ + r = talloc_asprintf_append(r, fmt "%s", arr->item[i], (i+1 == arr->count)?"":",");\ + }\ + return talloc_asprintf_append(r, ")");\ +} + +char *string_CIMVAR(TALLOC_CTX *mem_ctx, union CIMVAR *v, enum CIMTYPE_ENUMERATION cimtype) +{ + switch (cimtype) { + case CIM_SINT8: return talloc_asprintf(mem_ctx, "%d", v->v_sint8); + case CIM_UINT8: return talloc_asprintf(mem_ctx, "%u", v->v_uint8); + case CIM_SINT16: return talloc_asprintf(mem_ctx, "%d", v->v_sint16); + case CIM_UINT16: return talloc_asprintf(mem_ctx, "%u", v->v_uint16); + case CIM_SINT32: return talloc_asprintf(mem_ctx, "%d", v->v_sint32); + case CIM_UINT32: return talloc_asprintf(mem_ctx, "%u", v->v_uint32); + case CIM_SINT64: return talloc_asprintf(mem_ctx, "%lld", v->v_sint64); + case CIM_UINT64: return talloc_asprintf(mem_ctx, "%llu", v->v_sint64); + case CIM_REAL32: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint32); + case CIM_REAL64: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint64); + case CIM_BOOLEAN: return talloc_asprintf(mem_ctx, "%s", v->v_boolean?"True":"False"); + case CIM_STRING: + case CIM_DATETIME: + case CIM_REFERENCE: return talloc_asprintf(mem_ctx, "%s", v->v_string); + case CIM_CHAR16: return talloc_asprintf(mem_ctx, "Unsupported"); + case CIM_OBJECT: return talloc_asprintf(mem_ctx, "Unsupported"); + case CIM_ARR_SINT8: RETURN_CVAR_ARRAY_STR("%d", v->a_sint8); + case CIM_ARR_UINT8: RETURN_CVAR_ARRAY_STR("%u", v->a_uint8); + case CIM_ARR_SINT16: RETURN_CVAR_ARRAY_STR("%d", v->a_sint16); + case CIM_ARR_UINT16: RETURN_CVAR_ARRAY_STR("%u", v->a_uint16); + case CIM_ARR_SINT32: RETURN_CVAR_ARRAY_STR("%d", v->a_sint32); + case CIM_ARR_UINT32: RETURN_CVAR_ARRAY_STR("%u", v->a_uint32); + case CIM_ARR_SINT64: RETURN_CVAR_ARRAY_STR("%lld", v->a_sint64); + case CIM_ARR_UINT64: RETURN_CVAR_ARRAY_STR("%llu", v->a_uint64); + case CIM_ARR_REAL32: RETURN_CVAR_ARRAY_STR("%f", v->a_real32); + case CIM_ARR_REAL64: RETURN_CVAR_ARRAY_STR("%f", v->a_real64); + case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY_STR("%d", v->a_boolean); + case CIM_ARR_STRING: RETURN_CVAR_ARRAY_STR("%s", v->a_string); + case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY_STR("%s", v->a_datetime); + case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY_STR("%s", v->a_reference); + default: return talloc_asprintf(mem_ctx, "Unsupported"); + } +} + +#undef RETURN_CVAR_ARRAY_STR + +int main(int argc, char **argv) +{ + struct program_args args = {}; + uint32_t cnt = 5, ret; + char *class_name = NULL; + WERROR result; + NTSTATUS status; + struct IWbemServices *pWS = NULL; + struct BSTR queryLanguage, query; + struct IEnumWbemClassObject *pEnum = NULL; + struct com_context *ctx = NULL; + + parse_args(argc, argv, &args); + + wmi_init(&ctx, cmdline_credentials); + + if (!args.ns) + args.ns = "root\\cimv2"; + result = WBEM_ConnectServer(ctx, args.hostname, args.ns, 0, 0, 0, 0, 0, 0, &pWS); + WERR_CHECK("Login to remote object."); + + queryLanguage.data = "WQL"; + query.data = args.query; + result = IWbemServices_ExecQuery(pWS, ctx, queryLanguage, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_ENSURE_LOCATABLE, NULL, &pEnum); + WERR_CHECK("WMI query execute."); + + IEnumWbemClassObject_Reset(pEnum, ctx); + WERR_CHECK("Reset result of WMI query."); + + do { + uint32_t i, j; + struct WbemClassObject *co[cnt]; + + result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, cnt, co, &ret); + /* WERR_BADFUNC is OK, it means only that there is less returned objects than requested */ + if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) { + WERR_CHECK("Retrieve result data."); + } else { + DEBUG(1, ("OK : Retrieved less objects than requested (it is normal).\n")); + } + if (!ret) break; + + for (i = 0; i < ret; ++i) { + if (!class_name || strcmp(co[i]->obj_class->__CLASS, class_name)) { + if (class_name) talloc_free(class_name); + class_name = talloc_strdup(ctx, co[i]->obj_class->__CLASS); + printf("CLASS: %s\n", class_name); + for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j) + printf("%s%s", j?"|":"", co[i]->obj_class->properties[j].property.name); + printf("\n"); + } + for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j) { + char *s; + s = string_CIMVAR(ctx, &co[i]->instance->data[j], co[i]->obj_class->properties[j].property.desc->cimtype & CIM_TYPEMASK); + printf("%s%s", j?"|":"", s); + } + printf("\n"); + } + } while (ret == cnt); + talloc_free(ctx); + return 0; +error: + status = werror_to_ntstatus(result); + fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)); + talloc_free(ctx); + return 1; +} diff --git a/source4/lib/wmi/tools/wmis.c b/source4/lib/wmi/tools/wmis.c new file mode 100644 index 0000000000..314fdd1cd7 --- /dev/null +++ b/source4/lib/wmi/tools/wmis.c @@ -0,0 +1,221 @@ +/* + WMI Sample client + Copyright (C) 2006 Andrzej Hajda + Copyright (C) 2008 Jelmer Vernooij + + 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" +#include "lib/cmdline/popt_common.h" +#include "auth/credentials/credentials.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/gen_ndr/ndr_oxidresolver.h" +#include "librpc/gen_ndr/ndr_oxidresolver_c.h" +#include "librpc/gen_ndr/dcom.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/gen_ndr/ndr_dcom_c.h" +#include "librpc/gen_ndr/ndr_remact_c.h" +#include "librpc/gen_ndr/ndr_epmapper_c.h" +#include "librpc/gen_ndr/com_dcom.h" + +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/com_wmi.h" +#include "librpc/ndr/ndr_table.h" + +#include "lib/wmi/wmi.h" + +struct program_args { + char *hostname; + char *query; +}; + +static void parse_args(int argc, char *argv[], struct program_args *pmyargs) +{ + poptContext pc; + int opt, i; + + int argc_new; + char **argv_new; + + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + POPT_TABLEEND + }; + + pc = poptGetContext("wmi", argc, (const char **) argv, + long_options, POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, "//host\n\nExample: wmis -U [domain/]adminuser%password //host"); + + while ((opt = poptGetNextOpt(pc)) != -1) { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + argv_new = discard_const_p(char *, poptGetArgs(pc)); + + argc_new = argc; + for (i = 0; i < argc; i++) { + if (argv_new[i] == NULL) { + argc_new = i; + break; + } + } + + if (argc_new < 2 || argv_new[1][0] != '/' + || argv_new[1][1] != '/') { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + pmyargs->hostname = argv_new[1] + 2; + poptFreeContext(pc); +} + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(0, ("ERROR: %s\n", msg)); \ + goto error; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } +/* +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services) +{ + struct GUID clsid; + struct GUID iid; + WERROR result, coresult; + struct IUnknown **mqi; + struct IWbemLevel1Login *pL; + + if (user) { + char *cred; + struct cli_credentials *cc; + + cred = talloc_asprintf(NULL, "%s%%%s", user, password); + cc = cli_credentials_init(ctx); + cli_credentials_set_conf(cc); + cli_credentials_parse_string(cc, cred, CRED_SPECIFIED); + dcom_set_server_credentials(ctx, server, cc); + talloc_free(cred); + } + + GUID_from_string(CLSID_WBEMLEVEL1LOGIN, &clsid); + GUID_from_string(COM_IWBEMLEVEL1LOGIN_UUID, &iid); + result = dcom_create_object(ctx, &clsid, server, 1, &iid, &mqi, &coresult); + WERR_CHECK("dcom_create_object."); + result = coresult; + WERR_CHECK("Create remote WMI object."); + pL = (struct IWbemLevel1Login *)mqi[0]; + talloc_free(mqi); + + result = IWbemLevel1Login_NTLMLogin(pL, ctx, nspace, locale, flags, wbem_ctx, services); + WERR_CHECK("Login to remote object."); +error: + return result; +} +*/ +WERROR WBEM_RemoteExecute(struct IWbemServices *pWS, const char *cmdline, uint32_t *ret_code) +{ + struct IWbemClassObject *wco = NULL; + struct IWbemClassObject *inc, *outc, *in; + struct IWbemClassObject *out = NULL; + WERROR result; + union CIMVAR v; + TALLOC_CTX *ctx; + struct BSTR objectPath, methodName; + + ctx = talloc_new(0); + + objectPath.data = "Win32_Process"; + + result = IWbemServices_GetObject(pWS, ctx, objectPath, + WBEM_FLAG_RETURN_WBEM_COMPLETE, NULL, &wco, NULL); + WERR_CHECK("GetObject."); + + result = IWbemClassObject_GetMethod(wco, ctx, "Create", 0, &inc, &outc); + WERR_CHECK("IWbemClassObject_GetMethod."); + + result = IWbemClassObject_SpawnInstance(inc, ctx, 0, &in); + WERR_CHECK("IWbemClassObject_SpawnInstance."); + + v.v_string = cmdline; + result = IWbemClassObject_Put(in, ctx, "CommandLine", 0, &v, 0); + WERR_CHECK("IWbemClassObject_Put(CommandLine)."); + + methodName.data = "Create"; + result = IWbemServices_ExecMethod(pWS, ctx, objectPath, methodName, 0, NULL, in, &out, + NULL); + WERR_CHECK("IWbemServices_ExecMethod."); + + if (ret_code) { + result = WbemClassObject_Get(out->object_data, ctx, "ReturnValue", 0, &v, 0, 0); + WERR_CHECK("IWbemClassObject_Put(CommandLine)."); + *ret_code = v.v_uint32; + } +error: + talloc_free(ctx); + return result; +} + +int main(int argc, char **argv) +{ + struct program_args args = {}; + struct com_context *ctx = NULL; + WERROR result; + NTSTATUS status; + struct IWbemServices *pWS = NULL; + struct IEnumWbemClassObject *pEnum = NULL; + uint32_t cnt; + struct BSTR queryLanguage; + struct BSTR query; + + parse_args(argc, argv, &args); + + wmi_init(&ctx, cmdline_credentials); + result = WBEM_ConnectServer(ctx, args.hostname, "root\\cimv2", 0, 0, 0, 0, 0, 0, &pWS); + WERR_CHECK("WBEM_ConnectServer."); + + printf("1: Creating directory C:\\wmi_test_dir_tmp using method Win32_Process.Create\n"); + WBEM_RemoteExecute(pWS, "cmd.exe /C mkdir C:\\wmi_test_dir_tmp", &cnt); + WERR_CHECK("WBEM_RemoteExecute."); + printf("2: ReturnCode: %d\n", cnt); + + printf("3: Monitoring directory C:\\wmi_test_dir_tmp. Please create/delete files in that directory to see notifications, after 4 events program quits.\n"); + query.data = "SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=\"C:\\\\\\\\wmi_test_dir_tmp\"'"; + queryLanguage.data = "WQL"; + result = IWbemServices_ExecNotificationQuery(pWS, ctx, queryLanguage, + query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum); + WERR_CHECK("WMI query execute."); + for (cnt = 0; cnt < 4; ++cnt) { + struct WbemClassObject *co; + uint32_t ret; + result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, 1, &co, &ret); + WERR_CHECK("IEnumWbemClassObject_Next."); + printf("%s\n", co->obj_class->__CLASS); + } + +error: + status = werror_to_ntstatus(result); + fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)); + talloc_free(ctx); + return 1; +} diff --git a/source4/lib/wmi/wbemdata.c b/source4/lib/wmi/wbemdata.c new file mode 100644 index 0000000000..57e4022e7c --- /dev/null +++ b/source4/lib/wmi/wbemdata.c @@ -0,0 +1,451 @@ +/* + WMI Implementation + Copyright (C) 2006 Andrzej Hajda + Copyright (C) 2008 Jelmer Vernooij + + 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" +#include "librpc/gen_ndr/dcom.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "librpc/ndr/libndr.h" +#include "librpc/ndr/libndr_proto.h" +#include "lib/com/com.h" +#include "lib/com/dcom/dcom.h" +#include "lib/util/dlinklist.h" +#include "librpc/ndr/libndr.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/gen_ndr/ndr_misc.h" +#include "lib/talloc/talloc.h" +#include "libcli/composite/composite.h" +#include "lib/wmi/wmi.h" +#include "librpc/gen_ndr/ndr_wmi.h" + +enum { + DATATYPE_CLASSOBJECT = 2, + DATATYPE_OBJECT = 3, + COFLAG_IS_CLASS = 4, +}; + +static enum ndr_err_code marshal(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struct OBJREF *o) +{ + struct ndr_push *ndr; + struct IWbemClassObject *wco; + struct MInterfacePointer *mp; + + mp = (struct MInterfacePointer *)((char *)o - offsetof(struct MInterfacePointer, obj)); /* FIXME:high remove this Mumbo Jumbo */ + wco = pv->object_data; + ndr = talloc_zero(mem_ctx, struct ndr_push); + ndr->flags = 0; + ndr->alloc_size = 1024; + ndr->data = talloc_array(mp, uint8_t, ndr->alloc_size); + + if (wco) { + uint32_t ofs; + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x12345678)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_IWbemClassObject(ndr, NDR_SCALARS | NDR_BUFFERS, wco)); + ofs = ndr->offset; + ndr->offset = 4; + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ofs - 8)); + ndr->offset = ofs; + } else { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + } + o->u_objref.u_custom.pData = talloc_realloc(mp, ndr->data, uint8_t, ndr->offset); + o->u_objref.u_custom.size = ndr->offset; + mp->size = sizeof(struct OBJREF) - sizeof(union OBJREF_Types) + sizeof(struct u_custom) + o->u_objref.u_custom.size - 4; + if (DEBUGLVL(9)) { + NDR_PRINT_DEBUG(IWbemClassObject, wco); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code unmarshal(TALLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown **pv) +{ + struct ndr_pull *ndr; + struct IWbemClassObject *wco; + enum ndr_err_code ndr_err; + uint32_t u; + + mem_ctx = talloc_new(0); + ndr = talloc_zero(mem_ctx, struct ndr_pull); + ndr->current_mem_ctx = mem_ctx; + ndr->data = o->u_objref.u_custom.pData; + ndr->data_size = o->u_objref.u_custom.size; + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + if (!u) { + talloc_free(*pv); + *pv = NULL; + return NDR_ERR_SUCCESS; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + if (u + 8 > ndr->data_size) { + DEBUG(1, ("unmarshall_IWbemClassObject: Incorrect data_size")); + return NDR_ERR_BUFSIZE; + } + wco = talloc_zero(*pv, struct IWbemClassObject); + ndr->current_mem_ctx = wco; + ndr_err = ndr_pull_IWbemClassObject(ndr, NDR_SCALARS | NDR_BUFFERS, wco); + + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err) && (DEBUGLVL(9))) { + NDR_PRINT_DEBUG(IWbemClassObject, wco); + } + + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + (*pv)->object_data = wco; + } else { + talloc_free(wco); + } + return NDR_ERR_SUCCESS; +} + +WERROR dcom_IWbemClassObject_from_WbemClassObject(struct com_context *ctx, struct IWbemClassObject **_p, struct IWbemClassObject *wco) +{ + struct IWbemClassObject *p; + + p = talloc_zero(ctx, struct IWbemClassObject); + p->ctx = ctx; + p->obj.signature = 0x574f454d; + p->obj.flags = OBJREF_CUSTOM; + GUID_from_string("dc12a681-737f-11cf-884d-00aa004b2e24", &p->obj.iid); + GUID_from_string("4590f812-1d3a-11d0-891f-00aa004b2e24", &p->obj.u_objref.u_custom.clsid); + p->object_data = (void *)wco; + talloc_steal(p, p->object_data); + *_p = p; + return WERR_OK; +} + +WERROR IWbemClassObject_GetMethod(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, struct IWbemClassObject **in, struct IWbemClassObject **out) +{ + uint32_t i; + struct IWbemClassObject *wco; + + wco = (struct IWbemClassObject *)d->object_data; + for (i = 0; i < wco->obj_methods->count; ++i) + if (!strcmp(wco->obj_methods->method[i].name, name)) { + if (in) dcom_IWbemClassObject_from_WbemClassObject(d->ctx, in, wco->obj_methods->method[i].in); + if (out) dcom_IWbemClassObject_from_WbemClassObject(d->ctx, out, wco->obj_methods->method[i].out); + return WERR_OK; + } + return WERR_NOT_FOUND; +} + +void IWbemClassObject_CreateInstance(struct IWbemClassObject *wco) +{ + uint32_t i; + + wco->instance = talloc_zero(wco, struct WbemInstance); + wco->instance->default_flags = talloc_array(wco->instance, uint8_t, wco->obj_class->__PROPERTY_COUNT); + wco->instance->data = talloc_array(wco->instance, union CIMVAR, wco->obj_class->__PROPERTY_COUNT); + memset(wco->instance->data, 0, sizeof(union CIMVAR) * wco->obj_class->__PROPERTY_COUNT); + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + wco->instance->default_flags[i] = 1; /* FIXME:high resolve this magic */ + } + wco->instance->__CLASS = wco->obj_class->__CLASS; + wco->instance->u2_4 = 4; + wco->instance->u3_1 = 1; +} + +WERROR IWbemClassObject_Clone(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, struct IWbemClassObject **copy) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR IWbemClassObject_SpawnInstance(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, uint32_t flags, struct IWbemClassObject **instance) +{ + struct IWbemClassObject *wco, *nwco; + + wco = (struct IWbemClassObject *)d->object_data; + nwco = talloc_zero(mem_ctx, struct IWbemClassObject); + nwco->flags = WCF_INSTANCE; + nwco->obj_class = wco->obj_class; + IWbemClassObject_CreateInstance(nwco); + dcom_IWbemClassObject_from_WbemClassObject(d->ctx, instance, nwco); + return WERR_OK; +} + +WERROR IWbemClassObject_Get(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION *cimtype, uint32_t *flavor) +{ + uint32_t i; + for (i = 0; i < d->obj_class->__PROPERTY_COUNT; ++i) { + if (!strcmp(d->obj_class->properties[i].property.name, name)) { + duplicate_CIMVAR(mem_ctx, &d->instance->data[i], val, d->obj_class->properties[i].property.desc->cimtype); + if (cimtype != NULL) + *cimtype = d->obj_class->properties[i].property.desc->cimtype; + if (flavor != NULL) + *flavor = 0; /* FIXME:avg implement flavor */ + return WERR_OK; + } + } + return WERR_NOT_FOUND; +} + +WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION cimtype) +{ + struct IWbemClassObject *wco; + uint32_t i; + + wco = (struct IWbemClassObject *)d->object_data; + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + if (!strcmp(wco->obj_class->properties[i].property.name, name)) { + if (cimtype && cimtype != wco->obj_class->properties[i].property.desc->cimtype) return WERR_INVALID_PARAM; + wco->instance->default_flags[i] = 0; + duplicate_CIMVAR(wco->instance, val, &wco->instance->data[i], wco->obj_class->properties[i].property.desc->cimtype); + return WERR_OK; + } + } + return WERR_NOT_FOUND; +} + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(1, ("ERROR: %s - %s\n", msg, wmi_errstr(result))); \ + return result; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } + +struct pair_guid_ptr { + struct GUID guid; + void *ptr; + struct pair_guid_ptr *next, *prev; +}; + +static void *get_ptr_by_guid(struct pair_guid_ptr *list, struct GUID *uuid) +{ + for (; list; list = list->next) { + if (GUID_equal(&list->guid, uuid)) + return list->ptr; + } + return NULL; +} + +static void add_pair_guid_ptr(TALLOC_CTX *mem_ctx, struct pair_guid_ptr **list, struct GUID *uuid, void *ptr) +{ + struct pair_guid_ptr *e; + + e = talloc(mem_ctx, struct pair_guid_ptr); + e->guid = *uuid; + e->ptr = ptr; + talloc_steal(e, ptr); + DLIST_ADD(*list, e); +} + +struct IEnumWbemClassObject_data { + struct GUID guid; + struct IWbemFetchSmartEnum *pFSE; + struct IWbemWCOSmartEnum *pSE; + struct pair_guid_ptr *cache; +}; +#define NDR_CHECK_EXPR(expr) do { if (!(expr)) {\ + DEBUG(0, ("%s(%d): WBEMDATA_ERR(0x%08X): Error parsing(%s)\n", __FILE__, __LINE__, ndr->offset, #expr)); \ + return NDR_ERR_VALIDATE; \ + } \ + } while(0) + +#define NDR_CHECK_CONST(val, exp) NDR_CHECK_EXPR((val) == (exp)) + + +static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t size, struct IEnumWbemClassObject *d, uint32_t uCount, struct IWbemClassObject **apObjects) +{ + struct ndr_pull *ndr; + uint32_t u, i, ofs_next; + uint8_t u8, datatype; + struct GUID guid; + struct IEnumWbemClassObject_data *ecod; + + if (!uCount) + return NDR_ERR_BAD_SWITCH; + + ecod = d->object_data; + + ndr = talloc_zero(mem_ctx, struct ndr_pull); + ndr->current_mem_ctx = d->ctx; + ndr->data = data; + ndr->data_size = size; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, *(const uint32_t *)"WBEM"); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, *(const uint32_t *)"DATA"); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x1A); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 6); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x0); + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u8)); + NDR_CHECK_CONST(u8, 0x01); /* Major Version */ + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u8)); + NDR_CHECK_EXPR(u8 <= 1); /* Minor Version 0 - Win2000, 1 - XP/2003 */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x8); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0xC); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 4); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, uCount); + for (i = 0; i < uCount; ++i) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x9); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 1); + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &datatype)); + ofs_next = ndr->offset + u; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x18); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 16); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &guid)); + switch (datatype) { + case DATATYPE_CLASSOBJECT: + apObjects[i] = talloc_zero(d->ctx, struct IWbemClassObject); + ndr->current_mem_ctx = apObjects[i]; + NDR_CHECK(ndr_pull_WbemClassObject(ndr, NDR_SCALARS|NDR_BUFFERS, apObjects[i])); + ndr->current_mem_ctx = d->ctx; + add_pair_guid_ptr(ecod, &ecod->cache, &guid, apObjects[i]->obj_class); + break; + case DATATYPE_OBJECT: + apObjects[i] = talloc_zero(d->ctx, struct IWbemClassObject); + apObjects[i]->obj_class = get_ptr_by_guid(ecod->cache, &guid); + (void)talloc_reference(apObjects[i], apObjects[i]->obj_class); + ndr->current_mem_ctx = apObjects[i]; + NDR_CHECK(ndr_pull_WbemClassObject_Object(ndr, NDR_SCALARS|NDR_BUFFERS, apObjects[i])); + ndr->current_mem_ctx = d->ctx; + break; + default: + DEBUG(0, ("WBEMDATA_Parse: Data type %d not supported\n", datatype)); + return NDR_ERR_BAD_SWITCH; + } + ndr->offset = ofs_next; + if (DEBUGLVL(9)) { + NDR_PRINT_DEBUG(IWbemClassObject, apObjects[i]); + } + } + return NDR_ERR_SUCCESS; +} + +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct IWbemClassObject **apObjects, uint32_t *puReturned) +{ + WERROR result; + NTSTATUS status; + struct IEnumWbemClassObject_data *ecod; + TALLOC_CTX *loc_ctx; + uint32_t size; + uint8_t *data; + + loc_ctx = talloc_new(0); + ecod = d->object_data; + if (!ecod) { + struct GUID iid; + WERROR coresult; + + d->object_data = ecod = talloc_zero(d, struct IEnumWbemClassObject_data); + GUID_from_string(COM_IWBEMFETCHSMARTENUM_UUID, &iid); + result = dcom_query_interface((struct IUnknown *)d, 5, 1, &iid, (struct IUnknown **)&ecod->pFSE, &coresult); + WERR_CHECK("dcom_query_interface."); + result = coresult; + WERR_CHECK("Retrieve enumerator of result(IWbemFetchSmartEnum)."); + + result = IWbemFetchSmartEnum_Fetch(ecod->pFSE, mem_ctx, &ecod->pSE); + WERR_CHECK("Retrieve enumerator of result(IWbemWCOSmartEnum)."); + + ecod->guid = GUID_random(); + d->vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send; + } + + result = IWbemWCOSmartEnum_Next(ecod->pSE, loc_ctx, &ecod->guid, lTimeout, uCount, puReturned, &size, &data); + if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) { + WERR_CHECK("IWbemWCOSmartEnum_Next."); + } + + if (data) { + NDR_CHECK(WBEMDATA_Parse(mem_ctx, data, size, d, *puReturned, apObjects)); + } + if (!W_ERROR_IS_OK(result)) { + status = werror_to_ntstatus(result); + DEBUG(9, ("dcom_proxy_IEnumWbemClassObject_Next: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status))); + } + talloc_free(loc_ctx); + return result; +} + +struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c, *cr; + struct REMINTERFACEREF iref[3]; + struct dcom_object_exporter *ox; + struct IEnumWbemClassObject_data *ecod; + int n; + + c = composite_create(d->ctx, d->ctx->event_ctx); + if (c == NULL) return NULL; + c->private_data = d; + + ox = object_exporter_by_ip(d->ctx, d); + iref[0].ipid = IUnknown_ipid(d); + iref[0].cPublicRefs = 5; + iref[0].cPrivateRefs = 0; + n = 1; + + ecod = d->object_data; + if (ecod) { + if (ecod->pFSE) { + talloc_steal(d, ecod->pFSE); + iref[n].ipid = IUnknown_ipid(ecod->pFSE); + iref[n].cPublicRefs = 5; + iref[n].cPrivateRefs = 0; + ++n; + } + if (ecod->pSE) { + talloc_steal(d, ecod->pSE); + iref[n].ipid = IUnknown_ipid(ecod->pSE); + iref[n].cPublicRefs = 5; + iref[n].cPrivateRefs = 0; + ++n; + } + } + cr = IRemUnknown_RemRelease_send(ox->rem_unknown, mem_ctx, n, iref); + + composite_continue(c, cr, dcom_release_continue, c); + return c; +} + +NTSTATUS dcom_proxy_IWbemClassObject_init(void) +{ + struct GUID clsid; + GUID_from_string("4590f812-1d3a-11d0-891f-00aa004b2e24", &clsid); + dcom_register_marshal(&clsid, marshal, unmarshal); + +#if 0 + struct IEnumWbemClassObject_vtable *proxy_vtable; + proxy_vtable = (struct IEnumWbemClassObject_vtable *)dcom_proxy_vtable_by_iid((struct GUID *)&dcerpc_table_IEnumWbemClassObject.syntax_id.uuid); + if (proxy_vtable) + proxy_vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send; + else + DEBUG(0, ("WARNING: IEnumWbemClassObject should be initialized before IWbemClassObject.")); +#endif + + return NT_STATUS_OK; +} diff --git a/source4/lib/wmi/wmi.h b/source4/lib/wmi/wmi.h new file mode 100644 index 0000000000..46c9b70cdb --- /dev/null +++ b/source4/lib/wmi/wmi.h @@ -0,0 +1,48 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 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 . +*/ + +#ifndef _WMI_H_ +#define _WMI_H_ + +#include "librpc/gen_ndr/com_wmi.h" + +/* The following definitions come from lib/wmi/wmicore.c */ + + +/** FIXME: Use credentials struct rather than user/password here */ +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, + struct cli_credentials *credentials, + const char *locale, uint32_t flags, const char *authority, + struct IWbemContext* wbem_ctx, struct IWbemServices** services); +const char *wmi_errstr(WERROR werror); + +/* The following definitions come from lib/wmi/wbemdata.c */ + +WERROR IWbemClassObject_GetMethod(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, struct IWbemClassObject **in, struct IWbemClassObject **out); +void WbemClassObject_CreateInstance(struct IWbemClassObject *wco); +WERROR IWbemClassObject_Clone(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, struct IWbemClassObject **copy); +WERROR IWbemClassObject_SpawnInstance(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, uint32_t flags, struct IWbemClassObject **instance); +WERROR IWbemClassObject_Get(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION *cimtype, uint32_t *flavor); +WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION cimtype); +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct IWbemClassObject **apObjects, uint32_t *puReturned); +struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx); + +void wmi_init(struct com_context **ctx, struct cli_credentials *credentials); + +#endif diff --git a/source4/lib/wmi/wmi.i b/source4/lib/wmi/wmi.i new file mode 100644 index 0000000000..2c8bbe517e --- /dev/null +++ b/source4/lib/wmi/wmi.i @@ -0,0 +1,352 @@ +/* + WMI Implementation + Copyright (C) 2006 Andrzej Hajda + Copyright (C) 2008 Jelmer Vernooij + + 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. +*/ + +%module wmi + +%include "typemaps.i" +%include "libcli/util/errors.i" +%import "stdint.i" +%import "lib/talloc/talloc.i" + +%runtime %{ +void push_object(PyObject **stack, PyObject *o) +{ + if ((!*stack) || (*stack == Py_None)) { + *stack = o; + } else { + PyObject *o2, *o3; + if (!PyTuple_Check(*stack)) { + o2 = *stack; + *stack = PyTuple_New(1); + PyTuple_SetItem(*stack,0,o2); + } + o3 = PyTuple_New(1); + PyTuple_SetItem(o3,0,o); + o2 = *stack; + *stack = PySequence_Concat(o2,o3); + Py_DECREF(o2); + Py_DECREF(o3); + } +} +%} + +%{ +#include "includes.h" +#include "librpc/gen_ndr/misc.h" +#include "librpc/rpc/dcerpc.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/wmi/wmi.h" + + +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services); +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout,uint32_t uCount, + struct WbemClassObject **apObjects, uint32_t *puReturned); + +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar); +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco); + +static struct com_context *com_ctx; +static PyObject *ComError; +static PyObject *mod_win32_client; +static PyObject *mod_pywintypes; + +typedef struct IUnknown IUnknown; +typedef struct IWbemServices IWbemServices; +typedef struct IWbemClassObject IWbemClassObject; +typedef struct IEnumWbemClassObject IEnumWbemClassObject; +%} + +%wrapper %{ + +#define RETURN_CVAR_ARRAY(fmt, arr) {\ + PyObject *l, *o;\ + uint32_t i;\ +\ + if (!arr) {\ + Py_INCREF(Py_None);\ + return Py_None;\ + }\ + l = PyList_New(arr->count);\ + if (!l) return NULL;\ + for (i = 0; i < arr->count; ++i) {\ + o = _Py_BuildValue(fmt, arr->item[i]);\ + if (!o) {\ + Py_DECREF(l);\ + return NULL;\ + }\ + PyList_SET_ITEM(l, i, o);\ + }\ + return l;\ +} + +static PyObject *_Py_BuildValue(char *str, ...) +{ + PyObject * result = NULL; + va_list lst; + va_start(lst, str); + if (str && *str == 'I') { + uint32_t value = va_arg(lst, uint32_t); + if (value & 0x80000000) { + result = Py_BuildValue("L", (long)value); + } else { + result = Py_BuildValue("i", value); + } + } else { + result = Py_VaBuildValue(str, lst); + } + va_end(lst); + return result; +} + + +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar) +{ + switch (cimtype) { + case CIM_SINT8: return Py_BuildValue("b", cvar->v_sint8); + case CIM_UINT8: return Py_BuildValue("B", cvar->v_uint8); + case CIM_SINT16: return Py_BuildValue("h", cvar->v_sint16); + case CIM_UINT16: return Py_BuildValue("H", cvar->v_uint16); + case CIM_SINT32: return Py_BuildValue("i", cvar->v_sint32); + case CIM_UINT32: return _Py_BuildValue("I", cvar->v_uint32); + case CIM_SINT64: return Py_BuildValue("L", cvar->v_sint64); + case CIM_UINT64: return Py_BuildValue("K", cvar->v_uint64); + case CIM_REAL32: return Py_BuildValue("f", cvar->v_real32); + case CIM_REAL64: return Py_BuildValue("d", cvar->v_real64); + case CIM_BOOLEAN: return Py_BuildValue("h", cvar->v_boolean); + case CIM_STRING: return Py_BuildValue("s", cvar->v_string); + case CIM_DATETIME: return Py_BuildValue("s", cvar->v_datetime); + case CIM_REFERENCE: return Py_BuildValue("s", cvar->v_reference); + case CIM_OBJECT: return PySWbemObject_FromWbemClassObject(cvar->v_object); + case CIM_ARR_SINT8: RETURN_CVAR_ARRAY("b", cvar->a_sint8); + case CIM_ARR_UINT8: RETURN_CVAR_ARRAY("B", cvar->a_uint8); + case CIM_ARR_SINT16: RETURN_CVAR_ARRAY("h", cvar->a_sint16); + case CIM_ARR_UINT16: RETURN_CVAR_ARRAY("H", cvar->a_uint16); + case CIM_ARR_SINT32: RETURN_CVAR_ARRAY("i", cvar->a_sint32); + case CIM_ARR_UINT32: RETURN_CVAR_ARRAY("I", cvar->a_uint32); + case CIM_ARR_SINT64: RETURN_CVAR_ARRAY("L", cvar->a_sint64); + case CIM_ARR_UINT64: RETURN_CVAR_ARRAY("K", cvar->a_uint64); + case CIM_ARR_REAL32: RETURN_CVAR_ARRAY("f", cvar->a_real32); + case CIM_ARR_REAL64: RETURN_CVAR_ARRAY("d", cvar->a_real64); + case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY("h", cvar->a_boolean); + case CIM_ARR_STRING: RETURN_CVAR_ARRAY("s", cvar->a_string); + case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY("s", cvar->a_datetime); + case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY("s", cvar->a_reference); + default: + { + char *str; + str = talloc_asprintf(NULL, "Unsupported CIMTYPE(0x%04X)", cimtype); + PyErr_SetString(PyExc_RuntimeError, str); + talloc_free(str); + return NULL; + } + } +} + +#undef RETURN_CVAR_ARRAY + +PyObject *PySWbemObject_InitProperites(PyObject *o, struct WbemClassObject *wco) +{ + PyObject *properties; + PyObject *addProp; + uint32_t i; + int32_t r; + PyObject *result; + + result = NULL; + properties = PyObject_GetAttrString(o, "Properties_"); + if (!properties) return NULL; + addProp = PyObject_GetAttrString(properties, "Add"); + if (!addProp) { + Py_DECREF(properties); + return NULL; + } + + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + PyObject *args, *property; + + args = Py_BuildValue("(si)", wco->obj_class->properties[i].property.name, wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK); + if (!args) goto finish; + property = PyObject_CallObject(addProp, args); + Py_DECREF(args); + if (!property) goto finish; + if (wco->flags & WCF_INSTANCE) { + PyObject *value; + + if (wco->instance->default_flags[i] & 1) { + value = Py_None; + Py_INCREF(Py_None); + } else + value = PyObject_FromCVAR(wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK, &wco->instance->data[i]); + if (!value) { + Py_DECREF(property); + goto finish; + } + r = PyObject_SetAttrString(property, "Value", value); + Py_DECREF(value); + if (r == -1) { + PyErr_SetString(PyExc_RuntimeError, "Error setting value of property"); + goto finish; + } + } + Py_DECREF(property); + } + + Py_INCREF(Py_None); + result = Py_None; +finish: + Py_DECREF(addProp); + Py_DECREF(properties); + return result; +} + +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco) +{ + PyObject *swo_class, *swo, *args, *result; + + swo_class = PyObject_GetAttrString(mod_win32_client, "SWbemObject"); + if (!swo_class) return NULL; + args = PyTuple_New(0); + if (!args) { + Py_DECREF(swo_class); + return NULL; + } + swo = PyObject_CallObject(swo_class, args); + Py_DECREF(args); + Py_DECREF(swo_class); + if (!swo) return NULL; + + result = PySWbemObject_InitProperites(swo, wco); + if (!result) { + Py_DECREF(swo); + return NULL; + } + Py_DECREF(result); + + return swo; +} + +%} + +%typemap(in, numinputs=0) struct com_context *ctx { + $1 = com_ctx; +} + +%typemap(in, numinputs=0) struct IWbemServices **services (struct IWbemServices *temp) { + $1 = &temp; +} + +%typemap(argout) struct IWbemServices **services { + PyObject *o; + o = SWIG_NewPointerObj(*$1, SWIGTYPE_p_IWbemServices, 0); + push_object(&$result, o); +} + +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services); + +%typemap(in, numinputs=0) struct IEnumWbemClassObject **ppEnum (struct IEnumWbemClassObject *temp) { + $1 = &temp; +} + +%typemap(argout) struct IEnumWbemClassObject **ppEnum { + PyObject *o; + o = SWIG_NewPointerObj(*$1, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&$result, o); +} + +typedef struct IUnknown { + %extend { + uint32_t Release(TALLOC_CTX *mem_ctx); + } +} IUnknown; + +%typemap(in) struct BSTR { + $1.data = PyString_AsString($input); +} + + +typedef struct IWbemServices { + %extend { + WERROR ExecQuery(TALLOC_CTX *mem_ctx, struct BSTR strQueryLanguage, struct BSTR strQuery, int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum); + WERROR ExecNotificationQuery(TALLOC_CTX *mem_ctx, struct BSTR strQueryLanguage, struct BSTR strQuery, int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum); + WERROR CreateInstanceEnum(TALLOC_CTX *mem_ctx, struct BSTR strClass, + int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum); + } +} IWbemServices; + +typedef struct IEnumWbemClassObject { + %extend { + WERROR Reset(TALLOC_CTX *mem_ctx); + } +} IEnumWbemClassObject; + +%typemap(in, numinputs=1) (uint32_t uCount, struct WbemClassObject **apObjects, uint32_t *puReturned) (uint32_t uReturned) { + if (PyLong_Check($input)) + $1 = PyLong_AsUnsignedLong($input); + else if (PyInt_Check($input)) + $1 = PyInt_AsLong($input); + else { + PyErr_SetString(PyExc_TypeError,"Expected a long or an int"); + return NULL; + } + $2 = talloc_array(NULL, struct WbemClassObject *, $1); + $3 = &uReturned; +} + +%typemap(argout) (struct WbemClassObject **apObjects, uint32_t *puReturned) { + uint32_t i; + PyObject *o; + int32_t error; + + error = 0; + + $result = PyTuple_New(*$2); + for (i = 0; i < *$2; ++i) { + if (!error) { + o = PySWbemObject_FromWbemClassObject($1[i]); + if (!o) + --error; + else + error = PyTuple_SetItem($result, i, o); + } + talloc_free($1[i]); + } + talloc_free($1); + if (error) return NULL; +} + +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, + struct WbemClassObject **apObjects, uint32_t *puReturned); + +%init %{ + + mod_win32_client = PyImport_ImportModule("win32com.client"); + mod_pywintypes = PyImport_ImportModule("pywintypes"); + ComError = PyObject_GetAttrString(mod_pywintypes, "com_error"); + + wmi_init(&com_ctx, NULL); + { + PyObject *pModule; + + pModule = PyImport_ImportModule( "win32com.client" ); + } +%} diff --git a/source4/lib/wmi/wmi.py b/source4/lib/wmi/wmi.py new file mode 100644 index 0000000000..4bc59cfe41 --- /dev/null +++ b/source4/lib/wmi/wmi.py @@ -0,0 +1,95 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.36 +# +# Don't modify this file, modify the SWIG interface instead. + +import _wmi +import new +new_instancemethod = new.instancemethod +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'PySwigObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +def _swig_setattr_nondynamic_method(set): + def set_attr(self,name,value): + if (name == "thisown"): return self.this.own(value) + if hasattr(self,name) or (name == "this"): + set(self,name,value) + else: + raise AttributeError("You cannot add attributes to %s" % self) + return set_attr + + +WBEM_ConnectServer = _wmi.WBEM_ConnectServer +class IUnknown(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + __repr__ = _swig_repr + def __init__(self, *args, **kwargs): + _wmi.IUnknown_swiginit(self,_wmi.new_IUnknown(*args, **kwargs)) + __swig_destroy__ = _wmi.delete_IUnknown +IUnknown.Release = new_instancemethod(_wmi.IUnknown_Release,None,IUnknown) +IUnknown_swigregister = _wmi.IUnknown_swigregister +IUnknown_swigregister(IUnknown) + +class IWbemServices(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + __repr__ = _swig_repr + def __init__(self, *args, **kwargs): + _wmi.IWbemServices_swiginit(self,_wmi.new_IWbemServices(*args, **kwargs)) + __swig_destroy__ = _wmi.delete_IWbemServices +IWbemServices.ExecQuery = new_instancemethod(_wmi.IWbemServices_ExecQuery,None,IWbemServices) +IWbemServices.ExecNotificationQuery = new_instancemethod(_wmi.IWbemServices_ExecNotificationQuery,None,IWbemServices) +IWbemServices.CreateInstanceEnum = new_instancemethod(_wmi.IWbemServices_CreateInstanceEnum,None,IWbemServices) +IWbemServices_swigregister = _wmi.IWbemServices_swigregister +IWbemServices_swigregister(IWbemServices) + +class IEnumWbemClassObject(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + __repr__ = _swig_repr + def __init__(self, *args, **kwargs): + _wmi.IEnumWbemClassObject_swiginit(self,_wmi.new_IEnumWbemClassObject(*args, **kwargs)) + __swig_destroy__ = _wmi.delete_IEnumWbemClassObject +IEnumWbemClassObject.Reset = new_instancemethod(_wmi.IEnumWbemClassObject_Reset,None,IEnumWbemClassObject) +IEnumWbemClassObject_swigregister = _wmi.IEnumWbemClassObject_swigregister +IEnumWbemClassObject_swigregister(IEnumWbemClassObject) + +IEnumWbemClassObject_SmartNext = _wmi.IEnumWbemClassObject_SmartNext + + diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/wmi/wmi_wrap.c similarity index 76% rename from source4/lib/tdb/tdb_wrap.c rename to source4/lib/wmi/wmi_wrap.c index 32665d79fd..ee5a8fcb0f 100644 --- a/source4/lib/tdb/tdb_wrap.c +++ b/source4/lib/wmi/wmi_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2472,21 +2478,50 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) +void push_object(PyObject **stack, PyObject *o) +{ + if ((!*stack) || (*stack == Py_None)) { + *stack = o; + } else { + PyObject *o2, *o3; + if (!PyTuple_Check(*stack)) { + o2 = *stack; + *stack = PyTuple_New(1); + PyTuple_SetItem(*stack,0,o2); + } + o3 = PyTuple_New(1); + PyTuple_SetItem(o3,0,o); + o2 = *stack; + *stack = PySequence_Concat(o2,o3); + Py_DECREF(o2); + Py_DECREF(o3); + } +} + + /* -------- TYPES TABLE (BEGIN) -------- */ -#define SWIGTYPE_p_TDB_DATA swig_types[0] -#define SWIGTYPE_p_char swig_types[1] -#define SWIGTYPE_p_int swig_types[2] -#define SWIGTYPE_p_long_long swig_types[3] -#define SWIGTYPE_p_short swig_types[4] -#define SWIGTYPE_p_signed_char swig_types[5] -#define SWIGTYPE_p_tdb_context swig_types[6] -#define SWIGTYPE_p_unsigned_char swig_types[7] -#define SWIGTYPE_p_unsigned_int swig_types[8] -#define SWIGTYPE_p_unsigned_long_long swig_types[9] -#define SWIGTYPE_p_unsigned_short swig_types[10] -static swig_type_info *swig_types[12]; -static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; +#define SWIGTYPE_p_BSTR swig_types[0] +#define SWIGTYPE_p_IEnumWbemClassObject swig_types[1] +#define SWIGTYPE_p_IUnknown swig_types[2] +#define SWIGTYPE_p_IWbemContext swig_types[3] +#define SWIGTYPE_p_IWbemServices swig_types[4] +#define SWIGTYPE_p_TALLOC_CTX swig_types[5] +#define SWIGTYPE_p_char swig_types[6] +#define SWIGTYPE_p_com_context swig_types[7] +#define SWIGTYPE_p_int swig_types[8] +#define SWIGTYPE_p_long_long swig_types[9] +#define SWIGTYPE_p_p_IEnumWbemClassObject swig_types[10] +#define SWIGTYPE_p_p_IWbemServices swig_types[11] +#define SWIGTYPE_p_p_WbemClassObject swig_types[12] +#define SWIGTYPE_p_short swig_types[13] +#define SWIGTYPE_p_signed_char swig_types[14] +#define SWIGTYPE_p_unsigned_char swig_types[15] +#define SWIGTYPE_p_unsigned_int swig_types[16] +#define SWIGTYPE_p_unsigned_long_long swig_types[17] +#define SWIGTYPE_p_unsigned_short swig_types[18] +static swig_type_info *swig_types[20]; +static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2512,13 +2547,13 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; #define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- - @(target):= _tdb.so + @(target):= _wmi.so ------------------------------------------------*/ -#define SWIG_init init_tdb +#define SWIG_init init_wmi -#define SWIG_name "_tdb" +#define SWIG_name "_wmi" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2526,31 +2561,34 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) +#include "libcli/util/pyerrors.h" -/* This symbol is used in both includes.h and Python.h which causes an - annoying compiler warning. */ - -#ifdef HAVE_FSTAT -#undef HAVE_FSTAT -#endif -/* Include tdb headers */ -#include -#include -#include -#include +#include "includes.h" +#include "librpc/gen_ndr/misc.h" +#include "librpc/rpc/dcerpc.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/wmi/wmi.h" -typedef TDB_CONTEXT tdb; +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services); +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout,uint32_t uCount, + struct WbemClassObject **apObjects, uint32_t *puReturned); - #define SWIG_From_long PyInt_FromLong +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar); +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco); +static struct com_context *com_ctx; +static PyObject *ComError; +static PyObject *mod_win32_client; +static PyObject *mod_pywintypes; -SWIGINTERNINLINE PyObject * -SWIG_From_int (int value) -{ - return SWIG_From_long (value); -} +typedef struct IUnknown IUnknown; +typedef struct IWbemServices IWbemServices; +typedef struct IWbemClassObject IWbemClassObject; +typedef struct IEnumWbemClassObject IEnumWbemClassObject; SWIGINTERN swig_type_info* @@ -2711,6 +2749,84 @@ SWIG_CanCastAsInteger(double *d, double min, double max) { } +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_int (unsigned int value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + SWIGINTERN int SWIG_AsVal_long (PyObject *obj, long* val) { @@ -2765,472 +2881,508 @@ SWIG_AsVal_int (PyObject * obj, int *val) return res; } -SWIGINTERN tdb *new_tdb(char const *name,int hash_size,int tdb_flags,int flags,mode_t mode){ - return tdb_open(name, hash_size, tdb_flags, flags, mode); - } -SWIGINTERN void delete_tdb(tdb *self){ tdb_close(self); } +#ifdef __cplusplus +extern "C" { +#endif -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char* carray, size_t size) + +#define RETURN_CVAR_ARRAY(fmt, arr) {\ + PyObject *l, *o;\ + uint32_t i;\ +\ + if (!arr) {\ + Py_INCREF(Py_None);\ + return Py_None;\ + }\ + l = PyList_New(arr->count);\ + if (!l) return NULL;\ + for (i = 0; i < arr->count; ++i) {\ + o = _Py_BuildValue(fmt, arr->item[i]);\ + if (!o) {\ + Py_DECREF(l);\ + return NULL;\ + }\ + PyList_SET_ITEM(l, i, o);\ + }\ + return l;\ +} + +static PyObject *_Py_BuildValue(char *str, ...) { - if (carray) { - if (size > INT_MAX) { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { - return PyString_FromStringAndSize(carray, (int)(size)); - } - } else { - return SWIG_Py_Void(); - } + PyObject * result = NULL; + va_list lst; + va_start(lst, str); + if (str && *str == 'I') { + uint32_t value = va_arg(lst, uint32_t); + if (value & 0x80000000) { + result = Py_BuildValue("L", (long)value); + } else { + result = Py_BuildValue("i", value); + } + } else { + result = Py_VaBuildValue(str, lst); + } + va_end(lst); + return result; } -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtr(const char *cptr) -{ - return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar) +{ + switch (cimtype) { + case CIM_SINT8: return Py_BuildValue("b", cvar->v_sint8); + case CIM_UINT8: return Py_BuildValue("B", cvar->v_uint8); + case CIM_SINT16: return Py_BuildValue("h", cvar->v_sint16); + case CIM_UINT16: return Py_BuildValue("H", cvar->v_uint16); + case CIM_SINT32: return Py_BuildValue("i", cvar->v_sint32); + case CIM_UINT32: return _Py_BuildValue("I", cvar->v_uint32); + case CIM_SINT64: return Py_BuildValue("L", cvar->v_sint64); + case CIM_UINT64: return Py_BuildValue("K", cvar->v_uint64); + case CIM_REAL32: return Py_BuildValue("f", cvar->v_real32); + case CIM_REAL64: return Py_BuildValue("d", cvar->v_real64); + case CIM_BOOLEAN: return Py_BuildValue("h", cvar->v_boolean); + case CIM_STRING: return Py_BuildValue("s", cvar->v_string); + case CIM_DATETIME: return Py_BuildValue("s", cvar->v_datetime); + case CIM_REFERENCE: return Py_BuildValue("s", cvar->v_reference); + case CIM_OBJECT: return PySWbemObject_FromWbemClassObject(cvar->v_object); + case CIM_ARR_SINT8: RETURN_CVAR_ARRAY("b", cvar->a_sint8); + case CIM_ARR_UINT8: RETURN_CVAR_ARRAY("B", cvar->a_uint8); + case CIM_ARR_SINT16: RETURN_CVAR_ARRAY("h", cvar->a_sint16); + case CIM_ARR_UINT16: RETURN_CVAR_ARRAY("H", cvar->a_uint16); + case CIM_ARR_SINT32: RETURN_CVAR_ARRAY("i", cvar->a_sint32); + case CIM_ARR_UINT32: RETURN_CVAR_ARRAY("I", cvar->a_uint32); + case CIM_ARR_SINT64: RETURN_CVAR_ARRAY("L", cvar->a_sint64); + case CIM_ARR_UINT64: RETURN_CVAR_ARRAY("K", cvar->a_uint64); + case CIM_ARR_REAL32: RETURN_CVAR_ARRAY("f", cvar->a_real32); + case CIM_ARR_REAL64: RETURN_CVAR_ARRAY("d", cvar->a_real64); + case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY("h", cvar->a_boolean); + case CIM_ARR_STRING: RETURN_CVAR_ARRAY("s", cvar->a_string); + case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY("s", cvar->a_datetime); + case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY("s", cvar->a_reference); + default: + { + char *str; + str = talloc_asprintf(NULL, "Unsupported CIMTYPE(0x%04X)", cimtype); + PyErr_SetString(PyExc_RuntimeError, str); + talloc_free(str); + return NULL; + } + } } +#undef RETURN_CVAR_ARRAY -SWIGINTERNINLINE PyObject* -SWIG_From_unsigned_SS_long (unsigned long value) +PyObject *PySWbemObject_InitProperites(PyObject *o, struct WbemClassObject *wco) { - return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); + PyObject *properties; + PyObject *addProp; + uint32_t i; + int32_t r; + PyObject *result; + + result = NULL; + properties = PyObject_GetAttrString(o, "Properties_"); + if (!properties) return NULL; + addProp = PyObject_GetAttrString(properties, "Add"); + if (!addProp) { + Py_DECREF(properties); + return NULL; + } + + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + PyObject *args, *property; + + args = Py_BuildValue("(si)", wco->obj_class->properties[i].property.name, wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK); + if (!args) goto finish; + property = PyObject_CallObject(addProp, args); + Py_DECREF(args); + if (!property) goto finish; + if (wco->flags & WCF_INSTANCE) { + PyObject *value; + + if (wco->instance->default_flags[i] & 1) { + value = Py_None; + Py_INCREF(Py_None); + } else + value = PyObject_FromCVAR(wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK, &wco->instance->data[i]); + if (!value) { + Py_DECREF(property); + goto finish; + } + r = PyObject_SetAttrString(property, "Value", value); + Py_DECREF(value); + if (r == -1) { + PyErr_SetString(PyExc_RuntimeError, "Error setting value of property"); + goto finish; + } + } + Py_DECREF(property); + } + + Py_INCREF(Py_None); + result = Py_None; +finish: + Py_DECREF(addProp); + Py_DECREF(properties); + return result; } +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco) +{ + PyObject *swo_class, *swo, *args, *result; + + swo_class = PyObject_GetAttrString(mod_win32_client, "SWbemObject"); + if (!swo_class) return NULL; + args = PyTuple_New(0); + if (!args) { + Py_DECREF(swo_class); + return NULL; + } + swo = PyObject_CallObject(swo_class, args); + Py_DECREF(args); + Py_DECREF(swo_class); + if (!swo) return NULL; + + result = PySWbemObject_InitProperites(swo, wco); + if (!result) { + Py_DECREF(swo); + return NULL; + } + Py_DECREF(result); -SWIGINTERNINLINE PyObject * -SWIG_From_size_t (size_t value) -{ - return SWIG_From_unsigned_SS_long ((unsigned long)(value)); + return swo; } -#ifdef __cplusplus -extern "C" { -#endif -SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + +SWIGINTERN PyObject *_wrap_WBEM_ConnectServer(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int arg2 ; - int arg3 ; - int arg4 ; - mode_t arg5 ; - tdb *result = 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - int val5 ; - int ecode5 = 0 ; + struct com_context *arg1 = (struct com_context *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + char *arg6 = (char *) 0 ; + uint32_t arg7 ; + char *arg8 = (char *) 0 ; + struct IWbemContext *arg9 = (struct IWbemContext *) 0 ; + struct IWbemServices **arg10 = (struct IWbemServices **) 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + unsigned int val7 ; + int ecode7 = 0 ; + int res8 ; + char *buf8 = 0 ; + int alloc8 = 0 ; + void *argp9 = 0 ; + int res9 = 0 ; + struct IWbemServices *temp10 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; char * kwnames[] = { - (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "flags",(char *) "mode", NULL + (char *) "server",(char *) "nspace",(char *) "user",(char *) "password",(char *) "locale",(char *) "flags",(char *) "authority",(char *) "wbem_ctx", NULL }; + WERROR result; - arg2 = 0; - arg3 = TDB_DEFAULT; - arg4 = O_RDWR; - arg5 = 0600; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:new_Tdb",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Tdb" "', argument " "1"" of type '" "char const *""'"); + { + arg1 = com_ctx; } - arg1 = (char *)(buf1); - if (obj1) { - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Tdb" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); + { + arg10 = &temp10; } - if (obj2) { - ecode3 = SWIG_AsVal_int(obj2, &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Tdb" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:WBEM_ConnectServer",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "WBEM_ConnectServer" "', argument " "2"" of type '" "char const *""'"); } - if (obj3) { - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Tdb" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "WBEM_ConnectServer" "', argument " "3"" of type '" "char const *""'"); } - if (obj4) { - ecode5 = SWIG_AsVal_int(obj4, &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_Tdb" "', argument " "5"" of type '" "mode_t""'"); - } - arg5 = (mode_t)(val5); + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(obj2, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "WBEM_ConnectServer" "', argument " "4"" of type '" "char const *""'"); } - result = (tdb *)new_tdb((char const *)arg1,arg2,arg3,arg4,arg5); - /* Throw an IOError exception from errno if tdb_open() returns NULL */ - if (result == NULL) { - PyErr_SetFromErrno(PyExc_IOError); + arg4 = (char *)(buf4); + res5 = SWIG_AsCharPtrAndSize(obj3, &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "WBEM_ConnectServer" "', argument " "5"" of type '" "char const *""'"); + } + arg5 = (char *)(buf5); + res6 = SWIG_AsCharPtrAndSize(obj4, &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "WBEM_ConnectServer" "', argument " "6"" of type '" "char const *""'"); + } + arg6 = (char *)(buf6); + ecode7 = SWIG_AsVal_unsigned_SS_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "WBEM_ConnectServer" "', argument " "7"" of type '" "uint32_t""'"); + } + arg7 = (uint32_t)(val7); + res8 = SWIG_AsCharPtrAndSize(obj6, &buf8, NULL, &alloc8); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "WBEM_ConnectServer" "', argument " "8"" of type '" "char const *""'"); + } + arg8 = (char *)(buf8); + res9 = SWIG_ConvertPtr(obj7, &argp9,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "WBEM_ConnectServer" "', argument " "9"" of type '" "struct IWbemContext *""'"); + } + arg9 = (struct IWbemContext *)(argp9); + result = WBEM_ConnectServer(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,arg7,(char const *)arg8,arg9,arg10); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg10, SWIGTYPE_p_IWbemServices, 0); + push_object(&resultobj, o); } - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_tdb_context, 0); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); + if (alloc6 == SWIG_NEWOBJ) free((char*)buf6); + if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return resultobj; fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); + if (alloc6 == SWIG_NEWOBJ) free((char*)buf6); + if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_IUnknown_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - enum TDB_ERROR result; + IUnknown *arg1 = (IUnknown *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + uint32_t result; + arg2 = NULL; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IUnknown, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_error" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IUnknown_Release" "', argument " "1"" of type '" "IUnknown *""'"); } - arg1 = (tdb *)(argp1); - result = (enum TDB_ERROR)tdb_error(arg1); - resultobj = SWIG_From_int((int)(result)); + arg1 = (IUnknown *)(argp1); + result = (uint32_t)IUnknown_Release(arg1,arg2); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_IUnknown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; + IUnknown *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Tdb" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - delete_tdb(arg1); - - resultobj = SWIG_Py_Void(); + if (!SWIG_Python_UnpackTuple(args,"new_IUnknown",0,0,0)) SWIG_fail; + result = (IUnknown *)calloc(1, sizeof(IUnknown)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IUnknown, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_delete_IUnknown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; + IUnknown *arg1 = (IUnknown *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IUnknown, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_close" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IUnknown" "', argument " "1"" of type '" "IUnknown *""'"); } - arg1 = (tdb *)(argp1); - result = (int)tdb_close(arg1); - resultobj = SWIG_From_int((int)(result)); + arg1 = (IUnknown *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA arg2 ; - TDB_DATA arg3 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - char * kwnames[] = { - (char *) "self",(char *) "key",(char *) "new_dbuf", NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_append" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - if (obj1 == Py_None) { - (&arg2)->dsize = 0; - (&arg2)->dptr = NULL; - } else if (!PyString_Check(obj1)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg2)->dsize = PyString_Size(obj1); - (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1); - } - if (obj2 == Py_None) { - (&arg3)->dsize = 0; - (&arg3)->dptr = NULL; - } else if (!PyString_Check(obj2)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg3)->dsize = PyString_Size(obj2); - (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2); - } - result = (int)tdb_append(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; +SWIGINTERN PyObject *IUnknown_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_IUnknown, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); } - -SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - char *result = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_errorstr" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = (char *)tdb_errorstr(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; +SWIGINTERN PyObject *IUnknown_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); } - -SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { +SWIGINTERN PyObject *_wrap_IWbemServices_ExecQuery(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA arg2 ; - TDB_DATA result; + IWbemServices *arg1 = (IWbemServices *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + struct BSTR arg3 ; + struct BSTR arg4 ; + int32_t arg5 ; + struct IWbemContext *arg6 = (struct IWbemContext *) 0 ; + struct IEnumWbemClassObject **arg7 = (struct IEnumWbemClassObject **) 0 ; void *argp1 = 0 ; int res1 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + struct IEnumWbemClassObject *temp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; char * kwnames[] = { - (char *) "self",(char *) "key", NULL + (char *) "self",(char *) "strQueryLanguage",(char *) "strQuery",(char *) "lFlags",(char *) "pCtx", NULL }; + WERROR result; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + arg2 = NULL; + { + arg7 = &temp7; + } + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:IWbemServices_ExecQuery",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_ExecQuery" "', argument " "1"" of type '" "IWbemServices *""'"); } - arg1 = (tdb *)(argp1); - if (obj1 == Py_None) { - (&arg2)->dsize = 0; - (&arg2)->dptr = NULL; - } else if (!PyString_Check(obj1)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg2)->dsize = PyString_Size(obj1); - (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1); + arg1 = (IWbemServices *)(argp1); + { + (&arg3)->data = PyString_AsString(obj1); } - result = tdb_fetch(arg1,arg2); - if ((&result)->dptr == NULL && (&result)->dsize == 0) { - resultobj = Py_None; - } else { - resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize); - free((&result)->dptr); + { + (&arg4)->data = PyString_AsString(obj2); } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA arg2 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - char * kwnames[] = { - (char *) "self",(char *) "key", NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_delete" "', argument " "1"" of type '" "tdb *""'"); + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "IWbemServices_ExecQuery" "', argument " "5"" of type '" "int32_t""'"); + } + arg5 = (int32_t)(val5); + res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IWbemServices_ExecQuery" "', argument " "6"" of type '" "struct IWbemContext *""'"); } - arg1 = (tdb *)(argp1); - if (obj1 == Py_None) { - (&arg2)->dsize = 0; - (&arg2)->dptr = NULL; - } else if (!PyString_Check(obj1)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg2)->dsize = PyString_Size(obj1); - (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1); + arg6 = (struct IWbemContext *)(argp6); + result = IWbemServices_ExecQuery(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&resultobj, o); } - result = (int)tdb_delete(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { +SWIGINTERN PyObject *_wrap_IWbemServices_ExecNotificationQuery(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA arg2 ; - TDB_DATA arg3 ; - int arg4 ; - int result; + IWbemServices *arg1 = (IWbemServices *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + struct BSTR arg3 ; + struct BSTR arg4 ; + int32_t arg5 ; + struct IWbemContext *arg6 = (struct IWbemContext *) 0 ; + struct IEnumWbemClassObject **arg7 = (struct IEnumWbemClassObject **) 0 ; void *argp1 = 0 ; int res1 = 0 ; - int val4 ; - int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + struct IEnumWbemClassObject *temp7 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; char * kwnames[] = { - (char *) "self",(char *) "key",(char *) "dbuf",(char *) "flag", NULL + (char *) "self",(char *) "strQueryLanguage",(char *) "strQuery",(char *) "lFlags",(char *) "pCtx", NULL }; + WERROR result; - arg4 = TDB_REPLACE; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_store" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - if (obj1 == Py_None) { - (&arg2)->dsize = 0; - (&arg2)->dptr = NULL; - } else if (!PyString_Check(obj1)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg2)->dsize = PyString_Size(obj1); - (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1); - } - if (obj2 == Py_None) { - (&arg3)->dsize = 0; - (&arg3)->dptr = NULL; - } else if (!PyString_Check(obj2)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg3)->dsize = PyString_Size(obj2); - (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2); - } - if (obj3) { - ecode4 = SWIG_AsVal_int(obj3, &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Tdb_store" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); + arg2 = NULL; + { + arg7 = &temp7; } - result = (int)tdb_store(arg1,arg2,arg3,arg4); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA arg2 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - char * kwnames[] = { - (char *) "self",(char *) "key", NULL - }; - - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:IWbemServices_ExecNotificationQuery",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_exists" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "1"" of type '" "IWbemServices *""'"); } - arg1 = (tdb *)(argp1); - if (obj1 == Py_None) { - (&arg2)->dsize = 0; - (&arg2)->dptr = NULL; - } else if (!PyString_Check(obj1)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg2)->dsize = PyString_Size(obj1); - (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1); + arg1 = (IWbemServices *)(argp1); + { + (&arg3)->data = PyString_AsString(obj1); } - result = (int)tdb_exists(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_firstkey" "', argument " "1"" of type '" "tdb *""'"); + { + (&arg4)->data = PyString_AsString(obj2); } - arg1 = (tdb *)(argp1); - result = tdb_firstkey(arg1); - if ((&result)->dptr == NULL && (&result)->dsize == 0) { + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "5"" of type '" "int32_t""'"); + } + arg5 = (int32_t)(val5); + res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "6"" of type '" "struct IWbemContext *""'"); + } + arg6 = (struct IWbemContext *)(argp6); + result = IWbemServices_ExecNotificationQuery(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { resultobj = Py_None; - } else { - resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize); - free((&result)->dptr); + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&resultobj, o); } return resultobj; fail: @@ -3238,517 +3390,376 @@ fail: } -SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { +SWIGINTERN PyObject *_wrap_IWbemServices_CreateInstanceEnum(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - TDB_DATA arg2 ; - TDB_DATA result; + IWbemServices *arg1 = (IWbemServices *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + struct BSTR arg3 ; + int32_t arg4 ; + struct IWbemContext *arg5 = (struct IWbemContext *) 0 ; + struct IEnumWbemClassObject **arg6 = (struct IEnumWbemClassObject **) 0 ; void *argp1 = 0 ; int res1 = 0 ; + int val4 ; + int ecode4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + struct IEnumWbemClassObject *temp6 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; char * kwnames[] = { - (char *) "self",(char *) "key", NULL + (char *) "self",(char *) "strClass",(char *) "lFlags",(char *) "pCtx", NULL }; + WERROR result; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + arg2 = NULL; + { + arg6 = &temp6; + } + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:IWbemServices_CreateInstanceEnum",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_nextkey" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "1"" of type '" "IWbemServices *""'"); } - arg1 = (tdb *)(argp1); - if (obj1 == Py_None) { - (&arg2)->dsize = 0; - (&arg2)->dptr = NULL; - } else if (!PyString_Check(obj1)) { - PyErr_SetString(PyExc_TypeError, "string arg expected"); - return NULL; - } else { - (&arg2)->dsize = PyString_Size(obj1); - (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1); + arg1 = (IWbemServices *)(argp1); + { + (&arg3)->data = PyString_AsString(obj1); } - result = tdb_nextkey(arg1,arg2); - if ((&result)->dptr == NULL && (&result)->dsize == 0) { - resultobj = Py_None; - } else { - resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize); - free((&result)->dptr); + ecode4 = SWIG_AsVal_int(obj2, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "4"" of type '" "int32_t""'"); + } + arg4 = (int32_t)(val4); + res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "5"" of type '" "struct IWbemContext *""'"); } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_lock_all" "', argument " "1"" of type '" "tdb *""'"); + arg5 = (struct IWbemContext *)(argp5); + result = IWbemServices_CreateInstanceEnum(arg1,arg2,arg3,arg4,arg5,arg6); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; } - arg1 = (tdb *)(argp1); - result = (int)tdb_lockall(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'"); + { + PyObject *o; + o = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&resultobj, o); } - arg1 = (tdb *)(argp1); - result = (int)tdb_unlockall(arg1); - resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_IWbemServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; + IWbemServices *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = (int)tdb_lockall_read(arg1); - resultobj = SWIG_From_int((int)(result)); + if (!SWIG_Python_UnpackTuple(args,"new_IWbemServices",0,0,0)) SWIG_fail; + result = (IWbemServices *)calloc(1, sizeof(IWbemServices)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IWbemServices, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_delete_IWbemServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; + IWbemServices *arg1 = (IWbemServices *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IWbemServices, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IWbemServices" "', argument " "1"" of type '" "IWbemServices *""'"); } - arg1 = (tdb *)(argp1); - result = (int)tdb_unlockall_read(arg1); - resultobj = SWIG_From_int((int)(result)); + arg1 = (IWbemServices *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_reopen" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = (int)tdb_reopen(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; +SWIGINTERN PyObject *IWbemServices_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_IWbemServices, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); } - -SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = (int)tdb_transaction_start(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; +SWIGINTERN PyObject *IWbemServices_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); } - -SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_Reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; + IEnumWbemClassObject *arg1 = (IEnumWbemClassObject *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + WERROR result; + arg2 = NULL; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IEnumWbemClassObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IEnumWbemClassObject_Reset" "', argument " "1"" of type '" "IEnumWbemClassObject *""'"); } - arg1 = (tdb *)(argp1); - result = (int)tdb_transaction_commit(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'"); + arg1 = (IEnumWbemClassObject *)(argp1); + result = IEnumWbemClassObject_Reset(arg1,arg2); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; } - arg1 = (tdb *)(argp1); - result = (int)tdb_transaction_cancel(arg1); - resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_IEnumWbemClassObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; + IEnumWbemClassObject *result = 0 ; - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = (int)tdb_transaction_recover(arg1); - resultobj = SWIG_From_int((int)(result)); + if (!SWIG_Python_UnpackTuple(args,"new_IEnumWbemClassObject",0,0,0)) SWIG_fail; + result = (IEnumWbemClassObject *)calloc(1, sizeof(IEnumWbemClassObject)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IEnumWbemClassObject, SWIG_POINTER_NEW | 0 ); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_delete_IEnumWbemClassObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; + IEnumWbemClassObject *arg1 = (IEnumWbemClassObject *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IEnumWbemClassObject, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_hash_size" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IEnumWbemClassObject" "', argument " "1"" of type '" "IEnumWbemClassObject *""'"); } - arg1 = (tdb *)(argp1); - result = (int)tdb_hash_size(arg1); - resultobj = SWIG_From_int((int)(result)); + arg1 = (IEnumWbemClassObject *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - size_t result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_map_size" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = tdb_map_size(arg1); - resultobj = SWIG_From_size_t((size_t)(result)); - return resultobj; -fail: - return NULL; +SWIGINTERN PyObject *IEnumWbemClassObject_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_IEnumWbemClassObject, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); } - -SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int result; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get_flags" "', argument " "1"" of type '" "tdb *""'"); - } - arg1 = (tdb *)(argp1); - result = (int)tdb_get_flags(arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; +SWIGINTERN PyObject *IEnumWbemClassObject_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); } - -SWIGINTERN PyObject *_wrap_Tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { +SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_SmartNext(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - int arg2 ; + struct IEnumWbemClassObject *arg1 = (struct IEnumWbemClassObject *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + int32_t arg3 ; + uint32_t arg4 ; + struct WbemClassObject **arg5 = (struct WbemClassObject **) 0 ; + uint32_t *arg6 = (uint32_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + uint32_t uReturned4 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; char * kwnames[] = { - (char *) "self",(char *) "max_dead", NULL + (char *) "d",(char *) "lTimeout",(char *) "uCount", NULL }; + WERROR result; - if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); + arg2 = NULL; + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:IEnumWbemClassObject_SmartNext",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IEnumWbemClassObject, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IEnumWbemClassObject_SmartNext" "', argument " "1"" of type '" "struct IEnumWbemClassObject *""'"); } - arg1 = (tdb *)(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tdb_set_max_dead" "', argument " "2"" of type '" "int""'"); + arg1 = (struct IEnumWbemClassObject *)(argp1); + ecode3 = SWIG_AsVal_int(obj1, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IEnumWbemClassObject_SmartNext" "', argument " "3"" of type '" "int32_t""'"); } - arg2 = (int)(val2); - tdb_set_max_dead(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - tdb *arg1 = (tdb *) 0 ; - char *result = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_name" "', argument " "1"" of type '" "tdb *""'"); + arg3 = (int32_t)(val3); + { + if (PyLong_Check(obj2)) + arg4 = PyLong_AsUnsignedLong(obj2); + else if (PyInt_Check(obj2)) + arg4 = PyInt_AsLong(obj2); + else { + PyErr_SetString(PyExc_TypeError,"Expected a long or an int"); + return NULL; + } + arg5 = talloc_array(NULL, struct WbemClassObject *, arg4); + arg6 = &uReturned4; + } + result = IEnumWbemClassObject_SmartNext(arg1,arg2,arg3,arg4,arg5,arg6); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + uint32_t i; + PyObject *o; + int32_t error; + + error = 0; + + resultobj = PyTuple_New(*arg6); + for (i = 0; i < *arg6; ++i) { + if (!error) { + o = PySWbemObject_FromWbemClassObject(arg5[i]); + if (!o) + --error; + else + error = PyTuple_SetItem(resultobj, i, o); + } + talloc_free(arg5[i]); + } + talloc_free(arg5); + if (error) return NULL; } - arg1 = (tdb *)(argp1); - result = (char *)tdb_name(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } -SWIGINTERN PyObject *Tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *obj; - if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_tdb_context, SWIG_NewClientData(obj)); - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject *Tdb_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - return SWIG_Python_InitShadowInstance(args); -} - static PyMethodDef SwigMethods[] = { - { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, (char *)"\n" - "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n" - "Open a TDB file.\n" - ""}, - { (char *)"Tdb_error", (PyCFunction)_wrap_Tdb_error, METH_O, (char *)"\n" - "S.error() -> int\n" - "Find last error number returned by operation on this TDB.\n" - ""}, - { (char *)"delete_Tdb", (PyCFunction)_wrap_delete_Tdb, METH_O, NULL}, - { (char *)"Tdb_close", (PyCFunction)_wrap_Tdb_close, METH_O, (char *)"\n" - "S.close() -> None\n" - "Close the TDB file.\n" - ""}, - { (char *)"Tdb_append", (PyCFunction) _wrap_Tdb_append, METH_VARARGS | METH_KEYWORDS, NULL}, - { (char *)"Tdb_errorstr", (PyCFunction)_wrap_Tdb_errorstr, METH_O, (char *)"\n" - "S.errorstr() -> errorstring\n" - "Obtain last error message.\n" - ""}, - { (char *)"Tdb_get", (PyCFunction) _wrap_Tdb_get, METH_VARARGS | METH_KEYWORDS, (char *)"\n" - "S.fetch(key) -> value\n" - "Fetch a value.\n" - ""}, - { (char *)"Tdb_delete", (PyCFunction) _wrap_Tdb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n" - "S.delete(key) -> None\n" - "Delete an entry.\n" - ""}, - { (char *)"Tdb_store", (PyCFunction) _wrap_Tdb_store, METH_VARARGS | METH_KEYWORDS, (char *)"\n" - "S.store(key, value, flag=TDB_REPLACE) -> None\n" - "Store an entry.\n" - ""}, - { (char *)"Tdb_exists", (PyCFunction) _wrap_Tdb_exists, METH_VARARGS | METH_KEYWORDS, (char *)"\n" - "S.exists(key) -> bool\n" - "Check whether key exists in this database.\n" - ""}, - { (char *)"Tdb_firstkey", (PyCFunction)_wrap_Tdb_firstkey, METH_O, (char *)"\n" - "S.firstkey() -> data\n" - "Return the first key in this database.\n" - ""}, - { (char *)"Tdb_nextkey", (PyCFunction) _wrap_Tdb_nextkey, METH_VARARGS | METH_KEYWORDS, (char *)"\n" - "S.nextkey(prev) -> data\n" - "Return the next key in this database.\n" - ""}, - { (char *)"Tdb_lock_all", (PyCFunction)_wrap_Tdb_lock_all, METH_O, (char *)"S.lockall() -> bool"}, - { (char *)"Tdb_unlock_all", (PyCFunction)_wrap_Tdb_unlock_all, METH_O, (char *)"S.unlockall() -> bool"}, - { (char *)"Tdb_read_lock_all", (PyCFunction)_wrap_Tdb_read_lock_all, METH_O, NULL}, - { (char *)"Tdb_read_unlock_all", (PyCFunction)_wrap_Tdb_read_unlock_all, METH_O, NULL}, - { (char *)"Tdb_reopen", (PyCFunction)_wrap_Tdb_reopen, METH_O, (char *)"\n" - "S.reopen() -> bool\n" - "Reopen this file.\n" - ""}, - { (char *)"Tdb_transaction_start", (PyCFunction)_wrap_Tdb_transaction_start, METH_O, (char *)"\n" - "S.transaction_start() -> None\n" - "Start a new transaction.\n" - ""}, - { (char *)"Tdb_transaction_commit", (PyCFunction)_wrap_Tdb_transaction_commit, METH_O, (char *)"\n" - "S.transaction_commit() -> None\n" - "Commit the currently active transaction.\n" - ""}, - { (char *)"Tdb_transaction_cancel", (PyCFunction)_wrap_Tdb_transaction_cancel, METH_O, (char *)"\n" - "S.transaction_cancel() -> None\n" - "Cancel the currently active transaction.\n" - ""}, - { (char *)"Tdb_transaction_recover", (PyCFunction)_wrap_Tdb_transaction_recover, METH_O, NULL}, - { (char *)"Tdb_hash_size", (PyCFunction)_wrap_Tdb_hash_size, METH_O, (char *)"S.hash_size() -> int"}, - { (char *)"Tdb_map_size", (PyCFunction)_wrap_Tdb_map_size, METH_O, (char *)"S.map_size() -> int"}, - { (char *)"Tdb_get_flags", (PyCFunction)_wrap_Tdb_get_flags, METH_O, (char *)"S.get_flags() -> int"}, - { (char *)"Tdb_set_max_dead", (PyCFunction) _wrap_Tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, (char *)"S.set_max_dead(int) -> None"}, - { (char *)"Tdb_name", (PyCFunction)_wrap_Tdb_name, METH_O, (char *)"\n" - "S.name() -> path\n" - "Return filename of this TDB file.\n" - ""}, - { (char *)"Tdb_swigregister", Tdb_swigregister, METH_VARARGS, NULL}, - { (char *)"Tdb_swiginit", Tdb_swiginit, METH_VARARGS, NULL}, + { (char *)"WBEM_ConnectServer", (PyCFunction) _wrap_WBEM_ConnectServer, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"IUnknown_Release", (PyCFunction)_wrap_IUnknown_Release, METH_O, NULL}, + { (char *)"new_IUnknown", (PyCFunction)_wrap_new_IUnknown, METH_NOARGS, NULL}, + { (char *)"delete_IUnknown", (PyCFunction)_wrap_delete_IUnknown, METH_O, NULL}, + { (char *)"IUnknown_swigregister", IUnknown_swigregister, METH_VARARGS, NULL}, + { (char *)"IUnknown_swiginit", IUnknown_swiginit, METH_VARARGS, NULL}, + { (char *)"IWbemServices_ExecQuery", (PyCFunction) _wrap_IWbemServices_ExecQuery, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"IWbemServices_ExecNotificationQuery", (PyCFunction) _wrap_IWbemServices_ExecNotificationQuery, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"IWbemServices_CreateInstanceEnum", (PyCFunction) _wrap_IWbemServices_CreateInstanceEnum, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"new_IWbemServices", (PyCFunction)_wrap_new_IWbemServices, METH_NOARGS, NULL}, + { (char *)"delete_IWbemServices", (PyCFunction)_wrap_delete_IWbemServices, METH_O, NULL}, + { (char *)"IWbemServices_swigregister", IWbemServices_swigregister, METH_VARARGS, NULL}, + { (char *)"IWbemServices_swiginit", IWbemServices_swiginit, METH_VARARGS, NULL}, + { (char *)"IEnumWbemClassObject_Reset", (PyCFunction)_wrap_IEnumWbemClassObject_Reset, METH_O, NULL}, + { (char *)"new_IEnumWbemClassObject", (PyCFunction)_wrap_new_IEnumWbemClassObject, METH_NOARGS, NULL}, + { (char *)"delete_IEnumWbemClassObject", (PyCFunction)_wrap_delete_IEnumWbemClassObject, METH_O, NULL}, + { (char *)"IEnumWbemClassObject_swigregister", IEnumWbemClassObject_swigregister, METH_VARARGS, NULL}, + { (char *)"IEnumWbemClassObject_swiginit", IEnumWbemClassObject_swiginit, METH_VARARGS, NULL}, + { (char *)"IEnumWbemClassObject_SmartNext", (PyCFunction) _wrap_IEnumWbemClassObject_SmartNext, METH_VARARGS | METH_KEYWORDS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ -static swig_type_info _swigt__p_TDB_DATA = {"_p_TDB_DATA", "TDB_DATA *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BSTR = {"_p_BSTR", "struct BSTR *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IEnumWbemClassObject = {"_p_IEnumWbemClassObject", "struct IEnumWbemClassObject *|IEnumWbemClassObject *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IUnknown = {"_p_IUnknown", "struct IUnknown *|IUnknown *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IWbemContext = {"_p_IWbemContext", "struct IWbemContext *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IWbemServices = {"_p_IWbemServices", "struct IWbemServices *|IWbemServices *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *|mode_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_com_context = {"_p_com_context", "struct com_context *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_IEnumWbemClassObject = {"_p_p_IEnumWbemClassObject", "struct IEnumWbemClassObject **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_IWbemServices = {"_p_p_IWbemServices", "struct IWbemServices **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_WbemClassObject = {"_p_p_WbemClassObject", "struct WbemClassObject **", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_tdb_context = {"_p_tdb_context", "struct tdb_context *|tdb *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { - &_swigt__p_TDB_DATA, + &_swigt__p_BSTR, + &_swigt__p_IEnumWbemClassObject, + &_swigt__p_IUnknown, + &_swigt__p_IWbemContext, + &_swigt__p_IWbemServices, + &_swigt__p_TALLOC_CTX, &_swigt__p_char, + &_swigt__p_com_context, &_swigt__p_int, &_swigt__p_long_long, + &_swigt__p_p_IEnumWbemClassObject, + &_swigt__p_p_IWbemServices, + &_swigt__p_p_WbemClassObject, &_swigt__p_short, &_swigt__p_signed_char, - &_swigt__p_tdb_context, &_swigt__p_unsigned_char, &_swigt__p_unsigned_int, &_swigt__p_unsigned_long_long, &_swigt__p_unsigned_short, }; -static swig_cast_info _swigc__p_TDB_DATA[] = { {&_swigt__p_TDB_DATA, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BSTR[] = { {&_swigt__p_BSTR, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IEnumWbemClassObject[] = { {&_swigt__p_IEnumWbemClassObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IUnknown[] = { {&_swigt__p_IUnknown, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IWbemContext[] = { {&_swigt__p_IWbemContext, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IWbemServices[] = { {&_swigt__p_IWbemServices, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_com_context[] = { {&_swigt__p_com_context, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_IEnumWbemClassObject[] = { {&_swigt__p_p_IEnumWbemClassObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_IWbemServices[] = { {&_swigt__p_p_IWbemServices, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_WbemClassObject[] = { {&_swigt__p_p_WbemClassObject, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_tdb_context[] = { {&_swigt__p_tdb_context, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { - _swigc__p_TDB_DATA, + _swigc__p_BSTR, + _swigc__p_IEnumWbemClassObject, + _swigc__p_IUnknown, + _swigc__p_IWbemContext, + _swigc__p_IWbemServices, + _swigc__p_TALLOC_CTX, _swigc__p_char, + _swigc__p_com_context, _swigc__p_int, _swigc__p_long_long, + _swigc__p_p_IEnumWbemClassObject, + _swigc__p_p_IWbemServices, + _swigc__p_p_WbemClassObject, _swigc__p_short, _swigc__p_signed_char, - _swigc__p_tdb_context, _swigc__p_unsigned_char, _swigc__p_unsigned_int, _swigc__p_unsigned_long_long, @@ -4282,26 +4293,18 @@ SWIGEXPORT void SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "REPLACE",SWIG_From_int((int)(TDB_REPLACE))); - SWIG_Python_SetConstant(d, "INSERT",SWIG_From_int((int)(TDB_INSERT))); - SWIG_Python_SetConstant(d, "MODIFY",SWIG_From_int((int)(TDB_MODIFY))); - SWIG_Python_SetConstant(d, "DEFAULT",SWIG_From_int((int)(TDB_DEFAULT))); - SWIG_Python_SetConstant(d, "CLEAR_IF_FIRST",SWIG_From_int((int)(TDB_CLEAR_IF_FIRST))); - SWIG_Python_SetConstant(d, "INTERNAL",SWIG_From_int((int)(TDB_INTERNAL))); - SWIG_Python_SetConstant(d, "NOLOCK",SWIG_From_int((int)(TDB_NOLOCK))); - SWIG_Python_SetConstant(d, "NOMMAP",SWIG_From_int((int)(TDB_NOMMAP))); - SWIG_Python_SetConstant(d, "CONVERT",SWIG_From_int((int)(TDB_CONVERT))); - SWIG_Python_SetConstant(d, "BIGENDIAN",SWIG_From_int((int)(TDB_BIGENDIAN))); - SWIG_Python_SetConstant(d, "TDB_SUCCESS",SWIG_From_int((int)(TDB_SUCCESS))); - SWIG_Python_SetConstant(d, "TDB_ERR_CORRUPT",SWIG_From_int((int)(TDB_ERR_CORRUPT))); - SWIG_Python_SetConstant(d, "TDB_ERR_IO",SWIG_From_int((int)(TDB_ERR_IO))); - SWIG_Python_SetConstant(d, "TDB_ERR_LOCK",SWIG_From_int((int)(TDB_ERR_LOCK))); - SWIG_Python_SetConstant(d, "TDB_ERR_OOM",SWIG_From_int((int)(TDB_ERR_OOM))); - SWIG_Python_SetConstant(d, "TDB_ERR_EXISTS",SWIG_From_int((int)(TDB_ERR_EXISTS))); - SWIG_Python_SetConstant(d, "TDB_ERR_NOLOCK",SWIG_From_int((int)(TDB_ERR_NOLOCK))); - SWIG_Python_SetConstant(d, "TDB_ERR_LOCK_TIMEOUT",SWIG_From_int((int)(TDB_ERR_LOCK_TIMEOUT))); - SWIG_Python_SetConstant(d, "TDB_ERR_NOEXIST",SWIG_From_int((int)(TDB_ERR_NOEXIST))); - SWIG_Python_SetConstant(d, "TDB_ERR_EINVAL",SWIG_From_int((int)(TDB_ERR_EINVAL))); - SWIG_Python_SetConstant(d, "TDB_ERR_RDONLY",SWIG_From_int((int)(TDB_ERR_RDONLY))); + + + mod_win32_client = PyImport_ImportModule("win32com.client"); + mod_pywintypes = PyImport_ImportModule("pywintypes"); + ComError = PyObject_GetAttrString(mod_pywintypes, "com_error"); + + wmi_init(&com_ctx, NULL); + { + PyObject *pModule; + + pModule = PyImport_ImportModule( "win32com.client" ); + } + } diff --git a/source4/lib/wmi/wmicore.c b/source4/lib/wmi/wmicore.c new file mode 100644 index 0000000000..3ac6c89292 --- /dev/null +++ b/source4/lib/wmi/wmicore.c @@ -0,0 +1,252 @@ +/* + WMI Sample client + Copyright (C) 2006 Andrzej Hajda + Copyright (C) 2008 Jelmer Vernooij + + 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" +#include "auth/credentials/credentials.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/wmi.h" +#include "librpc/gen_ndr/com_wmi.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/ndr/ndr_table.h" +#include "param/param.h" + +struct IWbemServices; +struct IWbemContext; + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(0, ("ERROR: %s\n", msg)); \ + goto end; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } + +void wmi_init(struct com_context **ctx, struct cli_credentials *credentials) +{ + dcerpc_init(); + ndr_table_init(); + + /* FIXME: Register DCOM proxies? */ + + com_init_ctx(ctx, NULL); + dcom_client_init(*ctx, credentials); +} + +/** FIXME: Use credentials struct rather than user/password here */ +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const uint16_t *nspace, + struct cli_credentials *credentials, + const char *locale, uint32_t flags, const char *authority, + struct IWbemContext* wbem_ctx, struct IWbemServices** services) +{ + struct GUID clsid; + struct GUID iid; + WERROR result, coresult; + struct IUnknown **mqi; + struct IWbemLevel1Login *pL; + + GUID_from_string(CLSID_WBEMLEVEL1LOGIN, &clsid); + GUID_from_string(COM_IWBEMLEVEL1LOGIN_UUID, &iid); + result = dcom_create_object(ctx, &clsid, server, 1, &iid, &mqi, &coresult); + WERR_CHECK("dcom_create_object."); + result = coresult; + WERR_CHECK("Create remote WMI object."); + pL = (struct IWbemLevel1Login *)mqi[0]; + talloc_free(mqi); + + result = IWbemLevel1Login_NTLMLogin(pL, ctx, nspace, locale, flags, wbem_ctx, services); + WERR_CHECK("Login to remote object."); + + IUnknown_Release((struct IUnknown *)pL, ctx); +end: + return result; +} + +struct werror_code_struct { + const char *dos_errstr; + WERROR werror; +}; + +static const struct werror_code_struct wmi_errs[] = +{ + { "RPC_S_CALL_FAILED", W_ERROR(RPC_S_CALL_FAILED) }, + + { "WBEM_NO_ERROR", W_ERROR(WBEM_NO_ERROR) }, + { "WBEM_S_NO_ERROR", W_ERROR(WBEM_S_NO_ERROR) }, + { "WBEM_S_SAME", W_ERROR(WBEM_S_SAME) }, + { "WBEM_S_FALSE", W_ERROR(WBEM_S_FALSE) }, + { "WBEM_S_ALREADY_EXISTS", W_ERROR(WBEM_S_ALREADY_EXISTS) }, + { "WBEM_S_RESET_TO_DEFAULT", W_ERROR(WBEM_S_RESET_TO_DEFAULT) }, + { "WBEM_S_DIFFERENT", W_ERROR(WBEM_S_DIFFERENT) }, + { "WBEM_S_TIMEDOUT", W_ERROR(WBEM_S_TIMEDOUT) }, + { "WBEM_S_NO_MORE_DATA", W_ERROR(WBEM_S_NO_MORE_DATA) }, + { "WBEM_S_OPERATION_CANCELLED", W_ERROR(WBEM_S_OPERATION_CANCELLED) }, + { "WBEM_S_PENDING", W_ERROR(WBEM_S_PENDING) }, + { "WBEM_S_DUPLICATE_OBJECTS", W_ERROR(WBEM_S_DUPLICATE_OBJECTS) }, + { "WBEM_S_ACCESS_DENIED", W_ERROR(WBEM_S_ACCESS_DENIED) }, + { "WBEM_S_PARTIAL_RESULTS", W_ERROR(WBEM_S_PARTIAL_RESULTS) }, + { "WBEM_S_NO_POSTHOOK", W_ERROR(WBEM_S_NO_POSTHOOK) }, + { "WBEM_S_POSTHOOK_WITH_BOTH", W_ERROR(WBEM_S_POSTHOOK_WITH_BOTH) }, + { "WBEM_S_POSTHOOK_WITH_NEW", W_ERROR(WBEM_S_POSTHOOK_WITH_NEW) }, + { "WBEM_S_POSTHOOK_WITH_STATUS", W_ERROR(WBEM_S_POSTHOOK_WITH_STATUS) }, + { "WBEM_S_POSTHOOK_WITH_OLD", W_ERROR(WBEM_S_POSTHOOK_WITH_OLD) }, + { "WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT", W_ERROR(WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT) }, + { "WBEM_S_SOURCE_NOT_AVAILABLE", W_ERROR(WBEM_S_SOURCE_NOT_AVAILABLE) }, + { "WBEM_E_FAILED", W_ERROR(WBEM_E_FAILED) }, + { "WBEM_E_NOT_FOUND", W_ERROR(WBEM_E_NOT_FOUND) }, + { "WBEM_E_ACCESS_DENIED", W_ERROR(WBEM_E_ACCESS_DENIED) }, + { "WBEM_E_PROVIDER_FAILURE", W_ERROR(WBEM_E_PROVIDER_FAILURE) }, + { "WBEM_E_TYPE_MISMATCH", W_ERROR(WBEM_E_TYPE_MISMATCH) }, + { "WBEM_E_OUT_OF_MEMORY", W_ERROR(WBEM_E_OUT_OF_MEMORY) }, + { "WBEM_E_INVALID_CONTEXT", W_ERROR(WBEM_E_INVALID_CONTEXT) }, + { "WBEM_E_INVALID_PARAMETER", W_ERROR(WBEM_E_INVALID_PARAMETER) }, + { "WBEM_E_NOT_AVAILABLE", W_ERROR(WBEM_E_NOT_AVAILABLE) }, + { "WBEM_E_CRITICAL_ERROR", W_ERROR(WBEM_E_CRITICAL_ERROR) }, + { "WBEM_E_INVALID_STREAM", W_ERROR(WBEM_E_INVALID_STREAM) }, + { "WBEM_E_NOT_SUPPORTED", W_ERROR(WBEM_E_NOT_SUPPORTED) }, + { "WBEM_E_INVALID_SUPERCLASS", W_ERROR(WBEM_E_INVALID_SUPERCLASS) }, + { "WBEM_E_INVALID_NAMESPACE", W_ERROR(WBEM_E_INVALID_NAMESPACE) }, + { "WBEM_E_INVALID_OBJECT", W_ERROR(WBEM_E_INVALID_OBJECT) }, + { "WBEM_E_INVALID_CLASS", W_ERROR(WBEM_E_INVALID_CLASS) }, + { "WBEM_E_PROVIDER_NOT_FOUND", W_ERROR(WBEM_E_PROVIDER_NOT_FOUND) }, + { "WBEM_E_INVALID_PROVIDER_REGISTRATION", W_ERROR(WBEM_E_INVALID_PROVIDER_REGISTRATION) }, + { "WBEM_E_PROVIDER_LOAD_FAILURE", W_ERROR(WBEM_E_PROVIDER_LOAD_FAILURE) }, + { "WBEM_E_INITIALIZATION_FAILURE", W_ERROR(WBEM_E_INITIALIZATION_FAILURE) }, + { "WBEM_E_TRANSPORT_FAILURE", W_ERROR(WBEM_E_TRANSPORT_FAILURE) }, + { "WBEM_E_INVALID_OPERATION", W_ERROR(WBEM_E_INVALID_OPERATION) }, + { "WBEM_E_INVALID_QUERY", W_ERROR(WBEM_E_INVALID_QUERY) }, + { "WBEM_E_INVALID_QUERY_TYPE", W_ERROR(WBEM_E_INVALID_QUERY_TYPE) }, + { "WBEM_E_ALREADY_EXISTS", W_ERROR(WBEM_E_ALREADY_EXISTS) }, + { "WBEM_E_OVERRIDE_NOT_ALLOWED", W_ERROR(WBEM_E_OVERRIDE_NOT_ALLOWED) }, + { "WBEM_E_PROPAGATED_QUALIFIER", W_ERROR(WBEM_E_PROPAGATED_QUALIFIER) }, + { "WBEM_E_PROPAGATED_PROPERTY", W_ERROR(WBEM_E_PROPAGATED_PROPERTY) }, + { "WBEM_E_UNEXPECTED", W_ERROR(WBEM_E_UNEXPECTED) }, + { "WBEM_E_ILLEGAL_OPERATION", W_ERROR(WBEM_E_ILLEGAL_OPERATION) }, + { "WBEM_E_CANNOT_BE_KEY", W_ERROR(WBEM_E_CANNOT_BE_KEY) }, + { "WBEM_E_INCOMPLETE_CLASS", W_ERROR(WBEM_E_INCOMPLETE_CLASS) }, + { "WBEM_E_INVALID_SYNTAX", W_ERROR(WBEM_E_INVALID_SYNTAX) }, + { "WBEM_E_NONDECORATED_OBJECT", W_ERROR(WBEM_E_NONDECORATED_OBJECT) }, + { "WBEM_E_READ_ONLY", W_ERROR(WBEM_E_READ_ONLY) }, + { "WBEM_E_PROVIDER_NOT_CAPABLE", W_ERROR(WBEM_E_PROVIDER_NOT_CAPABLE) }, + { "WBEM_E_CLASS_HAS_CHILDREN", W_ERROR(WBEM_E_CLASS_HAS_CHILDREN) }, + { "WBEM_E_CLASS_HAS_INSTANCES", W_ERROR(WBEM_E_CLASS_HAS_INSTANCES) }, + { "WBEM_E_QUERY_NOT_IMPLEMENTED", W_ERROR(WBEM_E_QUERY_NOT_IMPLEMENTED) }, + { "WBEM_E_ILLEGAL_NULL", W_ERROR(WBEM_E_ILLEGAL_NULL) }, + { "WBEM_E_INVALID_QUALIFIER_TYPE", W_ERROR(WBEM_E_INVALID_QUALIFIER_TYPE) }, + { "WBEM_E_INVALID_PROPERTY_TYPE", W_ERROR(WBEM_E_INVALID_PROPERTY_TYPE) }, + { "WBEM_E_VALUE_OUT_OF_RANGE", W_ERROR(WBEM_E_VALUE_OUT_OF_RANGE) }, + { "WBEM_E_CANNOT_BE_SINGLETON", W_ERROR(WBEM_E_CANNOT_BE_SINGLETON) }, + { "WBEM_E_INVALID_CIM_TYPE", W_ERROR(WBEM_E_INVALID_CIM_TYPE) }, + { "WBEM_E_INVALID_METHOD", W_ERROR(WBEM_E_INVALID_METHOD) }, + { "WBEM_E_INVALID_METHOD_PARAMETERS", W_ERROR(WBEM_E_INVALID_METHOD_PARAMETERS) }, + { "WBEM_E_SYSTEM_PROPERTY", W_ERROR(WBEM_E_SYSTEM_PROPERTY) }, + { "WBEM_E_INVALID_PROPERTY", W_ERROR(WBEM_E_INVALID_PROPERTY) }, + { "WBEM_E_CALL_CANCELLED", W_ERROR(WBEM_E_CALL_CANCELLED) }, + { "WBEM_E_SHUTTING_DOWN", W_ERROR(WBEM_E_SHUTTING_DOWN) }, + { "WBEM_E_PROPAGATED_METHOD", W_ERROR(WBEM_E_PROPAGATED_METHOD) }, + { "WBEM_E_UNSUPPORTED_PARAMETER", W_ERROR(WBEM_E_UNSUPPORTED_PARAMETER) }, + { "WBEM_E_MISSING_PARAMETER_ID", W_ERROR(WBEM_E_MISSING_PARAMETER_ID) }, + { "WBEM_E_INVALID_PARAMETER_ID", W_ERROR(WBEM_E_INVALID_PARAMETER_ID) }, + { "WBEM_E_NONCONSECUTIVE_PARAMETER_IDS", W_ERROR(WBEM_E_NONCONSECUTIVE_PARAMETER_IDS) }, + { "WBEM_E_PARAMETER_ID_ON_RETVAL", W_ERROR(WBEM_E_PARAMETER_ID_ON_RETVAL) }, + { "WBEM_E_INVALID_OBJECT_PATH", W_ERROR(WBEM_E_INVALID_OBJECT_PATH) }, + { "WBEM_E_OUT_OF_DISK_SPACE", W_ERROR(WBEM_E_OUT_OF_DISK_SPACE) }, + { "WBEM_E_BUFFER_TOO_SMALL", W_ERROR(WBEM_E_BUFFER_TOO_SMALL) }, + { "WBEM_E_UNSUPPORTED_PUT_EXTENSION", W_ERROR(WBEM_E_UNSUPPORTED_PUT_EXTENSION) }, + { "WBEM_E_UNKNOWN_OBJECT_TYPE", W_ERROR(WBEM_E_UNKNOWN_OBJECT_TYPE) }, + { "WBEM_E_UNKNOWN_PACKET_TYPE", W_ERROR(WBEM_E_UNKNOWN_PACKET_TYPE) }, + { "WBEM_E_MARSHAL_VERSION_MISMATCH", W_ERROR(WBEM_E_MARSHAL_VERSION_MISMATCH) }, + { "WBEM_E_MARSHAL_INVALID_SIGNATURE", W_ERROR(WBEM_E_MARSHAL_INVALID_SIGNATURE) }, + { "WBEM_E_INVALID_QUALIFIER", W_ERROR(WBEM_E_INVALID_QUALIFIER) }, + { "WBEM_E_INVALID_DUPLICATE_PARAMETER", W_ERROR(WBEM_E_INVALID_DUPLICATE_PARAMETER) }, + { "WBEM_E_TOO_MUCH_DATA", W_ERROR(WBEM_E_TOO_MUCH_DATA) }, + { "WBEM_E_SERVER_TOO_BUSY", W_ERROR(WBEM_E_SERVER_TOO_BUSY) }, + { "WBEM_E_INVALID_FLAVOR", W_ERROR(WBEM_E_INVALID_FLAVOR) }, + { "WBEM_E_CIRCULAR_REFERENCE", W_ERROR(WBEM_E_CIRCULAR_REFERENCE) }, + { "WBEM_E_UNSUPPORTED_CLASS_UPDATE", W_ERROR(WBEM_E_UNSUPPORTED_CLASS_UPDATE) }, + { "WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE", W_ERROR(WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE) }, + { "WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE", W_ERROR(WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE) }, + { "WBEM_E_TOO_MANY_PROPERTIES", W_ERROR(WBEM_E_TOO_MANY_PROPERTIES) }, + { "WBEM_E_UPDATE_TYPE_MISMATCH", W_ERROR(WBEM_E_UPDATE_TYPE_MISMATCH) }, + { "WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED", W_ERROR(WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED) }, + { "WBEM_E_UPDATE_PROPAGATED_METHOD", W_ERROR(WBEM_E_UPDATE_PROPAGATED_METHOD) }, + { "WBEM_E_METHOD_NOT_IMPLEMENTED", W_ERROR(WBEM_E_METHOD_NOT_IMPLEMENTED) }, + { "WBEM_E_METHOD_DISABLED", W_ERROR(WBEM_E_METHOD_DISABLED) }, + { "WBEM_E_REFRESHER_BUSY", W_ERROR(WBEM_E_REFRESHER_BUSY) }, + { "WBEM_E_UNPARSABLE_QUERY", W_ERROR(WBEM_E_UNPARSABLE_QUERY) }, + { "WBEM_E_NOT_EVENT_CLASS", W_ERROR(WBEM_E_NOT_EVENT_CLASS) }, + { "WBEM_E_MISSING_GROUP_WITHIN", W_ERROR(WBEM_E_MISSING_GROUP_WITHIN) }, + { "WBEM_E_MISSING_AGGREGATION_LIST", W_ERROR(WBEM_E_MISSING_AGGREGATION_LIST) }, + { "WBEM_E_PROPERTY_NOT_AN_OBJECT", W_ERROR(WBEM_E_PROPERTY_NOT_AN_OBJECT) }, + { "WBEM_E_AGGREGATING_BY_OBJECT", W_ERROR(WBEM_E_AGGREGATING_BY_OBJECT) }, + { "WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY", W_ERROR(WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY) }, + { "WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING", W_ERROR(WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING) }, + { "WBEM_E_QUEUE_OVERFLOW", W_ERROR(WBEM_E_QUEUE_OVERFLOW) }, + { "WBEM_E_PRIVILEGE_NOT_HELD", W_ERROR(WBEM_E_PRIVILEGE_NOT_HELD) }, + { "WBEM_E_INVALID_OPERATOR", W_ERROR(WBEM_E_INVALID_OPERATOR) }, + { "WBEM_E_LOCAL_CREDENTIALS", W_ERROR(WBEM_E_LOCAL_CREDENTIALS) }, + { "WBEM_E_CANNOT_BE_ABSTRACT", W_ERROR(WBEM_E_CANNOT_BE_ABSTRACT) }, + { "WBEM_E_AMENDED_OBJECT", W_ERROR(WBEM_E_AMENDED_OBJECT) }, + { "WBEM_E_CLIENT_TOO_SLOW", W_ERROR(WBEM_E_CLIENT_TOO_SLOW) }, + { "WBEM_E_NULL_SECURITY_DESCRIPTOR", W_ERROR(WBEM_E_NULL_SECURITY_DESCRIPTOR) }, + { "WBEM_E_TIMED_OUT", W_ERROR(WBEM_E_TIMED_OUT) }, + { "WBEM_E_INVALID_ASSOCIATION", W_ERROR(WBEM_E_INVALID_ASSOCIATION) }, + { "WBEM_E_AMBIGUOUS_OPERATION", W_ERROR(WBEM_E_AMBIGUOUS_OPERATION) }, + { "WBEM_E_QUOTA_VIOLATION", W_ERROR(WBEM_E_QUOTA_VIOLATION) }, + { "WBEM_E_RESERVED_001", W_ERROR(WBEM_E_RESERVED_001) }, + { "WBEM_E_RESERVED_002", W_ERROR(WBEM_E_RESERVED_002) }, + { "WBEM_E_UNSUPPORTED_LOCALE", W_ERROR(WBEM_E_UNSUPPORTED_LOCALE) }, + { "WBEM_E_HANDLE_OUT_OF_DATE", W_ERROR(WBEM_E_HANDLE_OUT_OF_DATE) }, + { "WBEM_E_CONNECTION_FAILED", W_ERROR(WBEM_E_CONNECTION_FAILED) }, + { "WBEM_E_INVALID_HANDLE_REQUEST", W_ERROR(WBEM_E_INVALID_HANDLE_REQUEST) }, + { "WBEM_E_PROPERTY_NAME_TOO_WIDE", W_ERROR(WBEM_E_PROPERTY_NAME_TOO_WIDE) }, + { "WBEM_E_CLASS_NAME_TOO_WIDE", W_ERROR(WBEM_E_CLASS_NAME_TOO_WIDE) }, + { "WBEM_E_METHOD_NAME_TOO_WIDE", W_ERROR(WBEM_E_METHOD_NAME_TOO_WIDE) }, + { "WBEM_E_QUALIFIER_NAME_TOO_WIDE", W_ERROR(WBEM_E_QUALIFIER_NAME_TOO_WIDE) }, + { "WBEM_E_RERUN_COMMAND", W_ERROR(WBEM_E_RERUN_COMMAND) }, + { "WBEM_E_DATABASE_VER_MISMATCH", W_ERROR(WBEM_E_DATABASE_VER_MISMATCH) }, + { "WBEM_E_VETO_DELETE", W_ERROR(WBEM_E_VETO_DELETE) }, + { "WBEM_E_VETO_PUT", W_ERROR(WBEM_E_VETO_PUT) }, + { "WBEM_E_INVALID_LOCALE", W_ERROR(WBEM_E_INVALID_LOCALE) }, + { "WBEM_E_PROVIDER_SUSPENDED", W_ERROR(WBEM_E_PROVIDER_SUSPENDED) }, + { "WBEM_E_SYNCHRONIZATION_REQUIRED", W_ERROR(WBEM_E_SYNCHRONIZATION_REQUIRED) }, + { "WBEM_E_NO_SCHEMA", W_ERROR(WBEM_E_NO_SCHEMA) }, + { "WBEM_E_PROVIDER_ALREADY_REGISTERED", W_ERROR(WBEM_E_PROVIDER_ALREADY_REGISTERED) }, + { "WBEM_E_PROVIDER_NOT_REGISTERED", W_ERROR(WBEM_E_PROVIDER_NOT_REGISTERED) }, + { "WBEM_E_FATAL_TRANSPORT_ERROR", W_ERROR(WBEM_E_FATAL_TRANSPORT_ERROR) }, + { "WBEM_E_ENCRYPTED_CONNECTION_REQUIRED", W_ERROR(WBEM_E_ENCRYPTED_CONNECTION_REQUIRED) }, + { "WBEM_E_PROVIDER_TIMED_OUT", W_ERROR(WBEM_E_PROVIDER_TIMED_OUT) }, + { "WBEM_E_NO_KEY", W_ERROR(WBEM_E_NO_KEY) }, + { "WBEM_E_PROVIDER_DISABLED", W_ERROR(WBEM_E_PROVIDER_DISABLED) }, + { NULL, W_ERROR(0) } +}; + +const char *wmi_errstr(WERROR werror) +{ + int idx = 0; + + while (wmi_errs[idx].dos_errstr != NULL) { + if (W_ERROR_V(wmi_errs[idx].werror) == + W_ERROR_V(werror)) + return wmi_errs[idx].dos_errstr; + idx++; + } + + return win_errstr(werror); +} diff --git a/source4/libcli/auth/credentials.c b/source4/libcli/auth/credentials.c index a6cb17c12e..3c77b0836d 100644 --- a/source4/libcli/auth/credentials.c +++ b/source4/libcli/auth/credentials.c @@ -23,7 +23,7 @@ #include "includes.h" #include "system/time.h" #include "auth/auth.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" /* diff --git a/source4/libcli/auth/smbdes.c b/source4/libcli/auth/smbdes.c index 7f998e512d..32e65e779d 100644 --- a/source4/libcli/auth/smbdes.c +++ b/source4/libcli/auth/smbdes.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "libcli/auth/libcli_auth.h" /* NOTES: diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index 7de9627302..096f51e49b 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -25,7 +25,7 @@ #include "system/time.h" #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "pstring.h" #include "param/param.h" @@ -497,10 +497,10 @@ bool encode_pw_buffer(uint8_t buffer[516], const char *password, int string_flag returned password including termination. ************************************************************/ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, - int new_pwrd_size, uint32_t *new_pw_len, - int string_flags) + int new_pwrd_size, int string_flags) { int byte_len=0; + ssize_t converted_pw_len; /* the incoming buffer can be any alignment. */ string_flags |= STR_NOALIGN; @@ -526,15 +526,72 @@ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, } /* decode into the return buffer. Buffer length supplied */ - *new_pw_len = pull_string(lp_iconv_convenience(global_loadparm), new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, + converted_pw_len = pull_string(lp_iconv_convenience(global_loadparm), new_pwrd, &in_buffer[512 - byte_len], new_pwrd_size, byte_len, string_flags); + if (converted_pw_len == -1) { + return false; + } + #ifdef DEBUG_PASSWORD DEBUG(100,("decode_pw_buffer: new_pwrd: ")); - dump_data(100, (const uint8_t *)new_pwrd, *new_pw_len); - DEBUG(100,("multibyte len:%d\n", *new_pw_len)); + dump_data(100, (const uint8_t *)new_pwrd, converted_pw_len); + DEBUG(100,("multibyte len:%d\n", (int)converted_pw_len)); DEBUG(100,("original char len:%d\n", byte_len/2)); #endif return true; } + +/*********************************************************** + encode a password buffer with an already unicode password. The + rest of the buffer is filled with random data to make it harder to attack. +************************************************************/ +bool set_pw_in_buffer(uint8_t buffer[516], DATA_BLOB *password) +{ + if (password->length > 512) { + return false; + } + + memcpy(&buffer[512 - password->length], password->data, password->length); + + generate_random_buffer(buffer, 512 - password->length); + + /* + * The length of the new password is in the last 4 bytes of + * the data buffer. + */ + SIVAL(buffer, 512, password->length); + return true; +} + +/*********************************************************** + decode a password buffer + *new_pw_size is the length in bytes of the extracted unicode password +************************************************************/ +bool extract_pw_from_buffer(TALLOC_CTX *mem_ctx, + uint8_t in_buffer[516], DATA_BLOB *new_pass) +{ + int byte_len=0; + + /* The length of the new password is in the last 4 bytes of the data buffer. */ + + byte_len = IVAL(in_buffer, 512); + +#ifdef DEBUG_PASSWORD + dump_data(100, in_buffer, 516); +#endif + + /* Password cannot be longer than the size of the password buffer */ + if ( (byte_len < 0) || (byte_len > 512)) { + return false; + } + + *new_pass = data_blob_talloc(mem_ctx, &in_buffer[512 - byte_len], byte_len); + + if (!*new_pass->data) { + return false; + } + + return true; +} diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c index 860bd358d5..9f1a159573 100644 --- a/source4/libcli/cldap/cldap.c +++ b/source4/libcli/cldap/cldap.c @@ -33,7 +33,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/ldap/ldap.h" #include "libcli/ldap/ldap_ndr.h" #include "libcli/cldap/cldap.h" diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h index 7c2daf0ca2..c78e395faa 100644 --- a/source4/libcli/cldap/cldap.h +++ b/source4/libcli/cldap/cldap.h @@ -19,8 +19,8 @@ along with this program. If not, see . */ -#include "lib/util/asn1.h" -#include "libcli/netlogon.h" +#include "../lib/util/asn1.h" +#include "../libcli/netlogon.h" struct ldap_message; diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c index c20a7fd935..e42b04cdc5 100644 --- a/source4/libcli/cliconnect.c +++ b/source4/libcli/cliconnect.c @@ -69,12 +69,14 @@ NTSTATUS smbcli_negprot(struct smbcli_state *cli, bool unicode, int maxprotocol) /* wrapper around smb_raw_sesssetup() */ NTSTATUS smbcli_session_setup(struct smbcli_state *cli, struct cli_credentials *credentials, - const char *workgroup) + const char *workgroup, + struct smbcli_session_options options) { struct smb_composite_sesssetup setup; NTSTATUS status; - cli->session = smbcli_session_init(cli->transport, cli, true); + cli->session = smbcli_session_init(cli->transport, cli, true, + options); if (!cli->session) return NT_STATUS_UNSUCCESSFUL; setup.in.sesskey = cli->transport->negotiate.sesskey; @@ -144,7 +146,8 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx, struct cli_credentials *credentials, struct resolve_context *resolve_ctx, struct event_context *ev, - struct smbcli_options *options) + struct smbcli_options *options, + struct smbcli_session_options *session_options) { struct smbcli_tree *tree; NTSTATUS status; @@ -155,7 +158,8 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx, &tree, host, ports, sharename, devtype, credentials, resolve_ctx, ev, - options); + options, + session_options); if (!NT_STATUS_IS_OK(status)) { goto done; } diff --git a/source4/libcli/clideltree.c b/source4/libcli/clideltree.c index 2c306e501e..28563d918e 100644 --- a/source4/libcli/clideltree.c +++ b/source4/libcli/clideltree.c @@ -84,12 +84,14 @@ int smbcli_deltree(struct smbcli_tree *tree, const char *dname) { char *mask; struct delete_state dstate; + NTSTATUS status; dstate.tree = tree; dstate.total_deleted = 0; dstate.failed = false; /* it might be a file */ + status = smbcli_unlink(tree, dname); if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) { return 1; } @@ -98,6 +100,13 @@ int smbcli_deltree(struct smbcli_tree *tree, const char *dname) NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_NO_SUCH_FILE)) { return 0; } + if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { + /* it could be read-only */ + status = smbcli_setatr(tree, dname, FILE_ATTRIBUTE_NORMAL, 0); + if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) { + return 1; + } + } asprintf(&mask, "%s\\*", dname); smbcli_unlink(dstate.tree, mask); @@ -105,7 +114,14 @@ int smbcli_deltree(struct smbcli_tree *tree, const char *dname) FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM, delete_fn, &dstate); free(mask); - if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate.tree, dname))) { + + status = smbcli_rmdir(dstate.tree, dname); + if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { + /* it could be read-only */ + status = smbcli_setatr(dstate.tree, dname, FILE_ATTRIBUTE_NORMAL, 0); + status = smbcli_rmdir(dstate.tree, dname); + } + if (NT_STATUS_IS_ERR(status)) { DEBUG(2,("Failed to delete %s - %s\n", dname, smbcli_errstr(dstate.tree))); return -1; diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 3e3f224f47..104397fa48 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -28,7 +28,7 @@ #include "libcli/composite/composite.h" #include "lib/messaging/irpc.h" #include "librpc/rpc/dcerpc.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" /* create a new composite_context structure @@ -214,5 +214,5 @@ _PUBLIC_ void composite_continue_nbt(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk index 262a2cfa22..8d9a1f5fa8 100644 --- a/source4/libcli/config.mk +++ b/source4/libcli/config.mk @@ -40,52 +40,52 @@ $(eval $(call proto_header_template,$(libclisrcdir)/smb_composite/proto.h,$(LIBC [SUBSYSTEM::NDR_NBT_BUF] -NDR_NBT_BUF_OBJ_FILES = $(libclisrcdir)/nbt/nbtname.o +NDR_NBT_BUF_OBJ_FILES = $(libclinbtsrcdir)/nbtname.o -$(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbtname.h,$(NDR_NBT_BUF_OBJ_FILES:.o=.c))) +$(eval $(call proto_header_template,$(libclinbtsrcdir)/nbtname.h,$(NDR_NBT_BUF_OBJ_FILES:.o=.c))) [SUBSYSTEM::LIBCLI_NBT] PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \ NDR_SECURITY samba-socket LIBSAMBA-UTIL -LIBCLI_NBT_OBJ_FILES = $(addprefix $(libclisrcdir)/nbt/, \ +LIBCLI_NBT_OBJ_FILES = $(addprefix $(libclinbtsrcdir)/, \ nbtsocket.o \ namequery.o \ nameregister.o \ namerefresh.o \ namerelease.o) -$(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbt_proto.h,$(LIBCLI_NBT_OBJ_FILES:.o=.c))) +[BINARY::nmblookup] +INSTALLDIR = BINDIR +PRIVATE_DEPENDENCIES = \ + LIBSAMBA-HOSTCONFIG \ + LIBSAMBA-UTIL \ + LIBCLI_NBT \ + LIBPOPT \ + POPT_SAMBA \ + LIBNETIF \ + LIBCLI_RESOLVE + +nmblookup_OBJ_FILES = $(libclinbtsrcdir)/tools/nmblookup.o +MANPAGES += $(libclinbtsrcdir)/man/nmblookup.1 [SUBSYSTEM::LIBCLI_NDR_NETLOGON] PUBLIC_DEPENDENCIES = LIBNDR \ NDR_SECURITY -LIBCLI_NDR_NETLOGON_OBJ_FILES = $(addprefix $(libclisrcdir)/, ndr_netlogon.o) - -$(eval $(call proto_header_template,$(libclisrcdir)/ndr_netlogon_proto.h,$(LIBCLI_NDR_NETLOGON_OBJ_FILES:.o=.c))) +LIBCLI_NDR_NETLOGON_OBJ_FILES = $(addprefix $(libclinbtsrcdir)/../, ndr_netlogon.o) [SUBSYSTEM::LIBCLI_NETLOGON] PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_NDR_NETLOGON -LIBCLI_NETLOGON_OBJ_FILES = $(addprefix $(libclisrcdir)/, \ - netlogon.o) - -$(eval $(call proto_header_template,$(libclisrcdir)/netlogon_proto.h,$(LIBCLI_NETLOGON_OBJ_FILES:.o=.c))) - -[SUBSYSTEM::LIBCLI_DRSBLOBS] -PUBLIC_DEPENDENCIES = LIBNDR - -LIBCLI_DRSBLOBS_OBJ_FILES = $(addprefix $(libclisrcdir)/, \ - drsblobs.o) - -$(eval $(call proto_header_template,$(libclisrcdir)/drsblobs_proto.h,$(LIBCLI_DRSBLOBS_OBJ_FILES:.o=.c))) +LIBCLI_NETLOGON_OBJ_FILES = $(addprefix $(libclinbtsrcdir)/, \ + ../netlogon.o) [PYTHON::python_netbios] LIBRARY_REALNAME = samba/netbios.$(SHLIBEXT) PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-HOSTCONFIG -python_netbios_OBJ_FILES = $(libclisrcdir)/nbt/pynbt.o +python_netbios_OBJ_FILES = $(libclinbtsrcdir)/pynbt.o $(python_libcli_nbt_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index 06b7bd5771..18bfd689d2 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -21,7 +21,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/dgram/libdgram.h" #include "lib/socket/socket.h" #include "param/param.h" diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index e1209e7a54..2f8feb5345 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -19,7 +19,7 @@ along with this program. If not, see . */ -#include "libcli/netlogon.h" +#include "../libcli/netlogon.h" /* a datagram name request diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c index 4f9d0bfc7c..e613dd9228 100644 --- a/source4/libcli/dgram/mailslot.c +++ b/source4/libcli/dgram/mailslot.c @@ -33,7 +33,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/dgram/libdgram.h" #include "lib/socket/socket.h" #include "param/param.h" @@ -197,7 +197,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock, trans->data_offset = 70 + strlen(mailslot_name); trans->opcode = 1; /* write mail slot */ trans->priority = 1; - trans->class = 2; + trans->_class = 2; trans->mailslot_name = mailslot_name; trans->data = *request; diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c index 56f931ce19..f12f1ac805 100644 --- a/source4/libcli/finddcs.c +++ b/source4/libcli/finddcs.c @@ -217,7 +217,7 @@ static void fallback_node_status(struct finddcs_state *state) static void fallback_node_status_replied(struct nbt_name_request *name_req) { int i; - struct finddcs_state *state = talloc_get_type(name_req->async.private, struct finddcs_state); + struct finddcs_state *state = talloc_get_type(name_req->async.private_data, struct finddcs_state); state->ctx->status = nbt_name_status_recv(name_req, state, &state->node_status); if (!composite_is_ok(state->ctx)) return; diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c index fc6de7993e..87c89daf9f 100644 --- a/source4/libcli/ldap/ldap.c +++ b/source4/libcli/ldap/ldap.c @@ -23,7 +23,7 @@ */ #include "includes.h" -#include "lib/util/asn1.h" +#include "../lib/util/asn1.h" #include "libcli/ldap/ldap.h" #include "libcli/ldap/ldap_proto.h" diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c index 65673116be..b66232c02e 100644 --- a/source4/libcli/ldap/ldap_bind.c +++ b/source4/libcli/ldap/ldap_bind.c @@ -387,6 +387,7 @@ _PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, if (NT_STATUS_IS_OK(status)) { struct socket_context *sasl_socket; status = gensec_socket_init(conn->gensec, + conn, conn->sock, conn->event.event_ctx, ldap_read_io_handler, diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c index 844238afdb..a59356761b 100644 --- a/source4/libcli/ldap/ldap_client.c +++ b/source4/libcli/ldap/ldap_client.c @@ -23,8 +23,8 @@ */ #include "includes.h" -#include "lib/util/asn1.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/asn1.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" #include "lib/socket/socket.h" #include "libcli/ldap/ldap.h" @@ -77,6 +77,12 @@ static void ldap_connection_dead(struct ldap_connection *conn) { struct ldap_request *req; + talloc_free(conn->sock); /* this will also free event.fde */ + talloc_free(conn->packet); + conn->sock = NULL; + conn->event.fde = NULL; + conn->packet = NULL; + /* return an error for any pending request ... */ while (conn->pending) { req = conn->pending; @@ -87,12 +93,6 @@ static void ldap_connection_dead(struct ldap_connection *conn) req->async.fn(req); } } - - talloc_free(conn->sock); /* this will also free event.fde */ - talloc_free(conn->packet); - conn->sock = NULL; - conn->event.fde = NULL; - conn->packet = NULL; } static void ldap_reconnect(struct ldap_connection *conn); @@ -400,6 +400,7 @@ static void ldap_connect_got_sock(struct composite_context *ctx, talloc_steal(conn, conn->sock); if (conn->ldaps) { struct socket_context *tls_socket; + struct socket_context *tmp_socket; char *cafile = private_path(conn->sock, conn->lp_ctx, lp_tls_cafile(conn->lp_ctx)); if (!cafile || !*cafile) { @@ -414,9 +415,11 @@ static void ldap_connect_got_sock(struct composite_context *ctx, talloc_free(conn->sock); return; } - talloc_unlink(conn, conn->sock); - conn->sock = tls_socket; - talloc_steal(conn, conn->sock); + + /* the original socket, must become a child of the tls socket */ + tmp_socket = conn->sock; + conn->sock = talloc_steal(conn, tls_socket); + talloc_steal(conn->sock, tmp_socket); } conn->packet = packet_init(conn); @@ -432,7 +435,7 @@ static void ldap_connect_got_sock(struct composite_context *ctx, packet_set_error_handler(conn->packet, ldap_error_handler); packet_set_event_context(conn->packet, conn->event.event_ctx); packet_set_fde(conn->packet, conn->event.fde); - packet_set_serialise(conn->packet); +/* packet_set_serialise(conn->packet); */ composite_done(ctx); } diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c index 3b94580033..930d97c40d 100644 --- a/source4/libcli/ldap/ldap_controls.c +++ b/source4/libcli/ldap/ldap_controls.c @@ -20,9 +20,10 @@ */ #include "includes.h" -#include "lib/util/asn1.h" +#include "../lib/util/asn1.h" #include "libcli/ldap/ldap.h" #include "lib/ldb/include/ldb.h" +#include "libcli/ldap/ldap_proto.h" struct control_handler { const char *oid; diff --git a/source4/libcli/ldap/ldap_msg.c b/source4/libcli/ldap/ldap_msg.c index c712e1e654..e45213c004 100644 --- a/source4/libcli/ldap/ldap_msg.c +++ b/source4/libcli/ldap/ldap_msg.c @@ -24,6 +24,7 @@ #include "includes.h" #include "libcli/ldap/ldap.h" #include "libcli/ldap/ldap_client.h" +#include "libcli/ldap/ldap_proto.h" _PUBLIC_ struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx) diff --git a/source4/libcli/ldap/ldap_ndr.c b/source4/libcli/ldap/ldap_ndr.c index a10f80ae2c..5e938ea148 100644 --- a/source4/libcli/ldap/ldap_ndr.c +++ b/source4/libcli/ldap/ldap_ndr.c @@ -25,6 +25,7 @@ #include "libcli/ldap/ldap.h" #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_misc.h" +#include "libcli/ldap/ldap_ndr.h" /* encode a NDR uint32 as a ldap filter element diff --git a/source4/libcli/nbt/libnbt.h b/source4/libcli/nbt/libnbt.h deleted file mode 100644 index 0b01365510..0000000000 --- a/source4/libcli/nbt/libnbt.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - a raw async NBT library - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#ifndef __LIBNBT_H__ -#define __LIBNBT_H__ - -#include "librpc/gen_ndr/nbt.h" -#include "librpc/ndr/libndr.h" - -/* - possible states for pending requests -*/ -enum nbt_request_state {NBT_REQUEST_SEND, - NBT_REQUEST_WAIT, - NBT_REQUEST_DONE, - NBT_REQUEST_TIMEOUT, - NBT_REQUEST_ERROR}; - -/* - a nbt name request -*/ -struct nbt_name_request { - struct nbt_name_request *next, *prev; - - enum nbt_request_state state; - - NTSTATUS status; - - /* the socket this was on */ - struct nbt_name_socket *nbtsock; - - /* where to send the request */ - struct socket_address *dest; - - /* timeout between retries */ - int timeout; - - /* how many retries to send on timeout */ - int num_retries; - - /* whether we have received a WACK */ - bool received_wack; - - /* the timeout event */ - struct timed_event *te; - - /* the name transaction id */ - uint16_t name_trn_id; - - /* is it a reply? */ - bool is_reply; - - /* the encoded request */ - DATA_BLOB encoded; - - /* shall we allow multiple replies? */ - bool allow_multiple_replies; - - unsigned int num_replies; - struct nbt_name_reply { - struct nbt_name_packet *packet; - struct socket_address *dest; - } *replies; - - /* information on what to do on completion */ - struct { - void (*fn)(struct nbt_name_request *); - void *private; - } async; -}; - - - -/* - context structure for operations on name queries -*/ -struct nbt_name_socket { - struct socket_context *sock; - struct event_context *event_ctx; - struct smb_iconv_convenience *iconv_convenience; - - /* a queue of requests pending to be sent */ - struct nbt_name_request *send_queue; - - /* the fd event */ - struct fd_event *fde; - - /* mapping from name_trn_id to pending event */ - struct idr_context *idr; - - /* how many requests are waiting for a reply */ - uint16_t num_pending; - - /* what to do with incoming request packets */ - struct { - void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, - struct socket_address *); - void *private; - } incoming; - - /* what to do with unexpected replies */ - struct { - void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, - struct socket_address *); - void *private; - } unexpected; -}; - - -/* a simple name query */ -struct nbt_name_query { - struct { - struct nbt_name name; - const char *dest_addr; - uint16_t dest_port; - bool broadcast; - bool wins_lookup; - int timeout; /* in seconds */ - int retries; - } in; - struct { - const char *reply_from; - struct nbt_name name; - int16_t num_addrs; - const char **reply_addrs; - } out; -}; - -/* a simple name status query */ -struct nbt_name_status { - struct { - struct nbt_name name; - const char *dest_addr; - uint16_t dest_port; - int timeout; /* in seconds */ - int retries; - } in; - struct { - const char *reply_from; - struct nbt_name name; - struct nbt_rdata_status status; - } out; -}; - -/* a name registration request */ -struct nbt_name_register { - struct { - struct nbt_name name; - const char *dest_addr; - uint16_t dest_port; - const char *address; - uint16_t nb_flags; - bool register_demand; - bool broadcast; - bool multi_homed; - uint32_t ttl; - int timeout; /* in seconds */ - int retries; - } in; - struct { - const char *reply_from; - struct nbt_name name; - const char *reply_addr; - uint8_t rcode; - } out; -}; - -/* a send 3 times then demand name broadcast name registration */ -struct nbt_name_register_bcast { - struct { - struct nbt_name name; - const char *dest_addr; - uint16_t dest_port; - const char *address; - uint16_t nb_flags; - uint32_t ttl; - } in; -}; - - -/* wins name register with multiple wins servers to try and multiple - addresses to register */ -struct nbt_name_register_wins { - struct { - struct nbt_name name; - const char **wins_servers; - uint16_t wins_port; - const char **addresses; - uint16_t nb_flags; - uint32_t ttl; - } in; - struct { - const char *wins_server; - uint8_t rcode; - } out; -}; - - - -/* a name refresh request */ -struct nbt_name_refresh { - struct { - struct nbt_name name; - const char *dest_addr; - uint16_t dest_port; - const char *address; - uint16_t nb_flags; - bool broadcast; - uint32_t ttl; - int timeout; /* in seconds */ - int retries; - } in; - struct { - const char *reply_from; - struct nbt_name name; - const char *reply_addr; - uint8_t rcode; - } out; -}; - -/* wins name refresh with multiple wins servers to try and multiple - addresses to register */ -struct nbt_name_refresh_wins { - struct { - struct nbt_name name; - const char **wins_servers; - uint16_t wins_port; - const char **addresses; - uint16_t nb_flags; - uint32_t ttl; - } in; - struct { - const char *wins_server; - uint8_t rcode; - } out; -}; - - -/* a name release request */ -struct nbt_name_release { - struct { - struct nbt_name name; - const char *dest_addr; - uint16_t dest_port; - const char *address; - uint16_t nb_flags; - bool broadcast; - int timeout; /* in seconds */ - int retries; - } in; - struct { - const char *reply_from; - struct nbt_name name; - const char *reply_addr; - uint8_t rcode; - } out; -}; - -struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, - struct event_context *event_ctx, - struct smb_iconv_convenience *iconv_convenience); -struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock, - struct nbt_name_query *io); -NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, - TALLOC_CTX *mem_ctx, struct nbt_name_query *io); -NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, struct nbt_name_query *io); -struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *nbtsock, - struct nbt_name_status *io); -NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, - TALLOC_CTX *mem_ctx, struct nbt_name_status *io); -NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, struct nbt_name_status *io); - -NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname); -NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name); -NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name); -void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type); -char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name); -NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, struct nbt_name_register *io); -NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io); -NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, struct nbt_name_release *io); -NTSTATUS nbt_name_register_wins(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, - struct nbt_name_register_wins *io); -NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock, - TALLOC_CTX *mem_ctx, - struct nbt_name_refresh_wins *io); -NTSTATUS nbt_name_register_recv(struct nbt_name_request *req, - TALLOC_CTX *mem_ctx, struct nbt_name_register *io); -struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock, - struct nbt_name_register *io); -NTSTATUS nbt_name_release_recv(struct nbt_name_request *req, - TALLOC_CTX *mem_ctx, struct nbt_name_release *io); - -struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock, - struct nbt_name_release *io); - -NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req, - TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io); - -NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock, - void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, - struct socket_address *), - void *private); -NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, - struct socket_address *dest, - struct nbt_name_packet *request); - - -NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *) -NDR_SCALAR_PROTO(nbt_string, const char *) -NDR_BUFFER_PROTO(nbt_name, struct nbt_name) -NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode); - -struct composite_context; -struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock, - struct nbt_name_register_bcast *io); -NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c); -struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock, - struct nbt_name_register_wins *io); -NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, - struct nbt_name_refresh_wins *io); -struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock, - struct nbt_name_refresh_wins *io); -NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, - struct nbt_name_register_wins *io); - - -#endif /* __LIBNBT_H__ */ diff --git a/source4/libcli/raw/clierror.c b/source4/libcli/raw/clierror.c index 157bd847d4..a41748640b 100644 --- a/source4/libcli/raw/clierror.c +++ b/source4/libcli/raw/clierror.c @@ -20,6 +20,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" /*************************************************************************** diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c index ad4ca7b471..38d8f700f2 100644 --- a/source4/libcli/raw/clisession.c +++ b/source4/libcli/raw/clisession.c @@ -35,7 +35,8 @@ Initialize the session context ****************************************************************************/ struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport, - TALLOC_CTX *parent_ctx, bool primary) + TALLOC_CTX *parent_ctx, bool primary, + struct smbcli_session_options options) { struct smbcli_session *session; uint16_t flags2; @@ -53,9 +54,7 @@ struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport, } session->pid = (uint16_t)getpid(); session->vuid = UID_FIELD_INVALID; - session->options.lanman_auth = lp_client_lanman_auth(global_loadparm); - session->options.ntlmv2_auth = lp_client_ntlmv2_auth(global_loadparm); - session->options.plaintext_auth = lp_client_plaintext_auth(global_loadparm); + session->options = options; capabilities = transport->negotiate.capabilities; diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c index 49838e8a1c..d51ffbaa74 100644 --- a/source4/libcli/raw/clisocket.c +++ b/source4/libcli/raw/clisocket.c @@ -27,6 +27,7 @@ #include "lib/socket/socket.h" #include "libcli/resolve/resolve.h" #include "param/param.h" +#include "libcli/raw/raw_proto.h" struct sock_connect_state { struct composite_context *ctx; diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index e95ae3271e..db43c9e20c 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -23,12 +23,12 @@ #include "libcli/raw/libcliraw.h" #include "libcli/raw/raw_proto.h" #include "lib/socket/socket.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" #include "lib/stream/packet.h" #include "librpc/gen_ndr/ndr_nbt.h" #include "param/param.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" /* diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 15cd70833c..4b5d2dc397 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -177,7 +177,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, struct cli_credentials *credentials, struct resolve_context *resolve_ctx, struct event_context *ev, - struct smbcli_options *options) + struct smbcli_options *options, + struct smbcli_session_options *session_options) { struct smb_composite_connect io; NTSTATUS status; @@ -200,6 +201,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, * is complete -- abartlet 2008-04-28 */ io.in.workgroup = lp_workgroup(global_loadparm); io.in.options = *options; + io.in.session_options = *session_options; status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); if (NT_STATUS_IS_OK(status)) { diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index 537041c137..c2269cbbc2 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -904,6 +904,7 @@ enum smb_setfileinfo_level { RAW_SFILEINFO_UNIX_HLINK = SMB_SFILEINFO_UNIX_HLINK, RAW_SFILEINFO_BASIC_INFORMATION = SMB_SFILEINFO_BASIC_INFORMATION, RAW_SFILEINFO_RENAME_INFORMATION = SMB_SFILEINFO_RENAME_INFORMATION, + RAW_SFILEINFO_LINK_INFORMATION = SMB_SFILEINFO_LINK_INFORMATION, RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION, RAW_SFILEINFO_POSITION_INFORMATION = SMB_SFILEINFO_POSITION_INFORMATION, RAW_SFILEINFO_FULL_EA_INFORMATION = SMB_SFILEINFO_FULL_EA_INFORMATION, @@ -984,6 +985,7 @@ union smb_setfileinfo { NTTIME write_time; NTTIME change_time; uint32_t attrib; + uint32_t reserved; } in; } basic_info; @@ -1029,6 +1031,17 @@ union smb_setfileinfo { } in; } rename_information; + /* RAW_SFILEINFO_LINK_INFORMATION interface */ + struct { + enum smb_setfileinfo_level level; + struct { + union smb_handle_or_path file; + uint8_t overwrite; + uint64_t root_fid; + const char *new_name; + } in; + } link_information; + /* RAW_SFILEINFO_POSITION_INFORMATION interface */ struct { enum smb_setfileinfo_level level; @@ -1112,6 +1125,15 @@ union smb_setfileinfo { struct security_descriptor *sd; } in; } set_secdesc; + + /* RAW_SFILEINFO_FULL_EA_INFORMATION */ + struct { + enum smb_setfileinfo_level level; + struct { + union smb_handle_or_path file; + struct smb_ea_list eas; + } in; + } full_ea_information; }; diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h index d55b4cc42c..bd9bda0db1 100644 --- a/source4/libcli/raw/libcliraw.h +++ b/source4/libcli/raw/libcliraw.h @@ -261,6 +261,12 @@ struct smbcli_request { counter by one */ uint_t sign_single_increment:1; + /* the caller wants to do the signing check */ + bool sign_caller_checks; + + /* give the caller a chance to prevent the talloc_free() in the _recv() function */ + bool do_not_free; + /* the mid of this packet - used to match replies */ uint16_t mid; diff --git a/source4/libcli/raw/rawdate.c b/source4/libcli/raw/rawdate.c index 9a86c88697..5264653cc6 100644 --- a/source4/libcli/raw/rawdate.c +++ b/source4/libcli/raw/rawdate.c @@ -21,6 +21,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" /******************************************************************* put a dos date into a buffer (time/date format) diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c index 6317c49fd7..09fd4aa412 100644 --- a/source4/libcli/raw/raweas.c +++ b/source4/libcli/raw/raweas.c @@ -20,6 +20,7 @@ #include "includes.h" #include "smb.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" /* work out how many bytes on the wire a ea list will consume. diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c index d39c61551b..d174fbfc28 100644 --- a/source4/libcli/raw/rawfile.c +++ b/source4/libcli/raw/rawfile.c @@ -30,6 +30,50 @@ if (!req) return NULL; \ } while (0) +/** + Return a string representing a CIFS attribute for a file. +**/ +_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) +{ + int i, len; + const struct { + char c; + uint16_t attr; + } attr_strs[] = { + {'V', FILE_ATTRIBUTE_VOLUME}, + {'D', FILE_ATTRIBUTE_DIRECTORY}, + {'A', FILE_ATTRIBUTE_ARCHIVE}, + {'H', FILE_ATTRIBUTE_HIDDEN}, + {'S', FILE_ATTRIBUTE_SYSTEM}, + {'N', FILE_ATTRIBUTE_NORMAL}, + {'R', FILE_ATTRIBUTE_READONLY}, + {'d', FILE_ATTRIBUTE_DEVICE}, + {'t', FILE_ATTRIBUTE_TEMPORARY}, + {'s', FILE_ATTRIBUTE_SPARSE}, + {'r', FILE_ATTRIBUTE_REPARSE_POINT}, + {'c', FILE_ATTRIBUTE_COMPRESSED}, + {'o', FILE_ATTRIBUTE_OFFLINE}, + {'n', FILE_ATTRIBUTE_NONINDEXED}, + {'e', FILE_ATTRIBUTE_ENCRYPTED} + }; + char *ret; + + ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1); + if (!ret) { + return NULL; + } + + for (len=i=0; istatus; - talloc_free(req); + + if (!req->do_not_free) { + talloc_free(req); + } + return status; } diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c index 5a4706778a..f7dfb933f1 100644 --- a/source4/libcli/raw/rawsetfileinfo.c +++ b/source4/libcli/raw/rawsetfileinfo.c @@ -37,7 +37,7 @@ bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx, #define NEED_BLOB(n) do { \ *blob = data_blob_talloc(mem_ctx, NULL, n); \ - if (blob->data == NULL) return false; \ + if (blob->data == NULL && n != 0) return false; \ } while (0) switch (level) { @@ -109,6 +109,16 @@ bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx, return true; } + case RAW_SFILEINFO_FULL_EA_INFORMATION: + printf("num_eas=%d\n", parms->full_ea_information.in.eas.num_eas); + NEED_BLOB(ea_list_size_chained( + parms->full_ea_information.in.eas.num_eas, + parms->full_ea_information.in.eas.eas, 4)); + ea_put_list_chained(blob->data, + parms->full_ea_information.in.eas.num_eas, + parms->full_ea_information.in.eas.eas, 4); + return true; + /* Unhandled levels */ case RAW_SFILEINFO_PIPE_INFORMATION: case RAW_SFILEINFO_VALID_DATA_INFORMATION: diff --git a/source4/libcli/raw/rawtrans.c b/source4/libcli/raw/rawtrans.c index 2f529863dc..d68df56705 100644 --- a/source4/libcli/raw/rawtrans.c +++ b/source4/libcli/raw/rawtrans.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/raw/libcliraw.h" #include "libcli/raw/raw_proto.h" diff --git a/source4/libcli/raw/smb_signing.c b/source4/libcli/raw/smb_signing.c index 1d03686d9a..e798f052ba 100644 --- a/source4/libcli/raw/smb_signing.c +++ b/source4/libcli/raw/smb_signing.c @@ -23,7 +23,7 @@ #include "smb.h" #include "libcli/raw/libcliraw.h" #include "libcli/raw/raw_proto.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "param/param.h" /*********************************************************** @@ -298,11 +298,20 @@ bool smbcli_request_check_sign_mac(struct smbcli_request *req) { bool good; + if (!req->transport->negotiate.sign_info.doing_signing && + req->sign_caller_checks) { + return true; + } + + req->sign_caller_checks = false; + switch (req->transport->negotiate.sign_info.signing_state) { case SMB_SIGNING_ENGINE_OFF: return true; case SMB_SIGNING_ENGINE_BSRSPYL: + return true; + case SMB_SIGNING_ENGINE_ON: { if (req->in.size < (HDR_SS_FIELD + 8)) { @@ -350,6 +359,7 @@ bool smbcli_simple_set_signing(TALLOC_CTX *mem_ctx, dump_data_pw("Started Signing with key:\n", sign_info->mac_key.data, sign_info->mac_key.length); sign_info->signing_state = SMB_SIGNING_ENGINE_ON; + sign_info->next_seq_num = 2; return true; } diff --git a/source4/libcli/resolve/bcast.c b/source4/libcli/resolve/bcast.c index 2e2eb05397..ca78a2ce43 100644 --- a/source4/libcli/resolve/bcast.c +++ b/source4/libcli/resolve/bcast.c @@ -75,7 +75,13 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx, NTSTATUS resolve_name_bcast_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, const char **reply_addr) { - return resolve_name_nbtlist_recv(c, mem_ctx, reply_addr); + NTSTATUS status = resolve_name_nbtlist_recv(c, mem_ctx, reply_addr); + if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { + /* this makes much more sense for a bcast name resolution + timeout */ + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + return status; } /* diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c index 8f085c5404..531ce6098f 100644 --- a/source4/libcli/resolve/nbtlist.c +++ b/source4/libcli/resolve/nbtlist.c @@ -28,8 +28,9 @@ #include "system/network.h" #include "lib/socket/netif.h" #include "librpc/gen_ndr/ndr_nbt.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" #include "param/param.h" +#include "libcli/resolve/resolve.h" struct nbtlist_state { struct nbt_name name; @@ -46,7 +47,7 @@ struct nbtlist_state { */ static void nbtlist_handler(struct nbt_name_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); struct nbtlist_state *state = talloc_get_type(c->private_data, struct nbtlist_state); struct nbt_name_query *q; @@ -169,7 +170,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx, if (composite_nomem(state->queries[i], c)) return c; state->queries[i]->async.fn = nbtlist_handler; - state->queries[i]->async.private = c; + state->queries[i]->async.private_data = c; } return c; diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index d89b50e430..7f4ae4d79f 100644 --- a/source4/libcli/resolve/resolve.c +++ b/source4/libcli/resolve/resolve.c @@ -27,7 +27,7 @@ #include "librpc/gen_ndr/ndr_nbt.h" #include "param/param.h" #include "system/network.h" -#include "util/dlinklist.h" +#include "../lib/util/dlinklist.h" struct resolve_state { struct resolve_context *ctx; @@ -165,6 +165,10 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx, } state->method = ctx->methods; + if (state->method == NULL) { + composite_error(c, NT_STATUS_BAD_NETWORK_NAME); + return c; + } state->creq = setup_next_method(c); if (composite_nomem(state->creq, c)) return c; diff --git a/source4/libcli/resolve/resolve.h b/source4/libcli/resolve/resolve.h index 79b91dc836..22de146c99 100644 --- a/source4/libcli/resolve/resolve.h +++ b/source4/libcli/resolve/resolve.h @@ -22,7 +22,7 @@ #ifndef __RESOLVE_H__ #define __RESOLVE_H__ -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" typedef struct composite_context *(*resolve_name_send_fn)(TALLOC_CTX *mem_ctx, struct event_context *, void *privdata, struct nbt_name *); typedef NTSTATUS (*resolve_name_recv_fn)(struct composite_context *, TALLOC_CTX *, const char **); #include "libcli/resolve/proto.h" diff --git a/source4/libcli/resolve/wins.c b/source4/libcli/resolve/wins.c index 3ec180f332..f787d52d31 100644 --- a/source4/libcli/resolve/wins.c +++ b/source4/libcli/resolve/wins.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" #include "libcli/resolve/resolve.h" #include "param/param.h" #include "lib/socket/netif.h" @@ -79,7 +79,7 @@ NTSTATUS resolve_name_wins(struct nbt_name *name, bool resolve_context_add_wins_method(struct resolve_context *ctx, const char **address_list, struct interface *ifaces, uint16_t nbt_port, int nbt_timeout) { struct resolve_wins_data *wins_data = talloc(ctx, struct resolve_wins_data); - wins_data->address_list = str_list_copy(wins_data, address_list); + wins_data->address_list = (const char **)str_list_copy(wins_data, address_list); wins_data->ifaces = talloc_reference(wins_data, ifaces); wins_data->nbt_port = nbt_port; wins_data->nbt_timeout = nbt_timeout; diff --git a/source4/libcli/security/access_check.c b/source4/libcli/security/access_check.c index e2ede05545..d5a0a13445 100644 --- a/source4/libcli/security/access_check.c +++ b/source4/libcli/security/access_check.c @@ -38,6 +38,10 @@ static uint32_t access_check_max_allowed(const struct security_descriptor *sd, granted |= SEC_STD_DELETE; } + if (sd->dacl == NULL) { + return granted & ~denied; + } + for (i = 0;idacl->num_aces; i++) { struct security_ace *ace = &sd->dacl->aces[i]; @@ -101,10 +105,14 @@ NTSTATUS sec_access_check(const struct security_descriptor *sd, return NT_STATUS_OK; } - /* empty dacl denies access */ +#if 0 + /* tridge: previously we had empty dacl denying access, but + that can lead to undeletable directories, where + nobody can change the ACL on a directory */ if (sd->dacl == NULL || sd->dacl->num_aces == 0) { return NT_STATUS_ACCESS_DENIED; } +#endif /* the owner always gets SEC_STD_WRITE_DAC, SEC_STD_READ_CONTROL and SEC_STD_DELETE */ if ((bits_remaining & (SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL|SEC_STD_DELETE)) && @@ -116,6 +124,10 @@ NTSTATUS sec_access_check(const struct security_descriptor *sd, bits_remaining &= ~SEC_STD_DELETE; } + if (sd->dacl == NULL) { + goto done; + } + /* check each ace in turn. */ for (i=0; bits_remaining && i < sd->dacl->num_aces; i++) { struct security_ace *ace = &sd->dacl->aces[i]; @@ -143,6 +155,7 @@ NTSTATUS sec_access_check(const struct security_descriptor *sd, } } +done: if (bits_remaining != 0) { return NT_STATUS_ACCESS_DENIED; } diff --git a/source4/libcli/security/security.i b/source4/libcli/security/security.i index 1d964cc3d5..420439d147 100644 --- a/source4/libcli/security/security.i +++ b/source4/libcli/security/security.i @@ -27,8 +27,8 @@ typedef struct security_token security_token; typedef struct security_descriptor security_descriptor; %} -%import "../../lib/talloc/talloc.i" -%import "../util/errors.i" +%import "../lib/talloc/talloc.i" +%include "../util/errors.i" %import "stdint.i" enum sec_privilege { @@ -105,6 +105,12 @@ typedef struct security_descriptor { %talloctype(dom_sid); typedef struct dom_sid { + %immutable; + uint8_t sid_rev_num; + int8_t num_auths;/* [range(0,15)] */ + uint8_t id_auth[6]; + uint32_t *sub_auths; + %mutable; %extend { dom_sid(TALLOC_CTX *mem_ctx, const char *text) { return dom_sid_parse_talloc(mem_ctx, text); @@ -117,6 +123,10 @@ typedef struct dom_sid { #endif bool equal(const struct dom_sid *other); } +%pythoncode { + def __repr__(self): + return "Sid(%r)" % str(self) +} } dom_sid; %feature("docstring") random_sid "random_sid() -> sid\n" \ diff --git a/source4/libcli/security/security.py b/source4/libcli/security/security.py index 065c7a19e4..8afb3eda61 100644 --- a/source4/libcli/security/security.py +++ b/source4/libcli/security/security.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. @@ -147,8 +147,15 @@ security_descriptor_swigregister(security_descriptor) class Sid(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr + sid_rev_num = _swig_property(_security.Sid_sid_rev_num_get) + num_auths = _swig_property(_security.Sid_num_auths_get) + id_auth = _swig_property(_security.Sid_id_auth_get) + sub_auths = _swig_property(_security.Sid_sub_auths_get) def __init__(self, *args, **kwargs): _security.Sid_swiginit(self,_security.new_Sid(*args, **kwargs)) + def __repr__(self): + return "Sid(%r)" % str(self) + __swig_destroy__ = _security.delete_Sid Sid.__str__ = new_instancemethod(_security.Sid___str__,None,Sid) Sid.__eq__ = new_instancemethod(_security.Sid___eq__,None,Sid) diff --git a/source4/libcli/security/security_wrap.c b/source4/libcli/security/security_wrap.c index a10626c043..f7e3c2fb21 100644 --- a/source4/libcli/security/security_wrap.c +++ b/source4/libcli/security/security_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2521,7 +2527,7 @@ static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0}; #define SWIG_name "_security" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2537,6 +2543,9 @@ typedef struct security_token security_token; typedef struct security_descriptor security_descriptor; +#include "libcli/util/pyerrors.h" + + #define SWIG_From_long PyInt_FromLong @@ -2703,6 +2712,28 @@ SWIGINTERN void delete_security_token(security_token *self){ talloc_free(self); SWIGINTERN security_descriptor *new_security_descriptor(TALLOC_CTX *mem_ctx){ return security_descriptor_initialise(mem_ctx); } SWIGINTERN void delete_security_descriptor(security_descriptor *self){ talloc_free(self); } +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_char (unsigned char value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_signed_SS_char (signed char value) +{ + return SWIG_From_long (value); +} + + SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { @@ -2834,7 +2865,6 @@ SWIGINTERN PyObject *_wrap_SecurityToken_is_sid(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; struct dom_sid *arg2 = (struct dom_sid *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -2844,6 +2874,7 @@ SWIGINTERN PyObject *_wrap_SecurityToken_is_sid(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "sid", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:SecurityToken_is_sid",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_token, 0 | 0 ); @@ -2867,10 +2898,10 @@ fail: SWIGINTERN PyObject *_wrap_SecurityToken_is_system(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2890,10 +2921,10 @@ fail: SWIGINTERN PyObject *_wrap_SecurityToken_is_anonymous(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2914,7 +2945,6 @@ SWIGINTERN PyObject *_wrap_SecurityToken_has_sid(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; struct dom_sid *arg2 = (struct dom_sid *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -2924,6 +2954,7 @@ SWIGINTERN PyObject *_wrap_SecurityToken_has_sid(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "sid", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:SecurityToken_has_sid",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_token, 0 | 0 ); @@ -2947,10 +2978,10 @@ fail: SWIGINTERN PyObject *_wrap_SecurityToken_has_builtin_administrators(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2970,10 +3001,10 @@ fail: SWIGINTERN PyObject *_wrap_SecurityToken_has_nt_authenticated_users(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + bool result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2994,7 +3025,6 @@ SWIGINTERN PyObject *_wrap_SecurityToken_has_privilege(PyObject *SWIGUNUSEDPARM( PyObject *resultobj = 0; security_token *arg1 = (security_token *) 0 ; enum sec_privilege arg2 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int val2 ; @@ -3004,6 +3034,7 @@ SWIGINTERN PyObject *_wrap_SecurityToken_has_privilege(PyObject *SWIGUNUSEDPARM( char * kwnames[] = { (char *) "self",(char *) "privilege", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:SecurityToken_has_privilege",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_token, 0 | 0 ); @@ -3072,7 +3103,6 @@ SWIGINTERN PyObject *_wrap_delete_SecurityToken(PyObject *SWIGUNUSEDPARM(self), } arg1 = (security_token *)(argp1); delete_security_token(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3110,7 +3140,6 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_add(PyObject *SWIGUNUSEDPARM PyObject *resultobj = 0; security_descriptor *arg1 = (security_descriptor *) 0 ; struct security_ace *arg2 = (struct security_ace *) 0 ; - NTSTATUS result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3120,6 +3149,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_add(PyObject *SWIGUNUSEDPARM char * kwnames[] = { (char *) "self",(char *) "ace", NULL }; + NTSTATUS result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:security_descriptor_sacl_add",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_descriptor, 0 | 0 ); @@ -3134,8 +3164,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_add(PyObject *SWIGUNUSEDPARM arg2 = (struct security_ace *)(argp2); result = security_descriptor_sacl_add(arg1,(struct security_ace const *)arg2); if (NT_STATUS_IS_ERR(result)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result)); - PyErr_SetObject(PyExc_RuntimeError, obj); + PyErr_SetNTSTATUS(result); SWIG_fail; } else if (resultobj == NULL) { resultobj = Py_None; @@ -3150,7 +3179,6 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_add(PyObject *SWIGUNUSEDPARM PyObject *resultobj = 0; security_descriptor *arg1 = (security_descriptor *) 0 ; struct security_ace *arg2 = (struct security_ace *) 0 ; - NTSTATUS result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3160,6 +3188,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_add(PyObject *SWIGUNUSEDPARM char * kwnames[] = { (char *) "self",(char *) "ace", NULL }; + NTSTATUS result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:security_descriptor_dacl_add",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_descriptor, 0 | 0 ); @@ -3174,8 +3203,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_add(PyObject *SWIGUNUSEDPARM arg2 = (struct security_ace *)(argp2); result = security_descriptor_dacl_add(arg1,(struct security_ace const *)arg2); if (NT_STATUS_IS_ERR(result)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result)); - PyErr_SetObject(PyExc_RuntimeError, obj); + PyErr_SetNTSTATUS(result); SWIG_fail; } else if (resultobj == NULL) { resultobj = Py_None; @@ -3190,7 +3218,6 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_del(PyObject *SWIGUNUSEDPARM PyObject *resultobj = 0; security_descriptor *arg1 = (security_descriptor *) 0 ; struct dom_sid *arg2 = (struct dom_sid *) 0 ; - NTSTATUS result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3200,6 +3227,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_del(PyObject *SWIGUNUSEDPARM char * kwnames[] = { (char *) "self",(char *) "trustee", NULL }; + NTSTATUS result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:security_descriptor_dacl_del",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_descriptor, 0 | 0 ); @@ -3214,8 +3242,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_del(PyObject *SWIGUNUSEDPARM arg2 = (struct dom_sid *)(argp2); result = security_descriptor_dacl_del(arg1,(struct dom_sid const *)arg2); if (NT_STATUS_IS_ERR(result)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result)); - PyErr_SetObject(PyExc_RuntimeError, obj); + PyErr_SetNTSTATUS(result); SWIG_fail; } else if (resultobj == NULL) { resultobj = Py_None; @@ -3230,7 +3257,6 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_del(PyObject *SWIGUNUSEDPARM PyObject *resultobj = 0; security_descriptor *arg1 = (security_descriptor *) 0 ; struct dom_sid *arg2 = (struct dom_sid *) 0 ; - NTSTATUS result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3240,6 +3266,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_del(PyObject *SWIGUNUSEDPARM char * kwnames[] = { (char *) "self",(char *) "trustee", NULL }; + NTSTATUS result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:security_descriptor_sacl_del",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_descriptor, 0 | 0 ); @@ -3254,8 +3281,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_del(PyObject *SWIGUNUSEDPARM arg2 = (struct dom_sid *)(argp2); result = security_descriptor_sacl_del(arg1,(struct dom_sid const *)arg2); if (NT_STATUS_IS_ERR(result)) { - PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result)); - PyErr_SetObject(PyExc_RuntimeError, obj); + PyErr_SetNTSTATUS(result); SWIG_fail; } else if (resultobj == NULL) { resultobj = Py_None; @@ -3270,7 +3296,6 @@ SWIGINTERN PyObject *_wrap_security_descriptor___eq__(PyObject *SWIGUNUSEDPARM(s PyObject *resultobj = 0; security_descriptor *arg1 = (security_descriptor *) 0 ; struct security_descriptor *arg2 = (struct security_descriptor *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3280,6 +3305,7 @@ SWIGINTERN PyObject *_wrap_security_descriptor___eq__(PyObject *SWIGUNUSEDPARM(s char * kwnames[] = { (char *) "self",(char *) "other", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:security_descriptor___eq__",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_security_descriptor, 0 | 0 ); @@ -3315,7 +3341,6 @@ SWIGINTERN PyObject *_wrap_delete_security_descriptor(PyObject *SWIGUNUSEDPARM(s } arg1 = (security_descriptor *)(argp1); delete_security_descriptor(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3334,11 +3359,102 @@ SWIGINTERN PyObject *security_descriptor_swiginit(PyObject *SWIGUNUSEDPARM(self) return SWIG_Python_InitShadowInstance(args); } +SWIGINTERN PyObject *_wrap_Sid_sid_rev_num_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + dom_sid *arg1 = (dom_sid *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + uint8_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_dom_sid, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Sid_sid_rev_num_get" "', argument " "1"" of type '" "dom_sid *""'"); + } + arg1 = (dom_sid *)(argp1); + result = (uint8_t) ((arg1)->sid_rev_num); + resultobj = SWIG_From_unsigned_SS_char((unsigned char)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Sid_num_auths_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + dom_sid *arg1 = (dom_sid *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int8_t result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_dom_sid, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Sid_num_auths_get" "', argument " "1"" of type '" "dom_sid *""'"); + } + arg1 = (dom_sid *)(argp1); + result = (int8_t) ((arg1)->num_auths); + resultobj = SWIG_From_signed_SS_char((signed char)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Sid_id_auth_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + dom_sid *arg1 = (dom_sid *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + uint8_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_dom_sid, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Sid_id_auth_get" "', argument " "1"" of type '" "dom_sid *""'"); + } + arg1 = (dom_sid *)(argp1); + result = (uint8_t *)(uint8_t *) ((arg1)->id_auth); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_char, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Sid_sub_auths_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + dom_sid *arg1 = (dom_sid *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + uint32_t *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_dom_sid, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Sid_sub_auths_get" "', argument " "1"" of type '" "dom_sid *""'"); + } + arg1 = (dom_sid *)(argp1); + result = (uint32_t *) ((arg1)->sub_auths); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_int, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_new_Sid(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; char *arg2 = (char *) 0 ; - dom_sid *result = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; @@ -3346,6 +3462,7 @@ SWIGINTERN PyObject *_wrap_new_Sid(PyObject *SWIGUNUSEDPARM(self), PyObject *arg char * kwnames[] = { (char *) "text", NULL }; + dom_sid *result = 0 ; arg1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:new_Sid",kwnames,&obj0)) SWIG_fail; @@ -3368,10 +3485,10 @@ SWIGINTERN PyObject *_wrap_Sid___str__(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject *resultobj = 0; dom_sid *arg1 = (dom_sid *) 0 ; TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; arg2 = NULL; if (!args) SWIG_fail; @@ -3393,7 +3510,6 @@ SWIGINTERN PyObject *_wrap_Sid___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; dom_sid *arg1 = (dom_sid *) 0 ; struct dom_sid *arg2 = (struct dom_sid *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3403,6 +3519,7 @@ SWIGINTERN PyObject *_wrap_Sid___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "other", NULL }; + bool result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Sid___eq__",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_dom_sid, 0 | 0 ); @@ -3438,7 +3555,6 @@ SWIGINTERN PyObject *_wrap_delete_Sid(PyObject *SWIGUNUSEDPARM(self), PyObject * } arg1 = (dom_sid *)(argp1); delete_dom_sid(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3475,13 +3591,13 @@ fail: SWIGINTERN PyObject *_wrap_privilege_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; enum sec_privilege arg1 ; - char *result = 0 ; int val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "privilege", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:privilege_name",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_int(obj0, &val1); @@ -3500,7 +3616,6 @@ fail: SWIGINTERN PyObject *_wrap_privilege_id(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; char *arg1 = (char *) 0 ; - enum sec_privilege result; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -3508,6 +3623,7 @@ SWIGINTERN PyObject *_wrap_privilege_id(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "name", NULL }; + enum sec_privilege result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:privilege_id",kwnames,&obj0)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); @@ -3559,6 +3675,10 @@ static PyMethodDef SwigMethods[] = { { (char *)"delete_security_descriptor", (PyCFunction)_wrap_delete_security_descriptor, METH_O, NULL}, { (char *)"security_descriptor_swigregister", security_descriptor_swigregister, METH_VARARGS, NULL}, { (char *)"security_descriptor_swiginit", security_descriptor_swiginit, METH_VARARGS, NULL}, + { (char *)"Sid_sid_rev_num_get", (PyCFunction)_wrap_Sid_sid_rev_num_get, METH_O, NULL}, + { (char *)"Sid_num_auths_get", (PyCFunction)_wrap_Sid_num_auths_get, METH_O, NULL}, + { (char *)"Sid_id_auth_get", (PyCFunction)_wrap_Sid_id_auth_get, METH_O, NULL}, + { (char *)"Sid_sub_auths_get", (PyCFunction)_wrap_Sid_sub_auths_get, METH_O, NULL}, { (char *)"new_Sid", (PyCFunction) _wrap_new_Sid, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Sid___str__", (PyCFunction)_wrap_Sid___str__, METH_O, NULL}, { (char *)"Sid___eq__", (PyCFunction) _wrap_Sid___eq__, METH_VARARGS | METH_KEYWORDS, NULL}, diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py index 82ce7aeba8..b539de833d 100644 --- a/source4/libcli/security/tests/bindings.py +++ b/source4/libcli/security/tests/bindings.py @@ -65,6 +65,10 @@ class DomSidTests(unittest.TestCase): sid = security.random_sid() self.assertTrue(str(sid).startswith("S-1-5-21-")) + def test_repr(self): + sid = security.random_sid() + self.assertTrue(repr(sid).startswith("Sid('S-1-5-21-")) + class PrivilegeTests(unittest.TestCase): def test_privilege_name(self): diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c index 43151943d3..bbfcf010ae 100644 --- a/source4/libcli/smb2/connect.c +++ b/source4/libcli/smb2/connect.c @@ -184,8 +184,8 @@ static void continue_socket(struct composite_context *creq) } state->negprot.in.capabilities = 0; unix_to_nt_time(&state->negprot.in.start_time, time(NULL)); - dialects[0] = 0; - dialects[1] = SMB2_DIALECT_REVISION; + dialects[0] = SMB2_DIALECT_REVISION; + dialects[1] = 0; state->negprot.in.dialects = dialects; req = smb2_negprot_send(transport, &state->negprot); @@ -206,7 +206,13 @@ static void continue_resolve(struct composite_context *creq) struct smb2_connect_state *state = talloc_get_type(c->private_data, struct smb2_connect_state); const char *addr; - const char *ports[2] = { "445", NULL }; + const char **ports; + const char *default_ports[] = { "445", NULL }; + + ports = lp_parm_string_list(state, global_loadparm, NULL, "smb2", "ports", NULL); + if (ports == NULL) { + ports = default_ports; + } c->status = resolve_name_recv(creq, state, &addr); if (!composite_is_ok(c)) return; diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index 64d427f889..cc355fc33e 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -23,7 +23,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" #include "libcli/smb2/smb2.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" #include "libcli/smb2/smb2_calls.h" #include "param/param.h" @@ -279,7 +279,7 @@ NTSTATUS smb2_pull_o16s16_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ { uint16_t ofs, size; if (smb2_oob(buf, ptr, 4)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } ofs = SVAL(ptr, 0); size = SVAL(ptr, 2); @@ -288,7 +288,7 @@ NTSTATUS smb2_pull_o16s16_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ return NT_STATUS_OK; } if (smb2_oob(buf, buf->hdr + ofs, size)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size); NT_STATUS_HAVE_NO_MEMORY(blob->data); @@ -315,12 +315,12 @@ NTSTATUS smb2_push_o16s16_blob(struct smb2_request_buffer *buf, /* we have only 16 bit for the size */ if (blob.length > 0xFFFF) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } /* check if there're enough room for ofs and size */ if (smb2_oob(buf, ptr, 4)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } if (blob.data == NULL) { @@ -376,7 +376,7 @@ NTSTATUS smb2_push_o16s32_blob(struct smb2_request_buffer *buf, /* check if there're enough room for ofs and size */ if (smb2_oob(buf, ptr, 6)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } if (blob.data == NULL) { @@ -432,7 +432,7 @@ NTSTATUS smb2_push_o32s32_blob(struct smb2_request_buffer *buf, /* check if there're enough room for ofs and size */ if (smb2_oob(buf, ptr, 8)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } if (blob.data == NULL) { @@ -488,7 +488,7 @@ NTSTATUS smb2_push_s32o32_blob(struct smb2_request_buffer *buf, /* check if there're enough room for ofs and size */ if (smb2_oob(buf, ptr, 8)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } if (blob.data == NULL) { @@ -533,7 +533,7 @@ NTSTATUS smb2_pull_o16s32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ uint32_t size; if (smb2_oob(buf, ptr, 6)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } ofs = SVAL(ptr, 0); size = IVAL(ptr, 2); @@ -542,7 +542,7 @@ NTSTATUS smb2_pull_o16s32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ return NT_STATUS_OK; } if (smb2_oob(buf, buf->hdr + ofs, size)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size); NT_STATUS_HAVE_NO_MEMORY(blob->data); @@ -557,7 +557,7 @@ NTSTATUS smb2_pull_o32s32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ { uint32_t ofs, size; if (smb2_oob(buf, ptr, 8)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } ofs = IVAL(ptr, 0); size = IVAL(ptr, 4); @@ -566,7 +566,7 @@ NTSTATUS smb2_pull_o32s32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ return NT_STATUS_OK; } if (smb2_oob(buf, buf->hdr + ofs, size)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size); NT_STATUS_HAVE_NO_MEMORY(blob->data); @@ -584,7 +584,7 @@ NTSTATUS smb2_pull_o16As32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem { uint32_t ofs, size; if (smb2_oob(buf, ptr, 8)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } ofs = SVAL(ptr, 0); size = IVAL(ptr, 4); @@ -593,7 +593,7 @@ NTSTATUS smb2_pull_o16As32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem return NT_STATUS_OK; } if (smb2_oob(buf, buf->hdr + ofs, size)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size); NT_STATUS_HAVE_NO_MEMORY(blob->data); @@ -608,7 +608,7 @@ NTSTATUS smb2_pull_s32o32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ { uint32_t ofs, size; if (smb2_oob(buf, ptr, 8)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; } size = IVAL(ptr, 0); ofs = IVAL(ptr, 4); @@ -617,7 +617,31 @@ NTSTATUS smb2_pull_s32o32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ return NT_STATUS_OK; } if (smb2_oob(buf, buf->hdr + ofs, size)) { - return NT_STATUS_BUFFER_TOO_SMALL; + return NT_STATUS_INVALID_PARAMETER; + } + *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size); + NT_STATUS_HAVE_NO_MEMORY(blob->data); + return NT_STATUS_OK; +} + +/* + pull a uint32_t length/ uint16_t ofs/blob triple from a data blob + the ptr points to the start of the offset/length pair +*/ +NTSTATUS smb2_pull_s32o16_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ctx, uint8_t *ptr, DATA_BLOB *blob) +{ + uint32_t ofs, size; + if (smb2_oob(buf, ptr, 8)) { + return NT_STATUS_INVALID_PARAMETER; + } + size = IVAL(ptr, 0); + ofs = SVAL(ptr, 4); + if (ofs == 0) { + *blob = data_blob(NULL, 0); + return NT_STATUS_OK; + } + if (smb2_oob(buf, buf->hdr + ofs, size)) { + return NT_STATUS_INVALID_PARAMETER; } *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size); NT_STATUS_HAVE_NO_MEMORY(blob->data); diff --git a/source4/libcli/smb2/signing.c b/source4/libcli/smb2/signing.c index de9e1e9d29..101fb00c12 100644 --- a/source4/libcli/smb2/signing.c +++ b/source4/libcli/smb2/signing.c @@ -23,7 +23,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" /* sign an outgoing message diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index f00107de60..9d63a4a95f 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -178,6 +178,7 @@ struct smb2_request { #define SMB2_MIN_SIZE 0x42 +#define SMB2_MIN_SIZE_NO_BODY 0x40 /* offsets into header elements for a sync SMB2 request */ #define SMB2_HDR_PROTOCOL_ID 0x00 diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c index b946a102c8..6d7531f4b5 100644 --- a/source4/libcli/smb2/transport.c +++ b/source4/libcli/smb2/transport.c @@ -27,7 +27,7 @@ #include "lib/socket/socket.h" #include "lib/events/events.h" #include "lib/stream/packet.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* diff --git a/source4/libcli/smb2/util.c b/source4/libcli/smb2/util.c index 311cea94a0..a360d8fbdf 100644 --- a/source4/libcli/smb2/util.c +++ b/source4/libcli/smb2/util.c @@ -138,7 +138,7 @@ int smb2_deltree(struct smb2_tree *tree, const char *dname) } ZERO_STRUCT(create_parm); - create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED; + create_parm.in.desired_access = SEC_FILE_READ_DATA; create_parm.in.share_access = NTCREATEX_SHARE_ACCESS_READ| NTCREATEX_SHARE_ACCESS_WRITE; @@ -197,6 +197,12 @@ int smb2_deltree(struct smb2_tree *tree, const char *dname) smb2_util_close(tree, create_parm.out.file.handle); status = smb2_util_rmdir(tree, dname); + if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { + /* it could be read-only */ + status = smb2_util_setatr(tree, dname, FILE_ATTRIBUTE_NORMAL); + status = smb2_util_rmdir(tree, dname); + } + if (NT_STATUS_IS_ERR(status)) { DEBUG(2,("Failed to delete %s - %s\n", dname, nt_errstr(status))); diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index e56339f96b..a4137290bb 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -234,7 +234,7 @@ static NTSTATUS connect_negprot(struct composite_context *c, NT_STATUS_NOT_OK_RETURN(status); /* next step is a session setup */ - state->session = smbcli_session_init(state->transport, state, true); + state->session = smbcli_session_init(state->transport, state, true, io->in.session_options); NT_STATUS_HAVE_NO_MEMORY(state->session); /* setup for a tconx (or at least have the structure ready to diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c index 9cd02a51f4..ff4f0e7930 100644 --- a/source4/libcli/smb_composite/fetchfile.c +++ b/source4/libcli/smb_composite/fetchfile.c @@ -147,6 +147,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc state->connect->in.workgroup = io->in.workgroup; state->connect->in.options = io->in.options; + state->connect->in.session_options = io->in.session_options; state->creq = smb_composite_connect_send(state->connect, state, io->in.resolve_ctx, event_ctx); diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c index 270d71f518..dc5327a29c 100644 --- a/source4/libcli/smb_composite/fsinfo.c +++ b/source4/libcli/smb_composite/fsinfo.c @@ -127,7 +127,8 @@ static void fsinfo_composite_handler(struct composite_context *creq) composite fsinfo call - connects to a tree and queries a file system information */ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree, - struct smb_composite_fsinfo *io) + struct smb_composite_fsinfo *io, + struct resolve_context *resolve_ctx) { struct composite_context *c; struct fsinfo_state *state; @@ -154,13 +155,14 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree, state->connect->in.workgroup = io->in.workgroup; state->connect->in.options = tree->session->transport->options; + state->connect->in.session_options = tree->session->options; c->state = COMPOSITE_STATE_IN_PROGRESS; state->stage = FSINFO_CONNECT; c->private_data = state; state->creq = smb_composite_connect_send(state->connect, state, - lp_resolve_context(global_loadparm), c->event_ctx); + resolve_ctx, c->event_ctx); if (state->creq == NULL) goto failed; @@ -197,9 +199,10 @@ NTSTATUS smb_composite_fsinfo_recv(struct composite_context *c, TALLOC_CTX *mem_ */ NTSTATUS smb_composite_fsinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - struct smb_composite_fsinfo *io) + struct smb_composite_fsinfo *io, + struct resolve_context *resolve_ctx) { - struct composite_context *c = smb_composite_fsinfo_send(tree, io); + struct composite_context *c = smb_composite_fsinfo_send(tree, io, resolve_ctx); return smb_composite_fsinfo_recv(c, mem_ctx); } diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c index 11ac37e257..645f5362ac 100644 --- a/source4/libcli/smb_composite/sesssetup.c +++ b/source4/libcli/smb_composite/sesssetup.c @@ -35,6 +35,7 @@ struct sesssetup_state { union smb_sesssetup setup; + NTSTATUS remote_status; NTSTATUS gensec_status; struct smb_composite_sesssetup *io; struct smbcli_request *req; @@ -85,10 +86,26 @@ static void request_handler(struct smbcli_request *req) DATA_BLOB session_key = data_blob(NULL, 0); DATA_BLOB null_data_blob = data_blob(NULL, 0); NTSTATUS session_key_err, nt_status; + struct smbcli_request *check_req = NULL; - c->status = smb_raw_sesssetup_recv(req, state, &state->setup); + if (req->sign_caller_checks) { + req->do_not_free = true; + check_req = req; + } + + state->remote_status = smb_raw_sesssetup_recv(req, state, &state->setup); + c->status = state->remote_status; state->req = NULL; + /* + * we only need to check the signature if the + * NT_STATUS_OK is returned + */ + if (!NT_STATUS_IS_OK(state->remote_status)) { + talloc_free(check_req); + check_req = NULL; + } + switch (state->setup.old.level) { case RAW_SESSSETUP_OLD: state->io->out.vuid = state->setup.old.out.vuid; @@ -102,6 +119,7 @@ static void request_handler(struct smbcli_request *req) state->io, &state->req); if (NT_STATUS_IS_OK(nt_status)) { + talloc_free(check_req); c->status = nt_status; composite_continue_smb(c, state->req, request_handler, c); return; @@ -120,6 +138,7 @@ static void request_handler(struct smbcli_request *req) state->io, &state->req); if (NT_STATUS_IS_OK(nt_status)) { + talloc_free(check_req); c->status = nt_status; composite_continue_smb(c, state->req, request_handler, c); return; @@ -138,6 +157,7 @@ static void request_handler(struct smbcli_request *req) state->io, &state->req); if (NT_STATUS_IS_OK(nt_status)) { + talloc_free(check_req); c->status = nt_status; composite_continue_smb(c, state->req, request_handler, c); return; @@ -169,12 +189,16 @@ static void request_handler(struct smbcli_request *req) state->setup.spnego.in.secblob = data_blob(NULL, 0); } - /* we need to do another round of session setup. We keep going until both sides - are happy */ - session_key_err = gensec_session_key(session->gensec, &session_key); - if (NT_STATUS_IS_OK(session_key_err)) { - set_user_session_key(session, &session_key); - smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob); + if (NT_STATUS_IS_OK(state->remote_status)) { + if (state->setup.spnego.in.secblob.length) { + c->status = NT_STATUS_INTERNAL_ERROR; + break; + } + session_key_err = gensec_session_key(session->gensec, &session_key); + if (NT_STATUS_IS_OK(session_key_err)) { + set_user_session_key(session, &session_key); + smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob); + } } if (state->setup.spnego.in.secblob.length) { @@ -186,6 +210,9 @@ static void request_handler(struct smbcli_request *req) session->vuid = state->io->out.vuid; state->req = smb_raw_sesssetup_send(session, &state->setup); session->vuid = vuid; + if (state->req) { + state->req->sign_caller_checks = true; + } composite_continue_smb(c, state->req, request_handler, c); return; } @@ -196,6 +223,15 @@ static void request_handler(struct smbcli_request *req) break; } + if (check_req) { + check_req->sign_caller_checks = false; + if (!smbcli_request_check_sign_mac(check_req)) { + c->status = NT_STATUS_ACCESS_DENIED; + } + talloc_free(check_req); + check_req = NULL; + } + /* enforce the local signing required flag */ if (NT_STATUS_IS_OK(c->status) && !cli_credentials_is_anonymous(state->io->in.credentials)) { if (!session->transport->negotiate.sign_info.doing_signing @@ -222,11 +258,14 @@ static NTSTATUS session_setup_nt1(struct composite_context *c, struct smb_composite_sesssetup *io, struct smbcli_request **req) { - NTSTATUS nt_status; + NTSTATUS nt_status = NT_STATUS_INTERNAL_ERROR; struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state); DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm)); - DATA_BLOB session_key; + DATA_BLOB session_key = data_blob(NULL, 0); int flags = CLI_CRED_NTLM_AUTH; + + smbcli_temp_set_signing(session->transport); + if (session->options.lanman_auth) { flags |= CLI_CRED_LANMAN_AUTH; } @@ -258,12 +297,6 @@ static NTSTATUS session_setup_nt1(struct composite_context *c, &state->setup.nt1.in.password2, NULL, &session_key); NT_STATUS_NOT_OK_RETURN(nt_status); - - smbcli_transport_simple_set_signing(session->transport, session_key, - state->setup.nt1.in.password2); - set_user_session_key(session, &session_key); - - data_blob_free(&session_key); } else if (session->options.plaintext_auth) { const char *password = cli_credentials_get_password(io->in.credentials); state->setup.nt1.in.password1 = data_blob_talloc(state, password, strlen(password)); @@ -277,6 +310,15 @@ static NTSTATUS session_setup_nt1(struct composite_context *c, if (!*req) { return NT_STATUS_NO_MEMORY; } + + if (NT_STATUS_IS_OK(nt_status)) { + smbcli_transport_simple_set_signing(session->transport, session_key, + state->setup.nt1.in.password2); + set_user_session_key(session, &session_key); + + data_blob_free(&session_key); + } + return (*req)->status; } @@ -350,9 +392,7 @@ static NTSTATUS session_setup_spnego(struct composite_context *c, struct smbcli_request **req) { struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state); - NTSTATUS status, session_key_err; - DATA_BLOB session_key = data_blob(NULL, 0); - DATA_BLOB null_data_blob = data_blob(NULL, 0); + NTSTATUS status; const char *chosen_oid = NULL; state->setup.spnego.level = RAW_SESSSETUP_SPNEGO; @@ -440,15 +480,18 @@ static NTSTATUS session_setup_spnego(struct composite_context *c, } state->gensec_status = status; - session_key_err = gensec_session_key(session->gensec, &session_key); - if (NT_STATUS_IS_OK(session_key_err)) { - smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob); - } - *req = smb_raw_sesssetup_send(session, &state->setup); if (!*req) { return NT_STATUS_NO_MEMORY; } + + /* + * we need to check the signature ourself + * as the session key might be the acceptor subkey + * which comes within the response itself + */ + (*req)->sign_caller_checks = true; + return (*req)->status; } diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h index 7f4b9d73e4..08ca40c833 100644 --- a/source4/libcli/smb_composite/smb_composite.h +++ b/source4/libcli/smb_composite/smb_composite.h @@ -57,6 +57,7 @@ struct smb_composite_fetchfile { const char *workgroup; const char *filename; struct smbcli_options options; + struct smbcli_session_options session_options; struct resolve_context *resolve_ctx; } in; struct { @@ -98,6 +99,7 @@ struct smb_composite_connect { bool fallback_to_anonymous; const char *workgroup; struct smbcli_options options; + struct smbcli_session_options session_options; } in; struct { struct smbcli_tree *tree; diff --git a/source4/libcli/swig/libcli_smb.i b/source4/libcli/swig/libcli_smb.i index 4125bcf5a9..0162b7b66a 100644 --- a/source4/libcli/swig/libcli_smb.i +++ b/source4/libcli/swig/libcli_smb.i @@ -1,6 +1,6 @@ %module libcli_smb -%import "../../lib/talloc/talloc.i" +%import "../../../lib/talloc/talloc.i" %import "../../lib/events/events.i" %{ diff --git a/source4/libcli/swig/libcli_smb.py b/source4/libcli/swig/libcli_smb.py index 6e4fe036c7..4662618fd3 100644 --- a/source4/libcli/swig/libcli_smb.py +++ b/source4/libcli/swig/libcli_smb.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/libcli/swig/libcli_smb_wrap.c b/source4/libcli/swig/libcli_smb_wrap.c index a3ea079b83..99bbdc7f96 100644 --- a/source4/libcli/swig/libcli_smb_wrap.c +++ b/source4/libcli/swig/libcli_smb_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2513,7 +2519,7 @@ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0}; #define SWIG_name "_libcli_smb" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2603,7 +2609,6 @@ SWIGINTERN PyObject *_wrap_smbcli_sock_connect_byname(PyObject *SWIGUNUSEDPARM(s TALLOC_CTX *arg3 = (TALLOC_CTX *) 0 ; struct resolve_context *arg4 = (struct resolve_context *) 0 ; struct event_context *arg5 = (struct event_context *) 0 ; - struct smbcli_socket *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2620,8 +2625,9 @@ SWIGINTERN PyObject *_wrap_smbcli_sock_connect_byname(PyObject *SWIGUNUSEDPARM(s char * kwnames[] = { (char *) "host",(char *) "ports",(char *) "resolve_ctx",(char *) "event_ctx", NULL }; + struct smbcli_socket *result = 0 ; - arg5 = s4_event_context_init(NULL); + arg5 = event_context_init(NULL); arg3 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:smbcli_sock_connect_byname",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 1eb2de83d2..abca8f49b2 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -349,7 +349,7 @@ NTSTATUS smblsa_sid_del_privileges(struct smbcli_state *cli, struct dom_sid *sid r.in.handle = &cli->lsa->handle; r.in.sid = sid; - r.in.unknown = 0; + r.in.remove_all = 0; r.in.rights = rights; return dcerpc_lsa_RemoveAccountRights(cli->lsa->pipe, mem_ctx, &r); diff --git a/source4/libcli/util/ntstatus.h b/source4/libcli/util/ntstatus.h index 9c7bee0dfe..7d223ae789 100644 --- a/source4/libcli/util/ntstatus.h +++ b/source4/libcli/util/ntstatus.h @@ -597,6 +597,7 @@ typedef uint32_t NTSTATUS; #define NT_STATUS_DOWNGRADE_DETECTED NT_STATUS(0xC0000000 | 0x0388) #define NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED NT_STATUS(0xC0000000 | 0x20004) #define NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX NT_STATUS(0xC0000000 | 0x20026) +#define NT_STATUS_RPC_NT_CALL_FAILED NT_STATUS(0xC0000000 | 0x2001B) /* I use NT_STATUS_FOOBAR when I have no idea what error code to use - diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 0a4e52bd7b..84bda8c858 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -21,7 +21,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/socket/socket.h" #include "libcli/wrepl/winsrepl.h" #include "librpc/gen_ndr/ndr_winsrepl.h" diff --git a/source4/libnet/groupinfo.c b/source4/libnet/groupinfo.c index 6c8580a662..1da6646702 100644 --- a/source4/libnet/groupinfo.c +++ b/source4/libnet/groupinfo.c @@ -30,6 +30,7 @@ #include "libnet/userman.h" #include "libnet/groupinfo.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "libnet/libnet_proto.h" struct groupinfo_state { diff --git a/source4/libnet/groupman.c b/source4/libnet/groupman.c index 1e12c87713..58d5742336 100644 --- a/source4/libnet/groupman.c +++ b/source4/libnet/groupman.c @@ -26,6 +26,7 @@ #include "libnet/composite.h" #include "libnet/groupman.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "libnet/libnet_proto.h" struct groupadd_state { diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index 332b041e36..6e7924248c 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -770,7 +770,7 @@ static void becomeDC_recv_cldap(struct cldap_request *req) c->status = cldap_netlogon_recv(req, s, &s->cldap.io); if (!composite_is_ok(c)) return; - s->cldap.netlogon = s->cldap.io.out.netlogon.nt5_ex; + s->cldap.netlogon = s->cldap.io.out.netlogon.data.nt5_ex; s->domain.dns_name = s->cldap.netlogon.dns_domain; s->domain.netbios_name = s->cldap.netlogon.domain; @@ -820,8 +820,8 @@ static NTSTATUS becomeDC_ldap1_rootdse(struct libnet_BecomeDC_state *s) basedn = ldb_dn_new(s, s->ldap1.ldb, NULL); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -829,7 +829,6 @@ static NTSTATUS becomeDC_ldap1_rootdse(struct libnet_BecomeDC_state *s) talloc_free(r); return NT_STATUS_INVALID_NETWORK_RESPONSE; } - talloc_steal(s, r); s->ldap1.rootdse = r->msgs[0]; @@ -864,8 +863,8 @@ static NTSTATUS becomeDC_ldap1_crossref_behavior_version(struct libnet_BecomeDC_ basedn = ldb_dn_new(s, s->ldap1.ldb, s->forest.config_dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_ONELEVEL, - "(cn=Partitions)", attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_ONELEVEL, attrs, + "(cn=Partitions)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -893,8 +892,8 @@ static NTSTATUS becomeDC_ldap1_domain_behavior_version(struct libnet_BecomeDC_st basedn = ldb_dn_new(s, s->ldap1.ldb, s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -922,8 +921,8 @@ static NTSTATUS becomeDC_ldap1_schema_object_version(struct libnet_BecomeDC_stat basedn = ldb_dn_new(s, s->ldap1.ldb, s->forest.schema_dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -952,8 +951,8 @@ static NTSTATUS becomeDC_ldap1_w2k3_update_revision(struct libnet_BecomeDC_state s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); talloc_free(basedn); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* w2k doesn't have this object */ @@ -1000,8 +999,8 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", _1_1_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + _1_1_attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -1013,8 +1012,8 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state basedn = talloc_steal(s, r->msgs[0]->dn); talloc_free(r); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", fsmo_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + fsmo_attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -1038,8 +1037,8 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state s->infrastructure_fsmo.server_dn_str = ldb_dn_alloc_linearized(s, server_dn); NT_STATUS_HAVE_NO_MEMORY(s->infrastructure_fsmo.server_dn_str); - ret = ldb_search(s->ldap1.ldb, server_dn, LDB_SCOPE_BASE, - "(objectClass=*)", dns_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, server_dn, LDB_SCOPE_BASE, + dns_attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); } else if (r->count != 1) { @@ -1053,8 +1052,8 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state talloc_free(r); - ret = ldb_search(s->ldap1.ldb, ntds_dn, LDB_SCOPE_BASE, - "(objectClass=*)", guid_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, ntds_dn, LDB_SCOPE_BASE, + guid_attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); } else if (r->count != 1) { @@ -1097,8 +1096,8 @@ static NTSTATUS becomeDC_ldap1_rid_manager_fsmo(struct libnet_BecomeDC_state *s) basedn = ldb_dn_new(s, s->ldap1.ldb, s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", rid_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + rid_attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -1115,8 +1114,8 @@ static NTSTATUS becomeDC_ldap1_rid_manager_fsmo(struct libnet_BecomeDC_state *s) talloc_free(r); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", fsmo_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + fsmo_attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -1140,8 +1139,8 @@ static NTSTATUS becomeDC_ldap1_rid_manager_fsmo(struct libnet_BecomeDC_state *s) s->rid_manager_fsmo.server_dn_str = ldb_dn_alloc_linearized(s, server_dn); NT_STATUS_HAVE_NO_MEMORY(s->rid_manager_fsmo.server_dn_str); - ret = ldb_search(s->ldap1.ldb, server_dn, LDB_SCOPE_BASE, - "(objectClass=*)", dns_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, server_dn, LDB_SCOPE_BASE, + dns_attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); } else if (r->count != 1) { @@ -1155,8 +1154,8 @@ static NTSTATUS becomeDC_ldap1_rid_manager_fsmo(struct libnet_BecomeDC_state *s) talloc_free(r); - ret = ldb_search(s->ldap1.ldb, ntds_dn, LDB_SCOPE_BASE, - "(objectClass=*)", guid_attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, ntds_dn, LDB_SCOPE_BASE, + guid_attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); } else if (r->count != 1) { @@ -1182,8 +1181,8 @@ static NTSTATUS becomeDC_ldap1_site_object(struct libnet_BecomeDC_state *s) s->forest.config_dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", NULL, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + NULL, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -1214,7 +1213,6 @@ static NTSTATUS becomeDC_ldap1_computer_object(struct libnet_BecomeDC_state *s) int ret; struct ldb_result *r; struct ldb_dn *basedn; - char *filter; static const char *attrs[] = { "distinguishedName", "userAccountControl", @@ -1224,12 +1222,9 @@ static NTSTATUS becomeDC_ldap1_computer_object(struct libnet_BecomeDC_state *s) basedn = ldb_dn_new(s, s->ldap1.ldb, s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - filter = talloc_asprintf(basedn, "(&(|(objectClass=user)(objectClass=computer))(sAMAccountName=%s$))", - s->dest_dsa.netbios_name); - NT_STATUS_HAVE_NO_MEMORY(filter); - - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_SUBTREE, - filter, attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_SUBTREE, attrs, + "(&(|(objectClass=user)(objectClass=computer))(sAMAccountName=%s$))", + s->dest_dsa.netbios_name); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -1263,8 +1258,8 @@ static NTSTATUS becomeDC_ldap1_server_object_1(struct libnet_BecomeDC_state *s) s->forest.config_dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", NULL, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + NULL, "(objectClass=*)"); talloc_free(basedn); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* if the object doesn't exist, we'll create it later */ @@ -1320,8 +1315,8 @@ static NTSTATUS becomeDC_ldap1_server_object_2(struct libnet_BecomeDC_state *s) basedn = ldb_dn_new(s, s->ldap1.ldb, s->dest_dsa.computer_dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->ldap1.ldb, s, &r, basedn, LDB_SCOPE_BASE, + attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -2178,11 +2173,15 @@ static void becomeDC_drsuapi1_add_entry_send(struct libnet_BecomeDC_state *s) /* setup request structure */ r->in.bind_handle = &s->drsuapi1.bind_handle; r->in.level = 2; - r->in.req.req2.first_object.next_object = NULL; - r->in.req.req2.first_object.object.identifier = identifier; - r->in.req.req2.first_object.object.flags = 0x00000000; - r->in.req.req2.first_object.object.attribute_ctr.num_attributes = num_attrs; - r->in.req.req2.first_object.object.attribute_ctr.attributes = attrs; + r->in.req = talloc(s, union drsuapi_DsAddEntryRequest); + r->in.req->req2.first_object.next_object = NULL; + r->in.req->req2.first_object.object.identifier = identifier; + r->in.req->req2.first_object.object.flags = 0x00000000; + r->in.req->req2.first_object.object.attribute_ctr.num_attributes= num_attrs; + r->in.req->req2.first_object.object.attribute_ctr.attributes = attrs; + + r->out.level_out = talloc(s, int32_t); + r->out.ctr = talloc(s, union drsuapi_DsAddEntryCtr); req = dcerpc_drsuapi_DsAddEntry_send(s->drsuapi1.pipe, r, r); composite_continue_rpc(c, req, becomeDC_drsuapi1_add_entry_recv, s); @@ -2217,37 +2216,37 @@ static void becomeDC_drsuapi1_add_entry_recv(struct rpc_request *req) return; } - if (r->out.level == 3) { - if (r->out.ctr.ctr3.count != 1) { + if (*r->out.level_out == 3) { + if (r->out.ctr->ctr3.count != 1) { WERROR status; - if (r->out.ctr.ctr3.level != 1) { + if (r->out.ctr->ctr3.level != 1) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } - if (!r->out.ctr.ctr3.error) { + if (!r->out.ctr->ctr3.error) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } - status = r->out.ctr.ctr3.error->info1.status; + status = r->out.ctr->ctr3.error->info1.status; - if (!r->out.ctr.ctr3.error->info1.info) { + if (!r->out.ctr->ctr3.error->info1.info) { composite_error(c, werror_to_ntstatus(status)); return; } /* see if we can get a more detailed error */ - switch (r->out.ctr.ctr3.error->info1.level) { + switch (r->out.ctr->ctr3.error->info1.level) { case 1: - status = r->out.ctr.ctr3.error->info1.info->error1.status; + status = r->out.ctr->ctr3.error->info1.info->error1.status; break; case 4: case 5: case 6: case 7: - status = r->out.ctr.ctr3.error->info1.info->errorX.status; + status = r->out.ctr->ctr3.error->info1.info->errorX.status; break; } @@ -2255,14 +2254,14 @@ static void becomeDC_drsuapi1_add_entry_recv(struct rpc_request *req) return; } - s->dest_dsa.ntds_guid = r->out.ctr.ctr3.objects[0].guid; - } else if (r->out.level == 2) { - if (r->out.ctr.ctr2.count != 1) { - composite_error(c, werror_to_ntstatus(r->out.ctr.ctr2.error.status)); + s->dest_dsa.ntds_guid = r->out.ctr->ctr3.objects[0].guid; + } else if (*r->out.level_out == 2) { + if (r->out.ctr->ctr2.count != 1) { + composite_error(c, werror_to_ntstatus(r->out.ctr->ctr2.error.status)); return; } - s->dest_dsa.ntds_guid = r->out.ctr.ctr2.objects[0].guid; + s->dest_dsa.ntds_guid = r->out.ctr->ctr2.objects[0].guid; } else { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; @@ -2397,40 +2396,42 @@ static void becomeDC_drsuapi_pull_partition_send(struct libnet_BecomeDC_state *s r = talloc(s, struct drsuapi_DsGetNCChanges); if (composite_nomem(r, c)) return; - r->in.level = talloc(r, int32_t); - if (composite_nomem(r->in.level, c)) return; - r->out.level = talloc(r, int32_t); - if (composite_nomem(r->out.level, c)) return; + r->out.level_out = talloc(r, int32_t); + if (composite_nomem(r->out.level_out, c)) return; + r->in.req = talloc(r, union drsuapi_DsGetNCChangesRequest); + if (composite_nomem(r->in.req, c)) return; + r->out.ctr = talloc(r, union drsuapi_DsGetNCChangesCtr); + if (composite_nomem(r->out.ctr, c)) return; r->in.bind_handle = &drsuapi_h->bind_handle; if (drsuapi_h->remote_info28.supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) { - *r->in.level = 8; - r->in.req.req8.destination_dsa_guid = partition->destination_dsa_guid; - r->in.req.req8.source_dsa_invocation_id = partition->source_dsa_invocation_id; - r->in.req.req8.naming_context = &partition->nc; - r->in.req.req8.highwatermark = partition->highwatermark; - r->in.req.req8.uptodateness_vector = NULL; - r->in.req.req8.replica_flags = partition->replica_flags; - r->in.req.req8.max_object_count = 133; - r->in.req.req8.max_ndr_size = 1336811; - r->in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req8.fsmo_info = 0; - r->in.req.req8.partial_attribute_set = NULL; - r->in.req.req8.partial_attribute_set_ex = NULL; - r->in.req.req8.mapping_ctr.num_mappings = 0; - r->in.req.req8.mapping_ctr.mappings = NULL; + r->in.level = 8; + r->in.req->req8.destination_dsa_guid = partition->destination_dsa_guid; + r->in.req->req8.source_dsa_invocation_id= partition->source_dsa_invocation_id; + r->in.req->req8.naming_context = &partition->nc; + r->in.req->req8.highwatermark = partition->highwatermark; + r->in.req->req8.uptodateness_vector = NULL; + r->in.req->req8.replica_flags = partition->replica_flags; + r->in.req->req8.max_object_count = 133; + r->in.req->req8.max_ndr_size = 1336811; + r->in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req8.fsmo_info = 0; + r->in.req->req8.partial_attribute_set = NULL; + r->in.req->req8.partial_attribute_set_ex= NULL; + r->in.req->req8.mapping_ctr.num_mappings= 0; + r->in.req->req8.mapping_ctr.mappings = NULL; } else { - *r->in.level = 5; - r->in.req.req5.destination_dsa_guid = partition->destination_dsa_guid; - r->in.req.req5.source_dsa_invocation_id = partition->source_dsa_invocation_id; - r->in.req.req5.naming_context = &partition->nc; - r->in.req.req5.highwatermark = partition->highwatermark; - r->in.req.req5.uptodateness_vector = NULL; - r->in.req.req5.replica_flags = partition->replica_flags; - r->in.req.req5.max_object_count = 133; - r->in.req.req5.max_ndr_size = 1336770; - r->in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req5.fsmo_info = 0; + r->in.level = 5; + r->in.req->req5.destination_dsa_guid = partition->destination_dsa_guid; + r->in.req->req5.source_dsa_invocation_id= partition->source_dsa_invocation_id; + r->in.req->req5.naming_context = &partition->nc; + r->in.req->req5.highwatermark = partition->highwatermark; + r->in.req->req5.uptodateness_vector = NULL; + r->in.req->req5.replica_flags = partition->replica_flags; + r->in.req->req5.max_object_count = 133; + r->in.req->req5.max_ndr_size = 1336770; + r->in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req5.fsmo_info = 0; } /* @@ -2462,28 +2463,28 @@ static WERROR becomeDC_drsuapi_pull_partition_recv(struct libnet_BecomeDC_state return r->out.result; } - if (*r->out.level == 1) { + if (*r->out.level_out == 1) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr1; - } else if (*r->out.level == 2 && - r->out.ctr.ctr2.mszip1.ts) { + ctr1 = &r->out.ctr->ctr1; + } else if (*r->out.level_out == 2 && + r->out.ctr->ctr2.mszip1.ts) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr2.mszip1.ts->ctr1; - } else if (*r->out.level == 6) { + ctr1 = &r->out.ctr->ctr2.mszip1.ts->ctr1; + } else if (*r->out.level_out == 6) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && - r->out.ctr.ctr7.ctr.mszip6.ts) { + ctr6 = &r->out.ctr->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && + r->out.ctr->ctr7.ctr.mszip6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.mszip6.ts->ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && - r->out.ctr.ctr7.ctr.xpress6.ts) { + ctr6 = &r->out.ctr->ctr7.ctr.mszip6.ts->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && + r->out.ctr->ctr7.ctr.xpress6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.xpress6.ts->ctr6; + ctr6 = &r->out.ctr->ctr7.ctr.xpress6.ts->ctr6; } else { return WERR_BAD_NET_RESP; } @@ -2908,8 +2909,8 @@ static NTSTATUS becomeDC_ldap2_move_computer(struct libnet_BecomeDC_state *s) s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap2.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", _1_1_attrs, &r); + ret = ldb_search(s->ldap2.ldb, s, &r, basedn, LDB_SCOPE_BASE, + _1_1_attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index 5776888cb0..0ed5e8ae26 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -27,7 +27,7 @@ #include "param/secrets.h" #include "dsdb/samdb/samdb.h" #include "ldb_wrap.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "libcli/security/security.h" #include "auth/credentials/credentials.h" #include "auth/credentials/credentials_krb5.h" @@ -162,13 +162,19 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J ZERO_STRUCT(r_crack_names); r_crack_names.in.bind_handle = &drsuapi_bind_handle; r_crack_names.in.level = 1; - r_crack_names.in.req.req1.codepage = 1252; /* western european */ - r_crack_names.in.req.req1.language = 0x00000407; /* german */ - r_crack_names.in.req.req1.count = 1; - r_crack_names.in.req.req1.names = names; - r_crack_names.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; - r_crack_names.in.req.req1.format_offered= DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r_crack_names.in.req.req1.format_desired= DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r_crack_names.in.req = talloc(r, union drsuapi_DsNameRequest); + if (!r_crack_names.in.req) { + r->out.error_string = NULL; + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } + r_crack_names.in.req->req1.codepage = 1252; /* western european */ + r_crack_names.in.req->req1.language = 0x00000407; /* german */ + r_crack_names.in.req->req1.count = 1; + r_crack_names.in.req->req1.names = names; + r_crack_names.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r_crack_names.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r_crack_names.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = dom_sid_string(tmp_ctx, r->out.account_sid); if (!names[0].str) { r->out.error_string = NULL; @@ -176,6 +182,14 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J return NT_STATUS_NO_MEMORY; } + r_crack_names.out.ctr = talloc(r, union drsuapi_DsNameCtr); + r_crack_names.out.level_out = talloc(r, int32_t); + if (!r_crack_names.out.ctr || !r_crack_names.out.level_out) { + r->out.error_string = NULL; + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } + status = dcerpc_drsuapi_DsCrackNames(drsuapi_pipe, tmp_ctx, &r_crack_names); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { @@ -201,24 +215,24 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J "DsCrackNames failed - %s", win_errstr(r_crack_names.out.result)); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; - } else if (r_crack_names.out.level != 1 - || !r_crack_names.out.ctr.ctr1 - || r_crack_names.out.ctr.ctr1->count != 1) { + } else if (*r_crack_names.out.level_out != 1 + || !r_crack_names.out.ctr->ctr1 + || r_crack_names.out.ctr->ctr1->count != 1) { r->out.error_string = talloc_asprintf(r, "DsCrackNames failed"); talloc_free(tmp_ctx); return NT_STATUS_INVALID_PARAMETER; - } else if (r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: %d", r_crack_names.out.ctr.ctr1->array[0].status); + } else if (r_crack_names.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: %d", r_crack_names.out.ctr->ctr1->array[0].status); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; - } else if (r_crack_names.out.ctr.ctr1->array[0].result_name == NULL) { + } else if (r_crack_names.out.ctr->ctr1->array[0].result_name == NULL) { r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: no result name"); talloc_free(tmp_ctx); return NT_STATUS_INVALID_PARAMETER; } /* Store the DN of our machine account. */ - account_dn_str = r_crack_names.out.ctr.ctr1->array[0].result_name; + account_dn_str = r_crack_names.out.ctr->ctr1->array[0].result_name; /* Now we know the user's DN, open with LDAP, read and modify a few things */ @@ -248,8 +262,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J } /* search for the user's record */ - ret = ldb_search(remote_ldb, account_dn, LDB_SCOPE_BASE, - NULL, attrs, &res); + ret = ldb_search(remote_ldb, tmp_ctx, &res, + account_dn, LDB_SCOPE_BASE, attrs, NULL); if (ret != LDB_SUCCESS) { r->out.error_string = talloc_asprintf(r, "ldb_search for %s failed - %s", account_dn_str, ldb_errstring(remote_ldb)); @@ -257,8 +271,6 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J return NT_STATUS_UNSUCCESSFUL; } - talloc_steal(tmp_ctx, res); - if (res->count != 1) { r->out.error_string = talloc_asprintf(r, "ldb_search for %s failed - found %d entries", account_dn_str, res->count); @@ -330,8 +342,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J } /* DsCrackNames to find out the DN of the domain. */ - r_crack_names.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r_crack_names.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r_crack_names.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r_crack_names.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(tmp_ctx, "%s\\", r->out.domain_name); if (!names[0].str) { r->out.error_string = NULL; @@ -364,11 +376,11 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J "DsCrackNames failed - %s", win_errstr(r_crack_names.out.result)); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; - } else if (r_crack_names.out.level != 1 - || !r_crack_names.out.ctr.ctr1 - || r_crack_names.out.ctr.ctr1->count != 1 - || !r_crack_names.out.ctr.ctr1->array[0].result_name - || r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + } else if (*r_crack_names.out.level_out != 1 + || !r_crack_names.out.ctr->ctr1 + || r_crack_names.out.ctr->ctr1->count != 1 + || !r_crack_names.out.ctr->ctr1->array[0].result_name + || r_crack_names.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { r->out.error_string = talloc_asprintf(r, "DsCrackNames failed"); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; @@ -379,8 +391,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J talloc_steal(r, account_dn_str); /* Store the domain DN. */ - r->out.domain_dn_str = r_crack_names.out.ctr.ctr1->array[0].result_name; - talloc_steal(r, r_crack_names.out.ctr.ctr1->array[0].result_name); + r->out.domain_dn_str = r_crack_names.out.ctr->ctr1->array[0].result_name; + talloc_steal(r, r_crack_names.out.ctr->ctr1->array[0].result_name); /* Store the KVNO of the account, critical for some kerberos * operations */ diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c index cab4d9e73f..dc54ec3cf1 100644 --- a/source4/libnet/libnet_lookup.c +++ b/source4/libnet/libnet_lookup.c @@ -129,7 +129,7 @@ NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, if (NT_STATUS_IS_OK(status)) { s = talloc_get_type(c->private_data, struct lookup_state); - io->out.address = str_list_make(mem_ctx, s->address, NULL); + io->out.address = (const char **)str_list_make(mem_ctx, s->address, NULL); NT_STATUS_HAVE_NO_MEMORY(io->out.address); } diff --git a/source4/libnet/libnet_passwd.c b/source4/libnet/libnet_passwd.c index 28d9ae8cbe..de2ed01abd 100644 --- a/source4/libnet/libnet_passwd.c +++ b/source4/libnet/libnet_passwd.c @@ -20,7 +20,7 @@ #include "includes.h" #include "libnet/libnet.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "librpc/gen_ndr/ndr_samr_c.h" diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index 9d417d280d..1fe07b60dc 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -22,7 +22,7 @@ #include "includes.h" #include "libnet/libnet.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "samba3/samba3.h" #include "libcli/security/security.h" diff --git a/source4/libnet/libnet_samdump_keytab.c b/source4/libnet/libnet_samdump_keytab.c index 0c4d3e5c59..4b71b0c24d 100644 --- a/source4/libnet/libnet_samdump_keytab.c +++ b/source4/libnet/libnet_samdump_keytab.c @@ -68,6 +68,11 @@ static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +struct libnet_samdump_keytab_data { + const char *keytab_name; + struct loadparm_context *lp_ctx; +}; + static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, void *private, enum netr_SamDatabaseID database, @@ -75,8 +80,7 @@ static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - const char *keytab_name = private; - + struct libnet_samdump_keytab_data *data = private; *error_string = NULL; switch (delta->delta_type) { case NETR_DELTA_USER: @@ -85,8 +89,8 @@ static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, if (database == SAM_DATABASE_DOMAIN) { nt_status = samdump_keytab_handle_user(mem_ctx, event_context_find(mem_ctx), - global_loadparm, - keytab_name, + data->lp_ctx, + data->keytab_name, delta); break; } @@ -101,14 +105,18 @@ static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, NTSTATUS libnet_SamDump_keytab(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_SamDump_keytab *r) { NTSTATUS nt_status; + struct libnet_samdump_keytab_data data; struct libnet_SamSync r2; + data.keytab_name = r->in.keytab_name; + data.lp_ctx = ctx->lp_ctx; + r2.out.error_string = NULL; r2.in.binding_string = r->in.binding_string; r2.in.rid_crypt = true; r2.in.init_fn = NULL; r2.in.delta_fn = libnet_samdump_keytab_fn; - r2.in.fn_ctx = discard_const(r->in.keytab_name); + r2.in.fn_ctx = &data; r2.in.machine_account = r->in.machine_account; nt_status = libnet_SamSync_netlogon(ctx, mem_ctx, &r2); r->out.error_string = r2.out.error_string; diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c index c72aef7d70..8b7dd1f598 100644 --- a/source4/libnet/libnet_samsync_ldb.c +++ b/source4/libnet/libnet_samsync_ldb.c @@ -27,7 +27,7 @@ #include "libcli/ldap/ldap_ndr.h" #include "dsdb/samdb/samdb.h" #include "auth/auth.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "ldb_wrap.h" #include "libcli/security/security.h" diff --git a/source4/libnet/libnet_site.c b/source4/libnet/libnet_site.c index bb65de1f54..4a32ab92ed 100644 --- a/source4/libnet/libnet_site.c +++ b/source4/libnet/libnet_site.c @@ -56,9 +56,10 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; search.in.map_response = true; - cldap = cldap_socket_init(tmp_ctx, lctx->event_ctx, lp_iconv_convenience(global_loadparm)); + cldap = cldap_socket_init(tmp_ctx, lctx->event_ctx, lp_iconv_convenience(lctx->lp_ctx)); status = cldap_netlogon(cldap, tmp_ctx, &search); - if (!NT_STATUS_IS_OK(status) || !search.out.netlogon.nt5_ex.client_site) { + if (!NT_STATUS_IS_OK(status) + || !search.out.netlogon.data.nt5_ex.client_site) { /* If cldap_netlogon() returns in error, default to using Default-First-Site-Name. @@ -72,7 +73,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li } } else { site_name_str = talloc_asprintf(tmp_ctx, "%s", - search.out.netlogon.nt5_ex.client_site); + search.out.netlogon.data.nt5_ex.client_site); if (!site_name_str) { r->out.error_string = NULL; talloc_free(tmp_ctx); diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c index 6a42fa2370..79c6dc0fc1 100644 --- a/source4/libnet/libnet_unbecome_dc.c +++ b/source4/libnet/libnet_unbecome_dc.c @@ -289,7 +289,7 @@ static void unbecomeDC_recv_cldap(struct cldap_request *req) c->status = cldap_netlogon_recv(req, s, &s->cldap.io); if (!composite_is_ok(c)) return; - s->cldap.netlogon = s->cldap.io.out.netlogon.nt5_ex; + s->cldap.netlogon = s->cldap.io.out.netlogon.data.nt5_ex; s->domain.dns_name = s->cldap.netlogon.dns_domain; s->domain.netbios_name = s->cldap.netlogon.domain; @@ -337,8 +337,8 @@ static NTSTATUS unbecomeDC_ldap_rootdse(struct libnet_UnbecomeDC_state *s) basedn = ldb_dn_new(s, s->ldap.ldb, NULL); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(s->ldap.ldb, s, &r, basedn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -346,7 +346,6 @@ static NTSTATUS unbecomeDC_ldap_rootdse(struct libnet_UnbecomeDC_state *s) talloc_free(r); return NT_STATUS_INVALID_NETWORK_RESPONSE; } - talloc_steal(s, r); s->domain.dn_str = ldb_msg_find_attr_as_string(r->msgs[0], "defaultNamingContext", NULL); if (!s->domain.dn_str) return NT_STATUS_INVALID_NETWORK_RESPONSE; @@ -371,7 +370,6 @@ static NTSTATUS unbecomeDC_ldap_computer_object(struct libnet_UnbecomeDC_state * int ret; struct ldb_result *r; struct ldb_dn *basedn; - char *filter; static const char *attrs[] = { "distinguishedName", "userAccountControl", @@ -381,12 +379,9 @@ static NTSTATUS unbecomeDC_ldap_computer_object(struct libnet_UnbecomeDC_state * basedn = ldb_dn_new(s, s->ldap.ldb, s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - filter = talloc_asprintf(basedn, "(&(|(objectClass=user)(objectClass=computer))(sAMAccountName=%s$))", - s->dest_dsa.netbios_name); - NT_STATUS_HAVE_NO_MEMORY(filter); - - ret = ldb_search(s->ldap.ldb, basedn, LDB_SCOPE_SUBTREE, - filter, attrs, &r); + ret = ldb_search(s->ldap.ldb, s, &r, basedn, LDB_SCOPE_SUBTREE, attrs, + "(&(|(objectClass=user)(objectClass=computer))(sAMAccountName=%s$))", + s->dest_dsa.netbios_name); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -462,8 +457,8 @@ static NTSTATUS unbecomeDC_ldap_move_computer(struct libnet_UnbecomeDC_state *s) s->domain.dn_str); NT_STATUS_HAVE_NO_MEMORY(basedn); - ret = ldb_search(s->ldap.ldb, basedn, LDB_SCOPE_BASE, - "(objectClass=*)", _1_1_attrs, &r); + ret = ldb_search(s->ldap.ldb, s, &r, basedn, LDB_SCOPE_BASE, + _1_1_attrs, "(objectClass=*)"); talloc_free(basedn); if (ret != LDB_SUCCESS) { return NT_STATUS_LDAP(ret); @@ -644,9 +639,13 @@ static void unbecomeDC_drsuapi_remove_ds_server_send(struct libnet_UnbecomeDC_st r->in.bind_handle = &s->drsuapi.bind_handle; r->in.level = 1; - r->in.req.req1.server_dn= s->dest_dsa.server_dn_str; - r->in.req.req1.domain_dn= s->domain.dn_str; - r->in.req.req1.unknown = 0x00000001; + r->in.req = talloc(s, union drsuapi_DsRemoveDSServerRequest); + r->in.req->req1.server_dn = s->dest_dsa.server_dn_str; + r->in.req->req1.domain_dn = s->domain.dn_str; + r->in.req->req1.commit = true; + + r->out.level_out = talloc(s, int32_t); + r->out.res = talloc(s, union drsuapi_DsRemoveDSServerResult); req = dcerpc_drsuapi_DsRemoveDSServer_send(s->drsuapi.pipe, s, r); composite_continue_rpc(c, req, unbecomeDC_drsuapi_remove_ds_server_recv, s); @@ -667,15 +666,10 @@ static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request *req) return; } - if (r->out.level != 1) { + if (*r->out.level_out != 1) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } - - if (!W_ERROR_IS_OK(r->out.res.res1.status)) { - composite_error(c, werror_to_ntstatus(r->out.res.res1.status)); - return; - } composite_done(c); } diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c index 42d6f72dd1..7b686ba007 100644 --- a/source4/libnet/libnet_vampire.c +++ b/source4/libnet/libnet_vampire.c @@ -26,7 +26,7 @@ #include "libnet/libnet.h" #include "lib/events/events.h" #include "dsdb/samdb/samdb.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" #include "librpc/ndr/libndr.h" diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index 3736454fa0..d5495f1e72 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -24,7 +24,7 @@ #include "libcli/security/security.h" #include "lib/events/events.h" -struct libnet_context *py_net_ctx(PyObject *obj, struct event_context *ev) +static struct libnet_context *py_net_ctx(PyObject *obj, struct event_context *ev) { /* FIXME: Use obj */ return libnet_context_init(ev, global_loadparm); diff --git a/source4/libnet/userinfo.c b/source4/libnet/userinfo.c index 847997fc12..e8b6b090c7 100644 --- a/source4/libnet/userinfo.c +++ b/source4/libnet/userinfo.c @@ -29,6 +29,7 @@ #include "libnet/userman.h" #include "libnet/userinfo.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "libnet/libnet_proto.h" struct userinfo_state { diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c index 25ed4775cb..398d9f2cb0 100644 --- a/source4/libnet/userman.c +++ b/source4/libnet/userman.c @@ -27,6 +27,7 @@ #include "libnet/userman.h" #include "libnet/userinfo.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "libnet/libnet_proto.h" /* * Composite USER ADD functionality diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index b68d5e6a69..a988dcf420 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -8,18 +8,16 @@ dcerpcsrcdir = $(librpcsrcdir)/rpc PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET \ LIBSAMBA-HOSTCONFIG -LIBNDR_OBJ_FILES = $(addprefix $(ndrsrcdir)/, ndr.o ndr_basic.o ndr_string.o uuid.o) +LIBNDR_OBJ_FILES = $(addprefix $(ndrsrcdir)/, ndr_string.o) ../librpc/ndr/ndr_basic.o ../librpc/ndr/uuid.o ../librpc/ndr/ndr.o -$(eval $(call proto_header_template,$(ndrsrcdir)/libndr_proto.h,$(LIBNDR_OBJ_FILES:.o=.c))) - -PC_FILES += $(librpcsrcdir)/ndr.pc +PC_FILES += ../librpc/ndr.pc LIBNDR_VERSION = 0.0.1 LIBNDR_SOVERSION = 0 # End SUBSYSTEM LIBNDR ################################################ -PUBLIC_HEADERS += $(ndrsrcdir)/libndr.h +PUBLIC_HEADERS += ../librpc/ndr/libndr.h ################################# # Start BINARY ndrdump @@ -36,9 +34,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY ndrdump ################################# -ndrdump_OBJ_FILES = $(librpcsrcdir)/tools/ndrdump.o +ndrdump_OBJ_FILES = ../librpc/tools/ndrdump.o -MANPAGES += $(librpcsrcdir)/tools/ndrdump.1 +MANPAGES += ../librpc/tools/ndrdump.1 ################################################ # Start SUBSYSTEM NDR_COMPRESSION @@ -48,9 +46,7 @@ PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBNDR # End SUBSYSTEM NDR_COMPRESSION ################################################ -NDR_COMPRESSION_OBJ_FILES = $(ndrsrcdir)/ndr_compression.o - -$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_compression.h,$(NDR_COMPRESSION_OBJ_FILES:.o=.c))) +NDR_COMPRESSION_OBJ_FILES = ../librpc/ndr/ndr_compression.o [SUBSYSTEM::NDR_SECURITY] PUBLIC_DEPENDENCIES = NDR_MISC LIBSECURITY @@ -84,6 +80,16 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY NDR_NBT NDR_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc.o +[SUBSYSTEM::NDR_DCOM] +PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY NDR_ORPC + +NDR_DCOM_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dcom.o + +[SUBSYSTEM::NDR_WMI] +PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY NDR_DCOM + +NDR_WMI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wmi.o ../librpc/ndr/ndr_wmi.o + [SUBSYSTEM::NDR_DSBACKUP] PUBLIC_DEPENDENCIES = LIBNDR @@ -97,7 +103,7 @@ NDR_EFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_efs.o [SUBSYSTEM::NDR_MISC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc.o $(ndrsrcdir)/ndr_misc.o +NDR_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc.o ../librpc/ndr/ndr_misc.o PUBLIC_HEADERS += $(gen_ndrsrcdir)/misc.h $(gen_ndrsrcdir)/ndr_misc.h @@ -131,12 +137,12 @@ NDR_FRSAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsapi.o [SUBSYSTEM::NDR_DRSUAPI] PUBLIC_DEPENDENCIES = LIBNDR NDR_COMPRESSION NDR_SECURITY NDR_SAMR ASN1_UTIL -NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi.o $(ndrsrcdir)/ndr_drsuapi.o +NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi.o ../librpc/ndr/ndr_drsuapi.o [SUBSYSTEM::NDR_DRSBLOBS] -PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI LIBCLI_DRSBLOBS +PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI -NDR_DRSBLOBS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsblobs.o +NDR_DRSBLOBS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsblobs.o ../librpc/ndr/ndr_drsblobs.o [SUBSYSTEM::NDR_SASL_HELPERS] PUBLIC_DEPENDENCIES = LIBNDR @@ -253,7 +259,7 @@ NDR_PROTECTED_STORAGE_OBJ_FILES = $(gen_ndrsrcdir)/ndr_protected_storage.o [SUBSYSTEM::NDR_ORPC] PUBLIC_DEPENDENCIES = LIBNDR -NDR_ORPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_orpc.o $(ndrsrcdir)/ndr_orpc.o +NDR_ORPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_orpc.o ../librpc/ndr/ndr_orpc.o [SUBSYSTEM::NDR_OXIDRESOLVER] PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC NDR_MISC @@ -310,7 +316,7 @@ NDR_KEYSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_keysvc.o [SUBSYSTEM::NDR_KRB5PAC] PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON NDR_SECURITY -NDR_KRB5PAC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_krb5pac.o $(ndrsrcdir)/ndr_krb5pac.o +NDR_KRB5PAC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_krb5pac.o ../librpc/ndr/ndr_krb5pac.o [SUBSYSTEM::NDR_XATTR] PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY @@ -356,7 +362,7 @@ NDR_WINBIND_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winbind.o #PUBLIC_HEADERS += $(gen_ndrsrcdir)/winbind.h $(librpcsrcdir)/idl-deps: - $(PERL) $(librpcsrcdir)/idl-deps.pl $(librpcsrcdir)/idl/*.idl >$@ + $(PERL) $(librpcsrcdir)/idl-deps.pl $(filter-out ../librpc/idl/security.idl,$(wildcard $(librpcsrcdir)/idl/*.idl ../librpc/idl/*.idl)) >$@ clean:: rm -f $(librpcsrcdir)/idl-deps @@ -365,7 +371,7 @@ clean:: $(gen_ndrsrcdir)/tables.c: $(IDL_NDR_PARSE_H_FILES) @echo Generating $@ - @$(PERL) $(librpcsrcdir)/tables.pl --output=$@ $^ > $(gen_ndrsrcdir)/tables.x + @$(PERL) ../librpc/tables.pl --output=$@ $^ > $(gen_ndrsrcdir)/tables.x @mv $(gen_ndrsrcdir)/tables.x $@ [SUBSYSTEM::NDR_TABLE] @@ -379,11 +385,10 @@ PUBLIC_DEPENDENCIES = \ NDR_NETLOGON NDR_TRKWKS NDR_KEYSVC NDR_KRB5PAC NDR_XATTR NDR_SCHANNEL \ NDR_ROT NDR_DRSBLOBS NDR_SVCCTL NDR_NBT NDR_WINSREPL NDR_SECURITY \ NDR_INITSHUTDOWN NDR_DNSSERVER NDR_WINSTATION NDR_IRPC NDR_OPENDB \ - NDR_SASL_HELPERS NDR_NOTIFY NDR_WINBIND NDR_FRSRPC NDR_FRSAPI NDR_NFS4ACL NDR_NTP_SIGND - -NDR_TABLE_OBJ_FILES = $(ndrsrcdir)/ndr_table.o $(gen_ndrsrcdir)/tables.o + NDR_SASL_HELPERS NDR_NOTIFY NDR_WINBIND NDR_FRSRPC NDR_FRSAPI NDR_NFS4ACL NDR_NTP_SIGND \ + NDR_DCOM NDR_WMI -$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_table.h,$(NDR_TABLE_OBJ_FILES:.o=.c))) +NDR_TABLE_OBJ_FILES = ../librpc/ndr/ndr_table.o $(gen_ndrsrcdir)/tables.o [SUBSYSTEM::RPC_NDR_ROT] PUBLIC_DEPENDENCIES = NDR_ROT dcerpc @@ -607,8 +612,9 @@ PC_FILES += $(librpcsrcdir)/dcerpc.pc dcerpc_VERSION = 0.0.1 dcerpc_SOVERSION = 0 -dcerpc_OBJ_FILES = $(addprefix $(dcerpcsrcdir)/, dcerpc.o dcerpc_auth.o dcerpc_schannel.o dcerpc_util.o binding.o \ - dcerpc_error.o dcerpc_smb.o dcerpc_smb2.o dcerpc_sock.o dcerpc_connect.o dcerpc_secondary.o) +dcerpc_OBJ_FILES = $(addprefix $(dcerpcsrcdir)/, dcerpc.o dcerpc_auth.o dcerpc_schannel.o dcerpc_util.o \ + dcerpc_error.o dcerpc_smb.o dcerpc_smb2.o dcerpc_sock.o dcerpc_connect.o dcerpc_secondary.o) \ + ../librpc/rpc/binding.o $(eval $(call proto_header_template,$(dcerpcsrcdir)/dcerpc_proto.h,$(dcerpc_OBJ_FILES:.o=.c))) @@ -671,7 +677,7 @@ python_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/py_atsvc.o [PYTHON::python_dcerpc_nbt] LIBRARY_REALNAME = samba/nbt.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc python_dcerpc_misc python_dcerpc_security python_dcerpc_nbt_OBJ_FILES = $(gen_ndrsrcdir)/py_nbt.o @@ -732,13 +738,12 @@ python_dcerpc_security_OBJ_FILES = $(gen_ndrsrcdir)/py_security.o $(IDL_HEADER_FILES) $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \ $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \ $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \ - $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES) \ $(IDL_NDR_PY_C_FILES) $(IDL_NDR_PY_H_FILES): idl idl_full:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm - @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh FULL $(librpcsrcdir)/idl $(librpcsrcdir)/gen_ndr + @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh FULL $(librpcsrcdir)/gen_ndr $(IDL_FILES) idl:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm - @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh PARTIAL $(librpcsrcdir)/idl $(librpcsrcdir)/gen_ndr + @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh PARTIAL $(librpcsrcdir)/gen_ndr $(IDL_FILES) diff --git a/source4/librpc/idl-deps.pl b/source4/librpc/idl-deps.pl index 49fba4c935..44990c5196 100755 --- a/source4/librpc/idl-deps.pl +++ b/source4/librpc/idl-deps.pl @@ -4,8 +4,9 @@ use strict; my %vars = (); foreach(@ARGV) { + my $f = $_; my $b = $_; $b =~ s/.*\/(.*?).idl$/$1/; - push (@{$vars{IDL_FILES}}, "\$(librpcsrcdir)/idl/$b.idl"); + push (@{$vars{IDL_FILES}}, $f); push (@{$vars{IDL_HEADER_FILES}}, "\$(librpcsrcdir)/gen_ndr/$b.h"); push (@{$vars{IDL_NDR_PARSE_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.h"); push (@{$vars{IDL_NDR_PARSE_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.c"); diff --git a/source4/librpc/idl/dcerpc.idl b/source4/librpc/idl/dcerpc.idl index 1c6574b11b..7c0abe6ab8 100644 --- a/source4/librpc/idl/dcerpc.idl +++ b/source4/librpc/idl/dcerpc.idl @@ -205,26 +205,26 @@ interface dcerpc } dcerpc_working; typedef [enum8bit] enum { - DCERPC_PKT_REQUEST = 0, - DCERPC_PKT_PING = 1, - DCERPC_PKT_RESPONSE = 2, - DCERPC_PKT_FAULT = 3, - DCERPC_PKT_WORKING = 4, - DCERPC_PKT_NOCALL = 5, - DCERPC_PKT_REJECT = 6, - DCERPC_PKT_ACK = 7, - DCERPC_PKT_CL_CANCEL = 8, - DCERPC_PKT_FACK = 9, - DCERPC_PKT_CANCEL_ACK = 10, - DCERPC_PKT_BIND = 11, - DCERPC_PKT_BIND_ACK = 12, - DCERPC_PKT_BIND_NAK = 13, - DCERPC_PKT_ALTER = 14, - DCERPC_PKT_ALTER_RESP = 15, - DCERPC_PKT_AUTH3 = 16, - DCERPC_PKT_SHUTDOWN = 17, - DCERPC_PKT_CO_CANCEL = 18, - DCERPC_PKT_ORPHANED = 19 + DCERPC_PKT_REQUEST = 0, /* Ordinary request. */ + DCERPC_PKT_PING = 1, /* Connectionless is server alive ? */ + DCERPC_PKT_RESPONSE = 2, /* Ordinary reply. */ + DCERPC_PKT_FAULT = 3, /* Fault in processing of call. */ + DCERPC_PKT_WORKING = 4, /* Connectionless reply to a ping when server busy. */ + DCERPC_PKT_NOCALL = 5, /* Connectionless reply to a ping when server has lost part of clients call. */ + DCERPC_PKT_REJECT = 6, /* Refuse a request with a code. */ + DCERPC_PKT_ACK = 7, /* Connectionless client to server code. */ + DCERPC_PKT_CL_CANCEL = 8, /* Connectionless cancel. */ + DCERPC_PKT_FACK = 9, /* Connectionless fragment ack. Both client and server send. */ + DCERPC_PKT_CANCEL_ACK = 10, /* Server ACK to client cancel request. */ + DCERPC_PKT_BIND = 11, /* Bind to interface. */ + DCERPC_PKT_BIND_ACK = 12, /* Server ack of bind. */ + DCERPC_PKT_BIND_NAK = 13, /* Server nack of bind. */ + DCERPC_PKT_ALTER = 14, /* Alter auth. */ + DCERPC_PKT_ALTER_RESP = 15, /* Reply to alter auth. */ + DCERPC_PKT_AUTH3 = 16, /* not the real name! this is undocumented! */ + DCERPC_PKT_SHUTDOWN = 17, /* Server to client request to shutdown. */ + DCERPC_PKT_CO_CANCEL = 18, /* Connection-oriented cancel request. */ + DCERPC_PKT_ORPHANED = 19 /* Client telling server it's aborting a partially sent request or telling server to stop sending replies. */ } dcerpc_pkt_type; typedef [nodiscriminant] union { @@ -261,6 +261,7 @@ interface dcerpc const uint8 DCERPC_PFC_FLAG_OBJECT_UUID = 0x80; /* on valid guid is in the optional object field */ /* these offsets are needed by the signing code */ + const uint8 DCERPC_PFC_OFFSET = 3; const uint8 DCERPC_DREP_OFFSET = 4; const uint8 DCERPC_FRAG_LEN_OFFSET = 8; const uint8 DCERPC_AUTH_LEN_OFFSET = 10; diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl deleted file mode 100644 index cc76599be6..0000000000 --- a/source4/librpc/idl/drsuapi.idl +++ /dev/null @@ -1,1558 +0,0 @@ -#include "idl_types.h" - -import "security.idl", "misc.idl", "samr.idl"; - -[ - uuid("e3514235-4b06-11d1-ab04-00c04fc2dcd2"), - version(4.0), - endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]", "ncacn_ip_tcp:", "ncalrpc:"), - authservice("ldap"), - helpstring("Active Directory Replication"), - helper("librpc/ndr/ndr_drsuapi.h"), - pointer_default(unique) -] -interface drsuapi -{ - typedef bitmap samr_GroupAttrs samr_GroupAttrs; - - /*****************/ - /* Function 0x00 */ - typedef [bitmap32bit] bitmap { - DRSUAPI_SUPPORTED_EXTENSION_BASE = 0x00000001, - DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION = 0x00000002, - DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI = 0x00000004, - DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2 = 0x00000008, - DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS = 0x00000010, - DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1 = 0x00000020, - DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION = 0x00000040, - DRSUAPI_SUPPORTED_EXTENSION_00000080 = 0x00000080, - DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE = 0x00000100, - DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2 = 0x00000200, - DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION = 0x00000400, - DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2 = 0x00000800, - DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD= 0x00001000, - DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND = 0x00002000, - DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO = 0x00004000, - DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION = 0x00008000, - DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01 = 0x00010000, - DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP = 0x00020000, - DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY = 0x00040000, - DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3 = 0x00080000, - DRSUAPI_SUPPORTED_EXTENSION_00100000 = 0x00100000, - DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2 = 0x00200000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6 = 0x00400000, - DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS = 0x00800000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8 = 0x01000000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5 = 0x02000000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6 = 0x04000000, - /* - * the following 3 have the same value - * repadmin.exe /bind says that - */ - DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3 = 0x08000000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7 = 0x08000000, - DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT = 0x08000000, - DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS = 0x10000000, - DRSUAPI_SUPPORTED_EXTENSION_20000000 = 0x20000000, - DRSUAPI_SUPPORTED_EXTENSION_40000000 = 0x40000000, - DRSUAPI_SUPPORTED_EXTENSION_80000000 = 0x80000000 - } drsuapi_SupportedExtensions; - - typedef [bitmap32bit] bitmap { - DRSUAPI_SUPPORTED_EXTENSION_ADAM = 0x00000001, - DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2 = 0x00000002 - } drsuapi_SupportedExtensionsExt; - - /* this is used by w2k */ - typedef struct { - drsuapi_SupportedExtensions supported_extensions; - GUID site_guid; - uint32 pid; - } drsuapi_DsBindInfo24; - - /* this is used by w2k3 */ - typedef struct { - drsuapi_SupportedExtensions supported_extensions; - GUID site_guid; - uint32 pid; - uint32 repl_epoch; - } drsuapi_DsBindInfo28; - - /* this is used by w2k8 */ - typedef struct { - drsuapi_SupportedExtensions supported_extensions; - GUID site_guid; - uint32 pid; - uint32 repl_epoch; - drsuapi_SupportedExtensionsExt supported_extensions_ext; - GUID config_dn_guid; - } drsuapi_DsBindInfo48; - - typedef struct { - [flag(NDR_REMAINING)] DATA_BLOB info; - } drsuapi_DsBindInfoFallBack; - - typedef [nodiscriminant] union { - [case(24)][subcontext(4)] drsuapi_DsBindInfo24 info24; - [case(28)][subcontext(4)] drsuapi_DsBindInfo28 info28; - [case(48)][subcontext(4)] drsuapi_DsBindInfo48 info48; - [default][subcontext(4)] drsuapi_DsBindInfoFallBack FallBack; - } drsuapi_DsBindInfo; - - /* the drsuapi_DsBindInfoCtr was this before - * typedef [flag(NDR_PAHEX)] struct { - * [range(1,10000)] uint32 length; - * [size_is(length)] uint8 data[]; - * } drsuapi_DsBindInfo; - * - * but we don't want the caller to manually decode this blob, - * so we're doing it here - */ - - typedef struct { - [range(1,10000)] uint32 length; - [switch_is(length)] drsuapi_DsBindInfo info; - } drsuapi_DsBindInfoCtr; - - /* this is a magic guid you need to pass to DsBind to make drsuapi_DsWriteAccountSpn() work - * - * maybe the bind_guid could also be the invocation_id see drsuapi_DsReplicaConnection04 - */ - const char *DRSUAPI_DS_BIND_GUID = "e24d201a-4fd6-11d1-a3da-0000f875ae0d"; - /* - * this magic guid are needed to fetch the whole tree with drsuapi_DsGetNCChanges() - * as administrator and this values are also used in the destination_dsa_guid field - * of drsuapi_DsGetNCChangesReq5/8 and the source_dsa_guid is zero. - */ - const char *DRSUAPI_DS_BIND_GUID_W2K = "6abec3d1-3054-41c8-a362-5a0c5b7d5d71"; - const char *DRSUAPI_DS_BIND_GUID_W2K3 = "6afab99c-6e26-464a-975f-f58f105218bc"; - - [public] WERROR drsuapi_DsBind( - [in,unique] GUID *bind_guid, - [in,out,unique] drsuapi_DsBindInfoCtr *bind_info, - [out] policy_handle *bind_handle - ); - - /*****************/ - /* Function 0x01 */ - WERROR drsuapi_DsUnbind( - [in,out] policy_handle *bind_handle - ); - - /*****************/ - /* Function 0x02 */ - typedef [public,gensize] struct { - [value(ndr_size_drsuapi_DsReplicaObjectIdentifier(r, ndr->flags)-4)] uint32 __ndr_size; - [value(ndr_size_dom_sid28(&sid, ndr->flags))] uint32 __ndr_size_sid; - GUID guid; - dom_sid28 sid; - [value(strlen_m(dn))] uint32 __ndr_size_dn; - [charset(UTF16),size_is(__ndr_size_dn+1)] uint16 dn[]; - } drsuapi_DsReplicaObjectIdentifier; - - typedef [public] bitmap { - DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_SYNC_WRITEABLE = 0x00000002, - DRSUAPI_DS_REPLICA_SYNC_PERIODIC = 0x00000004, - DRSUAPI_DS_REPLICA_SYNC_INTERSITE_MESSAGING = 0x00000008, - DRSUAPI_DS_REPLICA_SYNC_ALL_SOURCES = 0x00000010, - DRSUAPI_DS_REPLICA_SYNC_FULL = 0x00000020, - DRSUAPI_DS_REPLICA_SYNC_URGENT = 0x00000040, - DRSUAPI_DS_REPLICA_SYNC_NO_DISCARD = 0x00000080, - DRSUAPI_DS_REPLICA_SYNC_FORCE = 0x00000100, - DRSUAPI_DS_REPLICA_SYNC_ADD_REFERENCE = 0x00000200, - DRSUAPI_DS_REPLICA_SYNC_NEVER_COMPLETED = 0x00000400, - DRSUAPI_DS_REPLICA_SYNC_TWO_WAY = 0x00000800, - DRSUAPI_DS_REPLICA_SYNC_NEVER_NOTIFY = 0x00001000, - DRSUAPI_DS_REPLICA_SYNC_INITIAL = 0x00002000, - DRSUAPI_DS_REPLICA_SYNC_USE_COMPRESSION = 0x00004000, - DRSUAPI_DS_REPLICA_SYNC_ABANDONED = 0x00008000, - DRSUAPI_DS_REPLICA_SYNC_INITIAL_IN_PROGRESS = 0x00010000, - DRSUAPI_DS_REPLICA_SYNC_PARTIAL_ATTRIBUTE_SET = 0x00020000, - DRSUAPI_DS_REPLICA_SYNC_REQUEUE = 0x00040000, - DRSUAPI_DS_REPLICA_SYNC_NOTIFICATION = 0x00080000, - DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_REPLICA = 0x00100000, - DRSUAPI_DS_REPLICA_SYNC_CRITICAL = 0x00200000, - DRSUAPI_DS_REPLICA_SYNC_FULL_IN_PROGRESS = 0x00400000, - DRSUAPI_DS_REPLICA_SYNC_PREEMPTED = 0x00800000 - } drsuapi_DsReplicaSyncOptions; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *naming_context; - GUID source_dsa_guid; - astring *other_info; /* I assume this is related to the repsFromTo1OtherInfo dns_name */ - drsuapi_DsReplicaSyncOptions options; - } drsuapi_DsReplicaSyncRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsReplicaSyncRequest1 req1; - } drsuapi_DsReplicaSyncRequest; - - WERROR drsuapi_DsReplicaSync( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,switch_is(level)] drsuapi_DsReplicaSyncRequest req - ); - - /*****************/ - /* Function 0x03 */ - typedef [public] struct { - hyper tmp_highest_usn; /* updated after each object update */ - hyper reserved_usn; - hyper highest_usn; /* updated after a full replication cycle */ - } drsuapi_DsReplicaHighWaterMark; - - typedef [public] struct { - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - hyper highest_usn; /* updated after a full replication cycle */ - } drsuapi_DsReplicaCursor; - - typedef struct { - [value(1)] uint32 version; - [value(0)] uint32 reserved1; - [range(0,0x100000)] uint32 count; - [value(0)] uint32 reserved2; - [size_is(count)] drsuapi_DsReplicaCursor cursors[]; - } drsuapi_DsReplicaCursorCtrEx; - - typedef [public] bitmap { - /* the _WRITEABLE flag indicates a replication with all attributes - * - * --metze - */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE = 0x00000010, - DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP = 0x00000020, - DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS = 0x00000040, - DRSUAPI_DS_REPLICA_NEIGHBOUR_USE_ASYNC_INTERSIDE_TRANSPORT = 0x00000080, - DRSUAPI_DS_REPLICA_NEIGHBOUR_TWO_WAY_SYNC = 0x00000200, - DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS = 0x00000800, - DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_IN_PROGRESS = 0x00001000, /* was 0x00010000, */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_NEXT_PACKET = 0x00002000, /* was 0x00020000, */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED = 0x00200000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_PREEMPTED = 0x01000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_IGNORE_CHANGE_NOTIFICATIONS = 0x04000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_DISABLE_SCHEDULED_SYNC = 0x08000000, - /* - * the following NOTE applies to DsGetNCChangesRequest5: - * - the data is only compressed when 10 or more objects are replicated - * - but there could also be a size limit of 35 KBytes or something like that - * - the reply is DsGetNCChangesCtr2 - * - maybe the same applies to DsGetNCChangesRequest8... - * - * --metze - */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES = 0x10000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_NO_CHANGE_NOTIFICATIONS = 0x20000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_PARTIAL_ATTRIBUTE_SET = 0x40000000 - } drsuapi_DsReplicaNeighbourFlags; - - typedef [flag(NDR_PAHEX),v1_enum] enum { - DRSUAPI_EXOP_NONE = 0x00000000, - DRSUAPI_EXOP_FSMO_REQ_ROLE = 0x00000001, - DRSUAPI_EXOP_FSMO_RID_ALLOC = 0x00000002, - DRSUAPI_EXOP_FSMO_RID_REQ_ROLE = 0x00000003, - DRSUAPI_EXOP_FSMO_REQ_PDC = 0x00000004, - DRSUAPI_EXOP_FSMO_ABANDON_ROLE = 0x00000005, - DRSUAPI_EXOP_REPL_OBJ = 0x00000006, - DRSUAPI_EXOP_REPL_SECRET = 0x00000007 - } drsuapi_DsExtendedOperation; - - typedef [flag(NDR_PAHEX),v1_enum] enum { - DRSUAPI_EXOP_ERR_NONE = 0x00000000, - DRSUAPI_EXOP_ERR_SUCCESS = 0x00000001, - DRSUAPI_EXOP_ERR_UNKNOWN_OP = 0x00000002, - DRSUAPI_EXOP_ERR_FSMO_NOT_OWNER = 0x00000003, - DRSUAPI_EXOP_ERR_UPDATE_ERR = 0x00000004, - DRSUAPI_EXOP_ERR_EXCEPTION = 0x00000005, - DRSUAPI_EXOP_ERR_UNKNOWN_CALLER = 0x00000006, - DRSUAPI_EXOP_ERR_RID_ALLOC = 0x00000007, - DRSUAPI_EXOP_ERR_FSMO_OWNER_DELETED = 0x00000008, - DRSUAPI_EXOP_ERR_FMSO_PENDING_OP = 0x00000009, - DRSUAPI_EXOP_ERR_MISMATCH = 0x0000000A, - DRSUAPI_EXOP_ERR_COULDNT_CONTACT = 0x0000000B, - DRSUAPI_EXOP_ERR_FSMO_REFUSING_ROLES = 0x0000000C, - DRSUAPI_EXOP_ERR_DIR_ERROR = 0x0000000D, - DRSUAPI_EXOP_ERR_FSMO_MISSING_SETTINGS = 0x0000000E, - DRSUAPI_EXOP_ERR_ACCESS_DENIED = 0x0000000F, - DRSUAPI_EXOP_ERR_PARAM_ERROR = 0x00000010 - } drsuapi_DsExtendedError; - - typedef struct { - GUID destination_dsa_guid; - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - [ref] drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark highwatermark; - drsuapi_DsReplicaCursorCtrEx *uptodateness_vector; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */ - uint32 max_ndr_size; /* w2k3 seems to ignore this */ - drsuapi_DsExtendedOperation extended_op; - hyper fsmo_info; - } drsuapi_DsGetNCChangesRequest5; - - /* - * In DRSUAPI all attributes with syntax 2.5.5.2 - * are identified by uint32 values - * - * the following table shows the mapping used between the two representations - * e.g. - objectClass 'nTDSDSA' has governsID: 1.2.840.113556.1.5.7000.47 - * and a UINT32-ID of '0x0017002F'. - * - so the OID 1.2.840.113556.1.5.7000.47 is splitted into a - * OID-prefix: 1.2.840.113556.1.5.7000 - * and a value: 47 => 0x2F - * - the mapping table gives a UINT32-prefix: 0x00170000 - * - and the UINT32-ID is 0x0017002F = 0x00170000 | 0x2F - * - * This prefix mapping table is replied in the drsuapi_DsReplicaOIDMapping_Ctr - * array. The following are the default mappings of w2k3 - * - * OID-prefix => UINT32-Id prefix - * - * 2.5.4.* => 0x00000000 (standard attributes RFC2256 core.schema) - * 2.5.6.* => 0x00010000 (standard object classes RFC2256 core.schema) - * 1.2.840.113556.1.2.* => 0x00020000 - * 1.2.840.113556.1.3.* => 0x00030000 - * 2.5.5.* => 0x00080000 (attributeSyntax OID's) - * 1.2.840.113556.1.4.* => 0x00090000 - * 1.2.840.113556.1.5.* => 0x000A0000 - * 2.16.840.1.113730.3.* => 0x00140000 - * 0.9.2342.19200300.100.1.* => 0x00150000 - * 2.16.840.1.113730.3.1.* => 0x00160000 - * 1.2.840.113556.1.5.7000.* => 0x00170000 - * 2.5.21.* => 0x00180000 (attrs for SubSchema) - * 2.5.18.* => 0x00190000 (createTimeStamp,modifyTimeStamp, SubSchema) - * 2.5.20.* => 0x001A0000 - * 1.3.6.1.4.1.1466.101.119.* => 0x001B0000 (dynamicObject, entryTTL) - * 2.16.840.1.113730.3.2.* => 0x001C0000 - * 1.3.6.1.4.1.250.1.* => 0x001D0000 - * 1.2.840.113549.1.9.* => 0x001E0000 (unstructuredAddress,unstructuredName) - * 0.9.2342.19200300.100.4.* => 0x001F0000 - * - * Here's a list of used 'attributeSyntax' OID's - * - * 2.5.5.1 => Object(DS-DN) string - * struct drsuapi_DsObjectIdentifier3 - * - * 2.5.5.2 => OID-string - * => all values are represented as uint32 values in drsuapi - * => governsID, attributeID and attributeSyntax returned as OID-Strings in LDAP - * => mayContain, mustContain and all other attributes with 2.5.5.2 syntax - * are returned as attribute names - * - * 2.5.5.4 => String(Teletex) case-insensitive string with teletex charset - * - * 2.5.5.5 => String(IA5) case-sensitive string - * - * 2.5.5.6 => String(Numeric) - * => eg. internationalISDNNumber - * - * 2.5.5.7 => Object(DN-Binary) B::: - * => e.g. wellKnownObjects - * - * 2.5.5.8 => BOOL - * - * 2.5.5.9 => int32 - * - * 2.5.5.10 => DATA_BLOB - * => struct GUID - * - * 2.5.5.11 => LDAP timestring - * => NTTIME_1sec - * - * 2.5.5.12 => String(Unicode) case-insensitive string - * => 'standard strings' - * - * 2.5.5.13 => Object(Presentation-Address) string - * => used in objectClass applicationEntity - * - * 2.5.5.14 => Object(DN-String) S::: - * => not used - * - * 2.5.5.15 => ntSecurityDescriptor - * - * 2.5.5.16 => int64 - * - * 2.5.5.17 => dom_sid - */ - typedef [nopush,nopull] struct { - [range(0,10000),value(ndr_size_drsuapi_DsReplicaOID_oid(oid, 0))] uint32 __ndr_size; - [size_is(__ndr_size),charset(DOS)] uint8 *oid; /* it's encoded with asn1_write_OID_String() */ - } drsuapi_DsReplicaOID; - - typedef struct { - uint32 id_prefix; - drsuapi_DsReplicaOID oid; - } drsuapi_DsReplicaOIDMapping; - - typedef [public] struct { - [range(0,0x100000)] uint32 num_mappings; - [size_is(num_mappings)] drsuapi_DsReplicaOIDMapping *mappings; - } drsuapi_DsReplicaOIDMapping_Ctr; - - typedef [flag(NDR_PAHEX),v1_enum] enum { - DRSUAPI_OBJECTCLASS_top = 0x00010000, - DRSUAPI_OBJECTCLASS_classSchema = 0x0003000d, - DRSUAPI_OBJECTCLASS_attributeSchema = 0x0003000e - } drsuapi_DsObjectClassId; - - typedef [flag(NDR_PAHEX),v1_enum,public] enum { - DRSUAPI_ATTRIBUTE_objectClass = 0x00000000, - DRSUAPI_ATTRIBUTE_description = 0x0000000d, - DRSUAPI_ATTRIBUTE_member = 0x0000001f, - DRSUAPI_ATTRIBUTE_instanceType = 0x00020001, - DRSUAPI_ATTRIBUTE_whenCreated = 0x00020002, - DRSUAPI_ATTRIBUTE_hasMasterNCs = 0x0002000e, - DRSUAPI_ATTRIBUTE_governsID = 0x00020016, - DRSUAPI_ATTRIBUTE_attributeID = 0x0002001e, - DRSUAPI_ATTRIBUTE_attributeSyntax = 0x00020020, - DRSUAPI_ATTRIBUTE_isSingleValued = 0x00020021, - DRSUAPI_ATTRIBUTE_rangeLower = 0x00020022, - DRSUAPI_ATTRIBUTE_rangeUpper = 0x00020023, - DRSUAPI_ATTRIBUTE_dMDLocation = 0x00020024, - DRSUAPI_ATTRIBUTE_objectVersion = 0x0002004c, - DRSUAPI_ATTRIBUTE_invocationId = 0x00020073, - DRSUAPI_ATTRIBUTE_showInAdvancedViewOnly = 0x000200a9, - DRSUAPI_ATTRIBUTE_adminDisplayName = 0x000200c2, - DRSUAPI_ATTRIBUTE_adminDescription = 0x000200e2, - DRSUAPI_ATTRIBUTE_oMSyntax = 0x000200e7, - DRSUAPI_ATTRIBUTE_ntSecurityDescriptor = 0x00020119, - DRSUAPI_ATTRIBUTE_searchFlags = 0x0002014e, - DRSUAPI_ATTRIBUTE_lDAPDisplayName = 0x000201cc, - DRSUAPI_ATTRIBUTE_name = 0x00090001, - DRSUAPI_ATTRIBUTE_currentValue = 0x0009001b, - DRSUAPI_ATTRIBUTE_objectSid = 0x00090092, - DRSUAPI_ATTRIBUTE_schemaIDGUID = 0x00090094, - DRSUAPI_ATTRIBUTE_dBCSPwd = 0x00090037,/* lmPwdHash */ - DRSUAPI_ATTRIBUTE_unicodePwd = 0x0009005a,/* ntPwdHash */ - DRSUAPI_ATTRIBUTE_ntPwdHistory = 0x0009005e, - DRSUAPI_ATTRIBUTE_priorValue = 0x00090064, - DRSUAPI_ATTRIBUTE_supplementalCredentials = 0x0009007d, - DRSUAPI_ATTRIBUTE_trustAuthIncoming = 0x00090081, - DRSUAPI_ATTRIBUTE_trustAuthOutgoing = 0x00090087, - DRSUAPI_ATTRIBUTE_lmPwdHistory = 0x000900a0, - DRSUAPI_ATTRIBUTE_sAMAccountName = 0x000900dd, - DRSUAPI_ATTRIBUTE_fSMORoleOwner = 0x00090171, - DRSUAPI_ATTRIBUTE_systemFlags = 0x00090177, - DRSUAPI_ATTRIBUTE_serverReference = 0x00090203, - DRSUAPI_ATTRIBUTE_serverReferenceBL = 0x00090204, - DRSUAPI_ATTRIBUTE_initialAuthIncoming = 0x0009021b, - DRSUAPI_ATTRIBUTE_initialAuthOutgoing = 0x0009021c, - DRSUAPI_ATTRIBUTE_wellKnownObjects = 0x0009026a, - DRSUAPI_ATTRIBUTE_isMemberOfPartialAttributeSet = 0x0009027f, - DRSUAPI_ATTRIBUTE_objectCategory = 0x0009030e, - DRSUAPI_ATTRIBUTE_gPLink = 0x0009037b, - DRSUAPI_ATTRIBUTE_msDS_Behavior_Version = 0x000905b3, - DRSUAPI_ATTRIBUTE_msDS_KeyVersionNumber = 0x000906f6, - DRSUAPI_ATTRIBUTE_msDS_HasDomainNCs = 0x0009071c, - DRSUAPI_ATTRIBUTE_msDS_hasMasterNCs = 0x0009072c - } drsuapi_DsAttributeId; - - typedef struct { - [value(1)] uint32 version; - [value(0)] uint32 reserved1; - [range(1,0x100000)] uint32 num_attids; - [size_is(num_attids)] drsuapi_DsAttributeId attids[]; - } drsuapi_DsPartialAttributeSet; - - typedef struct { - GUID destination_dsa_guid; - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - [ref] drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark highwatermark; - drsuapi_DsReplicaCursorCtrEx *uptodateness_vector; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */ - uint32 max_ndr_size; /* w2k3 seems to ignore this */ - drsuapi_DsExtendedOperation extended_op; - hyper fsmo_info; - drsuapi_DsPartialAttributeSet *partial_attribute_set; - drsuapi_DsPartialAttributeSet *partial_attribute_set_ex; - drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr; - } drsuapi_DsGetNCChangesRequest8; - - typedef [switch_type(int32)] union { - [case(5)] drsuapi_DsGetNCChangesRequest5 req5; - [case(8)] drsuapi_DsGetNCChangesRequest8 req8; - } drsuapi_DsGetNCChangesRequest; - - typedef [public] struct { - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - hyper highest_usn; /* updated after a full replication cycle */ - NTTIME last_sync_success; - } drsuapi_DsReplicaCursor2; - - typedef struct { - [value(2)] uint32 version; - [value(0)] uint32 reserved1; - [range(0,0x100000)] uint32 count; - [value(0)] uint32 reserved2; - [size_is(count)] drsuapi_DsReplicaCursor2 cursors[]; - } drsuapi_DsReplicaCursor2CtrEx; - - /* Generic DATA_BLOB values */ - typedef struct { - [range(0,10485760),value(ndr_size_DATA_BLOB(0,blob,0))] uint32 __ndr_size; - DATA_BLOB *blob; - } drsuapi_DsAttributeValue; - - typedef struct { - [range(0,10485760)] uint32 num_values; - [size_is(num_values)] drsuapi_DsAttributeValue *values; - } drsuapi_DsAttributeValueCtr; - - /* DN String values */ - typedef [public,gensize] struct { - [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(r, ndr->flags))] uint32 __ndr_size; - [value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid; - GUID guid; - dom_sid28 sid; - [value(strlen_m(dn))] uint32 __ndr_size_dn; - [charset(UTF16)] uint16 dn[__ndr_size_dn+1]; - } drsuapi_DsReplicaObjectIdentifier3; - - typedef [public,gensize] struct { - [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary(r, ndr->flags))] uint32 __ndr_size; - [value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid; - GUID guid; - dom_sid28 sid; - [value(strlen_m(dn))] uint32 __ndr_size_dn; - [charset(UTF16)] uint16 dn[__ndr_size_dn+1]; - [value(binary.length + 4)] uint32 __ndr_size_binary; - [flag(NDR_REMAINING)] DATA_BLOB binary; - } drsuapi_DsReplicaObjectIdentifier3Binary; - - typedef [public] struct { - drsuapi_DsAttributeId attid; - drsuapi_DsAttributeValueCtr value_ctr; - } drsuapi_DsReplicaAttribute; - - typedef struct { - [range(0,1048576)] uint32 num_attributes; - [size_is(num_attributes)] drsuapi_DsReplicaAttribute *attributes; - } drsuapi_DsReplicaAttributeCtr; - - typedef [public] bitmap { - DRSUAPI_DS_REPLICA_OBJECT_FROM_MASTER = 0x00000001, - DRSUAPI_DS_REPLICA_OBJECT_DYNAMIC = 0x00000002, - DRSUAPI_DS_REPLICA_OBJECT_REMOTE_MODIFY = 0x00010000 - } drsuapi_DsReplicaObjectFlags; - - typedef [public] struct { - drsuapi_DsReplicaObjectIdentifier *identifier; - drsuapi_DsReplicaObjectFlags flags; - drsuapi_DsReplicaAttributeCtr attribute_ctr; - } drsuapi_DsReplicaObject; - - typedef struct { - uint32 version; - NTTIME_1sec originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - } drsuapi_DsReplicaMetaData; - - typedef [public] struct { - [range(0,1048576)] uint32 count; - [size_is(count)] drsuapi_DsReplicaMetaData meta_data[]; - } drsuapi_DsReplicaMetaDataCtr; - - typedef [public,noprint] struct { - drsuapi_DsReplicaObjectListItemEx *next_object; - drsuapi_DsReplicaObject object; - boolean32 is_nc_prefix; - GUID *parent_object_guid; - drsuapi_DsReplicaMetaDataCtr *meta_data_ctr; - } drsuapi_DsReplicaObjectListItemEx; - - typedef [public,gensize] struct { - GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */ - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark old_highwatermark; - drsuapi_DsReplicaHighWaterMark new_highwatermark; - drsuapi_DsReplicaCursorCtrEx *uptodateness_vector; - drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr; - drsuapi_DsExtendedError extended_ret; /* w2k sends the nc_object_count value here */ - uint32 object_count; - /* this +55 is sometimes +56, so I don't know where this comes from... --metze */ - [value(ndr_size_drsuapi_DsGetNCChangesCtr1(r,ndr->flags)+55)] uint32 __ndr_size; - drsuapi_DsReplicaObjectListItemEx *first_object; - boolean32 more_data; - } drsuapi_DsGetNCChangesCtr1; - - /* - * if the DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE flag - * isn't there it means the value is deleted - */ - typedef [public] bitmap { - DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE = 0x00000001 - } drsuapi_DsLinkedAttributeFlags; - - typedef [public] struct { - drsuapi_DsReplicaObjectIdentifier *identifier; - drsuapi_DsAttributeId attid; - drsuapi_DsAttributeValue value; - drsuapi_DsLinkedAttributeFlags flags; - NTTIME_1sec originating_add_time; - drsuapi_DsReplicaMetaData meta_data; - } drsuapi_DsReplicaLinkedAttribute; - - typedef [public,gensize] struct { - GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */ - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark old_highwatermark; - drsuapi_DsReplicaHighWaterMark new_highwatermark; - drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector; - drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr; - drsuapi_DsExtendedError extended_ret; - uint32 object_count; - /* this +55 is sometimes +56, so I don't know where this comes from... --metze */ - [value(ndr_size_drsuapi_DsGetNCChangesCtr6(r,ndr->flags)+55)] uint32 __ndr_size; - drsuapi_DsReplicaObjectListItemEx *first_object; - boolean32 more_data; - uint32 nc_object_count; /* estimated amount of objects in the whole NC */ - uint32 nc_linked_attributes_count; /* estimated amount of linked values in the whole NC */ - [range(0,1048576)] uint32 linked_attributes_count; - [size_is(linked_attributes_count)] drsuapi_DsReplicaLinkedAttribute *linked_attributes; - WERROR drs_error; - } drsuapi_DsGetNCChangesCtr6; - - typedef [public] struct { - [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr1 ctr1; - } drsuapi_DsGetNCChangesCtr1TS; - - typedef [public] struct { - [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr6 ctr6; - } drsuapi_DsGetNCChangesCtr6TS; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1TS *ts; - } drsuapi_DsGetNCChangesMSZIPCtr1; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6TS *ts; - } drsuapi_DsGetNCChangesMSZIPCtr6; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1TS *ts; - } drsuapi_DsGetNCChangesXPRESSCtr1; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6TS *ts; - } drsuapi_DsGetNCChangesXPRESSCtr6; - - typedef [enum16bit] enum { - DRSUAPI_COMPRESSION_TYPE_MSZIP = 2, - DRSUAPI_COMPRESSION_TYPE_XPRESS = 3 - } drsuapi_DsGetNCChangesCompressionType; - - typedef [nodiscriminant,flag(NDR_PAHEX)] union { - [case(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesMSZIPCtr1 mszip1; - [case(6|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesMSZIPCtr6 mszip6; - [case(1|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr1 xpress1; - [case(6|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr6 xpress6; - } drsuapi_DsGetNCChangesCompressedCtr; - - typedef struct { - drsuapi_DsGetNCChangesMSZIPCtr1 mszip1; - } drsuapi_DsGetNCChangesCtr2; - - typedef struct { - [range(0,6)] int32 level; - [range(2,3)] drsuapi_DsGetNCChangesCompressionType type; - [switch_is(level | (type<<16))] drsuapi_DsGetNCChangesCompressedCtr ctr; - } drsuapi_DsGetNCChangesCtr7; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetNCChangesCtr1 ctr1; - [case(2)] drsuapi_DsGetNCChangesCtr2 ctr2; - [case(6)] drsuapi_DsGetNCChangesCtr6 ctr6; - [case(7)] drsuapi_DsGetNCChangesCtr7 ctr7; - } drsuapi_DsGetNCChangesCtr; - - WERROR drsuapi_DsGetNCChanges( - [in] policy_handle *bind_handle, - [in,out,ref] int32 *level, - [in,switch_is(*level)] drsuapi_DsGetNCChangesRequest req, - [out,switch_is(*level)] drsuapi_DsGetNCChangesCtr ctr - ); - - /*****************/ - /* Function 0x04 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_UPDATE_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_UPDATE_WRITEABLE = 0x00000002, - DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE = 0x00000004, - DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE = 0x00000008, - DRSUAPI_DS_REPLICA_UPDATE_0x00000010 = 0x00000010 - } drsuapi_DsReplicaUpdateRefsOptions; - - typedef struct { - [ref] drsuapi_DsReplicaObjectIdentifier *naming_context; - [ref,charset(DOS),string] uint8 *dest_dsa_dns_name; - GUID dest_dsa_guid; - drsuapi_DsReplicaUpdateRefsOptions options; - } drsuapi_DsReplicaUpdateRefsRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsReplicaUpdateRefsRequest1 req1; - } drsuapi_DsReplicaUpdateRefsRequest; - - WERROR drsuapi_DsReplicaUpdateRefs( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,switch_is(level)] drsuapi_DsReplicaUpdateRefsRequest req - ); - - /*****************/ - /* Function 0x05 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_ADD_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_ADD_WRITEABLE = 0x00000002 - /* TODO ... */ - } drsuapi_DsReplicaAddOptions; - - [todo] WERROR DRSUAPI_REPLICA_ADD(); - - /*****************/ - /* Function 0x06 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_DELETE_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_DELETE_WRITEABLE = 0x00000002 - /* TODO ... */ - } drsuapi_DsReplicaDeleteOptions; - - [todo] WERROR DRSUAPI_REPLICA_DEL(); - - /*****************/ - /* Function 0x07 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_MODIFY_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_MODIFY_WRITEABLE = 0x00000002 - } drsuapi_DsReplicaModifyOptions; - - [todo] WERROR DRSUAPI_REPLICA_MODIFY(); - - /*****************/ - /* Function 0x08 */ - [todo] WERROR DRSUAPI_VERIFY_NAMES(); - - /*****************/ - /* Function 0x09 */ - - /* how are type 4 and 7 different from 2 and 3 ? */ - typedef [v1_enum] enum { - DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_AND_DOMAIN_GROUPS = 1, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS = 2, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS = 3, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS2 = 4, - DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_GROUPS = 5, - DRSUAPI_DS_MEMBERSHIP_TYPE_GROUPMEMBERS = 6, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS2 = 7 - } drsuapi_DsMembershipType; - - typedef struct { - NTSTATUS status; - [range(0,10000)] uint32 num_memberships; - [range(0,10000)] uint32 num_sids; - [size_is(num_memberships)] drsuapi_DsReplicaObjectIdentifier **info_array; - [size_is(num_memberships)] samr_GroupAttrs *group_attrs; - [size_is(num_sids)] dom_sid28 **sids; - } drsuapi_DsGetMembershipsCtr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1; - } drsuapi_DsGetMembershipsCtr; - - const int DRSUAPI_DS_MEMBERSHIP_FLAG_GROUP_ATTR = 0x1; - - typedef struct { - [range(1,10000)] uint32 count; - [size_is(count)] drsuapi_DsReplicaObjectIdentifier **info_array; - uint32 flags; - drsuapi_DsMembershipType type; - drsuapi_DsReplicaObjectIdentifier *domain; - } drsuapi_DsGetMembershipsRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMembershipsRequest1 req1; - } drsuapi_DsGetMembershipsRequest; - - [todo] WERROR drsuapi_DsGetMemberships( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in] [switch_is(level)] drsuapi_DsGetMembershipsRequest req, - [out] [switch_is(level)] drsuapi_DsGetMembershipsCtr ctr - ); - - /*****************/ - /* Function 0x0a */ - [todo] WERROR DRSUAPI_INTER_DOMAIN_MOVE(); - - /*****************/ - /* Function 0x0b */ - typedef struct { - uint32 unknown1; - uint32 unknown2; - [range(0,0x00A00000)] uint32 length; - [size_is(length)] uint8 *data; - } drsuapi_DsGetNT4ChangeLogRequest1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsGetNT4ChangeLogRequest1 req1; - } drsuapi_DsGetNT4ChangeLogRequest; - - typedef struct { - [range(0,0x00A00000)] uint32 length1; - [range(0,0x00A00000)] uint32 length2; - hyper unknown1; - NTTIME time2; - hyper unknown3; - NTTIME time4; - hyper unknown5; - NTTIME time6; - NTSTATUS status; - [size_is(length1)] uint8 *data1; - [size_is(length2)] uint8 *data2; - } drsuapi_DsGetNT4ChangeLogInfo1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsGetNT4ChangeLogInfo1 info1; - } drsuapi_DsGetNT4ChangeLogInfo; - - [todo] WERROR drsuapi_DsGetNT4ChangeLog( - [in] policy_handle *bind_handle, - [in,out] uint32 level, - [in] [switch_is(level)] drsuapi_DsGetNT4ChangeLogRequest req, - [out] [switch_is(level)] drsuapi_DsGetNT4ChangeLogInfo info - ); - - /*****************/ - /* Function 0x0c */ - typedef [v1_enum] enum { - DRSUAPI_DS_NAME_STATUS_OK = 0, - DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR = 1, - DRSUAPI_DS_NAME_STATUS_NOT_FOUND = 2, - DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE = 3, - DRSUAPI_DS_NAME_STATUS_NO_MAPPING = 4, - DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY = 5, - DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING = 6, - DRSUAPI_DS_NAME_STATUS_TRUST_REFERRAL = 7 - } drsuapi_DsNameStatus; - - typedef [v1_enum] enum { - DRSUAPI_DS_NAME_FLAG_NO_FLAGS = 0x0, - DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1, - DRSUAPI_DS_NAME_FLAG_EVAL_AT_DC = 0x2, - DRSUAPI_DS_NAME_FLAG_GCVERIFY = 0x4, - DRSUAPI_DS_NAME_FLAG_TRUST_REFERRAL = 0x8 - } drsuapi_DsNameFlags; - - typedef [v1_enum] enum { - DRSUAPI_DS_NAME_FORMAT_UKNOWN = 0, - DRSUAPI_DS_NAME_FORMAT_FQDN_1779 = 1, - DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT = 2, - DRSUAPI_DS_NAME_FORMAT_DISPLAY = 3, - DRSUAPI_DS_NAME_FORMAT_GUID = 6, - DRSUAPI_DS_NAME_FORMAT_CANONICAL = 7, - DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL = 8, - DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX = 9, - DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL = 10, - DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY = 11, - DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN = 12 - } drsuapi_DsNameFormat; - - typedef struct { - [string,charset(UTF16)] uint16 *str; - } drsuapi_DsNameString; - - typedef struct { - uint32 codepage; /* 0x000004e4 - 1252 is german codepage*/ - uint32 language; /* 0x00000407 - german language ID*/ - drsuapi_DsNameFlags format_flags; - drsuapi_DsNameFormat format_offered; - drsuapi_DsNameFormat format_desired; - [range(1,10000)] uint32 count; - [size_is(count)] drsuapi_DsNameString *names; - } drsuapi_DsNameRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsNameRequest1 req1; - } drsuapi_DsNameRequest; - - typedef struct { - drsuapi_DsNameStatus status; - [charset(UTF16),string] uint16 *dns_domain_name; - [charset(UTF16),string] uint16 *result_name; - } drsuapi_DsNameInfo1; - - typedef struct { - uint32 count; - [size_is(count)] drsuapi_DsNameInfo1 *array; - } drsuapi_DsNameCtr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsNameCtr1 *ctr1; - } drsuapi_DsNameCtr; - - WERROR drsuapi_DsCrackNames( - [in] policy_handle *bind_handle, - [in, out] int32 level, - [in,switch_is(level)] drsuapi_DsNameRequest req, - [out,switch_is(level)] drsuapi_DsNameCtr ctr - ); - - /*****************/ - /* Function 0x0d */ - typedef [v1_enum] enum { - DRSUAPI_DS_SPN_OPERATION_ADD = 0, - DRSUAPI_DS_SPN_OPERATION_REPLACE= 1, - DRSUAPI_DS_SPN_OPERATION_DELETE = 2 - } drsuapi_DsSpnOperation; - - typedef struct { - drsuapi_DsSpnOperation operation; - uint32 unknown1; - [charset(UTF16),string] uint16 *object_dn; - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsNameString *spn_names; - } drsuapi_DsWriteAccountSpnRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsWriteAccountSpnRequest1 req1; - } drsuapi_DsWriteAccountSpnRequest; - - typedef struct { - WERROR status; - } drsuapi_DsWriteAccountSpnResult1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsWriteAccountSpnResult1 res1; - } drsuapi_DsWriteAccountSpnResult; - - WERROR drsuapi_DsWriteAccountSpn( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in,switch_is(level)] drsuapi_DsWriteAccountSpnRequest req, - [out,switch_is(level)] drsuapi_DsWriteAccountSpnResult res - ); - - /*****************/ - /* Function 0x0e */ - typedef struct { - [charset(UTF16),string] uint16 *server_dn; - [charset(UTF16),string] uint16 *domain_dn; - uint32 unknown; /* 0x000000001 */ - } drsuapi_DsRemoveDSServerRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsRemoveDSServerRequest1 req1; - } drsuapi_DsRemoveDSServerRequest; - - typedef struct { - WERROR status; - } drsuapi_DsRemoveDSServerResult1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsRemoveDSServerResult1 res1; - } drsuapi_DsRemoveDSServerResult; - - WERROR drsuapi_DsRemoveDSServer( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in,switch_is(level)] drsuapi_DsRemoveDSServerRequest req, - [out,switch_is(level)] drsuapi_DsRemoveDSServerResult res - ); - - /*****************/ - /* Function 0x0f */ - [todo] WERROR DRSUAPI_REMOVE_DS_DOMAIN(); - - /*****************/ - /* Function 0x10 */ - typedef struct { - [charset(UTF16),string] uint16 *domain_name; /* netbios or dns */ - int32 level; /* specifies the switch level for the request */ - } drsuapi_DsGetDCInfoRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetDCInfoRequest1 req1; - } drsuapi_DsGetDCInfoRequest; - - typedef struct { - [charset(UTF16),string] uint16 *netbios_name; - [charset(UTF16),string] uint16 *dns_name; - [charset(UTF16),string] uint16 *site_name; - [charset(UTF16),string] uint16 *computer_dn; - [charset(UTF16),string] uint16 *server_dn; - uint32 is_pdc; - uint32 is_enabled; - } drsuapi_DsGetDCInfo1; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCInfo1 *array; - } drsuapi_DsGetDCInfoCtr1; - - typedef struct { - [charset(UTF16),string] uint16 *netbios_name; - [charset(UTF16),string] uint16 *dns_name; - [charset(UTF16),string] uint16 *site_name; - [charset(UTF16),string] uint16 *site_dn; - [charset(UTF16),string] uint16 *computer_dn; - [charset(UTF16),string] uint16 *server_dn; - [charset(UTF16),string] uint16 *ntds_dn; - uint32 is_pdc; - uint32 is_enabled; - uint32 is_gc; - GUID site_guid; - GUID computer_guid; - GUID server_guid; - GUID ntds_guid; - } drsuapi_DsGetDCInfo2; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCInfo2 *array; - } drsuapi_DsGetDCInfoCtr2; - - /* - * this represents an active connection to the - * Directory System Agent (DSA) - * this can be via LDAP or DRSUAPI - */ - typedef struct { - [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address; - uint32 unknown2; - uint32 connection_time; /* in seconds */ - uint32 unknown4; - uint32 unknown5; - uint32 unknown6; - /* - * client_account can be the following: - * "W2K3\Administrator" - * "Administrator@W2K3" - * "cn=Administrator,cn=Users,DC=w2k3,DC=vmnet1,DC=vm,DC=base" - * "" - * or NULL - */ - [charset(UTF16),string] uint16 *client_account; - } drsuapi_DsGetDCConnection01; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCConnection01 *array; - } drsuapi_DsGetDCConnectionCtr01; - - typedef [v1_enum] enum { - DRSUAPI_DC_INFO_CTR_1 = 1, - DRSUAPI_DC_INFO_CTR_2 = 2, - DRSUAPI_DC_CONNECTION_CTR_01 = -1 - } drsuapi_DsGetDCInfoCtrLevels; - - typedef [switch_type(int32)] union { - [case(DRSUAPI_DC_INFO_CTR_1)] drsuapi_DsGetDCInfoCtr1 ctr1; - [case(DRSUAPI_DC_INFO_CTR_2)] drsuapi_DsGetDCInfoCtr2 ctr2; - [case(DRSUAPI_DC_CONNECTION_CTR_01)] drsuapi_DsGetDCConnectionCtr01 ctr01; - } drsuapi_DsGetDCInfoCtr; - - WERROR drsuapi_DsGetDomainControllerInfo( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,switch_is(level)] drsuapi_DsGetDCInfoRequest req, - [out] int32 level_out, - [out,switch_is(level_out)] drsuapi_DsGetDCInfoCtr ctr - ); - - /*****************/ - /* Function 0x11 */ - typedef [public,noprint] struct { - drsuapi_DsReplicaObjectListItem *next_object; - drsuapi_DsReplicaObject object; - } drsuapi_DsReplicaObjectListItem; - - /* - * The DsAddEntry() call which creates a nTDSDSA object, - * also adds a servicePrincipalName in the following form - * to the computer account of the new domain controller - * referenced by the "serverReferenece" attribute. - * - * E3514235-4B06-11D1-AB04-00C04FC2DCD2// - * - * also note that the "serverReference" isn't added to the new object! - */ - const char *DRSUAPI_NTDSDSA_KRB5_SERVICE_GUID = "E3514235-4B06-11D1-AB04-00C04FC2DCD2"; - - /* - * please note the the current idl - * for DsAddEntry does only parse - * what I saw between 2 w2k3 boxes - * in my dssync experiments I got some other replies - * so all I want to say is that this is very incomplete yet... - * --metze - */ - typedef struct { - drsuapi_DsReplicaObjectListItem first_object; - } drsuapi_DsAddEntryRequest2; - - typedef [switch_type(int32)] union { - [case(2)] drsuapi_DsAddEntryRequest2 req2; - } drsuapi_DsAddEntryRequest; - - typedef struct { - uint32 unknown1; - WERROR status; - uint32 unknown2; - uint16 unknown3; - } drsuapi_DsAddEntryErrorInfoX; - - typedef struct { - [range(0,10485760)] uint32 size; - [size_is(size)] uint8 *data; - } drsuapi_DsAddEntryExtraErrorBuffer; - - typedef struct { - drsuapi_DsAddEntryErrorInfoX error; - drsuapi_DsAttributeId attid; - uint32 unknown2; - drsuapi_DsAddEntryExtraErrorBuffer buffer; - } drsuapi_DsAddEntryExtraError1; - - typedef /*[noprint]*/ struct { - drsuapi_DsAddEntryErrorListItem1 *next; - drsuapi_DsAddEntryExtraError1 error; - } drsuapi_DsAddEntryErrorListItem1; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *id; - WERROR status; - drsuapi_DsAddEntryErrorListItem1 first; - } drsuapi_DsAddEntryErrorInfo1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsAddEntryErrorInfo1 error1; -/* [case(2)] drsuapi_DsAddEntryErrorInfo2 error2; - [case(3)] drsuapi_DsAddEntryErrorInfo3 error3; -*/ [case(4)] drsuapi_DsAddEntryErrorInfoX errorX; - [case(5)] drsuapi_DsAddEntryErrorInfoX errorX; - [case(6)] drsuapi_DsAddEntryErrorInfoX errorX; - [case(7)] drsuapi_DsAddEntryErrorInfoX errorX; - } drsuapi_DsAddEntryErrorInfo; - - typedef struct { - WERROR status; - uint32 level; - [switch_is(level)] drsuapi_DsAddEntryErrorInfo *info; - } drsuapi_DsAddEntryError1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsAddEntryError1 info1; - } drsuapi_DsAddEntryError; - - typedef struct { - GUID guid; - dom_sid28 sid; - } drsuapi_DsReplicaObjectIdentifier2; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *id; - uint32 unknown1; - drsuapi_DsAddEntryErrorInfoX error; - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects; - } drsuapi_DsAddEntryCtr2; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *id; - uint32 level; - [switch_is(level)] drsuapi_DsAddEntryError *error; - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects; - } drsuapi_DsAddEntryCtr3; - - typedef [switch_type(int32)] union { - [case(2)] drsuapi_DsAddEntryCtr2 ctr2; - [case(3)] drsuapi_DsAddEntryCtr3 ctr3; - } drsuapi_DsAddEntryCtr; - - [public] WERROR drsuapi_DsAddEntry( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in,switch_is(level)] drsuapi_DsAddEntryRequest req, - [out,switch_is(level)] drsuapi_DsAddEntryCtr ctr - ); - - /*****************/ - /* Function 0x12 */ - [todo] WERROR DRSUAPI_EXECUTE_KCC(); - - /*****************/ - /* Function 0x13 */ - typedef [v1_enum] enum { - DRSUAPI_DS_REPLICA_GET_INFO = 1, - DRSUAPI_DS_REPLICA_GET_INFO2 = 2 - } drsuapi_DsReplicaGetInfoLevel; - - typedef [v1_enum] enum { - DRSUAPI_DS_REPLICA_INFO_NEIGHBORS = 0, - DRSUAPI_DS_REPLICA_INFO_CURSORS = 1, - DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA = 2, - DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES = 3, - DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES = 4, - DRSUAPI_DS_REPLICA_INFO_PENDING_OPS = 5, - DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA = 6, - DRSUAPI_DS_REPLICA_INFO_CURSORS2 = 7, - DRSUAPI_DS_REPLICA_INFO_CURSORS3 = 8, - DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2 = 9, - DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2 = 10, - DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02 = -2, - DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04 = -4, - DRSUAPI_DS_REPLICA_INFO_CURSORS05 = -5, - DRSUAPI_DS_REPLICA_INFO_06 = -6 - } drsuapi_DsReplicaInfoType; - - typedef struct { - drsuapi_DsReplicaInfoType info_type; - [charset(UTF16),string] uint16 *object_dn; - GUID guid1; - } drsuapi_DsReplicaGetInfoRequest1; - - typedef struct { - drsuapi_DsReplicaInfoType info_type; - [charset(UTF16),string] uint16 *object_dn; - GUID guid1; - uint32 unknown1; - [charset(UTF16),string] uint16 *string1; - [charset(UTF16),string] uint16 *string2; - uint32 unknown2; - } drsuapi_DsReplicaGetInfoRequest2; - - typedef [switch_type(drsuapi_DsReplicaGetInfoLevel)] union { - [case(DRSUAPI_DS_REPLICA_GET_INFO)] drsuapi_DsReplicaGetInfoRequest1 req1; - [case(DRSUAPI_DS_REPLICA_GET_INFO2)] drsuapi_DsReplicaGetInfoRequest2 req2; - } drsuapi_DsReplicaGetInfoRequest; - - typedef struct { - [charset(UTF16),string] uint16 *naming_context_dn; - [charset(UTF16),string] uint16 *source_dsa_obj_dn; - [charset(UTF16),string] uint16 *source_dsa_address; - [charset(UTF16),string] uint16 *transport_obj_dn; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint32 reserved; - GUID naming_context_obj_guid; - GUID source_dsa_obj_guid; - GUID source_dsa_invocation_id; - GUID transport_obj_guid; - hyper tmp_highest_usn; - hyper highest_usn; - NTTIME last_success; - NTTIME last_attempt; - WERROR result_last_attempt; - uint32 consecutive_sync_failures; - } drsuapi_DsReplicaNeighbour; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaNeighbour array[]; - } drsuapi_DsReplicaNeighbourCtr; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaCursor array[]; - } drsuapi_DsReplicaCursorCtr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - } drsuapi_DsReplicaObjMetaData; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaObjMetaData array[]; - } drsuapi_DsReplicaObjMetaDataCtr; - - typedef struct { - [charset(UTF16),string] uint16 *dsa_obj_dn; - GUID dsa_obj_guid; - NTTIME first_failure; - uint32 num_failures; - WERROR last_result; - } drsuapi_DsReplicaKccDsaFailure; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaKccDsaFailure array[]; - } drsuapi_DsReplicaKccDsaFailuresCtr; - - typedef enum { - DRSUAPI_DS_REPLICA_OP_TYPE_SYNC = 0, - DRSUAPI_DS_REPLICA_OP_TYPE_ADD = 1, - DRSUAPI_DS_REPLICA_OP_TYPE_DELETE = 2, - DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY = 3, - DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS = 4 - } drsuapi_DsReplicaOpType; - - typedef [switch_type(drsuapi_DsReplicaOpType)] union { - [case(DRSUAPI_DS_REPLICA_OP_TYPE_SYNC)] drsuapi_DsReplicaSyncOptions sync; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_ADD)] drsuapi_DsReplicaAddOptions add; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_DELETE)] drsuapi_DsReplicaDeleteOptions delete; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY)] drsuapi_DsReplicaModifyOptions modify; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS)] drsuapi_DsReplicaUpdateRefsOptions update_refs; - [default] uint32 unknown; - } drsuapi_DsRplicaOpOptions; - - typedef struct { - NTTIME operation_start; - uint32 serial_num; /* unique till reboot */ - uint32 priority; - drsuapi_DsReplicaOpType operation_type; - [switch_is(operation_type)] drsuapi_DsRplicaOpOptions options; - [charset(UTF16),string] uint16 *nc_dn; - [charset(UTF16),string] uint16 *remote_dsa_obj_dn; - [charset(UTF16),string] uint16 *remote_dsa_address; - GUID nc_obj_guid; - GUID remote_dsa_obj_guid; - } drsuapi_DsReplicaOp; - - typedef struct { - NTTIME time; - uint32 count; - [size_is(count)] drsuapi_DsReplicaOp array[]; - } drsuapi_DsReplicaOpCtr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - [charset(UTF16),string] uint16 *object_dn; - [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary; - DATA_BLOB *binary; - NTTIME deleted; - NTTIME created; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - } drsuapi_DsReplicaAttrValMetaData; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaAttrValMetaData array[]; - } drsuapi_DsReplicaAttrValMetaDataCtr; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaCursor2 array[]; - } drsuapi_DsReplicaCursor2Ctr; - - typedef struct { - GUID source_dsa_invocation_id; - hyper highest_usn; - NTTIME last_sync_success; - [charset(UTF16),string] uint16 *source_dsa_obj_dn; - } drsuapi_DsReplicaCursor3; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaCursor3 array[]; - } drsuapi_DsReplicaCursor3Ctr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - [charset(UTF16),string] uint16 *originating_dsa_dn; - } drsuapi_DsReplicaObjMetaData2; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaObjMetaData2 array[]; - } drsuapi_DsReplicaObjMetaData2Ctr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - [charset(UTF16),string] uint16 *object_dn; - [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary; - DATA_BLOB *binary; - NTTIME deleted; - NTTIME created; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - [charset(UTF16),string] uint16 *originating_dsa_dn; - } drsuapi_DsReplicaAttrValMetaData2; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaAttrValMetaData2 array[]; - } drsuapi_DsReplicaAttrValMetaData2Ctr; - - typedef struct { - hyper u1; /* session number? */ - uint32 u2; - uint32 u3; - GUID bind_guid; - NTTIME_1sec bind_time; - [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address; - uint32 u5; /* this is the same value the client used as pid in the DsBindInfoX struct */ - } drsuapi_DsReplicaConnection04; - - typedef struct { - [range(0,10000)] uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaConnection04 array[]; - } drsuapi_DsReplicaConnection04Ctr; - - typedef struct { - [charset(UTF16),string] uint16 *str1; - uint32 u1; - uint32 u2; - uint32 u3; - uint32 u4; - uint32 u5; - hyper u6; - uint32 u7; - } drsuapi_DsReplica06; - - typedef struct { - [range(0,256)] uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplica06 array[]; - } drsuapi_DsReplica06Ctr; - - typedef [switch_type(drsuapi_DsReplicaInfoType)] union { - [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS)] drsuapi_DsReplicaNeighbourCtr *neighbours; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS)] drsuapi_DsReplicaCursorCtr *cursors; - [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA)] drsuapi_DsReplicaObjMetaDataCtr *objmetadata; - [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *connectfailures; - [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *linkfailures; - [case(DRSUAPI_DS_REPLICA_INFO_PENDING_OPS)] drsuapi_DsReplicaOpCtr *pendingops; - [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA)] drsuapi_DsReplicaAttrValMetaDataCtr *attrvalmetadata; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS2)] drsuapi_DsReplicaCursor2Ctr *cursors2; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS3)] drsuapi_DsReplicaCursor3Ctr *cursors3; - [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2)] drsuapi_DsReplicaObjMetaData2Ctr *objmetadata2; - [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2)] drsuapi_DsReplicaAttrValMetaData2Ctr *attrvalmetadata2; - [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02)] drsuapi_DsReplicaNeighbourCtr *neighbours02; - [case(DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04)] drsuapi_DsReplicaConnection04Ctr *connections04; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS05)] drsuapi_DsReplicaCursorCtrEx *cursors05; - [case(DRSUAPI_DS_REPLICA_INFO_06)] drsuapi_DsReplica06Ctr *i06; - } drsuapi_DsReplicaInfo; - - WERROR drsuapi_DsReplicaGetInfo( - [in] policy_handle *bind_handle, - [in] drsuapi_DsReplicaGetInfoLevel level, - [in,switch_is(level)] drsuapi_DsReplicaGetInfoRequest req, - [out] drsuapi_DsReplicaInfoType info_type, - [out,switch_is(info_type)] drsuapi_DsReplicaInfo info - ); - - /*****************/ - /* Function 0x14 */ - [todo] WERROR DRSUAPI_ADD_SID_HISTORY(); - - /*****************/ - /* Function 0x15 */ - - typedef struct { - [range(0,10000)] uint32 num_entries; - [size_is(num_entries)] drsuapi_DsGetMembershipsCtr1 **ctrl_array; - } drsuapi_DsGetMemberships2Ctr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1; - } drsuapi_DsGetMemberships2Ctr; - - typedef struct { - [range(1,10000)] uint32 num_req; - [size_is(num_req)] drsuapi_DsGetMembershipsRequest1 **req_array; - } drsuapi_DsGetMemberships2Request1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMemberships2Request1 req1; - } drsuapi_DsGetMemberships2Request; - - WERROR drsuapi_DsGetMemberships2( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in] [switch_is(level)] drsuapi_DsGetMemberships2Request req, - [out] [switch_is(level)] drsuapi_DsGetMemberships2Ctr ctr - ); - - - /*****************/ - /* Function 0x16 */ - [todo] WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS(); - - /*****************/ - /* Function 0x17 */ - [todo] WERROR DRSUAPI_GET_OBJECT_EXISTENCE(); - - /*****************/ - /* Function 0x18 */ - typedef struct { - WERROR error_code; - uint32 site_cost; - } drsuapi_DsSiteCostInfo; - - typedef struct { - [range(0,10000)] uint32 num_info; - [size_is(num_info)] drsuapi_DsSiteCostInfo *info; - uint32 unknown; - } drsuapi_QuerySitesByCostCtr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_QuerySitesByCostCtr1 ctr1; - } drsuapi_QuerySitesByCostCtr; - - typedef struct { - [charset(UTF16),string] uint16 *site_from; - [range(1,10000)] uint32 num_req; - [size_is(num_req)] [charset(UTF16),string] uint16 **site_to; - uint32 flags; - } drsuapi_QuerySitesByCostRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_QuerySitesByCostRequest1 req1; - } drsuapi_QuerySitesByCostRequest; - - WERROR drsuapi_QuerySitesByCost( - [in] policy_handle *bind_handle, - [in] int32 level, - [in] [switch_is(level)] drsuapi_QuerySitesByCostRequest req, - [out] int32 level_out, - [out] [switch_is(level_out)] drsuapi_QuerySitesByCostCtr ctr - ); -} diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl index b26d50c173..4a7a42b4dc 100644 --- a/source4/librpc/idl/lsa.idl +++ b/source4/librpc/idl/lsa.idl @@ -45,6 +45,12 @@ import "misc.idl", "security.idl"; [charset(DOS),size_is(size),length_is(length)] uint8 *string; } lsa_AsciiStringLarge; + typedef [public] struct { + uint16 length; + uint16 size; + [size_is(size/2),length_is(length/2)] uint16 *array; + } lsa_BinaryString; + /******************/ /* Function: 0x00 */ NTSTATUS lsa_Close ( @@ -95,8 +101,11 @@ import "misc.idl", "security.idl"; /******************/ /* Function: 0x04 */ - [todo] NTSTATUS lsa_SetSecObj (); - + NTSTATUS lsa_SetSecObj( + [in] policy_handle *handle, + [in] security_secinfo sec_info, + [in,ref] sec_desc_buf *sdbuf + ); /******************/ /* Function: 0x05 */ @@ -121,12 +130,27 @@ import "misc.idl", "security.idl"; lsa_QosInfo *sec_qos; } lsa_ObjectAttribute; + typedef [public,bitmap32bit] bitmap { + LSA_POLICY_VIEW_LOCAL_INFORMATION = 0x00000001, + LSA_POLICY_VIEW_AUDIT_INFORMATION = 0x00000002, + LSA_POLICY_GET_PRIVATE_INFORMATION = 0x00000004, + LSA_POLICY_TRUST_ADMIN = 0x00000008, + LSA_POLICY_CREATE_ACCOUNT = 0x00000010, + LSA_POLICY_CREATE_SECRET = 0x00000020, + LSA_POLICY_CREATE_PRIVILEGE = 0x00000040, + LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS = 0x00000080, + LSA_POLICY_SET_AUDIT_REQUIREMENTS = 0x00000100, + LSA_POLICY_AUDIT_LOG_ADMIN = 0x00000200, + LSA_POLICY_SERVER_ADMIN = 0x00000400, + LSA_POLICY_LOOKUP_NAMES = 0x00000800 + } lsa_PolicyAccessMask; + /* notice the screwup with the system_name - thats why MS created OpenPolicy2 */ [public] NTSTATUS lsa_OpenPolicy ( [in,unique] uint16 *system_name, [in] lsa_ObjectAttribute *attr, - [in] uint32 access_mask, + [in] lsa_PolicyAccessMask access_mask, [out] policy_handle *handle ); @@ -137,12 +161,11 @@ import "misc.idl", "security.idl"; typedef struct { uint32 percent_full; - uint32 log_size; - NTTIME retention_time; + uint32 maximum_log_size; + hyper retention_time; uint8 shutdown_in_progress; - NTTIME time_to_shutdown; + hyper time_to_shutdown; uint32 next_audit_record; - uint32 unknown; } lsa_AuditLogInfo; typedef [v1_enum] enum { @@ -180,9 +203,13 @@ import "misc.idl", "security.idl"; lsa_String name; } lsa_PDAccountInfo; + typedef [v1_enum] enum { + LSA_ROLE_BACKUP=2, + LSA_ROLE_PRIMARY=3 + } lsa_Role; + typedef struct { - uint16 unknown; /* an midl padding bug? */ - uint16 role; + lsa_Role role; } lsa_ServerRole; typedef struct { @@ -201,7 +228,7 @@ import "misc.idl", "security.idl"; typedef struct { hyper modified_id; - NTTIME db_create_time; + NTTIME_hyper db_create_time; } lsa_ModificationInfo; typedef struct { @@ -209,7 +236,6 @@ import "misc.idl", "security.idl"; } lsa_AuditFullSetInfo; typedef struct { - uint16 unknown; /* an midl padding bug? */ uint8 shutdown_on_full; uint8 log_is_full; } lsa_AuditFullQueryInfo; @@ -237,10 +263,12 @@ import "misc.idl", "security.idl"; LSA_POLICY_INFO_ROLE=6, LSA_POLICY_INFO_REPLICA=7, LSA_POLICY_INFO_QUOTA=8, - LSA_POLICY_INFO_DB=9, + LSA_POLICY_INFO_MOD=9, LSA_POLICY_INFO_AUDIT_FULL_SET=10, LSA_POLICY_INFO_AUDIT_FULL_QUERY=11, - LSA_POLICY_INFO_DNS=12 + LSA_POLICY_INFO_DNS=12, + LSA_POLICY_INFO_DNS_INT=13, + LSA_POLICY_INFO_L_ACCOUNT_DOMAIN=14 } lsa_PolicyInfo; typedef [switch_type(uint16)] union { @@ -252,13 +280,15 @@ import "misc.idl", "security.idl"; [case(LSA_POLICY_INFO_ROLE)] lsa_ServerRole role; [case(LSA_POLICY_INFO_REPLICA)] lsa_ReplicaSourceInfo replica; [case(LSA_POLICY_INFO_QUOTA)] lsa_DefaultQuotaInfo quota; - [case(LSA_POLICY_INFO_DB)] lsa_ModificationInfo db; + [case(LSA_POLICY_INFO_MOD)] lsa_ModificationInfo mod; [case(LSA_POLICY_INFO_AUDIT_FULL_SET)] lsa_AuditFullSetInfo auditfullset; [case(LSA_POLICY_INFO_AUDIT_FULL_QUERY)] lsa_AuditFullQueryInfo auditfullquery; [case(LSA_POLICY_INFO_DNS)] lsa_DnsDomainInfo dns; + [case(LSA_POLICY_INFO_DNS_INT)] lsa_DnsDomainInfo dns; + [case(LSA_POLICY_INFO_L_ACCOUNT_DOMAIN)] lsa_DomainInfo l_account_domain; } lsa_PolicyInformation; - NTSTATUS lsa_QueryInfoPolicy ( + NTSTATUS lsa_QueryInfoPolicy( [in] policy_handle *handle, [in] lsa_PolicyInfo level, [out,unique,switch_is(level)] lsa_PolicyInformation *info @@ -280,7 +310,7 @@ import "misc.idl", "security.idl"; /* Function: 0x0a */ [public] NTSTATUS lsa_CreateAccount ( [in] policy_handle *handle, - [in] dom_sid2 *sid, + [in,ref] dom_sid2 *sid, [in] uint32 access_mask, [out] policy_handle *acct_handle ); @@ -384,7 +414,8 @@ import "misc.idl", "security.idl"; LSA_LOOKUP_NAMES_PRIMARY_DOMAIN_ONLY = 3, LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY = 4, LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY = 5, - LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 = 6 + LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 = 6, + LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC = 7 } lsa_LookupNamesLevel; [public] NTSTATUS lsa_LookupNames ( @@ -433,9 +464,9 @@ import "misc.idl", "security.idl"; /*****************************************/ /* Function: 0x11 */ - NTSTATUS lsa_OpenAccount ( + NTSTATUS lsa_OpenAccount( [in] policy_handle *handle, - [in] dom_sid2 *sid, + [in,ref] dom_sid2 *sid, [in] uint32 access_mask, [out] policy_handle *acct_handle ); @@ -465,7 +496,7 @@ import "misc.idl", "security.idl"; /* Function: 0x13 */ NTSTATUS lsa_AddPrivilegesToAccount( [in] policy_handle *handle, - [in] lsa_PrivilegeSet *privs + [in,ref] lsa_PrivilegeSet *privs ); @@ -483,16 +514,39 @@ import "misc.idl", "security.idl"; /* Function: 0x16 */ [todo] NTSTATUS lsa_SetQuotasForAccount(); + typedef [bitmap32bit] bitmap { + LSA_POLICY_MODE_INTERACTIVE = 0x00000001, + LSA_POLICY_MODE_NETWORK = 0x00000002, + LSA_POLICY_MODE_BATCH = 0x00000004, + LSA_POLICY_MODE_SERVICE = 0x00000010, + LSA_POLICY_MODE_PROXY = 0x00000020, + LSA_POLICY_MODE_DENY_INTERACTIVE = 0x00000040, + LSA_POLICY_MODE_DENY_NETWORK = 0x00000080, + LSA_POLICY_MODE_DENY_BATCH = 0x00000100, + LSA_POLICY_MODE_DENY_SERVICE = 0x00000200, + LSA_POLICY_MODE_REMOTE_INTERACTIVE = 0x00000400, + LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE = 0x00000800, + LSA_POLICY_MODE_ALL = 0x00000FF7, + LSA_POLICY_MODE_ALL_NT4 = 0x00000037 + } lsa_SystemAccessModeFlags; + /* Function: 0x17 */ - [todo] NTSTATUS lsa_GetSystemAccessAccount(); + NTSTATUS lsa_GetSystemAccessAccount( + [in] policy_handle *handle, + [out,ref] uint32 *access_mask + ); + /* Function: 0x18 */ - [todo] NTSTATUS lsa_SetSystemAccessAccount(); + NTSTATUS lsa_SetSystemAccessAccount( + [in] policy_handle *handle, + [in] uint32 access_mask + ); /* Function: 0x19 */ NTSTATUS lsa_OpenTrustedDomain( [in] policy_handle *handle, [in] dom_sid2 *sid, - [in] uint32 access_mask, + [in] uint32 access_mask, [out] policy_handle *trustdom_handle ); @@ -664,14 +718,14 @@ import "misc.idl", "security.idl"; /* Function: 0x1a */ NTSTATUS lsa_QueryTrustedDomainInfo( [in] policy_handle *trustdom_handle, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [out,switch_is(level),unique] lsa_TrustedDomainInfo *info ); /* Function: 0x1b */ NTSTATUS lsa_SetInformationTrustedDomain( [in] policy_handle *trustdom_handle, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [in,switch_is(level)] lsa_TrustedDomainInfo *info ); @@ -707,8 +761,8 @@ import "misc.idl", "security.idl"; /* Function: 0x1f */ NTSTATUS lsa_LookupPrivValue( [in] policy_handle *handle, - [in] lsa_String *name, - [out] lsa_LUID *luid + [in,ref] lsa_String *name, + [out,ref] lsa_LUID *luid ); @@ -738,8 +792,6 @@ import "misc.idl", "security.idl"; [in,out] policy_handle *handle ); - - /*******************/ /* Function: 0x23 */ NTSTATUS lsa_EnumAccountsWithUserRight ( @@ -754,14 +806,14 @@ import "misc.idl", "security.idl"; } lsa_RightAttribute; typedef struct { - uint32 count; + [range(0,256)] uint32 count; [size_is(count)] lsa_StringLarge *names; } lsa_RightSet; NTSTATUS lsa_EnumAccountRights ( [in] policy_handle *handle, - [in] dom_sid2 *sid, - [out] lsa_RightSet *rights + [in,ref] dom_sid2 *sid, + [out,ref] lsa_RightSet *rights ); @@ -769,24 +821,24 @@ import "misc.idl", "security.idl"; /* Function: 0x25 */ NTSTATUS lsa_AddAccountRights ( [in] policy_handle *handle, - [in] dom_sid2 *sid, - [in] lsa_RightSet *rights + [in,ref] dom_sid2 *sid, + [in,ref] lsa_RightSet *rights ); - + /**********************/ /* Function: 0x26 */ NTSTATUS lsa_RemoveAccountRights ( [in] policy_handle *handle, - [in] dom_sid2 *sid, - [in] uint32 unknown, - [in] lsa_RightSet *rights + [in,ref] dom_sid2 *sid, + [in] uint8 remove_all, + [in,ref] lsa_RightSet *rights ); /* Function: 0x27 */ NTSTATUS lsa_QueryTrustedDomainInfoBySid( [in] policy_handle *handle, [in] dom_sid2 *dom_sid, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [out,switch_is(level),unique] lsa_TrustedDomainInfo *info ); @@ -794,9 +846,10 @@ import "misc.idl", "security.idl"; NTSTATUS lsa_SetTrustedDomainInfo( [in] policy_handle *handle, [in] dom_sid2 *dom_sid, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [in,switch_is(level)] lsa_TrustedDomainInfo *info ); + /* Function: 0x29 */ NTSTATUS lsa_DeleteTrustedDomain( [in] policy_handle *handle, @@ -814,7 +867,7 @@ import "misc.idl", "security.idl"; [public] NTSTATUS lsa_OpenPolicy2 ( [in,unique] [string,charset(UTF16)] uint16 *system_name, [in] lsa_ObjectAttribute *attr, - [in] uint32 access_mask, + [in] lsa_PolicyAccessMask access_mask, [out] policy_handle *handle ); @@ -834,8 +887,8 @@ import "misc.idl", "security.idl"; /* Function: 0x2e */ NTSTATUS lsa_QueryInfoPolicy2( - [in] policy_handle *handle, - [in] lsa_PolicyInfo level, + [in] policy_handle *handle, + [in] lsa_PolicyInfo level, [out,unique,switch_is(level)] lsa_PolicyInformation *info ); @@ -849,9 +902,9 @@ import "misc.idl", "security.idl"; /**********************/ /* Function 0x30 */ NTSTATUS lsa_QueryTrustedDomainInfoByName( - [in] policy_handle *handle, + [in] policy_handle *handle, [in] lsa_String trusted_domain, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [out,unique,switch_is(level)] lsa_TrustedDomainInfo *info ); @@ -860,7 +913,7 @@ import "misc.idl", "security.idl"; NTSTATUS lsa_SetTrustedDomainInfoByName( [in] policy_handle *handle, [in] lsa_String trusted_domain, - [in] lsa_TrustDomInfoEnum level, + [in] lsa_TrustDomInfoEnum level, [in,unique,switch_is(level)] lsa_TrustedDomainInfo *info ); @@ -926,7 +979,7 @@ import "misc.idl", "security.idl"; NTSTATUS lsa_QueryDomainInformationPolicy( [in] policy_handle *handle, - [in] uint16 level, + [in] uint16 level, [out,unique,switch_is(level)] lsa_DomainInformationPolicy *info ); @@ -998,8 +1051,8 @@ import "misc.idl", "security.idl"; [in,out] lsa_TransSidArray2 *sids, [in] lsa_LookupNamesLevel level, [in,out] uint32 *count, - [in] uint32 unknown1, - [in] uint32 unknown2 + [in] uint32 lookup_options, + [in] uint32 client_revision /* LSA_CLIENT_REVISION* */ ); /* Function 0x3b */ @@ -1041,7 +1094,7 @@ import "misc.idl", "security.idl"; lsa_SidType sid_type; dom_sid2 *sid; uint32 sid_index; - uint32 unknown; + uint32 flags; } lsa_TranslatedSid3; typedef struct { @@ -1057,8 +1110,8 @@ import "misc.idl", "security.idl"; [in,out] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, [in,out] uint32 *count, - [in] uint32 unknown1, - [in] uint32 unknown2 + [in] uint32 lookup_options, + [in] uint32 client_revision /* LSA_CLIENT_REVISION* */ ); /* Function 0x45 */ @@ -1137,6 +1190,11 @@ import "misc.idl", "security.idl"; [in] uint32 unknown2 ); + const int LSA_CLIENT_REVISION_NO_DNS = 0x00000001; + const int LSA_CLIENT_REVISION_DNS = 0x00000002; + + const int LSA_LOOKUP_OPTIONS_NO_ISOLATED = 0x80000000; + /* Function 0x4d */ NTSTATUS lsa_LookupNames4( [in,range(0,1000)] uint32 num_names, @@ -1145,8 +1203,8 @@ import "misc.idl", "security.idl"; [in,out] lsa_TransSidArray3 *sids, [in] lsa_LookupNamesLevel level, [in,out] uint32 *count, - [in] uint32 unknown1, - [in] uint32 unknown2 + [in] uint32 lookup_options, + [in] uint32 client_revision /* LSA_CLIENT_REVISION* */ ); /* Function 0x4e */ diff --git a/source4/librpc/idl/misc.idl b/source4/librpc/idl/misc.idl deleted file mode 100644 index 8331977398..0000000000 --- a/source4/librpc/idl/misc.idl +++ /dev/null @@ -1,58 +0,0 @@ -/* - miscellaneous IDL structures -*/ - - -[ - pointer_default(unique) -] -interface misc -{ - typedef [public,noprint,gensize,noejs] struct { - uint32 time_low; - uint16 time_mid; - uint16 time_hi_and_version; - uint8 clock_seq[2]; - uint8 node[6]; - } GUID; - - typedef [public] struct { - GUID uuid; - uint32 if_version; - } ndr_syntax_id; - - typedef [public] struct { - uint32 handle_type; - GUID uuid; - } policy_handle; - - /* secure channel types */ - /* Only SEC_CHAN_WKSTA can forward requests to other domains. */ - - typedef [public] enum { - SEC_CHAN_WKSTA = 2, - SEC_CHAN_DOMAIN = 4, - SEC_CHAN_BDC = 6 - } netr_SchannelType; - - /* SAM database types */ - typedef [public,v1_enum] enum { - SAM_DATABASE_DOMAIN = 0, /* Domain users and groups */ - SAM_DATABASE_BUILTIN = 1, /* BUILTIN users and groups */ - SAM_DATABASE_PRIVS = 2 /* Privileges */ - } netr_SamDatabaseID; - - typedef [public,v1_enum] enum { - SAMR_REJECT_OTHER = 0, - SAMR_REJECT_TOO_SHORT = 1, - SAMR_REJECT_IN_HISTORY = 2, - SAMR_REJECT_COMPLEXITY = 5 - } samr_RejectReason; - - /* id used to identify a endpoint, possibly in a cluster */ - typedef [public] struct { - hyper id; - uint32 id2; - uint32 node; - } server_id; -} diff --git a/source4/librpc/idl/netlogon.idl b/source4/librpc/idl/netlogon.idl index 2298106851..d78c507c15 100644 --- a/source4/librpc/idl/netlogon.idl +++ b/source4/librpc/idl/netlogon.idl @@ -46,7 +46,7 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *server_name, [in] [string,charset(UTF16)] uint16 account_name[], [in] [string,charset(UTF16)] uint16 workstation[], - [out,unique] netr_UasInfo *info + [out,ref] netr_UasInfo *info ); @@ -62,7 +62,7 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *server_name, [in] [string,charset(UTF16)] uint16 account_name[], [in] [string,charset(UTF16)] uint16 workstation[], - [out] netr_UasLogoffInfo info + [out,ref] netr_UasLogoffInfo *info ); @@ -80,12 +80,24 @@ interface netlogon but it doesn't look as though this structure is reflected at the NDR level. Maybe it is left to the application to decode the bindata array. */ - typedef struct { - uint16 size; - uint16 length; - [size_is(size/2),length_is(length/2)] uint16 *bindata; + typedef [public] struct { + dlong lockout_duration; + udlong reset_count; + uint32 bad_attempt_lockout; + uint32 dummy; } netr_AcctLockStr; + /* - MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT + * sets the NETLOGON_SERVER_TRUST_ACCOUNT user_flag + * - MSV1_0_UPDATE_LOGON_STATISTICS + * sets the logon time on network logon + * - MSV1_0_RETURN_USER_PARAMETERS + * sets the user parameters in the driveletter + * - MSV1_0_RETURN_PROFILE_PATH + * returns the profilepath in the driveletter and + * sets LOGON_PROFILE_PATH_RETURNED user_flag + */ + typedef [public,bitmap32bit] bitmap { MSV1_0_CLEARTEXT_PASSWORD_ALLOWED = 0x00000002, MSV1_0_UPDATE_LOGON_STATISTICS = 0x00000004, @@ -143,11 +155,11 @@ interface netlogon typedef [public,switch_type(netr_LogonInfoClass)] union { [case(NetlogonInteractiveInformation)] netr_PasswordInfo *password; [case(NetlogonNetworkInformation)] netr_NetworkInfo *network; - [case(NetlogonServiceInformation)] netr_PasswordInfo *password; - [case(NetlogonGenericInformation)] netr_GenericInfo *generic; + [case(NetlogonServiceInformation)] netr_PasswordInfo *password; + [case(NetlogonGenericInformation)] netr_GenericInfo *generic; [case(NetlogonInteractiveTransitiveInformation)] netr_PasswordInfo *password; [case(NetlogonNetworkTransitiveInformation)] netr_NetworkInfo *network; - [case(NetlogonServiceTransitiveInformation)] netr_PasswordInfo *password; + [case(NetlogonServiceTransitiveInformation)] netr_PasswordInfo *password; } netr_LogonLevel; typedef [public,flag(NDR_PAHEX)] struct { @@ -160,16 +172,17 @@ interface netlogon /* Flags for user_flags below */ typedef [public,bitmap32bit] bitmap { - NETLOGON_GUEST = 0x0001, - NETLOGON_NOENCRYPTION = 0x0002, - NETLOGON_CACHED_ACCOUNT = 0x0004, - NETLOGON_USED_LM_PASSWORD = 0x0008, - NETLOGON_EXTRA_SIDS = 0x0020, - NETLOGON_SUBAUTH_SESSION_KEY = 0x0040, - NETLOGON_SERVER_TRUST_ACCOUNT = 0x0080, - NETLOGON_NTLMV2_ENABLED = 0x0100, - NETLOGON_RESOURCE_GROUPS = 0x0200, - NETLOGON_PROFILE_PATH_RETURNED = 0x0400 + NETLOGON_GUEST = 0x00000001, + NETLOGON_NOENCRYPTION = 0x00000002, + NETLOGON_CACHED_ACCOUNT = 0x00000004, + NETLOGON_USED_LM_PASSWORD = 0x00000008, + NETLOGON_EXTRA_SIDS = 0x00000020, + NETLOGON_SUBAUTH_SESSION_KEY = 0x00000040, + NETLOGON_SERVER_TRUST_ACCOUNT = 0x00000080, + NETLOGON_NTLMV2_ENABLED = 0x00000100, + NETLOGON_RESOURCE_GROUPS = 0x00000200, + NETLOGON_PROFILE_PATH_RETURNED = 0x00000400, + NETLOGON_GRACE_LOGON = 0x01000000 } netr_UserFlags; typedef struct { @@ -291,7 +304,7 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *computer_name, [in,unique] netr_Authenticator *credential, [in,out,unique] netr_Authenticator *return_authenticator, - [in] uint16 logon_level, + [in] netr_LogonInfoClass logon_level, [in] [switch_is(logon_level)] netr_LogonLevel logon ); @@ -446,7 +459,7 @@ interface netlogon NTTIME domain_create_time; uint32 SecurityInformation; sec_desc_buf sdbuf; - netr_AcctLockStr account_lockout; + lsa_BinaryString account_lockout; lsa_String unknown2; lsa_String unknown3; lsa_String unknown4; @@ -797,20 +810,26 @@ interface netlogon /*****************/ /* Function 0x0C */ + typedef [bitmap32bit] bitmap { + NETLOGON_CTRL_REPL_NEEDED = 0x0001, + NETLOGON_CTRL_REPL_IN_PROGRESS = 0x0002, + NETLOGON_CTRL_REPL_FULL_SYNC = 0x0004 + } netr_InfoFlags; + typedef struct { - uint32 flags; + netr_InfoFlags flags; uint32 pdc_connection_status; } netr_NETLOGON_INFO_1; typedef struct { - uint32 flags; + netr_InfoFlags flags; uint32 pdc_connection_status; [string,charset(UTF16)] uint16 trusted_dc_name[]; uint32 tc_connection_status; } netr_NETLOGON_INFO_2; typedef struct { - uint32 flags; + netr_InfoFlags flags; uint32 logon_attempts; uint32 unknown1; uint32 unknown2; @@ -827,6 +846,7 @@ interface netlogon /* function_code values */ typedef [v1_enum] enum { + NETLOGON_CONTROL_SYNC = 2, NETLOGON_CONTROL_REDISCOVER = 5, NETLOGON_CONTROL_TC_QUERY = 6, NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7, @@ -863,30 +883,54 @@ interface netlogon WERROR netr_LogonControl2( [in,unique] [string,charset(UTF16)] uint16 *logon_server, - [in] uint32 function_code, + [in] netr_LogonControlCode function_code, [in] uint32 level, [in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION data, [out][switch_is(level)] netr_CONTROL_QUERY_INFORMATION query ); - /* If this flag is not set, then the passwords and LM session keys are - * encrypted with DES calls. (And the user session key is - * unencrypted) */ - const int NETLOGON_NEG_ARCFOUR = 0x00000004; - const int NETLOGON_NEG_128BIT = 0x00004000; - const int NETLOGON_NEG_SCHANNEL = 0x40000000; + /* If NETLOGON_NEG_ARCFOUR flag is not set, then the passwords and LM + * session keys are encrypted with DES calls. (And the user session key + * is unencrypted) */ /*****************/ /* Function 0x0F */ + typedef [bitmap32bit] bitmap { + NETLOGON_NEG_ACCOUNT_LOCKOUT = 0x00000001, + NETLOGON_NEG_PERSISTENT_SAMREPL = 0x00000002, + NETLOGON_NEG_ARCFOUR = 0x00000004, + NETLOGON_NEG_PROMOTION_COUNT = 0x00000008, + NETLOGON_NEG_CHANGELOG_BDC = 0x00000010, + NETLOGON_NEG_FULL_SYNC_REPL = 0x00000020, + NETLOGON_NEG_MULTIPLE_SIDS = 0x00000040, + NETLOGON_NEG_REDO = 0x00000080, + NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL = 0x00000100, + NETLOGON_NEG_SEND_PASSWORD_INFO_PDC = 0x00000200, + NETLOGON_NEG_GENERIC_PASSTHROUGH = 0x00000400, + NETLOGON_NEG_CONCURRENT_RPC = 0x00000800, + NETLOGON_NEG_AVOID_ACCOUNT_DB_REPL = 0x00001000, + NETLOGON_NEG_AVOID_SECURITYAUTH_DB_REPL = 0x00002000, + NETLOGON_NEG_128BIT = 0x00004000, /* STRONG_KEYS */ + NETLOGON_NEG_TRANSITIVE_TRUSTS = 0x00008000, + NETLOGON_NEG_DNS_DOMAIN_TRUSTS = 0x00010000, + NETLOGON_NEG_PASSWORD_SET2 = 0x00020000, + NETLOGON_NEG_GETDOMAININFO = 0x00040000, + NETLOGON_NEG_CROSS_FOREST_TRUSTS = 0x00080000, + NETLOGON_NEG_NEUTRALIZE_NT4_EMULATION = 0x00100000, + NETLOGON_NEG_RODC_PASSTHROUGH = 0x00200000, + NETLOGON_NEG_AUTHENTICATED_RPC_LSASS = 0x20000000, + NETLOGON_NEG_SCHANNEL = 0x40000000 /* AUTHENTICATED_RPC */ + } netr_NegotiateFlags; + NTSTATUS netr_ServerAuthenticate2( [in,unique] [string,charset(UTF16)] uint16 *server_name, [in] [string,charset(UTF16)] uint16 account_name[], [in] netr_SchannelType secure_channel_type, [in] [string,charset(UTF16)] uint16 computer_name[], [in,out,ref] netr_Credential *credentials, - [in,out,ref] uint32 *negotiate_flags + [in,out,ref] netr_NegotiateFlags *negotiate_flags ); @@ -948,8 +992,25 @@ interface netlogon /*****************/ /* Function 0x14 */ - /* two unkown bits still: DS_IP_VERSION_AGNOSTIC and - * DS_TRY_NEXTCLOSEST_SITE - Guenther */ + /* one unkown bit still: DS_IP_VERSION_AGNOSTIC - gd*/ + + const int DSGETDC_VALID_FLAGS = (DS_FORCE_REDISCOVERY | + DS_DIRECTORY_SERVICE_REQUIRED | + DS_DIRECTORY_SERVICE_PREFERRED | + DS_GC_SERVER_REQUIRED | + DS_PDC_REQUIRED | + DS_BACKGROUND_ONLY | + DS_IP_REQUIRED | + DS_KDC_REQUIRED | + DS_TIMESERV_REQUIRED | + DS_WRITABLE_REQUIRED | + DS_GOOD_TIMESERV_PREFERRED | + DS_AVOID_SELF | + DS_ONLY_LDAP_NEEDED | + DS_IS_FLAT_NAME | + DS_IS_DNS_NAME | + DS_RETURN_FLAT_NAME | + DS_RETURN_DNS_NAME); typedef [bitmap32bit] bitmap { DS_FORCE_REDISCOVERY = 0x00000001, @@ -967,6 +1028,8 @@ interface netlogon DS_ONLY_LDAP_NEEDED = 0x00008000, DS_IS_FLAT_NAME = 0x00010000, DS_IS_DNS_NAME = 0x00020000, + DS_TRY_NEXTCLOSEST_SITE = 0x00040000, + DS_DIRECTORY_SERVICE_6_REQUIRED = 0x00080000, DS_RETURN_DNS_NAME = 0x40000000, DS_RETURN_FLAT_NAME = 0x80000000 } netr_DsRGetDCName_flags; @@ -977,19 +1040,21 @@ interface netlogon } netr_DsRGetDCNameInfo_AddressType; typedef [bitmap32bit] bitmap { - DS_SERVER_PDC = NBT_SERVER_PDC, - DS_SERVER_GC = NBT_SERVER_GC, - DS_SERVER_LDAP = NBT_SERVER_LDAP, - DS_SERVER_DS = NBT_SERVER_DS, - DS_SERVER_KDC = NBT_SERVER_KDC, - DS_SERVER_TIMESERV = NBT_SERVER_TIMESERV, - DS_SERVER_CLOSEST = NBT_SERVER_CLOSEST, - DS_SERVER_WRITABLE = NBT_SERVER_WRITABLE, - DS_SERVER_GOOD_TIMESERV = NBT_SERVER_GOOD_TIMESERV, - DS_SERVER_NDNC = 0x00000400, - DS_DNS_CONTROLLER = 0x20000000, - DS_DNS_DOMAIN = 0x40000000, - DS_DNS_FOREST = 0x80000000 + DS_SERVER_PDC = NBT_SERVER_PDC, + DS_SERVER_GC = NBT_SERVER_GC, + DS_SERVER_LDAP = NBT_SERVER_LDAP, + DS_SERVER_DS = NBT_SERVER_DS, + DS_SERVER_KDC = NBT_SERVER_KDC, + DS_SERVER_TIMESERV = NBT_SERVER_TIMESERV, + DS_SERVER_CLOSEST = NBT_SERVER_CLOSEST, + DS_SERVER_WRITABLE = NBT_SERVER_WRITABLE, + DS_SERVER_GOOD_TIMESERV = NBT_SERVER_GOOD_TIMESERV, + DS_SERVER_NDNC = NBT_SERVER_NDNC, + DS_SERVER_SELECT_SECRET_DOMAIN_6 = NBT_SERVER_SELECT_SECRET_DOMAIN_6, + DS_SERVER_FULL_SECRET_DOMAIN_6 = NBT_SERVER_FULL_SECRET_DOMAIN_6, + DS_DNS_CONTROLLER = 0x20000000, + DS_DNS_DOMAIN = 0x40000000, + DS_DNS_FOREST = 0x80000000 } netr_DsR_DcFlags; typedef struct { @@ -1040,12 +1105,12 @@ interface netlogon /****************/ /* Function 0x1a */ [public] NTSTATUS netr_ServerAuthenticate3( - [in,unique] [string,charset(UTF16)] uint16 *server_name, + [in,unique] [string,charset(UTF16)] uint16 *server_name, [in] [string,charset(UTF16)] uint16 account_name[], [in] netr_SchannelType secure_channel_type, [in] [string,charset(UTF16)] uint16 computer_name[], [in,out,ref] netr_Credential *credentials, - [in,out,ref] uint32 *negotiate_flags, + [in,out,ref] netr_NegotiateFlags *negotiate_flags, [out,ref] uint32 *rid ); @@ -1070,6 +1135,16 @@ interface netlogon /****************/ /* Function 0x1d */ + typedef [bitmap32bit] bitmap { + NETR_TRUST_FLAG_IN_FOREST = 0x00000001, + NETR_TRUST_FLAG_OUTBOUND = 0x00000002, + NETR_TRUST_FLAG_TREEROOT = 0x00000004, + NETR_TRUST_FLAG_PRIMARY = 0x00000008, + NETR_TRUST_FLAG_NATIVE = 0x00000010, + NETR_TRUST_FLAG_INBOUND = 0x00000020, + NETR_TRUST_FLAG_MIT_KRB5 = 0x00000080, + NETR_TRUST_FLAG_AES = 0x00000100 + } netr_TrustFlags; typedef [flag(NDR_PAHEX)] struct { uint16 length; @@ -1097,26 +1172,61 @@ interface netlogon [case(2)] netr_DomainQuery1 *query1; } netr_DomainQuery; + typedef struct { + /* these first 3 values come from the fact windows + actually encodes this structure as a UNICODE_STRING + - see MS-NRPC section 2.2.1.3.9 */ + [value(8)] uint32 length; + [value(0)] uint32 dummy; + [value(8)] uint32 size; + netr_TrustFlags flags; + uint32 parent_index; + uint32 trust_type; + uint32 trust_attributes; + } netr_trust_extension; + + typedef struct { + uint16 length; /* value is 16 when info != NULL, otherwise 0 */ + [value(length)] uint16 size; /* value is 16 when info != NULL, otherwise 0 */ + netr_trust_extension *info; + } netr_trust_extension_container; + typedef struct { lsa_String domainname; lsa_String fulldomainname; lsa_String forest; GUID guid; dom_sid2 *sid; - netr_BinaryString unknown1[4]; - uint32 unknown[4]; + netr_trust_extension_container trust_extension; + lsa_String dummystring[3]; + uint32 dummy[4]; } netr_DomainTrustInfo; + typedef struct { + uint32 policy_size; + [size_is(policy_size)] uint8 *policy; + } netr_LsaPolicyInfo; + + typedef [public,bitmap32bit] bitmap { + NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS = 0x00000001, + NETR_WS_FLAG_HANDLES_SPN_UPDATE = 0x00000002 + } netr_WorkstationFlags; + typedef struct { netr_DomainTrustInfo domaininfo; uint32 num_trusts; [size_is(num_trusts)] netr_DomainTrustInfo *trusts; - uint32 unknown[14]; /* room for expansion? */ + netr_LsaPolicyInfo lsa_policy; + lsa_String dns_hostname; + lsa_String dummystring[3]; + netr_WorkstationFlags workstation_flags; + uint32 supported_enc_types; + uint32 dummy[2]; } netr_DomainInfo1; typedef union { [case(1)] netr_DomainInfo1 *info1; - [case(2)] netr_DomainInfo1 *info1; + [case(2)] netr_DomainInfo1 *info2; } netr_DomainInfo; NTSTATUS netr_LogonGetDomainInfo( @@ -1200,14 +1310,6 @@ interface netlogon /****************/ /* Function 0x24 */ - typedef [bitmap32bit] bitmap { - NETR_TRUST_FLAG_IN_FOREST = 0x00000001, - NETR_TRUST_FLAG_OUTBOUND = 0x00000002, - NETR_TRUST_FLAG_TREEROOT = 0x00000004, - NETR_TRUST_FLAG_PRIMARY = 0x00000008, - NETR_TRUST_FLAG_NATIVE = 0x00000010, - NETR_TRUST_FLAG_INBOUND = 0x00000020 - } netr_TrustFlags; typedef [v1_enum] enum { NETR_TRUST_TYPE_DOWNLEVEL = 1, @@ -1280,7 +1382,7 @@ interface netlogon NTSTATUS netr_LogonSamLogonEx( [in,unique] [string,charset(UTF16)] uint16 *server_name, [in,unique] [string,charset(UTF16)] uint16 *computer_name, - [in] uint16 logon_level, + [in] netr_LogonInfoClass logon_level, [in] [switch_is(logon_level)] netr_LogonLevel logon, [in] uint16 validation_level, [out] [switch_is(validation_level)] netr_Validation validation, @@ -1312,7 +1414,7 @@ interface netlogon /****************/ /* Function 0x2a */ NTSTATUS netr_ServerTrustPasswordsGet( - [in,unique] [string,charset(UTF16)] uint16 *server_name, + [in,unique] [string,charset(UTF16)] uint16 *server_name, [in] [string,charset(UTF16)] uint16 account_name[], [in] netr_SchannelType secure_channel_type, [in] [string,charset(UTF16)] uint16 computer_name[], @@ -1354,7 +1456,7 @@ interface netlogon [in,unique] [string,charset(UTF16)] uint16 *computer_name, [in,unique] netr_Authenticator *credential, [in,out,unique] netr_Authenticator *return_authenticator, - [in] uint16 logon_level, + [in] netr_LogonInfoClass logon_level, [in] [switch_is(logon_level)] netr_LogonLevel logon, [in] uint16 validation_level, [out] [switch_is(validation_level)] netr_Validation validation, diff --git a/source4/librpc/idl/ntsvcs.idl b/source4/librpc/idl/ntsvcs.idl deleted file mode 100644 index 1cdf8eecaa..0000000000 --- a/source4/librpc/idl/ntsvcs.idl +++ /dev/null @@ -1,77 +0,0 @@ -/* - plug and play services -*/ - -[ - uuid("8d9f4e40-a03d-11ce-8f69-08003e30051b"), - version(1.0), - helpstring("Plug and Play services") -] -interface ntsvcs -{ - [todo] void PNP_Disconnect(); - [todo] void PNP_Connect(); - [todo] void PNP_GetVersion(); - [todo] void PNP_GetGlobalState(); - [todo] void PNP_InitDetection(); - [todo] void PNP_ReportLogOn(); - [todo] void PNP_ValidateDeviceInstance(); - [todo] void PNP_GetRootDeviceInstance(); - [todo] void PNP_GetRelatedDeviceInstance(); - [todo] void PNP_EnumerateSubKeys(); - [todo] void PNP_GetDeviceList(); - [todo] void PNP_GetDeviceListSize(); - [todo] void PNP_GetDepth(); - [todo] void PNP_GetDeviceRegProp(); - [todo] void PNP_SetDeviceRegProp(); - [todo] void PNP_GetClassInstance(); - [todo] void PNP_CreateKey(); - [todo] void PNP_DeleteRegistryKey(); - [todo] void PNP_GetClassCount(); - [todo] void PNP_GetClassName(); - [todo] void PNP_DeleteClassKey(); - [todo] void PNP_GetInterfaceDeviceAlias(); - [todo] void PNP_GetInterfaceDeviceList(); - [todo] void PNP_GetInterfaceDeviceListSize(); - [todo] void PNP_RegisterDeviceClassAssociation(); - [todo] void PNP_UnregisterDeviceClassAssociation(); - [todo] void PNP_GetClassRegProp(); - [todo] void PNP_SetClassRegProp(); - [todo] void PNP_CreateDevInst(); - [todo] void PNP_DeviceInstanceAction(); - [todo] void PNP_GetDeviceStatus(); - [todo] void PNP_SetDeviceProblem(); - [todo] void PNP_DisableDevInst(); - [todo] void PNP_UninstallDevInst(); - [todo] void PNP_AddID(); - [todo] void PNP_RegisterDriver(); - [todo] void PNP_QueryRemove(); - [todo] void PNP_RequestDeviceEject(); - [todo] void PNP_IsDockStationPresent(); - [todo] void PNP_RequestEjectPC(); - [todo] void PNP_HwProfFlags(); - [todo] void PNP_GetHwProfInfo(); - [todo] void PNP_AddEmptyLogConf(); - [todo] void PNP_FreeLogConf(); - [todo] void PNP_GetFirstLogConf(); - [todo] void PNP_GetNextLogConf(); - [todo] void PNP_GetLogConfPriority(); - [todo] void PNP_AddResDes(); - [todo] void PNP_FreeResDes(); - [todo] void PNP_GetNextResDes(); - [todo] void PNP_GetResDesData(); - [todo] void PNP_GetResDesDataSize(); - [todo] void PNP_ModifyResDes(); - [todo] void PNP_DetectResourceLimit(); - [todo] void PNP_QueryResConfList(); - [todo] void PNP_SetHwProf(); - [todo] void PNP_QueryArbitratorFreeData(); - [todo] void PNP_QueryArbitratorFreeSize(); - [todo] void PNP_RunDetection(); - [todo] void PNP_RegisterNotification(); - [todo] void PNP_UnregisterNotification(); - [todo] void PNP_GetCustomDevProp(); - [todo] void PNP_GetVersionInternal(); - [todo] void PNP_GetBlockedDriverInfo(); - [todo] void PNP_GetServerSideDeviceInstallFlags(); -} diff --git a/source4/librpc/idl/opendb.idl b/source4/librpc/idl/opendb.idl index cdbaa6cb1b..265cfaf7ad 100644 --- a/source4/librpc/idl/opendb.idl +++ b/source4/librpc/idl/opendb.idl @@ -7,7 +7,7 @@ ntvfs/common/opendb.c */ -import "misc.idl"; +import "security.idl"; [ pointer_default(unique) diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl index b6cce38196..47882dfb84 100644 --- a/source4/librpc/idl/samr.idl +++ b/source4/librpc/idl/samr.idl @@ -730,6 +730,17 @@ import "misc.idl", "lsa.idl", "security.idl"; NTTIME acct_expiry; } samr_UserInfo17; + typedef [public, flag(NDR_PAHEX)] struct { + uint8 hash[16]; + } samr_Password; + + typedef struct { + samr_Password lm_pwd; + samr_Password nt_pwd; + boolean8 lm_pwd_active; + boolean8 nt_pwd_active; + } samr_UserInfo18; + typedef struct { lsa_String parameters; } samr_UserInfo20; @@ -768,6 +779,10 @@ import "misc.idl", "lsa.idl", "security.idl"; SAMR_FIELD_OWF_PWD = 0x20000000 } samr_FieldsPresent; + /* used for 'password_expired' in samr_UserInfo21 */ + const int PASS_MUST_CHANGE_AT_NEXT_LOGON = 0x01; + const int PASS_DONT_CHANGE_AT_NEXT_LOGON = 0x00; + typedef struct { NTTIME last_logon; NTTIME last_logoff; @@ -850,6 +865,7 @@ import "misc.idl", "lsa.idl", "security.idl"; [case(14)] samr_UserInfo14 info14; [case(16)] samr_UserInfo16 info16; [case(17)] samr_UserInfo17 info17; + [case(18)] samr_UserInfo18 info18; [case(20)] samr_UserInfo20 info20; [case(21)] samr_UserInfo21 info21; [case(23)] samr_UserInfo23 info23; @@ -875,10 +891,6 @@ import "misc.idl", "lsa.idl", "security.idl"; /************************/ /* Function 0x26 */ - typedef [public, flag(NDR_PAHEX)] struct { - uint8 hash[16]; - } samr_Password; - /* this is a password change interface that doesn't give the server the plaintext password. Depricated. @@ -1229,9 +1241,16 @@ import "misc.idl", "lsa.idl", "security.idl"; /************************/ /* Function 0x3e */ + + typedef enum { + SAMR_CONNECT_PRE_W2K = 1, + SAMR_CONNECT_W2K = 2, + SAMR_CONNECT_AFTER_W2K = 3 + } samr_ConnectVersion; + NTSTATUS samr_Connect4( [in,unique,string,charset(UTF16)] uint16 *system_name, - [in] uint32 unknown, + [in] samr_ConnectVersion client_version, [in] samr_ConnectAccessMask access_mask, [out,ref] policy_handle *connect_handle ); @@ -1264,7 +1283,7 @@ import "misc.idl", "lsa.idl", "security.idl"; /* Function 0x40 */ typedef struct { - uint32 unknown1; /* w2k3 gives 3 */ + samr_ConnectVersion client_version; /* w2k3 gives 3 */ uint32 unknown2; /* w2k3 gives 0 */ } samr_ConnectInfo1; diff --git a/source4/librpc/idl/security.idl b/source4/librpc/idl/security.idl index 80efe46453..40aa698176 100644 --- a/source4/librpc/idl/security.idl +++ b/source4/librpc/idl/security.idl @@ -153,6 +153,7 @@ interface security const string SID_CREATOR_OWNER_DOMAIN = "S-1-3"; const string SID_CREATOR_OWNER = "S-1-3-0"; const string SID_CREATOR_GROUP = "S-1-3-1"; + const string SID_OWNER_RIGHTS = "S-1-3-4"; /* SECURITY_NT_AUTHORITY */ const string NAME_NT_AUTHORITY = "NT AUTHORITY"; @@ -172,9 +173,14 @@ interface security const string SID_NT_TERMINAL_SERVER_USERS = "S-1-5-13"; const string SID_NT_REMOTE_INTERACTIVE = "S-1-5-14"; const string SID_NT_THIS_ORGANISATION = "S-1-5-15"; + const string SID_NT_IUSR = "S-1-5-17"; const string SID_NT_SYSTEM = "S-1-5-18"; const string SID_NT_LOCAL_SERVICE = "S-1-5-19"; const string SID_NT_NETWORK_SERVICE = "S-1-5-20"; + const string SID_NT_DIGEST_AUTHENTICATION = "S-1-5-64-21"; + const string SID_NT_NTLM_AUTHENTICATION = "S-1-5-64-10"; + const string SID_NT_SCHANNEL_AUTHENTICATION = "S-1-5-64-14"; + const string SID_NT_OTHER_ORGANISATION = "S-1-5-1000"; /* SECURITY_BUILTIN_DOMAIN_RID */ const string NAME_BUILTIN = "BUILTIN"; @@ -246,6 +252,13 @@ interface security uint32 sub_auths[num_auths]; } dom_sid; + /* id used to identify a endpoint, possibly in a cluster */ + typedef [public] struct { + hyper id; + uint32 id2; + uint32 node; + } server_id; + typedef [bitmap8bit] bitmap { SEC_ACE_FLAG_OBJECT_INHERIT = 0x01, SEC_ACE_FLAG_CONTAINER_INHERIT = 0x02, diff --git a/source4/librpc/idl/srvsvc.idl b/source4/librpc/idl/srvsvc.idl index 703f3281cf..10807cd6af 100644 --- a/source4/librpc/idl/srvsvc.idl +++ b/source4/librpc/idl/srvsvc.idl @@ -65,7 +65,7 @@ import "security.idl", "svcctl.idl"; /******************/ /* Function: 0x01 */ WERROR srvsvc_NetCharDevGetInfo( - [in,unique] [string,charset(UTF16)] uint16 *server_unc, + [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 device_name[], [in] uint32 level, [out,switch_is(level)] srvsvc_NetCharDevInfo info @@ -74,7 +74,7 @@ import "security.idl", "svcctl.idl"; /******************/ /* Function: 0x02 */ WERROR srvsvc_NetCharDevControl( - [in,unique] [string,charset(UTF16)] uint16 *server_unc, + [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 device_name[], [in] uint32 opcode ); @@ -131,7 +131,7 @@ import "security.idl", "svcctl.idl"; /******************/ /* Function: 0x04 */ WERROR srvsvc_NetCharDevQGetInfo( - [in,unique] [string,charset(UTF16)] uint16 *server_unc, + [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 queue_name[], [in] [string,charset(UTF16)] uint16 user[], [in] uint32 level, @@ -151,14 +151,14 @@ import "security.idl", "svcctl.idl"; /******************/ /* Function: 0x06 */ WERROR srvsvc_NetCharDevQPurge( - [in,unique] [string,charset(UTF16)] uint16 *server_unc, + [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 queue_name[] ); /******************/ /* Function: 0x07 */ WERROR srvsvc_NetCharDevQPurgeSelf( - [in,unique] [string,charset(UTF16)] uint16 *server_unc, + [in,unique] [string,charset(UTF16)] uint16 *server_unc, [in] [string,charset(UTF16)] uint16 queue_name[], [in] [string,charset(UTF16)] uint16 computer_name[] ); diff --git a/source4/librpc/idl/svcctl.idl b/source4/librpc/idl/svcctl.idl deleted file mode 100644 index 615f4e3dab..0000000000 --- a/source4/librpc/idl/svcctl.idl +++ /dev/null @@ -1,499 +0,0 @@ -#include "idl_types.h" - -/* - svcctl interface definitions -*/ - -import "misc.idl"; -[ uuid("367abb81-9844-35f1-ad32-98f038001003"), - version(2.0), - pointer_default(unique), - endpoint("ncacn_np:[\\pipe\\svcctl]", "ncalrpc:"), - helpstring("Service Control") -] interface svcctl -{ - typedef struct { - uint32 is_locked; - [string,charset(UTF16)] uint16 *lock_owner; - uint32 lock_duration; - } SERVICE_LOCK_STATUS; - - typedef struct { - uint32 type; - uint32 state; - uint32 controls_accepted; - WERROR win32_exit_code; - uint32 service_exit_code; - uint32 check_point; - uint32 wait_hint; - } SERVICE_STATUS; - - typedef struct { - [relative] astring *service_name; - [relative] astring *display_name; - SERVICE_STATUS status; - } ENUM_SERVICE_STATUS; - - const int SERVICE_TYPE_KERNEL_DRIVER = 0x01; - const int SERVICE_TYPE_FS_DRIVER = 0x02; - const int SERVICE_TYPE_ADAPTER = 0x04; - const int SERVICE_TYPE_RECOGNIZER_DRIVER = 0x08; - const int SERVICE_TYPE_DRIVER=SERVICE_TYPE_KERNEL_DRIVER|SERVICE_TYPE_FS_DRIVER|SERVICE_TYPE_RECOGNIZER_DRIVER; - const int SERVICE_TYPE_WIN32_OWN_PROCESS = 0x10; - const int SERVICE_TYPE_WIN32_SHARE_PROCESS = 0x20; - const int SERVICE_TYPE_WIN32=SERVICE_TYPE_WIN32_OWN_PROCESS|SERVICE_TYPE_WIN32_SHARE_PROCESS; - - const int SERVICE_STATE_ACTIVE = 0x01; - const int SERVICE_STATE_INACTIVE = 0x02; - const int SERVICE_STATE_ALL = 0x03; - - typedef [public,bitmap32bit] bitmap { - SV_TYPE_WORKSTATION = 0x00000001, - SV_TYPE_SERVER = 0x00000002, - SV_TYPE_SQLSERVER = 0x00000004, - SV_TYPE_DOMAIN_CTRL = 0x00000008, - SV_TYPE_DOMAIN_BAKCTRL = 0x00000010, - SV_TYPE_TIME_SOURCE = 0x00000020, - SV_TYPE_AFP = 0x00000040, - SV_TYPE_NOVELL = 0x00000080, - - SV_TYPE_DOMAIN_MEMBER = 0x00000100, - SV_TYPE_PRINTQ_SERVER = 0x00000200, - SV_TYPE_DIALIN_SERVER = 0x00000400, - SV_TYPE_SERVER_UNIX = 0x00000800, - SV_TYPE_NT = 0x00001000, - SV_TYPE_WFW = 0x00002000, - SV_TYPE_SERVER_MFPN = 0x00004000, - SV_TYPE_SERVER_NT = 0x00008000, - SV_TYPE_POTENTIAL_BROWSER = 0x00010000, - SV_TYPE_BACKUP_BROWSER = 0x00020000, - SV_TYPE_MASTER_BROWSER = 0x00040000, - SV_TYPE_DOMAIN_MASTER = 0x00080000, - SV_TYPE_SERVER_OSF = 0x00100000, - SV_TYPE_SERVER_VMS = 0x00200000, - SV_TYPE_WIN95_PLUS = 0x00400000, - SV_TYPE_DFS_SERVER = 0x00800000, - SV_TYPE_ALTERNATE_XPORT = 0x20000000, - SV_TYPE_LOCAL_LIST_ONLY = 0x40000000, - SV_TYPE_DOMAIN_ENUM = 0x80000000 - } svcctl_ServerType; - - const uint32 SV_TYPE_ALL = 0xFFFFFFFF; - - /*****************/ - /* Function 0x00 */ - WERROR svcctl_CloseServiceHandle( - [in,out,ref] policy_handle *handle - ); - - /*****************/ - /* Function 0x01 */ - - typedef enum { - FIXME=1 - } SERVICE_CONTROL; - - WERROR svcctl_ControlService( - [in,ref] policy_handle *handle, - [in] uint32 control, - [out,ref] SERVICE_STATUS *service_status - ); - - /*****************/ - /* Function 0x02 */ - WERROR svcctl_DeleteService( - [in,ref] policy_handle *handle - ); - - /*****************/ - /* Function 0x03 */ - - WERROR svcctl_LockServiceDatabase( - [in,ref] policy_handle *handle, - [out,ref] policy_handle *lock - ); - - /*****************/ - /* Function 0x04 */ - [todo] WERROR svcctl_QueryServiceObjectSecurity( - ); - - /*****************/ - /* Function 0x05 */ - [todo] WERROR svcctl_SetServiceObjectSecurity( - ); - - /*****************/ - /* Function 0x06 */ - WERROR svcctl_QueryServiceStatus( - [in,ref] policy_handle *handle, - [out,ref] SERVICE_STATUS *service_status - ); - - /*****************/ - /* Function 0x07 */ - [todo] WERROR svcctl_SetServiceStatus( - ); - - /*****************/ - /* Function 0x08 */ - WERROR svcctl_UnlockServiceDatabase( - [in,out,ref] policy_handle *lock - ); - - /*****************/ - /* Function 0x09 */ - [todo] WERROR svcctl_NotifyBootConfigStatus( - ); - - /*****************/ - /* Function 0x0a */ - WERROR svcctl_SCSetServiceBitsW( - [in,ref] policy_handle *handle, - [in] uint32 bits, - [in] boolean32 bitson, - [in] boolean32 immediate - ); - - /*****************/ - /* Function 0x0b */ - WERROR svcctl_ChangeServiceConfigW( - [in,ref] policy_handle *handle, - [in] uint32 type, - [in] uint32 start, - [in] uint32 error, - [in,unique] [string,charset(UTF16)] uint16 *binary_path, - [in,unique] [string,charset(UTF16)] uint16 *load_order_group, - [out,ref] uint32 *tag_id, - [in,unique] [string,charset(UTF16)] uint16 *dependencies, - [in,unique] [string,charset(UTF16)] uint16 *service_start_name, - [in,unique] [string,charset(UTF16)] uint16 *password, - [in,unique] [string,charset(UTF16)] uint16 *display_name - ); - - /*****************/ - /* Function 0x0c */ - WERROR svcctl_CreateServiceW( - [in,ref] policy_handle *scmanager_handle, - [in] [string,charset(UTF16)] uint16 ServiceName[], - [in,unique] [string,charset(UTF16)] uint16 *DisplayName, - [in] uint32 desired_access, - [in] uint32 type, - [in] uint32 start_type, - [in] uint32 error_control, - [in] [string,charset(UTF16)] uint16 binary_path[], - [in,unique] [string,charset(UTF16)] uint16 *LoadOrderGroupKey, - [in,out,unique] uint32 *TagId, - [in,unique,size_is(dependencies_size)] uint8 *dependencies, - [in] uint32 dependencies_size, - [in,unique] [string,charset(UTF16)] uint16 *service_start_name, - [in,unique,size_is(password_size)] uint8 *password, - [in] uint32 password_size, - [out,ref] policy_handle *handle - ); - - /*****************/ - /* Function 0x0d */ - WERROR svcctl_EnumDependentServicesW( - [in,ref] policy_handle *service, - [in] uint32 state, - [out,unique] ENUM_SERVICE_STATUS *service_status, - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed, - [out,ref] uint32 *services_returned - ); - - /*****************/ - /* Function 0x0e */ - WERROR svcctl_EnumServicesStatusW( - [in,ref] policy_handle *handle, - [in] uint32 type, - [in] uint32 state, - [in] uint32 buf_size, - [out,size_is(buf_size)] uint8 service[*], - [out,ref] uint32 *bytes_needed, - [out,ref] uint32 *services_returned, - [in,out,unique] uint32 *resume_handle - ); - - /*****************/ - /* Function 0x0f */ - WERROR svcctl_OpenSCManagerW( - [in,unique] [string,charset(UTF16)] uint16 *MachineName, - [in,unique] [string,charset(UTF16)] uint16 *DatabaseName, - [in] uint32 access_mask, - [out,ref] policy_handle *handle - ); - - /*****************/ - /* Function 0x10 */ - WERROR svcctl_OpenServiceW( - [in,ref] policy_handle *scmanager_handle, - [in] [string,charset(UTF16)] uint16 ServiceName[], - [in] uint32 access_mask, - [out,ref] policy_handle *handle - ); - - /*****************/ - /* Function 0x11 */ - WERROR svcctl_QueryServiceConfigW( - [in,ref] policy_handle *handle, - [out] uint8 query[buf_size], /*QUERY_SERVICE_CONFIG */ - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed - ); - - /*****************/ - /* Function 0x12 */ - WERROR svcctl_QueryServiceLockStatusW( - [in,ref] policy_handle *handle, - [in] uint32 buf_size, - [out,ref] SERVICE_LOCK_STATUS *lock_status, - [out,ref] uint32 *required_buf_size - ); - - /*****************/ - /* Function 0x13 */ - WERROR svcctl_StartServiceW( - [in,ref] policy_handle *handle, - [in] uint32 NumArgs, - [in,unique/*FIXME:,length_is(NumArgs)*/] [string,charset(UTF16)] uint16 *Arguments - ); - - /*****************/ - /* Function 0x14 */ - WERROR svcctl_GetServiceDisplayNameW( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *service_name, - [out,ref] [string,charset(UTF16)] uint16 **display_name, - [in,out,unique] uint32 *display_name_length - ); - - /*****************/ - /* Function 0x15 */ - WERROR svcctl_GetServiceKeyNameW( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *service_name, - [out,ref] [string,charset(UTF16)] uint16 **key_name, - [in,out,unique] uint32 *display_name_length - ); - - /*****************/ - /* Function 0x16 */ - WERROR svcctl_SCSetServiceBitsA( - [in,ref] policy_handle *handle, - [in] uint32 bits, - [in] boolean32 bitson, - [in] boolean32 immediate - ); - - /*****************/ - /* Function 0x17 */ - WERROR svcctl_ChangeServiceConfigA( - [in,ref] policy_handle *handle, - [in] uint32 type, - [in] uint32 start, - [in] uint32 error, - [in,unique] [string,charset(UTF16)] uint16 *binary_path, - [in,unique] [string,charset(UTF16)] uint16 *load_order_group, - [out,ref] uint32 *tag_id, - [in,unique] [string,charset(UTF16)] uint16 *dependencies, - [in,unique] [string,charset(UTF16)] uint16 *service_start_name, - [in,unique] [string,charset(UTF16)] uint16 *password, - [in,unique] [string,charset(UTF16)] uint16 *display_name - ); - - /*****************/ - /* Function 0x18 */ - WERROR svcctl_CreateServiceA( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *ServiceName, - [in,unique] [string,charset(UTF16)] uint16 *DisplayName, - [in] uint32 desired_access, - [in] uint32 type, - [in] uint32 start_type, - [in] uint32 error_control, - [in,unique] [string,charset(UTF16)] uint16 *binary_path, - [in,unique] [string,charset(UTF16)] uint16 *LoadOrderGroupKey, - [out,unique] uint32 *TagId, - [in,unique] [string,charset(UTF16)] uint16 *dependencies, - [in,unique] [string,charset(UTF16)] uint16 *service_start_name, - [in,unique] [string,charset(UTF16)] uint16 *password - ); - - /*****************/ - /* Function 0x19 */ - WERROR svcctl_EnumDependentServicesA( - [in,ref] policy_handle *service, - [in] uint32 state, - [out,unique] ENUM_SERVICE_STATUS *service_status, - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed, - [out,ref] uint32 *services_returned - ); - - /*****************/ - /* Function 0x1a */ - WERROR svcctl_EnumServicesStatusA( - [in,ref] policy_handle *handle, - [in] uint32 type, - [in] uint32 state, - [in] uint32 buf_size, - [out,size_is(buf_size)] uint8 service[*], - [out,ref] uint32 *bytes_needed, - [out,ref] uint32 *services_returned, - [in,out,unique] uint32 *resume_handle - ); - - /*****************/ - /* Function 0x1b */ - WERROR svcctl_OpenSCManagerA( - [in,unique] [string,charset(UTF16)] uint16 *MachineName, - [in,unique] [string,charset(UTF16)] uint16 *DatabaseName, - [in] uint32 access_mask, - [out,ref] policy_handle *handle - ); - - /*****************/ - /* Function 0x1c */ - WERROR svcctl_OpenServiceA( - [in,ref] policy_handle *scmanager_handle, - [in,unique] [string,charset(UTF16)] uint16 *ServiceName, - [in] uint32 access_mask - ); - - /*****************/ - /* Function 0x1d */ - WERROR svcctl_QueryServiceConfigA( - [in,ref] policy_handle *handle, - [out] uint8 query[buf_size], /*QUERYU_SERVICE_CONFIG */ - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed - ); - - /*****************/ - /* Function 0x1e */ - WERROR svcctl_QueryServiceLockStatusA( - [in,ref] policy_handle *handle, - [in] uint32 buf_size, - [out,ref] SERVICE_LOCK_STATUS *lock_status, - [out,ref] uint32 *required_buf_size - ); - - /*****************/ - /* Function 0x1f */ - WERROR svcctl_StartServiceA( - [in,ref] policy_handle *handle, - [in] uint32 NumArgs, - [in,unique/*FIXME:,length_is(NumArgs)*/] [string,charset(UTF16)] uint16 *Arguments - ); - - /*****************/ - /* Function 0x20 */ - WERROR svcctl_GetServiceDisplayNameA( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *service_name, - [out,ref] [string,charset(UTF16)] uint16 **display_name, - [in,out,unique] uint32 *display_name_length - ); - - /*****************/ - /* Function 0x21 */ - WERROR svcctl_GetServiceKeyNameA( - [in,ref] policy_handle *handle, - [in,unique] [string,charset(UTF16)] uint16 *service_name, - [out,ref] [string,charset(UTF16)] uint16 **key_name, - [in,out,unique] uint32 *display_name_length - ); - - /*****************/ - /* Function 0x22 */ - [todo] WERROR svcctl_GetCurrentGroupeStateW( - ); - - /*****************/ - /* Function 0x23 */ - [todo] WERROR svcctl_EnumServiceGroupW( - ); - - /*****************/ - /* Function 0x24 */ - WERROR svcctl_ChangeServiceConfig2A( - [in,ref] policy_handle *handle, - [in] uint32 info_level, - [in,unique] uint8 *info - ); - - /*****************/ - /* Function 0x25 */ - WERROR svcctl_ChangeServiceConfig2W( - [in,ref] policy_handle *handle, - [in] uint32 info_level, - [in,unique] uint8 *info - ); - - /*****************/ - /* Function 0x26 */ - WERROR svcctl_QueryServiceConfig2A( - [in,ref] policy_handle *handle, - [in] uint32 info_level, - [out] uint8 buffer[buf_size], - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed - ); - - /*****************/ - /* Function 0x27 */ - WERROR svcctl_QueryServiceConfig2W( - [in,ref] policy_handle *handle, - [in] uint32 info_level, - [out] uint8 buffer[buf_size], - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed - ); - - /*****************/ - /* Function 0x28 */ - WERROR svcctl_QueryServiceStatusEx( - [in,ref] policy_handle *handle, - [in] uint32 info_level, - [out] uint8 buffer[buf_size], - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed - ); - - /*****************/ - /* Function 0x29 */ - WERROR EnumServicesStatusExA( - [in,ref] policy_handle *scmanager, - [in] uint32 info_level, - [in] uint32 type, - [in] uint32 state, - [out] uint8 services[buf_size], - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed, - [out,ref] uint32 *service_returned, - [in,out,unique] uint32 *resume_handle, - [out,ref] [string,charset(UTF16)] uint16 **group_name - ); - - /*****************/ - /* Function 0x2a */ - WERROR EnumServicesStatusExW( - [in,ref] policy_handle *scmanager, - [in] uint32 info_level, - [in] uint32 type, - [in] uint32 state, - [out] uint8 services[buf_size], - [in] uint32 buf_size, - [out,ref] uint32 *bytes_needed, - [out,ref] uint32 *service_returned, - [in,out,unique] uint32 *resume_handle, - [out,ref] [string,charset(UTF16)] uint16 **group_name - ); - - /*****************/ - /* Function 0x2b */ - [todo] WERROR svcctl_SCSendTSMessage( - ); -} diff --git a/source4/librpc/idl/wkssvc.idl b/source4/librpc/idl/wkssvc.idl deleted file mode 100644 index 023ce59ad9..0000000000 --- a/source4/librpc/idl/wkssvc.idl +++ /dev/null @@ -1,795 +0,0 @@ -#include "idl_types.h" - -/* - wkssvc interface definitions -*/ - -import "srvsvc.idl", "lsa.idl"; - -[ uuid("6bffd098-a112-3610-9833-46c3f87e345a"), - version(1.0), - pointer_default(unique), - helpstring("Workstation Service"), - endpoint("ncacn_np:[\\pipe\\wkssvc]","ncacn_ip_tcp:","ncalrpc:") -] interface wkssvc -{ - typedef [v1_enum] enum srvsvc_PlatformId srvsvc_PlatformId; - -#define BOOL uint32 - - /******************/ - /* Function: 0x00 */ - - typedef struct { - srvsvc_PlatformId platform_id; - [string,charset(UTF16)] uint16 *server_name; - [string,charset(UTF16)] uint16 *domain_name; - uint32 version_major; - uint32 version_minor; - } wkssvc_NetWkstaInfo100; - - typedef struct { - srvsvc_PlatformId platform_id; - [string,charset(UTF16)] uint16 *server_name; - [string,charset(UTF16)] uint16 *domain_name; - uint32 version_major; - uint32 version_minor; - [string,charset(UTF16)] uint16 *lan_root; - } wkssvc_NetWkstaInfo101; - - typedef struct { - srvsvc_PlatformId platform_id; - [string,charset(UTF16)] uint16 *server_name; - [string,charset(UTF16)] uint16 *domain_name; - uint32 version_major; - uint32 version_minor; - [string,charset(UTF16)] uint16 *lan_root; - uint32 logged_on_users; - } wkssvc_NetWkstaInfo102; - - /* FIXME: 302, 402 */ - - typedef struct { - uint32 char_wait; - uint32 collection_time; - uint32 maximum_collection_count; - uint32 keep_connection; - uint32 max_commands; - uint32 session_timeout; - uint32 size_char_buf; - uint32 max_threads; - uint32 lock_quota; - uint32 lock_increment; - uint32 lock_maximum; - uint32 pipe_increment; - uint32 pipe_maximum; - uint32 cache_file_timeout; - uint32 dormant_file_limit; - uint32 read_ahead_throughput; - uint32 num_mailslot_buffers; - uint32 num_srv_announce_buffers; - uint32 max_illegal_dgram_events; - uint32 dgram_event_reset_freq; - BOOL log_election_packets; - BOOL use_opportunistic_locking; - BOOL use_unlock_behind; - BOOL use_close_behind; - BOOL buf_named_pipes; - BOOL use_lock_read_unlock; - BOOL utilize_nt_caching; - BOOL use_raw_read; - BOOL use_raw_write; - BOOL use_write_raw_data; - BOOL use_encryption; - BOOL buf_files_deny_write; - BOOL buf_read_only_files; - BOOL force_core_create_mode; - BOOL use_512_byte_max_transfer; - } wkssvc_NetWkstaInfo502; - - typedef struct { - uint32 char_wait; - } wkssvc_NetWkstaInfo1010; - - typedef struct { - uint32 collection_time; - } wkssvc_NetWkstaInfo1011; - - typedef struct { - uint32 maximum_collection_count; - } wkssvc_NetWkstaInfo1012; - - typedef struct { - uint32 keep_connection; - } wkssvc_NetWkstaInfo1013; - - typedef struct { - uint32 session_timeout; - } wkssvc_NetWkstaInfo1018; - - typedef struct { - uint32 size_char_buf; - } wkssvc_NetWkstaInfo1023; - - typedef struct { - uint32 errorlog_sz; - } wkssvc_NetWkstaInfo1027; - - /* downlevel */ - typedef struct { - uint32 print_buf_time; - } wkssvc_NetWkstaInfo1028; - - /* downlevel */ - typedef struct { - uint32 wrk_heuristics; - } wkssvc_NetWkstaInfo1032; - - typedef struct { - uint32 max_threads; - } wkssvc_NetWkstaInfo1033; - - typedef struct { - uint32 lock_quota; - } wkssvc_NetWkstaInfo1041; - - typedef struct { - uint32 lock_increment; - } wkssvc_NetWkstaInfo1042; - - typedef struct { - uint32 lock_maximum; - } wkssvc_NetWkstaInfo1043; - - typedef struct { - uint32 pipe_increment; - } wkssvc_NetWkstaInfo1044; - - typedef struct { - uint32 pipe_maximum; - } wkssvc_NetWkstaInfo1045; - - typedef struct { - uint32 dormant_file_limit; - } wkssvc_NetWkstaInfo1046; - - typedef struct { - uint32 cache_file_timeout; - } wkssvc_NetWkstaInfo1047; - - typedef struct { - uint32 use_opportunistic_locking; - } wkssvc_NetWkstaInfo1048; - - typedef struct { - uint32 use_unlock_behind; - } wkssvc_NetWkstaInfo1049; - - typedef struct { - uint32 use_close_behind; - } wkssvc_NetWkstaInfo1050; - - typedef struct { - uint32 buf_named_pipes; - } wkssvc_NetWkstaInfo1051; - - typedef struct { - uint32 use_lock_read_unlock; - } wkssvc_NetWkstaInfo1052; - - typedef struct { - uint32 utilize_nt_caching; - } wkssvc_NetWkstaInfo1053; - - typedef struct { - uint32 use_raw_read; - } wkssvc_NetWkstaInfo1054; - - typedef struct { - uint32 use_raw_write; - } wkssvc_NetWkstaInfo1055; - - typedef struct { - uint32 use_write_raw_data; - } wkssvc_NetWkstaInfo1056; - - typedef struct { - uint32 use_encryption; - } wkssvc_NetWkstaInfo1057; - - typedef struct { - uint32 buf_files_deny_write; - } wkssvc_NetWkstaInfo1058; - - typedef struct { - uint32 buf_read_only_files; - } wkssvc_NetWkstaInfo1059; - - typedef struct { - uint32 force_core_create_mode; - } wkssvc_NetWkstaInfo1060; - - typedef struct { - uint32 use_512_byte_max_transfer; - } wkssvc_NetWkstaInfo1061; - - typedef struct { - uint32 read_ahead_throughput; - } wkssvc_NetWkstaInfo1062; - - typedef union { - [case(100)] wkssvc_NetWkstaInfo100 *info100; - [case(101)] wkssvc_NetWkstaInfo101 *info101; - [case(102)] wkssvc_NetWkstaInfo102 *info102; - [case(502)] wkssvc_NetWkstaInfo502 *info502; - [case(1010)] wkssvc_NetWkstaInfo1010 *info1010; - [case(1011)] wkssvc_NetWkstaInfo1011 *info1011; - [case(1012)] wkssvc_NetWkstaInfo1012 *info1012; - [case(1013)] wkssvc_NetWkstaInfo1013 *info1013; - [case(1018)] wkssvc_NetWkstaInfo1018 *info1018; - [case(1023)] wkssvc_NetWkstaInfo1023 *info1023; - [case(1027)] wkssvc_NetWkstaInfo1027 *info1027; - [case(1028)] wkssvc_NetWkstaInfo1028 *info1028; - [case(1032)] wkssvc_NetWkstaInfo1032 *info1032; - [case(1033)] wkssvc_NetWkstaInfo1033 *info1033; - [case(1041)] wkssvc_NetWkstaInfo1041 *info1041; - [case(1042)] wkssvc_NetWkstaInfo1042 *info1042; - [case(1043)] wkssvc_NetWkstaInfo1043 *info1043; - [case(1044)] wkssvc_NetWkstaInfo1044 *info1044; - [case(1045)] wkssvc_NetWkstaInfo1045 *info1045; - [case(1046)] wkssvc_NetWkstaInfo1046 *info1046; - [case(1047)] wkssvc_NetWkstaInfo1047 *info1047; - [case(1048)] wkssvc_NetWkstaInfo1048 *info1048; - [case(1049)] wkssvc_NetWkstaInfo1049 *info1049; - [case(1050)] wkssvc_NetWkstaInfo1050 *info1050; - [case(1051)] wkssvc_NetWkstaInfo1051 *info1051; - [case(1052)] wkssvc_NetWkstaInfo1052 *info1052; - [case(1053)] wkssvc_NetWkstaInfo1053 *info1053; - [case(1054)] wkssvc_NetWkstaInfo1054 *info1054; - [case(1055)] wkssvc_NetWkstaInfo1055 *info1055; - [case(1056)] wkssvc_NetWkstaInfo1056 *info1056; - [case(1057)] wkssvc_NetWkstaInfo1057 *info1057; - [case(1058)] wkssvc_NetWkstaInfo1058 *info1058; - [case(1059)] wkssvc_NetWkstaInfo1059 *info1059; - [case(1060)] wkssvc_NetWkstaInfo1060 *info1060; - [case(1061)] wkssvc_NetWkstaInfo1061 *info1061; - [case(1062)] wkssvc_NetWkstaInfo1062 *info1062; - [default] ; - } wkssvc_NetWkstaInfo; - - WERROR wkssvc_NetWkstaGetInfo( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in] uint32 level, - [out,switch_is(level),ref] wkssvc_NetWkstaInfo *info - ); - - - /******************/ - /* Function: 0x01 */ - WERROR wkssvc_NetWkstaSetInfo( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in] uint32 level, - [in,switch_is(level),ref] wkssvc_NetWkstaInfo *info, - [in,out,ref] uint32 *parm_error - ); - - - /*****************************/ - /* Function 0x02 */ - typedef struct { - [string,charset(UTF16)] uint16 *user_name; - } wkssvc_NetrWkstaUserInfo0; - - typedef struct { - uint32 entries_read; - [size_is(entries_read)] wkssvc_NetrWkstaUserInfo0 *user0; - } wkssvc_NetWkstaEnumUsersCtr0; - - typedef struct { - [string,charset(UTF16)] uint16 *user_name; - [string,charset(UTF16)] uint16 *logon_domain; - [string,charset(UTF16)] uint16 *other_domains; - [string,charset(UTF16)] uint16 *logon_server; - } wkssvc_NetrWkstaUserInfo1; - - typedef struct { - uint32 entries_read; - [size_is(entries_read)] wkssvc_NetrWkstaUserInfo1 *user1; - } wkssvc_NetWkstaEnumUsersCtr1; - - typedef [switch_type(uint32)] union { - [case(0)] wkssvc_NetWkstaEnumUsersCtr0 *user0; - [case(1)] wkssvc_NetWkstaEnumUsersCtr1 *user1; - } wkssvc_NetWkstaEnumUsersCtr; - - typedef struct { - uint32 level; - [switch_is(level)] wkssvc_NetWkstaEnumUsersCtr ctr; - } wkssvc_NetWkstaEnumUsersInfo; - - WERROR wkssvc_NetWkstaEnumUsers( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,out,ref] wkssvc_NetWkstaEnumUsersInfo *info, - [in] uint32 prefmaxlen, - [out,ref] uint32 *entries_read, - [in,out,unique] uint32 *resume_handle - ); - - /*****************************/ - /* Function 0x03 */ - typedef struct { - [string,charset(UTF16)] uint16 *other_domains; - } wkssvc_NetrWkstaUserInfo1101; - - typedef [switch_type(uint32)] union { - [case(0)] wkssvc_NetrWkstaUserInfo0 *info0; - [case(1)] wkssvc_NetrWkstaUserInfo1 *info1; - [case(1101)] wkssvc_NetrWkstaUserInfo1101 *info1101; - } wkssvc_NetrWkstaUserInfo; - - WERROR wkssvc_NetrWkstaUserGetInfo( - [in,unique] [string,charset(UTF16)] uint16 *unknown, - [in] uint32 level, - [out,ref] [switch_is(level)] wkssvc_NetrWkstaUserInfo *info - ); - - /*****************************/ - /* Function 0x04 */ - WERROR wkssvc_NetrWkstaUserSetInfo( - [in,unique] [string,charset(UTF16)] uint16 *unknown, - [in] uint32 level, - [in,ref] [switch_is(level)] wkssvc_NetrWkstaUserInfo *info, - [in,out,unique] uint32 *parm_err - ); - - /*****************************/ - /* Function 0x05 */ - - typedef struct { - uint32 quality_of_service; - uint32 vc_count; - [string,charset(UTF16)] uint16 *name; - [string,charset(UTF16)] uint16 *address; - uint32 wan_link; - } wkssvc_NetWkstaTransportInfo0; - - typedef struct { - uint32 count; - [size_is(count)] wkssvc_NetWkstaTransportInfo0 *array; - } wkssvc_NetWkstaTransportCtr0; - - typedef union { - [case(0)] wkssvc_NetWkstaTransportCtr0 *ctr0; - } wkssvc_NetWkstaTransportCtr; - - typedef struct { - uint32 level; - [switch_is(level)] wkssvc_NetWkstaTransportCtr ctr; - } wkssvc_NetWkstaTransportInfo; - - WERROR wkssvc_NetWkstaTransportEnum ( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,out,ref] wkssvc_NetWkstaTransportInfo *info, - [in] uint32 max_buffer, - [out,ref] uint32 *total_entries, - [in,out,unique] uint32 *resume_handle - ); - - /*****************************/ - /* Function 0x06 */ - /* only supported on NT */ - WERROR wkssvc_NetrWkstaTransportAdd( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in] uint32 level, /* must be 0 */ - [in,ref] wkssvc_NetWkstaTransportInfo0 *info0, - [in,out,unique] uint32 *parm_err - ); - - /*****************************/ - /* Function 0x07 */ - /* only supported on NT */ - WERROR wkssvc_NetrWkstaTransportDel( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *transport_name, - [in] uint32 unknown3 - ); - - /*****************************/ - /* Function 0x08 */ - typedef struct { - [string,charset(UTF16)] uint16 *unknown1; - [string,charset(UTF16)] uint16 *unknown2; - } wkssvc_NetrUseInfo3; - - typedef struct { - [string,charset(UTF16)] uint16 *local; - [string,charset(UTF16)] uint16 *remote; - [string,charset(UTF16)] uint16 *password; - uint32 status; - uint32 asg_type; - uint32 ref_count; - uint32 use_count; - [string,charset(UTF16)] uint16 *user_name; - [string,charset(UTF16)] uint16 *domain_name; - } wkssvc_NetrUseInfo2; - - typedef struct { - [string,charset(UTF16)] uint16 *local; - [string,charset(UTF16)] uint16 *remote; - [string,charset(UTF16)] uint16 *password; - uint32 status; - uint32 asg_type; - uint32 ref_count; - uint32 use_count; - } wkssvc_NetrUseInfo1; - - typedef struct { - [string,charset(UTF16)] uint16 *local; - [string,charset(UTF16)] uint16 *remote; - } wkssvc_NetrUseInfo0; - - typedef [switch_type(uint32)] union { - [case(0)] wkssvc_NetrUseInfo0 *info0; - [case(1)] wkssvc_NetrUseInfo1 *info1; - [case(2)] wkssvc_NetrUseInfo2 *info2; - [case(3)] wkssvc_NetrUseInfo3 *info3; - } wkssvc_NetrUseGetInfoCtr; - - WERROR wkssvc_NetrUseAdd( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in] uint32 level, - [in,ref] [switch_is(level)] wkssvc_NetrUseGetInfoCtr *ctr, - [in,out,unique] uint32 *parm_err - ); - - /*****************************/ - /* Function 0x09 */ - WERROR wkssvc_NetrUseGetInfo( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *use_name, - [in] uint32 level, - [out,ref] [switch_is(level)] wkssvc_NetrUseGetInfoCtr *ctr - ); - - /*****************************/ - /* Function 0x0a */ - WERROR wkssvc_NetrUseDel( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *use_name, - [in] uint32 force_cond - ); - - /*****************************/ - /* Function 0x0b */ - typedef struct { - uint32 count; - [size_is(count)] wkssvc_NetrUseInfo2 *array; - } wkssvc_NetrUseEnumCtr2; - - typedef struct { - uint32 count; - [size_is(count)] wkssvc_NetrUseInfo1 *array; - } wkssvc_NetrUseEnumCtr1; - - typedef struct { - uint32 count; - [size_is(count)] wkssvc_NetrUseInfo0 *array; - } wkssvc_NetrUseEnumCtr0; - - typedef [switch_type(uint32)] union { - [case(0)] wkssvc_NetrUseEnumCtr0 *ctr0; - [case(1)] wkssvc_NetrUseEnumCtr1 *ctr1; - [case(2)] wkssvc_NetrUseEnumCtr2 *ctr2; - } wkssvc_NetrUseEnumCtr; - - typedef struct { - uint32 level; - [switch_is(level)] wkssvc_NetrUseEnumCtr ctr; - } wkssvc_NetrUseEnumInfo; - - WERROR wkssvc_NetrUseEnum( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,out,ref] wkssvc_NetrUseEnumInfo *info, - [in] uint32 prefmaxlen, - [out,ref] uint32 *entries_read, - [in,out,unique] uint32 *resume_handle - ); - - /*****************************/ - /* Function 0x0c */ - WERROR wkssvc_NetrMessageBufferSend( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *message_name, - [in,unique] [string,charset(UTF16)] uint16 *message_sender_name, - [in,ref] [size_is(message_size)] uint8 *message_buffer, - [in] uint32 message_size - ); - - /*****************************/ - /* Function 0x0d */ - typedef struct { - hyper unknown1; - hyper unknown2; - hyper unknown3; - hyper unknown4; - hyper unknown5; - hyper unknown6; - hyper unknown7; - hyper unknown8; - hyper unknown9; - hyper unknown10; - hyper unknown11; - hyper unknown12; - hyper unknown13; - uint32 unknown14; - uint32 unknown15; - uint32 unknown16; - uint32 unknown17; - uint32 unknown18; - uint32 unknown19; - uint32 unknown20; - uint32 unknown21; - uint32 unknown22; - uint32 unknown23; - uint32 unknown24; - uint32 unknown25; - uint32 unknown26; - uint32 unknown27; - uint32 unknown28; - uint32 unknown29; - uint32 unknown30; - uint32 unknown31; - uint32 unknown32; - uint32 unknown33; - uint32 unknown34; - uint32 unknown35; - uint32 unknown36; - uint32 unknown37; - uint32 unknown38; - uint32 unknown39; - uint32 unknown40; - } wkssvc_NetrWorkstationStatistics; - - WERROR wkssvc_NetrWorkstationStatisticsGet( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *unknown2, - [in] uint32 unknown3, - [in] uint32 unknown4, - [out,ref] wkssvc_NetrWorkstationStatistics **info - ); - - /*****************************/ - /* Function 0x0e */ - WERROR wkssvc_NetrLogonDomainNameAdd( - [in,ref] [string,charset(UTF16)] uint16 *domain_name - ); - - /*****************************/ - /* Function 0x0f */ - WERROR wkssvc_NetrLogonDomainNameDel( - [in,ref] [string,charset(UTF16)] uint16 *domain_name - ); - - /*****************************/ - /* Function 0x10 */ - WERROR wkssvc_NetrJoinDomain( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *domain_name, - [in,unique] [string,charset(UTF16)] uint16 *account_ou, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] [string,charset(UTF16)] uint16 *password, - [in] wkssvc_joinflags join_flags - ); - - /*****************************/ - /* Function 0x11 */ - WERROR wkssvc_NetrUnjoinDomain( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] [string,charset(UTF16)] uint16 *password, - [in] wkssvc_joinflags unjoin_flags - ); - - /*****************************/ - /* Function 0x12 */ - typedef [bitmap32bit] bitmap { - /* TRUE: create the account in the domain */ - WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE = 0x00000002 - } wkssvc_renameflags; - - WERROR wkssvc_NetrRenameMachineInDomain( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *NewMachineName, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] [string,charset(UTF16)] uint16 *password, - [in] wkssvc_renameflags RenameOptions - ); - - /*****************************/ - /* Function 0x13 */ - typedef enum { - NetSetupUnknown = 0, - NetSetupMachine = 1, - NetSetupWorkgroup = 2, - NetSetupDomain = 3, - NetSetupNonExistentDomain = 4, - NetSetupDnsMachine = 5 - } wkssvc_NetValidateNameType; - - WERROR wkssvc_NetrValidateName( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *name, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] [string,charset(UTF16)] uint16 *Password, - [in] wkssvc_NetValidateNameType name_type - ); - - /*****************************/ - /* Function 0x14 */ - typedef enum { - NetSetupUnknownStatus = 0, - NetSetupUnjoined = 1, - NetSetupWorkgroupName = 2, - NetSetupDomainName = 3 - } wkssvc_NetJoinStatus; - - WERROR wkssvc_NetrGetJoinInformation( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,out,ref] [string,charset(UTF16)] uint16 **name_buffer, - [out,ref] wkssvc_NetJoinStatus *name_type - ); - - /*****************************/ - /* Function 0x15 */ - WERROR wkssvc_NetrGetJoinableOus( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *domain_name, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] [string,charset(UTF16)] uint16 *unknown, - [in,out,ref] uint32 *num_ous, - /* - * this is a [ref] pointer to a [unique] pointer to an - * array of [unique] pointers to a string array - */ - [out,ref] [size_is(,*num_ous)] [string,charset(UTF16)] uint16 ***ous - ); - - typedef [flag(NDR_PAHEX)] struct { - uint8 data[524]; - } wkssvc_PasswordBuffer; - - typedef [bitmap32bit] bitmap { - WKSSVC_JOIN_FLAGS_JOIN_WITH_NEW_NAME = 0x00000400, - WKSSVC_JOIN_FLAGS_JOIN_DC_ACCOUNT = 0x00000200, - /* TRUE: defer setting the SPN and dNSHostName until a rename operation */ - WKSSVC_JOIN_FLAGS_DEFER_SPN = 0x00000100, - - /* TRUE: set the machine password to the provided one after the join completes */ - WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED = 0x00000080, - - /* TRUE: perform an unsecured join */ - WKSSVC_JOIN_FLAGS_JOIN_UNSECURE = 0x00000040, - - /* TRUE: allow the join to complete even if the account already exists */ - WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED = 0x00000020, - - /* TRUE: this join is part of a w9x upgrade */ - WKSSVC_JOIN_FLAGS_WIN9X_UPGRADE = 0x00000010, - - /* TRUE: delete the account when the domain is left */ - WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE = 0x00000004, - - /* TRUE: create the account in the domain */ - WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE = 0x00000002, - - /* TRUE: join domain FALSE: join workgroup */ - WKSSVC_JOIN_FLAGS_JOIN_TYPE = 0x00000001 - - } wkssvc_joinflags; - - /*****************************/ - /* Function 0x16 */ - WERROR wkssvc_NetrJoinDomain2 ( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *domain_name, - [in,unique] [string,charset(UTF16)] uint16 *account_ou, - [in,unique] [string,charset(UTF16)] uint16 *admin_account, - [in,unique] wkssvc_PasswordBuffer *encrypted_password, - [in] wkssvc_joinflags join_flags - ); - - /*****************************/ - /* Function 0x17 */ - WERROR wkssvc_NetrUnjoinDomain2 ( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *account, - [in,unique] wkssvc_PasswordBuffer *encrypted_password, - [in] wkssvc_joinflags unjoin_flags - ); - - /*****************************/ - /* Function 0x18 */ - WERROR wkssvc_NetrRenameMachineInDomain2( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *NewMachineName, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] wkssvc_PasswordBuffer *EncryptedPassword, - [in] wkssvc_renameflags RenameOptions - ); - - /*****************************/ - /* Function 0x19 */ - WERROR wkssvc_NetrValidateName2( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *name, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] wkssvc_PasswordBuffer *EncryptedPassword, - [in] wkssvc_NetValidateNameType name_type - ); - - /*****************************/ - /* Function 0x1a */ - WERROR wkssvc_NetrGetJoinableOus2( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,ref] [string,charset(UTF16)] uint16 *domain_name, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] wkssvc_PasswordBuffer *EncryptedPassword, - [in,out,ref] uint32 *num_ous, - /* - * this is a [ref] pointer to a [unique] pointer to an - * array of [unique] pointers to a string array - */ - [out,ref] [size_is(,*num_ous)] [string,charset(UTF16)] uint16 ***ous - ); - - /*****************************/ - /* Function 0x1b */ - WERROR wkssvc_NetrAddAlternateComputerName( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *NewAlternateMachineName, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] wkssvc_PasswordBuffer *EncryptedPassword, - [in] uint32 Reserved - ); - - /*****************************/ - /* Function 0x1c */ - WERROR wkssvc_NetrRemoveAlternateComputerName( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *AlternateMachineNameToRemove, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] wkssvc_PasswordBuffer *EncryptedPassword, - [in] uint32 Reserved - ); - - /*****************************/ - /* Function 0x1d */ - WERROR wkssvc_NetrSetPrimaryComputername( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in,unique] [string,charset(UTF16)] uint16 *primary_name, - [in,unique] [string,charset(UTF16)] uint16 *Account, - [in,unique] wkssvc_PasswordBuffer *EncryptedPassword, - [in] uint32 Reserved - ); - - /*****************************/ - /* Function 0x1e */ - typedef enum { - NetPrimaryComputerName = 0, - NetAlternateComputerNames = 1, - NetAllComputerNames = 2, - NetComputerNameTypeMax = 3 - } wkssvc_ComputerNameType; - - typedef struct { - uint32 count; - [size_is(count)] lsa_String *computer_name; - } wkssvc_ComputerNamesCtr; - - WERROR wkssvc_NetrEnumerateComputerNames( - [in,unique] [string,charset(UTF16)] uint16 *server_name, - [in] wkssvc_ComputerNameType name_type, - [in] uint32 Reserved, - [out,ref] wkssvc_ComputerNamesCtr **ctr - ); -} diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 79548f81bc..a143284f17 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -587,8 +587,7 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co ndr->depth++; for (i=0;ipfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) { ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT; + hdr_size += 16; } ndr_err = ndr_push_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, pkt); @@ -415,7 +415,7 @@ static NTSTATUS ncacn_push_request_sign(struct dcerpc_connection *c, case DCERPC_AUTH_LEVEL_PRIVACY: status = gensec_seal_packet(c->security_state.generic_state, mem_ctx, - blob->data + DCERPC_REQUEST_LENGTH, + blob->data + hdr_size, payload_length, blob->data, blob->length, @@ -428,7 +428,7 @@ static NTSTATUS ncacn_push_request_sign(struct dcerpc_connection *c, case DCERPC_AUTH_LEVEL_INTEGRITY: status = gensec_sign_packet(c->security_state.generic_state, mem_ctx, - blob->data + DCERPC_REQUEST_LENGTH, + blob->data + hdr_size, payload_length, blob->data, blob->length, diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h index 1fd56cb052..482e803a35 100644 --- a/source4/librpc/rpc/dcerpc.h +++ b/source4/librpc/rpc/dcerpc.h @@ -27,7 +27,7 @@ #ifndef __DCERPC_H__ #define __DCERPC_H__ -#include "lib/util/data_blob.h" +#include "../lib/util/data_blob.h" #include "librpc/gen_ndr/dcerpc.h" #include "librpc/ndr/libndr.h" @@ -375,4 +375,6 @@ NTSTATUS dcerpc_request(struct dcerpc_pipe *p, typedef NTSTATUS (*dcerpc_call_fn) (struct dcerpc_pipe *, TALLOC_CTX *, void *); +enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot); + #endif /* __DCERPC_H__ */ diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 318b8fe36d..b117a98270 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -121,6 +121,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT conn->in.workgroup = lp_workgroup(lp_ctx); lp_smbcli_options(lp_ctx, &conn->in.options); + lp_smbcli_session_options(lp_ctx, &conn->in.session_options); /* * provide proper credentials - user supplied, but allow a @@ -137,7 +138,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT /* send smb connect request */ conn_req = smb_composite_connect_send(conn, s->io.pipe->conn, - lp_resolve_context(lp_ctx), + s->io.resolve_ctx, s->io.pipe->conn->event_ctx); if (composite_nomem(conn_req, c)) return c; diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c index abc67ad38b..b4d5d05b61 100644 --- a/source4/librpc/rpc/dcerpc_secondary.c +++ b/source4/librpc/rpc/dcerpc_secondary.c @@ -95,13 +95,14 @@ _PUBLIC_ struct composite_context* dcerpc_secondary_connection_send(struct dcerp s->binding->host, s->binding->target_hostname, atoi(s->binding->endpoint), - lp_resolve_context(global_loadparm)); + dcerpc_resolve_ctx(s->pipe->conn)); composite_continue(c, pipe_tcp_req, continue_open_tcp, c); return c; case NCALRPC: - pipe_ncalrpc_req = dcerpc_pipe_open_pipe_send(s->pipe2->conn, lp_ncalrpc_dir(global_loadparm), - s->binding->endpoint); + case NCACN_UNIX_STREAM: + pipe_ncalrpc_req = dcerpc_pipe_open_unix_stream_send(s->pipe2->conn, + dcerpc_unix_socket_path(s->pipe->conn)); composite_continue(c, pipe_ncalrpc_req, continue_open_pipe, c); return c; diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 7480beae33..1e2b4cde48 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -39,6 +39,9 @@ struct sock_private { struct packet_context *packet; uint32_t pending_reads; + + struct resolve_context *resolve_ctx; + const char *path; /* For ncacn_unix_sock and ncalrpc */ }; @@ -307,6 +310,7 @@ static struct composite_context *dcerpc_pipe_open_socket_send(TALLOC_CTX *mem_ct struct resolve_context *resolve_context, struct socket_address *server, const char *target_hostname, + const char *full_path, enum dcerpc_transport_t transport) { struct composite_context *c; @@ -334,6 +338,9 @@ static struct composite_context *dcerpc_pipe_open_socket_send(TALLOC_CTX *mem_ct talloc_steal(s->sock, s->socket_ctx); + s->sock->resolve_ctx = resolve_context; + s->sock->path = talloc_reference(s->sock, full_path); + conn_req = socket_connect_send(s->socket_ctx, NULL, s->server, 0, resolve_context, c->event_ctx); @@ -386,6 +393,7 @@ static void continue_ip_resolve_name(struct composite_context *ctx) sock_ipv4_req = dcerpc_pipe_open_socket_send(c, s->conn, s->resolve_ctx, s->srvaddr, s->target_hostname, + NULL, NCACN_IP_TCP); composite_continue(c, sock_ipv4_req, continue_ipv4_open_socket, c); } @@ -561,6 +569,7 @@ struct composite_context *dcerpc_pipe_open_unix_stream_send(struct dcerpc_connec sock_unix_req = dcerpc_pipe_open_socket_send(c, s->conn, NULL, s->srvaddr, NULL, + s->path, NCALRPC); composite_continue(c, sock_unix_req, continue_unix_open_socket, c); return c; @@ -579,13 +588,6 @@ NTSTATUS dcerpc_pipe_open_unix_stream_recv(struct composite_context *c) } -struct pipe_np_state { - char *full_path; - struct socket_address *srvaddr; - struct dcerpc_connection *conn; -}; - - /* Stage 2 of dcerpc_pipe_open_pipe_send: receive socket open request */ @@ -612,13 +614,13 @@ struct composite_context* dcerpc_pipe_open_pipe_send(struct dcerpc_connection *c struct composite_context *c; struct composite_context *sock_np_req; - struct pipe_np_state *s; + struct pipe_unix_state *s; /* composite context allocation and setup */ c = composite_create(conn, conn->event_ctx); if (c == NULL) return NULL; - s = talloc_zero(c, struct pipe_np_state); + s = talloc_zero(c, struct pipe_unix_state); if (composite_nomem(s, c)) return c; c->private_data = s; @@ -628,15 +630,15 @@ struct composite_context* dcerpc_pipe_open_pipe_send(struct dcerpc_connection *c s->conn = conn; string_replace(canon, '/', '\\'); - s->full_path = talloc_asprintf(canon, "%s/%s", ncalrpc_dir, canon); - if (composite_nomem(s->full_path, c)) return c; + s->path = talloc_asprintf(canon, "%s/%s", ncalrpc_dir, canon); + if (composite_nomem(s->path, c)) return c; /* prepare server address using path and transport name */ - s->srvaddr = socket_address_from_strings(conn, "unix", s->full_path, 0); + s->srvaddr = socket_address_from_strings(conn, "unix", s->path, 0); if (composite_nomem(s->srvaddr, c)) return c; /* send socket open request */ - sock_np_req = dcerpc_pipe_open_socket_send(c, s->conn, NULL, s->srvaddr, NULL, NCALRPC); + sock_np_req = dcerpc_pipe_open_socket_send(c, s->conn, NULL, s->srvaddr, NULL, s->path, NCALRPC); composite_continue(c, sock_np_req, continue_np_open_socket, c); return c; } @@ -662,3 +664,15 @@ NTSTATUS dcerpc_pipe_open_pipe(struct dcerpc_connection *conn, const char *ncalr struct composite_context *c = dcerpc_pipe_open_pipe_send(conn, ncalrpc_dir, identifier); return dcerpc_pipe_open_pipe_recv(c); } + +const char *dcerpc_unix_socket_path(struct dcerpc_connection *p) +{ + struct sock_private *sock = (struct sock_private *)p->transport.private_data; + return sock->path; +} + +struct resolve_context *dcerpc_resolve_ctx(struct dcerpc_connection *p) +{ + struct sock_private *sock = (struct sock_private *)p->transport.private_data; + return sock->resolve_ctx; +} diff --git a/source4/librpc/scripts/build_idl.sh b/source4/librpc/scripts/build_idl.sh index 3f13b64a2e..230939bb48 100755 --- a/source4/librpc/scripts/build_idl.sh +++ b/source4/librpc/scripts/build_idl.sh @@ -1,24 +1,23 @@ #!/bin/sh FULLBUILD=$1 -IDLDIR=$2 -OUTDIR=$3 -shift 3 -PIDL_EXTRA_ARGS="$*" +OUTDIR=$2 +shift 2 +IDL_FILES="$*" [ -d $OUTDIR ] || mkdir -p $OUTDIR || exit 1 -PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python $PIDL_EXTRA_ARGS" +PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python --dcom-proxy --com-header --includedir ../librpc/idl -- " if [ x$FULLBUILD = xFULL ]; then echo Rebuilding all idl files in $IDLDIR - $PIDL $IDLDIR/*.idl || exit 1 + $PIDL $IDL_FILES || exit 1 exit 0 fi list="" -for f in $IDLDIR/*.idl ; do +for f in $IDL_FILES ; do basename=`basename $f .idl` ndr="$OUTDIR/ndr_$basename.c" # blergh - most shells don't have the -nt function diff --git a/testprogs/blackbox/ndrdump/samr-CreateUser-in.dat b/source4/librpc/tests/samr-CreateUser-in.dat similarity index 100% rename from testprogs/blackbox/ndrdump/samr-CreateUser-in.dat rename to source4/librpc/tests/samr-CreateUser-in.dat diff --git a/testprogs/blackbox/ndrdump/samr-CreateUser-out.dat b/source4/librpc/tests/samr-CreateUser-out.dat similarity index 100% rename from testprogs/blackbox/ndrdump/samr-CreateUser-out.dat rename to source4/librpc/tests/samr-CreateUser-out.dat diff --git a/testprogs/blackbox/test_ndrdump.sh b/source4/librpc/tests/test_ndrdump.sh similarity index 87% rename from testprogs/blackbox/test_ndrdump.sh rename to source4/librpc/tests/test_ndrdump.sh index 50fd76ba92..511856061c 100755 --- a/testprogs/blackbox/test_ndrdump.sh +++ b/source4/librpc/tests/test_ndrdump.sh @@ -4,13 +4,13 @@ # Copyright (C) 2008 Andrew Bartlett # based on test_smbclient.sh -. `dirname $0`/subunit.sh +. `dirname $0`/../../../testprogs/blackbox/subunit.sh failed=0 -samba4bindir=`dirname $0`/../../source4/bin +samba4bindir=`dirname $0`/../../bin ndrdump=$samba4bindir/ndrdump -files=`dirname $0`/ndrdump +files=`dirname $0`/ testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1` testit "ndrdump with out" $VALGRIND $ndrdump samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1` diff --git a/source4/main.mk b/source4/main.mk index 28db54c10f..8ce86b91ca 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -16,16 +16,18 @@ mkinclude lib/registry/config.mk mkinclude lib/messaging/config.mk mkinclude lib/events/config.mk mkinclude lib/cmdline/config.mk -mkinclude lib/socket_wrapper/config.mk -mkinclude lib/nss_wrapper/config.mk -mkinclude lib/appweb/config.mk +mkinclude ../lib/socket_wrapper/config.mk +mkinclude ../lib/nss_wrapper/config.mk mkinclude lib/stream/config.mk -mkinclude lib/util/config.mk +mkinclude ../lib/util/config.mk mkinclude lib/tdr/config.mk mkinclude lib/dbwrap/config.mk -mkinclude lib/crypto/config.mk +mkinclude ../lib/crypto/config.mk mkinclude lib/torture/config.mk mkinclude lib/basic.mk +mkinclude lib/com/config.mk +# WMI fails at the moment +# mkinclude lib/wmi/config.mk mkinclude param/config.mk mkinclude smb_server/config.mk mkinclude rpc_server/config.mk @@ -44,6 +46,5 @@ mkinclude torture/config.mk mkinclude librpc/config.mk mkinclude client/config.mk mkinclude libcli/config.mk -mkinclude scripting/ejs/config.mk mkinclude scripting/python/config.mk mkinclude kdc/config.mk diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index 1121bfc690..951949a43f 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -70,7 +70,7 @@ $(eval $(call proto_header_template,$(nbt_serversrcdir)/nbt_server_proto.h,$(NBT [MODULE::service_nbtd] INIT_FUNCTION = server_service_nbtd_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = NBT_SERVER process_model service_nbtd_OBJ_FILES = \ diff --git a/source4/nbt_server/defense.c b/source4/nbt_server/defense.c index 2d7a126f5b..fbe22aa781 100644 --- a/source4/nbt_server/defense.c +++ b/source4/nbt_server/defense.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "system/network.h" #include "nbt_server/nbt_server.h" #include "nbt_server/wins/winsserver.h" @@ -38,7 +38,7 @@ void nbtd_request_defense(struct nbt_name_socket *nbtsock, { struct nbtd_iface_name *iname; struct nbt_name *name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); /* diff --git a/source4/nbt_server/dgram/browse.c b/source4/nbt_server/dgram/browse.c index 2e12fa114a..1ebc88fcd4 100644 --- a/source4/nbt_server/dgram/browse.c +++ b/source4/nbt_server/dgram/browse.c @@ -23,6 +23,7 @@ #include "nbt_server/nbt_server.h" #include "lib/socket/socket.h" #include "librpc/gen_ndr/ndr_nbt.h" +#include "nbt_server/dgram/proto.h" static const char *nbt_browse_opcode_string(enum nbt_browse_opcode r) { diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c index 5e95270b7d..a3a7552f6a 100644 --- a/source4/nbt_server/dgram/netlogon.c +++ b/source4/nbt_server/dgram/netlogon.c @@ -26,11 +26,12 @@ #include "lib/ldb/include/ldb.h" #include "dsdb/samdb/samdb.h" #include "auth/auth.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "param/param.h" #include "smbd/service_task.h" #include "cldap_server/cldap_server.h" #include "libcli/security/security.h" +#include "nbt_server/dgram/proto.h" /* reply to a GETDC request @@ -77,7 +78,7 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot, /* setup a GETDC reply */ ZERO_STRUCT(netlogon_response); netlogon_response.response_type = NETLOGON_GET_PDC; - pdc = &netlogon_response.get_pdc; + pdc = &netlogon_response.data.get_pdc; pdc->command = NETLOGON_RESPONSE_FROM_PDC; pdc->pdc_name = lp_netbios_name(iface->nbtsrv->task->lp_ctx); @@ -132,7 +133,7 @@ static void nbtd_netlogon_samlogon(struct dgram_mailslot_handler *dgmslot, status = fill_netlogon_samlogon_response(samctx, packet, NULL, name->name, sid, NULL, netlogon->req.logon.user_name, netlogon->req.logon.acct_control, src->addr, - netlogon->req.logon.nt_version, iface->nbtsrv->task->lp_ctx, &netlogon_response.samlogon); + netlogon->req.logon.nt_version, iface->nbtsrv->task->lp_ctx, &netlogon_response.data.samlogon); if (!NT_STATUS_IS_OK(status)) { DEBUG(2,("NBT netlogon query failed domain=%s sid=%s version=%d - %s\n", name->name, dom_sid_string(packet, sid), netlogon->req.logon.nt_version, nt_errstr(status))); diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c index e59475051b..49406440cf 100644 --- a/source4/nbt_server/interfaces.c +++ b/source4/nbt_server/interfaces.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "nbt_server/nbt_server.h" #include "smbd/service_task.h" #include "lib/socket/socket.h" @@ -38,7 +38,7 @@ static void nbtd_request_handler(struct nbt_name_socket *nbtsock, struct nbt_name_packet *packet, struct socket_address *src) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c index 8f1f74afcf..fc61372ead 100644 --- a/source4/nbt_server/irpc.c +++ b/source4/nbt_server/irpc.c @@ -79,16 +79,17 @@ static void getdc_recv_netlogon_reply(struct dgram_mailslot_handler *dgmslot, /* We asked for version 1 only */ if (netlogon.response_type == NETLOGON_SAMLOGON - && netlogon.samlogon.ntver != NETLOGON_NT_VERSION_1) { + && netlogon.data.samlogon.ntver != NETLOGON_NT_VERSION_1) { status = NT_STATUS_INVALID_NETWORK_RESPONSE; goto done; } - p = netlogon.samlogon.nt4.server; + p = netlogon.data.samlogon.data.nt4.server; DEBUG(10, ("NTLOGON_SAM_LOGON_REPLY: server: %s, user: %s, " - "domain: %s\n", p, netlogon.samlogon.nt4.user_name, - netlogon.samlogon.nt4.domain)); + "domain: %s\n", p, + netlogon.data.samlogon.data.nt4.user_name, + netlogon.data.samlogon.data.nt4.domain)); if (*p == '\\') p += 1; if (*p == '\\') p += 1; diff --git a/source4/nbt_server/nbt_server.h b/source4/nbt_server/nbt_server.h index 688b6a7a7d..00d8f31b2b 100644 --- a/source4/nbt_server/nbt_server.h +++ b/source4/nbt_server/nbt_server.h @@ -19,7 +19,7 @@ along with this program. If not, see . */ -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" #include "libcli/wrepl/winsrepl.h" #include "libcli/dgram/libdgram.h" #include "librpc/gen_ndr/irpc.h" diff --git a/source4/nbt_server/nodestatus.c b/source4/nbt_server/nodestatus.c index a7bf67ad51..8dc1f45053 100644 --- a/source4/nbt_server/nodestatus.c +++ b/source4/nbt_server/nodestatus.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "system/network.h" #include "nbt_server/nbt_server.h" #include "lib/socket/socket.h" @@ -104,7 +104,7 @@ void nbtd_query_status(struct nbt_name_socket *nbtsock, { struct nbt_name *name; struct nbtd_iface_name *iname; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); NBTD_ASSERT_PACKET(packet, src, packet->qdcount == 1); diff --git a/source4/nbt_server/packet.c b/source4/nbt_server/packet.c index 07a309b633..ff4e94fef9 100644 --- a/source4/nbt_server/packet.c +++ b/source4/nbt_server/packet.c @@ -47,7 +47,7 @@ bool nbtd_self_packet_and_bcast(struct nbt_name_socket *nbtsock, struct nbt_name_packet *packet, const struct socket_address *src) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); /* if its not a broadcast then its not considered a self packet */ @@ -74,7 +74,7 @@ bool nbtd_self_packet(struct nbt_name_socket *nbtsock, struct nbt_name_packet *packet, const struct socket_address *src) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; @@ -106,7 +106,7 @@ void nbtd_name_query_reply(struct nbt_name_socket *nbtsock, { struct nbt_name_packet *packet; size_t num_addresses = str_list_length(addresses); - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; int i; @@ -168,7 +168,7 @@ void nbtd_negative_name_query_reply(struct nbt_name_socket *nbtsock, { struct nbt_name_packet *packet; struct nbt_name *name = &request_packet->questions[0].name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; @@ -212,7 +212,7 @@ void nbtd_name_registration_reply(struct nbt_name_socket *nbtsock, { struct nbt_name_packet *packet; struct nbt_name *name = &request_packet->questions[0].name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; @@ -260,7 +260,7 @@ void nbtd_name_release_reply(struct nbt_name_socket *nbtsock, { struct nbt_name_packet *packet; struct nbt_name *name = &request_packet->questions[0].name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; @@ -306,7 +306,7 @@ void nbtd_wack_reply(struct nbt_name_socket *nbtsock, { struct nbt_name_packet *packet; struct nbt_name *name = &request_packet->questions[0].name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct nbtd_server *nbtsrv = iface->nbtsrv; diff --git a/source4/nbt_server/query.c b/source4/nbt_server/query.c index dfd742db5a..be1492f1cd 100644 --- a/source4/nbt_server/query.c +++ b/source4/nbt_server/query.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "system/network.h" #include "nbt_server/nbt_server.h" #include "nbt_server/wins/winsserver.h" @@ -38,7 +38,7 @@ void nbtd_request_query(struct nbt_name_socket *nbtsock, { struct nbtd_iface_name *iname; struct nbt_name *name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); /* see if its a node status query */ diff --git a/source4/nbt_server/register.c b/source4/nbt_server/register.c index a17d503190..1192cba337 100644 --- a/source4/nbt_server/register.c +++ b/source4/nbt_server/register.c @@ -21,7 +21,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "nbt_server/nbt_server.h" #include "smbd/service_task.h" #include "libcli/composite/composite.h" @@ -38,7 +38,7 @@ static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname); */ static void refresh_completion_handler(struct nbt_name_request *req) { - struct nbtd_iface_name *iname = talloc_get_type(req->async.private, + struct nbtd_iface_name *iname = talloc_get_type(req->async.private_data, struct nbtd_iface_name); NTSTATUS status; struct nbt_name_refresh io; @@ -108,7 +108,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t if (req == NULL) return; req->async.fn = refresh_completion_handler; - req->async.private = iname; + req->async.private_data = iname; } diff --git a/source4/nbt_server/wins/wins_dns_proxy.c b/source4/nbt_server/wins/wins_dns_proxy.c index 3322ad55fd..cd605907a8 100644 --- a/source4/nbt_server/wins/wins_dns_proxy.c +++ b/source4/nbt_server/wins/wins_dns_proxy.c @@ -68,7 +68,7 @@ void nbtd_wins_dns_proxy_query(struct nbt_name_socket *nbtsock, struct socket_address *src) { struct nbt_name *name = &packet->questions[0].name; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_dns_proxy_state *s; struct composite_context *creq; diff --git a/source4/nbt_server/wins/winsclient.c b/source4/nbt_server/wins/winsclient.c index 1d07f4a60a..133592f1fd 100644 --- a/source4/nbt_server/wins/winsclient.c +++ b/source4/nbt_server/wins/winsclient.c @@ -140,7 +140,7 @@ static void nbtd_wins_refresh(struct event_context *ev, struct timed_event *te, /* setup a wins name refresh request */ io.in.name = iname->name; - io.in.wins_servers = str_list_make(tmp_ctx, iname->wins_server, NULL); + io.in.wins_servers = (const char **)str_list_make(tmp_ctx, iname->wins_server, NULL); io.in.wins_port = lp_nbt_port(iface->nbtsrv->task->lp_ctx); io.in.addresses = nbtd_address_list(iface, tmp_ctx); io.in.nb_flags = iname->nb_flags; diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index c84b01f2b2..283cd1219a 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -45,10 +45,8 @@ uint64_t winsdb_get_maxVersion(struct winsdb_handle *h) if (!dn) goto failed; /* find the record in the WINS database */ - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, - NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); if (res->count > 1) goto failed; if (res->count == 1) { @@ -82,14 +80,10 @@ uint64_t winsdb_set_maxVersion(struct winsdb_handle *h, uint64_t newMaxVersion) if (!dn) goto failed; /* find the record in the WINS database */ - ret = ldb_search(wins_db, dn, LDB_SCOPE_BASE, NULL, NULL, &res); - + ret = ldb_search(wins_db, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); if (res->count > 1) goto failed; - talloc_steal(tmp_ctx, res); - if (res->count == 1) { oldMaxVersion = ldb_msg_find_attr_as_uint64(res->msgs[0], "maxVersion", 0); } @@ -143,10 +137,8 @@ uint64_t winsdb_get_seqnumber(struct winsdb_handle *h) if (!dn) goto failed; /* find the record in the WINS database */ - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, - NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); if (res->count > 1) goto failed; if (res->count == 1) { @@ -589,10 +581,10 @@ NTSTATUS winsdb_lookup(struct winsdb_handle *h, time_t now = time(NULL); /* find the record in the WINS database */ - ret = ldb_search(wins_db, winsdb_dn(tmp_ctx, wins_db, name), LDB_SCOPE_BASE, - NULL, NULL, &res); + ret = ldb_search(wins_db, tmp_ctx, &res, + winsdb_dn(tmp_ctx, wins_db, name), + LDB_SCOPE_BASE, NULL, NULL); - talloc_steal(tmp_ctx, res); if (ret != LDB_SUCCESS || res->count > 1) { status = NT_STATUS_INTERNAL_DB_CORRUPTION; goto failed; @@ -964,9 +956,8 @@ static bool winsdb_check_or_add_module_list(struct event_context *ev_ctx, if (!dn) goto failed; /* find the record in the WINS database */ - ret = ldb_search(h->ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(h->ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); if (res->count > 0) goto skip; diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c index f8901ce09d..399530b4cf 100644 --- a/source4/nbt_server/wins/winsserver.c +++ b/source4/nbt_server/wins/winsserver.c @@ -68,7 +68,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock, const struct socket_address *src, enum wrepl_name_type type) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; struct nbt_name *name = &packet->questions[0].name; @@ -119,7 +119,7 @@ static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock, struct winsdb_addr *winsdb_addr, const struct socket_address *src) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; uint32_t ttl = wins_server_ttl(winssrv, packet->additional[0].ttl); @@ -158,7 +158,7 @@ static uint8_t wins_sgroup_merge(struct nbt_name_socket *nbtsock, const char *address, const struct socket_address *src) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; uint32_t ttl = wins_server_ttl(winssrv, packet->additional[0].ttl); @@ -357,7 +357,7 @@ static void wins_register_wack(struct nbt_name_socket *nbtsock, struct socket_address *src, enum wrepl_name_type new_type) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; struct wack_state *s; @@ -415,7 +415,7 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock, struct socket_address *src) { NTSTATUS status; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; struct nbt_name *name = &packet->questions[0].name; @@ -671,7 +671,7 @@ static void nbtd_winsserver_query(struct loadparm_context *lp_ctx, struct socket_address *src) { NTSTATUS status; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; struct nbt_name *name = &packet->questions[0].name; @@ -813,7 +813,7 @@ static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock, struct socket_address *src) { NTSTATUS status; - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; struct nbt_name *name = &packet->questions[0].name; @@ -928,7 +928,7 @@ void nbtd_winsserver_request(struct nbt_name_socket *nbtsock, struct nbt_name_packet *packet, struct socket_address *src) { - struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, + struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data, struct nbtd_interface); struct wins_server *winssrv = iface->nbtsrv->winssrv; if ((packet->operation & NBT_FLAG_BROADCAST) || winssrv == NULL) { diff --git a/source4/nbt_server/wins/winswack.c b/source4/nbt_server/wins/winswack.c index 43d2747ae7..7e0c73a810 100644 --- a/source4/nbt_server/wins/winswack.c +++ b/source4/nbt_server/wins/winswack.c @@ -37,7 +37,7 @@ struct wins_challenge_state { static void wins_challenge_handler(struct nbt_name_request *req) { - struct composite_context *ctx = talloc_get_type(req->async.private, struct composite_context); + struct composite_context *ctx = talloc_get_type(req->async.private_data, struct composite_context); struct wins_challenge_state *state = talloc_get_type(ctx->private_data, struct wins_challenge_state); ctx->status = nbt_name_query_recv(req, state, &state->query); @@ -123,7 +123,7 @@ struct composite_context *wins_challenge_send(TALLOC_CTX *mem_ctx, struct wins_c if (req == NULL) goto failed; req->async.fn = wins_challenge_handler; - req->async.private = result; + req->async.private_data = result; return result; failed: @@ -151,7 +151,7 @@ struct wins_release_demand_state { static void wins_release_demand_handler(struct nbt_name_request *req) { - struct composite_context *ctx = talloc_get_type(req->async.private, struct composite_context); + struct composite_context *ctx = talloc_get_type(req->async.private_data, struct composite_context); struct wins_release_demand_state *state = talloc_get_type(ctx->private_data, struct wins_release_demand_state); ctx->status = nbt_name_release_recv(req, state, &state->release); @@ -240,7 +240,7 @@ static struct composite_context *wins_release_demand_send(TALLOC_CTX *mem_ctx, s if (req == NULL) goto failed; req->async.fn = wins_release_demand_handler; - req->async.private = result; + req->async.private_data = result; return result; failed: diff --git a/source4/nsswitch/tests/test_wbinfo.sh b/source4/nsswitch/tests/test_wbinfo.sh index dfd633b656..a67fac9394 100755 --- a/source4/nsswitch/tests/test_wbinfo.sh +++ b/source4/nsswitch/tests/test_wbinfo.sh @@ -62,7 +62,7 @@ admin_sid=`$wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1` echo "$DOMAIN/$USERNAME resolved to $admin_sid" testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=`expr $failed + 1` -admin_name=`wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z` +admin_name=`$wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z` echo "$admin_sid resolved to $admin_name" tested_name=`echo $DOMAIN/$USERNAME | tr a-z A-Z` @@ -100,7 +100,7 @@ else echo "success: wbinfo -U check for sane mapping" fi -admin_uid=`wbinfo -U $admin_sid` +admin_uid=`$wbinfo -U $admin_sid` testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=`expr $failed + 1` @@ -149,7 +149,7 @@ testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`e testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1` echo "test: wbinfo --own-domain against $TARGET check output" -own_domain=`wbinfo --own-domain` +own_domain=`$wbinfo --own-domain` if test x$own_domain = x$DOMAIN; then echo "success: wbinfo --own-domain against $TARGET check output" else diff --git a/source4/nsswitch/winbind_nss_config.h b/source4/nsswitch/winbind_nss_config.h index e0828dc905..ba6153ec28 100644 --- a/source4/nsswitch/winbind_nss_config.h +++ b/source4/nsswitch/winbind_nss_config.h @@ -31,7 +31,7 @@ /* Include header files from data in config.h file */ #ifndef NO_CONFIG_H -#include "lib/replace/replace.h" +#include "../replace/replace.h" #endif #include "system/passwd.h" diff --git a/source4/nsswitch/winbind_nss_netbsd.h b/source4/nsswitch/winbind_nss_netbsd.h new file mode 100644 index 0000000000..dceb57c784 --- /dev/null +++ b/source4/nsswitch/winbind_nss_netbsd.h @@ -0,0 +1,40 @@ +/* + Unix SMB/CIFS implementation. + + NetBSD loadable authentication module, providing identification + routines against Samba winbind/Windows NT Domain + + Copyright (C) Luke Mewburn 2004-2005 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef _WINBIND_NSS_NETBSD_H +#define _WINBIND_NSS_NETBSD_H + +#include + + /* dynamic nsswitch with "new" getpw* nsdispatch API available */ +#if defined(NSS_MODULE_INTERFACE_VERSION) && defined(HAVE_GETPWENT_R) + +typedef int NSS_STATUS; + +#define NSS_STATUS_SUCCESS NS_SUCCESS +#define NSS_STATUS_NOTFOUND NS_NOTFOUND +#define NSS_STATUS_UNAVAIL NS_UNAVAIL +#define NSS_STATUS_TRYAGAIN NS_TRYAGAIN + +#endif /* NSS_MODULE_INTERFACE_VERSION && HAVE_GETPWENT_R */ + +#endif /* _WINBIND_NSS_NETBSD_H */ diff --git a/source4/ntp_signd/config.mk b/source4/ntp_signd/config.mk index 96e0de5583..3b52a200ce 100644 --- a/source4/ntp_signd/config.mk +++ b/source4/ntp_signd/config.mk @@ -4,7 +4,7 @@ # Start SUBSYSTEM NTP_signd [MODULE::NTP_SIGND] INIT_FUNCTION = server_service_ntp_signd_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = \ SAMDB NDR_NTP_SIGND # End SUBSYSTEM NTP_SIGND diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c index 546743e4e6..575be1e97e 100644 --- a/source4/ntp_signd/ntp_signd.c +++ b/source4/ntp_signd/ntp_signd.c @@ -34,7 +34,7 @@ #include "libcli/security/security.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" -#include "lib/crypto/md5.h" +#include "../lib/crypto/md5.h" #include "system/passwd.h" /* @@ -166,7 +166,7 @@ static NTSTATUS ntp_signd_recv(void *private, DATA_BLOB wrapped_input) return signing_failure(ntp_signdconn, sign_request.packet_id); } - ret = ldb_search_exp_fmt(ntp_signdconn->ntp_signd->samdb, tmp_ctx, + ret = ldb_search(ntp_signdconn->ntp_signd->samdb, tmp_ctx, &res, samdb_base_dn(ntp_signdconn->ntp_signd->samdb), LDB_SCOPE_SUBTREE, attrs, "(&(objectSid=%s)(objectClass=user))", dom_sid_string(tmp_ctx, sid)); @@ -349,7 +349,7 @@ static void ntp_signd_task_init(struct task_server *task) /* within the ntp_signd task we want to be a single process, so ask for the single process model ops and pass these to the stream_setup_socket() call. */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(task->event_ctx, "single"); if (!model_ops) { DEBUG(0,("Can't find 'single' process model_ops\n")); return; diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c index 3573fac3ea..1636aa91e7 100644 --- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c +++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c @@ -34,7 +34,7 @@ #include "auth/auth.h" #include "dsdb/samdb/samdb.h" #include "ldb_wrap.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "rpc_server/common/common.h" #include "param/param.h" diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 844fa11cc5..322814ef5d 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -31,7 +31,7 @@ #include "auth/auth.h" #include "auth/credentials/credentials.h" #include "ntvfs/ntvfs.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" #include "libcli/resolve/resolve.h" @@ -206,6 +206,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.service = remote_share; io.in.service_type = "?????"; lp_smbcli_options(ntvfs->ctx->lp_ctx, &io.in.options); + lp_smbcli_session_options(ntvfs->ctx->lp_ctx, &io.in.session_options); if (!(ntvfs->ctx->client_caps & NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS)) { io.in.options.use_level2_oplocks = false; diff --git a/source4/ntvfs/cifs_posix_cli/svfs_util.c b/source4/ntvfs/cifs_posix_cli/svfs_util.c index 42d869209d..e502340229 100644 --- a/source4/ntvfs/cifs_posix_cli/svfs_util.c +++ b/source4/ntvfs/cifs_posix_cli/svfs_util.c @@ -31,6 +31,7 @@ #include "system/time.h" #include "system/dir.h" #include "ntvfs/ntvfs.h" +#include "ntvfs/cifs_posix_cli/proto.h" /* convert a windows path to a unix path - don't do any manging or case sensitive handling diff --git a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c index a61ac16669..34a26b06b4 100644 --- a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c +++ b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c @@ -31,7 +31,7 @@ #include "system/filesys.h" #include "cifsposix.h" #include "system/time.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" #include "ntvfs/cifs_posix_cli/proto.h" diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c index 3b34873152..21670bbea5 100644 --- a/source4/ntvfs/common/brlock.c +++ b/source4/ntvfs/common/brlock.c @@ -26,7 +26,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "messaging/messaging.h" #include "lib/messaging/irpc.h" #include "libcli/libcli.h" diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c index c94b9b446e..ba955038f8 100644 --- a/source4/ntvfs/common/brlock_tdb.c +++ b/source4/ntvfs/common/brlock_tdb.c @@ -26,7 +26,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "messaging/messaging.h" #include "lib/dbwrap/dbwrap.h" #include "lib/messaging/irpc.h" diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c index 9055d6ece3..dbe4722d37 100644 --- a/source4/ntvfs/common/notify.c +++ b/source4/ntvfs/common/notify.c @@ -25,13 +25,13 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" -#include "lib/util/util_tdb.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/util_tdb.h" #include "messaging/messaging.h" #include "tdb_wrap.h" #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_notify.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/common/ntvfs_common.h" #include "ntvfs/sysdep/sys_notify.h" #include "cluster/cluster.h" diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index d7531297ed..83da122fe2 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -40,7 +40,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "messaging/messaging.h" #include "tdb_wrap.h" #include "lib/messaging/irpc.h" diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c index d9fb7e21b2..077ecaf79f 100644 --- a/source4/ntvfs/ipc/rap_server.c +++ b/source4/ntvfs/ipc/rap_server.c @@ -24,6 +24,8 @@ #include "librpc/gen_ndr/srvsvc.h" #include "rpc_server/common/common.h" #include "param/param.h" +#include "ntvfs/ipc/ipc.h" +#include "ntvfs/ipc/proto.h" /* At this moment these are just dummy functions, but you might get the * idea. */ diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 8ac7ac7d03..5a63edcc3e 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -25,7 +25,7 @@ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" #include "libcli/rap/rap.h" #include "ntvfs/ipc/proto.h" diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index 5de8a8b649..0d5738d9f0 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -23,6 +23,7 @@ #include "libcli/raw/interfaces.h" #include "param/share.h" +#include "librpc/gen_ndr/security.h" /* modules can use the following to determine if the interface has changed */ /* version 1 -> 0 - make module stacking easier -- metze */ diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index 1385481bbc..c2501aaba9 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -23,7 +23,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" #include "param/param.h" diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index c34bb7125e..554d5c5aef 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -533,6 +533,8 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, /* we need to check these bits before we check the private mask */ if (io2->generic.in.create_options & SMB2_CREATE_OPTIONS_NOT_SUPPORTED_MASK) { + DEBUG(2,(__location__ " create_options 0x%x not supported\n", + io2->generic.in.create_options)); status = NT_STATUS_NOT_SUPPORTED; break; } diff --git a/source4/ntvfs/ntvfs_util.c b/source4/ntvfs/ntvfs_util.c index fadbe2b80a..1163139255 100644 --- a/source4/ntvfs/ntvfs_util.c +++ b/source4/ntvfs/ntvfs_util.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c index 57a463aba6..d479f1e2ee 100644 --- a/source4/ntvfs/posix/pvfs_acl.c +++ b/source4/ntvfs/posix/pvfs_acl.c @@ -511,6 +511,12 @@ NTSTATUS pvfs_access_check(struct pvfs_state *pvfs, NTSTATUS status; struct security_descriptor *sd; + /* on SMB2 a blank access mask is always denied */ + if (pvfs->ntvfs->ctx->protocol == PROTOCOL_SMB2 && + *access_mask == 0) { + return NT_STATUS_ACCESS_DENIED; + } + if (pvfs_read_only(pvfs, *access_mask)) { return NT_STATUS_ACCESS_DENIED; } diff --git a/source4/ntvfs/posix/pvfs_acl_nfs4.c b/source4/ntvfs/posix/pvfs_acl_nfs4.c index fa855555b2..02ed058af7 100644 --- a/source4/ntvfs/posix/pvfs_acl_nfs4.c +++ b/source4/ntvfs/posix/pvfs_acl_nfs4.c @@ -22,7 +22,7 @@ #include "includes.h" #include "vfs_posix.h" -#include "lib/util/unix_privs.h" +#include "../lib/util/unix_privs.h" #include "librpc/gen_ndr/ndr_nfs4acl.h" #include "libcli/security/security.h" diff --git a/source4/ntvfs/posix/pvfs_acl_xattr.c b/source4/ntvfs/posix/pvfs_acl_xattr.c index 1cf52718c2..87bb6bcb94 100644 --- a/source4/ntvfs/posix/pvfs_acl_xattr.c +++ b/source4/ntvfs/posix/pvfs_acl_xattr.c @@ -21,7 +21,7 @@ #include "includes.h" #include "vfs_posix.h" -#include "lib/util/unix_privs.h" +#include "../lib/util/unix_privs.h" #include "librpc/gen_ndr/ndr_xattr.h" /* diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c index 0054455838..173b2fe187 100644 --- a/source4/ntvfs/posix/pvfs_lock.c +++ b/source4/ntvfs/posix/pvfs_lock.c @@ -22,7 +22,7 @@ #include "includes.h" #include "vfs_posix.h" #include "system/time.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "messaging/messaging.h" diff --git a/source4/ntvfs/posix/pvfs_notify.c b/source4/ntvfs/posix/pvfs_notify.c index 06d2bc8e0c..719b7fa5fc 100644 --- a/source4/ntvfs/posix/pvfs_notify.c +++ b/source4/ntvfs/posix/pvfs_notify.c @@ -23,7 +23,7 @@ #include "vfs_posix.h" #include "lib/messaging/irpc.h" #include "messaging/messaging.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" /* pending notifies buffer, hung off struct pvfs_file for open directories diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index c127885a68..8a32f01223 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -23,7 +23,7 @@ #include "vfs_posix.h" #include "system/dir.h" #include "system/time.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "messaging/messaging.h" #include "librpc/gen_ndr/xattr.h" @@ -1216,6 +1216,8 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs, create_options &= ~create_options_must_ignore_mask; if (create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) { + DEBUG(2,(__location__ " create_options 0x%x not supported\n", + create_options)); return NT_STATUS_NOT_SUPPORTED; } diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c index e0fe4fb64d..b846845731 100644 --- a/source4/ntvfs/posix/pvfs_search.c +++ b/source4/ntvfs/posix/pvfs_search.c @@ -25,7 +25,7 @@ #include "librpc/gen_ndr/security.h" #include "smbd/service_stream.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* place a reasonable limit on old-style searches as clients tend to not send search close requests */ diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 291250befd..c22a0c8792 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -21,7 +21,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "vfs_posix.h" #include "smbd/service_stream.h" #include "lib/messaging/irpc.h" diff --git a/source4/ntvfs/posix/pvfs_xattr.c b/source4/ntvfs/posix/pvfs_xattr.c index 3cbbcbe92f..1ca09402a3 100644 --- a/source4/ntvfs/posix/pvfs_xattr.c +++ b/source4/ntvfs/posix/pvfs_xattr.c @@ -21,7 +21,7 @@ #include "includes.h" #include "vfs_posix.h" -#include "lib/util/unix_privs.h" +#include "../lib/util/unix_privs.h" #include "librpc/gen_ndr/ndr_xattr.h" #include "param/param.h" @@ -50,7 +50,7 @@ static NTSTATUS pull_xattr_blob(struct pvfs_state *pvfs, if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)|| NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)|| NT_STATUS_EQUAL(status, NT_STATUS_INVALID_SYSTEM_SERVICE)) { - DEBUG(5,("pvfs_xattr: xattr not supported in filesystem: %s\n", nt_errstr(status))); + DEBUG(2,("pvfs_xattr: xattr not supported in filesystem: %s\n", nt_errstr(status))); pvfs->flags &= ~PVFS_FLAG_XATTR_ENABLE; status = NT_STATUS_NOT_FOUND; } diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index ce0da7033d..601c876cfb 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -26,9 +26,9 @@ #include "includes.h" #include "vfs_posix.h" #include "librpc/gen_ndr/security.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "tdb_wrap.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "libcli/security/security.h" #include "lib/events/events.h" #include "param/param.h" diff --git a/source4/ntvfs/posix/xattr_system.c b/source4/ntvfs/posix/xattr_system.c index 9a89f2a338..f22c0e9ea4 100644 --- a/source4/ntvfs/posix/xattr_system.c +++ b/source4/ntvfs/posix/xattr_system.c @@ -21,7 +21,7 @@ #include "includes.h" #include "vfs_posix.h" -#include "lib/util/wrap_xattr.h" +#include "../lib/util/wrap_xattr.h" /* pull a xattr as a blob, from either a file or a file descriptor diff --git a/source4/ntvfs/posix/xattr_tdb.c b/source4/ntvfs/posix/xattr_tdb.c index 1113ac1739..aa13fee4c8 100644 --- a/source4/ntvfs/posix/xattr_tdb.c +++ b/source4/ntvfs/posix/xattr_tdb.c @@ -21,7 +21,7 @@ #include "includes.h" #include "vfs_posix.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "tdb_wrap.h" #define XATTR_LIST_ATTR ".xattr_list" diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c index 286c556e30..a0cdbe9c39 100644 --- a/source4/ntvfs/simple/svfs_util.c +++ b/source4/ntvfs/simple/svfs_util.c @@ -28,6 +28,7 @@ #include "system/time.h" #include "system/dir.h" #include "ntvfs/ntvfs.h" +#include "ntvfs/simple/proto.h" /* convert a windows path to a unix path - don't do any manging or case sensitive handling diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index dfc07f3483..5d904b4fcb 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -30,7 +30,7 @@ #include "system/filesys.h" #include "svfs.h" #include "system/time.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" #include "ntvfs/simple/proto.h" diff --git a/source4/ntvfs/smb2/vfs_smb2.c b/source4/ntvfs/smb2/vfs_smb2.c index 68b475a084..2c1461b916 100644 --- a/source4/ntvfs/smb2/vfs_smb2.c +++ b/source4/ntvfs/smb2/vfs_smb2.c @@ -35,7 +35,7 @@ #include "auth/auth.h" #include "auth/credentials/credentials.h" #include "ntvfs/ntvfs.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" #include "libcli/resolve/resolve.h" #include "libcli/smb2/smb2.h" diff --git a/source4/ntvfs/sysdep/inotify.c b/source4/ntvfs/sysdep/inotify.c index 093c15abab..e4e7c44686 100644 --- a/source4/ntvfs/sysdep/inotify.c +++ b/source4/ntvfs/sysdep/inotify.c @@ -25,7 +25,7 @@ #include "system/filesys.h" #include "ntvfs/sysdep/sys_notify.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/raw/smb.h" #include "param/param.h" diff --git a/source4/ntvfs/sysdep/sys_lease.c b/source4/ntvfs/sysdep/sys_lease.c index a0322bbcc1..6e28b46550 100644 --- a/source4/ntvfs/sysdep/sys_lease.c +++ b/source4/ntvfs/sysdep/sys_lease.c @@ -26,7 +26,7 @@ #include "system/filesys.h" #include "ntvfs/sysdep/sys_lease.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" /* list of registered backends */ diff --git a/source4/ntvfs/sysdep/sys_lease_linux.c b/source4/ntvfs/sysdep/sys_lease_linux.c index 0727eed212..41f1cbd710 100644 --- a/source4/ntvfs/sysdep/sys_lease_linux.c +++ b/source4/ntvfs/sysdep/sys_lease_linux.c @@ -27,7 +27,7 @@ #include "ntvfs/sysdep/sys_lease.h" #include "ntvfs/ntvfs.h" #include "librpc/gen_ndr/ndr_opendb.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "cluster/cluster.h" #define LINUX_LEASE_RT_SIGNAL (SIGRTMIN+1) diff --git a/source4/ntvfs/sysdep/sys_notify.c b/source4/ntvfs/sysdep/sys_notify.c index 9770323c3f..d84979e44c 100644 --- a/source4/ntvfs/sysdep/sys_notify.c +++ b/source4/ntvfs/sysdep/sys_notify.c @@ -26,7 +26,7 @@ #include "system/filesys.h" #include "ntvfs/sysdep/sys_notify.h" #include "lib/events/events.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" /* list of registered backends */ diff --git a/source4/param/generic.c b/source4/param/generic.c index b86e3ad234..ed3045605d 100644 --- a/source4/param/generic.c +++ b/source4/param/generic.c @@ -17,7 +17,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" #include "system/filesys.h" @@ -130,7 +130,7 @@ const char **param_get_string_list(struct param_context *ctx, const char *param, if (separator == NULL) separator = LIST_SEP; - return str_list_make(ctx, p->value, separator); + return (const char **)str_list_make(ctx, p->value, separator); } int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section) diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index e63a7aa8a1..e626cdf5dd 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -60,7 +60,7 @@ #include "system/network.h" /* needed for TCP_NODELAY */ #include "smb_server/smb_server.h" #include "libcli/raw/signing.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" #include "param/loadparm.h" #include "libcli/raw/libcliraw.h" @@ -97,8 +97,6 @@ struct loadparm_global char *szWINS_CONFIG_URL; char *szWINS_URL; char *szPrivateDir; - const char **jsInclude; - char *jsonrpcServicesDir; const char **szPasswordServers; char *szSocketOptions; char *szRealm; @@ -469,7 +467,6 @@ static struct parm_struct parm_table[] = { {"lock directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL}, {"modules dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szModulesDir), NULL, NULL}, {"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL}, - {"js include", P_LIST, P_GLOBAL, GLOBAL_VAR(jsInclude), NULL, NULL}, {"setup directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szSetupDir), NULL, NULL}, {"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL}, @@ -702,7 +699,6 @@ _PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_minprotocol, cli_minprotocol) _PUBLIC_ FN_GLOBAL_INTEGER(lp_security, security) _PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security) _PUBLIC_ FN_GLOBAL_INTEGER(lp_announce_as, announce_as) -_PUBLIC_ FN_GLOBAL_LIST(lp_js_include, jsInclude) const char *lp_servicename(const struct loadparm_service *service) { return lp_string((const char *)service->szService); @@ -889,7 +885,7 @@ const char **lp_parm_string_list(TALLOC_CTX *mem_ctx, const char *value = lp_get_parametric(lp_ctx, service, type, option); if (value != NULL) - return str_list_make(mem_ctx, value, separator); + return (const char **)str_list_make(mem_ctx, value, separator); return NULL; } @@ -1303,7 +1299,7 @@ static void copy_service(struct loadparm_service *pserviceDest, strupper(*(char **)dest_ptr); break; case P_LIST: - *(const char ***)dest_ptr = str_list_copy(pserviceDest, + *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest, *(const char ***)src_ptr); break; default: @@ -1657,7 +1653,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr, } case P_LIST: - *(const char ***)parm_ptr = str_list_make(mem_ctx, + *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx, pszParmValue, NULL); break; @@ -2413,7 +2409,6 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) lp_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem"); lp_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem"); lp_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem"); - lp_do_global_parameter_var(lp_ctx, "js include", "%s", dyn_JSDIR); lp_do_global_parameter_var(lp_ctx, "setup directory", "%s", dyn_SETUPDIR); @@ -2634,3 +2629,11 @@ void lp_smbcli_options(struct loadparm_context *lp_ctx, options->use_oplocks = true; options->use_level2_oplocks = true; } + +void lp_smbcli_session_options(struct loadparm_context *lp_ctx, + struct smbcli_session_options *options) +{ + options->lanman_auth = lp_client_lanman_auth(lp_ctx); + options->ntlmv2_auth = lp_client_ntlmv2_auth(lp_ctx); + options->plaintext_auth = lp_client_plaintext_auth(lp_ctx); +} diff --git a/source4/param/param.h b/source4/param/param.h index 4ed2654692..4c6e8b79a2 100644 --- a/source4/param/param.h +++ b/source4/param/param.h @@ -60,6 +60,7 @@ enum announce_as {/* Types of machine we can announce as. */ struct loadparm_context; struct loadparm_service; struct smbcli_options; +struct smbcli_session_options; void reload_charcnv(struct loadparm_context *lp_ctx); @@ -318,6 +319,8 @@ int lp_maxprintjobs(struct loadparm_service *service, struct loadparm_service *s struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx); void lp_smbcli_options(struct loadparm_context *lp_ctx, struct smbcli_options *options); +void lp_smbcli_session_options(struct loadparm_context *lp_ctx, + struct smbcli_session_options *options); /* The following definitions come from param/generic.c */ diff --git a/source4/param/param.py b/source4/param/param.py index 46c75cef97..4117db6f28 100644 --- a/source4/param/param.py +++ b/source4/param/param.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c index 48fd752f0e..eef7a06605 100644 --- a/source4/param/param_wrap.c +++ b/source4/param/param_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2479,7 +2485,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) #define SWIGTYPE_p_int swig_types[2] #define SWIGTYPE_p_loadparm_context swig_types[3] #define SWIGTYPE_p_loadparm_service swig_types[4] -#define SWIGTYPE_p_long swig_types[5] +#define SWIGTYPE_p_long_long swig_types[5] #define SWIGTYPE_p_param_context swig_types[6] #define SWIGTYPE_p_param_opt swig_types[7] #define SWIGTYPE_p_param_section swig_types[8] @@ -2487,7 +2493,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) #define SWIGTYPE_p_signed_char swig_types[10] #define SWIGTYPE_p_unsigned_char swig_types[11] #define SWIGTYPE_p_unsigned_int swig_types[12] -#define SWIGTYPE_p_unsigned_long swig_types[13] +#define SWIGTYPE_p_unsigned_long_long swig_types[13] #define SWIGTYPE_p_unsigned_short swig_types[14] static swig_type_info *swig_types[16]; static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; @@ -2522,7 +2528,7 @@ static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; #define SWIG_name "_param" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2830,13 +2836,13 @@ fail: SWIGINTERN PyObject *_wrap_LoadParm_default_service(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; - struct loadparm_service *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + struct loadparm_service *result = 0 ; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_default_service",kwnames,&obj0)) SWIG_fail; @@ -2859,7 +2865,6 @@ SWIGINTERN PyObject *_wrap_LoadParm_load(PyObject *SWIGUNUSEDPARM(self), PyObjec PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2870,6 +2875,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_load(PyObject *SWIGUNUSEDPARM(self), PyObjec char * kwnames[] = { (char *) "self",(char *) "filename", NULL }; + bool result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_load",kwnames,&obj0,&obj1)) SWIG_fail; @@ -2900,13 +2906,13 @@ fail: SWIGINTERN PyObject *_wrap_LoadParm_load_default(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + bool result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_load_default",kwnames,&obj0)) SWIG_fail; @@ -2928,13 +2934,13 @@ fail: SWIGINTERN PyObject *_wrap_LoadParm___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + int result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm___len__",kwnames,&obj0)) SWIG_fail; @@ -2957,7 +2963,6 @@ SWIGINTERN PyObject *_wrap_LoadParm___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; char *arg2 = (char *) 0 ; - struct loadparm_service *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -2968,6 +2973,7 @@ SWIGINTERN PyObject *_wrap_LoadParm___getitem__(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + struct loadparm_service *result = 0 ; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm___getitem__",kwnames,&obj0,&obj1)) SWIG_fail; @@ -2998,13 +3004,13 @@ fail: SWIGINTERN PyObject *_wrap_LoadParm_configfile(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "self", NULL }; + char *result = 0 ; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_configfile",kwnames,&obj0)) SWIG_fail; @@ -3027,7 +3033,6 @@ SWIGINTERN PyObject *_wrap_LoadParm_is_mydomain(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3038,6 +3043,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_is_mydomain(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "domain", NULL }; + bool result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_is_mydomain",kwnames,&obj0,&obj1)) SWIG_fail; @@ -3069,7 +3075,6 @@ SWIGINTERN PyObject *_wrap_LoadParm_is_myname(PyObject *SWIGUNUSEDPARM(self), Py PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; char *arg2 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3080,6 +3085,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_is_myname(PyObject *SWIGUNUSEDPARM(self), Py char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + bool result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_is_myname",kwnames,&obj0,&obj1)) SWIG_fail; @@ -3111,7 +3117,6 @@ SWIGINTERN PyObject *_wrap_LoadParm_use(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject *resultobj = 0; loadparm_context *arg1 = (loadparm_context *) 0 ; struct param_context *arg2 = (struct param_context *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3121,6 +3126,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_use(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "param_ctx", NULL }; + int result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_use",kwnames,&obj0,&obj1)) SWIG_fail; @@ -3151,7 +3157,6 @@ SWIGINTERN PyObject *_wrap_LoadParm_set(PyObject *SWIGUNUSEDPARM(self), PyObject loadparm_context *arg1 = (loadparm_context *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - bool result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3166,6 +3171,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_set(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "parm_name",(char *) "parm_value", NULL }; + bool result; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -3207,7 +3213,6 @@ SWIGINTERN PyObject *_wrap_LoadParm_get(PyObject *SWIGUNUSEDPARM(self), PyObject loadparm_context *arg1 = (loadparm_context *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; - PyObject *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3222,6 +3227,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_get(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "param_name",(char *) "service_name", NULL }; + PyObject *result = 0 ; arg1 = loadparm_init(NULL); if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_get",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; @@ -3278,7 +3284,6 @@ SWIGINTERN PyObject *_wrap_delete_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObj arg1 = (loadparm_context *)(argp1); } delete_loadparm_context(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3301,7 +3306,6 @@ SWIGINTERN PyObject *_wrap_loadparm_service_volume_label(PyObject *SWIGUNUSEDPAR PyObject *resultobj = 0; loadparm_service *arg1 = (loadparm_service *) 0 ; struct loadparm_service *arg2 = (struct loadparm_service *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3311,6 +3315,7 @@ SWIGINTERN PyObject *_wrap_loadparm_service_volume_label(PyObject *SWIGUNUSEDPAR char * kwnames[] = { (char *) "self",(char *) "sDefault", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_volume_label",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); @@ -3335,7 +3340,6 @@ SWIGINTERN PyObject *_wrap_loadparm_service_printername(PyObject *SWIGUNUSEDPARM PyObject *resultobj = 0; loadparm_service *arg1 = (loadparm_service *) 0 ; struct loadparm_service *arg2 = (struct loadparm_service *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3345,6 +3349,7 @@ SWIGINTERN PyObject *_wrap_loadparm_service_printername(PyObject *SWIGUNUSEDPARM char * kwnames[] = { (char *) "self",(char *) "sDefault", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_printername",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); @@ -3369,7 +3374,6 @@ SWIGINTERN PyObject *_wrap_loadparm_service_maxprintjobs(PyObject *SWIGUNUSEDPAR PyObject *resultobj = 0; loadparm_service *arg1 = (loadparm_service *) 0 ; struct loadparm_service *arg2 = (struct loadparm_service *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3379,6 +3383,7 @@ SWIGINTERN PyObject *_wrap_loadparm_service_maxprintjobs(PyObject *SWIGUNUSEDPAR char * kwnames[] = { (char *) "self",(char *) "sDefault", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_maxprintjobs",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 ); @@ -3425,7 +3430,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_get_section(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; param *arg1 = (param *) 0 ; char *arg2 = (char *) 0 ; - struct param_section *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3436,6 +3440,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_get_section(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + struct param_section *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_get_section",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3462,7 +3467,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_add_section(PyObject *SWIGUNUSEDPARM(self), PyObject *resultobj = 0; param *arg1 = (param *) 0 ; char *arg2 = (char *) 0 ; - struct param_section *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3473,6 +3477,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_add_section(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + struct param_section *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_add_section",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3500,7 +3505,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_get(PyObject *SWIGUNUSEDPARM(self), PyObjec param *arg1 = (param *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) "global" ; - struct param_opt *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3515,6 +3519,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_get(PyObject *SWIGUNUSEDPARM(self), PyObjec char * kwnames[] = { (char *) "self",(char *) "name",(char *) "section_name", NULL }; + struct param_opt *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:ParamFile_get",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3551,7 +3556,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_get_string(PyObject *SWIGUNUSEDPARM(self), param *arg1 = (param *) 0 ; char *arg2 = (char *) 0 ; char *arg3 = (char *) "global" ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3566,6 +3570,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_get_string(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "name",(char *) "section_name", NULL }; + char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:ParamFile_get_string",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3603,7 +3608,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_set_string(PyObject *SWIGUNUSEDPARM(self), char *arg2 = (char *) 0 ; char *arg3 = (char *) 0 ; char *arg4 = (char *) "global" ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3622,6 +3626,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_set_string(PyObject *SWIGUNUSEDPARM(self), char * kwnames[] = { (char *) "self",(char *) "param",(char *) "value",(char *) "section", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:ParamFile_set_string",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3666,7 +3671,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_set(PyObject *SWIGUNUSEDPARM(self), PyObjec char *arg2 = (char *) 0 ; PyObject *arg3 = (PyObject *) 0 ; char *arg4 = (char *) "global" ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3682,6 +3686,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_set(PyObject *SWIGUNUSEDPARM(self), PyObjec char * kwnames[] = { (char *) "self",(char *) "parameter",(char *) "ob",(char *) "section_name", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:ParamFile_set",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3717,10 +3722,10 @@ fail: SWIGINTERN PyObject *_wrap_ParamFile_first_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; param *arg1 = (param *) 0 ; - struct param_section *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + struct param_section *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3741,7 +3746,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_next_section(PyObject *SWIGUNUSEDPARM(self) PyObject *resultobj = 0; param *arg1 = (param *) 0 ; struct param_section *arg2 = (struct param_section *) 0 ; - struct param_section *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -3751,6 +3755,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_next_section(PyObject *SWIGUNUSEDPARM(self) char * kwnames[] = { (char *) "self",(char *) "s", NULL }; + struct param_section *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_next_section",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3775,7 +3780,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_read(PyObject *SWIGUNUSEDPARM(self), PyObje PyObject *resultobj = 0; param *arg1 = (param *) 0 ; char *arg2 = (char *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3786,6 +3790,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_read(PyObject *SWIGUNUSEDPARM(self), PyObje char * kwnames[] = { (char *) "self",(char *) "fn", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_read",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3812,7 +3817,6 @@ SWIGINTERN PyObject *_wrap_ParamFile_write(PyObject *SWIGUNUSEDPARM(self), PyObj PyObject *resultobj = 0; param *arg1 = (param *) 0 ; char *arg2 = (char *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -3823,6 +3827,7 @@ SWIGINTERN PyObject *_wrap_ParamFile_write(PyObject *SWIGUNUSEDPARM(self), PyObj char * kwnames[] = { (char *) "self",(char *) "fn", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_write",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 ); @@ -3860,7 +3865,6 @@ SWIGINTERN PyObject *_wrap_delete_ParamFile(PyObject *SWIGUNUSEDPARM(self), PyOb } arg1 = (param *)(argp1); delete_param(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3882,10 +3886,10 @@ SWIGINTERN PyObject *ParamFile_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject SWIGINTERN PyObject *_wrap_param_opt_key_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; param_opt *arg1 = (param_opt *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3905,10 +3909,10 @@ fail: SWIGINTERN PyObject *_wrap_param_opt_value_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; param_opt *arg1 = (param_opt *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3928,10 +3932,10 @@ fail: SWIGINTERN PyObject *_wrap_param_opt___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; param_opt *arg1 = (param_opt *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3963,7 +3967,6 @@ SWIGINTERN PyObject *_wrap_delete_param_opt(PyObject *SWIGUNUSEDPARM(self), PyOb } arg1 = (param_opt *)(argp1); delete_param_opt(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -3981,10 +3984,10 @@ SWIGINTERN PyObject *param_opt_swigregister(PyObject *SWIGUNUSEDPARM(self), PyOb SWIGINTERN PyObject *_wrap_param_section_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; param_section *arg1 = (param_section *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4005,7 +4008,6 @@ SWIGINTERN PyObject *_wrap_param_section_get(PyObject *SWIGUNUSEDPARM(self), PyO PyObject *resultobj = 0; param_section *arg1 = (param_section *) 0 ; char *arg2 = (char *) 0 ; - struct param_opt *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -4016,6 +4018,7 @@ SWIGINTERN PyObject *_wrap_param_section_get(PyObject *SWIGUNUSEDPARM(self), PyO char * kwnames[] = { (char *) "self",(char *) "name", NULL }; + struct param_opt *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:param_section_get",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_section, 0 | 0 ); @@ -4041,10 +4044,10 @@ fail: SWIGINTERN PyObject *_wrap_param_section_first_parameter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; param_section *arg1 = (param_section *) 0 ; - struct param_opt *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + struct param_opt *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -4065,7 +4068,6 @@ SWIGINTERN PyObject *_wrap_param_section_next_parameter(PyObject *SWIGUNUSEDPARM PyObject *resultobj = 0; param_section *arg1 = (param_section *) 0 ; struct param_opt *arg2 = (struct param_opt *) 0 ; - struct param_opt *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; @@ -4075,6 +4077,7 @@ SWIGINTERN PyObject *_wrap_param_section_next_parameter(PyObject *SWIGUNUSEDPARM char * kwnames[] = { (char *) "self",(char *) "s", NULL }; + struct param_opt *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:param_section_next_parameter",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_section, 0 | 0 ); @@ -4123,7 +4126,6 @@ SWIGINTERN PyObject *_wrap_delete_param_section(PyObject *SWIGUNUSEDPARM(self), } arg1 = (param_section *)(argp1); free((char *) arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -4250,18 +4252,18 @@ static PyMethodDef SwigMethods[] = { static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_int = {"_p_int", "int *|int_least32_t *|int32_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_long = {"_p_long", "intptr_t *|int_least64_t *|int_fast32_t *|int_fast64_t *|int64_t *|long *|int_fast16_t *|intmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uint_least32_t *|uint32_t *|unsigned int *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "uintptr_t *|uint_least64_t *|uint_fast32_t *|uint_fast64_t *|uint64_t *|unsigned long *|uint_fast16_t *|uintmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { @@ -4270,7 +4272,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_int, &_swigt__p_loadparm_context, &_swigt__p_loadparm_service, - &_swigt__p_long, + &_swigt__p_long_long, &_swigt__p_param_context, &_swigt__p_param_opt, &_swigt__p_param_section, @@ -4278,7 +4280,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_signed_char, &_swigt__p_unsigned_char, &_swigt__p_unsigned_int, - &_swigt__p_unsigned_long, + &_swigt__p_unsigned_long_long, &_swigt__p_unsigned_short, }; @@ -4287,7 +4289,7 @@ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}}; @@ -4295,7 +4297,7 @@ static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_long[] = { {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { @@ -4304,7 +4306,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_int, _swigc__p_loadparm_context, _swigc__p_loadparm_service, - _swigc__p_long, + _swigc__p_long_long, _swigc__p_param_context, _swigc__p_param_opt, _swigc__p_param_section, @@ -4312,7 +4314,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_signed_char, _swigc__p_unsigned_char, _swigc__p_unsigned_int, - _swigc__p_unsigned_long, + _swigc__p_unsigned_long_long, _swigc__p_unsigned_short, }; diff --git a/source4/param/secrets.c b/source4/param/secrets.c index 16fbb3b108..576df0a4fe 100644 --- a/source4/param/secrets.c +++ b/source4/param/secrets.c @@ -27,9 +27,9 @@ #include "system/filesys.h" #include "tdb_wrap.h" #include "lib/ldb/include/ldb.h" -#include "lib/tdb/include/tdb.h" -#include "lib/util/util_tdb.h" -#include "lib/util/util_ldb.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/util_tdb.h" +#include "../lib/util/util_ldb.h" #include "librpc/gen_ndr/ndr_security.h" /** diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c index eba1665cc9..29664c7177 100644 --- a/source4/param/share_ldb.c +++ b/source4/param/share_ldb.c @@ -174,8 +174,8 @@ static NTSTATUS sldb_list_all(TALLOC_CTX *mem_ctx, ldb = talloc_get_type(ctx->priv_data, struct ldb_context); - ret = ldb_search(ldb, ldb_dn_new(tmp_ctx, ldb, "CN=SHARES"), LDB_SCOPE_SUBTREE, "(name=*)", NULL, &res); - talloc_steal(tmp_ctx, res); + ret = ldb_search(ldb, tmp_ctx, &res, ldb_dn_new(tmp_ctx, ldb, "CN=SHARES"), + LDB_SCOPE_SUBTREE, NULL, "(name=*)"); if (ret != LDB_SUCCESS) { talloc_free(tmp_ctx); return NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -223,7 +223,7 @@ static NTSTATUS sldb_get_config(TALLOC_CTX *mem_ctx, ldb = talloc_get_type(ctx->priv_data, struct ldb_context); - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, + ret = ldb_search(ldb, tmp_ctx, &res, ldb_dn_new(tmp_ctx, ldb, "CN=SHARES"), LDB_SCOPE_SUBTREE, NULL, "(name=%s)", name); if (ret != LDB_SUCCESS || res->count > 1) { @@ -287,7 +287,7 @@ static NTSTATUS sldb_get_config(TALLOC_CTX *mem_ctx, goto done; \ } } while(0) -NTSTATUS sldb_create(struct share_context *ctx, const char *name, struct share_info *info, int count) +static NTSTATUS sldb_create(struct share_context *ctx, const char *name, struct share_info *info, int count) { struct ldb_context *ldb; struct ldb_message *msg; @@ -426,7 +426,7 @@ done: goto done; \ } } while(0) -NTSTATUS sldb_set(struct share_context *ctx, const char *name, struct share_info *info, int count) +static NTSTATUS sldb_set(struct share_context *ctx, const char *name, struct share_info *info, int count) { struct ldb_context *ldb; struct ldb_message *msg; @@ -535,7 +535,7 @@ done: return ret; } -NTSTATUS sldb_remove(struct share_context *ctx, const char *name) +static NTSTATUS sldb_remove(struct share_context *ctx, const char *name) { struct ldb_context *ldb; struct ldb_dn *dn; diff --git a/source4/rpc_server/common/server_info.c b/source4/rpc_server/common/server_info.c index da034e85ea..ab04b3af1f 100644 --- a/source4/rpc_server/common/server_info.c +++ b/source4/rpc_server/common/server_info.c @@ -26,6 +26,8 @@ #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "param/param.h" +#include "rpc_server/common/common.h" +#include "rpc_server/common/proto.h" /* Here are common server info functions used by some dcerpc server interfaces diff --git a/source4/rpc_server/common/share_info.c b/source4/rpc_server/common/share_info.c index b27dc37949..130babd175 100644 --- a/source4/rpc_server/common/share_info.c +++ b/source4/rpc_server/common/share_info.c @@ -23,6 +23,8 @@ #include "param/share.h" #include "librpc/gen_ndr/srvsvc.h" #include "rpc_server/dcerpc_server.h" +#include "rpc_server/common/common.h" +#include "rpc_server/common/proto.h" /* Here are common server info functions used by some dcerpc server interfaces diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index 6b1813544e..fb697d0c0f 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -206,7 +206,7 @@ PUBLIC_HEADERS += $(rpc_serversrcdir)/dcerpc_server.h [MODULE::DCESRV] INIT_FUNCTION = server_service_rpc_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = dcerpc_server DCESRV_OBJ_FILES = $(rpc_serversrcdir)/service_rpc.o diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index e5f59d0cf9..1d1efa7480 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -24,7 +24,7 @@ #include "librpc/gen_ndr/ndr_dcerpc.h" #include "auth/auth.h" #include "auth/gensec/gensec.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "rpc_server/dcerpc_server.h" #include "rpc_server/dcerpc_server_proto.h" #include "librpc/rpc/dcerpc_proto.h" @@ -870,10 +870,6 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call) call->context = context; call->ndr_pull = pull; - if (call->pkt.pfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) { - pull->flags |= LIBNDR_FLAG_OBJECT_PRESENT; - } - if (!(call->pkt.drep[0] & DCERPC_DREP_LE)) { pull->flags |= LIBNDR_FLAG_BIGENDIAN; } @@ -1112,6 +1108,10 @@ NTSTATUS dcesrv_input_process(struct dcesrv_connection *dce_conn) ndr->flags |= LIBNDR_FLAG_BIGENDIAN; } + if (CVAL(blob.data, DCERPC_PFC_OFFSET) & DCERPC_PFC_FLAG_OBJECT_UUID) { + ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT; + } + ndr_err = ndr_pull_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, &call->pkt); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(dce_conn->partial_input.data); diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h index b5672b41ac..59a4bab083 100644 --- a/source4/rpc_server/dcerpc_server.h +++ b/source4/rpc_server/dcerpc_server.h @@ -23,7 +23,7 @@ #ifndef SAMBA_DCERPC_SERVER_H #define SAMBA_DCERPC_SERVER_H -#include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" #include "librpc/rpc/dcerpc.h" #include "librpc/ndr/libndr.h" diff --git a/source4/rpc_server/dcesrv_auth.c b/source4/rpc_server/dcesrv_auth.c index 16bf4eb7ed..bef7e4be78 100644 --- a/source4/rpc_server/dcesrv_auth.c +++ b/source4/rpc_server/dcesrv_auth.c @@ -95,6 +95,10 @@ bool dcesrv_auth_bind(struct dcesrv_call_state *call) return false; } + if (call->conn->state_flags & DCESRV_CALL_STATE_FLAG_HEADER_SIGNING) { + gensec_want_feature(auth->gensec_security, GENSEC_FEATURE_SIGN_PKT_HEADER); + } + return true; } @@ -287,6 +291,7 @@ bool dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet) struct ndr_pull *ndr; NTSTATUS status; enum ndr_err_code ndr_err; + size_t hdr_size = DCERPC_REQUEST_LENGTH; if (!dce_conn->auth_state.auth_info || !dce_conn->auth_state.gensec_security) { @@ -335,6 +340,11 @@ bool dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet) ndr->flags |= LIBNDR_FLAG_BIGENDIAN; } + if (pkt->pfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) { + ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT; + hdr_size += 16; + } + ndr_err = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, &auth); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(ndr); @@ -346,13 +356,13 @@ bool dcesrv_auth_request(struct dcesrv_call_state *call, DATA_BLOB *full_packet) case DCERPC_AUTH_LEVEL_PRIVACY: status = gensec_unseal_packet(dce_conn->auth_state.gensec_security, call, - full_packet->data + DCERPC_REQUEST_LENGTH, + full_packet->data + hdr_size, pkt->u.request.stub_and_verifier.length, full_packet->data, full_packet->length-auth.credentials.length, &auth.credentials); memcpy(pkt->u.request.stub_and_verifier.data, - full_packet->data + DCERPC_REQUEST_LENGTH, + full_packet->data + hdr_size, pkt->u.request.stub_and_verifier.length); break; diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c index bbb78cb778..6af8ea50b5 100644 --- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c +++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c @@ -69,7 +69,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C server_site_dn = samdb_server_site_dn(b_state->sam_ctx, mem_ctx); W_ERROR_HAVE_NO_MEMORY(server_site_dn); - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &site_res, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &site_res, server_site_dn, LDB_SCOPE_BASE, site_attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { @@ -86,7 +86,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C ntds_dn = samdb_ntds_settings_dn(b_state->sam_ctx); W_ERROR_HAVE_NO_MEMORY(ntds_dn); - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &ntds_res, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &ntds_res, ntds_dn, LDB_SCOPE_BASE, ntds_attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { @@ -330,19 +330,21 @@ static WERROR dcesrv_drsuapi_DsGetNT4ChangeLog(struct dcesrv_call_state *dce_cal /* drsuapi_DsCrackNames */ -WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct drsuapi_DsCrackNames *r) { WERROR status; struct drsuapi_bind_state *b_state; struct dcesrv_handle *h; - r->out.level = r->in.level; - ZERO_STRUCT(r->out.ctr); + *r->out.level_out = r->in.level; DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); b_state = h->data; + r->out.ctr = talloc_zero(mem_ctx, union drsuapi_DsNameCtr); + W_ERROR_HAVE_NO_MEMORY(r->out.ctr); + switch (r->in.level) { case 1: { struct drsuapi_DsNameCtr1 *ctr1; @@ -353,16 +355,16 @@ WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CT ctr1 = talloc(mem_ctx, struct drsuapi_DsNameCtr1); W_ERROR_HAVE_NO_MEMORY(ctr1); - count = r->in.req.req1.count; + count = r->in.req->req1.count; names = talloc_array(mem_ctx, struct drsuapi_DsNameInfo1, count); W_ERROR_HAVE_NO_MEMORY(names); for (i=0; i < count; i++) { status = DsCrackNameOneName(b_state->sam_ctx, mem_ctx, - r->in.req.req1.format_flags, - r->in.req.req1.format_offered, - r->in.req.req1.format_desired, - r->in.req.req1.names[i].str, + r->in.req->req1.format_flags, + r->in.req->req1.format_offered, + r->in.req->req1.format_desired, + r->in.req->req1.names[i].str, &names[i]); if (!W_ERROR_IS_OK(status)) { return status; @@ -371,7 +373,7 @@ WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CT ctr1->count = count; ctr1->array = names; - r->out.ctr.ctr1 = ctr1; + r->out.ctr->ctr1 = ctr1; return WERR_OK; } @@ -389,17 +391,20 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal struct drsuapi_bind_state *b_state; struct dcesrv_handle *h; - r->out.level = r->in.level; + *r->out.level_out = r->in.level; DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); b_state = h->data; + r->out.res = talloc(mem_ctx, union drsuapi_DsWriteAccountSpnResult); + W_ERROR_HAVE_NO_MEMORY(r->out.res); + switch (r->in.level) { case 1: { struct drsuapi_DsWriteAccountSpnRequest1 *req; struct ldb_message *msg; int count, i, ret; - req = &r->in.req.req1; + req = &r->in.req->req1; count = req->count; msg = ldb_msg_new(mem_ctx); @@ -409,7 +414,7 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal msg->dn = ldb_dn_new(msg, b_state->sam_ctx, req->object_dn); if ( ! ldb_dn_validate(msg->dn)) { - r->out.res.res1.status = WERR_OK; + r->out.res->res1.status = WERR_OK; return WERR_OK; } @@ -440,9 +445,9 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal DEBUG(0,("Failed to modify SPNs on %s: %s\n", ldb_dn_get_linearized(msg->dn), ldb_errstring(b_state->sam_ctx))); - r->out.res.res1.status = WERR_ACCESS_DENIED; + r->out.res->res1.status = WERR_ACCESS_DENIED; } else { - r->out.res.res1.status = WERR_OK; + r->out.res->res1.status = WERR_OK; } return WERR_OK; @@ -473,7 +478,7 @@ static WERROR dcesrv_DRSUAPI_REMOVE_DS_DOMAIN(struct dcesrv_call_state *dce_call } /* Obtain the site name from a server DN */ -const char *result_site_name(struct ldb_dn *site_dn) +static const char *result_site_name(struct ldb_dn *site_dn) { /* Format is cn=,cn=Servers,cn=,cn=sites.... */ const struct ldb_val *val = ldb_dn_get_component_val(site_dn, 2); @@ -519,14 +524,16 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta int ret, i; - r->out.level_out = r->in.req.req1.level; + *r->out.level_out = r->in.req->req1.level; + r->out.ctr = talloc(mem_ctx, union drsuapi_DsGetDCInfoCtr); + W_ERROR_HAVE_NO_MEMORY(r->out.ctr); sites_dn = samdb_sites_dn(b_state->sam_ctx, mem_ctx); if (!sites_dn) { return WERR_DS_OBJ_NOT_FOUND; } - switch (r->out.level_out) { + switch (*r->out.level_out) { case -1: /* this level is not like the others */ return WERR_UNKNOWN_LEVEL; @@ -540,7 +547,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta return WERR_UNKNOWN_LEVEL; } - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res, sites_dn, LDB_SCOPE_SUBTREE, attrs, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res, sites_dn, LDB_SCOPE_SUBTREE, attrs, "objectClass=server"); if (ret) { @@ -549,9 +556,9 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta return WERR_GENERAL_FAILURE; } - switch (r->out.level_out) { + switch (*r->out.level_out) { case 1: - ctr1 = &r->out.ctr.ctr1; + ctr1 = &r->out.ctr->ctr1; ctr1->count = res->count; ctr1->array = talloc_zero_array(mem_ctx, struct drsuapi_DsGetDCInfo1, @@ -571,7 +578,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta return WERR_NOMEM; } - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_account, ref_dn, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_account, ref_dn, LDB_SCOPE_BASE, attrs_account_1, "objectClass=computer"); if (ret == LDB_SUCCESS && res_account->count == 1) { const char *errstr; @@ -588,7 +595,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta &domain_dn, &errstr); if (ret == LDB_SUCCESS) { - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn, LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s", ldb_dn_get_linearized(ntds_dn)); if (ret) { @@ -614,7 +621,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta } break; case 2: - ctr2 = &r->out.ctr.ctr2; + ctr2 = &r->out.ctr->ctr2; ctr2->count = res->count; ctr2->array = talloc_zero_array(mem_ctx, struct drsuapi_DsGetDCInfo2, @@ -641,7 +648,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta return WERR_NOMEM; } - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_ntds, ntds_dn, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_ntds, ntds_dn, LDB_SCOPE_BASE, attrs_ntds, "objectClass=nTDSDSA"); if (ret == LDB_SUCCESS && res_ntds->count == 1) { ctr2->array[i].is_gc @@ -655,7 +662,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta ldb_dn_get_linearized(ntds_dn), ldb_errstring(b_state->sam_ctx))); } - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_site, site_dn, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_site, site_dn, LDB_SCOPE_BASE, attrs_site, "objectClass=site"); if (ret == LDB_SUCCESS && res_site->count == 1) { ctr2->array[i].site_guid @@ -667,7 +674,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta ldb_dn_get_linearized(site_dn), ldb_errstring(b_state->sam_ctx))); } - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_account, ref_dn, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_account, ref_dn, LDB_SCOPE_BASE, attrs_account_2, "objectClass=computer"); if (ret == LDB_SUCCESS && res_account->count == 1) { const char *errstr; @@ -685,7 +692,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta &domain_dn, &errstr); if (ret == LDB_SUCCESS) { - ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn, + ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn, LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s", ldb_dn_get_linearized(ntds_dn)); if (ret == LDB_SUCCESS && res_domain->count == 1) { diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 47174b6eeb..284354feb4 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "rpc_server/dcerpc_server.h" /* @@ -29,7 +29,6 @@ static int dcesrv_handle_destructor(struct dcesrv_handle *h) { DLIST_REMOVE(h->context->handles, h); - talloc_free(h); return 0; } diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index a1ca3b4a46..b009d2f2f8 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -1,3 +1,5 @@ +/* need access mask/acl implementation */ + /* Unix SMB/CIFS implementation. @@ -21,13 +23,13 @@ */ #include "rpc_server/lsa/lsa.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "libcli/ldap/ldap_ndr.h" #include "system/kerberos.h" #include "auth/kerberos/kerberos.h" #include "librpc/gen_ndr/ndr_drsblobs.h" #include "librpc/gen_ndr/ndr_lsa.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" /* this type allows us to distinguish handle types @@ -141,7 +143,8 @@ static NTSTATUS dcesrv_lsa_DeleteObject(struct dcesrv_call_state *dce_call, TALL return NT_STATUS_OK; } else if (h->wire_handle.handle_type == LSA_HANDLE_TRUSTED_DOMAIN) { - struct lsa_trusted_domain_state *trusted_domain_state = h->data; + struct lsa_trusted_domain_state *trusted_domain_state = + talloc_get_type(h->data, struct lsa_trusted_domain_state); ret = ldb_transaction_start(trusted_domain_state->policy->sam_ldb); if (ret != 0) { return NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -187,6 +190,9 @@ static NTSTATUS dcesrv_lsa_DeleteObject(struct dcesrv_call_state *dce_call, TALL r2.in.sid = astate->account_sid; r2.out.rights = rights; + /* dcesrv_lsa_EnumAccountRights takes a LSA_HANDLE_POLICY, + but we have a LSA_HANDLE_ACCOUNT here, so this call + will always fail */ status = dcesrv_lsa_EnumAccountRights(dce_call, mem_ctx, &r2); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { return NT_STATUS_OK; @@ -393,7 +399,6 @@ static WERROR dcesrv_dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_cal return WERR_INVALID_PARAM; } - /* fill in the AccountDomain info */ @@ -444,18 +449,52 @@ static NTSTATUS dcesrv_lsa_QueryInfoPolicy2(struct dcesrv_call_state *dce_call, ZERO_STRUCTP(r->out.info); switch (r->in.level) { + case LSA_POLICY_INFO_AUDIT_LOG: + /* we don't need to fill in any of this */ + ZERO_STRUCT(r->out.info->audit_log); + return NT_STATUS_OK; + case LSA_POLICY_INFO_AUDIT_EVENTS: + /* we don't need to fill in any of this */ + ZERO_STRUCT(r->out.info->audit_events); + return NT_STATUS_OK; + case LSA_POLICY_INFO_PD: + /* we don't need to fill in any of this */ + ZERO_STRUCT(r->out.info->pd); + return NT_STATUS_OK; + case LSA_POLICY_INFO_DOMAIN: + return dcesrv_lsa_info_AccountDomain(state, mem_ctx, &r->out.info->domain); case LSA_POLICY_INFO_ACCOUNT_DOMAIN: return dcesrv_lsa_info_AccountDomain(state, mem_ctx, &r->out.info->account_domain); + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: + return dcesrv_lsa_info_AccountDomain(state, mem_ctx, &r->out.info->l_account_domain); + + + case LSA_POLICY_INFO_ROLE: + r->out.info->role.role = LSA_ROLE_PRIMARY; + return NT_STATUS_OK; case LSA_POLICY_INFO_DNS: + case LSA_POLICY_INFO_DNS_INT: return dcesrv_lsa_info_DNS(state, mem_ctx, &r->out.info->dns); - case LSA_POLICY_INFO_DB: + + case LSA_POLICY_INFO_REPLICA: + ZERO_STRUCT(r->out.info->replica); + return NT_STATUS_OK; + + case LSA_POLICY_INFO_QUOTA: + ZERO_STRUCT(r->out.info->quota); + return NT_STATUS_OK; + + case LSA_POLICY_INFO_MOD: case LSA_POLICY_INFO_AUDIT_FULL_SET: case LSA_POLICY_INFO_AUDIT_FULL_QUERY: + /* windows gives INVALID_PARAMETER */ + r->out.info = NULL; return NT_STATUS_INVALID_PARAMETER; } + r->out.info = NULL; return NT_STATUS_INVALID_INFO_CLASS; } @@ -468,6 +507,8 @@ static NTSTATUS dcesrv_lsa_QueryInfoPolicy(struct dcesrv_call_state *dce_call, T struct lsa_QueryInfoPolicy2 r2; NTSTATUS status; + ZERO_STRUCT(r2); + r2.in.handle = r->in.handle; r2.in.level = r->in.level; @@ -484,6 +525,7 @@ static NTSTATUS dcesrv_lsa_QueryInfoPolicy(struct dcesrv_call_state *dce_call, T static NTSTATUS dcesrv_lsa_SetInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct lsa_SetInfoPolicy *r) { + /* need to support this */ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); } @@ -502,6 +544,13 @@ static NTSTATUS dcesrv_lsa_ClearAuditLog(struct dcesrv_call_state *dce_call, TAL lsa_CreateAccount This call does not seem to have any long-term effects, hence no database operations + + we need to talk to the MS product group to find out what this account database means! + + answer is that the lsa database is totally separate from the SAM and + ldap databases. We are going to need a separate ldb to store these + accounts. The SIDs on this account bear no relation to the SIDs in + AD */ static NTSTATUS dcesrv_lsa_CreateAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct lsa_CreateAccount *r) @@ -626,7 +675,7 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc const char *name; DATA_BLOB session_key = data_blob(NULL, 0); DATA_BLOB trustAuthIncoming, trustAuthOutgoing, auth_blob; - struct trustAuthInAndOutBlob auth_struct; + struct trustDomainPasswords auth_struct; int ret; NTSTATUS nt_status; enum ndr_err_code ndr_err; @@ -648,7 +697,7 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc dns_name = r->in.info->domain_name.string; - trusted_domain_state = talloc(mem_ctx, struct lsa_trusted_domain_state); + trusted_domain_state = talloc_zero(mem_ctx, struct lsa_trusted_domain_state); if (!trusted_domain_state) { return NT_STATUS_NO_MEMORY; } @@ -679,16 +728,49 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc ndr_err = ndr_pull_struct_blob(&auth_blob, mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), &auth_struct, - (ndr_pull_flags_fn_t)ndr_pull_trustAuthInAndOutBlob); + (ndr_pull_flags_fn_t)ndr_pull_trustDomainPasswords); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return NT_STATUS_INVALID_PARAMETER; } + + if (op == NDR_LSA_CREATETRUSTEDDOMAINEX) { + if (auth_struct.incoming.count > 1) { + return NT_STATUS_INVALID_PARAMETER; + } + } } if (auth_struct.incoming.count) { + int i; + struct trustAuthInOutBlob incoming; + + incoming.count = auth_struct.incoming.count; + incoming.current = talloc(mem_ctx, struct AuthenticationInformationArray); + if (!incoming.current) { + return NT_STATUS_NO_MEMORY; + } + + incoming.current->array = *auth_struct.incoming.current; + if (!incoming.current->array) { + return NT_STATUS_NO_MEMORY; + } + + incoming.previous = talloc(mem_ctx, struct AuthenticationInformationArray); + if (!incoming.previous) { + return NT_STATUS_NO_MEMORY; + } + incoming.previous->array = talloc_array(mem_ctx, struct AuthenticationInformation, incoming.count); + if (!incoming.previous->array) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < incoming.count; i++) { + incoming.previous->array[i].LastUpdateTime = 0; + incoming.previous->array[i].AuthType = 0; + } ndr_err = ndr_push_struct_blob(&trustAuthIncoming, mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), - &auth_struct.incoming, + &incoming, (ndr_push_flags_fn_t)ndr_push_trustAuthInOutBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return NT_STATUS_INVALID_PARAMETER; @@ -698,9 +780,36 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc } if (auth_struct.outgoing.count) { + int i; + struct trustAuthInOutBlob outgoing; + + outgoing.count = auth_struct.outgoing.count; + outgoing.current = talloc(mem_ctx, struct AuthenticationInformationArray); + if (!outgoing.current) { + return NT_STATUS_NO_MEMORY; + } + + outgoing.current->array = *auth_struct.outgoing.current; + if (!outgoing.current->array) { + return NT_STATUS_NO_MEMORY; + } + + outgoing.previous = talloc(mem_ctx, struct AuthenticationInformationArray); + if (!outgoing.previous) { + return NT_STATUS_NO_MEMORY; + } + outgoing.previous->array = talloc_array(mem_ctx, struct AuthenticationInformation, outgoing.count); + if (!outgoing.previous->array) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < outgoing.count; i++) { + outgoing.previous->array[i].LastUpdateTime = 0; + outgoing.previous->array[i].AuthType = 0; + } ndr_err = ndr_push_struct_blob(&trustAuthOutgoing, mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), - &auth_struct.outgoing, + &outgoing, (ndr_push_flags_fn_t)ndr_push_trustAuthInOutBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return NT_STATUS_INVALID_PARAMETER; @@ -859,24 +968,19 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc if (auth_struct.incoming.count) { int i; for (i=0; i < auth_struct.incoming.count; i++ ) { - if (auth_struct.incoming.current->array[i].AuthType == TRUST_AUTH_TYPE_NT4OWF) { + if (auth_struct.incoming.current[i]->AuthType == TRUST_AUTH_TYPE_NT4OWF) { samdb_msg_add_hash(trusted_domain_state->policy->sam_ldb, mem_ctx, msg_user, "unicodePwd", - &auth_struct.incoming.current->array[i].AuthInfo.nt4owf.password); - } else if (auth_struct.incoming.current->array[i].AuthType == TRUST_AUTH_TYPE_CLEAR) { - struct samr_Password hash; -/* - . We cannot do this, as windows chooses to send in random passwords here, that won't convert to UTF8 - samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, - mem_ctx, msg_user, "userPassword", - auth_struct.incoming.current->array[i].AuthInfo.clear.password); -*/ - mdfour(hash.hash, auth_struct.incoming.current->array[i].AuthInfo.clear.password, - auth_struct.incoming.current->array[i].AuthInfo.clear.size); - samdb_msg_add_hash(trusted_domain_state->policy->sam_ldb, - mem_ctx, msg_user, "unicodePwd", - &hash); - } + &auth_struct.incoming.current[i]->AuthInfo.nt4owf.password); + } else if (auth_struct.incoming.current[i]->AuthType == TRUST_AUTH_TYPE_CLEAR) { + DATA_BLOB new_password = data_blob_const(auth_struct.incoming.current[i]->AuthInfo.clear.password, + auth_struct.incoming.current[i]->AuthInfo.clear.size); + ret = ldb_msg_add_value(msg_user, "clearTextPassword", &new_password, NULL); + if (ret != LDB_SUCCESS) { + ldb_transaction_cancel(policy_state->sam_ldb); + return NT_STATUS_NO_MEMORY; + } + } } } @@ -1004,7 +1108,7 @@ static NTSTATUS dcesrv_lsa_OpenTrustedDomain(struct dcesrv_call_state *dce_call, ZERO_STRUCTP(r->out.trustdom_handle); policy_state = policy_handle->data; - trusted_domain_state = talloc(mem_ctx, struct lsa_trusted_domain_state); + trusted_domain_state = talloc_zero(mem_ctx, struct lsa_trusted_domain_state); if (!trusted_domain_state) { return NT_STATUS_NO_MEMORY; } @@ -1088,7 +1192,7 @@ static NTSTATUS dcesrv_lsa_OpenTrustedDomainByName(struct dcesrv_call_state *dce return NT_STATUS_INVALID_PARAMETER; } - trusted_domain_state = talloc(mem_ctx, struct lsa_trusted_domain_state); + trusted_domain_state = talloc_zero(mem_ctx, struct lsa_trusted_domain_state); if (!trusted_domain_state) { return NT_STATUS_NO_MEMORY; } @@ -1228,7 +1332,7 @@ static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfo(struct dcesrv_call_state *dce_ DCESRV_PULL_HANDLE(h, r->in.trustdom_handle, LSA_HANDLE_TRUSTED_DOMAIN); - trusted_domain_state = h->data; + trusted_domain_state = talloc_get_type(h->data, struct lsa_trusted_domain_state); /* pull all the user attributes */ ret = gendb_search_dn(trusted_domain_state->policy->sam_ldb, mem_ctx, @@ -1951,7 +2055,36 @@ static NTSTATUS dcesrv_lsa_SetQuotasForAccount(struct dcesrv_call_state *dce_cal static NTSTATUS dcesrv_lsa_GetSystemAccessAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct lsa_GetSystemAccessAccount *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + int i; + NTSTATUS status; + struct lsa_EnumPrivsAccount enumPrivs; + + enumPrivs.in.handle = r->in.handle; + + status = dcesrv_lsa_EnumPrivsAccount(dce_call, mem_ctx, &enumPrivs); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + *(r->out.access_mask) = 0x00000000; + + for (i = 0; i < enumPrivs.out.privs->count; i++) { + int priv = enumPrivs.out.privs->set[i].luid.low; + + switch (priv) { + case SEC_PRIV_INTERACTIVE_LOGON: + *(r->out.access_mask) |= LSA_POLICY_MODE_INTERACTIVE; + break; + case SEC_PRIV_NETWORK_LOGON: + *(r->out.access_mask) |= LSA_POLICY_MODE_NETWORK; + break; + case SEC_PRIV_REMOTE_INTERACTIVE_LOGON: + *(r->out.access_mask) |= LSA_POLICY_MODE_REMOTE_INTERACTIVE; + break; + } + } + + return NT_STATUS_OK; } @@ -2786,6 +2919,7 @@ static NTSTATUS dcesrv_lsa_SetInfoPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct lsa_SetInfoPolicy2 *r) { + /* need to support these */ DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); } diff --git a/source4/rpc_server/lsa/lsa.h b/source4/rpc_server/lsa/lsa.h index b7c41486a2..ffdf96d091 100644 --- a/source4/rpc_server/lsa/lsa.h +++ b/source4/rpc_server/lsa/lsa.h @@ -30,7 +30,7 @@ #include "libcli/security/security.h" #include "libcli/auth/libcli_auth.h" #include "param/secrets.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "librpc/gen_ndr/ndr_dssetup.h" #include "param/param.h" diff --git a/source4/rpc_server/lsa/lsa_init.c b/source4/rpc_server/lsa/lsa_init.c index 0dc21fd9c5..8d8417109f 100644 --- a/source4/rpc_server/lsa/lsa_init.c +++ b/source4/rpc_server/lsa/lsa_init.c @@ -71,12 +71,11 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ return NT_STATUS_NO_MEMORY; } - ret = ldb_search(state->sam_ldb, state->domain_dn, LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res); - + ret = ldb_search(state->sam_ldb, mem_ctx, &dom_res, + state->domain_dn, LDB_SCOPE_BASE, dom_attrs, NULL); if (ret != LDB_SUCCESS) { return NT_STATUS_INVALID_SYSTEM_SERVICE; } - talloc_steal(mem_ctx, dom_res); if (dom_res->count != 1) { return NT_STATUS_NO_SUCH_DOMAIN; } @@ -95,7 +94,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ talloc_free(dom_res); - ret = ldb_search_exp_fmt(state->sam_ldb, state, &ref_res, + ret = ldb_search(state->sam_ldb, state, &ref_res, partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs, "(&(objectclass=crossRef)(ncName=%s))", ldb_dn_get_linearized(state->domain_dn)); @@ -125,7 +124,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ talloc_free(ref_res); - ret = ldb_search_exp_fmt(state->sam_ldb, state, &forest_ref_res, + ret = ldb_search(state->sam_ldb, state, &forest_ref_res, partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs, "(&(objectclass=crossRef)(ncName=%s))", ldb_dn_get_linearized(state->forest_dn)); @@ -200,6 +199,12 @@ NTSTATUS dcesrv_lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX * ZERO_STRUCTP(r->out.handle); + if (r->in.attr != NULL && + r->in.attr->root_dir != NULL) { + /* MS-LSAD 3.1.4.4.1 */ + return NT_STATUS_INVALID_PARAMETER; + } + status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state); if (!NT_STATUS_IS_OK(status)) { return status; @@ -212,6 +217,8 @@ NTSTATUS dcesrv_lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX * handle->data = talloc_steal(handle, state); + /* need to check the access mask against - need ACLs - fails + WSPP test */ state->access_mask = r->in.access_mask; state->handle = handle; *r->out.handle = handle->wire_handle; diff --git a/source4/rpc_server/lsa/lsa_lookup.c b/source4/rpc_server/lsa/lsa_lookup.c index 30bceb8139..2375a6d27a 100644 --- a/source4/rpc_server/lsa/lsa_lookup.c +++ b/source4/rpc_server/lsa/lsa_lookup.c @@ -43,6 +43,11 @@ static const struct { .sid = SID_CREATOR_GROUP, .rtype = SID_NAME_WKN_GRP, }, + { + .name = "Owner Rights", + .sid = SID_OWNER_RIGHTS, + .rtype = SID_NAME_WKN_GRP, + }, { .domain = "NT AUTHORITY", .name = "Dialup", @@ -111,7 +116,7 @@ static const struct { }, { .domain = "NT AUTHORITY", - .name = "Termainal Server User", + .name = "Terminal Server User", .sid = SID_NT_TERMINAL_SERVER_USERS, .rtype = SID_NAME_WKN_GRP, }, @@ -145,6 +150,42 @@ static const struct { .sid = SID_NT_NETWORK_SERVICE, .rtype = SID_NAME_WKN_GRP, }, + { + .domain = "NT AUTHORITY", + .name = "Digest Authentication", + .sid = SID_NT_DIGEST_AUTHENTICATION, + .rtype = SID_NAME_WKN_GRP, + }, + { + .domain = "NT AUTHORITY", + .name = "Enterprise Domain Controllers", + .sid = SID_NT_ENTERPRISE_DCS, + .rtype = SID_NAME_WKN_GRP, + }, + { + .domain = "NT AUTHORITY", + .name = "NTLM Authentication", + .sid = SID_NT_NTLM_AUTHENTICATION, + .rtype = SID_NAME_WKN_GRP, + }, + { + .domain = "NT AUTHORITY", + .name = "Other Organization", + .sid = SID_NT_OTHER_ORGANISATION, + .rtype = SID_NAME_WKN_GRP, + }, + { + .domain = "NT AUTHORITY", + .name = "SChannel Authentication", + .sid = SID_NT_SCHANNEL_AUTHENTICATION, + .rtype = SID_NAME_WKN_GRP, + }, + { + .domain = "NT AUTHORITY", + .name = "IUSR", + .sid = SID_NT_IUSR, + .rtype = SID_NAME_WKN_GRP, + }, { .sid = NULL, } @@ -484,8 +525,19 @@ NTSTATUS dcesrv_lsa_LookupSids2(struct dcesrv_call_state *dce_call, int i; NTSTATUS status = NT_STATUS_OK; + if (r->in.level < LSA_LOOKUP_NAMES_ALL || + r->in.level > LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC) { + return NT_STATUS_INVALID_PARAMETER; + } + r->out.domains = NULL; + /* NOTE: the WSPP test suite tries SIDs with invalid revision numbers, + and expects NT_STATUS_INVALID_PARAMETER back - we just treat it as + an unknown SID. We could add a SID validator here. (tridge) + MS-DTYP 2.4.2 + */ + status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state); if (!NT_STATUS_IS_OK(status)) { return status; @@ -542,7 +594,7 @@ NTSTATUS dcesrv_lsa_LookupSids2(struct dcesrv_call_state *dce_call, authority_name, sid, r->out.domains, &sid_index); if (!NT_STATUS_IS_OK(status2)) { - return status2; + continue; } r->out.names->names[i].sid_type = rtype; @@ -579,6 +631,8 @@ NTSTATUS dcesrv_lsa_LookupSids3(struct dcesrv_call_state *dce_call, NTSTATUS status; struct dcesrv_handle *h; + ZERO_STRUCT(r2); + /* No policy handle on the wire, so make one up here */ r2.in.handle = talloc(mem_ctx, struct policy_handle); if (!r2.in.handle) { @@ -608,9 +662,6 @@ NTSTATUS dcesrv_lsa_LookupSids3(struct dcesrv_call_state *dce_call, r2.out.names = r->out.names; status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2); - if (dce_call->fault_code != 0) { - return status; - } r->out.domains = r2.out.domains; r->out.names = r2.out.names; @@ -630,6 +681,8 @@ NTSTATUS dcesrv_lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *m NTSTATUS status; int i; + ZERO_STRUCT(r2); + r2.in.handle = r->in.handle; r2.in.sids = r->in.sids; r2.in.names = NULL; @@ -641,9 +694,8 @@ NTSTATUS dcesrv_lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *m r2.out.names = NULL; status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2); - if (dce_call->fault_code != 0) { - return status; - } + /* we deliberately don't check for error from the above, + as even on error we are supposed to return the names */ r->out.domains = r2.out.domains; if (!r2.out.names) { @@ -685,6 +737,11 @@ NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call, DCESRV_PULL_HANDLE(policy_handle, r->in.handle, LSA_HANDLE_POLICY); + if (r->in.level < LSA_LOOKUP_NAMES_ALL || + r->in.level > LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC) { + return NT_STATUS_INVALID_PARAMETER; + } + policy_state = policy_handle->data; r->out.domains = NULL; @@ -720,7 +777,7 @@ NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call, r->out.sids->sids[i].sid_type = SID_NAME_UNKNOWN; r->out.sids->sids[i].sid = NULL; r->out.sids->sids[i].sid_index = 0xFFFFFFFF; - r->out.sids->sids[i].unknown = 0; + r->out.sids->sids[i].flags = 0; status2 = dcesrv_lsa_lookup_name(dce_call->event_ctx, lp_ctx, policy_state, mem_ctx, name, &authority_name, &sid, &rtype); if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) { @@ -730,13 +787,13 @@ NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call, status2 = dcesrv_lsa_authority_list(policy_state, mem_ctx, rtype, authority_name, sid, r->out.domains, &sid_index); if (!NT_STATUS_IS_OK(status2)) { - return status2; + continue; } r->out.sids->sids[i].sid_type = rtype; r->out.sids->sids[i].sid = sid; r->out.sids->sids[i].sid_index = sid_index; - r->out.sids->sids[i].unknown = 0; + r->out.sids->sids[i].flags = 0; (*r->out.count)++; } @@ -765,6 +822,8 @@ NTSTATUS dcesrv_lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX NTSTATUS status; struct dcesrv_handle *h; + ZERO_STRUCT(r2); + /* No policy handle on the wire, so make one up here */ r2.in.handle = talloc(mem_ctx, struct policy_handle); if (!r2.in.handle) { @@ -786,18 +845,16 @@ NTSTATUS dcesrv_lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX r2.in.num_names = r->in.num_names; r2.in.names = r->in.names; + r2.in.level = r->in.level; r2.in.sids = r->in.sids; r2.in.count = r->in.count; - r2.in.unknown1 = r->in.unknown1; - r2.in.unknown2 = r->in.unknown2; + r2.in.lookup_options = r->in.lookup_options; + r2.in.client_revision = r->in.client_revision; r2.out.domains = r->out.domains; r2.out.sids = r->out.sids; r2.out.count = r->out.count; status = dcesrv_lsa_LookupNames3(dce_call, mem_ctx, &r2); - if (dce_call->fault_code != 0) { - return status; - } r->out.domains = r2.out.domains; r->out.sids = r2.out.sids; @@ -821,6 +878,11 @@ NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call, DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY); + if (r->in.level < LSA_LOOKUP_NAMES_ALL || + r->in.level > LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC) { + return NT_STATUS_INVALID_PARAMETER; + } + state = h->data; r->out.domains = talloc_zero(mem_ctx, struct lsa_RefDomainList); @@ -851,7 +913,10 @@ NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call, r->out.sids->count++; r->out.sids->sids[i].sid_type = SID_NAME_UNKNOWN; - r->out.sids->sids[i].rid = 0xFFFFFFFF; + /* MS-LSAT 3.1.4.7 - rid zero is considered equivalent + to sid NULL - so we should return 0 rid for + unmapped entries */ + r->out.sids->sids[i].rid = 0; r->out.sids->sids[i].sid_index = 0xFFFFFFFF; r->out.sids->sids[i].unknown = 0; @@ -864,7 +929,7 @@ NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call, status2 = dcesrv_lsa_authority_list(state, mem_ctx, rtype, authority_name, sid, r->out.domains, &sid_index); if (!NT_STATUS_IS_OK(status2)) { - return status2; + continue; } r->out.sids->sids[i].sid_type = rtype; @@ -895,18 +960,20 @@ NTSTATUS dcesrv_lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX * NTSTATUS status; int i; + ZERO_STRUCT(r2); + r2.in.handle = r->in.handle; r2.in.num_names = r->in.num_names; r2.in.names = r->in.names; r2.in.sids = NULL; r2.in.level = r->in.level; r2.in.count = r->in.count; - r2.in.unknown1 = 0; - r2.in.unknown2 = 0; + r2.in.lookup_options = 0; + r2.in.client_revision = 0; r2.out.count = r->out.count; status = dcesrv_lsa_LookupNames2(dce_call, mem_ctx, &r2); - if (dce_call->fault_code != 0) { + if (r2.out.sids == NULL) { return status; } diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index 6f4287f9d8..9d4c897892 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -29,13 +29,14 @@ #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" #include "rpc_server/samr/proto.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "libcli/auth/libcli_auth.h" #include "auth/gensec/schannel_state.h" #include "libcli/security/security.h" #include "param/param.h" #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_irpc.h" +#include "librpc/gen_ndr/ndr_netlogon.h" struct server_pipe_state { struct netr_Credential client_challenge; @@ -86,6 +87,9 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca const char *attrs[] = {"unicodePwd", "userAccountControl", "objectSid", NULL}; + const char *trust_dom_attrs[] = {"flatname", NULL}; + const char *account_name; + ZERO_STRUCTP(r->out.credentials); *r->out.rid = 0; *r->out.negotiate_flags = *r->in.negotiate_flags; @@ -100,10 +104,54 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca if (sam_ctx == NULL) { return NT_STATUS_INVALID_SYSTEM_SERVICE; } + + if (r->in.secure_channel_type == SEC_CHAN_DNS_DOMAIN) { + char *encoded_account = ldb_binary_encode_string(mem_ctx, r->in.account_name); + const char *flatname; + if (!encoded_account) { + return NT_STATUS_NO_MEMORY; + } + + /* Kill the trailing dot */ + if (encoded_account[strlen(encoded_account)-1] == '.') { + encoded_account[strlen(encoded_account)-1] = '\0'; + } + + /* pull the user attributes */ + num_records = gendb_search(sam_ctx, mem_ctx, NULL, &msgs, trust_dom_attrs, + "(&(trustPartner=%s)(objectclass=trustedDomain))", + encoded_account); + + if (num_records == 0) { + DEBUG(3,("Couldn't find trust [%s] in samdb.\n", + encoded_account)); + return NT_STATUS_ACCESS_DENIED; + } + + if (num_records > 1) { + DEBUG(0,("Found %d records matching user [%s]\n", num_records, r->in.account_name)); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + flatname = ldb_msg_find_attr_as_string(msgs[0], "flatname", NULL); + if (!flatname) { + /* No flatname for this trust - we can't proceed */ + return NT_STATUS_ACCESS_DENIED; + } + account_name = talloc_asprintf(mem_ctx, "%s$", flatname); + + if (!account_name) { + return NT_STATUS_NO_MEMORY; + } + + } else { + account_name = r->in.account_name; + } + /* pull the user attributes */ num_records = gendb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs, "(&(sAMAccountName=%s)(objectclass=user))", - r->in.account_name); + ldb_binary_encode_string(mem_ctx, account_name)); if (num_records == 0) { DEBUG(3,("Couldn't find user [%s] in samdb.\n", @@ -129,7 +177,8 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca DEBUG(1, ("Client asked for a workstation secure channel, but is not a workstation (member server) acb flags: 0x%x\n", user_account_control)); return NT_STATUS_ACCESS_DENIED; } - } else if (r->in.secure_channel_type == SEC_CHAN_DOMAIN) { + } else if (r->in.secure_channel_type == SEC_CHAN_DOMAIN || + r->in.secure_channel_type == SEC_CHAN_DNS_DOMAIN) { if (!(user_account_control & UF_INTERDOMAIN_TRUST_ACCOUNT)) { DEBUG(1, ("Client asked for a trusted domain secure channel, but is not a trusted domain: acb flags: 0x%x\n", user_account_control)); @@ -321,7 +370,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call creds->sid, NULL, /* Don't have plaintext */ NULL, &r->in.new_password, - false, /* This is not considered a password change */ + true, /* Password change */ NULL, NULL); return nt_status; } @@ -336,16 +385,14 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal struct creds_CredentialState *creds; struct ldb_context *sam_ctx; NTSTATUS nt_status; - char new_pass[512]; - uint32_t new_pass_len; - bool ret; + DATA_BLOB new_password; struct samr_CryptPassword password_buf; nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, mem_ctx, - &r->in.credential, &r->out.return_authenticator, - &creds); + &r->in.credential, &r->out.return_authenticator, + &creds); NT_STATUS_NOT_OK_RETURN(nt_status); sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx)); @@ -354,22 +401,20 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal } memcpy(password_buf.data, r->in.new_password.data, 512); - SIVAL(password_buf.data,512,r->in.new_password.length); + SIVAL(password_buf.data, 512, r->in.new_password.length); creds_arcfour_crypt(creds, password_buf.data, 516); - ret = decode_pw_buffer(password_buf.data, new_pass, sizeof(new_pass), - &new_pass_len, STR_UNICODE); - if (!ret) { - DEBUG(3,("netr_ServerPasswordSet2: failed to decode password buffer\n")); - return NT_STATUS_ACCESS_DENIED; + if (!extract_pw_from_buffer(mem_ctx, password_buf.data, &new_password)) { + DEBUG(3,("samr: failed to decode password buffer\n")); + return NT_STATUS_WRONG_PASSWORD; } - + /* Using the sid for the account as the key, set the password */ nt_status = samdb_set_password_sid(sam_ctx, mem_ctx, creds->sid, - new_pass, /* we have plaintext */ + &new_password, /* we have plaintext */ NULL, NULL, - false, /* This is not considered a password change */ + true, /* Password change */ NULL, NULL); return nt_status; } @@ -899,20 +944,37 @@ static NTSTATUS fill_domain_trust_info(TALLOC_CTX *mem_ctx, struct ldb_message *res, struct ldb_message *ref_res, struct netr_DomainTrustInfo *info, - bool is_local) + bool is_local, bool is_trust_list) { ZERO_STRUCTP(info); + info->trust_extension.info = talloc_zero(mem_ctx, struct netr_trust_extension); + info->trust_extension.length = 16; + info->trust_extension.info->flags = + NETR_TRUST_FLAG_TREEROOT | + NETR_TRUST_FLAG_IN_FOREST | + NETR_TRUST_FLAG_PRIMARY; + info->trust_extension.info->parent_index = 0; /* should be index into array + of parent */ + info->trust_extension.info->trust_type = LSA_TRUST_TYPE_UPLEVEL; /* should be based on ldb search for trusts */ + info->trust_extension.info->trust_attributes = LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE; /* needs to be based on ldb search */ + + if (is_trust_list) { + /* MS-NRPC 3.5.4.3.9 - must be set to NULL for trust list */ + info->forest.string = NULL; + } else { + /* TODO: we need a common function for pulling the forest */ + info->forest.string = samdb_result_string(ref_res, "dnsRoot", NULL); + } + if (is_local) { info->domainname.string = samdb_result_string(ref_res, "nETBIOSName", NULL); info->fulldomainname.string = samdb_result_string(ref_res, "dnsRoot", NULL); - info->forest.string = NULL; info->guid = samdb_result_guid(res, "objectGUID"); info->sid = samdb_result_dom_sid(mem_ctx, res, "objectSid"); } else { info->domainname.string = samdb_result_string(res, "flatName", NULL); info->fulldomainname.string = samdb_result_string(res, "trustPartner", NULL); - info->forest.string = NULL; info->guid = samdb_result_guid(res, "objectGUID"); info->sid = samdb_result_dom_sid(mem_ctx, res, "securityIdentifier"); } @@ -948,6 +1010,9 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal r->in.credential, r->out.return_authenticator, NULL); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,(__location__ " Bad credentials - error\n")); + } NT_STATUS_NOT_OK_RETURN(status); sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); @@ -993,17 +1058,25 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal info1->num_trusts); NT_STATUS_HAVE_NO_MEMORY(info1->trusts); - status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->domaininfo, true); + status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->domaininfo, + true, false); NT_STATUS_NOT_OK_RETURN(status); for (i=0;itrusts[i], false); + status = fill_domain_trust_info(mem_ctx, res2[i], NULL, &info1->trusts[i], + false, true); NT_STATUS_NOT_OK_RETURN(status); } - status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->trusts[i], true); + status = fill_domain_trust_info(mem_ctx, res1[0], ref_res[0], &info1->trusts[i], + true, true); NT_STATUS_NOT_OK_RETURN(status); + info1->dns_hostname.string = samdb_result_string(ref_res[0], "dnsRoot", NULL); + info1->workstation_flags = + NETR_WS_FLAG_HANDLES_INBOUND_TRUSTS | NETR_WS_FLAG_HANDLES_SPN_UPDATE; + info1->supported_enc_types = 0; /* w2008 gives this 0 */ + r->out.info.info1 = info1; return NT_STATUS_OK; diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c index cd32160d88..3cf8fbe8fb 100644 --- a/source4/rpc_server/remote/dcesrv_remote.c +++ b/source4/rpc_server/remote/dcesrv_remote.c @@ -225,7 +225,7 @@ static NTSTATUS remote_register_one_iface(struct dcesrv_context *dce_ctx, const static NTSTATUS remote_op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server) { int i; - const char **ifaces = str_list_make(dce_ctx, lp_parm_string(dce_ctx->lp_ctx, NULL, "dcerpc_remote", "interfaces"),NULL); + const char **ifaces = (const char **)str_list_make(dce_ctx, lp_parm_string(dce_ctx->lp_ctx, NULL, "dcerpc_remote", "interfaces"),NULL); if (!ifaces) { DEBUG(3,("remote_op_init_server: no interfaces configured\n")); diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c index e54d518f76..22d201e58e 100644 --- a/source4/rpc_server/samr/dcesrv_samr.c +++ b/source4/rpc_server/samr/dcesrv_samr.c @@ -34,7 +34,7 @@ #include "libcli/ldap/ldap_ndr.h" #include "libcli/security/security.h" #include "rpc_server/samr/proto.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "param/param.h" /* these query macros make samr_Query[User|Group]Info a bit easier to read */ @@ -341,7 +341,7 @@ static NTSTATUS dcesrv_samr_EnumDomains(struct dcesrv_call_state *dce_call, TALL partitions_basedn = samdb_partitions_dn(c_state->sam_ctx, mem_ctx); - ret = ldb_search_exp_fmt(c_state->sam_ctx, mem_ctx, &dom_res, ldb_get_default_basedn(c_state->sam_ctx), + ret = ldb_search(c_state->sam_ctx, mem_ctx, &dom_res, ldb_get_default_basedn(c_state->sam_ctx), LDB_SCOPE_SUBTREE, dom_attrs, "(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain))"); if (ret != LDB_SUCCESS) { DEBUG(0,("samdb: unable to find domains: %s\n", ldb_errstring(c_state->sam_ctx))); @@ -373,7 +373,7 @@ static NTSTATUS dcesrv_samr_EnumDomains(struct dcesrv_call_state *dce_call, TALL for (i=0;icount-start_i;i++) { array->entries[i].idx = start_i + i; /* try and find the domain */ - ret = ldb_search_exp_fmt(c_state->sam_ctx, mem_ctx, &ref_res, partitions_basedn, + ret = ldb_search(c_state->sam_ctx, mem_ctx, &ref_res, partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs, "(&(objectClass=crossRef)(ncName=%s))", ldb_dn_get_linearized(dom_res->msgs[i]->dn)); @@ -1502,7 +1502,7 @@ static NTSTATUS dcesrv_samr_EnumDomainUsers(struct dcesrv_call_state *dce_call, d_state = h->data; /* don't have to worry about users in the builtin domain, as there are none */ - ret = ldb_search_exp_fmt(d_state->sam_ctx, mem_ctx, &res, d_state->domain_dn, LDB_SCOPE_SUBTREE, attrs, "objectClass=user"); + ret = ldb_search(d_state->sam_ctx, mem_ctx, &res, d_state->domain_dn, LDB_SCOPE_SUBTREE, attrs, "objectClass=user"); if (ret != LDB_SUCCESS) { DEBUG(3, ("Failed to search for Domain Users in %s: %s\n", @@ -2110,7 +2110,7 @@ static NTSTATUS dcesrv_samr_QueryGroupInfo(struct dcesrv_call_state *dce_call, T a_state = h->data; - ret = ldb_search_exp_fmt(a_state->sam_ctx, mem_ctx, &res, a_state->account_dn, LDB_SCOPE_SUBTREE, attrs, "objectClass=*"); + ret = ldb_search(a_state->sam_ctx, mem_ctx, &res, a_state->account_dn, LDB_SCOPE_SUBTREE, attrs, "objectClass=*"); if (ret == LDB_ERR_NO_SUCH_OBJECT) { return NT_STATUS_NO_SUCH_GROUP; @@ -2246,7 +2246,7 @@ static NTSTATUS dcesrv_samr_AddGroupMember(struct dcesrv_call_state *dce_call, T /* In native mode, AD can also nest domain groups. Not sure yet * whether this is also available via RPC. */ - ret = ldb_search_exp_fmt(d_state->sam_ctx, mem_ctx, &res, + ret = ldb_search(d_state->sam_ctx, mem_ctx, &res, d_state->domain_dn, LDB_SCOPE_SUBTREE, attrs, "(&(objectSid=%s)(objectclass=user))", ldap_encode_ndr_dom_sid(mem_ctx, membersid)); @@ -2348,7 +2348,7 @@ static NTSTATUS dcesrv_samr_DeleteGroupMember(struct dcesrv_call_state *dce_call /* In native mode, AD can also nest domain groups. Not sure yet * whether this is also available via RPC. */ - ret = ldb_search_exp_fmt(d_state->sam_ctx, mem_ctx, &res, + ret = ldb_search(d_state->sam_ctx, mem_ctx, &res, d_state->domain_dn, LDB_SCOPE_SUBTREE, attrs, "(&(objectSid=%s)(objectclass=user))", ldap_encode_ndr_dom_sid(mem_ctx, membersid)); @@ -4262,7 +4262,7 @@ static NTSTATUS dcesrv_samr_Connect5(struct dcesrv_call_state *dce_call, TALLOC_ status = dcesrv_samr_Connect(dce_call, mem_ctx, &c); - r->out.info->info1.unknown1 = 3; + r->out.info->info1.client_version = SAMR_CONNECT_AFTER_W2K; r->out.info->info1.unknown2 = 0; r->out.level = r->in.level; diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c index b78a9ceaa7..859fd03801 100644 --- a/source4/rpc_server/samr/samr_password.c +++ b/source4/rpc_server/samr/samr_password.c @@ -25,14 +25,14 @@ #include "rpc_server/common/common.h" #include "rpc_server/samr/dcesrv_samr.h" #include "system/time.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "dsdb/common/flags.h" #include "libcli/ldap/ldap.h" #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "rpc_server/samr/proto.h" #include "libcli/auth/libcli_auth.h" -#include "util/util_ldb.h" +#include "../lib/util/util_ldb.h" #include "param/param.h" /* @@ -86,7 +86,8 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call, } msg = res[0]; - status = samdb_result_passwords(mem_ctx, msg, &lm_pwd, &nt_pwd); + status = samdb_result_passwords(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, + msg, &lm_pwd, &nt_pwd); if (!NT_STATUS_IS_OK(status) || !lm_pwd || !nt_pwd) { ldb_transaction_cancel(sam_ctx); return NT_STATUS_WRONG_PASSWORD; @@ -183,8 +184,8 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, struct samr_OemChangePasswordUser2 *r) { NTSTATUS status; - char new_pass[512]; - uint32_t new_pass_len; + DATA_BLOB new_password, new_unicode_password; + char *new_pass; struct samr_CryptPassword *pwbuf = r->in.password; struct ldb_context *sam_ctx; struct ldb_dn *user_dn; @@ -195,6 +196,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, DATA_BLOB lm_pwd_blob; uint8_t new_lm_hash[16]; struct samr_Password lm_verifier; + ssize_t unicode_pw_len; if (pwbuf == NULL) { return NT_STATUS_INVALID_PARAMETER; @@ -231,7 +233,8 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, user_dn = res[0]->dn; - status = samdb_result_passwords(mem_ctx, res[0], &lm_pwd, NULL); + status = samdb_result_passwords(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, + res[0], &lm_pwd, NULL); if (!NT_STATUS_IS_OK(status) || !lm_pwd) { ldb_transaction_cancel(sam_ctx); return NT_STATUS_WRONG_PASSWORD; @@ -242,18 +245,33 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, arcfour_crypt_blob(pwbuf->data, 516, &lm_pwd_blob); data_blob_free(&lm_pwd_blob); - if (!decode_pw_buffer(pwbuf->data, new_pass, sizeof(new_pass), - &new_pass_len, STR_ASCII)) { + if (!extract_pw_from_buffer(mem_ctx, pwbuf->data, &new_password)) { ldb_transaction_cancel(sam_ctx); DEBUG(3,("samr: failed to decode password buffer\n")); return NT_STATUS_WRONG_PASSWORD; } + + if (convert_string_talloc(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + CH_DOS, CH_UNIX, + (const char *)new_password.data, + new_password.length, + (void **)&new_pass) == -1) { + DEBUG(3,("samr: failed to convert incoming password buffer to unix charset\n")); + ldb_transaction_cancel(sam_ctx); + return NT_STATUS_WRONG_PASSWORD; + } - /* check LM verifier */ - if (lm_pwd == NULL) { + unicode_pw_len = convert_string_talloc(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + CH_DOS, CH_UTF16, + (const char *)new_password.data, + new_password.length, + (void **)&new_unicode_password.data); + if (unicode_pw_len == -1) { + DEBUG(3,("samr: failed to convert incoming password buffer to UTF16 charset\n")); ldb_transaction_cancel(sam_ctx); return NT_STATUS_WRONG_PASSWORD; } + new_unicode_password.length = unicode_pw_len; E_deshash(new_pass, new_lm_hash); E_old_pw_hash(new_lm_hash, lm_pwd->hash, lm_verifier.hash); @@ -278,7 +296,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, * due to password policies */ status = samdb_set_password(sam_ctx, mem_ctx, user_dn, NULL, - mod, new_pass, + mod, &new_unicode_password, NULL, NULL, true, /* this is a user password change */ NULL, @@ -320,8 +338,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, struct samr_ChangePasswordUser3 *r) { NTSTATUS status; - char new_pass[512]; - uint32_t new_pass_len; + DATA_BLOB new_password; struct ldb_context *sam_ctx = NULL; struct ldb_dn *user_dn; int ret; @@ -370,7 +387,8 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, user_dn = res[0]->dn; - status = samdb_result_passwords(mem_ctx, res[0], &lm_pwd, &nt_pwd); + status = samdb_result_passwords(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, + res[0], &lm_pwd, &nt_pwd); if (!NT_STATUS_IS_OK(status) ) { goto failed; } @@ -385,40 +403,49 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, arcfour_crypt_blob(r->in.nt_password->data, 516, &nt_pwd_blob); data_blob_free(&nt_pwd_blob); - if (!decode_pw_buffer(r->in.nt_password->data, new_pass, sizeof(new_pass), - &new_pass_len, STR_UNICODE)) { + if (!extract_pw_from_buffer(mem_ctx, r->in.nt_password->data, &new_password)) { + ldb_transaction_cancel(sam_ctx); DEBUG(3,("samr: failed to decode password buffer\n")); - status = NT_STATUS_WRONG_PASSWORD; - goto failed; + return NT_STATUS_WRONG_PASSWORD; } - + if (r->in.nt_verifier == NULL) { status = NT_STATUS_WRONG_PASSWORD; goto failed; } /* check NT verifier */ - E_md4hash(new_pass, new_nt_hash); + mdfour(new_nt_hash, new_password.data, new_password.length); + E_old_pw_hash(new_nt_hash, nt_pwd->hash, nt_verifier.hash); if (memcmp(nt_verifier.hash, r->in.nt_verifier->hash, 16) != 0) { status = NT_STATUS_WRONG_PASSWORD; goto failed; } - /* check LM verifier */ + /* check LM verifier (really not needed as we just checked the + * much stronger NT hash, but the RPC-SAMR test checks for + * this) */ if (lm_pwd && r->in.lm_verifier != NULL) { - E_deshash(new_pass, new_lm_hash); - E_old_pw_hash(new_nt_hash, lm_pwd->hash, lm_verifier.hash); - if (memcmp(lm_verifier.hash, r->in.lm_verifier->hash, 16) != 0) { - status = NT_STATUS_WRONG_PASSWORD; - goto failed; + char *new_pass; + if (convert_string_talloc(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx), + CH_UTF16, CH_UNIX, + (const char *)new_password.data, + new_password.length, + (void **)&new_pass) != -1) { + E_deshash(new_pass, new_lm_hash); + E_old_pw_hash(new_nt_hash, lm_pwd->hash, lm_verifier.hash); + if (memcmp(lm_verifier.hash, r->in.lm_verifier->hash, 16) != 0) { + status = NT_STATUS_WRONG_PASSWORD; + goto failed; + } } } - mod = ldb_msg_new(mem_ctx); if (mod == NULL) { - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto failed; } mod->dn = ldb_dn_copy(mod, user_dn); @@ -431,7 +458,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, * due to password policies */ status = samdb_set_password(sam_ctx, mem_ctx, user_dn, NULL, - mod, new_pass, + mod, &new_password, NULL, NULL, true, /* this is a user password change */ &reason, @@ -518,8 +545,7 @@ NTSTATUS samr_set_password(struct dcesrv_call_state *dce_call, struct samr_CryptPassword *pwbuf) { NTSTATUS nt_status; - char new_pass[512]; - uint32_t new_pass_len; + DATA_BLOB new_password; DATA_BLOB session_key = data_blob(NULL, 0); nt_status = dcesrv_fetch_session_key(dce_call->conn, &session_key); @@ -529,17 +555,16 @@ NTSTATUS samr_set_password(struct dcesrv_call_state *dce_call, arcfour_crypt_blob(pwbuf->data, 516, &session_key); - if (!decode_pw_buffer(pwbuf->data, new_pass, sizeof(new_pass), - &new_pass_len, STR_UNICODE)) { + if (!extract_pw_from_buffer(mem_ctx, pwbuf->data, &new_password)) { DEBUG(3,("samr: failed to decode password buffer\n")); return NT_STATUS_WRONG_PASSWORD; } - + /* set the password - samdb needs to know both the domain and user DNs, so the domain password policy can be used */ return samdb_set_password(sam_ctx, mem_ctx, account_dn, domain_dn, - msg, new_pass, + msg, &new_password, NULL, NULL, false, /* This is a password set, not change */ NULL, NULL); @@ -559,8 +584,7 @@ NTSTATUS samr_set_password_ex(struct dcesrv_call_state *dce_call, struct samr_CryptPasswordEx *pwbuf) { NTSTATUS nt_status; - char new_pass[512]; - uint32_t new_pass_len; + DATA_BLOB new_password; DATA_BLOB co_session_key; DATA_BLOB session_key = data_blob(NULL, 0); struct MD5Context ctx; @@ -582,17 +606,16 @@ NTSTATUS samr_set_password_ex(struct dcesrv_call_state *dce_call, arcfour_crypt_blob(pwbuf->data, 516, &co_session_key); - if (!decode_pw_buffer(pwbuf->data, new_pass, sizeof(new_pass), - &new_pass_len, STR_UNICODE)) { + if (!extract_pw_from_buffer(mem_ctx, pwbuf->data, &new_password)) { DEBUG(3,("samr: failed to decode password buffer\n")); return NT_STATUS_WRONG_PASSWORD; } - + /* set the password - samdb needs to know both the domain and user DNs, so the domain password policy can be used */ return samdb_set_password(sam_ctx, mem_ctx, account_dn, domain_dn, - msg, new_pass, + msg, &new_password, NULL, NULL, false, /* This is a password set, not change */ NULL, NULL); diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c index b68cec4c7d..f168614ad5 100644 --- a/source4/rpc_server/service_rpc.c +++ b/source4/rpc_server/service_rpc.c @@ -25,7 +25,7 @@ #include "librpc/gen_ndr/ndr_dcerpc.h" #include "auth/auth.h" #include "auth/gensec/gensec.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "rpc_server/dcerpc_server.h" #include "lib/events/events.h" #include "smbd/service_task.h" @@ -436,6 +436,25 @@ static void dcesrv_task_init(struct task_server *task) NTSTATUS status; struct dcesrv_context *dce_ctx; struct dcesrv_endpoint *e; + extern NTSTATUS dcerpc_server_wkssvc_init(void); + extern NTSTATUS dcerpc_server_drsuapi_init(void); + extern NTSTATUS dcerpc_server_winreg_init(void); + extern NTSTATUS dcerpc_server_spoolss_init(void); + extern NTSTATUS dcerpc_server_epmapper_init(void); + extern NTSTATUS dcerpc_server_srvsvc_init(void); + extern NTSTATUS dcerpc_server_netlogon_init(void); + extern NTSTATUS dcerpc_server_rpcecho_init(void); + extern NTSTATUS dcerpc_server_unixinfo_init(void); + extern NTSTATUS dcerpc_server_samr_init(void); + extern NTSTATUS dcerpc_server_remote_init(void); + extern NTSTATUS dcerpc_server_lsa_init(void); + init_module_fn static_init[] = { STATIC_DCESRV_MODULES }; + init_module_fn *shared_init = load_samba_modules(NULL, task->lp_ctx, "dcerpc_server"); + + run_init_functions(static_init); + run_init_functions(shared_init); + + talloc_free(shared_init); task_server_set_title(task, "task[dcesrv]"); @@ -462,25 +481,6 @@ failed: NTSTATUS server_service_rpc_init(void) { - extern NTSTATUS dcerpc_server_wkssvc_init(void); - extern NTSTATUS dcerpc_server_drsuapi_init(void); - extern NTSTATUS dcerpc_server_winreg_init(void); - extern NTSTATUS dcerpc_server_spoolss_init(void); - extern NTSTATUS dcerpc_server_epmapper_init(void); - extern NTSTATUS dcerpc_server_srvsvc_init(void); - extern NTSTATUS dcerpc_server_netlogon_init(void); - extern NTSTATUS dcerpc_server_rpcecho_init(void); - extern NTSTATUS dcerpc_server_unixinfo_init(void); - extern NTSTATUS dcerpc_server_samr_init(void); - extern NTSTATUS dcerpc_server_remote_init(void); - extern NTSTATUS dcerpc_server_lsa_init(void); - init_module_fn static_init[] = { STATIC_DCESRV_MODULES }; - init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server"); - run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); - return register_server_service("rpc", dcesrv_task_init); } diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c index 430982b9f8..db11958026 100644 --- a/source4/rpc_server/winreg/rpc_winreg.c +++ b/source4/rpc_server/winreg/rpc_winreg.c @@ -489,8 +489,8 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, case SECURITY_SYSTEM: case SECURITY_ADMINISTRATOR: case SECURITY_USER: - result = reg_key_get_value_by_name(mem_ctx, key, - r->in.value_name.name, &value_type, &value_data); + result = reg_key_get_value_by_name(mem_ctx, key, + r->in.value_name->name, &value_type, &value_data); if (!W_ERROR_IS_OK(result)) { /* if the lookup wasn't successful, send client query back */ @@ -504,17 +504,16 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, return WERR_NOMEM; } *r->out.type = value_type; - r->out.length = talloc(mem_ctx, uint32_t); - if (!r->out.length) { + r->out.data_length = talloc(mem_ctx, uint32_t); + if (!r->out.data_length) { return WERR_NOMEM; } *r->out.length = value_data.length; - r->out.size = talloc(mem_ctx, uint32_t); - if (!r->out.size) { + r->out.data_size = talloc(mem_ctx, uint32_t); + if (!r->out.data_size) { return WERR_NOMEM; } - *r->out.size = value_data.length; - + *r->out.data_size = value_data.length; r->out.data = value_data.data; return result; diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl deleted file mode 100755 index 5fac94ca6e..0000000000 --- a/source4/script/build_smb_interfaces.pl +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/perl -# -# Create ejs interfaces for structures in a C header file -# - -use File::Basename; -use Data::Dumper; - -# -# Generate parse tree for header file -# - -my $file = shift; -require smb_interfaces; -my $parser = new smb_interfaces; -$header = $parser->parse($file); - -# -# Make second pass over tree to make it easier to process. -# - -sub flatten_structs($) { - my $obj = shift; - my $s = { %$obj }; - - # Map NAME, STRUCT_NAME and UNION_NAME elements into a more likeable - # property. - - if (defined($obj->{STRUCT_NAME}) or defined($obj->{UNION_NAME})) { - - $s->{TYPE_DEFINED} = defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME} - : $obj->{UNION_NAME}; - - delete $s->{STRUCT_NAME}; - delete $s->{UNION_NAME}; - } - - # Create a new list of structure fields with flattened names - - foreach my $elt (@{$obj->{DATA}}) { - foreach my $name (@{$elt->{NAME}}) { - my $new_elt = { %$elt }; - $new_elt->{NAME} = $name; -# $new_elt->{PARENT} = $s; - push(@{$s->{FIELDS}}, flatten_structs($new_elt)); - } - } - - delete $s->{DATA}; - - return $s; -} - -@newheader = map { flatten_structs($_) } @{$header}; - -# -# Generate implementation -# - -my $basename = basename($file, ".h"); -stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir"); - -open(FILE, ">libcli/gen_raw/ejs_${basename}.c"); - -print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl */\n\n"; - -print FILE "#include \"includes.h\"\n"; -print FILE "#include \"scripting/ejs/smbcalls.h\"\n"; -print FILE "#include \"lib/appweb/ejs/ejs.h\"\n"; -print FILE "#include \"scripting/ejs/ejsrpc.h\"\n"; # TODO: remove this -print FILE "\n"; - -sub transfer_element($$$) { - my $dir = shift; - my $prefix = shift; - my $elt = shift; - - $type = $elt->{TYPE}; - $type =~ s/_t$//; - - print FILE "\tNDR_CHECK(ejs_${dir}_$type(ejs, v, \"$prefix.$elt->{NAME}\"));\n"; -} - -sub transfer_struct($$) { - my $dir = shift; - my $struct = shift; - - foreach my $field (@{$struct->{FIELDS}}) { - next if $dir eq "pull" and $field->{NAME} eq "out"; - next if $dir eq "push" and $field->{NAME} eq "in"; - - if ($field->{TYPE} eq "struct") { - foreach $subfield (@{$field->{FIELDS}}) { - transfer_element($dir, $field->{NAME}, $subfield); - } - } else { - transfer_element($dir, $struct->{NAME}, $field); - } - } -} - -# Top level call functions - -foreach my $s (@newheader) { - - if ($s->{TYPE} eq "struct") { - - # Push/pull top level struct - - print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, struct $s->{TYPE_DEFINED} *r)\n"; - print FILE "{\n"; - - transfer_struct("pull", $s); - - print FILE "\n\treturn NT_STATUS_OK;\n"; - print FILE "}\n\n"; - - print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}(struct ejs_rpc *ejs, struct MprVar *v, const struct $s->{TYPE_DEFINED} *r)\n"; - print FILE "{\n"; - - transfer_struct("push", $s); - - print FILE "\n\treturn NT_STATUS_OK;\n"; - print FILE "}\n\n"; - - # Function call - - print FILE "static int ejs_$s->{TYPE_DEFINED}(int eid, int argc, struct MprVar **argv)\n"; - print FILE "{\n"; - print FILE "\treturn ejs_raw_call(eid, argc, argv, (ejs_pull_function_t)ejs_pull_$s->{TYPE_DEFINED}, (ejs_push_function_t)ejs_push_$s->{TYPE_DEFINED});\n"; - print FILE "}\n\n"; - - } else { - - # Top level union - - foreach my $arm (@{$s->{FIELDS}}) { - - # Push/pull union arm - - print FILE "NTSTATUS ejs_pull_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, union $s->{TYPE_DEFINED} *r)\n"; - print FILE "{\n"; - - transfer_struct("pull", $arm); - - print FILE "\n\treturn NT_STATUS_OK;\n"; - print FILE "}\n\n"; - - print FILE "NTSTATUS ejs_push_$s->{TYPE_DEFINED}_$arm->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, const union $s->{TYPE_DEFINED} *r)\n"; - print FILE "{\n"; - - transfer_struct("push", $arm); - - print FILE "\n\treturn NT_STATUS_OK;\n"; - print FILE "}\n\n"; - - } - } -} - -close(FILE); diff --git a/source4/script/find_unused_makefilevars.pl b/source4/script/find_unused_makefilevars.pl index 1bed1228ec..23fc36ef6a 100755 --- a/source4/script/find_unused_makefilevars.pl +++ b/source4/script/find_unused_makefilevars.pl @@ -13,17 +13,26 @@ my %defines; # First, make a list of defines in configure $in = shift; -open(IN, $in); -while() { - my $line = $_; - while($line =~ /^\b([a-zA-Z0-9_][a-zA-Z0-9_]*)\b[ \t]*=.*/sgm) { - $defines{$1} = 1; - } - while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) { - $references{$1} = 1; +sub process_file($) +{ + my ($fn) = @_; + open(IN, $fn); + while() { + my $line = $_; + while($line =~ /^\b([a-zA-Z0-9_][a-zA-Z0-9_]*)\b[ \t]*=.*/sgm) { + $defines{$1} = 1; + } + while($line =~ /\$\(([a-zA-Z0-9_][a-zA-Z0-9_]*)\)/sgm) { + $references{$1} = 1; + } + while ($line =~ /^include (.*)/sgm) { + process_file($1); + } } + close IN; } -close IN; + +process_file($in); print "##### DEFINED BUT UNUSED: #####\n"; foreach(%defines) { diff --git a/source4/script/installlib.sh b/source4/script/installlib.sh index 962c9562b1..cc9ff0b9ea 100755 --- a/source4/script/installlib.sh +++ b/source4/script/installlib.sh @@ -15,7 +15,9 @@ for p in $*; do mv $LIBDIR/$p2 $LIBDIR/$p2.old fi cp $p $LIBDIR/ - ln -sf $p2 $LIBDIR/$lnname + if [ $p2 != $lnname ]; then + ln -sf $p2 $LIBDIR/$lnname + fi done cat << EOF diff --git a/source4/script/installmisc.sh b/source4/script/installmisc.sh index 5f7e11f083..2bd34b119f 100755 --- a/source4/script/installmisc.sh +++ b/source4/script/installmisc.sh @@ -2,16 +2,10 @@ # install miscellaneous files SRCDIR="$1" -JSDIR="$2" -SETUPDIR="$3" -BINDIR="$4" +SETUPDIR="$2" cd $SRCDIR || exit 1 -echo "Installing js libs" -mkdir -p $JSDIR || exit 1 -cp scripting/libjs/*.js $JSDIR || exit 1 - echo "Installing setup templates" mkdir -p $SETUPDIR || exit 1 cp setup/schema-map-* $SETUPDIR || exit 1 @@ -30,9 +24,4 @@ cp setup/provision.smb.conf.dc $SETUPDIR || exit 1 cp setup/provision.smb.conf.member $SETUPDIR || exit 1 cp setup/provision.smb.conf.standalone $SETUPDIR || exit 1 -echo "Installing script tools" -mkdir -p "$BINDIR" -rm -f scripting/bin/*~ -cp scripting/bin/* $BINDIR/ || exit 1 - exit 0 diff --git a/source4/script/installmodules.sh b/source4/script/installmodules.sh deleted file mode 100755 index fb0ad90c14..0000000000 --- a/source4/script/installmodules.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -INSTALLPERMS=$1 -LIBDIR=$2 -shift -shift -shift - -if [ ! -d $LIBDIR ]; then -mkdir $LIBDIR -if [ ! -d $LIBDIR ]; then - echo Failed to make directory $LIBDIR - exit 1 -fi -fi - -for p in $*; do - p2=`basename $p` - echo Installing $p as $LIBDIR/$p2 - cp -f $p $LIBDIR/ - chmod $INSTALLPERMS $LIBDIR/$p2 -done - - -cat << EOF -====================================================================== -The modules are installed. You may uninstall the modules using the -command "make uninstallmodules" or "make uninstall" to uninstall -binaries, man pages, shell scripts and modules. -====================================================================== -EOF - -exit 0 diff --git a/source4/script/installscripts.sh b/source4/script/installscripts.sh deleted file mode 100755 index bff5423e7c..0000000000 --- a/source4/script/installscripts.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# this script courtesy of James_K._Foote.PARC@xerox.com -# 5 July 96 Dan.Shearer@UniSA.Edu.Au Don't hardcode script names, get from Make - -INSTALLPERMS=$1 -BINDIR=$2 - -shift -shift - -echo Installing scripts in $BINDIR - -for d in $BINDIR; do - if [ ! -d $d ]; then - mkdir $d - if [ ! -d $d ]; then - echo Failed to make directory $d - echo Have you run installbin first? - exit 1 - fi - fi -done - -for p in $*; do - p2=`basename $p` - echo Installing $BINDIR/$p2 - if [ -f $BINDIR/$p2 ]; then - rm -f $BINDIR/$p2.old - mv $BINDIR/$p2 $BINDIR/$p2.old - fi - cp $p $BINDIR/ - chmod $INSTALLPERMS $BINDIR/$p2 - if [ ! -f $BINDIR/$p2 ]; then - echo Cannot copy $p2... does $USER have privileges? - fi -done - -cat << EOF -====================================================================== -The scripts have been installed. You may uninstall them using -the command "make uninstallscripts" or "make install" to install binaries, -man pages and shell scripts. You may recover the previous version (if any -by "make revert". -====================================================================== -EOF - -exit 0 diff --git a/source4/script/mkrelease.sh b/source4/script/mkrelease.sh index 0af738deb5..6a8c5ae2e7 100755 --- a/source4/script/mkrelease.sh +++ b/source4/script/mkrelease.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ ! -d ".git" -o `dirname $0` != "./source/script" ]; then +if [ ! -d ".git" -o `dirname $0` != "./source4/script" ]; then echo "Run this script from the top-level directory in the" echo "repository as: ./source/script/mkrelease.sh" exit 1 @@ -9,13 +9,23 @@ fi TMPDIR=`mktemp -d samba-XXXXX` (git archive --format=tar HEAD | (cd $TMPDIR/ && tar xf -)) -( cd $TMPDIR/source || exit 1 +#Prepare the tarball for a Samba4 release, with some generated files, +#but without Samba3 stuff (to avoid confusion) +( cd $TMPDIR/ || exit 1 + rm -rf source3 packaging docs-xml examples swat WHATSNEW.txt MAINTAINERS || exit 1 + cd source4 || exit 1 ./autogen.sh || exit 1 ./configure || exit 1 make dist || exit 1 ) || exit 1 -VERSION=`sed -n 's/^SAMBA_VERSION_STRING=//p' $TMPDIR/source/version.h` +VERSION_FILE=$TMPDIR/source4/version.h +if [ ! -f $VERSION_FILE ]; then + echo "Cannot find version.h at $VERSION_FILE" + exit 1; +fi + +VERSION=`sed -n 's/^SAMBA_VERSION_STRING=//p' $VERSION_FILE` mv $TMPDIR samba-$VERSION || exit 1 tar -cf samba-$VERSION.tar samba-$VERSION || (rm -rf samba-$VERSION; exit 1) rm -rf samba-$VERSION || exit 1 diff --git a/source4/script/uninstallheader.sh b/source4/script/uninstallheader.sh deleted file mode 100755 index cb491f071a..0000000000 --- a/source4/script/uninstallheader.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# based on uninstallbin.sh: -# 4 July 96 Dan.Shearer@UniSA.edu.au - -INCLUDEDIR=$1 -shift - -if [ ! -d $INCLUDEDIR ]; then - echo Directory $INCLUDEDIR does not exist! - echo Do a "make installbin" or "make install" first. - exit 1 -fi - -for p in $*; do - p2=`basename $p` - if [ -f $INCLUDEDIR/$p2 ]; then - echo Removing $INCLUDEDIR/$p2 - rm -f $INCLUDEDIR/$p2 - if [ -f $INCLUDEDIR/$p2 ]; then - echo Cannot remove $INCLUDEDIR/$p2 ... does $USER have privileges? - fi - fi -done - - -cat << EOF -====================================================================== -The headers have been uninstalled. You may restore the headers using -the command "make installheader" or "make install" to install binaries, -man pages, modules and shell scripts. You can restore a previous -version of the headers (if there were any) using "make revert". -====================================================================== -EOF - -exit 0 diff --git a/source4/script/uninstallmodules.sh b/source4/script/uninstallmodules.sh deleted file mode 100755 index 30582a39fa..0000000000 --- a/source4/script/uninstallmodules.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -#4 July 96 Dan.Shearer@UniSA.edu.au - -INSTALLPERMS=$1 -BASEDIR=$2 -LIBDIR=$3 -shift -shift -shift - -if [ ! -d $LIBDIR ]; then - echo Directory $LIBDIR does not exist! - echo Do a "make installmodules" or "make install" first. - exit 1 -fi - -for p in $*; do - p2=`basename $p` - if [ -f $LIBDIR/$p2 ]; then - echo Removing $LIBDIR/$p2 - rm -f $LIBDIR/$p2 - if [ -f $LIBDIR/$p2 ]; then - echo Cannot remove $LIBDIR/$p2 ... does $USER have privileges? - fi - fi -done - - -cat << EOF -====================================================================== -The modules have been uninstalled. You may restore the modules using -the command "make installmodules" or "make install" to install -binaries, modules, man pages and shell scripts. -====================================================================== -EOF - -exit 0 diff --git a/source4/script/uninstallscripts.sh b/source4/script/uninstallscripts.sh deleted file mode 100755 index 13104acedd..0000000000 --- a/source4/script/uninstallscripts.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# 5 July 96 Dan.Shearer@UniSA.Edu.Au - almost identical to uninstallbin.sh - -INSTALLPERMS=$1 -BINDIR=$2 - -shift -shift - -if [ ! -d $BINDIR ]; then - echo Directory $BINDIR does not exist! - echo Do a "make installscripts" or "make install" first. - exit 1 -fi - -for p in $*; do - p2=`basename $p` - if [ -f $BINDIR/$p2 ]; then - echo Removing $BINDIR/$p2 - rm -f $BINDIR/$p2 - if [ -f $BINDIR/$p2 ]; then - echo Cannot remove $BINDIR/$p2 ... does $USER have privileges? - fi - fi -done - -cat << EOF -====================================================================== -The scripts have been uninstalled. You may reinstall them using -the command "make installscripts" or "make install" to install binaries, -man pages and shell scripts. You may recover a previous version (if any -with "make revert". -====================================================================== -EOF - -exit 0 diff --git a/source4/scripting/bin/autoidl.py b/source4/scripting/bin/autoidl similarity index 100% rename from source4/scripting/bin/autoidl.py rename to source4/scripting/bin/autoidl diff --git a/source4/scripting/bin/epdump.py b/source4/scripting/bin/epdump old mode 100644 new mode 100755 similarity index 100% rename from source4/scripting/bin/epdump.py rename to source4/scripting/bin/epdump diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema similarity index 94% rename from source4/scripting/bin/minschema.py rename to source4/scripting/bin/minschema index 111557126d..e7d7ed4979 100755 --- a/source4/scripting/bin/minschema.py +++ b/source4/scripting/bin/minschema @@ -11,7 +11,8 @@ import os, sys sys.path.insert(0, "bin/python") import samba -from samba import getopt as options +from samba import getopt as options, Ldb +from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError import sys parser = optparse.OptionParser("minschema ") @@ -50,7 +51,9 @@ if len(args) != 2: (url, classfile) = args -creds = credopts.get_credentials() +lp_ctx = sambaopts.get_loadparm() + +creds = credopts.get_credentials(lp_ctx) ldb = Ldb(url, credentials=creds) objectclasses = [] @@ -131,17 +134,10 @@ attrib_attrs = ["objectClass", # 2: abstract # 3: auxiliary -# -# print only if verbose is set -# -def dprintf(text): - if verbose is not None: - print text - def get_object_cn(ldb, name): attrs = ["cn"] - res = ldb.search("(ldapDisplayName=%s)" % name, rootDse["schemaNamingContext"], ldb.SCOPE_SUBTREE, attrs) + res = ldb.search("(ldapDisplayName=%s)" % name, rootDse["schemaNamingContext"], SCOPE_SUBTREE, attrs) assert len(res) == 1 return res[0]["cn"] @@ -229,7 +225,7 @@ def find_objectclass_properties(ldb, o): """the properties of an objectclass""" res = ldb.search( expression="(ldapDisplayName=%s)" % o.name, - basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE, attrs=class_attrs) + base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE, attrs=class_attrs) assert(len(res) == 1) msg = res[0] for a in msg: @@ -239,7 +235,7 @@ def find_attribute_properties(ldb, o): """find the properties of an attribute""" res = ldb.search( expression="(ldapDisplayName=%s)" % o.name, - basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE, + base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE, attrs=attrib_attrs) assert(len(res) == 1) msg = res[0] @@ -269,7 +265,7 @@ def find_objectclass_auto(ldb, o): print "%s\n" % ldif return - res = ldb.search("", testdn, ldb.SCOPE_BASE) + res = ldb.search(base=testdn, scope=ldb.SCOPE_BASE) ldb.delete(testdn) for a in res.msgs[0]: @@ -284,7 +280,7 @@ def expand_objectclass(ldb, o): "subClassOf"] res = ldb.search( expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % o.name, - basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE, + base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE, attrs=attrs) print "Expanding class %s\n" % o.name assert(len(res) == 1) @@ -322,13 +318,13 @@ def walk_dn(ldb, dn): # get a list of all possible attributes for this object attrs = ["allowedAttributes"] try: - res = ldb.search("objectClass=*", dn, ldb.SCOPE_BASE, attrs) + res = ldb.search("objectClass=*", dn, SCOPE_BASE, attrs) except LdbError, e: print "Unable to fetch allowedAttributes for '%s' - %r\n" % (dn, e) return allattrs = res[0]["allowedAttributes"] try: - res = ldb.search("objectClass=*", dn, ldb.SCOPE_BASE, allattrs) + res = ldb.search("objectClass=*", dn, SCOPE_BASE, allattrs) except LdbError, e: print "Unable to fetch all attributes for '%s' - %s\n" % (dn, e) return @@ -340,7 +336,7 @@ def walk_dn(ldb, dn): def walk_naming_context(ldb, namingContext): """walk a naming context, looking for all records""" try: - res = ldb.search("objectClass=*", namingContext, ldb.SCOPE_DEFAULT, + res = ldb.search("objectClass=*", namingContext, SCOPE_DEFAULT, ["objectClass"]) except LdbError, e: print "Unable to fetch objectClasses for '%s' - %s\n" % (namingContext, e) @@ -398,7 +394,7 @@ def build_objectclass(ldb, name): try: res = ldb.search( expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % name, - basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE, + base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE, attrs=attrs) except LdbError, e: print "unknown class '%s'\n" % name @@ -503,10 +499,10 @@ objectCategory: CN=SubSchema,${SCHEMADN} def load_list(file): """load a list from a file""" - return open(file, 'r').splitlines() + return open(file, 'r').readlines() # get the rootDSE -res = ldb.search("", "", ldb.SCOPE_BASE) +res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["schemaNamingContext"]) rootDse = res[0] # load the list of classes we are interested in diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus index bbd0e84826..a9265ead6a 100755 --- a/source4/scripting/bin/smbstatus +++ b/source4/scripting/bin/smbstatus @@ -22,7 +22,7 @@ def show_sessions(conn): sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next() print "User Client Connected at" - print "-------------------------------------------------------------------------------" + print "-" * 79 for session in sessions: fulluser = "%s/%s" % (session.account_name, session.domain_name) print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time)) @@ -33,7 +33,7 @@ def show_tcons(open_connection): conn = open_connection("smb_server") tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next() print "Share Client Connected at" - print "-------------------------------------------------------------------------------" + print "-" * 79 for tcon in tcons: print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time)) @@ -76,7 +76,7 @@ else: try: conn = open_connection("smb_server") except RuntimeError, (num, msg): - if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND': + if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND': print "No active connections" else: show_sessions(conn) diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index 6f1086ad37..e7737bdbec 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -21,6 +21,7 @@ import sys # Find right directory when running from source tree sys.path.insert(0, "bin/python") +sys.path.insert(1, "../lib/subunit/python") from subunit import SubunitTestRunner from unittest import TestProgram diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk deleted file mode 100644 index 34c0a9678e..0000000000 --- a/source4/scripting/ejs/config.mk +++ /dev/null @@ -1,63 +0,0 @@ -[MODULE::smbcalls_config] -OUTPUT_TYPE = MERGED_OBJ -SUBSYSTEM = smbcalls -INIT_FUNCTION = smb_setup_ejs_config - -smbcalls_config_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_config.o - -[MODULE::smbcalls_ldb] -OUTPUT_TYPE = MERGED_OBJ -SUBSYSTEM = smbcalls -INIT_FUNCTION = smb_setup_ejs_ldb -PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR - -smbcalls_ldb_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_ldb.o - -[MODULE::smbcalls_auth] -OUTPUT_TYPE = MERGED_OBJ -SUBSYSTEM = smbcalls -INIT_FUNCTION = smb_setup_ejs_auth -PRIVATE_DEPENDENCIES = service_auth - -smbcalls_auth_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_auth.o - -smbcalls_auth_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_auth.o - -[MODULE::smbcalls_string] -SUBSYSTEM = smbcalls -OUTPUT_TYPE = MERGED_OBJ -INIT_FUNCTION = smb_setup_ejs_string - -smbcalls_string_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_string.o - -[MODULE::smbcalls_sys] -SUBSYSTEM = smbcalls -OUTPUT_TYPE = MERGED_OBJ -INIT_FUNCTION = smb_setup_ejs_system - -smbcalls_sys_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_sys.o - -[SUBSYSTEM::smbcalls] -PRIVATE_DEPENDENCIES = \ - EJS LIBSAMBA-UTIL \ - MESSAGING \ - LIBSAMBA-NET LIBCLI_SMB LIBPOPT \ - CREDENTIALS POPT_CREDENTIALS POPT_SAMBA \ - NDR_TABLE - -smbcalls_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/, \ - smbcalls.o \ - smbcalls_options.o \ - smbcalls_creds.o \ - mprutil.o) - -$(eval $(call proto_header_template,$(ejsscriptsrcdir)/proto.h,$(smbcalls_OBJ_FILES:.o=.c))) - -####################### -# Start BINARY SMBSCRIPT -[BINARY::smbscript] -PRIVATE_DEPENDENCIES = EJS LIBSAMBA-UTIL smbcalls LIBSAMBA-HOSTCONFIG -# End BINARY SMBSCRIPT -####################### - -smbscript_OBJ_FILES = $(ejsscriptsrcdir)/smbscript.o diff --git a/source4/scripting/ejs/mprutil.c b/source4/scripting/ejs/mprutil.c deleted file mode 100644 index 9143947fb8..0000000000 --- a/source4/scripting/ejs/mprutil.c +++ /dev/null @@ -1,494 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - utility functions for manipulating mpr variables in ejs calls - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "lib/appweb/ejs/ejs.h" -#include "lib/ldb/include/ldb.h" -#include "scripting/ejs/smbcalls.h" - -/* - return a default mpr object -*/ -struct MprVar mprObject(const char *name) -{ - return ejsCreateObj(name && *name?name:"(NULL)", MPR_DEFAULT_HASH_SIZE); -} - -/* - return a empty mpr array -*/ -struct MprVar mprArray(const char *name) -{ - return ejsCreateArray(name && *name?name:"(NULL)", 0); -} - -/* - find a mpr component, allowing for sub objects, using the '.' convention -*/ - NTSTATUS mprGetVar(struct MprVar **v, const char *name) -{ - const char *p = strchr(name, '.'); - char *objname; - NTSTATUS status; - if (p == NULL) { - *v = mprGetProperty(*v, name, NULL); - if (*v == NULL) { - DEBUG(1,("mprGetVar unable to find '%s'\n", name)); - return NT_STATUS_INVALID_PARAMETER; - } - return NT_STATUS_OK; - } - objname = talloc_strndup(mprMemCtx(), name, p-name); - NT_STATUS_HAVE_NO_MEMORY(objname); - *v = mprGetProperty(*v, objname, NULL); - NT_STATUS_HAVE_NO_MEMORY(*v); - status = mprGetVar(v, p+1); - talloc_free(objname); - return status; -} - - -/* - set a mpr component, allowing for sub objects, using the '.' convention - destroys 'val' after setting -*/ - NTSTATUS mprSetVar(struct MprVar *v, const char *name, struct MprVar val) -{ - const char *p = strchr(name, '.'); - char *objname; - struct MprVar *v2; - NTSTATUS status; - if (p == NULL) { - v2 = mprSetProperty(v, name, &val); - if (v2 == NULL) { - DEBUG(1,("mprSetVar unable to set '%s'\n", name)); - return NT_STATUS_INVALID_PARAMETER_MIX; - } - mprDestroyVar(&val); - return NT_STATUS_OK; - } - objname = talloc_strndup(mprMemCtx(), name, p-name); - if (objname == NULL) { - return NT_STATUS_NO_MEMORY; - } - v2 = mprGetProperty(v, objname, NULL); - if (v2 == NULL) { - mprSetVar(v, objname, mprObject(objname)); - v2 = mprGetProperty(v, objname, NULL); - } - status = mprSetVar(v2, p+1, val); - talloc_free(objname); - return status; -} - - - -/* - add an indexed array element to a property -*/ - void mprAddArray(struct MprVar *var, int i, struct MprVar v) -{ - char idx[16]; - mprItoa(i, idx, sizeof(idx)); - mprSetVar(var, idx, v); -} - -/* - construct a MprVar from a list -*/ -struct MprVar mprList(const char *name, const char **list) -{ - struct MprVar var; - int i; - - var = mprArray(name); - for (i=0;list && list[i];i++) { - mprAddArray(&var, i, mprString(list[i])); - } - return var; -} - -/* - construct a MprVar from a string, using NULL if needed -*/ -struct MprVar mprString(const char *s) -{ - if (s == NULL) { - return mprCreatePtrVar(NULL); - } - return mprCreateStringVar(s, true); -} - -/* - construct a string MprVar from a lump of data -*/ -struct MprVar mprData(const uint8_t *p, size_t length) -{ - struct MprVar var; - char *s = talloc_strndup(mprMemCtx(), (const char *)p, length); - if (s == NULL) { - return mprCreateUndefinedVar(); - } - var = mprString(s); - talloc_free(s); - return var; -} - -/* - turn a ldb_message into a ejs object variable -*/ -static struct MprVar mprLdbMessage(struct ldb_context *ldb, struct ldb_message *msg) -{ - struct MprVar var; - int i; - /* we force some attributes to always be an array in the - returned structure. This makes the scripting easier, as you don't - need a special case for the single value case */ - const char *multivalued[] = { "objectClass", "memberOf", "privilege", - "member", NULL }; - - var = mprObject(ldb_dn_alloc_linearized(msg, msg->dn)); - - for (i=0;inum_elements;i++) { - struct ldb_message_element *el = &msg->elements[i]; - struct MprVar val; - const struct ldb_schema_attribute *a; - struct ldb_val v; - - a = ldb_schema_attribute_by_name(ldb, el->name); - if (a == NULL) { - goto failed; - } - - if (el->num_values == 1 && - !str_list_check_ci(multivalued, el->name)) { - if (a->syntax->ldif_write_fn(ldb, msg, &el->values[0], &v) != 0) { - goto failed; - } - /* FIXME: nasty hack, remove me when ejs will support - * arbitrary string and does not truncate on \0 */ - if (strlen((char *)v.data) != v.length) { - val = mprDataBlob(v); - } else { - val = mprData(v.data, v.length); - } - } else { - int j; - val = mprArray(el->name); - for (j=0;jnum_values;j++) { - if (a->syntax->ldif_write_fn(ldb, msg, - &el->values[j], &v) != 0) { - goto failed; - } - /* FIXME: nasty hack, remove me when ejs will support - * arbitrary string and does not truncate on \0 */ - if (strlen((char *)v.data) != v.length) { - mprAddArray(&val, j, mprDataBlob(v)); - } else { - mprAddArray(&val, j, mprData(v.data, v.length)); - } - } - } - mprSetVar(&var, el->name, val); - } - - /* add the dn if it is not already specified */ - if (mprGetProperty(&var, "dn", 0) == 0) { - mprSetVar(&var, "dn", mprString(ldb_dn_alloc_linearized(msg, msg->dn))); - } - - return var; -failed: - return mprCreateUndefinedVar(); -} - - -/* - build a MprVar result object for ldb operations with lots of funky properties -*/ -struct MprVar mprLdbResult(struct ldb_context *ldb, int err, struct ldb_result *result) -{ - struct MprVar ret; - struct MprVar ary; - - ret = mprObject("ldbret"); - - mprSetVar(&ret, "error", mprCreateIntegerVar(err)); - mprSetVar(&ret, "errstr", mprString(ldb_errstring(ldb))); - - ary = mprArray("ldb_message"); - if (result) { - int i; - - for (i = 0; i < result->count; i++) { - mprAddArray(&ary, i, mprLdbMessage(ldb, result->msgs[i])); - } - } - - mprSetVar(&ret, "msgs", ary); - - /* TODO: add referrals, exteded ops, and controls */ - - return ret; -} - - -/* - turn a MprVar string variable into a const char * - */ -const char *mprToString(struct MprVar *v) -{ - if (v->trigger) { - mprReadProperty(v, 0); - } - if (!mprVarIsString(v->type)) return NULL; - return v->string; -} - -/* - turn a MprVar integer variable into an int - */ -int mprToInt(struct MprVar *v) -{ - if (v->trigger) { - mprReadProperty(v, 0); - } - if (!mprVarIsNumber(v->type)) return 0; - return mprVarToNumber(v); -} - -/* - turn a MprVar object variable into a string list - this assumes the object variable consists only of strings -*/ -const char **mprToList(TALLOC_CTX *mem_ctx, struct MprVar *v) -{ - const char **list = NULL; - struct MprVar *el; - - if (v->type != MPR_TYPE_OBJECT || - v->properties == NULL) { - return NULL; - } - for (el=mprGetFirstProperty(v, MPR_ENUM_DATA); - el; - el=mprGetNextProperty(v, el, MPR_ENUM_DATA)) { - const char *s = mprToString(el); - if (s) { - list = str_list_add(list, s); - } - } - talloc_steal(mem_ctx, list); - return list; -} - - -/* - turn a MprVar object variable into a string list - this assumes the object variable is an array of strings -*/ -const char **mprToArray(TALLOC_CTX *mem_ctx, struct MprVar *v) -{ - const char **list = NULL; - struct MprVar *len; - int length, i; - - len = mprGetProperty(v, "length", NULL); - if (len == NULL) { - return NULL; - } - length = mprToInt(len); - - for (i=0;itype != MPR_TYPE_STRING) { - talloc_free(list); - return NULL; - } - list = str_list_add(list, mprToString(vs)); - } - talloc_steal(mem_ctx, list); - return list; -} - -/* - turn a NTSTATUS into a MprVar object with lots of funky properties -*/ -struct MprVar mprNTSTATUS(NTSTATUS status) -{ - struct MprVar res; - - res = mprObject("ntstatus"); - - mprSetVar(&res, "errstr", mprString(nt_errstr(status))); - mprSetVar(&res, "v", mprCreateIntegerVar(NT_STATUS_V(status))); - mprSetVar(&res, "is_ok", mprCreateBoolVar(NT_STATUS_IS_OK(status))); - mprSetVar(&res, "is_err", mprCreateBoolVar(NT_STATUS_IS_ERR(status))); - - return res; -} - -/* - create a data-blob in a mpr variable -*/ -struct MprVar mprDataBlob(DATA_BLOB blob) -{ - struct MprVar res; - struct datablob *pblob = talloc(mprMemCtx(), struct datablob); - *pblob = data_blob_talloc(pblob, blob.data, blob.length); - - res = mprObject("DATA_BLOB"); - - mprSetVar(&res, "size", mprCreateIntegerVar(blob.length)); - mprSetPtrChild(&res, "blob", pblob); - - return res; -} - -/* - return a data blob from a mpr var created using mprDataBlob -*/ -struct datablob *mprToDataBlob(struct MprVar *v) -{ - return talloc_get_type(mprGetPtr(v, "blob"), struct datablob); -} - -/* - turn a WERROR into a MprVar object with lots of funky properties -*/ -struct MprVar mprWERROR(WERROR status) -{ - struct MprVar res; - - res = mprObject("werror"); - - mprSetVar(&res, "errstr", mprString(win_errstr(status))); - mprSetVar(&res, "v", mprCreateIntegerVar(W_ERROR_V(status))); - mprSetVar(&res, "is_ok", mprCreateBoolVar(W_ERROR_IS_OK(status))); - mprSetVar(&res, "is_err", mprCreateBoolVar(!W_ERROR_IS_OK(status))); - - return res; -} - - -/* - set a pointer in a existing MprVar -*/ -void mprSetPtr(struct MprVar *v, const char *propname, const void *p) -{ - mprSetVar(v, propname, mprCreatePtrVar(discard_const(p))); -} - -/* - set a pointer in a existing MprVar, freeing it when the property goes away -*/ -void mprSetPtrChild(struct MprVar *v, const char *propname, const void *p) -{ - mprSetVar(v, propname, mprCreatePtrVar(discard_const(p))); - v = mprGetProperty(v, propname, NULL); - v->allocatedData = 1; - talloc_steal(mprMemCtx(), p); -} - -/* - get a pointer from a MprVar -*/ -void *mprGetPtr(struct MprVar *v, const char *propname) -{ - struct MprVar *val; - val = mprGetProperty(v, propname, NULL); - if (val == NULL) { - return NULL; - } - if (val->type != MPR_TYPE_PTR) { - return NULL; - } - return val->ptr; -} - -/* - set the return value then free the variable -*/ - void mpr_Return(int eid, struct MprVar v) -{ - ejsSetReturnValue(eid, v); - mprDestroyVar(&v); -} - -/* - set the return value then free the variable -*/ -void mpr_ReturnString(int eid, const char *s) -{ - mpr_Return(eid, mprString(s)); -} - - -/* - set a C function in a variable -*/ - void mprSetCFunction(struct MprVar *obj, const char *name, MprCFunction fn) -{ - mprSetVar(obj, name, mprCreateCFunctionVar(fn, obj, MPR_VAR_SCRIPT_HANDLE)); -} - -/* - set a string C function in a variable -*/ - void mprSetStringCFunction(struct MprVar *obj, const char *name, MprStringCFunction fn) -{ - mprSetVar(obj, name, mprCreateStringCFunctionVar(fn, obj, MPR_VAR_SCRIPT_HANDLE)); -} - -/* - get a pointer in the current object -*/ -void *mprGetThisPtr(int eid, const char *name) -{ - struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); - return mprGetPtr(this, name); -} - -/* - set a pointer as a child of the local object -*/ -void mprSetThisPtr(int eid, const char *name, void *ptr) -{ - struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); - mprSetPtrChild(this, name, ptr); -} - -/* - used by object xxx_init() routines to allow for the caller - to supply a pre-existing object to add properties to, - or create a new object. This makes inheritance easy -*/ -struct MprVar *mprInitObject(int eid, const char *name, int argc, struct MprVar **argv) -{ - if (argc > 0 && mprVarIsObject(argv[0]->type)) { - return argv[0]; - } - mpr_Return(eid, mprObject(name)); - return ejsGetReturnValue(eid); -} diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c deleted file mode 100644 index 4314b51455..0000000000 --- a/source4/scripting/ejs/smbcalls.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide hooks into smbd C calls from ejs scripts - - Copyright (C) Andrew Tridgell 2005 - Copyright (C) Tim Potter 2005 - - 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 . -*/ - -#include "includes.h" -#include "param/param.h" -#include "scripting/ejs/smbcalls.h" -#include "version.h" - -/* - return the type of a variable -*/ -static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const struct { - MprType type; - const char *name; - } types[] = { - { MPR_TYPE_UNDEFINED, "undefined" }, - { MPR_TYPE_NULL, "object" }, - { MPR_TYPE_BOOL, "boolean" }, - { MPR_TYPE_CFUNCTION, "function" }, - { MPR_TYPE_FLOAT, "number" }, - { MPR_TYPE_INT, "number" }, - { MPR_TYPE_INT64, "number" }, - { MPR_TYPE_OBJECT, "object" }, - { MPR_TYPE_FUNCTION, "function" }, - { MPR_TYPE_STRING, "string" }, - { MPR_TYPE_STRING_CFUNCTION, "function" }, - { MPR_TYPE_PTR, "pointer" } - }; - int i; - const char *type = NULL; - - if (argc != 1) return -1; - - for (i=0;itype == types[i].type) { - type = types[i].name; - break; - } - } - if (type == NULL) return -1; - - mpr_ReturnString(eid, type); - return 0; -} - -/* - return the native type of a variable -*/ -static int ejs_typeof_native(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const struct { - MprType type; - const char *name; - } types[] = { - { MPR_TYPE_UNDEFINED, "undefined" }, - { MPR_TYPE_NULL, "null" }, - { MPR_TYPE_BOOL, "boolean" }, - { MPR_TYPE_CFUNCTION, "c_function" }, - { MPR_TYPE_FLOAT, "float" }, - { MPR_TYPE_INT, "integer" }, - { MPR_TYPE_INT64, "integer64" }, - { MPR_TYPE_OBJECT, "object" }, - { MPR_TYPE_FUNCTION, "js_function" }, - { MPR_TYPE_STRING, "string" }, - { MPR_TYPE_STRING_CFUNCTION, "string_c_function" }, - { MPR_TYPE_PTR, "pointer" } - }; - int i; - const char *type = NULL; - - if (argc != 1) return -1; - - for (i=0;itype == types[i].type) { - type = types[i].name; - break; - } - } - if (type == NULL) return -1; - - mpr_ReturnString(eid, type); - return 0; -} - -/* - libinclude() allows you to include js files using a search path specified - in "js include =" in smb.conf. -*/ -static int ejs_libinclude(int eid, int argc, char **argv) -{ - int i, j; - const char **js_include = lp_js_include(mprLpCtx()); - - if (js_include == NULL || js_include[0] == NULL) { - ejsSetErrorMsg(eid, "js include path not set"); - return -1; - } - - for (i = 0; i < argc; i++) { - const char *script = argv[i]; - struct MprVar result; - char *path, *emsg; - int ret; - - /* use specfied path to search for requested file */ - for (j=0;js_include[j];j++) { - path = talloc_asprintf(mprMemCtx(), "%s/%s", js_include[j], script); - if (path == NULL) { - return -1; - } - if (file_exist(path)) { - - ret = ejsEvalFile(eid, path, &result, &emsg); - talloc_free(path); - if (ret < 0) { - ejsSetErrorMsg(eid, "%s: %s", script, emsg); - return -1; - } - break; - } - talloc_free(path); - } - - if (js_include[j] == NULL) { - ejsSetErrorMsg(eid, "unable to include '%s'", script); - return -1; - } - } - return 0; -} - -/* - return the current version -*/ -static int ejs_version(MprVarHandle eid, int argc, struct MprVar **argv) -{ - mpr_ReturnString(eid, SAMBA_VERSION_STRING); - return 0; -} - - -static void (*ejs_exception_handler) (const char *) = NULL; - -_PUBLIC_ void ejs_exception(const char *reason) -{ - ejs_exception_handler(reason); -} - -/* - setup C functions that be called from ejs -*/ -void smb_setup_ejs_functions(void (*exception_handler)(const char *)) -{ - extern NTSTATUS ejs_init_security(void); - extern NTSTATUS ejs_init_initshutdown(void); - extern NTSTATUS smb_setup_ejs_reg(void); - extern NTSTATUS smb_setup_ejs_string(void); - extern NTSTATUS ejs_init_lsarpc(void); - extern NTSTATUS ejs_init_rpcecho(void); - extern NTSTATUS ejs_init_winreg(void); - extern NTSTATUS smb_setup_ejs_random(void); - extern NTSTATUS smb_setup_ejs_config(void); - extern NTSTATUS ejs_init_misc(void); - extern NTSTATUS ejs_init_netdfs(void); - extern NTSTATUS smb_setup_ejs_datablob(void); - extern NTSTATUS smb_setup_ejs_auth(void); - extern NTSTATUS smb_setup_ejs_nss(void); - extern NTSTATUS ejs_init_samr(void); - extern NTSTATUS ejs_init_wkssvc(void); - extern NTSTATUS smb_setup_ejs_system(void); - extern NTSTATUS smb_setup_ejs_ldb(void); - extern NTSTATUS ejs_init_svcctl(void); - extern NTSTATUS smb_setup_ejs_net(void); - extern NTSTATUS ejs_init_srvsvc(void); - extern NTSTATUS ejs_init_netlogon(void); - extern NTSTATUS ejs_init_drsuapi(void); - extern NTSTATUS ejs_init_irpc(void); - extern NTSTATUS ejs_init_eventlog(void); - init_module_fn static_init[] = { STATIC_smbcalls_MODULES }; - init_module_fn *shared_init; - - ejs_exception_handler = exception_handler; - - smb_setup_ejs_options(); - smb_setup_ejs_credentials(); - - shared_init = load_samba_modules(NULL, mprLpCtx(), "smbcalls"); - - run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); - - ejsDefineCFunction(-1, "typeof", ejs_typeof, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "nativeTypeOf", ejs_typeof_native, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineStringCFunction(-1, "libinclude", ejs_libinclude, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "version", ejs_version, NULL, MPR_VAR_SCRIPT_HANDLE); -} - diff --git a/source4/scripting/ejs/smbcalls.h b/source4/scripting/ejs/smbcalls.h deleted file mode 100644 index 3aaf324b6e..0000000000 --- a/source4/scripting/ejs/smbcalls.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide hooks into smbd C calls from ejs scripts - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "lib/appweb/ejs/ejs.h" -#include "lib/ldb/include/ldb.h" - -void mpr_Return(int eid, struct MprVar); -NTSTATUS mprSetVar(struct MprVar *v, const char *name, struct MprVar val); -NTSTATUS mprGetVar(struct MprVar **v, const char *name); -void mprAddArray(struct MprVar *var, int i, struct MprVar v); -void mprSetCFunction(struct MprVar *obj, const char *name, MprCFunction fn); -void mprSetStringCFunction(struct MprVar *obj, const char *name, MprStringCFunction fn); - -struct smbcalls_context { - struct event_context *event_ctx; - struct messaging_context *msg_ctx; -}; - -struct ldb_context; -struct ldb_message; -struct cli_credentials; - -#include "param/param.h" -#include "scripting/ejs/proto.h" diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c deleted file mode 100644 index b67bb7ed5b..0000000000 --- a/source4/scripting/ejs/smbcalls_auth.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - ejs auth functions - - Copyright (C) Simo Sorce 2005 - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "lib/appweb/ejs/ejs.h" -#include "auth/auth.h" -#include "auth/credentials/credentials.h" -#include "scripting/ejs/smbcalls.h" -#include "lib/events/events.h" -#include "lib/messaging/irpc.h" -#include "libcli/security/security.h" - -static int ejs_doauth(MprVarHandle eid, - TALLOC_CTX *tmp_ctx, struct MprVar *auth, - const char *username, const char *password, - const char *domain, const char *workstation, - struct socket_address *remote_host, - const char **auth_types) -{ - struct auth_usersupplied_info *user_info = NULL; - struct auth_serversupplied_info *server_info = NULL; - struct auth_session_info *session_info = NULL; - struct auth_context *auth_context; - struct MprVar *session_info_obj; - NTSTATUS nt_status; - bool set; - - struct smbcalls_context *c; - struct event_context *ev; - struct messaging_context *msg; - - /* Hope we can find an smbcalls_context somewhere up there... */ - c = talloc_find_parent_bytype(tmp_ctx, struct smbcalls_context); - if (c) { - ev = c->event_ctx; - msg = c->msg_ctx; - } else { - /* Hope we can find the event context somewhere up there... */ - ev = mprEventCtx(); - msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, mprLpCtx()), - lp_iconv_convenience(mprLpCtx()), ev); - } - - if (auth_types) { - nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, mprLpCtx(), &auth_context); - } else { - nt_status = auth_context_create(tmp_ctx, ev, msg, mprLpCtx(), &auth_context); - } - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(auth, "result", mprCreateBoolVar(false)); - mprSetPropertyValue(auth, "report", mprString("Auth System Failure")); - goto done; - } - - user_info = talloc(tmp_ctx, struct auth_usersupplied_info); - if (!user_info) { - mprSetPropertyValue(auth, "result", mprCreateBoolVar(false)); - mprSetPropertyValue(auth, "report", mprString("talloc failed")); - goto done; - } - - user_info->mapped_state = true; - user_info->client.account_name = username; - user_info->mapped.account_name = username; - user_info->client.domain_name = domain; - user_info->mapped.domain_name = domain; - - user_info->workstation_name = workstation; - - user_info->remote_host = remote_host; - - user_info->password_state = AUTH_PASSWORD_PLAIN; - user_info->password.plaintext = talloc_strdup(user_info, password); - - user_info->flags = USER_INFO_CASE_INSENSITIVE_USERNAME | - USER_INFO_DONT_CHECK_UNIX_ACCOUNT; - - user_info->logon_parameters = 0; - - nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info); - - /* Don't give the game away (any difference between no such - * user and wrong password) */ - nt_status = auth_nt_status_squash(nt_status); - - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(auth, "report", - mprString(talloc_strdup(mprMemCtx(), get_friendly_nt_error_msg(nt_status)))); - mprSetPropertyValue(auth, "result", mprCreateBoolVar(false)); - goto done; - } - - nt_status = auth_generate_session_info(tmp_ctx, mprEventCtx(), mprLpCtx(), server_info, &session_info); - if (!NT_STATUS_IS_OK(nt_status)) { - mprSetPropertyValue(auth, "report", mprString("Session Info generation failed")); - mprSetPropertyValue(auth, "result", mprCreateBoolVar(false)); - goto done; - } - - if (security_token_has_nt_authenticated_users(session_info->security_token)) { - mprSetPropertyValue(auth, "user_class", mprString("USER")); - set = true; - } - - if (security_token_has_builtin_administrators(session_info->security_token)) { - mprSetPropertyValue(auth, "user_class", mprString("ADMINISTRATOR")); - set = true; - } - - if (security_token_is_system(session_info->security_token)) { - mprSetPropertyValue(auth, "user_class", mprString("SYSTEM")); - set = true; - } - - if (security_token_is_anonymous(session_info->security_token)) { - mprSetPropertyValue(auth, "report", mprString("Anonymous login not permitted")); - mprSetPropertyValue(auth, "result", mprCreateBoolVar(false)); - goto done; - } - - if (!set) { - mprSetPropertyValue(auth, "report", mprString("Session Info generation failed")); - mprSetPropertyValue(auth, "result", mprCreateBoolVar(false)); - } - - session_info_obj = mprInitObject(eid, "session_info", 0, NULL); - - mprSetPtrChild(session_info_obj, "session_info", session_info); - talloc_steal(mprMemCtx(), session_info); - - mprSetProperty(auth, "session_info", session_info_obj); - mprSetPropertyValue(auth, "result", mprCreateBoolVar(server_info->authenticated)); - mprSetPropertyValue(auth, "username", mprString(server_info->account_name)); - mprSetPropertyValue(auth, "domain", mprString(server_info->domain_name)); - -done: - return 0; -} - -/* - perform user authentication, returning an array of results - -*/ -static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv) -{ - TALLOC_CTX *tmp_ctx; - const char *username; - const char *password; - const char *domain; - const char *workstation; - struct MprVar auth; - struct cli_credentials *creds; - struct socket_address *remote_host; - const char *auth_types_unix[] = { "unix", NULL }; - - if (argc != 2 || argv[0]->type != MPR_TYPE_OBJECT || argv[1]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "userAuth invalid arguments, this function requires an object."); - return -1; - } - - /* get credential values from credentials object */ - creds = mprGetPtr(argv[0], "creds"); - if (creds == NULL) { - ejsSetErrorMsg(eid, "userAuth requires a 'creds' first parameter"); - return -1; - } - - remote_host = (struct socket_address *)mprGetPtr(argv[1], "socket_address"); - if (remote_host == NULL) { - ejsSetErrorMsg(eid, "userAuth requires a socket address second parameter"); - return -1; - } - - tmp_ctx = talloc_new(mprMemCtx()); - - username = cli_credentials_get_username(creds); - password = cli_credentials_get_password(creds); - domain = cli_credentials_get_domain(creds); - workstation = cli_credentials_get_workstation(creds); - - if (username == NULL || password == NULL || domain == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - talloc_free(tmp_ctx); - return 0; - } - - auth = mprObject("auth"); - - if (domain && (strcmp("SYSTEM USER", domain) == 0)) { - ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, auth_types_unix); - } else { - ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, NULL); - } - - mpr_Return(eid, auth); - talloc_free(tmp_ctx); - return 0; -} - -/* - initialise credentials ejs object -*/ -static int ejs_system_session(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct MprVar *obj = mprInitObject(eid, "session_info", argc, argv); - struct auth_session_info *session_info = system_session(mprMemCtx(), mprLpCtx()); - - if (session_info == NULL) { - return -1; - } - - mprSetPtrChild(obj, "session_info", session_info); - return 0; -} - -/* - setup C functions that be called from ejs -*/ -NTSTATUS smb_setup_ejs_auth(void) -{ - ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE); - ejsDefineCFunction(-1, "system_session", ejs_system_session, NULL, MPR_VAR_SCRIPT_HANDLE); - return NT_STATUS_OK; -} diff --git a/source4/scripting/ejs/smbcalls_config.c b/source4/scripting/ejs/smbcalls_config.c deleted file mode 100644 index eb673b3a23..0000000000 --- a/source4/scripting/ejs/smbcalls_config.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide hooks into smbd C calls from ejs scripts - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "scripting/ejs/smbcalls.h" -#include "lib/appweb/ejs/ejs.h" -#include "param/loadparm.h" -#include "system/network.h" -#include "lib/socket/netif.h" -#include "param/param.h" - -/* - return a list of defined services -*/ -static int ejs_lpServices(MprVarHandle eid, int argc, char **argv) -{ - int i; - const char **list = NULL; - if (argc != 0) return -1; - - for (i=0;iclass == P_GLOBAL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - parm_ptr = lp_parm_ptr(mprLpCtx(), service, parm); - } else if (strchr(argv[0], ':')) { - /* its a global parametric option */ - const char *type = talloc_strndup(mprMemCtx(), - argv[0], strcspn(argv[0], ":")); - const char *option = strchr(argv[0], ':') + 1; - const char *value; - if (type == NULL || option == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - value = lp_get_parametric(mprLpCtx(), NULL, type, option); - if (value == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - mpr_ReturnString(eid, value); - return 0; - } else { - /* its a global parameter */ - parm = lp_parm_struct(argv[0]); - if (parm == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - parm_ptr = lp_parm_ptr(mprLpCtx(), NULL, parm); - } - - if (parm == NULL || parm_ptr == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - - /* construct and return the right type of ejs object */ - switch (parm->type) { - case P_STRING: - case P_USTRING: - mpr_ReturnString(eid, *(char **)parm_ptr); - break; - case P_BOOL: - mpr_Return(eid, mprCreateBoolVar(*(bool *)parm_ptr)); - break; - case P_INTEGER: - case P_OCTAL: - case P_BYTES: - mpr_Return(eid, mprCreateIntegerVar(*(int *)parm_ptr)); - break; - case P_ENUM: - for (i=0; parm->enum_list[i].name; i++) { - if (*(int *)parm_ptr == parm->enum_list[i].value) { - mpr_ReturnString(eid, parm->enum_list[i].name); - return 0; - } - } - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - case P_LIST: - mpr_Return(eid, mprList(parm->label, *(const char ***)parm_ptr)); - break; - } - return 0; -} - -/* - v = lp.filename(); obtain filename -*/ -static int ejs_lpFilename(MprVarHandle eid, int argc, char **argv) -{ - mpr_ReturnString(eid, lp_configfile(mprLpCtx())); - return 0; -} - -/* - set a smb.conf parameter. Only sets in memory, not permanent - - can be called in 4 ways: - - ok = lp.set("parm", "value"); -*/ -static int ejs_lpSet(MprVarHandle eid, int argc, char **argv) -{ - if (argc != 2) { - ejsSetErrorMsg(eid, "lp.set invalid arguments"); - return -1; - } - - mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(mprLpCtx(), argv[0], argv[1]))); - return 0; -} - -/* - reload smb.conf - - ok = lp.reload(); -*/ -static int ejs_lpReload(MprVarHandle eid, int argc, char **argv) -{ - bool ret; - const char *filename = lp_configfile(mprLpCtx()); - - ret = lp_load(mprLpCtx(), filename); - mpr_Return(eid, mprCreateBoolVar(ret)); - return 0; -} - -/* - initialise loadparm ejs subsystem -*/ -static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct MprVar *obj = mprInitObject(eid, "loadparm", argc, argv); - - mprSetStringCFunction(obj, "get", ejs_lpGet); - mprSetStringCFunction(obj, "set", ejs_lpSet); - mprSetStringCFunction(obj, "reload", ejs_lpReload); - mprSetStringCFunction(obj, "services", ejs_lpServices); - mprSetStringCFunction(obj, "filename", ejs_lpFilename); - return 0; -} - -/* - setup C functions that be called from ejs -*/ -NTSTATUS smb_setup_ejs_config(void) -{ - ejsDefineCFunction(-1, "loadparm_init", ejs_loadparm_init, NULL, MPR_VAR_SCRIPT_HANDLE); - return NT_STATUS_OK; -} diff --git a/source4/scripting/ejs/smbcalls_creds.c b/source4/scripting/ejs/smbcalls_creds.c deleted file mode 100644 index fd73f0751f..0000000000 --- a/source4/scripting/ejs/smbcalls_creds.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide hooks credentials calls - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "scripting/ejs/smbcalls.h" -#include "lib/appweb/ejs/ejs.h" -#include "lib/cmdline/popt_common.h" -#include "auth/credentials/credentials.h" - -/* - helper function to get the local objects credentials ptr -*/ -static struct cli_credentials *ejs_creds_get_credentials(int eid) -{ - struct cli_credentials *creds = (struct cli_credentials *)mprGetThisPtr(eid, "creds"); - if (creds == NULL) { - ejsSetErrorMsg(eid, "NULL ejs credentials"); - } - return creds; -} - -/* - get a domain -*/ -static int ejs_creds_get_domain(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - - mpr_Return(eid, mprString(cli_credentials_get_domain(creds))); - return 0; -} - - -/* - set a domain -*/ -static int ejs_creds_set_domain(MprVarHandle eid, int argc, char **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - if (argc != 1) { - ejsSetErrorMsg(eid, "bad arguments to set_domain"); - return -1; - } - - cli_credentials_set_domain(creds, argv[0], CRED_SPECIFIED); - mpr_Return(eid, mprCreateBoolVar(true)); - return 0; -} - - -/* - get a username -*/ -static int ejs_creds_get_username(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - - mpr_Return(eid, mprString(cli_credentials_get_username(creds))); - return 0; -} - - -/* - set a username -*/ -static int ejs_creds_set_username(MprVarHandle eid, int argc, char **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - if (argc != 1) { - ejsSetErrorMsg(eid, "bad arguments to set_username"); - return -1; - } - - cli_credentials_set_username(creds, argv[0], CRED_SPECIFIED); - mpr_Return(eid, mprCreateBoolVar(true)); - return 0; -} - - -/* - get user password -*/ -static int ejs_creds_get_password(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - - mpr_Return(eid, mprString(cli_credentials_get_password(creds))); - return 0; -} - - -/* - set user password -*/ -static int ejs_creds_set_password(MprVarHandle eid, int argc, char **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - if (argc != 1) { - ejsSetErrorMsg(eid, "bad arguments to set_password"); - return -1; - } - - cli_credentials_set_password(creds, argv[0], CRED_SPECIFIED); - mpr_Return(eid, mprCreateBoolVar(true)); - return 0; -} - - -/* - set realm -*/ -static int ejs_creds_set_realm(MprVarHandle eid, int argc, char **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - if (argc != 1) { - ejsSetErrorMsg(eid, "bad arguments to set_realm"); - return -1; - } - - cli_credentials_set_realm(creds, argv[0], CRED_SPECIFIED); - mpr_Return(eid, mprCreateBoolVar(true)); - return 0; -} - - -/* - get realm -*/ -static int ejs_creds_get_realm(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - - mpr_Return(eid, mprString(cli_credentials_get_realm(creds))); - return 0; -} - - -/* - set workstation -*/ -static int ejs_creds_set_workstation(MprVarHandle eid, int argc, char **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - if (argc != 1) { - ejsSetErrorMsg(eid, "bad arguments to set_workstation"); - return -1; - } - - cli_credentials_set_workstation(creds, argv[0], CRED_SPECIFIED); - mpr_Return(eid, mprCreateBoolVar(true)); - return 0; -} - - -/* - get workstation -*/ -static int ejs_creds_get_workstation(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - - mpr_Return(eid, mprString(cli_credentials_get_workstation(creds))); - return 0; -} - -/* - set machine account -*/ -static int ejs_creds_set_machine_account(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds = ejs_creds_get_credentials(eid); - if (argc != 0) { - ejsSetErrorMsg(eid, "bad arguments to set_machine_account"); - return -1; - } - - if (NT_STATUS_IS_OK(cli_credentials_set_machine_account(creds, mprLpCtx()))) { - mpr_Return(eid, mprCreateBoolVar(true)); - } else { - mpr_Return(eid, mprCreateBoolVar(false)); - } - return 0; -} - - -/* - initialise credentials ejs object -*/ -static int ejs_credentials_obj(struct MprVar *obj, struct cli_credentials *creds) -{ - mprSetPtrChild(obj, "creds", creds); - - /* setup our object methods */ - mprSetCFunction(obj, "get_domain", ejs_creds_get_domain); - mprSetStringCFunction(obj, "set_domain", ejs_creds_set_domain); - mprSetCFunction(obj, "get_username", ejs_creds_get_username); - mprSetStringCFunction(obj, "set_username", ejs_creds_set_username); - mprSetCFunction(obj, "get_password", ejs_creds_get_password); - mprSetStringCFunction(obj, "set_password", ejs_creds_set_password); - mprSetCFunction(obj, "get_realm", ejs_creds_get_realm); - mprSetStringCFunction(obj, "set_realm", ejs_creds_set_realm); - mprSetCFunction(obj, "get_workstation", ejs_creds_get_workstation); - mprSetStringCFunction(obj, "set_workstation", ejs_creds_set_workstation); - mprSetCFunction(obj, "set_machine_account", ejs_creds_set_machine_account); - - return 0; -} - - -struct MprVar mprCredentials(struct cli_credentials *creds) -{ - struct MprVar mpv = mprObject("credentials"); - - ejs_credentials_obj(&mpv, creds); - - return mpv; -} - - -/* - initialise credentials ejs object -*/ -static int ejs_credentials_init(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct cli_credentials *creds; - struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv); - - creds = cli_credentials_init(mprMemCtx()); - if (creds == NULL) { - return -1; - } - - cli_credentials_set_conf(creds, mprLpCtx()); - - return ejs_credentials_obj(obj, creds); -} - -/* - initialise cmdline credentials ejs object -*/ -int ejs_credentials_cmdline(int eid, int argc, struct MprVar **argv) -{ - struct MprVar *obj = mprInitObject(eid, "credentials", argc, argv); - if (talloc_reference(mprMemCtx(), cmdline_credentials) == NULL) { - return -1; - } - return ejs_credentials_obj(obj, cmdline_credentials); -} - -/* - setup C functions that be called from ejs -*/ -void smb_setup_ejs_credentials(void) -{ - ejsDefineCFunction(-1, "credentials_init", ejs_credentials_init, NULL, MPR_VAR_SCRIPT_HANDLE); -} - diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c deleted file mode 100644 index 4a157945af..0000000000 --- a/source4/scripting/ejs/smbcalls_ldb.c +++ /dev/null @@ -1,772 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide hooks into smbd C calls from ejs scripts - - Copyright (C) Andrew Tridgell 2005 - Copyright (C) Jelmer Vernooij 2005 - - 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 . -*/ - -#include "includes.h" -#include "scripting/ejs/smbcalls.h" -#include "lib/appweb/ejs/ejs.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "ldb_wrap.h" -#include "dsdb/samdb/samdb.h" -#include "librpc/ndr/libndr.h" -#include "libcli/security/security.h" - -/* - get the connected db - */ -static struct ldb_context *ejs_get_ldb_context(int eid) -{ - struct ldb_context *ldb = (struct ldb_context *)mprGetThisPtr(eid, "db"); - if (ldb == NULL) { - ejsSetErrorMsg(eid, "invalid ldb connection"); - } - return ldb; -} - -/* - perform an ldb search, returning an array of results - - syntax: - res = ldb.search("expression"); - var attrs = new Array("attr1", "attr2", "attr3"); - ldb.search("expression", attrs); - var basedn = "cn=this,dc=is,dc=a,dc=test"; - ldb.search("expression", basedn, ldb.SCOPE_SUBTREE, attrs); - ldb.search("expression", basedn, ldb.SCOPE_SUBTREE, attrs, controls); -*/ -static int ejs_ldbSearch(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const char **attrs = NULL; - const char *expression; - const char *base = NULL; - struct ldb_dn *basedn = NULL; - int scope = LDB_SCOPE_DEFAULT; - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - struct ldb_context *ldb; - int ret; - struct ldb_control **parsed_controls = NULL; - struct ldb_result *res=NULL; - struct ldb_request *req; - - /* validate arguments */ - if (argc < 1 || argc > 5) { - ejsSetErrorMsg(eid, "ldb.search invalid number of arguments"); - goto failed; - } - if (argc > 3 && argv[3]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "ldb.search attributes must be an object"); - goto failed; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - expression = mprToString(argv[0]); - if (argc > 1) { - base = mprToString(argv[1]); - /* a null basedn is valid */ - } - if (base != NULL) { - basedn = ldb_dn_new(tmp_ctx, ldb, base); - if ( ! ldb_dn_validate(basedn)) { - ejsSetErrorMsg(eid, "ldb.search malformed base dn"); - goto failed; - } - } else { - basedn = ldb_get_default_basedn(ldb); - } - if (argc > 2) { - scope = mprToInt(argv[2]); - switch (scope) { - case LDB_SCOPE_DEFAULT: - case LDB_SCOPE_BASE: - case LDB_SCOPE_ONELEVEL: - case LDB_SCOPE_SUBTREE: - break; /* ok */ - default: - ejsSetErrorMsg(eid, "ldb.search invalid scope"); - goto failed; - } - } - if (argc > 3) { - attrs = mprToList(tmp_ctx, argv[3]); - } - if (argc > 4) { - const char **controls; - controls = mprToList(tmp_ctx, argv[4]); - if (controls) { - parsed_controls = ldb_parse_control_strings(ldb, tmp_ctx, controls); - if (!parsed_controls) { - ejsSetErrorMsg(eid, "ldb.search cannot parse controls: %s", - ldb_errstring(ldb)); - goto failed; - } - } - } - - res = talloc_zero(tmp_ctx, struct ldb_result); - if (!res) { - return LDB_ERR_OPERATIONS_ERROR; - } - - ret = ldb_build_search_req(&req, ldb, tmp_ctx, - basedn, - scope, - expression, - attrs, - parsed_controls, - res, - ldb_search_default_callback); - - if (ret == LDB_SUCCESS) { - - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - - ret = ldb_request(ldb, req); - - if (ret == LDB_SUCCESS) { - ret = ldb_wait(req->handle, LDB_WAIT_ALL); - } - } - - if (ret != LDB_SUCCESS) { - ejsSetErrorMsg(eid, "ldb.search failed - %s", ldb_errstring(ldb)); - mpr_Return(eid, mprLdbResult(ldb, ret, NULL)); - } else { - mpr_Return(eid, mprLdbResult(ldb, ret, res)); - } - - talloc_free(tmp_ctx); - return 0; - -failed: - talloc_free(tmp_ctx); - return -1; -} - - -/* - perform an ldb add or modify -*/ -static int ejs_ldbAddModify(MprVarHandle eid, int argc, struct MprVar **argv, - int fn(struct ldb_context *, const struct ldb_message *)) -{ - const char *ldifstring; - struct ldb_context *ldb; - struct ldb_ldif *ldif; - int ret = 0, count=0; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.add/modify invalid arguments"); - return -1; - } - - ldifstring = mprToString(argv[0]); - if (ldifstring == NULL) { - ejsSetErrorMsg(eid, "ldb.add/modify invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - while ((ldif = ldb_ldif_read_string(ldb, &ldifstring))) { - count++; - ret = fn(ldb, ldif->msg); - talloc_free(ldif); - if (ret != 0) break; - } - - if (count == 0) { - ejsSetErrorMsg(eid, "ldb.add/modify invalid ldif"); - return -1; - } - - mpr_Return(eid, mprLdbResult(ldb, ret, NULL)); - return 0; -} - - -/* - perform an ldb delete - usage: - ok = ldb.delete(dn); -*/ -static int ejs_ldbDelete(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_dn *dn; - struct ldb_context *ldb; - int ret; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.delete invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - dn = ldb_dn_new(ldb, ldb, mprToString(argv[0])); - if ( ! ldb_dn_validate(dn)) { - ejsSetErrorMsg(eid, "ldb.delete malformed dn"); - return -1; - } - - ret = ldb_delete(ldb, dn); - - talloc_free(dn); - - mpr_Return(eid, mprLdbResult(ldb, ret, NULL)); - return 0; -} - -/* - perform an ldb rename - usage: - ok = ldb.rename(dn1, dn2); -*/ -static int ejs_ldbRename(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_dn *dn1, *dn2; - struct ldb_context *ldb; - int ret; - - if (argc != 2) { - ejsSetErrorMsg(eid, "ldb.rename invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - dn1 = ldb_dn_new(ldb, ldb, mprToString(argv[0])); - dn2 = ldb_dn_new(ldb, ldb, mprToString(argv[1])); - if ( ! ldb_dn_validate(dn1) || ! ldb_dn_validate(dn2)) { - ejsSetErrorMsg(eid, "ldb.rename invalid or malformed arguments"); - return -1; - } - - ret = ldb_rename(ldb, dn1, dn2); - - talloc_free(dn1); - talloc_free(dn2); - - mpr_Return(eid, mprLdbResult(ldb, ret, NULL)); - return 0; -} - -/* - get last error message - usage: - ok = ldb.errstring(); -*/ -static int ejs_ldbErrstring(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_context *ldb; - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - mpr_Return(eid, mprString(ldb_errstring(ldb))); - return 0; -} - -/* - base64 encode - usage: - dataout = ldb.encode(datain) - */ -static int ejs_base64encode(MprVarHandle eid, int argc, struct MprVar **argv) -{ - char *ret; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.base64encode invalid argument count"); - return -1; - } - - if (argv[0]->type == MPR_TYPE_STRING) { - const char *orig = mprToString(argv[0]); - ret = ldb_base64_encode(mprMemCtx(), orig, strlen(orig)); - } else { - DATA_BLOB *blob; - - blob = mprToDataBlob(argv[0]); - mprAssert(blob); - ret = ldb_base64_encode(mprMemCtx(), (char *)blob->data, blob->length); - } - - if (!ret) { - mpr_Return(eid, mprCreateUndefinedVar()); - } else { - mpr_Return(eid, mprString(ret)); - } - - talloc_free(ret); - - return 0; -} - -/* - base64 decode - usage: - dataout = ldb.decode(datain) - */ -static int ejs_base64decode(MprVarHandle eid, int argc, struct MprVar **argv) -{ - char *tmp; - int ret; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.base64encode invalid argument count"); - return -1; - } - - tmp = talloc_strdup(mprMemCtx(), mprToString(argv[0])); - ret = ldb_base64_decode(tmp); - if (ret == -1) { - mpr_Return(eid, mprCreateUndefinedVar()); - } else { - DATA_BLOB blob; - blob.data = (uint8_t *)tmp; - blob.length = ret; - mpr_Return(eid, mprDataBlob(blob)); - } - - talloc_free(tmp); - - return 0; -} - -/* - escape a DN - usage: - dataout = ldb.dn_escape(datain) - */ -static int ejs_dn_escape(MprVarHandle eid, int argc, struct MprVar **argv) -{ - char *ret; - struct ldb_val val; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.dn_escape invalid argument count"); - return -1; - } - - val = data_blob_string_const(mprToString(argv[0])); - - ret = ldb_dn_escape_value(mprMemCtx(), val); - if (ret == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - } else { - mpr_Return(eid, mprString(ret)); - talloc_free(ret); - } - - return 0; -} - -/* - perform an ldb add - - syntax: - ok = ldb.add(ldifstring); -*/ -static int ejs_ldbAdd(MprVarHandle eid, int argc, struct MprVar **argv) -{ - return ejs_ldbAddModify(eid, argc, argv, ldb_add); -} - -/* - perform an ldb modify - - syntax: - ok = ldb.modify(ldifstring); -*/ -static int ejs_ldbModify(MprVarHandle eid, int argc, struct MprVar **argv) -{ - return ejs_ldbAddModify(eid, argc, argv, ldb_modify); -} - -/* - connect to a database - usage: - ok = ldb.connect(dbfile); - ok = ldb.connect(dbfile, "modules:modlist"); - - ldb.credentials or ldb.session_info may be setup first - -*/ -static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv) -{ - struct ldb_context *ldb; - struct auth_session_info *session_info = NULL; - struct cli_credentials *creds = NULL; - struct MprVar *credentials, *session; - struct MprVar *this = mprGetProperty(ejsGetLocalObject(eid), "this", 0); - - const char *dbfile; - - if (argc < 1) { - ejsSetErrorMsg(eid, "ldb.connect invalid arguments"); - return -1; - } - - credentials = mprGetProperty(this, "credentials", NULL); - if (credentials) { - creds = talloc_get_type(mprGetPtr(credentials, "creds"), struct cli_credentials); - } - - session = mprGetProperty(this, "session_info", NULL); - if (session) { - session_info = talloc_get_type(mprGetPtr(session, "session_info"), struct auth_session_info); - } - - dbfile = argv[0]; - - ldb = ldb_wrap_connect(mprMemCtx(), mprEventCtx(), mprLpCtx(), dbfile, - session_info, creds, - 0, (const char **)(argv+1)); - if (ldb == NULL) { - ejsSetErrorMsg(eid, "ldb.connect failed to open %s", dbfile); - } - - mprSetThisPtr(eid, "db", ldb); - mpr_Return(eid, mprCreateBoolVar(ldb != NULL)); - return 0; -} - - -/* - close a db connection -*/ -static int ejs_ldbClose(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_context *ldb; - - if (argc != 0) { - ejsSetErrorMsg(eid, "ldb.close invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - mprSetThisPtr(eid, "db", NULL); - mpr_Return(eid, mprCreateBoolVar(true)); - return 0; -} - - -/* - start a ldb transaction - usage: - ok = ldb.transaction_start(); -*/ -static int ejs_ldbTransactionStart(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_context *ldb; - int ret; - - if (argc != 0) { - ejsSetErrorMsg(eid, "ldb.transaction_start invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - ret = ldb_transaction_start(ldb); - - mpr_Return(eid, mprCreateBoolVar(ret == 0)); - return 0; -} - -/* - cancel a ldb transaction - usage: - ok = ldb.transaction_cancel(); -*/ -static int ejs_ldbTransactionCancel(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_context *ldb; - int ret; - - if (argc != 0) { - ejsSetErrorMsg(eid, "ldb.transaction_cancel invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - ret = ldb_transaction_cancel(ldb); - - mpr_Return(eid, mprCreateBoolVar(ret == 0)); - return 0; -} - -/* - commit a ldb transaction - usage: - ok = ldb.transaction_commit(); -*/ -static int ejs_ldbTransactionCommit(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct ldb_context *ldb; - int ret; - - if (argc != 0) { - ejsSetErrorMsg(eid, "ldb.transaction_commit invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - ret = ldb_transaction_commit(ldb); - - mpr_Return(eid, mprCreateBoolVar(ret == 0)); - return 0; -} - -/* - commit a ldb attach a dsdb_schema from ldif files - usage: - ok = ldb.attach_dsdb_schema_from_ldif("prefixMap ldif content", "definition ldif content") -*/ -static int ejs_ldb_attach_dsdb_schema_from_ldif(MprVarHandle eid, int argc, char **argv) -{ - struct ldb_context *ldb; - WERROR status; - const char *pf; - const char *df; - - if (argc != 2) { - ejsSetErrorMsg(eid, "ldb.attach_dsdb_schema_from_ldif invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - pf = argv[0]; - df = argv[1]; - - status = dsdb_attach_schema_from_ldif_file(ldb, pf, df); - - mpr_Return(eid, mprWERROR(status)); - return 0; -} - -/* - set a particular invocationId against the running LDB - usage: - ok = ldb.set_ntds_invocationId("7729aa4b-f990-41ad-b81a-8b6a14090f41"); -*/ -static int ejs_ldb_set_ntds_invocationId(MprVarHandle eid, int argc, char **argv) -{ - struct ldb_context *ldb; - NTSTATUS status; - struct GUID guid; - char *guid_str; - bool ok; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.set_ntds_invocationId invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - guid_str = argv[0]; - - status = GUID_from_string(guid_str, &guid); - if (!NT_STATUS_IS_OK(status)) { - ejsSetErrorMsg(eid, "ldb.set_ntds_invocationId - failed to parse GUID '%s' %s\n", - guid_str, nt_errstr(status)); - return -1; - } - - ok = samdb_set_ntds_invocation_id(ldb, &guid); - if (!ok) { - ejsSetErrorMsg(eid, "ldb.set_ntds_invocationId - failed to set cached ntds invocationId\n"); - return -1; - } - - mpr_Return(eid, mprCreateBoolVar(ok)); - return 0; -} - -/* - attach a particular ntds objectGUID against the current ldb - usage: - ok = ldb.set_ntds_objectGUID("7729aa4b-f990-41ad-b81a-8b6a14090f41"); -*/ -static int ejs_ldb_set_ntds_objectGUID(MprVarHandle eid, int argc, char **argv) -{ - struct ldb_context *ldb; - NTSTATUS status; - struct GUID guid; - char *guid_str; - bool ok; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.set_ntds_objectGUID invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - guid_str = argv[0]; - - status = GUID_from_string(guid_str, &guid); - if (!NT_STATUS_IS_OK(status)) { - ejsSetErrorMsg(eid, "ldb.set_ntds_objectGUID - failed to parse GUID '%s' %s\n", - guid_str, nt_errstr(status)); - return -1; - } - - ok = samdb_set_ntds_invocation_id(ldb, &guid); - if (!ok) { - ejsSetErrorMsg(eid, "ldb.set_ntds_objectGUID - failed to set cached ntds invocationId\n"); - return -1; - } - - mpr_Return(eid, mprCreateBoolVar(ok)); - return 0; -} - -/* - attach a particular domain SID against the current ldb - usage: - ok = ldb.set_domain_sid("S-S-1-5-21-3065342217-3567412576-2214182334"); -*/ -static int ejs_ldb_set_domain_sid(MprVarHandle eid, int argc, char **argv) -{ - struct ldb_context *ldb; - struct dom_sid *dom_sid; - char *dom_sid_str; - bool ok; - - if (argc != 1) { - ejsSetErrorMsg(eid, "ldb.set_domain_sid invalid arguments"); - return -1; - } - - ldb = ejs_get_ldb_context(eid); - if (ldb == NULL) { - return -1; - } - - dom_sid_str = argv[0]; - - dom_sid = dom_sid_parse_talloc(NULL, dom_sid_str); - if (!dom_sid) { - ejsSetErrorMsg(eid, "ldb.set_domain_sid - failed to parse domain sid '%s'\n", - dom_sid_str); - return -1; - } - - ok = samdb_set_domain_sid(ldb, dom_sid); - talloc_free(dom_sid); - if (!ok) { - ejsSetErrorMsg(eid, "ldb.set_domain_sid - failed to set cached ntds invocationId\n"); - return -1; - } - - mpr_Return(eid, mprCreateBoolVar(ok)); - return 0; -} - -/* - initialise ldb ejs subsystem -*/ -static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct MprVar *ldb = mprInitObject(eid, "ldb", argc, argv); - - mprSetStringCFunction(ldb, "connect", ejs_ldbConnect); - mprSetCFunction(ldb, "search", ejs_ldbSearch); - mprSetCFunction(ldb, "add", ejs_ldbAdd); - mprSetCFunction(ldb, "modify", ejs_ldbModify); - mprSetCFunction(ldb, "del", ejs_ldbDelete); - mprSetCFunction(ldb, "rename", ejs_ldbRename); - mprSetCFunction(ldb, "errstring", ejs_ldbErrstring); - mprSetCFunction(ldb, "encode", ejs_base64encode); - mprSetCFunction(ldb, "decode", ejs_base64decode); - mprSetCFunction(ldb, "dn_escape", ejs_dn_escape); - mprSetCFunction(ldb, "close", ejs_ldbClose); - mprSetCFunction(ldb, "transaction_start", ejs_ldbTransactionStart); - mprSetCFunction(ldb, "transaction_cancel", ejs_ldbTransactionCancel); - mprSetCFunction(ldb, "transaction_commit", ejs_ldbTransactionCommit); - mprSetStringCFunction(ldb, "attach_dsdb_schema_from_ldif", - ejs_ldb_attach_dsdb_schema_from_ldif); - mprSetStringCFunction(ldb, "set_ntds_invocationId", - ejs_ldb_set_ntds_invocationId); - mprSetStringCFunction(ldb, "set_ntds_objectGUID", - ejs_ldb_set_ntds_objectGUID); - mprSetStringCFunction(ldb, "set_domain_sid", - ejs_ldb_set_domain_sid); - mprSetVar(ldb, "SCOPE_BASE", mprCreateNumberVar(LDB_SCOPE_BASE)); - mprSetVar(ldb, "SCOPE_ONE", mprCreateNumberVar(LDB_SCOPE_ONELEVEL)); - mprSetVar(ldb, "SCOPE_SUBTREE", mprCreateNumberVar(LDB_SCOPE_SUBTREE)); - mprSetVar(ldb, "SCOPE_DEFAULT", mprCreateNumberVar(LDB_SCOPE_DEFAULT)); - - return 0; -} - - -/* - setup C functions that be called from ejs -*/ -NTSTATUS smb_setup_ejs_ldb(void) -{ - ejsDefineCFunction(-1, "ldb_init", ejs_ldb_init, NULL, MPR_VAR_SCRIPT_HANDLE); - return NT_STATUS_OK; -} diff --git a/source4/scripting/ejs/smbcalls_options.c b/source4/scripting/ejs/smbcalls_options.c deleted file mode 100644 index 93872baa40..0000000000 --- a/source4/scripting/ejs/smbcalls_options.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide a command line options parsing function for ejs - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "lib/cmdline/popt_common.h" -#include "scripting/ejs/smbcalls.h" - - -/* - usage: - options = GetOptions(argv, - "realm=s", - "enablexx", - "myint=i"); - - the special options POPT_COMMON_* options are recognised and replaced - with the Samba internal options - - resulting parsed options are placed in the options object - - additional command line arguments are placed in options.ARGV -*/ - -static int ejs_GetOptions(MprVarHandle eid, int argc, struct MprVar **argv) -{ - poptContext pc; - int opt; - struct { - const char *name; - struct poptOption *table; - const char *description; - } tables[] = { - { "POPT_AUTOHELP", poptHelpOptions, "Help options:" }, - { "POPT_COMMON_SAMBA", popt_common_samba, "Common Samba options:" }, - { "POPT_COMMON_CONNECTION", popt_common_connection, "Connection options:" }, - { "POPT_COMMON_CREDENTIALS", popt_common_credentials, "Authentication options:" }, - { "POPT_COMMON_VERSION", popt_common_version, "Common Samba options:" } - }; - - struct MprVar *options = mprInitObject(eid, "options", 0, NULL); - - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - struct poptOption *long_options = NULL; - int i, num_options = 0; - int opt_argc; - const char **opt_argv; - const char **opt_names = NULL; - const int BASE_OPTNUM = 0x100000; - - /* validate arguments */ - if (argc < 1 || argv[0]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "GetOptions invalid arguments"); - return -1; - } - - opt_argv = mprToArray(tmp_ctx, argv[0]); - opt_argc = str_list_length(opt_argv); - - long_options = talloc_array(tmp_ctx, struct poptOption, 1); - if (long_options == NULL) { - return -1; - } - - /* create the long_options array */ - for (i=1;itype != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "GetOptions string argument"); - return -1; - } - - long_options = talloc_realloc(tmp_ctx, long_options, - struct poptOption, num_options+2); - if (long_options == NULL) { - return -1; - } - ZERO_STRUCT(long_options[num_options]); - - /* see if its one of the special samba option tables */ - for (t=0;t= num_options + BASE_OPTNUM) { - char *err; - err = talloc_asprintf(tmp_ctx, "%s: %s", - poptBadOption(pc, POPT_BADOPTION_NOALIAS), - poptStrerror(opt)); - mprSetVar(options, "ERROR", mprString(err)); - talloc_free(tmp_ctx); - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - opt -= BASE_OPTNUM; - arg = poptGetOptArg(pc); - if (arg == NULL) { - mprSetVar(options, opt_names[opt], mprCreateBoolVar(1)); - } else if (long_options[opt].argInfo == POPT_ARG_INT) { - int v = strtol(arg, NULL, 0); - mprSetVar(options, opt_names[opt], mprCreateIntegerVar(v)); - } else { - mprSetVar(options, opt_names[opt], mprString(arg)); - } - } - - /* setup options.argv list */ - mprSetVar(options, "ARGV", mprList("ARGV", poptGetArgs(pc))); - - poptFreeContext(pc); - - talloc_free(tmp_ctx); - - /* setup methods */ - mprSetCFunction(options, "get_credentials", ejs_credentials_cmdline); - - return 0; -} - - - -/* - setup C functions that be called from ejs -*/ -void smb_setup_ejs_options(void) -{ - ejsDefineCFunction(-1, "GetOptions", ejs_GetOptions, NULL, MPR_VAR_SCRIPT_HANDLE); -} diff --git a/source4/scripting/ejs/smbcalls_string.c b/source4/scripting/ejs/smbcalls_string.c deleted file mode 100644 index 541303ff2d..0000000000 --- a/source4/scripting/ejs/smbcalls_string.c +++ /dev/null @@ -1,529 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - provide access to string functions - - Copyright (C) Andrew Tridgell 2005 - Copyright (C) Jelmer Vernooij 2005 (substr) - - 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 . -*/ - -#include "includes.h" -#include "scripting/ejs/smbcalls.h" -#include "lib/appweb/ejs/ejs.h" - -/* - usage: - var len = strlen(str); -*/ -static int ejs_strlen(MprVarHandle eid, int argc, char **argv) -{ - if (argc != 1) { - ejsSetErrorMsg(eid, "strlen invalid arguments"); - return -1; - } - mpr_Return(eid, mprCreateIntegerVar(strlen_m(argv[0]))); - return 0; -} - -/* - usage: - var s = strlower("UPPER"); -*/ -static int ejs_strlower(MprVarHandle eid, int argc, char **argv) -{ - char *s; - if (argc != 1) { - ejsSetErrorMsg(eid, "strlower invalid arguments"); - return -1; - } - s = strlower_talloc(mprMemCtx(), argv[0]); - mpr_Return(eid, mprString(s)); - talloc_free(s); - return 0; -} - -/* - usage: - var s = strupper("lower"); -*/ -static int ejs_strupper(MprVarHandle eid, int argc, char **argv) -{ - char *s; - if (argc != 1) { - ejsSetErrorMsg(eid, "strupper invalid arguments"); - return -1; - } - s = strupper_talloc(mprMemCtx(), argv[0]); - mpr_Return(eid, mprString(s)); - talloc_free(s); - return 0; -} - -/* - usage: - var s = strstr(string, substring); -*/ -static int ejs_strstr(MprVarHandle eid, int argc, char **argv) -{ - char *s; - if (argc != 2) { - ejsSetErrorMsg(eid, "strstr invalid arguments"); - return -1; - } - s = strstr(argv[0], argv[1]); - mpr_Return(eid, mprString(s)); - return 0; -} - -/* - usage: - var s = strspn(string, legal_chars_string); -*/ -static int ejs_strspn(MprVarHandle eid, int argc, char **argv) -{ - int len; - if (argc != 2) { - ejsSetErrorMsg(eid, "strspn invalid arguments"); - return -1; - } - len = strspn(argv[0], argv[1]); - mpr_Return(eid, mprCreateIntegerVar(len)); - return 0; -} - -/* - usage: - list = split(".", "a.foo.bar"); - list = split(".", "a.foo.bar", count); - - count is an optional count of how many splits to make - - NOTE: does not take a regular expression, unlike perl split() -*/ -static int ejs_split(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const char *separator, *s; - char *p; - struct MprVar ret; - int count = 0, maxcount=0; - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - if (argc < 2 || - argv[0]->type != MPR_TYPE_STRING || - argv[1]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "split invalid arguments"); - return -1; - } - separator = mprToString(argv[0]); - s = mprToString(argv[1]); - if (argc == 3) { - maxcount = mprToInt(argv[2]); - } - - ret = mprArray("list"); - - while ((p = strstr(s, separator))) { - char *s2 = talloc_strndup(tmp_ctx, s, (int)(p-s)); - mprAddArray(&ret, count++, mprString(s2)); - talloc_free(s2); - s = p + strlen(separator); - if (maxcount != 0 && count >= maxcount) { - break; - } - } - if (*s) { - mprAddArray(&ret, count++, mprString(s)); - } - talloc_free(tmp_ctx); - mpr_Return(eid, ret); - return 0; -} - -/* - usage: - str = substr(orig[, start_offset[, length]]); - - special cases: - if start_offset < 0 then start_offset+=strlen(orig) - if length < 0 then length+=strlen(orig)-start_offset - - (as found in many other languages) -*/ -static int ejs_substr(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int start_offset = 0; - int length = 0; - const char *orig; - char *target; - - if (argc < 1 || argc > 3 || - argv[0]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "substr invalid arguments"); - return -1; - } - - if (argc == 1) { - mpr_Return(eid, *argv[0]); - return 0; - } - - orig = mprToString(argv[0]); - start_offset = mprToInt(argv[1]); - length = strlen(orig); - if (start_offset < 0) start_offset += strlen(orig); - if (start_offset < 0 || start_offset > strlen(orig)) { - ejsSetErrorMsg(eid, "substr arg 2 out of bounds ([%s], %d)", orig, start_offset); - return -1; - } - - if (argc == 3) { - length = mprToInt(argv[2]); - if (length < 0) length += strlen(orig) - start_offset; - if (length < 0 || length+start_offset > strlen(orig)) { - ejsSetErrorMsg(eid, "substr arg 3 out of bounds ([%s], %d, %d)", orig, start_offset, length); - return -1; - } - } - - target = talloc_strndup(mprMemCtx(), orig+start_offset, length); - - mpr_Return(eid, mprString(target)); - - talloc_free(target); - - return 0; -} - -/* - usage: - str = join("DC=", list); -*/ -static int ejs_join(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int i; - const char *separator; - char *ret = NULL; - const char **list; - TALLOC_CTX *tmp_ctx = talloc_new(mprMemCtx()); - if (argc != 2 || - argv[0]->type != MPR_TYPE_STRING || - argv[1]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "join invalid arguments"); - return -1; - } - - separator = mprToString(argv[0]); - list = mprToArray(tmp_ctx, argv[1]); - - if (list == NULL || list[0] == NULL) { - talloc_free(tmp_ctx); - mpr_Return(eid, mprString(NULL)); - return 0; - } - - ret = talloc_strdup(tmp_ctx, list[0]); - if (ret == NULL) { - goto failed; - } - for (i=1;list[i];i++) { - ret = talloc_asprintf_append_buffer(ret, "%s%s", separator, list[i]); - if (ret == NULL) { - goto failed; - } - } - mpr_Return(eid, mprString(ret)); - talloc_free(tmp_ctx); - return 0; -failed: - ejsSetErrorMsg(eid, "out of memory"); - return -1; -} - - -/* - blergh, C certainly makes this hard! - usage: - str = sprintf("i=%d s=%7s", 7, "foo"); -*/ -typedef char *(*_asprintf_append_t)(char *, const char *, ...); -static int ejs_sprintf(MprVarHandle eid, int argc, struct MprVar **argv) -{ - const char *format; - const char *p; - char *ret; - int a = 1; - _asprintf_append_t _asprintf_append; - TALLOC_CTX *tmp_ctx; - if (argc < 1 || argv[0]->type != MPR_TYPE_STRING) { - ejsSetErrorMsg(eid, "sprintf invalid arguments"); - return -1; - } - format = mprToString(argv[0]); - tmp_ctx = talloc_new(mprMemCtx()); - ret = talloc_strdup(tmp_ctx, ""); - - /* avoid all the format string warnings */ - _asprintf_append = (_asprintf_append_t)talloc_asprintf_append_buffer; - - /* - hackity hack ... - */ - while ((p = strchr(format, '%'))) { - char *fmt2; - int len, len_count=0; - char *tstr; - ret = talloc_asprintf_append_buffer(ret, "%*.*s", - (int)(p-format), (int)(p-format), - format); - if (ret == NULL) goto failed; - format += (int)(p-format); - len = strcspn(p+1, "dxuiofgGpXeEFcs%") + 1; - fmt2 = talloc_strndup(tmp_ctx, p, len+1); - if (fmt2 == NULL) goto failed; - len_count = count_chars(fmt2, '*'); - /* find the type string */ - tstr = &fmt2[len]; - while (tstr > fmt2 && isalpha((unsigned char)tstr[-1])) { - tstr--; - } - if (strcmp(tstr, "%") == 0) { - ret = talloc_asprintf_append_buffer(ret, "%%"); - if (ret == NULL) { - goto failed; - } - format += len+1; - continue; - } - if (len_count > 2 || - argc < a + len_count + 1) { - ejsSetErrorMsg(eid, "sprintf: not enough arguments for format"); - goto failed; - } -#define FMT_ARG(fn, type) do { \ - switch (len_count) { \ - case 0: \ - ret = _asprintf_append(ret, fmt2, \ - (type)fn(argv[a])); \ - break; \ - case 1: \ - ret = _asprintf_append(ret, fmt2, \ - (int)mprVarToNumber(argv[a]), \ - (type)fn(argv[a+1])); \ - break; \ - case 2: \ - ret = _asprintf_append(ret, fmt2, \ - (int)mprVarToNumber(argv[a]), \ - (int)mprVarToNumber(argv[a+1]), \ - (type)fn(argv[a+2])); \ - break; \ - } \ - a += len_count + 1; \ - if (ret == NULL) { \ - goto failed; \ - } \ -} while (0) - - if (strcmp(tstr, "s")==0) FMT_ARG(mprToString, const char *); - else if (strcmp(tstr, "c")==0) FMT_ARG(*mprToString, char); - else if (strcmp(tstr, "d")==0) FMT_ARG(mprVarToNumber, int); - else if (strcmp(tstr, "ld")==0) FMT_ARG(mprVarToNumber, long); - else if (strcmp(tstr, "lld")==0) FMT_ARG(mprVarToNumber, long long); - else if (strcmp(tstr, "x")==0) FMT_ARG(mprVarToNumber, int); - else if (strcmp(tstr, "lx")==0) FMT_ARG(mprVarToNumber, long); - else if (strcmp(tstr, "llx")==0) FMT_ARG(mprVarToNumber, long long); - else if (strcmp(tstr, "X")==0) FMT_ARG(mprVarToNumber, int); - else if (strcmp(tstr, "lX")==0) FMT_ARG(mprVarToNumber, long); - else if (strcmp(tstr, "llX")==0) FMT_ARG(mprVarToNumber, long long); - else if (strcmp(tstr, "u")==0) FMT_ARG(mprVarToNumber, int); - else if (strcmp(tstr, "lu")==0) FMT_ARG(mprVarToNumber, long); - else if (strcmp(tstr, "llu")==0) FMT_ARG(mprVarToNumber, long long); - else if (strcmp(tstr, "i")==0) FMT_ARG(mprVarToNumber, int); - else if (strcmp(tstr, "li")==0) FMT_ARG(mprVarToNumber, long); - else if (strcmp(tstr, "lli")==0) FMT_ARG(mprVarToNumber, long long); - else if (strcmp(tstr, "o")==0) FMT_ARG(mprVarToNumber, int); - else if (strcmp(tstr, "lo")==0) FMT_ARG(mprVarToNumber, long); - else if (strcmp(tstr, "llo")==0) FMT_ARG(mprVarToNumber, long long); - else if (strcmp(tstr, "f")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "lf")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "g")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "lg")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "e")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "le")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "E")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "lE")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "F")==0) FMT_ARG(mprVarToFloat, double); - else if (strcmp(tstr, "lF")==0) FMT_ARG(mprVarToFloat, double); - else { - ejsSetErrorMsg(eid, "sprintf: unknown format string '%s'", fmt2); - goto failed; - } - format += len+1; - } - - ret = talloc_asprintf_append_buffer(ret, "%s", format); - mpr_Return(eid, mprString(ret)); - talloc_free(tmp_ctx); - return 0; - -failed: - talloc_free(tmp_ctx); - return -1; -} - -/* - used to build your own print function - str = vsprintf(args); -*/ -static int ejs_vsprintf(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct MprVar **args, *len, *v; - int i, ret, length; - if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) { - ejsSetErrorMsg(eid, "vsprintf invalid arguments"); - return -1; - } - v = argv[0]; - len = mprGetProperty(v, "length", NULL); - if (len == NULL) { - ejsSetErrorMsg(eid, "vsprintf takes an array"); - return -1; - } - length = mprToInt(len); - args = talloc_array(mprMemCtx(), struct MprVar *, length); - if (args == NULL) { - return -1; - } - - for (i=0;i. -*/ - -#include "includes.h" -#include "scripting/ejs/smbcalls.h" -#include "lib/appweb/ejs/ejs.h" -#include "lib/ldb/include/ldb.h" -#include "system/time.h" -#include "system/network.h" -#include "lib/socket/netif.h" - -/* - return the list of configured network interfaces -*/ -static int ejs_sys_interfaces(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int i, count; - struct MprVar ret = mprArray("interfaces"); - struct interface *ifaces; - - load_interfaces(NULL, lp_interfaces(mprLpCtx()), &ifaces); - - count = iface_count(ifaces); - for (i=0;itype)) { - ejsSetErrorMsg(eid, "sys_unix2nttime invalid arguments"); - return -1; - } - unix_to_nt_time(&nt, mprVarToNumber(argv[0])); - v = mprCreateNumberVar(nt); - mpr_Return(eid, v); - return 0; -} - -/* - return the GMT time represented by the struct tm argument, as a time_t value -*/ -static int ejs_sys_gmmktime(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct MprVar *o; - struct tm tm; - if (argc != 1 || !mprVarIsObject(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_gmmktime invalid arguments"); - return -1; - } - - o = argv[0]; -#define TM_EL(n) tm.n = mprVarToNumber(mprGetProperty(o, #n, NULL)) - TM_EL(tm_sec); - TM_EL(tm_min); - TM_EL(tm_hour); - TM_EL(tm_mday); - TM_EL(tm_mon); - TM_EL(tm_year); - TM_EL(tm_wday); - TM_EL(tm_yday); - TM_EL(tm_isdst); -#undef TM_EL - - mpr_Return(eid, mprCreateIntegerVar(mktime(&tm))); - return 0; -} - -/* - return the given time as a gmtime structure -*/ -static int ejs_sys_gmtime(MprVarHandle eid, int argc, struct MprVar **argv) -{ - time_t t; - struct MprVar ret; - struct tm *tm; - if (argc != 1 || !mprVarIsNumber(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_gmtime invalid arguments"); - return -1; - } - t = (time_t) mprVarToNumber(argv[0]); - tm = gmtime(&t); - if (tm == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - ret = mprObject("gmtime"); -#define TM_EL(n) mprSetVar(&ret, #n, mprCreateIntegerVar(tm->n)) - TM_EL(tm_sec); - TM_EL(tm_min); - TM_EL(tm_hour); - TM_EL(tm_mday); - TM_EL(tm_mon); - TM_EL(tm_year); - TM_EL(tm_wday); - TM_EL(tm_yday); - TM_EL(tm_isdst); -#undef TM_EL - - mpr_Return(eid, ret); - return 0; -} - -/* - return the given NT time as a time_t value -*/ -static int ejs_sys_nttime2unix(MprVarHandle eid, int argc, struct MprVar **argv) -{ - time_t t; - struct MprVar v; - if (argc != 1 || !mprVarIsNumber(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_ntgmtime invalid arguments"); - return -1; - } - t = nt_time_to_unix(mprVarToNumber(argv[0])); - v = mprCreateNumberVar(t); - mpr_Return(eid, v); - return 0; -} - -/* - return the given NT time as a gmtime structure -*/ -static int ejs_sys_ntgmtime(MprVarHandle eid, int argc, struct MprVar **argv) -{ - time_t t; - struct MprVar ret; - struct tm *tm; - if (argc != 1 || !mprVarIsNumber(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_ntgmtime invalid arguments"); - return -1; - } - t = nt_time_to_unix(mprVarToNumber(argv[0])); - tm = gmtime(&t); - if (tm == NULL) { - mpr_Return(eid, mprCreateUndefinedVar()); - return 0; - } - ret = mprObject("gmtime"); -#define TM_EL(n) mprSetVar(&ret, #n, mprCreateIntegerVar(tm->n)) - TM_EL(tm_sec); - TM_EL(tm_min); - TM_EL(tm_hour); - TM_EL(tm_mday); - TM_EL(tm_mon); - TM_EL(tm_year); - TM_EL(tm_wday); - TM_EL(tm_yday); - TM_EL(tm_isdst); -#undef TM_EL - - mpr_Return(eid, ret); - return 0; -} - -/* - return a ldap time string from a nttime -*/ -static int ejs_sys_ldaptime(MprVarHandle eid, int argc, struct MprVar **argv) -{ - char *s; - time_t t; - if (argc != 1 || !mprVarIsNumber(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_ldaptime invalid arguments"); - return -1; - } - t = nt_time_to_unix(mprVarToNumber(argv[0])); - s = ldb_timestring(mprMemCtx(), t); - mpr_Return(eid, mprString(s)); - talloc_free(s); - return 0; -} - -/* - return a http time string from a nttime -*/ -static int ejs_sys_httptime(MprVarHandle eid, int argc, struct MprVar **argv) -{ - char *s; - time_t t; - if (argc != 1 || !mprVarIsNumber(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_httptime invalid arguments"); - return -1; - } - t = nt_time_to_unix(mprVarToNumber(argv[0])); - s = http_timestring(mprMemCtx(), t); - mpr_Return(eid, mprString(s)); - talloc_free(s); - return 0; -} - -/* - unlink a file - ok = sys.unlink(fname); -*/ -static int ejs_sys_unlink(MprVarHandle eid, int argc, char **argv) -{ - int ret; - if (argc != 1) { - ejsSetErrorMsg(eid, "sys_unlink invalid arguments"); - return -1; - } - ret = unlink(argv[0]); - mpr_Return(eid, mprCreateBoolVar(ret == 0)); - return 0; -} - -/* - load a file as a string - usage: - string = sys.file_load(filename); -*/ -static int ejs_sys_file_load(MprVarHandle eid, int argc, char **argv) -{ - char *s; - if (argc != 1) { - ejsSetErrorMsg(eid, "sys_file_load invalid arguments"); - return -1; - } - - s = file_load(argv[0], NULL, mprMemCtx()); - mpr_Return(eid, mprString(s)); - talloc_free(s); - return 0; -} - -/* - save a file from a string - usage: - ok = sys.file_save(filename, str); -*/ -static int ejs_sys_file_save(MprVarHandle eid, int argc, char **argv) -{ - bool ret; - if (argc != 2) { - ejsSetErrorMsg(eid, "sys_file_save invalid arguments"); - return -1; - } - ret = file_save(argv[0], argv[1], strlen(argv[1])); - mpr_Return(eid, mprCreateBoolVar(ret)); - return 0; -} - -/* - mkdir() - usage: - ok = sys.mkdir(dirname, mode); -*/ -static int ejs_sys_mkdir(MprVarHandle eid, int argc, struct MprVar **argv) -{ - bool ret; - char *name; - if (argc != 2) { - ejsSetErrorMsg(eid, "sys_mkdir invalid arguments, need mkdir(dirname, mode)"); - return -1; - } - if (!mprVarIsString(argv[0]->type)) { - ejsSetErrorMsg(eid, "sys_mkdir dirname not a string"); - return -1; - } - if (!mprVarIsNumber(argv[1]->type)) { - ejsSetErrorMsg(eid, "sys_mkdir mode not a number"); - return -1; - } - mprVarToString(&name, 0, NULL, argv[0]); - ret = mkdir(name, mprVarToNumber(argv[1])); - mpr_Return(eid, mprCreateBoolVar(ret == 0)); - return 0; -} - - -/* - return fields of a stat() call -*/ -static struct MprVar mpr_stat(struct stat *st) -{ - struct MprVar ret; - ret = mprObject("stat"); - -#define ST_EL(n) mprSetVar(&ret, #n, mprCreateNumberVar(st->n)) - ST_EL(st_dev); - ST_EL(st_ino); - ST_EL(st_mode); - ST_EL(st_nlink); - ST_EL(st_uid); - ST_EL(st_gid); - ST_EL(st_rdev); - ST_EL(st_size); - ST_EL(st_blksize); - ST_EL(st_blocks); - ST_EL(st_atime); - ST_EL(st_mtime); - ST_EL(st_ctime); - - return ret; -} - -/* - usage: - var st = sys.stat(filename); - returns an object containing struct stat elements -*/ -static int ejs_sys_stat(MprVarHandle eid, int argc, char **argv) -{ - struct stat st; - /* validate arguments */ - if (argc != 1) { - ejsSetErrorMsg(eid, "sys.stat invalid arguments"); - return -1; - } - if (stat(argv[0], &st) != 0) { - mpr_Return(eid, mprCreateUndefinedVar()); - } else { - mpr_Return(eid, mpr_stat(&st)); - } - return 0; -} - -/* - usage: - var st = sys.lstat(filename); - returns an object containing struct stat elements -*/ -static int ejs_sys_lstat(MprVarHandle eid, int argc, char **argv) -{ - struct stat st; - /* validate arguments */ - if (argc != 1) { - ejsSetErrorMsg(eid, "sys.stat invalid arguments"); - return -1; - } - if (lstat(argv[0], &st) != 0) { - mpr_Return(eid, mprCreateUndefinedVar()); - } else { - mpr_Return(eid, mpr_stat(&st)); - } - return 0; -} - -/* - bitwise AND - usage: - var z = sys.bitAND(x, 0x70); -*/ -static int ejs_sys_bitAND(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int x, y, z; - - if (argc != 2 || - !mprVarIsNumber(argv[0]->type) || - !mprVarIsNumber(argv[1]->type)) { - ejsSetErrorMsg(eid, "bitand invalid arguments"); - return -1; - } - x = mprToInt(argv[0]); - y = mprToInt(argv[1]); - z = x & y; - - mpr_Return(eid, mprCreateIntegerVar(z)); - return 0; -} - -/* - bitwise OR - usage: - var z = sys.bitOR(x, 0x70); -*/ -static int ejs_sys_bitOR(MprVarHandle eid, int argc, struct MprVar **argv) -{ - int x, y, z; - - if (argc != 2 || - !mprVarIsNumber(argv[0]->type) || - !mprVarIsNumber(argv[1]->type)) { - ejsSetErrorMsg(eid, "bitand invalid arguments"); - return -1; - } - x = mprToInt(argv[0]); - y = mprToInt(argv[1]); - z = x | y; - - mpr_Return(eid, mprCreateIntegerVar(z)); - return 0; -} - -/* - initialise sys ejs subsystem -*/ -static int ejs_sys_init(MprVarHandle eid, int argc, struct MprVar **argv) -{ - struct MprVar *obj = mprInitObject(eid, "sys", argc, argv); - - mprSetCFunction(obj, "interfaces", ejs_sys_interfaces); - mprSetCFunction(obj, "hostname", ejs_sys_hostname); - mprSetCFunction(obj, "nttime", ejs_sys_nttime); - mprSetCFunction(obj, "gettimeofday", ejs_sys_gettimeofday); - mprSetCFunction(obj, "unix2nttime", ejs_sys_unix2nttime); - mprSetCFunction(obj, "gmmktime", ejs_sys_gmmktime); - mprSetCFunction(obj, "gmtime", ejs_sys_gmtime); - mprSetCFunction(obj, "nttime2unix", ejs_sys_nttime2unix); - mprSetCFunction(obj, "ntgmtime", ejs_sys_ntgmtime); - mprSetCFunction(obj, "ldaptime", ejs_sys_ldaptime); - mprSetCFunction(obj, "httptime", ejs_sys_httptime); - mprSetCFunction(obj, "mkdir", ejs_sys_mkdir); - mprSetStringCFunction(obj, "unlink", ejs_sys_unlink); - mprSetStringCFunction(obj, "file_load", ejs_sys_file_load); - mprSetStringCFunction(obj, "file_save", ejs_sys_file_save); - mprSetStringCFunction(obj, "stat", ejs_sys_stat); - mprSetStringCFunction(obj, "lstat", ejs_sys_lstat); - mprSetCFunction(obj, "bitAND", ejs_sys_bitAND); - mprSetCFunction(obj, "bitOR", ejs_sys_bitOR); - - return 0; -} - - -/* - setup C functions that be called from ejs -*/ -NTSTATUS smb_setup_ejs_system(void) -{ - ejsDefineCFunction(-1, "sys_init", ejs_sys_init, NULL, MPR_VAR_SCRIPT_HANDLE); - return NT_STATUS_OK; -} diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c deleted file mode 100644 index db9fc9affa..0000000000 --- a/source4/scripting/ejs/smbscript.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Standalone client for ejs scripting. - - Copyright (C) Tim Potter 2005 - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "lib/appweb/ejs/ejs.h" -#include "lib/appweb/ejs/ejsInternal.h" -#include "scripting/ejs/smbcalls.h" -#include "auth/gensec/gensec.h" -#include "ldb/include/ldb.h" -#include "dynconfig/dynconfig.h" - -static EjsId eid; - -_NORETURN_ static void smbscript_ejs_exception(const char *reason) -{ - Ejs *ep = ejsPtr(eid); - ejsSetErrorMsg(eid, "%s", reason); - fprintf(stderr, "%s", ep->error); - exit(127); -} - -int main(int argc, const char **argv) -{ - EjsHandle handle = 0; - MprVar result; - char *emsg, *script; - size_t script_size; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - const char **argv_list = NULL; - const char *fname; - struct MprVar *return_var; - int exit_status, i; - struct loadparm_context *lp_ctx; - - fault_setup(argv[0]); - - global_loadparm = lp_ctx = loadparm_init(talloc_autofree_context()); - - if (getenv("SMB_CONF_PATH")) { - lp_load(lp_ctx, getenv("SMB_CONF_PATH")); - } else { - lp_load(lp_ctx, dyn_CONFIGFILE); - } - - gensec_init(lp_ctx); - mprSetCtx(mem_ctx); - - - if (argc < 2) { - fprintf(stderr, "You must supply a script name\n"); - exit(1); - } - - fname = argv[1]; - - if (ejsOpen(NULL, NULL, NULL) != 0) { - fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " - "EJS subsystem\n"); - exit(127); - } - - smb_setup_ejs_functions(smbscript_ejs_exception); - - if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { - fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " - "initialise an EJS engine\n"); - exit(127); - } - - /* setup ARGV[] in the ejs environment */ - for (i=1;argv[i];i++) { - argv_list = str_list_add(argv_list, argv[i]); - } - talloc_steal(mem_ctx, argv_list); - mprSetVar(ejsGetGlobalObject(eid), "ARGV", mprList("ARGV", argv_list)); - - /* load the script and advance past interpreter line*/ - script = file_load(fname, &script_size, mem_ctx); - - if (!script) { - fprintf(stderr, "Unable to load script from '%s'\n", fname); - exit(1); - } - - /* allow scriptable js */ - if (strncmp(script, "#!", 2) == 0) { - script += strcspn(script, "\r\n"); - script += strspn(script, "\r\n"); - } - /* and this copes with the ugly exec hack */ - if (strncmp(script, "exec ", 5) == 0) { - script += strcspn(script, "\r\n"); - script += strspn(script, "\r\n"); - } - - /* run the script */ - if (ejsEvalScript(eid, script, &result, &emsg) == -1) { - fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); - exit(127); - } - - return_var = ejsGetReturnValue(eid); - exit_status = mprVarToNumber(return_var); - - ejsClose(); - - talloc_free(mem_ctx); - - return exit_status; -} diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js deleted file mode 100644 index 790dfeb3e0..0000000000 --- a/source4/scripting/libjs/base.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - base js library functions - Copyright Andrew Tridgell 2005 - released under the GNU GPL version 3 or later -*/ - -if (global["HAVE_BASE_JS"] != undefined) { - return; -} -HAVE_BASE_JS=1 - -/* bring the string functions into the global frame */ -string_init(global); - -/* - an essential function! -*/ -function printf() -{ - print(vsprintf(arguments)); -} - -/* - substitute strings of the form ${NAME} in str, replacing - with substitutions from subobj -*/ -function substitute_var(str, subobj) -{ - var list = split("${", str); - var i; - for (i=1;i - ],[ - Py_InitModule(NULL, NULL); - ],[ - PYTHON_LDFLAGS="$1" - PYTHON_CFLAGS="$2" - working_python=yes - ]) - LIBS="$ac_save_LIBS" - CFLAGS="$ac_save_CFLAGS" - fi -]) - -dnl assume no working python -working_python=no - -if test -z "$PYTHON_VERSION"; then - AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) -else - AC_PATH_PROG([PYTHON_CONFIG], [python[$PYTHON_VERSION]-config]) -fi - -if test -z "$PYTHON_CONFIG"; then - AC_MSG_WARN([No python-config found]) -else - TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`]) - TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --cflags`]) - if x$working_python = xno; then - # It seems the library path isn't included on some systems - base=`$PYTHON_CONFIG --prefix` - TRY_LINK_PYTHON([`echo -n -L${base}/lib " "; $PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`]) - TRY_LINK_PYTHON([`echo -n -L${base}/lib " "; $PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --cflags`]) - fi -fi - -if test x$PYTHON != x -then - DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=1), sysconfig.get_config_var('CFLAGS'))"` - DISTUTILS_LDFLAGS=`$PYTHON -c "from distutils import sysconfig; print '%s %s -lpython%s -L%s' % (sysconfig.get_config_var('LIBS'), sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('LIBPL'))"` - TRY_LINK_PYTHON($DISTUTILS_LDFLAGS, $DISTUTILS_CFLAGS) -fi - -SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS]) - -AC_MSG_CHECKING(working python module support) -if test $working_python = yes; then - SMB_ENABLE(EXT_LIB_PYTHON,YES) - SMB_ENABLE(LIBPYTHON,YES) - AC_MSG_RESULT([yes]) -else - AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.]) -fi - -AC_MSG_CHECKING(python library directory) -pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1, 0, '\\${prefix}')"` -AC_MSG_RESULT($pythondir) - -AC_SUBST(pythondir) diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index b494ee6e8d..c88728a9fd 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -23,7 +23,7 @@ python_misc_OBJ_FILES = $(pyscriptsrcdir)/misc_wrap.o $(python_misc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) -_PY_FILES = $(shell find $(pyscriptsrcdir)/samba $(pyscriptsrcdir)/subunit -name "*.py") +_PY_FILES = $(shell find $(pyscriptsrcdir)/samba ../lib/subunit/python -name "*.py") $(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst $(pyscriptsrcdir)/%,%,$(pyfile)),$(pyfile)))) @@ -32,6 +32,6 @@ $(eval $(call python_py_module_template,samba/misc.py,$(pyscriptsrcdir)/misc.py) EPYDOC_OPTIONS = --no-private --url http://www.samba.org/ --no-sourcecode epydoc:: pythonmods - PYTHONPATH=$(pythonbuilddir) epydoc $(EPYDOC_OPTIONS) samba tdb ldb subunit + PYTHONPATH=$(pythonbuilddir):../lib/subunit/python epydoc $(EPYDOC_OPTIONS) samba tdb ldb subunit install:: installpython diff --git a/source4/scripting/python/misc.i b/source4/scripting/python/misc.i index 81be7d5c16..f40e88c6cd 100644 --- a/source4/scripting/python/misc.i +++ b/source4/scripting/python/misc.i @@ -31,7 +31,7 @@ %import "stdint.i" %include "exception.i" -%import "../../lib/talloc/talloc.i" +%import "../../../lib/talloc/talloc.i" %import "../../lib/ldb/ldb.i" %import "../../auth/credentials/credentials.i" %import "../../param/param.i" diff --git a/source4/scripting/python/misc_wrap.c b/source4/scripting/python/misc_wrap.c index 3aee83f72c..b669f3e801 100644 --- a/source4/scripting/python/misc_wrap.c +++ b/source4/scripting/python/misc_wrap.c @@ -2494,24 +2494,26 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) #define SWIGTYPE_p_ldb_ldif swig_types[8] #define SWIGTYPE_p_ldb_message swig_types[9] #define SWIGTYPE_p_ldb_message_element swig_types[10] -#define SWIGTYPE_p_ldb_result swig_types[11] -#define SWIGTYPE_p_loadparm_context swig_types[12] -#define SWIGTYPE_p_loadparm_service swig_types[13] -#define SWIGTYPE_p_long_long swig_types[14] -#define SWIGTYPE_p_param_context swig_types[15] -#define SWIGTYPE_p_param_opt swig_types[16] -#define SWIGTYPE_p_param_section swig_types[17] -#define SWIGTYPE_p_security_descriptor swig_types[18] -#define SWIGTYPE_p_security_token swig_types[19] -#define SWIGTYPE_p_short swig_types[20] -#define SWIGTYPE_p_signed_char swig_types[21] -#define SWIGTYPE_p_unsigned_char swig_types[22] -#define SWIGTYPE_p_unsigned_int swig_types[23] -#define SWIGTYPE_p_unsigned_long swig_types[24] -#define SWIGTYPE_p_unsigned_long_long swig_types[25] -#define SWIGTYPE_p_unsigned_short swig_types[26] -static swig_type_info *swig_types[28]; -static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0}; +#define SWIGTYPE_p_ldb_module swig_types[11] +#define SWIGTYPE_p_ldb_parse_tree swig_types[12] +#define SWIGTYPE_p_ldb_result swig_types[13] +#define SWIGTYPE_p_loadparm_context swig_types[14] +#define SWIGTYPE_p_loadparm_service swig_types[15] +#define SWIGTYPE_p_long_long swig_types[16] +#define SWIGTYPE_p_param_context swig_types[17] +#define SWIGTYPE_p_param_opt swig_types[18] +#define SWIGTYPE_p_param_section swig_types[19] +#define SWIGTYPE_p_security_descriptor swig_types[20] +#define SWIGTYPE_p_security_token swig_types[21] +#define SWIGTYPE_p_short swig_types[22] +#define SWIGTYPE_p_signed_char swig_types[23] +#define SWIGTYPE_p_unsigned_char swig_types[24] +#define SWIGTYPE_p_unsigned_int swig_types[25] +#define SWIGTYPE_p_unsigned_long swig_types[26] +#define SWIGTYPE_p_unsigned_long_long swig_types[27] +#define SWIGTYPE_p_unsigned_short swig_types[28] +static swig_type_info *swig_types[30]; +static swig_module_info swig_module = {swig_types, 29, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -3340,6 +3342,8 @@ static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn * static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_module = {"_p_ldb_module", "struct ldb_module *|ldb_module *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_parse_tree = {"_p_ldb_parse_tree", "struct ldb_parse_tree *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0}; @@ -3369,6 +3373,8 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_ldb_ldif, &_swigt__p_ldb_message, &_swigt__p_ldb_message_element, + &_swigt__p_ldb_module, + &_swigt__p_ldb_parse_tree, &_swigt__p_ldb_result, &_swigt__p_loadparm_context, &_swigt__p_loadparm_service, @@ -3398,6 +3404,8 @@ static swig_cast_info _swigc__p_ldb_dn[] = { {&_swigt__p_ldb_dn, 0, 0, 0},{0, 0 static swig_cast_info _swigc__p_ldb_ldif[] = { {&_swigt__p_ldb_ldif, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_message[] = { {&_swigt__p_ldb_message, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_message_element, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_module[] = { {&_swigt__p_ldb_module, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_parse_tree[] = { {&_swigt__p_ldb_parse_tree, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}}; @@ -3427,6 +3435,8 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_ldb_ldif, _swigc__p_ldb_message, _swigc__p_ldb_message_element, + _swigc__p_ldb_module, + _swigc__p_ldb_parse_tree, _swigc__p_ldb_result, _swigc__p_loadparm_context, _swigc__p_loadparm_service, diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 0fe15b2fda..e53f4cfaf2 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -18,6 +18,7 @@ */ #include "includes.h" +#include "scripting/python/modules.h" #include extern void init_ldb(void); diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 68f61532ad..823d5e6ff6 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -465,6 +465,7 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, "objectclass", "samldb", "kludge_acl", + "password_hash", "operational"] tdb_modules_list = [ "subtree_rename", @@ -516,7 +517,7 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, "DOMAINDN_LDB": domaindn_ldb, "SCHEMADN_MOD": "schema_fsmo,instancetype", "CONFIGDN_MOD": "naming_fsmo,instancetype", - "DOMAINDN_MOD": "pdc_fsmo,password_hash,instancetype", + "DOMAINDN_MOD": "pdc_fsmo,instancetype", "MODULES_LIST": ",".join(modules_list), "TDB_MODULES_LIST": tdb_modules_list_as_string, "MODULES_LIST2": ",".join(modules_list2), @@ -744,6 +745,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, samdb = SamDB(path, session_info=session_info, credentials=credentials, lp=lp) + if fill == FILL_DRS: + return samdb message("Pre-loading the Samba 4 and AD schema") samdb.set_domain_sid(domainsid) @@ -956,13 +959,16 @@ def provision(setup_dir, message, session_info, paths = provision_paths_from_lp(lp, names.dnsdomain) if hostip is None: - hostip = socket.getaddrinfo(names.hostname, None, socket.AF_INET, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0] + try: + hostip = socket.getaddrinfo(names.hostname, None, socket.AF_INET, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0] + except socket.gaierror, (socket.EAI_NODATA, msg): + hostip = None if hostip6 is None: try: hostip6 = socket.getaddrinfo(names.hostname, None, socket.AF_INET6, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0] - except socket.gaierror: - pass + except socket.gaierror, (socket.EAI_NODATA, msg): + hostip6 = None if serverrole is None: serverrole = lp.get("server role") @@ -1423,12 +1429,20 @@ def create_zone_file(path, setup_path, dnsdomain, domaindn, hostip6_base_line = "" hostip6_host_line = "" + if hostip is not None: + hostip_base_line = " IN A " + hostip + hostip_host_line = hostname + " IN A " + hostip + else: + hostip_base_line = "" + hostip_host_line = "" + setup_file(setup_path("provision.zone"), path, { "DNSPASS_B64": b64encode(dnspass), "HOSTNAME": hostname, "DNSDOMAIN": dnsdomain, "REALM": realm, - "HOSTIP": hostip, + "HOSTIP_BASE_LINE": hostip_base_line, + "HOSTIP_HOST_LINE": hostip_host_line, "DOMAINGUID": domainguid, "DATESTRING": time.strftime("%Y%m%d%H"), "DEFAULTSITE": DEFAULTSITE, diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index 5503a42cdd..74c177d8e8 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -2,12 +2,12 @@ TEST_FORMAT = plain SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(selftestdir)/selftest.pl --prefix=${selftest_prefix} \ --builddir=$(builddir) --srcdir=$(srcdir) \ - --expected-failures=$(srcdir)/samba4-knownfail \ + --expected-failures=$(srcdir)/selftest/knownfail \ --format=$(TEST_FORMAT) \ - --exclude=$(srcdir)/samba4-skip --testlist="./selftest/samba4_tests.sh|" \ + --exclude=$(srcdir)/selftest/skip --testlist="./selftest/tests.sh|" \ $(TEST_OPTIONS) -SELFTEST_NOSLOW_OPTS = --exclude=$(srcdir)/samba4-slow +SELFTEST_NOSLOW_OPTS = --exclude=$(srcdir)/selftest/slow SELFTEST_QUICK_OPTS = $(SELFTEST_NOSLOW_OPTS) --quick slowtest:: everything @@ -49,33 +49,39 @@ quicktestone:: all testenv:: everything $(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --socket-wrapper --testenv +testenv-%:: everything + SELFTEST_TESTENV=$* $(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --socket-wrapper --testenv + +test-%:: + $(MAKE) test TESTS=$* + valgrindtest:: valgrindtest-all valgrindtest-quick:: all - SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \ + SMBD_VALGRIND="xterm -n server -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \ VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ $(SELFTEST) $(SELFTEST_QUICK_OPTS) --immediate --socket-wrapper $(TESTS) valgrindtest-all:: everything - SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \ + SMBD_VALGRIND="xterm -n server -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \ VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ $(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS) valgrindtest-env:: everything - SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \ + SMBD_VALGRIND="xterm -n server -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \ VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ $(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --socket-wrapper --testenv gdbtest:: gdbtest-all gdbtest-quick:: all - SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \ + SMBD_VALGRIND="xterm -n server -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \ $(SELFTEST) $(SELFTEST_QUICK_OPTS) --immediate --socket-wrapper $(TESTS) gdbtest-all:: everything - SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \ + SMBD_VALGRIND="xterm -n server -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \ $(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS) gdbtest-env:: everything - SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \ + SMBD_VALGRIND="xterm -n server -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \ $(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --socket-wrapper --testenv diff --git a/source4/samba4-knownfail b/source4/selftest/knownfail similarity index 80% rename from source4/samba4-knownfail rename to source4/selftest/knownfail index ded7922ec9..f99db4fb1b 100644 --- a/source4/samba4-knownfail +++ b/source4/selftest/knownfail @@ -44,3 +44,9 @@ samba4.winbind.struct.*.SHOW_SEQUENCE # Not yet working in winbind samba4.winbind.struct.*.GETPWENT # Not yet working in winbind samba4.winbind.struct.*.SETPWENT # Not yet working in winbind samba4.winbind.struct.*.LOOKUP_NAME_SID # Not yet working in winbind +^samba4.*base.delaywrite.*update of write time and SMBwrite truncate$ +^samba4.*base.delaywrite.*update of write time and SMBwrite truncate expand$ +^samba4.*base.delaywrite.*delayed update of write time 3a$ +^samba4.*base.delaywrite.*delayed update of write time 3c$ +^samba4.*base.delaywrite.*update of write time using SET_END_OF_FILE$ +^samba4.*base.delaywrite.*update of write time using SET_ALLOCATION_SIZE$ diff --git a/source4/samba4-quick b/source4/selftest/quick similarity index 98% rename from source4/samba4-quick rename to source4/selftest/quick index 3627a87bbe..7bea619f18 100644 --- a/source4/samba4-quick +++ b/source4/selftest/quick @@ -35,3 +35,4 @@ rpc.altercontext rpc.join rpc.handles rpc.echo +smb.signing diff --git a/source4/samba4-skip b/source4/selftest/skip similarity index 94% rename from source4/samba4-skip rename to source4/selftest/skip index b1313adea0..e3e2d2d525 100644 --- a/source4/samba4-skip +++ b/source4/selftest/skip @@ -58,6 +58,4 @@ samba4.ntvfs.cifs.raw. ^samba4.net.domopen.*$ # Hangs for some reason ^samba4.net.api.become.dc.*$ # Fails nss.test # Fails -samba4.samba3sam.python # Conversion from EJS not yet finished raw.offline # Samba 4 doesn't have much offline support yet -winreg* #Does not authenticate against the target server diff --git a/source4/samba4-slow b/source4/selftest/slow similarity index 100% rename from source4/samba4-slow rename to source4/selftest/slow diff --git a/source4/selftest/test_win.sh b/source4/selftest/test_win.sh index bc40620af5..17c09e6b26 100755 --- a/source4/selftest/test_win.sh +++ b/source4/selftest/test_win.sh @@ -32,7 +32,7 @@ name="NET against Windows 2003" testit "$name" smb $WINTEST_DIR/wintest_net.sh $SMBTORTURE_REMOTE_HOST \ $SMBTORTURE_USERNAME $SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP -name="Windows 2003 against smbd" +name="Windows 2003 against samba" testit "$name" smb $WINTEST_DIR/wintest_client.sh $SMBTORTURE_REMOTE_HOST dc_tests="RPC-DRSUAPI ncacn_np ncacn_ip_tcp" diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/tests.sh similarity index 83% rename from source4/selftest/samba4_tests.sh rename to source4/selftest/tests.sh index 6f6ffbba60..49e8c2ef5d 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/tests.sh @@ -4,11 +4,11 @@ # The output of this script is parsed by selftest.pl, which then decides # which of the tests to actually run. It will, for example, skip all tests -# listed in samba4-skip or only run a subset during "make quicktest". +# listed in selftest/skip or only run a subset during "make quicktest". # The idea is that this script outputs all of the tests of Samba 4, not # just those that are known to pass, and list those that should be skipped -# or are known to file in samba4-skip/samba4-knownfail. This makes it +# or are known to fail in selftest/skip or selftest/knownfail. This makes it # very easy to see what functionality is still missing in Samba 4 and makes # it possible to run the testsuite against other servers, such as Samba 3 or # Windows that have a different set of features. @@ -23,8 +23,6 @@ then PERL=perl fi -incdir=`dirname $0` - plantest() { name=$1 env=$2 @@ -56,15 +54,36 @@ plansmbtorturetest() { plantest "$modname" "$env" $cmdline } -$incdir/../bin/smbtorture -V +bin/smbtorture -V -samba4srcdir=$incdir/.. +samba4srcdir=. samba4bindir=$samba4srcdir/bin -SCRIPTDIR=$samba4srcdir/../testprogs/ejs + +prefix_abs="$SELFTEST_PREFIX/s4client" + +test -d "$prefix_abs" || mkdir "$prefix_abs" +conffile="$SELFTEST_CONFFILE" + +TORTURE_OPTIONS="" +TORTURE_OPTIONS="$TORTURE_OPTIONS --configfile=$conffile" +TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME" +TORTURE_OPTIONS="$TORTURE_OPTIONS --target=$SELFTEST_TARGET" +TORTURE_OPTIONS="$TORTURE_OPTIONS --basedir=$prefix_abs" +if [ -n "$SELFTEST_VERBOSE" ]; then + TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no" +fi +TORTURE_OPTIONS="$TORTURE_OPTIONS --format=subunit" +if [ -n "$SELFTEST_QUICK" ]; then + TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes" +fi smb4torture="$samba4bindir/smbtorture $TORTURE_OPTIONS" -plantest "js.base" dc "$SCRIPTDIR/base.js" $CONFIGURATION -plantest "js.ldb" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION -d 10 +echo "OPTIONS $TORTURE_OPTIONS" + +SMB_CONF_PATH="$conffile" +export SMB_CONF_PATH +CONFIGURATION="--configfile=$conffile" +export CONFIGURATION # Simple tests for LDAP and CLDAP @@ -95,7 +114,7 @@ plantest "ldb" none TEST_DATA_PREFIX=\$PREFIX $LDBDIR/tests/test-tdb.sh # that they stay passing ncacn_np_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-HANDLES RPC-SAMSYNC RPC-SAMBA3SESSIONKEY RPC-SAMBA3-GETUSERNAME RPC-SAMBA3-LSA RPC-BINDSAMBA3 RPC-NETLOGSAMBA3 RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT" ncalrpc_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-DRSUAPI RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT" -ncacn_ip_tcp_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-HANDLES RPC-DSSYNC RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT" +ncacn_ip_tcp_tests="RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON RPC-HANDLES RPC-DSSYNC RPC-ASYNCBIND RPC-LSALOOKUP RPC-LSA-GETUSER RPC-SCHANNEL2 RPC-AUTHCONTEXT RPC-OBJECTUUID" slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS" slow_ncalrpc_tests="RPC-SAMR RPC-SAMR-PASSWORDS" slow_ncacn_ip_tcp_tests="RPC-SAMR RPC-SAMR-PASSWORDS RPC-CRACKNAMES" @@ -155,6 +174,7 @@ for t in $net; do done # Tests for session keys +# FIXME: Integrate these into a single smbtorture test bindoptions="" transport="ncacn_np" @@ -254,8 +274,8 @@ fi if test x"${PIDL_TESTS_SKIP}" = x"yes"; then echo "Skipping pidl tests - PIDL_TESTS_SKIP=yes" elif $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then - for f in $samba4srcdir/pidl/tests/*.pl; do - plantest "pidl.`basename $f .pl`" none $PERL $f "|" $samba4srcdir/script/harness2subunit.pl + for f in $samba4srcdir/../pidl/tests/*.pl; do + plantest "pidl.`basename $f .pl`" none $PERL $f "|" $samba4srcdir/../lib/subunit/harness2subunit.pl done else echo "Skipping pidl tests - Test::More not installed" @@ -263,22 +283,22 @@ fi # Blackbox Tests: # tests that interact directly with the command-line tools rather than using -# the API +# the API. These mainly test that the various command-line options of commands +# work correctly. -bbdir=$incdir/../../testprogs/blackbox +bbdir=../testprogs/blackbox -plantest "blackbox.ndrdump" dc $bbdir/test_ndrdump.sh +plantest "blackbox.ndrdump" none $samba4srcdir/librpc/tests/test_ndrdump.sh plantest "blackbox.net" dc $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" $CONFIGURATION plantest "blackbox.cifsdd" dc $samba4srcdir/client/tests/test_cifsdd.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" plantest "blackbox.nmblookup" dc $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP" plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP" -plantest "blackbox.locktest" dc $bbdir/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" -plantest "blackbox.masktest" dc $bbdir/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" -plantest "blackbox.gentest" dc $bbdir/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" +plantest "blackbox.locktest" dc $samba4srcdir/torture/tests/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" +plantest "blackbox.masktest" dc $samba4srcdir/torture/tests/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" +plantest "blackbox.gentest" dc $samba4srcdir/torture/tests/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" plantest "blackbox.wbinfo" dc $samba4srcdir/nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc" plantest "blackbox.wbinfo" member $samba4srcdir/nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member" -plantest "blackbox.wintest" none $bbdir/test_wintest.sh "$TORTURE_OPTIONS" # Tests using the "Simple" NTVFS backend @@ -286,10 +306,6 @@ for t in "BASE-RW1"; do plantest "ntvfs.simple.`normalize_testname $t`" dc $VALGRIND $smb4torture $ADDARGS //\$SERVER/simple -U"\$USERNAME"%"\$PASSWORD" $t done -DATADIR=$samba4srcdir/../testdata - -plantest "js.samba3sam" none $samba4bindir/smbscript $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ - # Domain Member Tests plantest "rpc.echo against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" RPC-ECHO "$*" @@ -299,6 +315,46 @@ plantest "rpc.samr.users against member server with local creds" member $VALGRIN plantest "rpc.samr.passwords against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-PASSWORDS" "$*" plantest "blackbox.smbclient against member server with local creds" member $samba4srcdir/client/tests/test_smbclient.sh "\$NETBIOSNAME" "\$USERNAME" "\$PASSWORD" "\$NETBIOSNAME" "$PREFIX" +# Tests SMB signing + +for mech in \ + "-k no" \ + "-k no --option=usespnego=no" \ + "-k no --option=gensec:spengo=no" \ + "-k yes" \ + "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"; do + for signing in \ + "--signing=on" \ + "--signing=required"; do + + signoptions="$mech $signing" + name="smb.signing on with $signoptions" + plantest "$name" dc $VALGRIND $smb4torture //"\$NETBIOSNAME"/tmp $signoptions -U"\$USERNAME"%"\$PASSWORD" BASE-XCOPY "$*" + done +done + +for mech in \ + "-k no" \ + "-k no --option=usespnego=no" \ + "-k no --option=gensec:spengo=no" \ + "-k yes" \ + "-k yes --option=gensec:fake_gssapi_krb5=yes --option=gensec:gssapi_krb5=no"; do + signoptions="$mech --signing=off" + name="smb.signing on with $signoptions" + plantest "$name domain-creds" member $VALGRIND $smb4torture //"\$NETBIOSNAME"/tmp $signoptions -U"\$DC_USERNAME"%"\$DC_PASSWORD" BASE-XCOPY "$*" +done +for mech in \ + "-k no" \ + "-k no --option=usespnego=no" \ + "-k no --option=gensec:spengo=no"; do + signoptions="$mech --signing=off" + name="smb.signing on with $signoptions" + plantest "$name local-creds" member $VALGRIND $smb4torture //"\$NETBIOSNAME"/tmp $signoptions -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" BASE-XCOPY "$*" +done +plantest "smb.signing --signing=yes anon" dc $VALGRIND $smb4torture //"\$NETBIOSNAME"/tmp -k no --signing=yes -U% BASE-XCOPY "$*" +plantest "smb.signing --signing=required anon" dc $VALGRIND $smb4torture //"\$NETBIOSNAME"/tmp -k no --signing=required -U% BASE-XCOPY "$*" +plantest "smb.signing --signing=no anon" member $VALGRIND $smb4torture //"\$NETBIOSNAME"/tmp -k no --signing=no -U% BASE-XCOPY "$*" + NBT_TESTS=`$smb4torture --list | grep "^NBT-" | xargs` for t in $NBT_TESTS; do @@ -333,7 +389,7 @@ SUBUNITRUN="$PYTHON ./scripting/bin/subunitrun" plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:lib/ldb/tests/python/" $SUBUNITRUN api plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:auth/credentials/tests" $SUBUNITRUN bindings plantest "registry.python" none PYTHONPATH="$PYTHONPATH:lib/registry/tests/" $SUBUNITRUN bindings -plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:lib/tdb/python/tests" $SUBUNITRUN simple +plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:../lib/tdb/python/tests" $SUBUNITRUN simple plantest "auth.python" none PYTHONPATH="$PYTHONPATH:auth/tests/" $SUBUNITRUN bindings plantest "security.python" none PYTHONPATH="$PYTHONPATH:libcli/security/tests" $SUBUNITRUN bindings plantest "param.python" none PYTHONPATH="$PYTHONPATH:param/tests" $SUBUNITRUN bindings @@ -348,6 +404,7 @@ plantest "samdb.python" none $SUBUNITRUN samba.tests.samdb plantest "events.python" none PYTHONPATH="$PYTHONPATH:lib/events" $SUBUNITRUN tests plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:lib/messaging/tests" $SUBUNITRUN bindings plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam +plantest "subunit.python" none $SUBUNITRUN subunit plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho plantest "winreg.python" dc $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN diff --git a/source4/setup/provision.zone b/source4/setup/provision.zone index 17ae3bb47a..e7d600df87 100644 --- a/source4/setup/provision.zone +++ b/source4/setup/provision.zone @@ -10,10 +10,10 @@ $TTL 1W 1W ) ; minimum IN NS ${HOSTNAME} ${HOSTIP6_BASE_LINE} - IN A ${HOSTIP} +${HOSTIP_BASE_LINE} ; ${HOSTIP6_HOST_LINE} -${HOSTNAME} IN A ${HOSTIP} +${HOSTIP_HOST_LINE} gc._msdcs IN CNAME ${HOSTNAME} ${HOSTGUID}._msdcs IN CNAME ${HOSTNAME} ; diff --git a/source4/setup/provision_basedn_modify.ldif b/source4/setup/provision_basedn_modify.ldif index 63332e937b..a7b501e8a8 100644 --- a/source4/setup/provision_basedn_modify.ldif +++ b/source4/setup/provision_basedn_modify.ldif @@ -77,4 +77,12 @@ subRefs: ${SCHEMADN} replace: gPLink gPLink: [LDAP://CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN};0] - +replace: wellKnownObjects +wellKnownObjects: B:32:22b70c67d56e4efb91e9300fca3dc1aa:CN=ForeignSecurityPrincipals,${DOMAINDN} +wellKnownObjects: B:32:2fbac1870ade11d297c400c04fd8d5cd:CN=Infrastructure,${DOMAINDN} +wellKnownObjects: B:32:ab1d30f3768811d1aded00c04fd8d5cd:CN=System,${DOMAINDN} +wellKnownObjects: B:32:a361b2ffffd211d1aa4b00c04fd7d83a:OU=Domain Controllers,${DOMAINDN} +wellKnownObjects: B:32:aa312825768811d1aded00c04fd8d5cd:CN=Computers,${DOMAINDN} +wellKnownObjects: B:32:a9d1ca15768811d1aded00c04fd8d5cd:CN=Users,${DOMAINDN} +- ${DOMAINGUID_MOD} diff --git a/source4/setup/provision_init.ldif b/source4/setup/provision_init.ldif index a6c591dd51..8e9b68fb30 100644 --- a/source4/setup/provision_init.ldif +++ b/source4/setup/provision_init.ldif @@ -34,6 +34,7 @@ dn: @OPTIONS checkBaseOnSearch: TRUE dn: @KLUDGEACL +passwordAttribute: clearTextPassword passwordAttribute: userPassword passwordAttribute: ntPwdHash passwordAttribute: sambaNTPwdHistory diff --git a/source4/setup/provision_users.ldif b/source4/setup/provision_users.ldif index 854c42d07c..c61cb805c4 100644 --- a/source4/setup/provision_users.ldif +++ b/source4/setup/provision_users.ldif @@ -137,6 +137,66 @@ sAMAccountName: RAS and IAS Servers groupType: -2147483644 isCriticalSystemObject: TRUE +dn: CN=Read-Only Domain Controllers,CN=Users,${DOMAINDN} +objectClass: top +objectClass: group +cn: Read-Only Domain Controllers +description: read-only domain controllers +objectSid: ${DOMAINSID}-521 +sAMAccountName: Read-Only Domain Controllers +groupType: -2147483644 +isCriticalSystemObject: TRUE + +dn: CN=Enterprise Read-Only Domain Controllers,CN=Users,${DOMAINDN} +objectClass: top +objectClass: group +cn: Enterprise Read-Only Domain Controllers +description: enterprise read-only domain controllers +objectSid: ${DOMAINSID}-498 +sAMAccountName: Enterprise Read-Only Domain Controllers +groupType: -2147483644 +isCriticalSystemObject: TRUE + +dn: CN=Certificate Service DCOM Access,CN=Users,${DOMAINDN} +objectClass: top +objectClass: group +cn: Certificate Service DCOM Access +description: Certificate Service DCOM Access +objectSid: ${DOMAINSID}-574 +sAMAccountName: Certificate Service DCOM Access +groupType: -2147483644 +isCriticalSystemObject: TRUE + +dn: CN=Cryptographic Operators,CN=Users,${DOMAINDN} +objectClass: top +objectClass: group +cn: Cryptographic Operators +description: Cryptographic Operators +objectSid: ${DOMAINSID}-569 +sAMAccountName: Cryptographic Operators +groupType: -2147483644 +isCriticalSystemObject: TRUE + +dn: CN=Event Log Readers,CN=Users,${DOMAINDN} +objectClass: top +objectClass: group +cn: Event Log Readers +description: Event Log Readers +objectSid: ${DOMAINSID}-573 +sAMAccountName: Event Log Readers +groupType: -2147483644 +isCriticalSystemObject: TRUE + +dn: CN=IIS_IUSRS,CN=Users,${DOMAINDN} +objectClass: top +objectClass: group +cn: IIS_IUSRS +description: IIS_IUSRS +objectSid: ${DOMAINSID}-568 +sAMAccountName: IIS_IUSRS +groupType: -2147483644 +isCriticalSystemObject: TRUE + dn: CN=Administrators,CN=Builtin,${DOMAINDN} objectClass: top objectClass: group diff --git a/source4/setup/schema_samba4.ldif b/source4/setup/schema_samba4.ldif index 3e129e4f6b..c27157d713 100644 --- a/source4/setup/schema_samba4.ldif +++ b/source4/setup/schema_samba4.ldif @@ -174,7 +174,11 @@ oMSyntax: 20 #Allocated: DSDB_CONTROL_CURRENT_PARTITION_OID 1.3.6.1.4.1.7165.4.3.2 +#Allocated: DSDB_CONTROL_REPLICATED_UPDATE_OID 1.3.6.1.4.1.7165.4.3.3 + #Allocated: DSDB_EXTENDED_REPLICATED_OBJECTS_OID 1.3.6.1.4.1.7165.4.4.1 +#Allocated: DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID 1.3.6.1.4.1.7165.4.4.2 +#Allocated: LDB_EXTENDED_SEQUENCE_NUMBER 1.3.6.1.4.1.7165.4.4.3 #Allocated: (middleName) attributeID: 1.3.6.1.4.1.7165.4.255.1 diff --git a/source4/setup/secrets_dc.ldif b/source4/setup/secrets_dc.ldif index abc5860cf7..8ae5578e6b 100644 --- a/source4/setup/secrets_dc.ldif +++ b/source4/setup/secrets_dc.ldif @@ -22,7 +22,7 @@ realm: ${REALM} sAMAccountName: krbtgt objectSid: ${DOMAINSID} servicePrincipalName: kadmin/changepw -krb5Keytab: HDB:ldb:${SAM_LDB}: +krb5Keytab: HDB:samba4:${SAM_LDB}: #The trailing : here is a HACK, but it matches the Heimdal format. # A hook from our credentials system into HDB, as we must be on a KDC, diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c index 368b81d18e..bd250361a4 100644 --- a/source4/smb_server/blob.c +++ b/source4/smb_server/blob.c @@ -19,7 +19,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "smb_server/smb_server.h" #include "librpc/gen_ndr/ndr_misc.h" #include "ntvfs/ntvfs.h" @@ -35,7 +35,7 @@ #define BLOB_CHECK_MIN_SIZE(blob, size) do { \ if ((blob)->length < (size)) { \ - return NT_STATUS_INFO_LENGTH_MISMATCH; \ + return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) @@ -530,13 +530,14 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx, switch (level) { case SMB_SFILEINFO_BASIC_INFORMATION: - BLOB_CHECK_MIN_SIZE(blob, 36); + BLOB_CHECK_MIN_SIZE(blob, 40); st->basic_info.in.create_time = pull_nttime(blob->data, 0); st->basic_info.in.access_time = pull_nttime(blob->data, 8); st->basic_info.in.write_time = pull_nttime(blob->data, 16); st->basic_info.in.change_time = pull_nttime(blob->data, 24); - st->basic_info.in.attrib = IVAL(blob->data, 32); + st->basic_info.in.attrib = IVAL(blob->data, 32); + st->basic_info.in.reserved = IVAL(blob->data, 36); return NT_STATUS_OK; @@ -581,6 +582,27 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; + + case RAW_SFILEINFO_LINK_INFORMATION: + if (!bufinfo) { + return NT_STATUS_INTERNAL_ERROR; + } + BLOB_CHECK_MIN_SIZE(blob, 20); + st->link_information.in.overwrite = CVAL(blob->data, 0); + st->link_information.in.root_fid = IVAL(blob->data, 8); + len = IVAL(blob->data, 16); + ofs = 20; + str_blob = *blob; + str_blob.length = MIN(str_blob.length, ofs+len); + smbsrv_blob_pull_string(bufinfo, &str_blob, ofs, + &st->link_information.in.new_name, + STR_UNICODE); + if (st->link_information.in.new_name == NULL) { + return NT_STATUS_FOOBAR; + } + + return NT_STATUS_OK; + case RAW_SFILEINFO_RENAME_INFORMATION_SMB2: /* SMB2 uses a different format for rename information */ if (!bufinfo) { diff --git a/source4/smb_server/config.mk b/source4/smb_server/config.mk index e11968a100..6a1a50ffbf 100644 --- a/source4/smb_server/config.mk +++ b/source4/smb_server/config.mk @@ -2,13 +2,21 @@ # [MODULE::SERVICE_SMB] INIT_FUNCTION = server_service_smb_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = SMB_SERVER SERVICE_SMB_OBJ_FILES = $(smb_serversrcdir)/smb_server.o $(eval $(call proto_header_template,$(smb_serversrcdir)/service_smb_proto.h,$(SERVICE_SMB_OBJ_FILES:.o=.c))) +# samba3 SMB server subsystem +# +[MODULE::SERVICE_SAMBA3_SMB] +INIT_FUNCTION = server_service_samba3_smb_init +SUBSYSTEM = samba + +SERVICE_SAMBA3_SMB_OBJ_FILES = $(smb_serversrcdir)/smb_samba3.o + ####################### # Start SUBSYSTEM SMB [SUBSYSTEM::SMB_SERVER] diff --git a/source4/smb_server/handle.c b/source4/smb_server/handle.c index 56f9c5825e..6ee4e163ad 100644 --- a/source4/smb_server/handle.c +++ b/source4/smb_server/handle.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "smb_server/smb_server.h" #include "ntvfs/ntvfs.h" diff --git a/source4/smb_server/session.c b/source4/smb_server/session.c index e7970eb7d5..0e626307d6 100644 --- a/source4/smb_server/session.c +++ b/source4/smb_server/session.c @@ -21,7 +21,7 @@ #include "includes.h" #include "smb_server/smb_server.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index c7fa2d7d8a..241c262857 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -135,7 +135,12 @@ void smbsrv_setup_reply(struct smbsrv_request *req, uint_t wct, size_t buflen) flags2 = FLAGS2_LONG_PATH_COMPONENTS | FLAGS2_EXTENDED_ATTRIBUTES | FLAGS2_IS_LONG_NAME; - flags2 |= (req->flags2 & (FLAGS2_UNICODE_STRINGS|FLAGS2_EXTENDED_SECURITY)); +#define _SMB_FLAGS2_ECHOED_FLAGS ( \ + FLAGS2_UNICODE_STRINGS | \ + FLAGS2_EXTENDED_SECURITY | \ + FLAGS2_SMB_SECURITY_SIGNATURES \ +) + flags2 |= (req->flags2 & _SMB_FLAGS2_ECHOED_FLAGS); if (req->smb_conn->negotiate.client_caps & CAP_STATUS32) { flags2 |= FLAGS2_32_BIT_ERROR_CODES; } diff --git a/source4/smb_server/smb/sesssetup.c b/source4/smb_server/smb/sesssetup.c index f45cbf1756..a12bbd5cec 100644 --- a/source4/smb_server/smb/sesssetup.c +++ b/source4/smb_server/smb/sesssetup.c @@ -193,16 +193,6 @@ static void sesssetup_nt1_send(struct auth_check_password_request *areq, goto done; } - /* Force check of the request packet, now we know the session key */ - smbsrv_signing_check_incoming(req); -/* TODO: why don't we check the result here? */ - - /* Unfortunetly win2k3 as a client doesn't sign the request - * packet here, so we have to force signing to start again */ - - smbsrv_signing_restart(req->smb_conn, &session_info->session_key, &sess->nt1.in.password2, - session_info->server_info->authenticated); - done: status = NT_STATUS_OK; failed: @@ -321,13 +311,8 @@ static void sesssetup_spnego_send(struct gensec_update_request *greq, void *priv if (!NT_STATUS_IS_OK(status)) goto failed; skey_status = gensec_session_key(smb_sess->gensec_ctx, &session_key); - if (NT_STATUS_IS_OK(skey_status) && - smbsrv_setup_signing(req->smb_conn, &session_key, NULL)) { - /* Force check of the request packet, now we know the session key */ - smbsrv_signing_check_incoming(req); - - smbsrv_signing_restart(req->smb_conn, &session_key, NULL, - session_info->server_info->authenticated); + if (NT_STATUS_IS_OK(skey_status)) { + smbsrv_setup_signing(req->smb_conn, &session_key, NULL); } /* Ensure this is marked as a 'real' vuid, not one diff --git a/source4/smb_server/smb/signing.c b/source4/smb_server/smb/signing.c index ee4531c8f6..0b5cf56fdb 100644 --- a/source4/smb_server/smb/signing.c +++ b/source4/smb_server/smb/signing.c @@ -75,30 +75,6 @@ bool smbsrv_setup_signing(struct smbsrv_connection *smb_conn, &smb_conn->signing, session_key, response); } -void smbsrv_signing_restart(struct smbsrv_connection *smb_conn, - DATA_BLOB *session_key, - DATA_BLOB *response, - bool authenticated_session) -{ - if (!smb_conn->signing.seen_valid) { - DEBUG(5, ("Client did not send a valid signature on " - "SPNEGO session setup - ignored, expect good next time\n")); - /* force things back on (most clients do not sign this packet)... */ - smbsrv_setup_signing(smb_conn, session_key, response); - smb_conn->signing.next_seq_num = 2; - - /* If mandetory_signing is set, and this was an authenticated logon, then force on */ - if (smb_conn->signing.mandatory_signing && authenticated_session) { - DEBUG(5, ("Configured for mandatory signing, 'good packet seen' forced on\n")); - /* if this is mandatory, then - * pretend we have seen a - * valid packet, so we don't - * turn it off */ - smb_conn->signing.seen_valid = true; - } - } -} - bool smbsrv_init_signing(struct smbsrv_connection *smb_conn) { smb_conn->signing.mac_key = data_blob(NULL, 0); @@ -118,10 +94,19 @@ bool smbsrv_init_signing(struct smbsrv_connection *smb_conn) smb_conn->signing.mandatory_signing = true; break; case SMB_SIGNING_AUTO: + /* If we are a domain controller, SMB signing is + * really important, as it can prevent a number of + * attacks on communications between us and the + * clients */ + if (lp_server_role(smb_conn->lp_ctx) == ROLE_DOMAIN_CONTROLLER) { smb_conn->signing.allow_smb_signing = true; smb_conn->signing.mandatory_signing = true; } else { + /* However, it really sucks (no sendfile, CPU + * overhead) performance-wise when used on a + * file server, so disable it by default (auto + * is the default) on non-DCs */ smb_conn->signing.allow_smb_signing = false; } break; diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index 0e820cfe0e..40ffeeef48 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "smb_server/smb_server.h" #include "librpc/gen_ndr/ndr_misc.h" #include "ntvfs/ntvfs.h" diff --git a/source4/smb_server/smb2/fileinfo.c b/source4/smb_server/smb2/fileinfo.c index 6c4b8f33d5..82b006c4a1 100644 --- a/source4/smb_server/smb2/fileinfo.c +++ b/source4/smb_server/smb2/fileinfo.c @@ -369,7 +369,7 @@ void smb2srv_setinfo_recv(struct smb2srv_request *req) SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_setinfo_send, NTVFS_ASYNC_STATE_MAY_ASYNC); info->in.level = SVAL(req->in.body, 0x02); - SMB2SRV_CHECK(smb2_pull_s32o32_blob(&req->in, info, req->in.body+0x04, &info->in.blob)); + SMB2SRV_CHECK(smb2_pull_s32o16_blob(&req->in, info, req->in.body+0x04, &info->in.blob)); info->in.flags = IVAL(req->in.body, 0x0C); info->in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10); diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c index 2c322ea587..4f4402ba33 100644 --- a/source4/smb_server/smb2/fileio.c +++ b/source4/smb_server/smb2/fileio.c @@ -254,6 +254,12 @@ void smb2srv_read_recv(struct smb2srv_request *req) union smb_read *io; SMB2SRV_CHECK_BODY_SIZE(req, 0x30, true); + + /* MS-SMB2 2.2.19 read must have a single byte of zero */ + if (req->in.body_size - req->in.body_fixed < 1) { + smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); + return; + } SMB2SRV_TALLOC_IO_PTR(io, union smb_read); SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_read_send, NTVFS_ASYNC_STATE_MAY_ASYNC); diff --git a/source4/smb_server/smb2/keepalive.c b/source4/smb_server/smb2/keepalive.c index f40bcc485c..ff47d594f0 100644 --- a/source4/smb_server/smb2/keepalive.c +++ b/source4/smb_server/smb2/keepalive.c @@ -54,8 +54,13 @@ void smb2srv_keepalive_recv(struct smb2srv_request *req) { uint16_t _pad; - if (req->in.body_size < 0x04) { - smb2srv_send_error(req, NT_STATUS_FOOBAR); + if (req->in.body_size != 0x04) { + smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); + return; + } + + if (SVAL(req->in.body, 0x00) != 0x04) { + smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); return; } diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c index d64b36d659..49a2d12ef4 100644 --- a/source4/smb_server/smb2/negprot.c +++ b/source4/smb_server/smb2/negprot.c @@ -192,7 +192,7 @@ void smb2srv_negprot_recv(struct smb2srv_request *req) enum ndr_err_code ndr_err; if (req->in.body_size < 0x26) { - smb2srv_send_error(req, NT_STATUS_FOOBAR); + smbsrv_terminate_connection(req->smb_conn, "Bad body size in SMB2 negprot"); return; } @@ -209,7 +209,7 @@ void smb2srv_negprot_recv(struct smb2srv_request *req) io->in.capabilities = IVAL(req->in.body, 0x08); ndr_err = smbcli_pull_guid(req->in.body, 0xC, &io->in.client_guid); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_FOOBAR)); + smbsrv_terminate_connection(req->smb_conn, "Bad GUID in SMB2 negprot"); talloc_free(req); return; } diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c index 1fe6f0b877..c3607f0a33 100644 --- a/source4/smb_server/smb2/receive.c +++ b/source4/smb_server/smb2/receive.c @@ -153,7 +153,7 @@ static void smb2srv_chain_reply(struct smb2srv_request *p_req) chain_offset = p_req->chain_offset; p_req->chain_offset = 0; - if (p_req->in.size < (NBT_HDR_SIZE + chain_offset + SMB2_MIN_SIZE)) { + if (p_req->in.size < (NBT_HDR_SIZE + chain_offset + SMB2_MIN_SIZE_NO_BODY)) { DEBUG(2,("Invalid SMB2 chained packet at offset 0x%X\n", chain_offset)); smbsrv_terminate_connection(p_req->smb_conn, "Invalid SMB2 chained packet"); @@ -184,6 +184,19 @@ static void smb2srv_chain_reply(struct smb2srv_request *p_req) req->in.body_size = req->in.size - (NBT_HDR_SIZE+ chain_offset + SMB2_HDR_BODY); req->in.dynamic = NULL; + req->seqnum = BVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID); + + if (req->in.body_size < 2) { + /* error handling for this is different for negprot to + other packet types */ + uint16_t opcode = SVAL(req->in.hdr, SMB2_HDR_OPCODE); + if (opcode == SMB2_OP_NEGPROT) { + smbsrv_terminate_connection(req->smb_conn, "Bad body size in SMB2 negprot"); + } else { + smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); + } + } + buffer_code = SVAL(req->in.body, 0); req->in.body_fixed = (buffer_code & ~1); dynamic_size = req->in.body_size - req->in.body_fixed; @@ -290,6 +303,10 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req) uint64_t uid; uint32_t flags; + if (SVAL(req->in.hdr, SMB2_HDR_LENGTH) != SMB2_HDR_BODY) { + smbsrv_terminate_connection(req->smb_conn, "Invalid SMB2 header length"); + return NT_STATUS_INVALID_PARAMETER; + } opcode = SVAL(req->in.hdr, SMB2_HDR_OPCODE); req->chain_offset = IVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND); req->seqnum = BVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID); @@ -297,6 +314,13 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req) uid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID); flags = IVAL(req->in.hdr, SMB2_HDR_FLAGS); + if (req->smb_conn->highest_smb2_seqnum != 0 && + req->seqnum <= req->smb_conn->highest_smb2_seqnum) { + smbsrv_terminate_connection(req->smb_conn, "Invalid SMB2 sequence number"); + return NT_STATUS_INVALID_PARAMETER; + } + req->smb_conn->highest_smb2_seqnum = req->seqnum; + req->session = smbsrv_session_find(req->smb_conn, uid, req->request_time); req->tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time); @@ -443,7 +467,7 @@ NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob) return NT_STATUS_OK; } - if (blob.length < (NBT_HDR_SIZE + SMB2_MIN_SIZE)) { + if (blob.length < (NBT_HDR_SIZE + SMB2_MIN_SIZE_NO_BODY)) { DEBUG(2,("Invalid SMB2 packet length count %ld\n", (long)blob.length)); smbsrv_terminate_connection(smb_conn, "Invalid SMB2 packet"); return NT_STATUS_OK; @@ -470,6 +494,19 @@ NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob) req->in.body_size = req->in.size - (SMB2_HDR_BODY+NBT_HDR_SIZE); req->in.dynamic = NULL; + req->seqnum = BVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID); + + if (req->in.body_size < 2) { + /* error handling for this is different for negprot to + other packet types */ + uint16_t opcode = SVAL(req->in.hdr, SMB2_HDR_OPCODE); + if (opcode == SMB2_OP_NEGPROT) { + smbsrv_terminate_connection(req->smb_conn, "Bad body size in SMB2 negprot"); + } else { + smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); + } + } + buffer_code = SVAL(req->in.body, 0); req->in.body_fixed = (buffer_code & ~1); dynamic_size = req->in.body_size - req->in.body_fixed; diff --git a/source4/smb_server/smb2/smb2_server.h b/source4/smb_server/smb2/smb2_server.h index d45e0861af..431add4ed9 100644 --- a/source4/smb_server/smb2/smb2_server.h +++ b/source4/smb_server/smb2/smb2_server.h @@ -75,7 +75,7 @@ struct smbsrv_request; /* useful way of catching field size errors with file and line number */ #define SMB2SRV_CHECK_BODY_SIZE(req, size, dynamic) do { \ size_t is_size = req->in.body_size; \ - uint16_t field_size = SVAL(req->in.body, 0); \ + uint16_t field_size; \ uint16_t want_size = ((dynamic)?(size)+1:(size)); \ if (is_size < (size)) { \ DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \ @@ -83,6 +83,7 @@ struct smbsrv_request; smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); \ return; \ }\ + field_size = SVAL(req->in.body, 0); \ if (field_size != want_size) { \ DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \ __location__, (unsigned)field_size, (unsigned)want_size)); \ diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c new file mode 100644 index 0000000000..ea589a0579 --- /dev/null +++ b/source4/smb_server/smb_samba3.c @@ -0,0 +1,176 @@ +/* + Unix SMB/CIFS implementation. + + process incoming connections and fork a samba3 in inetd mode + + Copyright (C) Stefan Metzmacher 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 . +*/ + +#include "includes.h" +#include "smbd/service_task.h" +#include "smbd/service_stream.h" +#include "smbd/service.h" +#include "lib/messaging/irpc.h" +#include "lib/stream/packet.h" +#include "lib/socket/socket.h" +#include "libcli/smb2/smb2.h" +#include "smb_server/smb2/smb2_server.h" +#include "system/network.h" +#include "lib/socket/netif.h" +#include "param/share.h" +#include "dsdb/samdb/samdb.h" +#include "param/param.h" +#include "dynconfig/dynconfig.h" +#include "smbd/process_model.h" + +/* + initialise a server_context from a open socket and register a event handler + for reading from that socket +*/ +static void samba3_smb_accept(struct stream_connection *conn) +{ + int i; + int fd = socket_get_fd(conn->socket); + const char *prog; + char *argv[2]; + char *reason; + extern char **environ; + + close(0); + close(1); + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + for (i=3;i<256;i++) { + close(i); + } + + prog = lp_parm_string(conn->lp_ctx, NULL, "samba3", "smbd"); + + if (prog == NULL) { + argv[0] = talloc_asprintf(conn, "%s/%s", dyn_BINDIR, "smbd3"); + } + else { + argv[0] = talloc_strdup(conn, prog); + } + + if (argv[0] == NULL) { + stream_terminate_connection(conn, "out of memory"); + return; + } + argv[1] = NULL; + + execve(argv[0], argv, environ); + + /* + * Should never get here + */ + reason = talloc_asprintf(conn, "Could not execute %s", argv[0]); + if (reason == NULL) { + stream_terminate_connection(conn, "out of memory"); + return; + } + stream_terminate_connection(conn, reason); + talloc_free(reason); +} + +static const struct stream_server_ops samba3_smb_stream_ops = { + .name = "samba3", + .accept_connection = samba3_smb_accept, +}; + +/* + setup a listening socket on all the SMB ports for a particular address +*/ +static NTSTATUS samba3_add_socket(struct event_context *event_context, + struct loadparm_context *lp_ctx, + const struct model_ops *model_ops, + const char *address) +{ + const char **ports = lp_smb_ports(lp_ctx); + int i; + NTSTATUS status; + + for (i=0;ports[i];i++) { + uint16_t port = atoi(ports[i]); + if (port == 0) continue; + status = stream_setup_socket(event_context, lp_ctx, + model_ops, &samba3_smb_stream_ops, + "ip", address, &port, + lp_socket_options(lp_ctx), + NULL); + NT_STATUS_NOT_OK_RETURN(status); + } + + return NT_STATUS_OK; +} + + +/* + open the smb server sockets +*/ +static void samba3_smb_task_init(struct task_server *task) +{ + NTSTATUS status; + const struct model_ops *model_ops; + + model_ops = process_model_startup(task->event_ctx, "standard"); + + if (model_ops == NULL) { + goto failed; + } + + task_server_set_title(task, "task[samba3_smb]"); + + if (lp_interfaces(task->lp_ctx) + && lp_bind_interfaces_only(task->lp_ctx)) { + int num_interfaces; + int i; + struct interface *ifaces; + + load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces); + + num_interfaces = iface_count(ifaces); + + /* We have been given an interfaces line, and been + told to only bind to those interfaces. Create a + socket per interface and bind to only these. + */ + for(i = 0; i < num_interfaces; i++) { + const char *address = iface_n_ip(ifaces, i); + status = samba3_add_socket(task->event_ctx, + task->lp_ctx, + model_ops, address); + if (!NT_STATUS_IS_OK(status)) goto failed; + } + } else { + /* Just bind to lp_socket_address() (usually 0.0.0.0) */ + status = samba3_add_socket(task->event_ctx, task->lp_ctx, + model_ops, + lp_socket_address(task->lp_ctx)); + if (!NT_STATUS_IS_OK(status)) goto failed; + } + + return; +failed: + task_server_terminate(task, "Failed to startup samba3 smb task"); +} + +/* called at smbd startup - register ourselves as a server service */ +NTSTATUS server_service_samba3_smb_init(void) +{ + return register_server_service("samba3_smb", samba3_smb_task_init); +} diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 4676fc3e9c..e3e55ae040 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -23,7 +23,7 @@ #include "libcli/raw/interfaces.h" #include "lib/events/events.h" #include "lib/socket/socket.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" /* this header declares the core context structures associated with smb @@ -386,6 +386,8 @@ struct smbsrv_connection { struct loadparm_context *lp_ctx; bool smb2_signing_required; + + uint64_t highest_smb2_seqnum; }; struct model_ops; diff --git a/source4/smb_server/tcon.c b/source4/smb_server/tcon.c index b18901325c..12131ea259 100644 --- a/source4/smb_server/tcon.c +++ b/source4/smb_server/tcon.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "smb_server/smb_server.h" #include "smbd/service_stream.h" #include "ntvfs/ntvfs.h" diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk index e60f444456..b5babd4d69 100644 --- a/source4/smbd/config.mk +++ b/source4/smbd/config.mk @@ -17,9 +17,7 @@ PIDFILE_OBJ_FILES = $(smbdsrcdir)/pidfile.o $(eval $(call proto_header_template,$(smbdsrcdir)/pidfile.h,$(PIDFILE_OBJ_FILES:.o=.c))) -################################# -# Start BINARY smbd -[BINARY::smbd] +[BINARY::samba] INSTALLDIR = SBINDIR PRIVATE_DEPENDENCIES = \ process_model \ @@ -36,8 +34,6 @@ PRIVATE_DEPENDENCIES = \ share \ CLUSTER -smbd_OBJ_FILES = $(smbdsrcdir)/server.o +samba_OBJ_FILES = $(smbdsrcdir)/server.o -MANPAGES += $(smbdsrcdir)/smbd.8 -# End BINARY smbd -################################# +MANPAGES += $(smbdsrcdir)/samba.8 diff --git a/source4/smbd/pidfile.c b/source4/smbd/pidfile.c index 3567846070..d8ba240e40 100644 --- a/source4/smbd/pidfile.c +++ b/source4/smbd/pidfile.c @@ -57,7 +57,7 @@ pid_t pidfile_pid(const char *piddir, const char *name) ret = (pid_t)atoi(pidstr); - if (!process_exists(ret)) { + if (!process_exists_by_pid(ret)) { goto noproc; } diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c index 704e6cc7a2..d6346a06f9 100644 --- a/source4/smbd/process_model.c +++ b/source4/smbd/process_model.c @@ -20,8 +20,11 @@ #include "includes.h" #include "smbd/process_model.h" +#include "smbd/process_model_proto.h" #include "param/param.h" +static const struct model_ops *process_model_byname(const char *name); + /* setup the events for the chosen process model */ @@ -99,7 +102,7 @@ _PUBLIC_ NTSTATUS process_model_init(struct loadparm_context *lp_ctx) /* return the operations structure for a named backend of the specified type */ -_PUBLIC_ const struct model_ops *process_model_byname(const char *name) +static const struct model_ops *process_model_byname(const char *name) { int i; diff --git a/source4/smbd/process_model.h b/source4/smbd/process_model.h index b545212091..6afb66ff20 100644 --- a/source4/smbd/process_model.h +++ b/source4/smbd/process_model.h @@ -63,7 +63,8 @@ struct model_ops { void *); /* function to terminate a connection or task */ - void (*terminate)(struct event_context *, const char *reason); + void (*terminate)(struct event_context *, struct loadparm_context *lp_ctx, + const char *reason); /* function to set a title for the connection or task */ void (*set_title)(struct event_context *, const char *title); @@ -78,7 +79,6 @@ struct process_model_critical_sizes { extern const struct model_ops single_ops; const struct model_ops *process_model_startup(struct event_context *ev, const char *model); -const struct model_ops *process_model_byname(const char *name); NTSTATUS register_process_model(const void *_ops); NTSTATUS process_model_init(struct loadparm_context *lp_ctx); diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c index 2ffb724a6c..1b369613ff 100644 --- a/source4/smbd/process_prefork.c +++ b/source4/smbd/process_prefork.c @@ -25,7 +25,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/socket/socket.h" #include "smbd/process_model.h" #include "param/secrets.h" @@ -189,7 +189,7 @@ static void prefork_new_task(struct event_context *ev, /* called when a task goes down */ -_NORETURN_ static void prefork_terminate(struct event_context *ev, const char *reason) +_NORETURN_ static void prefork_terminate(struct event_context *ev, struct loadparm_context *lp_ctx, const char *reason) { DEBUG(2,("prefork_terminate: reason[%s]\n",reason)); } diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c index a7a27ef9e0..26afff9930 100644 --- a/source4/smbd/process_single.c +++ b/source4/smbd/process_single.c @@ -95,7 +95,7 @@ static void single_new_task(struct event_context *ev, /* called when a task goes down */ -static void single_terminate(struct event_context *ev, const char *reason) +static void single_terminate(struct event_context *ev, struct loadparm_context *lp_ctx, const char *reason) { DEBUG(2,("single_terminate: reason[%s]\n",reason)); } diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index 3f2936bb26..0a864dabb2 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -23,7 +23,7 @@ #include "includes.h" #include "lib/events/events.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/socket/socket.h" #include "smbd/process_model.h" #include "param/secrets.h" @@ -196,13 +196,14 @@ static void standard_new_task(struct event_context *ev, /* called when a task goes down */ -_NORETURN_ static void standard_terminate(struct event_context *ev, const char *reason) +_NORETURN_ static void standard_terminate(struct event_context *ev, struct loadparm_context *lp_ctx, + const char *reason) { DEBUG(2,("standard_terminate: reason[%s]\n",reason)); /* this reload_charcnv() has the effect of freeing the iconv context memory, which makes leak checking easier */ - reload_charcnv(global_loadparm); + reload_charcnv(lp_ctx); talloc_free(ev); diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c index 540d956420..597cf587f1 100644 --- a/source4/smbd/process_thread.c +++ b/source4/smbd/process_thread.c @@ -188,7 +188,7 @@ static void thread_new_task(struct event_context *ev, } /* called when a task goes down */ -static void thread_terminate(struct event_context *event_ctx, const char *reason) +static void thread_terminate(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const char *reason) { DEBUG(10,("thread_terminate: reason[%s]\n",reason)); diff --git a/source4/smbd/smbd.8.xml b/source4/smbd/samba.8.xml similarity index 92% rename from source4/smbd/smbd.8.xml rename to source4/smbd/samba.8.xml index a02c2ce80a..e1ec8cabd5 100644 --- a/source4/smbd/smbd.8.xml +++ b/source4/smbd/samba.8.xml @@ -1,21 +1,21 @@ - + - smbd + samba 8 - smbd + samba server to provide filesharing- and directory services to clients - smbd + samba -i -M model @@ -26,7 +26,7 @@ This program is part of the samba 7 suite. - smbd is the server daemon that + samba is the server daemon that provides filesharing and directory services to Windows clients. The server provides filespace and directory services to clients using the SMB (or CIFS) protocol and other @@ -51,8 +51,9 @@ 5 manual page should be regarded as mandatory reading before proceeding with installation. - As of Samba 4, smbd also incorporates all the functionality of - nmbd. + As of Samba 4, there is a single daemon that incorporates the + functionality of both smbd and nmbd that are present in older versions + of Samba. @@ -66,7 +67,7 @@ server to run "interactively", not as a daemon, even if the server is executed on the command line of a shell. Setting this parameter negates the implicit deamon mode when run from the - command line. smbd also logs to standard + command line. samba also logs to standard output, as if the -S parameter had been given. @@ -75,7 +76,7 @@ -M model This parameter can be used to specify the - "process model" smbd should use. This determines + "process model" samba should use. This determines how concurrent clients are handled. Available process models include single (everything in a single process), standard (similar diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 5bd5568913..fd4b21b17f 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -199,7 +199,8 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[ extern NTSTATUS server_service_drepl_init(void); extern NTSTATUS server_service_rpc_init(void); extern NTSTATUS server_service_ntp_signd_init(void); - init_module_fn static_init[] = { STATIC_smbd_MODULES }; + extern NTSTATUS server_service_samba3_smb_init(void); + init_module_fn static_init[] = { STATIC_samba_MODULES }; init_module_fn *shared_init; struct event_context *event_ctx; uint16_t stdin_event_flags; diff --git a/source4/smbd/service.c b/source4/smbd/service.c index 2b1fcc4bd8..52db2801e9 100644 --- a/source4/smbd/service.c +++ b/source4/smbd/service.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "smbd/process_model.h" /* diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index f27560f6ee..ce5b6519a1 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -61,6 +61,8 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char if (!reason) reason = "unknown reason"; + DEBUG(3,("Terminating connection - '%s'\n", reason)); + srv_conn->terminate = reason; if (srv_conn->processing) { @@ -76,8 +78,8 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char talloc_free(srv_conn->event.fde); srv_conn->event.fde = NULL; + model_ops->terminate(event_ctx, srv_conn->lp_ctx, reason); talloc_free(srv_conn); - model_ops->terminate(event_ctx, reason); } /** diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h index d57a54cdc9..7ec2a0538b 100644 --- a/source4/smbd/service_stream.h +++ b/source4/smbd/service_stream.h @@ -23,7 +23,7 @@ #ifndef __SERVICE_STREAM_H__ #define __SERVICE_STREAM_H__ -#include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" /* modules can use the following to determine if the interface has changed * please increment the version number after each interface change diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c index 2274685059..9a2903e281 100644 --- a/source4/smbd/service_task.c +++ b/source4/smbd/service_task.c @@ -35,7 +35,7 @@ void task_server_terminate(struct task_server *task, const char *reason) struct event_context *event_ctx = task->event_ctx; const struct model_ops *model_ops = task->model_ops; DEBUG(0,("task_server_terminate: [%s]\n", reason)); - model_ops->terminate(event_ctx, reason); + model_ops->terminate(event_ctx, task->lp_ctx, reason); /* don't free this above, it might contain the 'reason' being printed */ talloc_free(task); diff --git a/source4/smbd/service_task.h b/source4/smbd/service_task.h index 207e2cbbca..ddd56bc9c9 100644 --- a/source4/smbd/service_task.h +++ b/source4/smbd/service_task.h @@ -22,7 +22,7 @@ #ifndef __SERVICE_TASK_H__ #define __SERVICE_TASK_H__ -#include "librpc/gen_ndr/misc.h" +#include "librpc/gen_ndr/security.h" struct task_server { struct event_context *event_ctx; diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c index 739a048d29..1e8b339997 100644 --- a/source4/torture/auth/ntlmssp.c +++ b/source4/torture/auth/ntlmssp.c @@ -48,7 +48,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; - gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f00"); + gensec_ntlmssp_state->session_key = strhex_to_data_blob(tctx, "0102030405060708090a0b0c0d0e0f00"); dump_data_pw("NTLMSSP session key: \n", gensec_ntlmssp_state->session_key.data, gensec_ntlmssp_state->session_key.length); @@ -59,11 +59,11 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) ntlmssp_sign_init(gensec_ntlmssp_state), "Failed to sign_init"); - data = strhex_to_data_blob("6a43494653"); + data = strhex_to_data_blob(tctx, "6a43494653"); gensec_ntlmssp_sign_packet(gensec_security, gensec_security, data.data, data.length, data.data, data.length, &sig); - expected_sig = strhex_to_data_blob("01000000e37f97f2544f4d7e00000000"); + expected_sig = strhex_to_data_blob(tctx, "01000000e37f97f2544f4d7e00000000"); dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length); dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length); @@ -103,7 +103,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; - gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405e538b0"); + gensec_ntlmssp_state->session_key = strhex_to_data_blob(tctx, "0102030405e538b0"); dump_data_pw("NTLMSSP session key: \n", gensec_ntlmssp_state->session_key.data, gensec_ntlmssp_state->session_key.length); @@ -114,11 +114,11 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) ntlmssp_sign_init(gensec_ntlmssp_state), "Failed to sign_init"); - data = strhex_to_data_blob("6a43494653"); + data = strhex_to_data_blob(tctx, "6a43494653"); gensec_ntlmssp_sign_packet(gensec_security, gensec_security, data.data, data.length, data.data, data.length, &sig); - expected_sig = strhex_to_data_blob("0100000078010900397420fe0e5a0f89"); + expected_sig = strhex_to_data_blob(tctx, "0100000078010900397420fe0e5a0f89"); dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length); dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length); diff --git a/source4/torture/auth/pac.c b/source4/torture/auth/pac.c index 42901f1eff..f6f2fcb498 100644 --- a/source4/torture/auth/pac.c +++ b/source4/torture/auth/pac.c @@ -379,7 +379,7 @@ static bool torture_pac_saved_check(struct torture_context *tctx) pac_file = torture_setting_string(tctx, "pac_file", NULL); if (pac_file) { - tmp_blob.data = (uint8_t *)file_load(pac_file, &tmp_blob.length, mem_ctx); + tmp_blob.data = (uint8_t *)file_load(pac_file, &tmp_blob.length, 0, mem_ctx); torture_comment(tctx, "(saved test) Loaded pac of size %ld from %s\n", (long)tmp_blob.length, pac_file); } else { tmp_blob = data_blob_talloc(mem_ctx, saved_pac, sizeof(saved_pac)); diff --git a/source4/torture/basic/aliases.c b/source4/torture/basic/aliases.c index 6bb8f99622..0309557acb 100644 --- a/source4/torture/basic/aliases.c +++ b/source4/torture/basic/aliases.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "libcli/raw/libcliraw.h" #include "libcli/raw/raw_proto.h" #include "torture/torture.h" diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index af42beb535..61678f4e52 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -55,7 +55,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - torture_comment(tctx, "Failed to open %s\n", fname); + torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname); return false; } @@ -65,10 +65,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); torture_comment(tctx, "Initial write time %s\n", nt_time_string(tctx, finfo1.basic_info.out.write_time)); @@ -80,8 +77,9 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1); if (written != 1) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", - (int)written, __location__); + torture_result(tctx, TORTURE_FAIL, + "write failed - wrote %d bytes (%s)\n", + (int)written, __location__); return false; } @@ -117,7 +115,8 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time (wrong!)"); ret = false; } @@ -154,7 +153,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - torture_comment(tctx, "Failed to open %s\n", fname); + torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname); return false; } @@ -174,10 +173,7 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); torture_comment(tctx, "Initial write time %s\n", nt_time_string(tctx, finfo1.all_info.out.write_time)); @@ -186,8 +182,9 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc written = smbcli_smbwrite(cli->tree, fnum1, "x", 1024, 0); if (written != 0) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", - (int)written, __location__); + torture_result(tctx, TORTURE_FAIL, + "write failed - wrote %d bytes (%s)\n", + (int)written, __location__); return false; } @@ -203,8 +200,9 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc } if (finfo2.all_info.out.size != 1024) { - DEBUG(0, ("file not truncated, size = %u (should be 1024)\n", - (unsigned int)finfo2.all_info.out.size)); + torture_result(tctx, TORTURE_FAIL, + "file not truncated, size = %u (should be 1024)", + (unsigned int)finfo2.all_info.out.size); ret = false; break; } @@ -233,7 +231,8 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc } if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time (wrong!)"); ret = false; } @@ -241,8 +240,9 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1); if (written != 1) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", - (int)written, __location__); + torture_result(tctx, TORTURE_FAIL, + "write failed - wrote %d bytes (%s)", + (int)written, __location__); return false; } @@ -279,7 +279,8 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc } if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) { - torture_comment(tctx, "Server updated write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server updated write time (wrong!)"); ret = false; } @@ -288,13 +289,11 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc fnum1 = -1; status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "pathinfo failed"); if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time on close (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time on close (wrong!)"); ret = false; } else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) { torture_comment(tctx, "Server updated write time on close (correct)\n"); @@ -335,7 +334,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - torture_comment(tctx, "Failed to open %s\n", fname); + torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname); return false; } @@ -355,10 +354,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); torture_comment(tctx, "Initial write time %s\n", nt_time_string(tctx, finfo1.all_info.out.write_time)); @@ -367,7 +363,7 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb written = smbcli_smbwrite(cli->tree, fnum1, "x", 10240, 0); if (written != 0) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", + torture_result(tctx, TORTURE_FAIL, "write failed - wrote %d bytes (%s)", (int)written, __location__); return false; } @@ -378,14 +374,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s", + nt_errstr(status)); ret = false; break; } if (finfo2.all_info.out.size != 10240) { - DEBUG(0, ("file not truncated, size = %u (should be 10240)\n", - (unsigned int)finfo2.all_info.out.size)); + torture_result(tctx, TORTURE_FAIL, + "file not truncated, size = %u (should be 10240)", + (unsigned int)finfo2.all_info.out.size); ret = false; break; } @@ -414,18 +412,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb } if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time (wrong!)"); ret = false; } /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */ written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1); - if (written != 1) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", - (int)written, __location__); - return false; - } + torture_assert_int_equal(tctx, written, 1, + "unexpected number of bytes written"); start = timeval_current(); end = timeval_add(&start, (10*sec), 0); @@ -433,14 +429,16 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo3); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s\n", + nt_errstr(status)); ret = false; break; } if (finfo3.all_info.out.size != 10240) { - DEBUG(0, ("file not truncated, size = %u (should be 10240)\n", - (unsigned int)finfo3.all_info.out.size)); + torture_result(tctx, TORTURE_FAIL, + "file not truncated, size = %u (should be 10240)", + (unsigned int)finfo3.all_info.out.size); ret = false; break; } @@ -460,7 +458,8 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb } if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) { - torture_comment(tctx, "Server updated write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server updated write time (wrong!)"); ret = false; } @@ -469,13 +468,11 @@ static bool test_delayed_write_update1a(struct torture_context *tctx, struct smb fnum1 = -1; status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "pathinfo failed"); if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time on close (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time on close (wrong!)"); ret = false; } else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) { torture_comment(tctx, "Server updated write time on close (correct)\n"); @@ -516,7 +513,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - torture_comment(tctx, "Failed to open %s\n", fname); + torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname); return false; } @@ -536,10 +533,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); torture_comment(tctx, "Initial write time %s\n", nt_time_string(tctx, finfo1.all_info.out.write_time)); @@ -547,11 +541,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb /* Do a SET_END_OF_FILE_INFO call to truncate. */ status = smbcli_ftruncate(cli->tree, fnum1, (uint64_t)10240); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "SET_END_OF_FILE failed (%s)\n", - nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "SET_END_OF_FILE failed"); start = timeval_current(); end = timeval_add(&start, (120*sec), 0); @@ -565,8 +555,9 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb } if (finfo2.all_info.out.size != 10240) { - DEBUG(0, ("file not truncated (size = %u, should be 10240)\n", - (unsigned int)finfo2.all_info.out.size )); + torture_result(tctx, TORTURE_FAIL, + "file not truncated (size = %u, should be 10240)", + (unsigned int)finfo2.all_info.out.size ); ret = false; break; } @@ -576,9 +567,10 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) { double diff = timeval_elapsed(&start); if (diff > (0.25 * sec * 0.75)) { /* 0.75 to cope with vmware timing */ - torture_comment(tctx, "After SET_END_OF_FILE truncate " + torture_result(tctx, TORTURE_FAIL, + "After SET_END_OF_FILE truncate " "server updated write_time after %.2f seconds" - "(1 sec == %.2f)(wrong!)\n", + "(1 sec == %.2f)(wrong!)", diff, sec); ret = false; break; @@ -595,18 +587,16 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb } if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time (wrong!)"); ret = false; } /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */ written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1); - if (written != 1) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", - (int)written, __location__); - return false; - } + torture_assert_int_equal(tctx, written, 1, + "unexpected number of bytes written"); start = timeval_current(); end = timeval_add(&start, (10*sec), 0); @@ -614,7 +604,8 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo3); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + torture_result(tctx, TORTURE_FAIL, + "fileinfo failed: %s", nt_errstr(status)); ret = false; break; } @@ -641,7 +632,7 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb } if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) { - torture_comment(tctx, "Server updated write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, "Server updated write time (wrong!)\n"); ret = false; } @@ -650,13 +641,10 @@ static bool test_delayed_write_update1b(struct torture_context *tctx, struct smb fnum1 = -1; status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "pathinfo failed"); if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time on close (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, "Server did not update write time on close (wrong!)\n"); ret = false; } else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) { torture_comment(tctx, "Server updated write time on close (correct)\n"); @@ -697,7 +685,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - torture_comment(tctx, "Failed to open %s\n", fname); + torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname); return false; } @@ -717,10 +705,7 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); torture_comment(tctx, "Initial write time %s\n", nt_time_string(tctx, finfo1.all_info.out.write_time)); @@ -730,13 +715,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb parms.allocation_info.in.file.fnum = fnum1; parms.allocation_info.in.alloc_size = 0; - status = smb_raw_setfileinfo(cli->tree, &parms); + status = smb_raw_setfileinfo(cli->tree, &parms); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "RAW_SFILEINFO_ALLOCATION_INFO failed (%s)\n", - nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, status, + "RAW_SFILEINFO_ALLOCATION_INFO failed"); start = timeval_current(); end = timeval_add(&start, (120*sec), 0); @@ -744,14 +726,16 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s", + nt_errstr(status)); ret = false; break; } if (finfo2.all_info.out.size != 0) { - DEBUG(0, ("file not truncated (size = %u, should be 10240)\n", - (unsigned int)finfo2.all_info.out.size )); + torture_result(tctx, TORTURE_FAIL, + "file not truncated (size = %u, should be 10240)", + (unsigned int)finfo2.all_info.out.size); ret = false; break; } @@ -780,18 +764,15 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb } if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server did not update write time (wrong!)"); ret = false; } /* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */ written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1); - - if (written != 1) { - torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", - (int)written, __location__); - return false; - } + torture_assert_int_equal(tctx, written, 1, + "Unexpected number of bytes written"); start = timeval_current(); end = timeval_add(&start, (10*sec), 0); @@ -799,13 +780,14 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb status = smb_raw_fileinfo(cli->tree, tctx, &finfo3); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); + torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s", + nt_errstr(status)); ret = false; break; } if (finfo3.all_info.out.size != 1) { - DEBUG(0, ("file not expanded\n")); + torture_result(tctx, TORTURE_FAIL, "file not expanded"); ret = false; break; } @@ -825,7 +807,8 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb } if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) { - torture_comment(tctx, "Server updated write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, + "Server updated write time (wrong!)"); ret = false; } @@ -834,13 +817,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb fnum1 = -1; status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("pathinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "pathinfo failed"); if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) { - torture_comment(tctx, "Server did not update write time on close (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, "Server did not update write time on close (wrong!)\n"); ret = false; } else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) { torture_comment(tctx, "Server updated write time on close (correct)\n"); @@ -894,10 +874,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); torture_comment(tctx, "Initial write time %s\n", nt_time_string(tctx, finfo1.basic_info.out.write_time)); @@ -927,10 +904,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc status = smb_raw_setfileinfo(cli->tree, &sfinfo); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("sfileinfo failed: %s\n", nt_errstr(status))); - return false; - } + torture_assert_ntstatus_ok(tctx, status, "sfileinfo failed"); } finfo2.basic_info.in.file.path = fname; @@ -947,7 +921,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { torture_comment(tctx, "Server updated write_time (correct)\n"); } else { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, "Server did not update write time (wrong!)\n"); ret = false; } @@ -1195,7 +1169,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - torture_comment(tctx, "Server did not update write time (wrong!)\n"); + torture_result(tctx, TORTURE_FAIL, "Server did not update write time (wrong!)\n"); ret = false; } @@ -2900,7 +2874,7 @@ struct torture_suite *torture_delay_write(void) torture_suite_add_2smb_test(suite, "finfo update on close", test_finfo_after_write); torture_suite_add_1smb_test(suite, "delayed update of write time", test_delayed_write_update); - torture_suite_add_1smb_test(suite, "update of write time and SMBwrite truncate ", test_delayed_write_update1); + torture_suite_add_1smb_test(suite, "update of write time and SMBwrite truncate", test_delayed_write_update1); torture_suite_add_1smb_test(suite, "update of write time and SMBwrite truncate expand", test_delayed_write_update1a); torture_suite_add_1smb_test(suite, "update of write time using SET_END_OF_FILE", test_delayed_write_update1b); torture_suite_add_1smb_test(suite, "update of write time using SET_ALLOCATION_SIZE", test_delayed_write_update1c); diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 58d7098972..98c53aac21 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -21,8 +21,8 @@ #include "torture/torture.h" #include "system/filesys.h" #include "system/dir.h" -#include "lib/tdb/include/tdb.h" -#include "lib/util/util_tdb.h" +#include "../tdb/include/tdb.h" +#include "../lib/util/util_tdb.h" #include "libcli/libcli.h" #include "torture/util.h" diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 24e0324bc3..3a09fa74b5 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -448,7 +448,7 @@ static int init_benchrw_params(struct torture_context *tctx, p = torture_setting_string(tctx, "unclist", NULL); if (p) { char *h, *s; - unc_list = file_lines_load(p, &num_unc_names, NULL); + unc_list = file_lines_load(p, &num_unc_names, 0, NULL); if (!unc_list || num_unc_names <= 0) { torture_comment(tctx, "Failed to load unc names list " "from '%s'\n", p); @@ -823,6 +823,7 @@ static struct composite_context *torture_connect_async( smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; lp_smbcli_options(tctx->lp_ctx, &smb->in.options); + lp_smbcli_session_options(tctx->lp_ctx, &smb->in.session_options); return smb_composite_connect_send(smb,mem_ctx, lp_resolve_context(tctx->lp_ctx),ev); diff --git a/source4/torture/basic/secleak.c b/source4/torture/basic/secleak.c index 4caeee72a4..ca1fd444d9 100644 --- a/source4/torture/basic/secleak.c +++ b/source4/torture/basic/secleak.c @@ -36,8 +36,11 @@ static bool try_failed_login(struct torture_context *tctx, struct smbcli_state * NTSTATUS status; struct smb_composite_sesssetup setup; struct smbcli_session *session; + struct smbcli_session_options options; - session = smbcli_session_init(cli->transport, cli, false); + lp_smbcli_session_options(tctx->lp_ctx, &options); + + session = smbcli_session_init(cli->transport, cli, false, options); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; setup.in.workgroup = lp_workgroup(tctx->lp_ctx); diff --git a/source4/torture/config.mk b/source4/torture/config.mk index 96da10b5df..211d09756d 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -116,7 +116,7 @@ torture_rpc_OBJ_FILES = $(addprefix $(torturesrcdir)/rpc/, \ eventlog.o epmapper.o winreg.o initshutdown.o oxidresolve.o remact.o mgmt.o \ scanner.o autoidl.o countcalls.o testjoin.o schannel.o netlogon.o remote_pac.o samlogon.o \ samsync.o bind.o dssetup.o alter_context.o bench.o samba3rpc.o rpc.o async_bind.o \ - handles.o frsapi.o) + handles.o frsapi.o object_uuid.o) $(eval $(call proto_header_template,$(torturesrcdir)/rpc/proto.h,$(torture_rpc_OBJ_FILES:.o=.c))) diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index af5a95e751..74ece99422 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -214,7 +214,9 @@ static bool connect_servers(struct event_context *ev, for (j=0;jmode_information.in.mode = gen_bits_mask(0xFFFFFFFF); break; + case RAW_SFILEINFO_FULL_EA_INFORMATION: + info->full_ea_information.in.eas = gen_ea_list(); + break; case RAW_SFILEINFO_GENERIC: case RAW_SFILEINFO_SEC_DESC: case RAW_SFILEINFO_UNIX_BASIC: @@ -2222,7 +2241,8 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info) do { i = gen_int_range(0, num_levels-1); } while (ignore_pattern(levels[i].name)); - + + ZERO_STRUCTP(info); info->generic.level = levels[i].level; switch (info->generic.level) { @@ -2279,6 +2299,9 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info) case RAW_SFILEINFO_MODE_INFORMATION: info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF); break; + case RAW_SFILEINFO_FULL_EA_INFORMATION: + info->full_ea_information.in.eas = gen_ea_list(); + break; case RAW_SFILEINFO_GENERIC: case RAW_SFILEINFO_SEC_DESC: @@ -2372,9 +2395,8 @@ static bool handler_smb_spathinfo(int instance) union smb_setfileinfo parm[NSERVERS]; NTSTATUS status[NSERVERS]; - parm[0].generic.in.file.path = gen_fname_open(instance); - gen_setfileinfo(instance, &parm[0]); + parm[0].generic.in.file.path = gen_fname_open(instance); GEN_COPY_PARM; @@ -2743,9 +2765,8 @@ static bool handler_smb2_sfileinfo(int instance) union smb_setfileinfo parm[NSERVERS]; NTSTATUS status[NSERVERS]; - parm[0].generic.in.file.fnum = gen_fnum(instance); - gen_setfileinfo(instance, &parm[0]); + parm[0].generic.in.file.fnum = gen_fnum(instance); GEN_COPY_PARM; GEN_SET_FNUM_SMB2(generic.in.file.handle); @@ -2907,12 +2928,11 @@ static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx) current_op.opnum = op; current_op.name = gen_ops[which_op].name; current_op.status = NT_STATUS_OK; + talloc_free(current_op.mem_ctx); current_op.mem_ctx = talloc_named(NULL, 0, "%s", current_op.name); ret = gen_ops[which_op].handler(instance); - talloc_free(current_op.mem_ctx); - gen_ops[which_op].count++; if (NT_STATUS_IS_OK(current_op.status)) { gen_ops[which_op].success_count++; @@ -3026,7 +3046,7 @@ static bool start_gentest(struct event_context *ev, /* generate the seeds - after this everything is deterministic */ if (options.use_preset_seeds) { int numops; - char **preset = file_lines_load(options.seeds_file, &numops, NULL); + char **preset = file_lines_load(options.seeds_file, &numops, 0, NULL); if (!preset) { printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno)); exit(1); @@ -3173,7 +3193,7 @@ static bool split_unc_name(const char *unc, char **server, char **share) } if (ignore_file) { - options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL); + options.ignore_patterns = file_lines_load(ignore_file, NULL, 0, NULL); } argv_new = discard_const_p(char *, poptGetArgs(pc)); diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c index 3730193c86..1ddc628a5c 100644 --- a/source4/torture/ldap/cldap.c +++ b/source4/torture/ldap/cldap.c @@ -24,6 +24,7 @@ #include "libcli/cldap/cldap.h" #include "libcli/ldap/ldap.h" #include "librpc/gen_ndr/ndr_nbt.h" +#include "librpc/gen_ndr/netlogon.h" #include "torture/torture.h" #include "lib/ldb/include/ldb.h" #include "param/param.h" @@ -64,7 +65,7 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) n1 = search.out.netlogon; search.in.user = "Administrator"; - search.in.realm = n1.nt5_ex.dns_domain; + search.in.realm = n1.data.nt5_ex.dns_domain; search.in.host = "__cldap_torture__"; printf("Scanning for netlogon levels\n"); @@ -93,8 +94,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) search.in.user = NULL; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); printf("Trying with User=Administrator\n"); @@ -102,8 +103,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); search.in.version = NETLOGON_NT_VERSION_5; status = cldap_netlogon(cldap, tctx, &search); @@ -114,8 +115,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) search.in.user = NULL; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE); printf("Trying with User=Administrator\n"); @@ -123,18 +124,18 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN); search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX; printf("Trying with a GUID\n"); search.in.realm = NULL; - search.in.domain_guid = GUID_string(tctx, &n1.nt5_ex.domain_uuid); + search.in.domain_guid = GUID_string(tctx, &n1.data.nt5_ex.domain_uuid); status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); - CHECK_STRING(GUID_string(tctx, &search.out.netlogon.nt5_ex.domain_uuid), search.in.domain_guid); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); + CHECK_STRING(GUID_string(tctx, &search.out.netlogon.data.nt5_ex.domain_uuid), search.in.domain_guid); printf("Trying with a incorrect GUID\n"); guid = GUID_random(); @@ -145,53 +146,53 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) printf("Trying with a AAC\n"); search.in.acct_control = ACB_WSTRUST|ACB_SVRTRUST; - search.in.realm = n1.nt5_ex.dns_domain; + search.in.realm = n1.data.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); printf("Trying with a zero AAC\n"); search.in.acct_control = 0x0; - search.in.realm = n1.nt5_ex.dns_domain; + search.in.realm = n1.data.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); printf("Trying with a zero AAC and user=Administrator\n"); search.in.acct_control = 0x0; search.in.user = "Administrator"; - search.in.realm = n1.nt5_ex.dns_domain; + search.in.realm = n1.data.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "Administrator"); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, "Administrator"); printf("Trying with a bad AAC\n"); search.in.user = NULL; search.in.acct_control = 0xFF00FF00; - search.in.realm = n1.nt5_ex.dns_domain; + search.in.realm = n1.data.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); printf("Trying with a user only\n"); search = empty_search; search.in.user = "Administrator"; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); + CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); printf("Trying with just a bad username\n"); search.in.user = "___no_such_user___"; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user); - CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, search.in.user); + CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX); printf("Trying with just a bad domain\n"); search = empty_search; @@ -200,29 +201,29 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest) CHECK_STATUS(status, NT_STATUS_NOT_FOUND); printf("Trying with a incorrect domain and correct guid\n"); - search.in.domain_guid = GUID_string(tctx, &n1.nt5_ex.domain_uuid); + search.in.domain_guid = GUID_string(tctx, &n1.data.nt5_ex.domain_uuid); status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); printf("Trying with a incorrect domain and incorrect guid\n"); search.in.domain_guid = GUID_string(tctx, &guid); status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_NOT_FOUND); - CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); printf("Trying with a incorrect GUID and correct domain\n"); search.in.domain_guid = GUID_string(tctx, &guid); - search.in.realm = n1.nt5_ex.dns_domain; + search.in.realm = n1.data.nt5_ex.dns_domain; status = cldap_netlogon(cldap, tctx, &search); CHECK_STATUS(status, NT_STATUS_OK); - CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain); - CHECK_STRING(search.out.netlogon.nt5_ex.user_name, ""); - CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); + CHECK_STRING(search.out.netlogon.data.nt5_ex.dns_domain, n1.data.nt5_ex.dns_domain); + CHECK_STRING(search.out.netlogon.data.nt5_ex.user_name, ""); + CHECK_VAL(search.out.netlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX); return true; } @@ -255,9 +256,9 @@ static bool test_cldap_netlogon_flags(struct torture_context *tctx, n1 = search.out.netlogon; if (n1.ntver == NETLOGON_NT_VERSION_5) - server_type = n1.nt5.server_type; + server_type = n1.data.nt5.server_type; else if (n1.ntver == NETLOGON_NT_VERSION_5EX) - server_type = n1.nt5_ex.server_type; + server_type = n1.data.nt5_ex.server_type; printf("The word is: %i\n", server_type); if (server_type & NBT_SERVER_PDC) @@ -280,16 +281,16 @@ static bool test_cldap_netlogon_flags(struct torture_context *tctx, printf("NBT_SERVER_GOOD_TIMESERV "); if (server_type & NBT_SERVER_NDNC) printf("NBT_SERVER_NDNC "); - if (server_type & NBT_SERVER_SEL_SEC_DOM_6) - printf("NBT_SERVER_SEL_SEC_DOM_6 "); - if (server_type & NBT_SERVER_FUL_SEC_DOM_6) - printf("NBT_SERVER_FUL_SEC_DOM_6 "); - if (server_type & NBT_SERVER_DS_DNS_CONTR) - printf("NBT_SERVER_DS_DNS_CONTR "); - if (server_type & NBT_SERVER_DS_DNS_DOMAIN) - printf("NBT_SERVER_DS_DNS_DOMAIN "); - if (server_type & NBT_SERVER_DS_DNS_FOREST) - printf("NBT_SERVER_DS_DNS_FOREST "); + if (server_type & NBT_SERVER_SELECT_SECRET_DOMAIN_6) + printf("NBT_SERVER_SELECT_SECRET_DOMAIN_6"); + if (server_type & NBT_SERVER_FULL_SECRET_DOMAIN_6) + printf("NBT_SERVER_FULL_SECRET_DOMAIN_6"); + if (server_type & DS_DNS_CONTROLLER) + printf("DS_DNS_CONTROLLER "); + if (server_type & DS_DNS_DOMAIN) + printf("DS_DNS_DOMAIN "); + if (server_type & DS_DNS_FOREST) + printf("DS_DNS_FOREST "); printf("\n"); @@ -366,11 +367,11 @@ static bool test_cldap_netlogon_flag_ds_dns_forest(struct torture_context *tctx, n1 = search.out.netlogon; if (n1.ntver == NETLOGON_NT_VERSION_5) - server_type = n1.nt5.server_type; + server_type = n1.data.nt5.server_type; else if (n1.ntver == NETLOGON_NT_VERSION_5EX) - server_type = n1.nt5_ex.server_type; + server_type = n1.data.nt5_ex.server_type; - if (server_type & NBT_SERVER_DS_DNS_FOREST) { + if (server_type & DS_DNS_FOREST) { struct cldap_search search2; const char *attrs[] = { "defaultNamingContext", "rootDomainNamingContext", NULL }; diff --git a/source4/torture/ldap/schema.c b/source4/torture/ldap/schema.c index 8437e7f79d..6184ad266d 100644 --- a/source4/torture/ldap/schema.c +++ b/source4/torture/ldap/schema.c @@ -26,7 +26,7 @@ #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" #include "dsdb/samdb/samdb.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "torture/torture.h" #include "torture/ldap/proto.h" @@ -41,6 +41,8 @@ struct test_rootDSE { }; struct test_schema_ctx { + struct ldb_context *ldb; + struct ldb_paged_control *ctrl; uint32_t count; bool pending; @@ -57,8 +59,8 @@ static bool test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro d_printf("Testing RootDSE Search\n"); - ret = ldb_search(ldb, ldb_dn_new(ldb, ldb, NULL), LDB_SCOPE_BASE, - NULL, NULL, &r); + ret = ldb_search(ldb, ldb, &r, ldb_dn_new(ldb, ldb, NULL), + LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) { return false; } else if (r->count != 1) { @@ -82,15 +84,24 @@ static bool test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro return true; } -static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +static int test_schema_search_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct test_schema_ctx *actx = talloc_get_type(context, struct test_schema_ctx); + struct test_schema_ctx *actx; int ret = LDB_SUCCESS; + actx = talloc_get_type(req->context, struct test_schema_ctx); + + if (!ares) { + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); + } + if (ares->error != LDB_SUCCESS) { + return ldb_request_done(req, ares->error); + } + switch (ares->type) { case LDB_REPLY_ENTRY: actx->count++; - ret = actx->callback(actx->private_data, ldb, ares->message); + ret = actx->callback(actx->private_data, actx->ldb, ares->message); break; case LDB_REPLY_REFERRAL: @@ -118,21 +129,22 @@ static int test_schema_search_callback(struct ldb_context *ldb, void *context, s actx->pending = true; } } - break; - + talloc_free(ares); + return ldb_request_done(req, LDB_SUCCESS); + default: d_printf("%s: unknown Reply Type %u\n", __location__, ares->type); - return LDB_ERR_OTHER; + return ldb_request_done(req, LDB_ERR_OTHER); } if (talloc_free(ares) == -1) { d_printf("talloc_free failed\n"); actx->pending = 0; - return LDB_ERR_OPERATIONS_ERROR; + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } if (ret) { - return LDB_ERR_OPERATIONS_ERROR; + return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR); } return LDB_SUCCESS; @@ -149,10 +161,12 @@ static bool test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE int ret; struct test_schema_ctx *actx; - req = talloc(ldb, struct ldb_request); - actx = talloc(req, struct test_schema_ctx); + actx = talloc(ldb, struct test_schema_ctx); + actx->ldb = ldb; + actx->private_data = private_data; + actx->callback= callback; - ctrl = talloc_array(req, struct ldb_control *, 2); + ctrl = talloc_array(actx, struct ldb_control *, 2); ctrl[0] = talloc(ctrl, struct ldb_control); ctrl[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID; ctrl[0]->critical = true; @@ -163,33 +177,30 @@ static bool test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE ctrl[0]->data = control; ctrl[1] = NULL; - req->operation = LDB_SEARCH; - req->op.search.base = ldb_dn_new(req, ldb, root->schemadn); - req->op.search.scope = LDB_SCOPE_SUBTREE; - req->op.search.tree = ldb_parse_tree(req, filter); - if (req->op.search.tree == NULL) return -1; - req->op.search.attrs = NULL; - req->controls = ctrl; - req->context = actx; - req->callback = test_schema_search_callback; - ldb_set_timeout(ldb, req, 0); - - actx->count = 0; - actx->ctrl = control; - actx->callback = callback; - actx->private_data = private_data; + ret = ldb_build_search_req(&req, ldb, actx, + ldb_dn_new(actx, ldb, root->schemadn), + LDB_SCOPE_SUBTREE, + filter, NULL, + ctrl, + actx, test_schema_search_callback, + NULL); + + actx->ctrl = control; + actx->count = 0; again: actx->pending = false; ret = ldb_request(ldb, req); if (ret != LDB_SUCCESS) { d_printf("search failed - %s\n", ldb_errstring(ldb)); + talloc_free(actx); return false; } ret = ldb_wait(req->handle, LDB_WAIT_ALL); if (ret != LDB_SUCCESS) { d_printf("search error - %s\n", ldb_errstring(ldb)); + talloc_free(actx); return false; } @@ -197,6 +208,7 @@ again: goto again; d_printf("filter[%s] count[%u]\n", filter, actx->count); + talloc_free(actx); return true; } diff --git a/source4/torture/ldap/uptodatevector.c b/source4/torture/ldap/uptodatevector.c index 87b7e09e13..6200f4c3de 100644 --- a/source4/torture/ldap/uptodatevector.c +++ b/source4/torture/ldap/uptodatevector.c @@ -26,7 +26,7 @@ #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" #include "dsdb/samdb/samdb.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "torture/torture.h" #include "torture/ldap/proto.h" @@ -57,15 +57,14 @@ static bool test_check_uptodatevector(struct torture_context *torture, torture_comment(torture, "Check replUpToDateVector on partition[%s]\n", ldb_dn_get_linearized(partition_dn)); - ret = ldb_search(ldb, partition_dn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(ldb, torture, &r, partition_dn, LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); if (ret != LDB_SUCCESS) { return false; } else if (r->count != 1) { talloc_free(r); return false; } - talloc_steal(torture, r); ZERO_STRUCT(utdv1); utdv_val1 = ldb_msg_find_ldb_val(r->msgs[0], "replUpToDateVector"); @@ -104,15 +103,14 @@ static bool test_check_uptodatevector(struct torture_context *torture, ret = ldb_modify(ldb, msg); if (ret != LDB_SUCCESS) return false; - ret = ldb_search(ldb, partition_dn, LDB_SCOPE_BASE, - "(objectClass=*)", attrs, &r); + ret = ldb_search(ldb, msg, &r, partition_dn, LDB_SCOPE_BASE, + attrs, "(objectClass=*)"); if (ret != LDB_SUCCESS) { return false; } else if (r->count != 1) { talloc_free(r); return false; } - talloc_steal(msg, r); ZERO_STRUCT(utdv); utdv_val = ldb_msg_find_ldb_val(r->msgs[0], "replUpToDateVector"); diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c index 463d2a5000..2b1bff40ee 100644 --- a/source4/torture/libnet/libnet_BecomeDC.c +++ b/source4/torture/libnet/libnet_BecomeDC.c @@ -26,7 +26,7 @@ #include "libnet/libnet.h" #include "lib/events/events.h" #include "dsdb/samdb/samdb.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" #include "librpc/ndr/libndr.h" diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c index d4124cc823..4a55eaa56c 100644 --- a/source4/torture/libnet/utils.c +++ b/source4/torture/libnet/utils.c @@ -27,6 +27,7 @@ #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" #include "param/param.h" +#include "torture/libnet/utils.h" bool test_opendomain(struct torture_context *tctx, diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk index cd1c7b1422..9ea212dfa5 100644 --- a/source4/torture/local/config.mk +++ b/source4/torture/local/config.mk @@ -20,23 +20,25 @@ PRIVATE_DEPENDENCIES = \ TORTURE_LOCAL_OBJ_FILES = \ $(torturesrcdir)/../lib/charset/tests/iconv.o \ - $(torturesrcdir)/../lib/talloc/testsuite.o \ - $(torturesrcdir)/../lib/replace/test/getifaddrs.o \ - $(torturesrcdir)/../lib/replace/test/os2_delete.o \ - $(torturesrcdir)/../lib/replace/test/strptime.o \ - $(torturesrcdir)/../lib/replace/test/testsuite.o \ + $(torturesrcdir)/../../lib/talloc/testsuite.o \ + $(torturesrcdir)/../../lib/replace/test/getifaddrs.o \ + $(torturesrcdir)/../../lib/replace/test/os2_delete.o \ + $(torturesrcdir)/../../lib/replace/test/strptime.o \ + $(torturesrcdir)/../../lib/replace/test/testsuite.o \ $(torturesrcdir)/../lib/messaging/tests/messaging.o \ $(torturesrcdir)/../lib/messaging/tests/irpc.o \ $(torturesrcdir)/../librpc/tests/binding_string.o \ - $(torturesrcdir)/../lib/util/tests/idtree.o \ + $(torturesrcdir)/../../lib/util/tests/idtree.o \ $(torturesrcdir)/../lib/socket/testsuite.o \ - $(torturesrcdir)/../lib/socket_wrapper/testsuite.o \ + $(torturesrcdir)/../../lib/socket_wrapper/testsuite.o \ $(torturesrcdir)/../libcli/resolve/testsuite.o \ - $(torturesrcdir)/../lib/util/tests/strlist.o \ - $(torturesrcdir)/../lib/util/tests/str.o \ - $(torturesrcdir)/../lib/util/tests/file.o \ - $(torturesrcdir)/../lib/util/tests/genrand.o \ - $(torturesrcdir)/../lib/compression/testsuite.o \ + $(torturesrcdir)/../../lib/util/tests/strlist.o \ + $(torturesrcdir)/../../lib/util/tests/str.o \ + $(torturesrcdir)/../../lib/util/tests/time.o \ + $(torturesrcdir)/../../lib/util/tests/data_blob.o \ + $(torturesrcdir)/../../lib/util/tests/file.o \ + $(torturesrcdir)/../../lib/util/tests/genrand.o \ + $(torturesrcdir)/../../lib/compression/testsuite.o \ $(torturesrcdir)/../lib/charset/tests/charset.o \ $(torturesrcdir)/../libcli/security/tests/sddl.o \ $(torturesrcdir)/../lib/tdr/testsuite.o \ diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c index 017c8568f4..9547e9ff74 100644 --- a/source4/torture/local/dbspeed.c +++ b/source4/torture/local/dbspeed.c @@ -21,7 +21,7 @@ #include "includes.h" #include "system/filesys.h" -#include "lib/tdb/include/tdb.h" +#include "../tdb/include/tdb.h" #include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb_errors.h" #include "lib/ldb_wrap.h" @@ -211,21 +211,18 @@ static bool test_ldb_speed(struct torture_context *torture, const void *_data) for (count=0;timeval_elapsed(&tv) < timelimit;count++) { struct ldb_dn *dn; struct ldb_result *res; - char *expr; i = random() % torture_entries; dn = ldb_dn_new_fmt(tmp_ctx, ldb, "SID=S-1-5-21-53173311-3623041448-2049097239-%u", i); - if (ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res) != LDB_SUCCESS || res->count != 1) { + if (ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL) != LDB_SUCCESS || res->count != 1) { torture_fail(torture, talloc_asprintf(torture, "Failed to find SID %d", i)); } talloc_free(res); talloc_free(dn); - expr = talloc_asprintf(tmp_ctx, "(UID=%u)", i); - if (ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res) != LDB_SUCCESS || res->count != 1) { + if (ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(UID=%u)", i) != LDB_SUCCESS || res->count != 1) { torture_fail(torture, talloc_asprintf(torture, "Failed to find UID %d", i)); } talloc_free(res); - talloc_free(expr); } if (talloc_total_blocks(torture) > 100) { diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c index bf53df4a11..6b38cd6db0 100644 --- a/source4/torture/local/local.c +++ b/source4/torture/local/local.c @@ -23,7 +23,7 @@ #include "torture/ndr/ndr.h" #include "torture/ndr/proto.h" #include "torture/auth/proto.h" -#include "lib/crypto/test_proto.h" +#include "../lib/crypto/test_proto.h" #include "lib/registry/tests/proto.h" /* ignore me */ static struct torture_suite * @@ -36,6 +36,8 @@ torture_local_util_strlist, torture_local_util_file, torture_local_util_str, + torture_local_util_time, + torture_local_util_data_blob, torture_local_idtree, torture_local_genrand, torture_local_iconv, diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index 9c7bffb6f4..69b966b31b 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -117,8 +117,10 @@ static struct smbcli_state *connect_one(struct event_context *ev, NTSTATUS status; int retries = 10; struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(lp_ctx, &options); + lp_smbcli_session_options(lp_ctx, &session_options); printf("connect_one(%s, %d, %d)\n", share, snum, conn); @@ -135,7 +137,7 @@ static struct smbcli_state *connect_one(struct event_context *ev, p = lp_parm_string(lp_ctx, NULL, "torture", "unclist"); if (p) { char *h, *s; - unc_list = file_lines_load(p, &num_unc_names, NULL); + unc_list = file_lines_load(p, &num_unc_names, 0, NULL); if (!unc_list || num_unc_names <= 0) { printf("Failed to load unc names list from '%s'\n", p); exit(1); @@ -164,7 +166,7 @@ static struct smbcli_state *connect_one(struct event_context *ev, share, NULL, servers[snum], lp_resolve_context(lp_ctx), - ev, &options); + ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { sleep(2); } diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c index e6c4728f0d..b49b8d256a 100644 --- a/source4/torture/locktest2.c +++ b/source4/torture/locktest2.c @@ -138,7 +138,8 @@ static bool try_unlock(struct smbcli_state *c, int fstype, return a connection to a server *******************************************************/ static struct smbcli_state *connect_one(char *share, const char **ports, - struct smb_options *optionsi, + struct smb_options *options, + struct smb_options *session_options, struct event_context *ev) { struct smbcli_state *c; @@ -168,7 +169,7 @@ static struct smbcli_state *connect_one(char *share, const char **ports, nt_status = smbcli_full_connection(NULL, &c, myname, server_n, ports, share, NULL, username, lp_workgroup(), password, ev, - options); + options, session_options); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status))); return NULL; @@ -185,6 +186,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], const char **ports, struct smbcli_options *options, + struct smbcli_session_options *session_options, struct event_context *ev, char *share1, char *share2) { @@ -204,7 +206,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], smbcli_ulogoff(cli[server][conn]); talloc_free(cli[server][conn]); } - cli[server][conn] = connect_one(share[server], ports, options, ev); + cli[server][conn] = connect_one(share[server], ports, options, session_options, ev); if (!cli[server][conn]) { DEBUG(0,("Failed to connect to %s\n", share[server])); exit(1); @@ -354,6 +356,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options, + struct smbcli_session_options *session_options, struct event_context *ev) { struct smbcli_state *cli[NSERVERS][NCONNECTIONS]; @@ -383,7 +386,7 @@ static void test_locks(char *share1, char *share2, recorded[n].needed = true; } - reconnect(cli, nfs, fnum, ports, options, ev, share1, share2); + reconnect(cli, nfs, fnum, ports, options, session_options, ev, share1, share2); open_files(cli, nfs, fnum); n = retest(cli, nfs, fnum, numops); @@ -394,7 +397,7 @@ static void test_locks(char *share1, char *share2, n1 = n; close_files(cli, nfs, fnum); - reconnect(cli, nfs, fnum, ports, options, ev, share1, share2); + reconnect(cli, nfs, fnum, ports, options, session_options, ev, share1, share2); open_files(cli, nfs, fnum); for (i=0;iresponse_type == NETLOGON_GET_PDC, "Got incorrect type of netlogon response"); - torture_assert(tctx, response->get_pdc.command == NETLOGON_RESPONSE_FROM_PDC, "Got incorrect netlogon response command"); + torture_assert(tctx, response->data.get_pdc.command == NETLOGON_RESPONSE_FROM_PDC, "Got incorrect netlogon response command"); return true; } @@ -243,10 +243,10 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX, "Got incorrect netlogon response command"); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.nt_version, NETLOGON_NT_VERSION_5EX_WITH_IP|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_1, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.nt_version, NETLOGON_NT_VERSION_5EX_WITH_IP|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_1, "Got incorrect netlogon response command"); /* setup (another) temporary mailslot listener for replies */ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, @@ -282,11 +282,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); - torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); + torture_assert_str_equal(tctx, response->data.samlogon.data.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); join_ctx = torture_join_domain(tctx, TEST_NAME, ACB_WSTRUST, &machine_credentials); @@ -333,9 +333,9 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); /* setup (another) temporary mailslot listener for replies */ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, @@ -374,9 +374,9 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); dgmslot->private = NULL; @@ -413,9 +413,9 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command"); torture_leave_domain(tctx, join_ctx); return true; @@ -522,11 +522,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); - torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); + torture_assert_str_equal(tctx, response->data.samlogon.data.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); /* setup a temporary mailslot listener for replies */ @@ -566,11 +566,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response"); - map_netlogon_samlogon_response(&response->samlogon); + map_netlogon_samlogon_response(&response->data.samlogon); - torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); + torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); - torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); + torture_assert_str_equal(tctx, response->data.samlogon.data.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response"); /* setup (another) temporary mailslot listener for replies */ @@ -606,7 +606,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_GET_PDC, "Got incorrect type of ntlogon response"); - torture_assert_int_equal(tctx, response->get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command"); + torture_assert_int_equal(tctx, response->data.get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command"); torture_leave_domain(tctx, join_ctx); @@ -643,7 +643,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); torture_assert_int_equal(tctx, response->response_type, NETLOGON_GET_PDC, "Got incorrect type of ntlogon response"); - torture_assert_int_equal(tctx, response->get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command"); + torture_assert_int_equal(tctx, response->data.get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command"); return true; diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c index 7d35fc856a..aee0c54358 100644 --- a/source4/torture/nbt/nbt.c +++ b/source4/torture/nbt/nbt.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "libcli/nbt/libnbt.h" +#include "../libcli/nbt/libnbt.h" #include "torture/torture.h" #include "torture/nbt/proto.h" #include "torture/smbtorture.h" diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c index 80027a1b68..b1b703a3c2 100644 --- a/source4/torture/nbt/query.c +++ b/source4/torture/nbt/query.c @@ -33,7 +33,7 @@ struct result_struct { static void increment_handler(struct nbt_name_request *req) { - struct result_struct *v = talloc_get_type(req->async.private, struct result_struct); + struct result_struct *v = talloc_get_type(req->async.private_data, struct result_struct); if (req->state != NBT_REQUEST_DONE) { v->num_fail++; } else { @@ -76,7 +76,7 @@ static bool bench_namequery(struct torture_context *tctx) req = nbt_name_query_send(nbtsock, &io); torture_assert(tctx, req != NULL, "Failed to setup request!"); req->async.fn = increment_handler; - req->async.private = result; + req->async.private_data = result; num_sent++; if (num_sent % 1000 == 0) { if (torture_setting_bool(tctx, "progress", true)) { diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c index ad9a97f133..0399daedf0 100644 --- a/source4/torture/nbt/wins.c +++ b/source4/torture/nbt/wins.c @@ -95,8 +95,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address torture_comment(tctx, "register the name\n"); io.in.name = *name; io.in.wins_port = lp_nbt_port(tctx->lp_ctx); - io.in.wins_servers = str_list_make(tctx, address, NULL); - io.in.addresses = str_list_make(tctx, myaddress, NULL); + io.in.wins_servers = (const char **)str_list_make(tctx, address, NULL); + io.in.addresses = (const char **)str_list_make(tctx, myaddress, NULL); io.in.nb_flags = nb_flags; io.in.ttl = 300000; @@ -168,8 +168,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address torture_comment(tctx, "refresh the name\n"); refresh.in.name = *name; refresh.in.wins_port = lp_nbt_port(tctx->lp_ctx); - refresh.in.wins_servers = str_list_make(tctx, address, NULL); - refresh.in.addresses = str_list_make(tctx, myaddress, NULL); + refresh.in.wins_servers = (const char **)str_list_make(tctx, address, NULL); + refresh.in.addresses = (const char **)str_list_make(tctx, myaddress, NULL); refresh.in.nb_flags = nb_flags; refresh.in.ttl = 12345; diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c index a0d90fb653..bea3d4f9cf 100644 --- a/source4/torture/nbt/winsbench.c +++ b/source4/torture/nbt/winsbench.c @@ -56,7 +56,7 @@ static struct nbt_name generate_name(TALLOC_CTX *tctx, int idx) static void register_handler(struct nbt_name_request *req) { - struct idx_state *istate = talloc_get_type(req->async.private, struct idx_state); + struct idx_state *istate = talloc_get_type(req->async.private_data, struct idx_state); struct wins_state *state = istate->state; struct nbt_name_register io; NTSTATUS status; @@ -100,7 +100,7 @@ static void generate_register(struct nbt_name_socket *nbtsock, struct wins_state req = nbt_name_register_send(nbtsock, &io); req->async.fn = register_handler; - req->async.private = istate; + req->async.private_data = istate; talloc_free(tmp_ctx); } @@ -108,7 +108,7 @@ static void generate_register(struct nbt_name_socket *nbtsock, struct wins_state static void release_handler(struct nbt_name_request *req) { - struct idx_state *istate = talloc_get_type(req->async.private, struct idx_state); + struct idx_state *istate = talloc_get_type(req->async.private_data, struct idx_state); struct wins_state *state = istate->state; struct nbt_name_release io; NTSTATUS status; @@ -150,7 +150,7 @@ static void generate_release(struct nbt_name_socket *nbtsock, struct wins_state req = nbt_name_release_send(nbtsock, &io); req->async.fn = release_handler; - req->async.private = istate; + req->async.private_data = istate; talloc_free(tmp_ctx); } @@ -158,7 +158,7 @@ static void generate_release(struct nbt_name_socket *nbtsock, struct wins_state static void query_handler(struct nbt_name_request *req) { - struct idx_state *istate = talloc_get_type(req->async.private, struct idx_state); + struct idx_state *istate = talloc_get_type(req->async.private_data, struct idx_state); struct wins_state *state = istate->state; struct nbt_name_query io; NTSTATUS status; @@ -197,7 +197,7 @@ static void generate_query(struct nbt_name_socket *nbtsock, struct wins_state *s req = nbt_name_query_send(nbtsock, &io); req->async.fn = query_handler; - req->async.private = istate; + req->async.private_data = istate; talloc_free(tmp_ctx); } diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c index 6b600bd7cd..b688f1fbfe 100644 --- a/source4/torture/nbt/winsreplication.c +++ b/source4/torture/nbt/winsreplication.c @@ -9457,7 +9457,7 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_ struct nbt_name *name; struct nbt_name_packet *rep_packet; struct test_conflict_owned_active_vs_replica_struct *rec = - (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private; + (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private_data; _NBT_ASSERT(req_packet->qdcount, 1); _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS); @@ -9556,7 +9556,7 @@ static void test_conflict_owned_active_vs_replica_handler_release( struct nbt_name *name; struct nbt_name_packet *rep_packet; struct test_conflict_owned_active_vs_replica_struct *rec = - (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private; + (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private_data; _NBT_ASSERT(req_packet->qdcount, 1); _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS); @@ -9610,7 +9610,7 @@ static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket struct socket_address *src) { struct test_conflict_owned_active_vs_replica_struct *rec = - (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private; + (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private_data; rec->defend.ret = false; diff --git a/source4/torture/ndr/lsa.c b/source4/torture/ndr/lsa.c index a72a03fa38..0d6d786882 100644 --- a/source4/torture/ndr/lsa.c +++ b/source4/torture/ndr/lsa.c @@ -1538,8 +1538,8 @@ static bool lsarlookupnames2_in_check(struct torture_context *tctx, torture_assert_str_equal(tctx, r->in.names[1].string, "Administrators", "names[1]"); torture_assert_int_equal(tctx, r->in.level, 1, "level"); - torture_assert_int_equal(tctx, r->in.unknown1, 0, "unknown 1"); - torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown 2"); + torture_assert_int_equal(tctx, r->in.lookup_options, 0, "lookup_options"); + torture_assert_int_equal(tctx, r->in.client_revision, 0, "client_revision"); torture_assert_int_equal(tctx, *r->in.count, 0, "count"); torture_assert_int_equal(tctx, r->in.sids->count, 0, "sids count"); torture_assert(tctx, r->in.sids->sids == NULL, "sids sids"); @@ -1637,8 +1637,8 @@ static bool lsarlookupnames3_in_check(struct torture_context *tctx, torture_assert_str_equal(tctx, r->in.names[1].string, "Administrators", "names[1]"); torture_assert_int_equal(tctx, r->in.level, 1, "level"); - torture_assert_int_equal(tctx, r->in.unknown1, 0, "unknown 1"); - torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown 2"); + torture_assert_int_equal(tctx, r->in.lookup_options, 0, "lookup_options"); + torture_assert_int_equal(tctx, r->in.client_revision, 0, "client_revision"); torture_assert_int_equal(tctx, *r->in.count, 0, "count"); torture_assert_int_equal(tctx, r->in.sids->count, 0, "sids count"); torture_assert(tctx, r->in.sids->sids == NULL, "sids sids"); diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c index 63636f8c5f..70bd070009 100644 --- a/source4/torture/ndr/ndr.c +++ b/source4/torture/ndr/ndr.c @@ -22,7 +22,7 @@ #include "torture/ndr/ndr.h" #include "torture/ndr/proto.h" #include "torture/torture.h" -#include "util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" struct ndr_pull_test_data { @@ -96,7 +96,7 @@ static bool test_check_string_terminator(struct torture_context *tctx) TALLOC_CTX *mem_ctx = tctx; /* Simple test */ - blob = strhex_to_data_blob("0000"); + blob = strhex_to_data_blob(tctx, "0000"); ndr = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx)); @@ -115,7 +115,7 @@ static bool test_check_string_terminator(struct torture_context *tctx) talloc_free(ndr); - blob = strhex_to_data_blob("11220000"); + blob = strhex_to_data_blob(tctx, "11220000"); ndr = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx)); torture_assert_ndr_success(tctx, diff --git a/source4/torture/ndr/winreg.c b/source4/torture/ndr/winreg.c index ab256a7152..de804b7721 100644 --- a/source4/torture/ndr/winreg.c +++ b/source4/torture/ndr/winreg.c @@ -197,10 +197,10 @@ static const uint8_t queryvalue_in_data[] = { static bool queryvalue_in_check(struct torture_context *tctx, struct winreg_QueryValue *r) { - torture_assert_str_equal(tctx, r->in.value_name.name, "HOMEPATH", "name"); + torture_assert_str_equal(tctx, r->in.value_name->name, "HOMEPATH", "name"); torture_assert_int_equal(tctx, *r->in.type, 0, "type"); - torture_assert_int_equal(tctx, *r->in.size, 4095, "size"); - torture_assert_int_equal(tctx, *r->in.length, 0, "length"); + torture_assert_int_equal(tctx, *r->in.data_size, 4095, "size"); + torture_assert_int_equal(tctx, *r->in.data_length, 0, "length"); torture_assert(tctx, r->in.data == NULL, "data pointer"); return true; @@ -218,8 +218,8 @@ static bool queryvalue_out_check(struct torture_context *tctx, torture_assert_werr_ok(tctx, r->out.result, "return code"); torture_assert_int_equal(tctx, *r->out.type, 1, "type"); torture_assert(tctx, r->out.data == NULL, "data pointer"); - torture_assert_int_equal(tctx, *r->out.size, 76, "size"); - torture_assert_int_equal(tctx, *r->out.length, 0, "length"); + torture_assert_int_equal(tctx, *r->out.data_size, 76, "size"); + torture_assert_int_equal(tctx, *r->out.data_length, 0, "length"); return true; } @@ -417,7 +417,7 @@ static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_Q torture_assert_str_equal(tctx, r->out.classname->name, "", "class out name"); torture_assert_int_equal(tctx, *r->out.num_subkeys, 0, "num subkeys"); torture_assert_int_equal(tctx, *r->out.max_subkeylen, 0, "subkey length"); - torture_assert_int_equal(tctx, *r->out.max_subkeysize, 140, "subkey size"); + torture_assert_int_equal(tctx, *r->out.max_classlen, 140, "subkey size"); torture_assert_werr_ok(tctx, r->out.result, "return code"); return true; } diff --git a/source4/torture/raw/chkpath.c b/source4/torture/raw/chkpath.c index 2ed83d308c..68ef8e226d 100644 --- a/source4/torture/raw/chkpath.c +++ b/source4/torture/raw/chkpath.c @@ -147,11 +147,11 @@ static bool test_chkpath(struct smbcli_state *cli, struct torture_context *tctx) } ret &= test_path_ex(cli, tctx, BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); - ret &= test_path_ex(cli, tctx, ((char *)BASEDIR) + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); - ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); - ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\foo\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); - ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\f\\o\\o\\..\\..\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); - ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\foo\\\\..\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); + ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR) + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); + ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); + ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\foo\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); + ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\f\\o\\o\\..\\..\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); + ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\foo\\\\..\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); ret &= test_path_ex(cli, tctx, BASEDIR"\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK); ret &= test_path_ex(cli, tctx, BASEDIR"\\\\..\\"BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK); ret &= test_path_ex(cli, tctx, BASEDIR"\\\\\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK); diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c index d73ac1327e..7f1f5943e1 100644 --- a/source4/torture/raw/composite.c +++ b/source4/torture/raw/composite.c @@ -164,6 +164,7 @@ static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tct io2.in.filename = fname; io2.in.resolve_ctx = lp_resolve_context(tctx->lp_ctx); lp_smbcli_options(tctx->lp_ctx, &io2.in.options); + lp_smbcli_session_options(tctx->lp_ctx, &io2.in.session_options); printf("testing parallel fetchfile with %d ops\n", torture_numops); @@ -358,7 +359,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx) c = talloc_array(tctx, struct composite_context *, torture_numops); for (i=0; itree,&io1); + c[i] = smb_composite_fsinfo_send(cli->tree, &io1, lp_resolve_context(tctx->lp_ctx)); c[i]->async.fn = loadfile_complete; c[i]->async.private_data = count; } diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c index 15e736fff5..450ad0f260 100644 --- a/source4/torture/raw/context.c +++ b/source4/torture/raw/context.c @@ -81,6 +81,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx) const char *fname = BASEDIR "\\test.txt"; uint8_t c = 1; int i; + struct smbcli_session_options options; printf("TESTING SESSION HANDLING\n"); @@ -89,7 +90,10 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx) } printf("create a second security context on the same transport\n"); - session = smbcli_session_init(cli->transport, tctx, false); + + lp_smbcli_session_options(tctx->lp_ctx, &options); + + session = smbcli_session_init(cli->transport, tctx, false, options); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ @@ -103,7 +107,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx) session->vuid = setup.out.vuid; printf("create a third security context on the same transport, with vuid set\n"); - session2 = smbcli_session_init(cli->transport, tctx, false); + session2 = smbcli_session_init(cli->transport, tctx, false, options); session2->vuid = session->vuid; setup.in.sesskey = cli->transport->negotiate.sesskey; @@ -130,7 +134,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx) if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) { printf("create a fourth security context on the same transport, without extended security\n"); - session3 = smbcli_session_init(cli->transport, tctx, false); + session3 = smbcli_session_init(cli->transport, tctx, false, options); session3->vuid = session->vuid; setup.in.sesskey = cli->transport->negotiate.sesskey; @@ -144,7 +148,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx) CHECK_STATUS(status, NT_STATUS_LOGON_FAILURE); printf("create a fouth anonymous security context on the same transport, without extended security\n"); - session4 = smbcli_session_init(cli->transport, tctx, false); + session4 = smbcli_session_init(cli->transport, tctx, false, options); session4->vuid = session->vuid; setup.in.sesskey = cli->transport->negotiate.sesskey; @@ -230,7 +234,7 @@ static bool test_session(struct smbcli_state *cli, struct torture_context *tctx) setups[i].in.credentials = cmdline_credentials; - sessions[i] = smbcli_session_init(cli->transport, tctx, false); + sessions[i] = smbcli_session_init(cli->transport, tctx, false, options); composite_contexts[i] = smb_composite_sesssetup_send(sessions[i], &setups[i]); } @@ -379,6 +383,7 @@ static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context * const char *fname1 = BASEDIR "\\test1.txt"; const char *fname2 = BASEDIR "\\test2.txt"; uint8_t c = 1; + struct smbcli_session_options options; printf("TESTING TREE with ulogoff\n"); @@ -389,8 +394,10 @@ static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context * share = torture_setting_string(tctx, "share", NULL); host = torture_setting_string(tctx, "host", NULL); + lp_smbcli_session_options(tctx->lp_ctx, &options); + printf("create the first new sessions\n"); - session1 = smbcli_session_init(cli->transport, tctx, false); + session1 = smbcli_session_init(cli->transport, tctx, false, options); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; setup.in.workgroup = lp_workgroup(tctx->lp_ctx); @@ -446,7 +453,7 @@ static bool test_tree_ulogoff(struct smbcli_state *cli, struct torture_context * CHECK_STATUS(status, NT_STATUS_OK); printf("create the second new sessions\n"); - session2 = smbcli_session_init(cli->transport, tctx, false); + session2 = smbcli_session_init(cli->transport, tctx, false, options); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; setup.in.workgroup = lp_workgroup(tctx->lp_ctx); @@ -634,6 +641,7 @@ static bool test_pid_2sess(struct smbcli_state *cli, struct torture_context *tct const char *fname = BASEDIR "\\test.txt"; uint8_t c = 1; uint16_t vuid1, vuid2; + struct smbcli_session_options options; printf("TESTING PID HANDLING WITH 2 SESSIONS\n"); @@ -641,8 +649,10 @@ static bool test_pid_2sess(struct smbcli_state *cli, struct torture_context *tct return false; } + lp_smbcli_session_options(tctx->lp_ctx, &options); + printf("create a second security context on the same transport\n"); - session = smbcli_session_init(cli->transport, tctx, false); + session = smbcli_session_init(cli->transport, tctx, false, options); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c index cd8d606795..dbe071c9ad 100644 --- a/source4/torture/raw/lock.c +++ b/source4/torture/raw/lock.c @@ -456,11 +456,14 @@ static bool test_async(struct torture_context *tctx, const char *fname = BASEDIR "\\test.txt"; time_t t; struct smbcli_request *req; + struct smbcli_session_options options; if (!torture_setup_dir(cli, BASEDIR)) { return false; } + lp_smbcli_session_options(tctx->lp_ctx, &options); + printf("Testing LOCKING_ANDX_CANCEL_LOCK\n"); io.generic.level = RAW_LOCK_LOCKX; @@ -590,7 +593,7 @@ static bool test_async(struct torture_context *tctx, } printf("create a new sessions\n"); - session = smbcli_session_init(cli->transport, tctx, false); + session = smbcli_session_init(cli->transport, tctx, false, options); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; setup.in.workgroup = lp_workgroup(tctx->lp_ctx); diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 21541d003b..26fad4235e 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -195,6 +195,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, io->in.fallback_to_anonymous = false; io->in.workgroup = lp_workgroup(state->tctx->lp_ctx); lp_smbcli_options(state->tctx->lp_ctx, &io->in.options); + lp_smbcli_session_options(state->tctx->lp_ctx, &io->in.session_options); /* kill off the remnants of the old connection */ talloc_free(state->tree); diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 25c91eb88b..d7541b7c71 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -583,7 +583,9 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.recursive = true; -#define NOTIFY_MASK_TEST(setup, op, cleanup, Action, expected, nchanges) \ +#define NOTIFY_MASK_TEST(test_name, setup, op, cleanup, Action, expected, nchanges) \ + do { \ + smbcli_getatr(cli->tree, test_name, NULL, NULL, NULL); \ do { for (mask=i=0;i<32;i++) { \ struct smbcli_request *req; \ status = smb_raw_open(cli->tree, tctx, &io); \ @@ -640,24 +642,25 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t mask, expected); \ } \ } \ - } while (0) + } while (0); \ + } while (0); printf("testing mkdir\n"); - NOTIFY_MASK_TEST(;, + NOTIFY_MASK_TEST("testing mkdir",;, smbcli_mkdir(cli->tree, BASEDIR "\\tname1");, smbcli_rmdir(cli->tree, BASEDIR "\\tname1");, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME, 1); printf("testing create file\n"); - NOTIFY_MASK_TEST(;, + NOTIFY_MASK_TEST("testing create file",;, smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, smbcli_unlink(cli->tree, BASEDIR "\\tname1");, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_FILE_NAME, 1); printf("testing unlink\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing unlink", smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, smbcli_unlink(cli->tree, BASEDIR "\\tname1");, ;, @@ -665,7 +668,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_FILE_NAME, 1); printf("testing rmdir\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing rmdir", smbcli_mkdir(cli->tree, BASEDIR "\\tname1");, smbcli_rmdir(cli->tree, BASEDIR "\\tname1");, ;, @@ -673,7 +676,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_DIR_NAME, 1); printf("testing rename file\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing rename file", smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, smbcli_rename(cli->tree, BASEDIR "\\tname1", BASEDIR "\\tname2");, smbcli_unlink(cli->tree, BASEDIR "\\tname2");, @@ -681,7 +684,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_ATTRIBUTES|FILE_NOTIFY_CHANGE_CREATION, 2); printf("testing rename dir\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing rename dir", smbcli_mkdir(cli->tree, BASEDIR "\\tname1");, smbcli_rename(cli->tree, BASEDIR "\\tname1", BASEDIR "\\tname2");, smbcli_rmdir(cli->tree, BASEDIR "\\tname2");, @@ -689,7 +692,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_DIR_NAME, 2); printf("testing set path attribute\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set path attribute", smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN, 0);, smbcli_unlink(cli->tree, BASEDIR "\\tname1");, @@ -697,7 +700,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_ATTRIBUTES, 1); printf("testing set path write time\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set path write time", smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));, smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_NORMAL, 1000);, smbcli_unlink(cli->tree, BASEDIR "\\tname1");, @@ -705,7 +708,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_LAST_WRITE, 1); printf("testing set file attribute\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set file attribute", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_fsetatr(cli->tree, fnum2, FILE_ATTRIBUTE_HIDDEN, 0, 0, 0, 0);, (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));, @@ -718,7 +721,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t } else { printf("testing set file create time\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set file create time", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_fsetatr(cli->tree, fnum2, 0, t, 0, 0, 0);, @@ -729,7 +732,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t } printf("testing set file access time\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set file access time", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_fsetatr(cli->tree, fnum2, 0, 0, t, 0, 0);, (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));, @@ -737,7 +740,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_LAST_ACCESS, 1); printf("testing set file write time\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set file write time", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, t, 0);, (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));, @@ -745,7 +748,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t FILE_NOTIFY_CHANGE_LAST_WRITE, 1); printf("testing set file change time\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing set file change time", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, 0, t);, (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));, @@ -754,7 +757,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t printf("testing write\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing write", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_write(cli->tree, fnum2, 1, &c, 10000, 1);, (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));, @@ -762,7 +765,7 @@ static bool test_notify_mask(struct smbcli_state *cli, struct torture_context *t 0, 1); printf("testing truncate\n"); - NOTIFY_MASK_TEST( + NOTIFY_MASK_TEST("testing truncate", fnum2 = create_complex_file(cli, tctx, BASEDIR "\\tname1");, smbcli_ftruncate(cli->tree, fnum2, 10000);, (smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));, diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c index f3494ea3d0..dd5ef0d0b9 100644 --- a/source4/torture/raw/open.c +++ b/source4/torture/raw/open.c @@ -1545,6 +1545,64 @@ static bool test_raw_open_multi(struct torture_context *tctx) return ret; } +/* + test opening for delete on a read-only attribute file. +*/ +static bool test_open_for_delete(struct smbcli_state *cli, struct torture_context *tctx) +{ + union smb_open io; + union smb_fileinfo finfo; + const char *fname = BASEDIR "\\torture_open_for_delete.txt"; + NTSTATUS status; + int fnum = -1; + bool ret = true; + + printf("Checking RAW_NTCREATEX for delete on a readonly file.\n"); + + /* reasonable default parameters */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_READONLY; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname; + + /* Create the readonly file. */ + + status = smb_raw_open(cli->tree, tctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + CHECK_VAL(io.ntcreatex.out.oplock_level, 0); + io.ntcreatex.in.create_options = 0; + CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED); + CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib); + smbcli_close(cli->tree, fnum); + + /* Now try and open for delete only - should succeed. */ + io.ntcreatex.in.access_mask = SEC_STD_DELETE; + io.ntcreatex.in.file_attr = 0; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + status = smb_raw_open(cli->tree, tctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + smbcli_unlink(cli->tree, fname); + +done: + smbcli_close(cli->tree, fnum); + smbcli_unlink(cli->tree, fname); + + return ret; +} + + /* basic testing of all RAW_OPEN_* calls */ bool torture_raw_open(struct torture_context *torture, struct smbcli_state *cli) @@ -1567,6 +1625,7 @@ bool torture_raw_open(struct torture_context *torture, struct smbcli_state *cli) ret &= test_ctemp(cli, torture); ret &= test_chained(cli, torture); ret &= test_no_leading_slash(cli, torture); + ret &= test_open_for_delete(cli, torture); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index 26b862c33f..ec94637445 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -137,6 +137,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, io->in.fallback_to_anonymous = false; io->in.workgroup = lp_workgroup(state->tctx->lp_ctx); lp_smbcli_options(state->tctx->lp_ctx, &io->in.options); + lp_smbcli_session_options(state->tctx->lp_ctx, &io->in.session_options); /* kill off the remnants of the old connection */ talloc_free(state->tree); diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index fd8d292980..19924e731b 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -175,10 +175,11 @@ static bool open_connection_no_level2_oplocks(struct torture_context *tctx, struct smbcli_state **c) { NTSTATUS status; - struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(tctx->lp_ctx, &options); + lp_smbcli_session_options(tctx->lp_ctx, &session_options); options.use_level2_oplocks = false; @@ -188,7 +189,7 @@ static bool open_connection_no_level2_oplocks(struct torture_context *tctx, torture_setting_string(tctx, "share", NULL), NULL, cmdline_credentials, lp_resolve_context(tctx->lp_ctx), - tctx->ev, &options); + tctx->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); return false; @@ -2787,6 +2788,75 @@ done: return ret; } +static bool test_raw_oplock_batch25(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) +{ + const char *fname = BASEDIR "\\test_batch25.dat"; + NTSTATUS status; + bool ret = true; + union smb_open io; + union smb_setfileinfo sfi; + uint16_t fnum=0; + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname); + + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + + /* + base ntcreatex parms + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname; + + torture_comment(tctx, "BATCH25: open a file with an batch oplock " + "(share mode: none)\n"); + + ZERO_STRUCT(break_info); + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | + NTCREATEX_FLAGS_REQUEST_OPLOCK | + NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + status = smb_raw_open(cli1->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); + + torture_comment(tctx, "setpathinfo attribute info should not trigger " + "a break nor a violation\n"); + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_SETATTR; + sfi.generic.in.file.path = fname; + sfi.setattr.in.attrib = FILE_ATTRIBUTE_HIDDEN; + sfi.setattr.in.write_time = 0; + + status = smb_raw_setpathinfo(cli2->tree, &sfi); + + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VAL(break_info.count, 0); + + smbcli_close(cli1->tree, fnum); + +done: + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smbcli_deltree(cli1->tree, BASEDIR); + return ret; +} + /* basic testing of oplocks */ @@ -2824,6 +2894,7 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx) torture_suite_add_2smb_test(suite, "BATCH22", test_raw_oplock_batch22); torture_suite_add_2smb_test(suite, "BATCH23", test_raw_oplock_batch23); torture_suite_add_2smb_test(suite, "BATCH24", test_raw_oplock_batch24); + torture_suite_add_2smb_test(suite, "BATCH25", test_raw_oplock_batch25); return suite; } diff --git a/source4/torture/raw/tconrate.c b/source4/torture/raw/tconrate.c index 6f0ba0d617..66ef2ae2dd 100644 --- a/source4/torture/raw/tconrate.c +++ b/source4/torture/raw/tconrate.c @@ -69,8 +69,10 @@ static int fork_tcon_client(struct torture_context *tctx, struct timeval end; struct timeval now; struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(tctx->lp_ctx, &options); + lp_smbcli_session_options(tctx->lp_ctx, &session_options); child = fork(); if (child == -1) { @@ -100,7 +102,7 @@ static int fork_tcon_client(struct torture_context *tctx, host, lp_smb_ports(tctx->lp_ctx), share, NULL, cmdline_credentials, lp_resolve_context(tctx->lp_ctx), - tctx->ev, &options); + tctx->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to //%s/%s: %s\n", diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e5cb3d7ddf..da6ce2b5f5 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -62,6 +62,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; + union drsuapi_DsGetDCInfoCtr ctr; + int32_t level_out = 0; bool found = false; int i, j, k; @@ -91,16 +93,21 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture for (i=0; i < ARRAY_SIZE(levels); i++) { for (j=0; j < ARRAY_SIZE(names); j++) { + union drsuapi_DsGetDCInfoRequest req; level = levels[i]; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; + r.in.req = &req; - r.in.req.req1.domain_name = names[j].name; - r.in.req.req1.level = level; + r.in.req->req1.domain_name = names[j].name; + r.in.req->req1.level = level; + + r.out.ctr = &ctr; + r.out.level_out = &level_out; torture_comment(torture, "testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); + r.in.req->req1.level, r.in.req->req1.domain_name); status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); torture_assert_ntstatus_ok(torture, status, @@ -115,13 +122,13 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture } torture_assert_int_equal(torture, - r.in.req.req1.level, r.out.level_out, + r.in.req->req1.level, *r.out.level_out, "dcerpc_drsuapi_DsGetDomainControllerInfo level"); switch (level) { case 1: - for (k=0; k < r.out.ctr.ctr1.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr1.array[k].netbios_name, + for (k=0; k < r.out.ctr->ctr1.count; k++) { + if (strcasecmp_m(r.out.ctr->ctr1.array[k].netbios_name, torture_join_netbios_name(priv->join)) == 0) { found = true; break; @@ -129,11 +136,11 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture } break; case 2: - for (k=0; k < r.out.ctr.ctr2.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr2.array[k].netbios_name, + for (k=0; k < r.out.ctr->ctr2.count; k++) { + if (strcasecmp_m(r.out.ctr->ctr2.array[k].netbios_name, torture_join_netbios_name(priv->join)) == 0) { found = true; - priv->dcinfo = r.out.ctr.ctr2.array[k]; + priv->dcinfo = r.out.ctr->ctr2.array[k]; break; } } @@ -146,12 +153,15 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - - r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; /* This is clearly ignored for this level */ - r.in.req.req1.level = -1; + + r.out.ctr = &ctr; + r.out.level_out = &level_out; + + r.in.req->req1.domain_name = "__UNKNOWN_DOMAIN__"; /* This is clearly ignored for this level */ + r.in.req->req1.level = -1; printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); + r.in.req->req1.level, r.in.req->req1.domain_name); status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); @@ -164,8 +174,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture const char *dc_account = talloc_asprintf(torture, "%s\\%s$", torture_join_dom_netbios_name(priv->join), priv->dcinfo.netbios_name); - for (k=0; k < r.out.ctr.ctr01.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr01.array[k].client_account, + for (k=0; k < r.out.ctr->ctr01.count; k++) { + if (strcasecmp_m(r.out.ctr->ctr01.array[k].client_account, dc_account)) { found = true; break; @@ -184,22 +194,29 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; + union drsuapi_DsWriteAccountSpnRequest req; struct drsuapi_DsNameString names[2]; + union drsuapi_DsWriteAccountSpnResult res; + int32_t level_out; bool ret = true; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; + r.in.req = &req; printf("testing DsWriteAccountSpn\n"); - r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_ADD; - r.in.req.req1.unknown1 = 0; - r.in.req.req1.object_dn = priv->dcinfo.computer_dn; - r.in.req.req1.count = 2; - r.in.req.req1.spn_names = names; + r.in.req->req1.operation = DRSUAPI_DS_SPN_OPERATION_ADD; + r.in.req->req1.unknown1 = 0; + r.in.req->req1.object_dn = priv->dcinfo.computer_dn; + r.in.req->req1.count = 2; + r.in.req->req1.spn_names = names; names[0].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.netbios_name); names[1].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.dns_name); + r.out.res = &res; + r.out.level_out = &level_out; + status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); @@ -213,8 +230,8 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = false; } - r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; - r.in.req.req1.unknown1 = 0; + r.in.req->req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; + r.in.req->req1.unknown1 = 0; status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -237,6 +254,9 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, struct torture_context { NTSTATUS status; struct drsuapi_DsReplicaGetInfo r; + union drsuapi_DsReplicaGetInfoRequest req; + union drsuapi_DsReplicaInfo info; + enum drsuapi_DsReplicaInfoType info_type; bool ret = true; int i; struct { @@ -313,6 +333,7 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, struct torture_context } r.in.bind_handle = &priv->bind_handle; + r.in.req = &req; for (i=0; i < ARRAY_SIZE(array); i++) { const char *object_dn; @@ -325,21 +346,24 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, struct torture_context r.in.level = array[i].level; switch(r.in.level) { case DRSUAPI_DS_REPLICA_GET_INFO: - r.in.req.req1.info_type = array[i].infotype; - r.in.req.req1.object_dn = object_dn; - ZERO_STRUCT(r.in.req.req1.guid1); + r.in.req->req1.info_type = array[i].infotype; + r.in.req->req1.object_dn = object_dn; + ZERO_STRUCT(r.in.req->req1.guid1); break; case DRSUAPI_DS_REPLICA_GET_INFO2: - r.in.req.req2.info_type = array[i].infotype; - r.in.req.req2.object_dn = object_dn; - ZERO_STRUCT(r.in.req.req1.guid1); - r.in.req.req2.unknown1 = 0; - r.in.req.req2.string1 = NULL; - r.in.req.req2.string2 = NULL; - r.in.req.req2.unknown2 = 0; + r.in.req->req2.info_type = array[i].infotype; + r.in.req->req2.object_dn = object_dn; + ZERO_STRUCT(r.in.req->req2.guid1); + r.in.req->req2.unknown1 = 0; + r.in.req->req2.string1 = NULL; + r.in.req->req2.string2 = NULL; + r.in.req->req2.unknown2 = 0; break; } + r.out.info = &info; + r.out.info_type = &info_type; + status = dcerpc_drsuapi_DsReplicaGetInfo(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); @@ -501,9 +525,12 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t bool ret = true; int i; struct drsuapi_DsGetNCChanges r; + union drsuapi_DsGetNCChangesRequest req; + union drsuapi_DsGetNCChangesCtr ctr; struct drsuapi_DsReplicaObjectIdentifier nc; struct GUID null_guid; struct dom_sid null_sid; + int32_t level_out; struct { int32_t level; } array[] = { @@ -528,29 +555,32 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t array[i].level); r.in.bind_handle = &priv->bind_handle; - r.in.level = &array[i].level; + r.in.level = array[i].level; + r.out.level_out = &level_out; + r.out.ctr = &ctr; - switch (*r.in.level) { + switch (r.in.level) { case 5: nc.guid = null_guid; nc.sid = null_sid; nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; - r.in.req.req5.destination_dsa_guid = GUID_random(); - r.in.req.req5.source_dsa_invocation_id = null_guid; - r.in.req.req5.naming_context = &nc; - r.in.req.req5.highwatermark.tmp_highest_usn = 0; - r.in.req.req5.highwatermark.reserved_usn = 0; - r.in.req.req5.highwatermark.highest_usn = 0; - r.in.req.req5.uptodateness_vector = NULL; - r.in.req.req5.replica_flags = 0; + r.in.req = &req; + r.in.req->req5.destination_dsa_guid = GUID_random(); + r.in.req->req5.source_dsa_invocation_id = null_guid; + r.in.req->req5.naming_context = &nc; + r.in.req->req5.highwatermark.tmp_highest_usn = 0; + r.in.req->req5.highwatermark.reserved_usn = 0; + r.in.req->req5.highwatermark.highest_usn = 0; + r.in.req->req5.uptodateness_vector = NULL; + r.in.req->req5.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi","compression", false)) { - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - r.in.req.req5.max_object_count = 0; - r.in.req.req5.max_ndr_size = 0; - r.in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req5.fsmo_info = 0; + r.in.req->req5.max_object_count = 0; + r.in.req->req5.max_ndr_size = 0; + r.in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req5.fsmo_info = 0; break; case 8: @@ -558,33 +588,34 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t nc.sid = null_sid; nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; - r.in.req.req8.destination_dsa_guid = GUID_random(); - r.in.req.req8.source_dsa_invocation_id = null_guid; - r.in.req.req8.naming_context = &nc; - r.in.req.req8.highwatermark.tmp_highest_usn = 0; - r.in.req.req8.highwatermark.reserved_usn = 0; - r.in.req.req8.highwatermark.highest_usn = 0; - r.in.req.req8.uptodateness_vector = NULL; - r.in.req.req8.replica_flags = 0; + r.in.req = &req; + r.in.req->req8.destination_dsa_guid = GUID_random(); + r.in.req->req8.source_dsa_invocation_id = null_guid; + r.in.req->req8.naming_context = &nc; + r.in.req->req8.highwatermark.tmp_highest_usn = 0; + r.in.req->req8.highwatermark.reserved_usn = 0; + r.in.req->req8.highwatermark.highest_usn = 0; + r.in.req->req8.uptodateness_vector = NULL; + r.in.req->req8.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi", "compression", false)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi", "neighbour_writeable", true)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req8.max_object_count = 402; - r.in.req.req8.max_ndr_size = 402116; - r.in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req8.fsmo_info = 0; - r.in.req.req8.partial_attribute_set = NULL; - r.in.req.req8.partial_attribute_set_ex = NULL; - r.in.req.req8.mapping_ctr.num_mappings = 0; - r.in.req.req8.mapping_ctr.mappings = NULL; + r.in.req->req8.max_object_count = 402; + r.in.req->req8.max_ndr_size = 402116; + r.in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req8.fsmo_info = 0; + r.in.req->req8.partial_attribute_set = NULL; + r.in.req->req8.partial_attribute_set_ex = NULL; + r.in.req->req8.mapping_ctr.num_mappings = 0; + r.in.req->req8.mapping_ctr.mappings = NULL; break; } @@ -611,20 +642,23 @@ bool test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, { NTSTATUS status; struct drsuapi_QuerySitesByCost r; + union drsuapi_QuerySitesByCostRequest req; bool ret = true; const char *my_site = "Default-First-Site-Name"; const char *remote_site1 = "smbtorture-nonexisting-site1"; const char *remote_site2 = "smbtorture-nonexisting-site2"; + req.req1.site_from = talloc_strdup(mem_ctx, my_site); + req.req1.num_req = 2; + req.req1.site_to = talloc_zero_array(mem_ctx, const char *, 2); + req.req1.site_to[0] = talloc_strdup(mem_ctx, remote_site1); + req.req1.site_to[1] = talloc_strdup(mem_ctx, remote_site2); + req.req1.flags = 0; + r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.site_from = talloc_strdup(mem_ctx, my_site); - r.in.req.req1.num_req = 2; - r.in.req.req1.site_to = talloc_zero_array(mem_ctx, const char *, r.in.req.req1.num_req); - r.in.req.req1.site_to[0] = talloc_strdup(mem_ctx, remote_site1); - r.in.req.req1.site_to[1] = talloc_strdup(mem_ctx, remote_site2); - r.in.req.req1.flags = 0; + r.in.req = &req; status = dcerpc_drsuapi_QuerySitesByCost(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -641,17 +675,17 @@ bool test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (W_ERROR_IS_OK(r.out.result)) { - if (!W_ERROR_EQUAL(r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND) || - !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { + if (!W_ERROR_EQUAL(r.out.ctr->ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND) || + !W_ERROR_EQUAL(r.out.ctr->ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n", - win_errstr(r.out.ctr.ctr1.info[0].error_code)); + win_errstr(r.out.ctr->ctr1.info[0].error_code)); ret = false; } - if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) || - (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) { + if ((r.out.ctr->ctr1.info[0].site_cost != (uint32_t) -1) || + (r.out.ctr->ctr1.info[1].site_cost != (uint32_t) -1)) { printf("expected site_cost %d, got %d\n", - (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost); + (uint32_t) -1, r.out.ctr->ctr1.info[0].site_cost); ret = false; } } diff --git a/source4/torture/rpc/drsuapi_cracknames.c b/source4/torture/rpc/drsuapi_cracknames.c index fbda69df57..dabd4125c7 100644 --- a/source4/torture/rpc/drsuapi_cracknames.c +++ b/source4/torture/rpc/drsuapi_cracknames.c @@ -38,7 +38,12 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NTSTATUS status; bool ret = true; struct drsuapi_DsCrackNames r; + union drsuapi_DsNameRequest req; + int32_t level_out; + union drsuapi_DsNameCtr ctr; + enum drsuapi_DsNameFormat formats[] = { + DRSUAPI_DS_NAME_FORMAT_UNKNOWN, DRSUAPI_DS_NAME_FORMAT_FQDN_1779, DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, DRSUAPI_DS_NAME_FORMAT_DISPLAY, @@ -59,17 +64,21 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ZERO_STRUCT(r); r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.codepage = 1252; /* german */ - r.in.req.req1.language = 0x00000407; /* german */ - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r.in.req = &req; + r.in.req->req1.codepage = 1252; /* german */ + r.in.req->req1.language = 0x00000407; /* german */ + r.in.req->req1.count = 1; + r.in.req->req1.names = names; + r.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + + r.out.level_out = &level_out; + r.out.ctr = &ctr; n_matrix[0][0] = dn; for (i = 0; i < ARRAY_SIZE(formats); i++) { - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - r.in.req.req1.format_desired = formats[i]; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_desired = formats[i]; names[0].str = dn; status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -78,13 +87,13 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired); printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired); printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; @@ -95,33 +104,33 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } switch (formats[i]) { case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) { + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - r.out.ctr.ctr1->array[0].status); + r.out.ctr->ctr1->array[0].status); return false; } printf ("(expected) error\n"); break; case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) { + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - r.out.ctr.ctr1->array[0].status); + r.out.ctr->ctr1->array[0].status); return false; } printf ("(expected) error\n"); break; case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) { + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - r.out.ctr.ctr1->array[0].status); + r.out.ctr->ctr1->array[0].status); return false; } printf ("(expected) error\n"); break; default: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("Error: %d\n", r.out.ctr.ctr1->array[0].status); + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("Error: %d\n", r.out.ctr->ctr1->array[0].status); return false; } } @@ -138,15 +147,15 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, n_from[i] = NULL; break; default: - n_from[i] = r.out.ctr.ctr1->array[0].result_name; + n_from[i] = r.out.ctr->ctr1->array[0].result_name; printf("%s\n", n_from[i]); } } for (i = 0; i < ARRAY_SIZE(formats); i++) { for (j = 0; j < ARRAY_SIZE(formats); j++) { - r.in.req.req1.format_offered = formats[i]; - r.in.req.req1.format_desired = formats[j]; + r.in.req->req1.format_offered = formats[i]; + r.in.req->req1.format_desired = formats[j]; if (!n_from[i]) { n_matrix[i][j] = NULL; continue; @@ -159,11 +168,11 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, errstr); + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr); ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, win_errstr(r.out.result)); ret = false; } @@ -171,8 +180,8 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!ret) { return ret; } - if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { - n_matrix[i][j] = r.out.ctr.ctr1->array[0].result_name; + if (r.out.ctr->ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { + n_matrix[i][j] = r.out.ctr->ctr1->array[0].result_name; } else { n_matrix[i][j] = NULL; } @@ -210,6 +219,9 @@ bool test_DsCrackNames(struct torture_context *tctx, { NTSTATUS status; struct drsuapi_DsCrackNames r; + union drsuapi_DsNameRequest req; + int32_t level_out; + union drsuapi_DsNameCtr ctr; struct drsuapi_DsNameString names[1]; bool ret = true; const char *dns_domain; @@ -232,21 +244,25 @@ bool test_DsCrackNames(struct torture_context *tctx, ZERO_STRUCT(r); r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.codepage = 1252; /* german */ - r.in.req.req1.language = 0x00000407; /* german */ - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r.in.req = &req; + r.in.req->req1.codepage = 1252; /* german */ + r.in.req->req1.language = 0x00000407; /* german */ + r.in.req->req1.count = 1; + r.in.req->req1.names = names; + r.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.out.level_out = &level_out; + r.out.ctr = &ctr; dom_sid = dom_sid_string(mem_ctx, torture_join_sid(priv->join)); names[0].str = dom_sid; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -259,8 +275,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -268,13 +284,13 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - dns_domain = r.out.ctr.ctr1->array[0].dns_domain_name; - nt4_domain = r.out.ctr.ctr1->array[0].result_name; + dns_domain = r.out.ctr->ctr1->array[0].dns_domain_name; + nt4_domain = r.out.ctr->ctr1->array[0].result_name; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -287,8 +303,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -296,14 +312,14 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - priv->domain_dns_name = r.out.ctr.ctr1->array[0].dns_domain_name; - priv->domain_guid_str = r.out.ctr.ctr1->array[0].result_name; + priv->domain_dns_name = r.out.ctr->ctr1->array[0].dns_domain_name; + priv->domain_guid_str = r.out.ctr->ctr1->array[0].result_name; GUID_from_string(priv->domain_guid_str, &priv->domain_guid); - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -316,8 +332,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -327,7 +343,7 @@ bool test_DsCrackNames(struct torture_context *tctx, ldb = ldb_init(mem_ctx, tctx->ev); - realm_dn_str = r.out.ctr.ctr1->array[0].result_name; + realm_dn_str = r.out.ctr->ctr1->array[0].result_name; realm_dn = ldb_dn_new(mem_ctx, ldb, realm_dn_str); realm_canonical = ldb_dn_canonical_string(mem_ctx, realm_dn); @@ -349,12 +365,12 @@ bool test_DsCrackNames(struct torture_context *tctx, return false; }; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = nt4_domain; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -367,8 +383,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -376,14 +392,14 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - priv->domain_obj_dn = r.out.ctr.ctr1->array[0].result_name; + priv->domain_obj_dn = r.out.ctr->ctr1->array[0].result_name; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, test_dc); printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -396,8 +412,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -405,14 +421,14 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name; + FQDN_1779_name = r.out.ctr->ctr1->array[0].result_name; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = priv->domain_guid_str; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -425,8 +441,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -434,8 +450,8 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - if (strcmp(priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name) != 0) { - printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name); + if (strcmp(priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name) != 0) { + printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name); return false; } @@ -919,17 +935,17 @@ bool test_DsCrackNames(struct torture_context *tctx, for (i=0; i < ARRAY_SIZE(crack); i++) { const char *comment; - r.in.req.req1.format_flags = crack[i].flags; - r.in.req.req1.format_offered = crack[i].format_offered; - r.in.req.req1.format_desired = crack[i].format_desired; + r.in.req->req1.format_flags = crack[i].flags; + r.in.req->req1.format_offered = crack[i].format_offered; + r.in.req->req1.format_desired = crack[i].format_desired; names[0].str = crack[i].str; if (crack[i].comment) { comment = talloc_asprintf(mem_ctx, "'%s' with name '%s' desired format:%d\n", - crack[i].comment, names[0].str, r.in.req.req1.format_desired); + crack[i].comment, names[0].str, r.in.req->req1.format_desired); } else { comment = talloc_asprintf(mem_ctx, "'%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); } if (crack[i].skip) { printf("skipping: %s", comment); @@ -946,11 +962,11 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != crack[i].status) { + } else if (r.out.ctr->ctr1->array[0].status != crack[i].status) { if (crack[i].alternate_status) { - if (r.out.ctr.ctr1->array[0].status != crack[i].alternate_status) { + if (r.out.ctr->ctr1->array[0].status != crack[i].alternate_status) { printf("DsCrackNames unexpected status %d, wanted %d or %d on: %s\n", - r.out.ctr.ctr1->array[0].status, + r.out.ctr->ctr1->array[0].status, crack[i].status, crack[i].alternate_status, comment); @@ -958,30 +974,30 @@ bool test_DsCrackNames(struct torture_context *tctx, } } else { printf("DsCrackNames unexpected status %d, wanted %d on: %s\n", - r.out.ctr.ctr1->array[0].status, + r.out.ctr->ctr1->array[0].status, crack[i].status, comment); ret = false; } } else if (crack[i].expected_str - && (strcmp(r.out.ctr.ctr1->array[0].result_name, + && (strcmp(r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str) != 0)) { - if (strcasecmp(r.out.ctr.ctr1->array[0].result_name, + if (strcasecmp(r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str) != 0) { printf("DsCrackNames failed - got %s, expected %s on %s\n", - r.out.ctr.ctr1->array[0].result_name, + r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str, comment); ret = false; } else { printf("(warning) DsCrackNames returned different case - got %s, expected %s on %s\n", - r.out.ctr.ctr1->array[0].result_name, + r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str, comment); } } else if (crack[i].expected_dns - && (strcmp(r.out.ctr.ctr1->array[0].dns_domain_name, + && (strcmp(r.out.ctr->ctr1->array[0].dns_domain_name, crack[i].expected_dns) != 0)) { printf("DsCrackNames failed - got DNS name %s, expected %s on %s\n", - r.out.ctr.ctr1->array[0].result_name, + r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str, comment); ret = false; } diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index e9346f9605..bee2658816 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -29,7 +29,7 @@ #include "torture/torture.h" #include "torture/ldap/proto.h" #include "libcli/auth/libcli_auth.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "auth/credentials/credentials.h" #include "libcli/auth/libcli_auth.h" #include "auth/gensec/gensec.h" @@ -265,6 +265,9 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) { NTSTATUS status; struct drsuapi_DsCrackNames r; + union drsuapi_DsNameRequest req; + union drsuapi_DsNameCtr ctr; + int32_t level_out = 0; struct drsuapi_DsNameString names[1]; bool ret = true; struct cldap_socket *cldap; @@ -274,15 +277,19 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) r.in.bind_handle = &ctx->admin.drsuapi.bind_handle; r.in.level = 1; - r.in.req.req1.codepage = 1252; /* western european */ - r.in.req.req1.language = 0x00000407; /* german */ - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req = &req; + r.in.req->req1.codepage = 1252; /* western european */ + r.in.req->req1.language = 0x00000407; /* german */ + r.in.req->req1.count = 1; + r.in.req->req1.names = names; + r.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup(tctx->lp_ctx)); + r.out.level_out = &level_out; + r.out.ctr = &ctr; + status = dcerpc_drsuapi_DsCrackNames(ctx->admin.drsuapi.pipe, ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); @@ -296,7 +303,7 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) return false; } - ctx->domain_dn = r.out.ctr.ctr1->array[0].result_name; + ctx->domain_dn = r.out.ctr->ctr1->array[0].result_name; ZERO_STRUCT(search); search.in.dest_address = ctx->drsuapi_binding->host; @@ -310,14 +317,14 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) ctx->site_name = talloc_asprintf(ctx, "%s", "Default-First-Site-Name"); printf("cldap_netlogon() returned %s. Defaulting to Site-Name: %s\n", errstr, ctx->site_name); } else { - ctx->site_name = talloc_steal(ctx, search.out.netlogon.nt5_ex.client_site); + ctx->site_name = talloc_steal(ctx, search.out.netlogon.data.nt5_ex.client_site); printf("cldap_netlogon() returned Client Site-Name: %s.\n",ctx->site_name); - printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.nt5_ex.server_site); + printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.data.nt5_ex.server_site); } if (!ctx->domain_dn) { struct ldb_context *ldb = ldb_init(ctx, tctx->ev); - struct ldb_dn *dn = samdb_dns_domain_to_dn(ldb, ctx, search.out.netlogon.nt5_ex.dns_domain); + struct ldb_dn *dn = samdb_dns_domain_to_dn(ldb, ctx, search.out.netlogon.data.nt5_ex.dns_domain); ctx->domain_dn = ldb_dn_alloc_linearized(ctx, dn); talloc_free(dn); talloc_free(ldb); @@ -592,6 +599,7 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) uint64_t highest_usn = 0; const char *partition = NULL; struct drsuapi_DsGetNCChanges r; + union drsuapi_DsGetNCChangesRequest req; struct drsuapi_DsReplicaObjectIdentifier nc; struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL; struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL; @@ -642,37 +650,38 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) array[i].level); r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle; - r.in.level = &array[i].level; + r.in.level = array[i].level; - switch (*r.in.level) { + switch (r.in.level) { case 5: nc.guid = null_guid; nc.sid = null_sid; nc.dn = partition; - r.in.req.req5.destination_dsa_guid = ctx->new_dc.invocation_id; - r.in.req.req5.source_dsa_invocation_id = null_guid; - r.in.req.req5.naming_context = &nc; - r.in.req.req5.highwatermark.tmp_highest_usn = highest_usn; - r.in.req.req5.highwatermark.reserved_usn = 0; - r.in.req.req5.highwatermark.highest_usn = highest_usn; - r.in.req.req5.uptodateness_vector = NULL; - r.in.req.req5.replica_flags = 0; + r.in.req = &req; + r.in.req->req5.destination_dsa_guid = ctx->new_dc.invocation_id; + r.in.req->req5.source_dsa_invocation_id = null_guid; + r.in.req->req5.naming_context = &nc; + r.in.req->req5.highwatermark.tmp_highest_usn = highest_usn; + r.in.req->req5.highwatermark.reserved_usn = 0; + r.in.req->req5.highwatermark.highest_usn = highest_usn; + r.in.req->req5.uptodateness_vector = NULL; + r.in.req->req5.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "compression", false)) { - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "neighbour_writeable", true)) { - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req5.max_object_count = 133; - r.in.req.req5.max_ndr_size = 1336770; - r.in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req5.fsmo_info = 0; + r.in.req->req5.max_object_count = 133; + r.in.req->req5.max_ndr_size = 1336770; + r.in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req5.fsmo_info = 0; break; case 8: @@ -680,35 +689,36 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) nc.sid = null_sid; nc.dn = partition; /* nc.dn can be set to any other ad partition */ - - r.in.req.req8.destination_dsa_guid = ctx->new_dc.invocation_id; - r.in.req.req8.source_dsa_invocation_id = null_guid; - r.in.req.req8.naming_context = &nc; - r.in.req.req8.highwatermark.tmp_highest_usn = highest_usn; - r.in.req.req8.highwatermark.reserved_usn = 0; - r.in.req.req8.highwatermark.highest_usn = highest_usn; - r.in.req.req8.uptodateness_vector = NULL; - r.in.req.req8.replica_flags = 0; + + r.in.req = &req; + r.in.req->req8.destination_dsa_guid = ctx->new_dc.invocation_id; + r.in.req->req8.source_dsa_invocation_id = null_guid; + r.in.req->req8.naming_context = &nc; + r.in.req->req8.highwatermark.tmp_highest_usn = highest_usn; + r.in.req->req8.highwatermark.reserved_usn = 0; + r.in.req->req8.highwatermark.highest_usn = highest_usn; + r.in.req->req8.uptodateness_vector = NULL; + r.in.req->req8.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "compression", false)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "neighbour_writeable", true)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req8.max_object_count = 402; - r.in.req.req8.max_ndr_size = 402116; + r.in.req->req8.max_object_count = 402; + r.in.req->req8.max_ndr_size = 402116; - r.in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req8.fsmo_info = 0; - r.in.req.req8.partial_attribute_set = NULL; - r.in.req.req8.partial_attribute_set_ex = NULL; - r.in.req.req8.mapping_ctr.num_mappings = 0; - r.in.req.req8.mapping_ctr.mappings = NULL; + r.in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req8.fsmo_info = 0; + r.in.req->req8.partial_attribute_set = NULL; + r.in.req->req8.partial_attribute_set_ex = NULL; + r.in.req->req8.mapping_ctr.num_mappings = 0; + r.in.req->req8.mapping_ctr.mappings = NULL; break; } @@ -716,19 +726,23 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) printf("Dumping AD partition: %s\n", nc.dn); for (y=0; ;y++) { int32_t _level = 0; + union drsuapi_DsGetNCChangesCtr ctr; + ZERO_STRUCT(r.out); - r.out.level = &_level; - if (*r.in.level == 5) { + r.out.level_out = &_level; + r.out.ctr = &ctr; + + if (r.in.level == 5) { DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y, - (long long)r.in.req.req5.highwatermark.tmp_highest_usn, - (long long)r.in.req.req5.highwatermark.highest_usn)); + (long long)r.in.req->req5.highwatermark.tmp_highest_usn, + (long long)r.in.req->req5.highwatermark.highest_usn)); } - if (*r.in.level == 8) { + if (r.in.level == 8) { DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y, - (long long)r.in.req.req8.highwatermark.tmp_highest_usn, - (long long)r.in.req.req8.highwatermark.highest_usn)); + (long long)r.in.req->req8.highwatermark.tmp_highest_usn, + (long long)r.in.req->req8.highwatermark.highest_usn)); } status = dcerpc_drsuapi_DsGetNCChanges(ctx->new_dc.drsuapi.pipe, ctx, &r); @@ -744,13 +758,13 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) ret = false; } - if (ret == true && *r.out.level == 1) { + if (ret == true && *r.out.level_out == 1) { out_level = 1; - ctr1 = &r.out.ctr.ctr1; - } else if (ret == true && *r.out.level == 2 && - r.out.ctr.ctr2.mszip1.ts) { + ctr1 = &r.out.ctr->ctr1; + } else if (ret == true && *r.out.level_out == 2 && + r.out.ctr->ctr2.mszip1.ts) { out_level = 1; - ctr1 = &r.out.ctr.ctr2.mszip1.ts->ctr1; + ctr1 = &r.out.ctr->ctr2.mszip1.ts->ctr1; } if (out_level == 1) { @@ -761,26 +775,26 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) test_analyse_objects(tctx, ctx, &gensec_skey, ctr1->first_object); if (ctr1->more_data) { - r.in.req.req5.highwatermark = ctr1->new_highwatermark; + r.in.req->req5.highwatermark = ctr1->new_highwatermark; continue; } } - if (ret == true && *r.out.level == 6) { + if (ret == true && *r.out.level_out == 6) { out_level = 6; - ctr6 = &r.out.ctr.ctr6; - } else if (ret == true && *r.out.level == 7 - && r.out.ctr.ctr7.level == 6 - && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP - && r.out.ctr.ctr7.ctr.mszip6.ts) { + ctr6 = &r.out.ctr->ctr6; + } else if (ret == true && *r.out.level_out == 7 + && r.out.ctr->ctr7.level == 6 + && r.out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP + && r.out.ctr->ctr7.ctr.mszip6.ts) { out_level = 6; - ctr6 = &r.out.ctr.ctr7.ctr.mszip6.ts->ctr6; - } else if (ret == true && *r.out.level == 7 - && r.out.ctr.ctr7.level == 6 - && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS - && r.out.ctr.ctr7.ctr.xpress6.ts) { + ctr6 = &r.out.ctr->ctr7.ctr.mszip6.ts->ctr6; + } else if (ret == true && *r.out.level_out == 7 + && r.out.ctr->ctr7.level == 6 + && r.out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS + && r.out.ctr->ctr7.ctr.xpress6.ts) { out_level = 6; - ctr6 = &r.out.ctr.ctr7.ctr.xpress6.ts->ctr6; + ctr6 = &r.out.ctr->ctr7.ctr.xpress6.ts->ctr6; } if (out_level == 6) { @@ -791,7 +805,7 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) test_analyse_objects(tctx, ctx, &gensec_skey, ctr6->first_object); if (ctr6->more_data) { - r.in.req.req8.highwatermark = ctr6->new_highwatermark; + r.in.req->req8.highwatermark = ctr6->new_highwatermark; continue; } } @@ -809,6 +823,9 @@ static bool test_FetchNT4Data(struct torture_context *tctx, NTSTATUS status; bool ret = true; struct drsuapi_DsGetNT4ChangeLog r; + union drsuapi_DsGetNT4ChangeLogRequest req; + union drsuapi_DsGetNT4ChangeLogInfo info; + int32_t level_out = 0; struct GUID null_guid; struct dom_sid null_sid; DATA_BLOB cookie; @@ -820,13 +837,17 @@ static bool test_FetchNT4Data(struct torture_context *tctx, ZERO_STRUCT(r); r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle; r.in.level = 1; + r.out.info = &info; + r.out.level_out = &level_out; - r.in.req.req1.unknown1 = lp_parm_int(tctx->lp_ctx, NULL, "dssync", "nt4-1", 3); - r.in.req.req1.unknown2 = lp_parm_int(tctx->lp_ctx, NULL, "dssync", "nt4-2", 0x00004000); + req.req1.unknown1 = lp_parm_int(tctx->lp_ctx, NULL, "dssync", "nt4-1", 3); + req.req1.unknown2 = lp_parm_int(tctx->lp_ctx, NULL, "dssync", "nt4-2", 0x00004000); while (1) { - r.in.req.req1.length = cookie.length; - r.in.req.req1.data = cookie.data; + req.req1.length = cookie.length; + req.req1.data = cookie.data; + + r.in.req = &req; status = dcerpc_drsuapi_DsGetNT4ChangeLog(ctx->new_dc.drsuapi.pipe, ctx, &r); if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { @@ -845,16 +866,16 @@ static bool test_FetchNT4Data(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsGetNT4ChangeLog failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.level != 1) { - printf("DsGetNT4ChangeLog unknown level - %u\n", r.out.level); + } else if (*r.out.level_out != 1) { + printf("DsGetNT4ChangeLog unknown level - %u\n", *r.out.level_out); ret = false; - } else if (NT_STATUS_IS_OK(r.out.info.info1.status)) { - } else if (NT_STATUS_EQUAL(r.out.info.info1.status, STATUS_MORE_ENTRIES)) { - cookie.length = r.out.info.info1.length1; - cookie.data = r.out.info.info1.data1; + } else if (NT_STATUS_IS_OK(r.out.info->info1.status)) { + } else if (NT_STATUS_EQUAL(r.out.info->info1.status, STATUS_MORE_ENTRIES)) { + cookie.length = r.out.info->info1.length1; + cookie.data = r.out.info->info1.data1; continue; } else { - printf("DsGetNT4ChangeLog failed - %s\n", nt_errstr(r.out.info.info1.status)); + printf("DsGetNT4ChangeLog failed - %s\n", nt_errstr(r.out.info->info1.status)); ret = false; } diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index feeeb9330b..d5665ad07d 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -40,13 +40,16 @@ static bool get_policy_handle(struct torture_context *tctx, { struct eventlog_OpenEventLogW r; struct eventlog_OpenUnknown0 unknown0; + struct lsa_String logname, servername; unknown0.unknown0 = 0x005c; unknown0.unknown1 = 0x0001; r.in.unknown0 = &unknown0; - init_lsa_String(&r.in.logname, "dns server"); - init_lsa_String(&r.in.servername, NULL); + init_lsa_String(r.in.logname, "dns server"); + init_lsa_String(r.in.servername, NULL); + r.in.logname = &logname; + r.in.servername = &servername; r.in.unknown2 = 0x00000001; r.in.unknown3 = 0x00000001; r.out.handle = handle; @@ -205,7 +208,7 @@ static bool test_ClearEventLog(struct torture_context *tctx, return false; r.in.handle = &handle; - r.in.unknown = NULL; + r.in.backupfile = NULL; torture_assert_ntstatus_ok(tctx, dcerpc_eventlog_ClearEventLogW(p, tctx, &r), diff --git a/source4/torture/rpc/initshutdown.c b/source4/torture/rpc/initshutdown.c index 92fec5be0c..149fae6c26 100644 --- a/source4/torture/rpc/initshutdown.c +++ b/source4/torture/rpc/initshutdown.c @@ -61,7 +61,7 @@ static bool test_Init(struct torture_context *tctx, init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; - r.in.reboot = 1; + r.in.do_reboot = 1; status = dcerpc_initshutdown_Init(p, tctx, &r); @@ -83,7 +83,7 @@ static bool test_InitEx(struct torture_context *tctx, init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; - r.in.reboot = 1; + r.in.do_reboot = 1; r.in.reason = 0; status = dcerpc_initshutdown_InitEx(p, tctx, &r); diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c index 77da32d572..ee0c05360f 100644 --- a/source4/torture/rpc/join.c +++ b/source4/torture/rpc/join.c @@ -19,6 +19,7 @@ bool torture_rpc_join(struct torture_context *torture) struct smbcli_state *cli; const char *host = torture_setting_string(torture, "host", NULL); struct smbcli_options options; + struct smbcli_session_options session_options; /* Join domain as a member server. */ tj = torture_join_domain(torture, @@ -33,13 +34,14 @@ bool torture_rpc_join(struct torture_context *torture) } lp_smbcli_options(torture->lp_ctx, &options); + lp_smbcli_session_options(torture->lp_ctx, &session_options); status = smbcli_full_connection(tj, &cli, host, lp_smb_ports(torture->lp_ctx), "IPC$", NULL, machine_account, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n", TORTURE_NETBIOS_NAME)); @@ -65,7 +67,7 @@ bool torture_rpc_join(struct torture_context *torture) "IPC$", NULL, machine_account, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n", TORTURE_NETBIOS_NAME)); diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index a13a8d8818..69df965f19 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -29,7 +29,7 @@ #include "libcli/auth/libcli_auth.h" #include "torture/rpc/rpc.h" #include "param/param.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #define TEST_MACHINENAME "lsatestmach" static void init_lsa_String(struct lsa_String *name, const char *s) @@ -46,7 +46,7 @@ static bool test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) NTSTATUS status; uint16_t system_name = '\\'; - printf("\ntesting OpenPolicy\n"); + printf("\nTesting OpenPolicy\n"); qos.len = 0; qos.impersonation_level = 2; @@ -88,7 +88,7 @@ bool test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_OpenPolicy2 r; NTSTATUS status; - printf("\ntesting OpenPolicy2\n"); + printf("\nTesting OpenPolicy2\n"); *handle = talloc(mem_ctx, struct policy_handle); if (!*handle) { @@ -222,12 +222,13 @@ static bool test_LookupNames_bogus(struct dcerpc_pipe *p, NTSTATUS status; int i; - struct lsa_TranslatedName name; + struct lsa_TranslatedName name[2]; struct lsa_TransNameArray tnames; - tnames.names = &name; - tnames.count = 1; - name.name.string = "NT AUTHORITY\\BOGUS"; + tnames.names = name; + tnames.count = 2; + name[0].name.string = "NT AUTHORITY\\BOGUS"; + name[1].name.string = NULL; printf("\nTesting LookupNames with bogus names\n"); @@ -337,8 +338,8 @@ static bool test_LookupNames2(struct dcerpc_pipe *p, r.in.sids = &sids; r.in.level = 1; r.in.count = &count; - r.in.unknown1 = 0; - r.in.unknown2 = 0; + r.in.lookup_options = 0; + r.in.client_revision = 0; r.out.count = &count; r.out.sids = &sids; @@ -382,8 +383,8 @@ static bool test_LookupNames3(struct dcerpc_pipe *p, r.in.sids = &sids; r.in.level = 1; r.in.count = &count; - r.in.unknown1 = 0; - r.in.unknown2 = 0; + r.in.lookup_options = 0; + r.in.client_revision = 0; r.out.count = &count; r.out.sids = &sids; @@ -424,8 +425,8 @@ static bool test_LookupNames4(struct dcerpc_pipe *p, r.in.sids = &sids; r.in.level = 1; r.in.count = &count; - r.in.unknown1 = 0; - r.in.unknown2 = 0; + r.in.lookup_options = 0; + r.in.client_revision = 0; r.out.count = &count; r.out.sids = &sids; @@ -780,7 +781,7 @@ static bool test_LookupPrivName(struct dcerpc_pipe *p, } static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct policy_handle *acct_handle, struct lsa_LUID *luid) @@ -790,7 +791,7 @@ static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, struct lsa_PrivilegeSet privs; bool ret = true; - printf("Testing RemovePrivilegesFromAccount\n"); + printf("\nTesting RemovePrivilegesFromAccount\n"); r.in.handle = acct_handle; r.in.remove_all = 0; @@ -830,7 +831,7 @@ static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, } static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, struct policy_handle *acct_handle, struct lsa_LUID *luid) { @@ -839,7 +840,7 @@ static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p, struct lsa_PrivilegeSet privs; bool ret = true; - printf("Testing AddPrivilegesToAccount\n"); + printf("\nTesting AddPrivilegesToAccount\n"); r.in.handle = acct_handle; r.in.privs = &privs; @@ -860,7 +861,7 @@ static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p, } static bool test_EnumPrivsAccount(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct policy_handle *acct_handle) { @@ -868,7 +869,7 @@ static bool test_EnumPrivsAccount(struct dcerpc_pipe *p, struct lsa_EnumPrivsAccount r; bool ret = true; - printf("Testing EnumPrivsAccount\n"); + printf("\nTesting EnumPrivsAccount\n"); r.in.handle = acct_handle; @@ -894,6 +895,60 @@ static bool test_EnumPrivsAccount(struct dcerpc_pipe *p, return ret; } +static bool test_GetSystemAccessAccount(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + struct policy_handle *acct_handle) +{ + NTSTATUS status; + uint32_t access_mask; + struct lsa_GetSystemAccessAccount r; + + printf("\nTesting GetSystemAccessAccount\n"); + + r.in.handle = acct_handle; + r.out.access_mask = &access_mask; + + status = dcerpc_lsa_GetSystemAccessAccount(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("GetSystemAccessAccount failed - %s\n", nt_errstr(status)); + return false; + } + + if (r.out.access_mask != NULL) { + printf("Rights:"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_INTERACTIVE) + printf(" LSA_POLICY_MODE_INTERACTIVE"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_NETWORK) + printf(" LSA_POLICY_MODE_NETWORK"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_BATCH) + printf(" LSA_POLICY_MODE_BATCH"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_SERVICE) + printf(" LSA_POLICY_MODE_SERVICE"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_PROXY) + printf(" LSA_POLICY_MODE_PROXY"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_INTERACTIVE) + printf(" LSA_POLICY_MODE_DENY_INTERACTIVE"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_NETWORK) + printf(" LSA_POLICY_MODE_DENY_NETWORK"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_BATCH) + printf(" LSA_POLICY_MODE_DENY_BATCH"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_SERVICE) + printf(" LSA_POLICY_MODE_DENY_SERVICE"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_REMOTE_INTERACTIVE) + printf(" LSA_POLICY_MODE_REMOTE_INTERACTIVE"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE) + printf(" LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_ALL) + printf(" LSA_POLICY_MODE_ALL"); + if (*(r.out.access_mask) & LSA_POLICY_MODE_ALL_NT4) + printf(" LSA_POLICY_MODE_ALL_NT4"); + printf("\n"); + } + + return true; +} + static bool test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) @@ -901,7 +956,7 @@ static bool test_Delete(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_Delete r; - printf("testing Delete\n"); + printf("\nTesting Delete\n"); r.in.handle = handle; status = dcerpc_lsa_Delete(p, mem_ctx, &r); @@ -920,13 +975,13 @@ static bool test_DeleteObject(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_DeleteObject r; - printf("testing DeleteObject\n"); + printf("\nTesting DeleteObject\n"); r.in.handle = handle; r.out.handle = handle; status = dcerpc_lsa_DeleteObject(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("Delete failed - %s\n", nt_errstr(status)); + printf("DeleteObject failed - %s\n", nt_errstr(status)); return false; } @@ -945,7 +1000,7 @@ static bool test_CreateAccount(struct dcerpc_pipe *p, newsid = dom_sid_parse_talloc(mem_ctx, "S-1-5-12349876-4321-2854"); - printf("Testing CreateAccount\n"); + printf("\nTesting CreateAccount\n"); r.in.handle = handle; r.in.sid = newsid; @@ -997,7 +1052,7 @@ static bool test_DeleteTrustedDomain(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenTrustedDomainByName(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("lsa_OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); + printf("OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); return false; } @@ -1025,7 +1080,7 @@ static bool test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p, status = dcerpc_lsa_DeleteTrustedDomain(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("lsa_DeleteTrustedDomain failed - %s\n", nt_errstr(status)); + printf("DeleteTrustedDomain failed - %s\n", nt_errstr(status)); return false; } @@ -1071,7 +1126,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, secname[GLOBAL] = talloc_asprintf(mem_ctx, "G$torturesecret-%u", (uint_t)random()); for (i=0; i< 2; i++) { - printf("Testing CreateSecret of %s\n", secname[i]); + printf("\nTesting CreateSecret of %s\n", secname[i]); init_lsa_String(&r.in.name, secname[i]); @@ -1383,7 +1438,7 @@ static bool test_EnumAccountRights(struct dcerpc_pipe *p, struct lsa_EnumAccountRights r; struct lsa_RightSet rights; - printf("Testing EnumAccountRights\n"); + printf("\nTesting EnumAccountRights\n"); r.in.handle = acct_handle; r.in.sid = sid; @@ -1409,11 +1464,11 @@ static bool test_QuerySecurity(struct dcerpc_pipe *p, struct lsa_QuerySecurity r; if (torture_setting_bool(tctx, "samba4", false)) { - printf("skipping QuerySecurity test against Samba4\n"); + printf("\nskipping QuerySecurity test against Samba4\n"); return true; } - printf("Testing QuerySecurity\n"); + printf("\nTesting QuerySecurity\n"); r.in.handle = acct_handle; r.in.sec_info = 7; @@ -1436,7 +1491,7 @@ static bool test_OpenAccount(struct dcerpc_pipe *p, struct lsa_OpenAccount r; struct policy_handle acct_handle; - printf("Testing OpenAccount\n"); + printf("\nTesting OpenAccount\n"); r.in.handle = handle; r.in.sid = sid; @@ -1453,6 +1508,10 @@ static bool test_OpenAccount(struct dcerpc_pipe *p, return false; } + if (!test_GetSystemAccessAccount(p, mem_ctx, handle, &acct_handle)) { + return false; + } + if (!test_QuerySecurity(p, mem_ctx, handle, &acct_handle)) { return false; } @@ -1471,7 +1530,7 @@ static bool test_EnumAccounts(struct dcerpc_pipe *p, int i; bool ret = true; - printf("\ntesting EnumAccounts\n"); + printf("\nTesting EnumAccounts\n"); r.in.handle = handle; r.in.resume_handle = &resume_handle; @@ -1502,7 +1561,7 @@ static bool test_EnumAccounts(struct dcerpc_pipe *p, * be on schannel, or we would not be able to do the * rest */ - printf("testing all accounts\n"); + printf("Testing all accounts\n"); for (i=0;istring); + printf("\nTesting LookupPrivDisplayName(%s)\n", priv_name->string); r.in.handle = handle; r.in.name = priv_name; @@ -1575,7 +1634,7 @@ static bool test_EnumAccountsWithUserRight(struct dcerpc_pipe *p, ZERO_STRUCT(sids); - printf("testing EnumAccountsWithUserRight(%s)\n", priv_name->string); + printf("\nTesting EnumAccountsWithUserRight(%s)\n", priv_name->string); r.in.handle = handle; r.in.name = priv_name; @@ -1608,7 +1667,7 @@ static bool test_EnumPrivs(struct dcerpc_pipe *p, int i; bool ret = true; - printf("\ntesting EnumPrivs\n"); + printf("\nTesting EnumPrivs\n"); r.in.handle = handle; r.in.resume_handle = &resume_handle; @@ -1668,7 +1727,7 @@ static bool test_QueryForestTrustInformation(struct dcerpc_pipe *p, status = dcerpc_lsa_lsaRQueryForestTrustInformation(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("lsaRQueryForestTrustInformation failed - %s\n", nt_errstr(status)); + printf("lsaRQueryForestTrustInformation of %s failed - %s\n", trusted_domain_name, nt_errstr(status)); ret = false; } @@ -1898,7 +1957,11 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, /* NO_MORE_ENTRIES is allowed */ if (NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES)) { - return true; + if (domains.count == 0) { + return true; + } + printf("EnumTrustDom failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n"); + return false; } else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) { /* Windows 2003 gets this off by one on the first run */ if (r.out.domains->count < 3 || r.out.domains->count > 4) { @@ -1949,7 +2012,11 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, /* NO_MORE_ENTRIES is allowed */ if (NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES)) { - return true; + if (domains_ex.count == 0) { + return true; + } + printf("EnumTrustDomainsEx failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n"); + return false; } else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) { /* Windows 2003 gets this off by one on the first run */ if (r_ex.out.domains->count < 3 || r_ex.out.domains->count > 4) { @@ -1990,7 +2057,7 @@ static bool test_CreateTrustedDomain(struct dcerpc_pipe *p, struct lsa_QueryTrustedDomainInfo q; int i; - printf("Testing CreateTrustedDomain for 12 domains\n"); + printf("\nTesting CreateTrustedDomain for 12 domains\n"); if (!test_EnumTrustDom(p, mem_ctx, handle)) { ret = false; @@ -2077,7 +2144,7 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, struct lsa_CreateTrustedDomainEx2 r; struct lsa_TrustDomainInfoInfoEx trustinfo; struct lsa_TrustDomainInfoAuthInfoInternal authinfo; - struct trustAuthInAndOutBlob auth_struct; + struct trustDomainPasswords auth_struct; DATA_BLOB auth_blob; struct dom_sid *domsid[12]; struct policy_handle trustdom_handle[12]; @@ -2086,7 +2153,7 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, enum ndr_err_code ndr_err; int i; - printf("Testing CreateTrustedDomainEx2 for 12 domains\n"); + printf("\nTesting CreateTrustedDomainEx2 for 12 domains\n"); status = dcerpc_fetch_session_key(p, &session_key); if (!NT_STATUS_IS_OK(status)) { @@ -2114,7 +2181,7 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, /* Try different trust types too */ - /* 1 == downleven (NT4), 2 == uplevel (ADS), 3 == MIT (kerberos but not AD) */ + /* 1 == downlevel (NT4), 2 == uplevel (ADS), 3 == MIT (kerberos but not AD) */ trustinfo.trust_type = (((i / 3) + 1) % 3) + 1; trustinfo.trust_attributes = LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION; @@ -2125,9 +2192,9 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, auth_struct.incoming.count = 0; ndr_err = ndr_push_struct_blob(&auth_blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx), &auth_struct, - (ndr_push_flags_fn_t)ndr_push_trustAuthInAndOutBlob); + (ndr_push_flags_fn_t)ndr_push_trustDomainPasswords); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - printf("ndr_push_struct_blob of trustAuthInAndOutBlob structure failed"); + printf("ndr_push_struct_blob of trustDomainPasswords structure failed"); ret = false; } @@ -2159,6 +2226,7 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, printf("QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status)); ret = false; } else if (!q.out.info) { + printf("QueryTrustedDomainInfo level 1 failed to return an info pointer\n"); ret = false; } else { if (strcmp(q.out.info->info_ex.netbios_name.string, trustinfo.netbios_name.string) != 0) { @@ -2187,11 +2255,13 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, /* now that we have some domains to look over, we can test the enum calls */ if (!test_EnumTrustDom(p, mem_ctx, handle)) { + printf("test_EnumTrustDom failed\n"); ret = false; } for (i=0; i<12; i++) { if (!test_DeleteTrustedDomainBySid(p, mem_ctx, handle, domsid[i])) { + printf("test_DeleteTrustedDomainBySid failed\n"); ret = false; } } @@ -2214,7 +2284,7 @@ static bool test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, r.in.handle = handle; r.in.level = i; - printf("\ntrying QueryDomainInformationPolicy level %d\n", i); + printf("\nTrying QueryDomainInformationPolicy level %d\n", i); status = dcerpc_lsa_QueryDomainInformationPolicy(p, tctx, &r); @@ -2232,38 +2302,63 @@ static bool test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, } -static bool test_QueryInfoPolicy(struct dcerpc_pipe *p, - struct torture_context *tctx, - struct policy_handle *handle) +static bool test_QueryInfoPolicyCalls( bool version2, + struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle) { struct lsa_QueryInfoPolicy r; NTSTATUS status; int i; bool ret = true; - printf("\nTesting QueryInfoPolicy\n"); - for (i=1;i<13;i++) { + if (version2) + printf("\nTesting QueryInfoPolicy2\n"); + else + printf("\nTesting QueryInfoPolicy\n"); + + for (i=1;i<=14;i++) { r.in.handle = handle; r.in.level = i; - printf("\ntrying QueryInfoPolicy level %d\n", i); + if (version2) + printf("\nTrying QueryInfoPolicy2 level %d\n", i); + else + printf("\nTrying QueryInfoPolicy level %d\n", i); - status = dcerpc_lsa_QueryInfoPolicy(p, tctx, &r); + if (version2) + /* We can perform the cast, because both types are + structurally equal */ + status = dcerpc_lsa_QueryInfoPolicy2(p, tctx, + (struct lsa_QueryInfoPolicy2*) &r); + else + status = dcerpc_lsa_QueryInfoPolicy(p, tctx, &r); switch (i) { - case LSA_POLICY_INFO_DB: + case LSA_POLICY_INFO_MOD: case LSA_POLICY_INFO_AUDIT_FULL_SET: case LSA_POLICY_INFO_AUDIT_FULL_QUERY: if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - printf("server should have failed level %u: %s\n", i, nt_errstr(status)); + printf("Server should have failed level %u: %s\n", i, nt_errstr(status)); ret = false; } break; case LSA_POLICY_INFO_DOMAIN: case LSA_POLICY_INFO_ACCOUNT_DOMAIN: + case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN: + case LSA_POLICY_INFO_DNS_INT: case LSA_POLICY_INFO_DNS: + case LSA_POLICY_INFO_REPLICA: + case LSA_POLICY_INFO_QUOTA: + case LSA_POLICY_INFO_ROLE: + case LSA_POLICY_INFO_AUDIT_LOG: + case LSA_POLICY_INFO_AUDIT_EVENTS: + case LSA_POLICY_INFO_PD: if (!NT_STATUS_IS_OK(status)) { - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + if (version2) + printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + else + printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); ret = false; } break; @@ -2271,17 +2366,24 @@ static bool test_QueryInfoPolicy(struct dcerpc_pipe *p, if (torture_setting_bool(tctx, "samba4", false)) { /* Other levels not implemented yet */ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) { - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + if (version2) + printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + else + printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); ret = false; } } else if (!NT_STATUS_IS_OK(status)) { - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + if (version2) + printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + else + printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); ret = false; } break; } - if (NT_STATUS_IS_OK(status) && i == LSA_POLICY_INFO_DNS) { + if (NT_STATUS_IS_OK(status) && (i == LSA_POLICY_INFO_DNS + || i == LSA_POLICY_INFO_DNS_INT)) { /* Let's look up some of these names */ struct lsa_TransNameArray tnames; @@ -2323,56 +2425,18 @@ static bool test_QueryInfoPolicy(struct dcerpc_pipe *p, return ret; } +static bool test_QueryInfoPolicy(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle) +{ + return test_QueryInfoPolicyCalls(false, p, tctx, handle); +} + static bool test_QueryInfoPolicy2(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle) { - struct lsa_QueryInfoPolicy2 r; - NTSTATUS status; - int i; - bool ret = true; - printf("\nTesting QueryInfoPolicy2\n"); - for (i=1;i<13;i++) { - r.in.handle = handle; - r.in.level = i; - - printf("\ntrying QueryInfoPolicy2 level %d\n", i); - - status = dcerpc_lsa_QueryInfoPolicy2(p, tctx, &r); - - switch (i) { - case LSA_POLICY_INFO_DB: - case LSA_POLICY_INFO_AUDIT_FULL_SET: - case LSA_POLICY_INFO_AUDIT_FULL_QUERY: - if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - printf("server should have failed level %u: %s\n", i, nt_errstr(status)); - ret = false; - } - break; - case LSA_POLICY_INFO_DOMAIN: - case LSA_POLICY_INFO_ACCOUNT_DOMAIN: - case LSA_POLICY_INFO_DNS: - if (!NT_STATUS_IS_OK(status)) { - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); - ret = false; - } - break; - default: - if (torture_setting_bool(tctx, "samba4", false)) { - /* Other levels not implemented yet */ - if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) { - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); - ret = false; - } - } else if (!NT_STATUS_IS_OK(status)) { - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); - ret = false; - } - break; - } - } - - return ret; + return test_QueryInfoPolicyCalls(true, p, tctx, handle); } static bool test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) @@ -2407,7 +2471,7 @@ bool test_lsa_Close(struct dcerpc_pipe *p, struct lsa_Close r; struct policy_handle handle2; - printf("\ntesting Close\n"); + printf("\nTesting Close\n"); r.in.handle = handle; r.out.handle = &handle2; @@ -2457,7 +2521,6 @@ bool torture_rpc_lsa(struct torture_context *tctx) if (!join) { ret = false; } - if (!test_LookupNames_wellknown(p, tctx, handle)) { ret = false; } @@ -2481,7 +2544,6 @@ bool torture_rpc_lsa(struct torture_context *tctx) if (!test_CreateSecret(p, tctx, handle)) { ret = false; } - if (!test_CreateTrustedDomain(p, tctx, handle)) { ret = false; } diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index 5ec2c29a20..f4ae5b35eb 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -29,6 +29,7 @@ #include "lib/cmdline/popt_common.h" #include "torture/rpc/rpc.h" #include "torture/rpc/netlogon.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "librpc/gen_ndr/ndr_netlogon_c.h" #include "librpc/gen_ndr/ndr_lsa_c.h" @@ -77,11 +78,10 @@ static bool test_SetupCredentials(struct dcerpc_pipe *p, struct torture_context struct netr_ServerAuthenticate a; struct netr_Credential credentials1, credentials2, credentials3; struct creds_CredentialState *creds; - struct samr_Password mach_password; - const char *plain_pass; - const char *machine_name; + const struct samr_Password *mach_password; + const char *machine_name; - plain_pass = cli_credentials_get_password(credentials); + mach_password = cli_credentials_get_nt_hash(credentials, tctx); machine_name = cli_credentials_get_workstation(credentials); torture_comment(tctx, "Testing ServerReqChallenge\n"); @@ -99,8 +99,6 @@ static bool test_SetupCredentials(struct dcerpc_pipe *p, struct torture_context status = dcerpc_netr_ServerReqChallenge(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge"); - E_md4hash(plain_pass, mach_password.hash); - a.in.server_name = NULL; a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name); a.in.secure_channel_type = SEC_CHAN_BDC; @@ -109,7 +107,7 @@ static bool test_SetupCredentials(struct dcerpc_pipe *p, struct torture_context a.out.credentials = &credentials3; creds_client_init(creds, &credentials1, &credentials2, - &mach_password, &credentials3, + mach_password, &credentials3, 0); torture_comment(tctx, "Testing ServerAuthenticate\n"); @@ -142,12 +140,12 @@ bool test_SetupCredentials2(struct dcerpc_pipe *p, struct torture_context *tctx, struct netr_ServerAuthenticate2 a; struct netr_Credential credentials1, credentials2, credentials3; struct creds_CredentialState *creds; - struct samr_Password mach_password; + const struct samr_Password *mach_password; const char *machine_name; const char *plain_pass; + mach_password = cli_credentials_get_nt_hash(machine_credentials, tctx); machine_name = cli_credentials_get_workstation(machine_credentials); - plain_pass = cli_credentials_get_password(machine_credentials); torture_comment(tctx, "Testing ServerReqChallenge\n"); @@ -164,8 +162,6 @@ bool test_SetupCredentials2(struct dcerpc_pipe *p, struct torture_context *tctx, status = dcerpc_netr_ServerReqChallenge(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge"); - E_md4hash(plain_pass, mach_password.hash); - a.in.server_name = NULL; a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name); a.in.secure_channel_type = sec_chan_type; @@ -176,7 +172,7 @@ bool test_SetupCredentials2(struct dcerpc_pipe *p, struct torture_context *tctx, a.out.credentials = &credentials3; creds_client_init(creds, &credentials1, &credentials2, - &mach_password, &credentials3, + mach_password, &credentials3, negotiate_flags); torture_comment(tctx, "Testing ServerAuthenticate2\n"); @@ -250,6 +246,10 @@ static bool test_SetupCredentials3(struct dcerpc_pipe *p, struct torture_context torture_assert(tctx, creds_client_check(creds, &credentials3), "Credential chaining failed"); torture_comment(tctx, "negotiate_flags=0x%08x\n", negotiate_flags); + + /* Prove that requesting a challenge again won't break it */ + status = dcerpc_netr_ServerReqChallenge(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge"); *creds_out = creds; return true; @@ -321,6 +321,24 @@ static bool test_SetPassword(struct torture_context *tctx, return true; } +/* + generate a random password for password change tests +*/ +static DATA_BLOB netlogon_very_rand_pass(TALLOC_CTX *mem_ctx, int len) +{ + int i; + DATA_BLOB password = data_blob_talloc(mem_ctx, NULL, len * 2 /* number of unicode chars */); + generate_random_buffer(password.data, password.length); + + for (i=0; i < len; i++) { + if (((uint16_t *)password.data)[i] == 0) { + ((uint16_t *)password.data)[i] = 1; + } + } + + return password; +} + /* try a change password for our machine account */ @@ -331,8 +349,10 @@ static bool test_SetPassword2(struct torture_context *tctx, NTSTATUS status; struct netr_ServerPasswordSet2 r; const char *password; + DATA_BLOB new_random_pass; struct creds_CredentialState *creds; struct samr_CryptPassword password_buf; + struct samr_Password nt_hash; if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { return false; @@ -440,6 +460,37 @@ static bool test_SetPassword2(struct torture_context *tctx, cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED); + torture_assert (tctx, + test_SetupCredentials(p, tctx, machine_credentials, &creds), + "ServerPasswordSet failed to actually change the password"); + + new_random_pass = netlogon_very_rand_pass(tctx, 128); + + /* now try a random stream of bytes for a password */ + set_pw_in_buffer(password_buf.data, &new_random_pass); + + creds_arcfour_crypt(creds, password_buf.data, 516); + + memcpy(r.in.new_password.data, password_buf.data, 512); + r.in.new_password.length = IVAL(password_buf.data, 512); + + torture_comment(tctx, + "Testing a third ServerPasswordSet2 on machine account, with a compleatly random password\n"); + + creds_client_authenticator(creds, &r.in.credential); + + status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet (3)"); + + if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { + torture_comment(tctx, "Credential chaining failed\n"); + } + + mdfour(nt_hash.hash, new_random_pass.data, new_random_pass.length); + + cli_credentials_set_password(machine_credentials, NULL, CRED_UNINITIALISED); + cli_credentials_set_nt_hash(machine_credentials, &nt_hash, CRED_SPECIFIED); + torture_assert (tctx, test_SetupCredentials(p, tctx, machine_credentials, &creds), "ServerPasswordSet failed to actually change the password"); @@ -1393,7 +1444,14 @@ static bool test_GetDomainInfo(struct torture_context *tctx, q1.blob2.data = NULL; q1.product.string = "product string"; - torture_comment(tctx, "Testing netr_uogonGetDomainInfo\n"); + torture_comment(tctx, "Testing netr_LogonGetDomainInfo\n"); + + status = dcerpc_netr_LogonGetDomainInfo(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "netr_LogonGetDomainInfo"); + torture_assert(tctx, creds_client_check(creds, &a.cred), "Credential chaining failed"); + + torture_comment(tctx, "Testing netr_LogonGetDomainInfo 2nd call\n"); + creds_client_authenticator(creds, &a); status = dcerpc_netr_LogonGetDomainInfo(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "netr_LogonGetDomainInfo"); @@ -1577,6 +1635,7 @@ struct torture_suite *torture_rpc_netlogon(TALLOC_CTX *mem_ctx) tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "netlogon", &ndr_table_netlogon, TEST_MACHINE_NAME); + torture_rpc_tcase_add_test(tcase, "LogonUasLogon", test_LogonUasLogon); torture_rpc_tcase_add_test(tcase, "LogonUasLogoff", test_LogonUasLogoff); torture_rpc_tcase_add_test_creds(tcase, "SamLogon", test_SamLogon); diff --git a/source4/torture/rpc/object_uuid.c b/source4/torture/rpc/object_uuid.c new file mode 100644 index 0000000000..5a77bd1c29 --- /dev/null +++ b/source4/torture/rpc/object_uuid.c @@ -0,0 +1,87 @@ +/* + Unix SMB/CIFS implementation. + + test suite for behaviour of object uuids in rpc requests + + Copyright (C) Stefan Metzmacher 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 . +*/ + +#include "includes.h" +#include "torture/torture.h" +#include "librpc/gen_ndr/ndr_dssetup.h" +#include "librpc/gen_ndr/ndr_dssetup_c.h" +#include "librpc/gen_ndr/ndr_lsa.h" +#include "librpc/gen_ndr/ndr_lsa_c.h" +#include "torture/rpc/rpc.h" + +/* + this tests the send object uuids in the dcerpc request +*/ + +static bool test_random_uuid(struct torture_context *torture) +{ + NTSTATUS status; + struct dcerpc_pipe *p1, *p2; + struct rpc_request *req; + struct GUID uuid; + struct dssetup_DsRoleGetPrimaryDomainInformation r1; + struct lsa_GetUserName r2; + struct lsa_StringPointer authority_name_p; + + torture_comment(torture, "RPC-OBJECTUUID-RANDOM\n"); + + status = torture_rpc_connection(torture, &p1, &ndr_table_dssetup); + torture_assert_ntstatus_ok(torture, status, "opening dsetup pipe1"); + + status = torture_rpc_connection(torture, &p2, &ndr_table_lsarpc); + torture_assert_ntstatus_ok(torture, status, "opening lsa pipe1"); + + uuid = GUID_random(); + + r1.in.level = DS_ROLE_BASIC_INFORMATION; + req = dcerpc_ndr_request_send(p1, &uuid, + &ndr_table_dssetup, + NDR_DSSETUP_DSROLEGETPRIMARYDOMAININFORMATION, + torture, &r1); + status = dcerpc_ndr_request_recv(req); + torture_assert_ntstatus_ok(torture, status, "DsRoleGetPrimaryDomainInformation failed"); + torture_assert_werr_ok(torture, r1.out.result, "DsRoleGetPrimaryDomainInformation failed"); + + uuid = GUID_random(); + + r2.in.system_name = "\\"; + r2.in.account_name = NULL; + r2.in.authority_name = &authority_name_p; + authority_name_p.string = NULL; + + req = dcerpc_ndr_request_send(p2, &uuid, + &ndr_table_lsarpc, + NDR_LSA_GETUSERNAME, + torture, &r2); + status = dcerpc_ndr_request_recv(req); + torture_assert_ntstatus_ok(torture, status, "lsaClose failed"); + torture_assert_ntstatus_ok(torture, r2.out.result, "lsaClose failed"); + + return true; +} + +struct torture_suite *torture_rpc_object_uuid(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite; + suite = torture_suite_create(mem_ctx, "OBJECTUUID"); + torture_suite_add_simple_test(suite, "random-uuid", test_random_uuid); + return suite; +} diff --git a/source4/torture/rpc/remote_pac.c b/source4/torture/rpc/remote_pac.c index 6419e40014..a4111d1c3e 100644 --- a/source4/torture/rpc/remote_pac.c +++ b/source4/torture/rpc/remote_pac.c @@ -68,8 +68,6 @@ static bool test_PACVerify(struct torture_context *tctx, TALLOC_CTX *tmp_ctx = talloc_new(tctx); - int i; - torture_assert(tctx, tmp_ctx != NULL, "talloc_new() failed"); if (!test_SetupCredentials2(p, tctx, NETLOGON_NEG_AUTH2_ADS_FLAGS, @@ -118,16 +116,12 @@ static bool test_PACVerify(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "gensec_update (client) failed"); } - if (client_to_server.length == 0) { - break; - } - status = gensec_update(gensec_server_context, tmp_ctx, client_to_server, &server_to_client); if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {; torture_assert_ntstatus_ok(tctx, status, "gensec_update (server) failed"); } - if (server_to_client.length == 0) { + if (NT_STATUS_IS_OK(status)) { break; } } while (1); @@ -137,7 +131,6 @@ static bool test_PACVerify(struct torture_context *tctx, status = gensec_session_info(gensec_server_context, &session_info); torture_assert_ntstatus_ok(tctx, status, "gensec_session_info failed"); - pac_wrapped_struct.MessageType = 0x3; pac_wrapped_struct.ChecksumLength = session_info->server_info->pac_srv_sig.signature.length; pac_wrapped_struct.SignatureType = session_info->server_info->pac_kdc_sig.type; pac_wrapped_struct.SignatureLength = session_info->server_info->pac_kdc_sig.signature.length; @@ -207,51 +200,6 @@ static bool test_PACVerify(struct torture_context *tctx, torture_assert(tctx, creds_client_check(creds, &r.out.return_authenticator->cred), "Credential chaining failed"); - /* This will break message type, check that however we still get NT_STATUS_OK */ - for (i=0; i < 256; i++) { - pac_wrapped_struct.MessageType = i; - pac_wrapped_struct.ChecksumLength = session_info->server_info->pac_srv_sig.signature.length; - pac_wrapped_struct.SignatureType = session_info->server_info->pac_kdc_sig.type; - pac_wrapped_struct.SignatureLength = session_info->server_info->pac_kdc_sig.signature.length; - pac_wrapped_struct.ChecksumAndSignature = payload - = data_blob_talloc(tmp_ctx, NULL, - pac_wrapped_struct.ChecksumLength - + pac_wrapped_struct.SignatureLength); - memcpy(&payload.data[0], - session_info->server_info->pac_srv_sig.signature.data, - pac_wrapped_struct.ChecksumLength); - memcpy(&payload.data[pac_wrapped_struct.ChecksumLength], - session_info->server_info->pac_kdc_sig.signature.data, - pac_wrapped_struct.SignatureLength); - - ndr_err = ndr_push_struct_blob(&pac_wrapped, tmp_ctx, lp_iconv_convenience(tctx->lp_ctx), &pac_wrapped_struct, - (ndr_push_flags_fn_t)ndr_push_PAC_Validate); - torture_assert(tctx, NDR_ERR_CODE_IS_SUCCESS(ndr_err), "ndr_push_struct_blob of PACValidate structure failed"); - - torture_assert(tctx, (creds->negotiate_flags & NETLOGON_NEG_ARCFOUR), "not willing to even try a PACValidate without RC4 encryption"); - creds_arcfour_crypt(creds, pac_wrapped.data, pac_wrapped.length); - - generic.length = pac_wrapped.length; - generic.data = pac_wrapped.data; - - ZERO_STRUCT(auth2); - creds_client_authenticator(creds, &auth); - r.in.credential = &auth; - r.in.return_authenticator = &auth2; - r.in.logon_level = NetlogonGenericInformation; - r.in.logon.generic = &generic; - r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); - r.in.computer_name = cli_credentials_get_workstation(credentials); - r.in.validation_level = NetlogonValidationGenericInfo2; - - status = dcerpc_netr_LogonSamLogon(p, tctx, &r); - - torture_assert_ntstatus_ok(tctx, status, "LogonSamLogon failed"); - - torture_assert(tctx, creds_client_check(creds, &r.out.return_authenticator->cred), - "Credential chaining failed"); - } - /* This will break the parsing nicely (even in the crypto wrapping), check we get INVALID_PARAMETER */ generic.length--; @@ -272,7 +220,6 @@ static bool test_PACVerify(struct torture_context *tctx, torture_assert(tctx, creds_client_check(creds, &r.out.return_authenticator->cred), "Credential chaining failed"); - pac_wrapped_struct.MessageType = 0x3; pac_wrapped_struct.ChecksumLength = session_info->server_info->pac_srv_sig.signature.length; pac_wrapped_struct.SignatureType = session_info->server_info->pac_kdc_sig.type; @@ -318,8 +265,6 @@ static bool test_PACVerify(struct torture_context *tctx, torture_assert(tctx, creds_client_check(creds, &r.out.return_authenticator->cred), "Credential chaining failed"); - - pac_wrapped_struct.MessageType = 0x3; pac_wrapped_struct.ChecksumLength = session_info->server_info->pac_srv_sig.signature.length; pac_wrapped_struct.SignatureType = session_info->server_info->pac_kdc_sig.type; pac_wrapped_struct.SignatureLength = session_info->server_info->pac_kdc_sig.signature.length; diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index 85f7bde16c..3e5d2d4323 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -25,7 +25,7 @@ #include "torture/rpc/rpc.h" #include "torture/smbtorture.h" #include "librpc/ndr/ndr_table.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" static bool torture_rpc_teardown (struct torture_context *tcase, void *data) @@ -387,6 +387,7 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_suite(suite, torture_rpc_atsvc(suite)); torture_suite_add_suite(suite, torture_rpc_wkssvc(suite)); torture_suite_add_suite(suite, torture_rpc_handles(suite)); + torture_suite_add_suite(suite, torture_rpc_object_uuid(suite)); torture_suite_add_suite(suite, torture_rpc_winreg(suite)); torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss); torture_suite_add_suite(suite, torture_rpc_spoolss_notify(suite)); diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 17342f9b86..260c1cc149 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -47,7 +47,7 @@ #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #include "libcli/auth/libcli_auth.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "auth/ntlmssp/ntlmssp.h" #include "libcli/security/proto.h" #include "param/param.h" @@ -74,6 +74,7 @@ bool torture_bind_authcontext(struct torture_context *torture) struct cli_credentials *anon_creds; struct smb_composite_sesssetup setup; struct smbcli_options options; + struct smbcli_session_options session_options; mem_ctx = talloc_init("torture_bind_authcontext"); @@ -83,13 +84,14 @@ bool torture_bind_authcontext(struct torture_context *torture) } lp_smbcli_options(torture->lp_ctx, &options); + lp_smbcli_session_options(torture->lp_ctx, &session_options); status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -142,7 +144,7 @@ bool torture_bind_authcontext(struct torture_context *torture) goto done; } - session2 = smbcli_session_init(cli->transport, mem_ctx, false); + session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options); if (session2 == NULL) { d_printf("smbcli_session_init failed\n"); goto done; @@ -288,6 +290,7 @@ bool torture_bind_samba3(struct torture_context *torture) bool ret = false; struct smbcli_state *cli; struct smbcli_options options; + struct smbcli_session_options session_options; mem_ctx = talloc_init("torture_bind_authcontext"); @@ -297,13 +300,14 @@ bool torture_bind_samba3(struct torture_context *torture) } lp_smbcli_options(torture->lp_ctx, &options); + lp_smbcli_session_options(torture->lp_ctx, &session_options); status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -1195,6 +1199,7 @@ bool torture_netlogon_samba3(struct torture_context *torture) const char *wks_name; int i; struct smbcli_options options; + struct smbcli_session_options session_options; wks_name = torture_setting_string(torture, "wksname", NULL); if (wks_name == NULL) { @@ -1214,13 +1219,14 @@ bool torture_netlogon_samba3(struct torture_context *torture) } lp_smbcli_options(torture->lp_ctx, &options); + lp_smbcli_session_options(torture->lp_ctx, &session_options); status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, anon_creds, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -1299,15 +1305,17 @@ static bool test_join3(struct torture_context *tctx, struct smbcli_state *cli; struct cli_credentials *wks_creds; struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(tctx->lp_ctx, &options); + lp_smbcli_session_options(tctx->lp_ctx, &session_options); status = smbcli_full_connection(tctx, &cli, torture_setting_string(tctx, "host", NULL), lp_smb_ports(tctx->lp_ctx), "IPC$", NULL, smb_creds, lp_resolve_context(tctx->lp_ctx), - tctx->ev, &options); + tctx->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", nt_errstr(status)); @@ -1670,19 +1678,21 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) struct cli_credentials *user_creds; char *domain_name; struct smbcli_options options; + struct smbcli_session_options session_options; if (!(mem_ctx = talloc_new(torture))) { return false; } lp_smbcli_options(torture->lp_ctx, &options); + lp_smbcli_session_options(torture->lp_ctx, &session_options); status = smbcli_full_connection( mem_ctx, &cli, torture_setting_string(torture, "host", NULL), lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) smbcli_full_connection failed: %s\n", __location__, nt_errstr(status)); @@ -1709,7 +1719,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) lp_smb_ports(torture->lp_ctx), "IPC$", NULL, anon_creds, lp_resolve_context(torture->lp_ctx), - torture->ev, &options); + torture->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) anon smbcli_full_connection failed: %s\n", __location__, nt_errstr(status)); @@ -1762,7 +1772,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) struct smb_composite_sesssetup setup; struct smbcli_tree *tree; - session2 = smbcli_session_init(cli->transport, mem_ctx, false); + session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options); if (session2 == NULL) { d_printf("(%s) smbcli_session_init failed\n", __location__); diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index e2558ff0a9..b7028e6609 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -26,7 +26,7 @@ #include "librpc/gen_ndr/ndr_netlogon_c.h" #include "librpc/gen_ndr/ndr_samr_c.h" #include "auth/auth.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "lib/cmdline/popt_common.h" #include "torture/rpc/rpc.h" #include "auth/gensec/schannel_proto.h" @@ -53,7 +53,9 @@ struct samlogon_state { const char *comment; const char *account_name; const char *account_domain; + const char *netbios_name; const char *password; + const char *workgroup; struct dcerpc_pipe *p; int function_level; uint32_t parameter_control; @@ -593,7 +595,7 @@ static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, DATA_BLOB lmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_session_key = data_blob(NULL, 0); DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, TEST_MACHINE_NAME, lp_workgroup(global_loadparm)); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, TEST_MACHINE_NAME, samlogon_state->workgroup); uint8_t lm_session_key[8]; uint8_t user_session_key[16]; @@ -741,7 +743,7 @@ static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, DATA_BLOB lmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_session_key = data_blob(NULL, 0); DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm)); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, samlogon_state->iconv_convenience, samlogon_state->netbios_name, samlogon_state->workgroup); DATA_BLOB ntlm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB ntlm_session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16); @@ -1337,6 +1339,8 @@ static bool test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, samlogon_state.account_name = account_name; samlogon_state.account_domain = account_domain; samlogon_state.password = plain_pass; + samlogon_state.workgroup = lp_workgroup(tctx->lp_ctx); + samlogon_state.netbios_name = lp_netbios_name(tctx->lp_ctx); samlogon_state.p = p; samlogon_state.creds = creds; samlogon_state.expected_error = expected_error; diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 6afda6e9b5..1f19b8ec3f 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -24,7 +24,7 @@ #include "system/time.h" #include "librpc/gen_ndr/lsa.h" #include "librpc/gen_ndr/ndr_samr_c.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #include "libcli/security/security.h" #include "torture/rpc/rpc.h" @@ -497,6 +497,24 @@ static char *samr_rand_pass(TALLOC_CTX *mem_ctx, int min_len) return s; } +/* + generate a random password for password change tests +*/ +static DATA_BLOB samr_very_rand_pass(TALLOC_CTX *mem_ctx, int len) +{ + int i; + DATA_BLOB password = data_blob_talloc(mem_ctx, NULL, len * 2 /* number of unicode chars */); + generate_random_buffer(password.data, password.length); + + for (i=0; i < len; i++) { + if (((uint16_t *)password.data)[i] == 0) { + ((uint16_t *)password.data)[i] = 1; + } + } + + return password; +} + /* generate a random password for password change tests (fixed length) */ @@ -1841,6 +1859,156 @@ bool test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + const char *account_string, + struct policy_handle *handle, + char **password) +{ + NTSTATUS status; + struct samr_ChangePasswordUser3 r; + struct samr_SetUserInfo s; + union samr_UserInfo u; + DATA_BLOB session_key; + DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16); + uint8_t confounder[16]; + struct MD5Context ctx; + + bool ret = true; + struct lsa_String server, account; + struct samr_CryptPassword nt_pass; + struct samr_Password nt_verifier; + DATA_BLOB new_random_pass; + char *newpass; + char *oldpass; + uint8_t old_nt_hash[16], new_nt_hash[16]; + NTTIME t; + + new_random_pass = samr_very_rand_pass(mem_ctx, 128); + + if (!*password) { + printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n"); + return false; + } + + oldpass = *password; + server.string = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + init_lsa_String(&account, account_string); + + s.in.user_handle = handle; + s.in.info = &u; + s.in.level = 25; + + ZERO_STRUCT(u); + + u.info25.info.fields_present = SAMR_FIELD_PASSWORD; + + set_pw_in_buffer(u.info25.password.data, &new_random_pass); + + status = dcerpc_fetch_session_key(p, &session_key); + if (!NT_STATUS_IS_OK(status)) { + printf("SetUserInfo level %u - no session key - %s\n", + s.in.level, nt_errstr(status)); + return false; + } + + generate_random_buffer((uint8_t *)confounder, 16); + + MD5Init(&ctx); + MD5Update(&ctx, confounder, 16); + MD5Update(&ctx, session_key.data, session_key.length); + MD5Final(confounded_session_key.data, &ctx); + + arcfour_crypt_blob(u.info25.password.data, 516, &confounded_session_key); + memcpy(&u.info25.password.data[516], confounder, 16); + + printf("Testing SetUserInfo level 25 (set password ex) with a password made up of only random bytes\n"); + + status = dcerpc_samr_SetUserInfo(p, mem_ctx, &s); + if (!NT_STATUS_IS_OK(status)) { + printf("SetUserInfo level %u failed - %s\n", + s.in.level, nt_errstr(status)); + ret = false; + } + + printf("Testing ChangePasswordUser3 with a password made up of only random bytes\n"); + + mdfour(old_nt_hash, new_random_pass.data, new_random_pass.length); + + new_random_pass = samr_very_rand_pass(mem_ctx, 128); + + mdfour(new_nt_hash, new_random_pass.data, new_random_pass.length); + + set_pw_in_buffer(nt_pass.data, &new_random_pass); + arcfour_crypt(nt_pass.data, old_nt_hash, 516); + E_old_pw_hash(new_nt_hash, old_nt_hash, nt_verifier.hash); + + r.in.server = &server; + r.in.account = &account; + r.in.nt_password = &nt_pass; + r.in.nt_verifier = &nt_verifier; + r.in.lm_change = 0; + r.in.lm_password = NULL; + r.in.lm_verifier = NULL; + r.in.password3 = NULL; + + unix_to_nt_time(&t, time(NULL)); + + status = dcerpc_samr_ChangePasswordUser3(p, mem_ctx, &r); + + if (NT_STATUS_EQUAL(status, NT_STATUS_PASSWORD_RESTRICTION)) { + if (r.out.reject && r.out.reject->reason != SAMR_REJECT_OTHER) { + printf("expected SAMR_REJECT_OTHER (%d), got %d\n", + SAMR_REJECT_OTHER, r.out.reject->reason); + return false; + } + /* Perhaps the server has a 'min password age' set? */ + + } else if (!NT_STATUS_IS_OK(status)) { + printf("ChangePasswordUser3 failed - %s\n", nt_errstr(status)); + ret = false; + } + + newpass = samr_rand_pass(mem_ctx, 128); + + mdfour(old_nt_hash, new_random_pass.data, new_random_pass.length); + + E_md4hash(newpass, new_nt_hash); + + encode_pw_buffer(nt_pass.data, newpass, STR_UNICODE); + arcfour_crypt(nt_pass.data, old_nt_hash, 516); + E_old_pw_hash(new_nt_hash, old_nt_hash, nt_verifier.hash); + + r.in.server = &server; + r.in.account = &account; + r.in.nt_password = &nt_pass; + r.in.nt_verifier = &nt_verifier; + r.in.lm_change = 0; + r.in.lm_password = NULL; + r.in.lm_verifier = NULL; + r.in.password3 = NULL; + + unix_to_nt_time(&t, time(NULL)); + + status = dcerpc_samr_ChangePasswordUser3(p, mem_ctx, &r); + + if (NT_STATUS_EQUAL(status, NT_STATUS_PASSWORD_RESTRICTION)) { + if (r.out.reject && r.out.reject->reason != SAMR_REJECT_OTHER) { + printf("expected SAMR_REJECT_OTHER (%d), got %d\n", + SAMR_REJECT_OTHER, r.out.reject->reason); + return false; + } + /* Perhaps the server has a 'min password age' set? */ + + } else if (!NT_STATUS_IS_OK(status)) { + printf("ChangePasswordUser3 (on second random password) failed - %s\n", nt_errstr(status)); + ret = false; + } else { + *password = talloc_strdup(mem_ctx, newpass); + } + + return ret; +} + static bool test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *alias_handle) @@ -2061,7 +2229,11 @@ static bool test_user_ops(struct dcerpc_pipe *p, if (!test_ChangePasswordUser2(p, tctx, base_acct_name, &password, samr_rand_pass(tctx, 4), false)) { ret = false; } - + + /* Try a compleatly random password */ + if (!test_ChangePasswordRandomBytes(p, tctx, base_acct_name, user_handle, &password)) { + ret = false; + } } for (i = 0; password_fields[i]; i++) { @@ -2554,7 +2726,7 @@ static bool test_CreateUser(struct dcerpc_pipe *p, struct torture_context *tctx, status = dcerpc_samr_CreateUser(p, user_ctx, &r); if (dom_sid_equal(domain_sid, dom_sid_parse_talloc(tctx, SID_BUILTIN))) { - if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { printf("Server correctly refused create of '%s'\n", r.in.account_name->string); return true; } else { @@ -2678,7 +2850,7 @@ static bool test_CreateUser2(struct dcerpc_pipe *p, struct torture_context *tctx status = dcerpc_samr_CreateUser2(p, user_ctx, &r); if (dom_sid_equal(domain_sid, dom_sid_parse_talloc(tctx, SID_BUILTIN))) { - if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { printf("Server correctly refused create of '%s'\n", r.in.account_name->string); continue; } else { @@ -4525,7 +4697,7 @@ static bool test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("testing samr_Connect4\n"); r4.in.system_name = ""; - r4.in.unknown = 0; + r4.in.client_version = 0; r4.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r4.out.connect_handle = &h; @@ -4543,7 +4715,7 @@ static bool test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("testing samr_Connect5\n"); - info.info1.unknown1 = 0; + info.info1.client_version = 0; info.info1.unknown2 = 0; r5.in.system_name = ""; diff --git a/source4/torture/rpc/samr_accessmask.c b/source4/torture/rpc/samr_accessmask.c index f496f6300c..bfff8c9267 100644 --- a/source4/torture/rpc/samr_accessmask.c +++ b/source4/torture/rpc/samr_accessmask.c @@ -53,7 +53,7 @@ static NTSTATUS torture_samr_Connect5(struct torture_context *tctx, struct samr_Connect5 r5; union samr_ConnectInfo info; - info.info1.unknown1 = 0; + info.info1.client_version = 0; info.info1.unknown2 = 0; r5.in.system_name = ""; r5.in.level = 1; diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index 1e76de1dd2..2d2aaa80d6 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -24,8 +24,8 @@ #include "includes.h" #include "torture/torture.h" #include "auth/auth.h" -#include "lib/util/dlinklist.h" -#include "lib/crypto/crypto.h" +#include "../lib/util/dlinklist.h" +#include "../lib/crypto/crypto.h" #include "system/time.h" #include "torture/rpc/rpc.h" #include "auth/gensec/schannel_proto.h" diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c index ab6309d55f..dc2a82414b 100644 --- a/source4/torture/rpc/spoolss_notify.c +++ b/source4/torture/rpc/spoolss_notify.c @@ -29,7 +29,7 @@ #include "smb_server/smb_server.h" #include "librpc/rpc/dcerpc_proto.h" #include "lib/socket/netif.h" -#include "util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" #include "param/param.h" diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c index 2af8c4f872..3408a1924c 100644 --- a/source4/torture/rpc/testjoin.c +++ b/source4/torture/rpc/testjoin.c @@ -27,7 +27,7 @@ #include "includes.h" #include "torture/torture.h" #include "system/time.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libnet/libnet.h" #include "lib/cmdline/popt_common.h" #include "lib/ldb/include/ldb.h" @@ -472,6 +472,7 @@ static NTSTATUS torture_leave_ads_domain(struct torture_context *torture, } ldb_set_opaque(ldb_ctx, "credentials", cmdline_credentials); + ldb_set_opaque(ldb_ctx, "loadparm", cmdline_lp_ctx); rtn = ldb_connect(ldb_ctx, remote_ldb_url, 0, NULL); if (rtn != 0) { diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 8b602ef652..08ec8f5ea1 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -80,6 +80,7 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, { struct winreg_NotifyChangeKeyValue r; + ZERO_STRUCT(r); r.in.handle = handle; r.in.watch_subtree = true; r.in.notify_filter = 0; @@ -109,6 +110,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle newhandle; enum winreg_CreateAction action_taken = 0; + ZERO_STRUCT(r); r.in.handle = handle; r.out.new_handle = &newhandle; init_winreg_String(&r.in.name, name); @@ -163,6 +165,7 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p, secbuf.length = sdblob.length-10; secbuf.inherit = 0; + ZERO_STRUCT(r); r.in.handle = handle; r.out.new_handle = newhandle; init_winreg_String(&r.in.name, name); @@ -317,6 +320,7 @@ static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx, { struct winreg_CloseKey r; + ZERO_STRUCT(r); r.in.handle = r.out.handle = handle; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CloseKey(p, tctx, &r), @@ -332,6 +336,7 @@ static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx, { struct winreg_FlushKey r; + ZERO_STRUCT(r); r.in.handle = handle; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_FlushKey(p, tctx, &r), @@ -351,6 +356,7 @@ static bool _test_OpenKey(struct dcerpc_pipe *p, struct torture_context *tctx, { struct winreg_OpenKey r; + ZERO_STRUCT(r); r.in.parent_handle = hive_handle; init_winreg_String(&r.in.keyname, keyname); r.in.unknown = 0x00000000; @@ -384,6 +390,7 @@ static bool test_Cleanup(struct dcerpc_pipe *p, struct torture_context *tctx, { struct winreg_DeleteKey r; + ZERO_STRUCT(r); r.in.handle = handle; init_winreg_String(&r.in.key, key); @@ -1389,7 +1396,7 @@ static bool test_QueryInfoKey(struct dcerpc_pipe *p, struct policy_handle *handle, char *class) { struct winreg_QueryInfoKey r; - uint32_t num_subkeys, max_subkeylen, max_subkeysize, + uint32_t num_subkeys, max_subkeylen, max_classlen, num_values, max_valnamelen, max_valbufsize, secdescsize; NTTIME last_changed_time; @@ -1398,7 +1405,7 @@ static bool test_QueryInfoKey(struct dcerpc_pipe *p, r.in.handle = handle; r.out.num_subkeys = &num_subkeys; r.out.max_subkeylen = &max_subkeylen; - r.out.max_subkeysize = &max_subkeysize; + r.out.max_classlen = &max_classlen; r.out.num_values = &num_values; r.out.max_valnamelen = &max_valnamelen; r.out.max_valbufsize = &max_valbufsize; @@ -1435,6 +1442,7 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx, class.name = ""; class.size = 1024; + ZERO_STRUCT(r); r.in.handle = handle; r.in.enum_index = 0; r.in.name = &name; @@ -1486,6 +1494,7 @@ static bool test_QueryMultipleValues(struct dcerpc_pipe *p, NTSTATUS status; uint32_t bufsize=0; + ZERO_STRUCT(r); r.in.key_handle = handle; r.in.values = r.out.values = talloc_array(tctx, struct QueryMultipleValue, 1); r.in.values[0].name = talloc(tctx, struct winreg_String); @@ -1527,12 +1536,14 @@ static bool test_QueryValue(struct dcerpc_pipe *p, uint32_t offered = 0xfff; uint32_t zero = 0; + ZERO_STRUCT(r); r.in.handle = handle; r.in.data = NULL; - r.in.value_name.name = valuename; + r.in.value_name = talloc_zero(tctx, struct winreg_String); + r.in.value_name->name = valuename; r.in.type = &zero_type; - r.in.size = &offered; - r.in.length = &zero; + r.in.data_size = &offered; + r.in.data_length = &zero; status = dcerpc_winreg_QueryValue(p, tctx, &r); if (NT_STATUS_IS_ERR(status)) { @@ -1558,6 +1569,7 @@ static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx, name.name = ""; name.size = 1024; + ZERO_STRUCT(r); r.in.handle = handle; r.in.enum_index = 0; r.in.name = &name; @@ -1594,6 +1606,7 @@ static bool test_AbortSystemShutdown(struct dcerpc_pipe *p, struct winreg_AbortSystemShutdown r; uint16_t server = 0x0; + ZERO_STRUCT(r); r.in.server = &server; torture_assert_ntstatus_ok(tctx, @@ -1612,12 +1625,13 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx, struct winreg_InitiateSystemShutdown r; uint16_t hostname = 0x0; + ZERO_STRUCT(r); r.in.hostname = &hostname; r.in.message = talloc(tctx, struct lsa_StringLarge); init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; - r.in.reboot = 1; + r.in.do_reboot = 1; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_InitiateSystemShutdown(p, tctx, &r), @@ -1636,12 +1650,13 @@ static bool test_InitiateSystemShutdownEx(struct torture_context *tctx, struct winreg_InitiateSystemShutdownEx r; uint16_t hostname = 0x0; + ZERO_STRUCT(r); r.in.hostname = &hostname; r.in.message = talloc(tctx, struct lsa_StringLarge); init_lsa_StringLarge(r.in.message, "spottyfood"); r.in.force_apps = 1; r.in.timeout = 30; - r.in.reboot = 1; + r.in.do_reboot = 1; r.in.reason = 0; torture_assert_ntstatus_ok(tctx, @@ -1694,6 +1709,7 @@ static bool test_Open_Security(struct torture_context *tctx, winreg_open_fn open_fn = userdata; + ZERO_STRUCT(r); r.in.system_name = 0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.out.handle = &handle; @@ -1767,6 +1783,7 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, winreg_open_fn open_fn = userdata; + ZERO_STRUCT(r); r.in.system_name = 0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.out.handle = &handle; diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index b212a44b33..015f20f6e2 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -25,7 +25,7 @@ #include "torture/rpc/rpc.h" #include "lib/cmdline/popt_common.h" #include "param/param.h" -#include "lib/crypto/crypto.h" +#include "../lib/crypto/crypto.h" #include "libcli/auth/libcli_auth.h" #define SMBTORTURE_MACHINE_NAME "smbtrt_name" @@ -1218,12 +1218,12 @@ static bool test_NetrJoinDomain2(struct torture_context *tctx, } switch (join_status) { - case NetSetupDomainName: + case NET_SETUP_DOMAIN_NAME: expected_err = WERR_SETUP_ALREADY_JOINED; break; - case NetSetupUnknownStatus: - case NetSetupUnjoined: - case NetSetupWorkgroupName: + case NET_SETUP_UNKNOWN_STATUS: + case NET_SETUP_UNJOINED: + case NET_SETUP_WORKGROUP_NAME: default: expected_err = WERR_OK; break; @@ -1271,7 +1271,7 @@ static bool test_NetrJoinDomain2(struct torture_context *tctx, return false; } - if (join_status != NetSetupDomainName) { + if (join_status != NET_SETUP_DOMAIN_NAME) { torture_comment(tctx, "Join verify failed: got %d\n", join_status); return false; @@ -1302,12 +1302,12 @@ static bool test_NetrUnjoinDomain2(struct torture_context *tctx, } switch (join_status) { - case NetSetupUnjoined: + case NET_SETUP_UNJOINED: expected_err = WERR_SETUP_NOT_JOINED; break; - case NetSetupDomainName: - case NetSetupUnknownStatus: - case NetSetupWorkgroupName: + case NET_SETUP_DOMAIN_NAME: + case NET_SETUP_UNKNOWN_STATUS: + case NET_SETUP_WORKGROUP_NAME: default: expected_err = WERR_OK; break; @@ -1350,11 +1350,11 @@ static bool test_NetrUnjoinDomain2(struct torture_context *tctx, } switch (join_status) { - case NetSetupUnjoined: - case NetSetupWorkgroupName: + case NET_SETUP_UNJOINED: + case NET_SETUP_WORKGROUP_NAME: break; - case NetSetupUnknown: - case NetSetupDomainName: + case NET_SETUP_UNKNOWN_STATUS: + case NET_SETUP_DOMAIN_NAME: default: torture_comment(tctx, "Unjoin verify failed: got %d\n", join_status); diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c index 4d1b4a7ed0..124e244151 100644 --- a/source4/torture/smb2/create.c +++ b/source4/torture/smb2/create.c @@ -256,6 +256,13 @@ static bool test_create_gentest(struct torture_context *torture, struct smb2_tre status = smb2_getinfo_file(tree, tmp_ctx, &q); CHECK_STATUS(status, NT_STATUS_OK); CHECK_EQUAL(q.access_information.out.access_flags, io.in.desired_access); + + io.in.file_attributes = 0; + io.in.desired_access = 0; + io.in.query_maximal_access = false; + io.in.share_access = 0; + status = smb2_create(tree, tmp_ctx, &io); + CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); talloc_free(tmp_ctx); diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c index 120a71cc95..9418650de4 100644 --- a/source4/torture/smb2/smb2.c +++ b/source4/torture/smb2/smb2.c @@ -23,7 +23,7 @@ #include "torture/smbtorture.h" #include "torture/smb2/proto.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" static bool wrap_simple_1smb2_test(struct torture_context *torture_ctx, struct torture_tcase *tcase, diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 1329f03b04..8d195f1253 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -31,7 +31,7 @@ #include "dynconfig/dynconfig.h" #include "torture/smbtorture.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "librpc/rpc/dcerpc.h" #include "param/param.h" @@ -474,7 +474,7 @@ const static struct torture_ui_ops quiet_ui_ops = { .test_result = quiet_test_result }; -void run_shell(struct torture_context *tctx) +static void run_shell(struct torture_context *tctx) { char *cline; int argc; diff --git a/testprogs/blackbox/test_gentest.sh b/source4/torture/tests/test_gentest.sh similarity index 84% rename from testprogs/blackbox/test_gentest.sh rename to source4/torture/tests/test_gentest.sh index 046f280f7d..2f4d00dc77 100755 --- a/testprogs/blackbox/test_gentest.sh +++ b/source4/torture/tests/test_gentest.sh @@ -17,10 +17,10 @@ DOMAIN=$4 shift 4 failed=0 -samba4bindir=`dirname $0`/../../source4/bin +samba4bindir=`dirname $0`/../../bin gentest=$samba4bindir/gentest -. `dirname $0`/subunit.sh +. `dirname $0`/../../../testprogs/blackbox/subunit.sh cat < st/gentest.ignore all_info.out.fname @@ -29,6 +29,6 @@ EOF testit "gentest" $VALGRIND $gentest //$SERVER/test1 //$SERVER/test2 --num-ops=100 --ignore=st/gentest.ignore -W "$DOMAIN" -U"$USERNAME%$PASSWORD" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` -/bin/rm -f st/gentest.ignore +rm -f st/gentest.ignore exit $failed diff --git a/testprogs/blackbox/test_locktest.sh b/source4/torture/tests/test_locktest.sh similarity index 84% rename from testprogs/blackbox/test_locktest.sh rename to source4/torture/tests/test_locktest.sh index 9cad4dafa2..1fe39b4d1d 100755 --- a/testprogs/blackbox/test_locktest.sh +++ b/source4/torture/tests/test_locktest.sh @@ -18,10 +18,10 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../source4/bin +samba4bindir=`dirname $0`/../../bin locktest=$samba4bindir/locktest -. `dirname $0`/subunit.sh +. `dirname $0`/../../../testprogs/blackbox/subunit.sh testit "locktest" $VALGRIND $locktest //$SERVER/test1 //$SERVER/test2 --num-ops=100 -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` diff --git a/testprogs/blackbox/test_masktest.sh b/source4/torture/tests/test_masktest.sh similarity index 84% rename from testprogs/blackbox/test_masktest.sh rename to source4/torture/tests/test_masktest.sh index 440966261f..59165e47df 100755 --- a/testprogs/blackbox/test_masktest.sh +++ b/source4/torture/tests/test_masktest.sh @@ -18,10 +18,10 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../source4/bin +samba4bindir=`dirname $0`/../../bin masktest=$samba4bindir/masktest -. `dirname $0`/subunit.sh +. `dirname $0`/../../../testprogs/blackbox/subunit.sh testit "masktest" $VALGRIND $masktest //$SERVER/tmp --num-ops=200 --dieonerror -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 54fe0ead27..dc98c2cc9a 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -21,9 +21,10 @@ #include "includes.h" #include "system/time.h" #include "torture/torture.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" #include "lib/cmdline/popt_common.h" +#include "torture/smbtorture.h" _PUBLIC_ int torture_numops=10; _PUBLIC_ int torture_entries=1000; diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c index d7482ddcf1..3bddde2a97 100644 --- a/source4/torture/unix/unix_info2.c +++ b/source4/torture/unix/unix_info2.c @@ -56,15 +56,17 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx) const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(tctx->lp_ctx, &options); + lp_smbcli_session_options(tctx->lp_ctx, &session_options); status = smbcli_full_connection(tctx, &cli, host, lp_smb_ports(tctx->lp_ctx), share, NULL, cmdline_credentials, lp_resolve_context(tctx->lp_ctx), - tctx->ev, &options); + tctx->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to //%s/%s: %s\n", diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c index 39d0a12ab1..d742e23e82 100644 --- a/source4/torture/unix/whoami.c +++ b/source4/torture/unix/whoami.c @@ -77,14 +77,16 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx, const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(tctx->lp_ctx, &options); + lp_smbcli_session_options(tctx->lp_ctx, &session_options); status = smbcli_full_connection(tctx, &cli, host, lp_smb_ports(tctx->lp_ctx), share, NULL, creds, lp_resolve_context(tctx->lp_ctx), - tctx->ev, &options); + tctx->ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to //%s/%s: %s\n", diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 938e7d6c03..3d9c5e321d 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -29,7 +29,7 @@ #include "system/wait.h" #include "system/time.h" #include "torture/torture.h" -#include "util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "auth/credentials/credentials.h" #include "libcli/resolve/resolve.h" #include "param/param.h" @@ -475,8 +475,10 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, NTSTATUS status; struct smbcli_options options; + struct smbcli_session_options session_options; lp_smbcli_options(tctx->lp_ctx, &options); + lp_smbcli_session_options(tctx->lp_ctx, &session_options); options.use_oplocks = torture_setting_bool(tctx, "use_oplocks", true); options.use_level2_oplocks = torture_setting_bool(tctx, "use_level2_oplocks", true); @@ -486,7 +488,7 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, sharename, NULL, cmdline_credentials, lp_resolve_context(tctx->lp_ctx), - ev, &options); + ev, &options, &session_options); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); return false; @@ -512,7 +514,7 @@ _PUBLIC_ bool torture_get_conn_index(int conn_index, return true; } - unc_list = file_lines_load(p, &num_unc_names, NULL); + unc_list = file_lines_load(p, &num_unc_names, 0, NULL); if (!unc_list || num_unc_names <= 0) { DEBUG(0,("Failed to load unc names list from '%s'\n", p)); return false; diff --git a/source4/utils/ad2oLschema.c b/source4/utils/ad2oLschema.c index e229bd104b..c579112b45 100644 --- a/source4/utils/ad2oLschema.c +++ b/source4/utils/ad2oLschema.c @@ -75,18 +75,16 @@ static struct ldb_dn *find_schema_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ct } /* Search for rootdse */ - ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_BASE, NULL, rootdse_attrs, &rootdse_res); + ldb_ret = ldb_search(ldb, mem_ctx, &rootdse_res, + basedn, LDB_SCOPE_BASE, rootdse_attrs, NULL); if (ldb_ret != LDB_SUCCESS) { - ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, - "(&(objectClass=dMD)(cn=Schema))", - NULL, &schema_res); + ldb_ret = ldb_search(ldb, mem_ctx, &schema_res, basedn, LDB_SCOPE_SUBTREE, + NULL, "(&(objectClass=dMD)(cn=Schema))"); if (ldb_ret) { printf("cn=Schema Search failed: %s\n", ldb_errstring(ldb)); return NULL; } - talloc_steal(mem_ctx, schema_res); - if (schema_res->count != 1) { talloc_free(schema_res); printf("Failed to find rootDSE"); @@ -223,7 +221,6 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch for (attribute=schema->attributes; attribute; attribute = attribute->next) { const char *name = attribute->lDAPDisplayName; - const char *description = attribute->adminDescription; const char *oid = attribute->attributeID_oid; const char *syntax = attribute->attributeSyntax_oid; const char *equality = NULL, *substring = NULL; @@ -272,7 +269,16 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch } } - schema_entry = schema_attribute_description(mem_ctx, target, seperator, oid, name, description, equality, substring, syntax, single_value, false); + schema_entry = schema_attribute_description(mem_ctx, + target, + seperator, + oid, + name, + equality, + substring, + syntax, + single_value, + false); if (schema_entry == NULL) { ret.failures++; @@ -293,7 +299,6 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch /* This is already sorted to have 'top' and similar classes first */ for (objectclass=schema->classes; objectclass; objectclass = objectclass->next) { const char *name = objectclass->lDAPDisplayName; - const char *description = objectclass->adminDescription; const char *oid = objectclass->governsID_oid; const char *subClassOf = objectclass->subClassOf; int objectClassCategory = objectclass->objectClassCategory; @@ -358,7 +363,6 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch oid, name, NULL, - description, subClassOf, objectClassCategory, must, diff --git a/source4/utils/config.mk b/source4/utils/config.mk index 37a19077f1..0b98dcfa85 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -61,23 +61,6 @@ PRIVATE_DEPENDENCIES = setnttoken_OBJ_FILES = $(utilssrcdir)/setnttoken.o -################################# -# Start BINARY nmblookup -[BINARY::nmblookup] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBSAMBA-HOSTCONFIG \ - LIBSAMBA-UTIL \ - LIBCLI_NBT \ - LIBPOPT \ - POPT_SAMBA \ - LIBNETIF \ - LIBCLI_RESOLVE -# End BINARY nmblookup -################################# - -nmblookup_OBJ_FILES = $(utilssrcdir)/nmblookup.o - ################################# # Start BINARY testparm [BINARY::testparm] diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 132d689dcb..f26c87bd85 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -22,7 +22,7 @@ #include "includes.h" #include "system/filesys.h" #include "librpc/gen_ndr/ndr_xattr.h" -#include "lib/util/wrap_xattr.h" +#include "../lib/util/wrap_xattr.h" #include "param/param.h" static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); diff --git a/source4/utils/man/ndrdump.1.xml b/source4/utils/man/ndrdump.1.xml deleted file mode 100644 index 9d66102682..0000000000 --- a/source4/utils/man/ndrdump.1.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - ndrdump - 1 - - - - - ndrdump - DCE/RPC Packet Parser and Dumper - - - - - ndrdump - -c context - pipe - function - in|out - filename - - - ndrdump - pipe - - - ndrdump - - - - - DESCRIPTION - - ndrdump tries to parse the specified filename - using Samba's parser for the specified pipe and function. The - third argument should be - either in or out, depending - on whether the data should be parsed as a request or a reply. - - Running ndrdump without arguments will list the pipes for which - parsers are available. - - Running ndrdump with one argument will list the functions that - Samba can parse for the specified pipe. - - The primary function of ndrdump is debugging Samba's internal - DCE/RPC parsing functions. The file being parsed is usually - one exported by wiresharks Export selected packet bytes - function. - - The context argument can be used to load context data from the request - packet when parsing reply packets (such as array lengths). - - - - - VERSION - - This man page is correct for version 4.0 of the Samba suite. - - - - SEE ALSO - - wireshark, pidl - - - - - AUTHOR - - This utility is part of the Samba suite, which is developed by the global Samba Team. - - ndrdump was written by Andrew Tridgell. - - This manpage was written by Jelmer Vernooij. - - - - diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 6a6302837e..1ec87c6b42 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -869,7 +869,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod } if (strequal(request, "LANMAN-Challenge")) { - challenge = strhex_to_data_blob(parameter); + challenge = strhex_to_data_blob(NULL, parameter); if (challenge.length != 8) { mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 8)\n.\n", parameter, @@ -877,7 +877,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod challenge = data_blob(NULL, 0); } } else if (strequal(request, "NT-Response")) { - nt_response = strhex_to_data_blob(parameter); + nt_response = strhex_to_data_blob(NULL, parameter); if (nt_response.length < 24) { mux_printf(mux_id, "Error: hex decode of %s failed! (only got %d bytes, needed at least 24)\n.\n", parameter, @@ -885,7 +885,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod nt_response = data_blob(NULL, 0); } } else if (strequal(request, "LANMAN-Response")) { - lm_response = strhex_to_data_blob(parameter); + lm_response = strhex_to_data_blob(NULL, parameter); if (lm_response.length != 24) { mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 24)\n.\n", parameter, diff --git a/source4/web_server/config.mk b/source4/web_server/config.mk index fe78687794..e034590111 100644 --- a/source4/web_server/config.mk +++ b/source4/web_server/config.mk @@ -4,11 +4,11 @@ # Start SUBSYSTEM WEB [MODULE::WEB] INIT_FUNCTION = server_service_web_init -SUBSYSTEM = smbd -PRIVATE_DEPENDENCIES = ESP LIBTLS smbcalls process_model +SUBSYSTEM = samba +PRIVATE_DEPENDENCIES = LIBTLS smbcalls process_model LIBPYTHON # End SUBSYSTEM WEB ####################### -WEB_OBJ_FILES = $(addprefix $(web_serversrcdir)/, web_server.o http.o) +WEB_OBJ_FILES = $(addprefix $(web_serversrcdir)/, web_server.o wsgi.o) $(eval $(call proto_header_template,$(web_serversrcdir)/proto.h,$(WEB_OBJ_FILES:.o=.c))) diff --git a/source4/web_server/http.c b/source4/web_server/http.c deleted file mode 100644 index bd6efa9262..0000000000 --- a/source4/web_server/http.c +++ /dev/null @@ -1,1030 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - http handling code - - Copyright (C) Andrew Tridgell 2005 - - 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 . -*/ - -#include "includes.h" -#include "smbd/service_task.h" -#include "web_server/web_server.h" -#include "smbd/service_stream.h" -#include "smbd/service.h" -#include "lib/events/events.h" -#include "system/time.h" -#include "system/wait.h" -#include "lib/appweb/esp/esp.h" -#include "lib/appweb/ejs/ejsInternal.h" -#include "lib/util/dlinklist.h" -#include "lib/tls/tls.h" -#include "scripting/ejs/smbcalls.h" -#include "param/param.h" - -#define SAMBA_SESSION_KEY "SambaSessionId" -#define HTTP_PREAUTH_URI "/scripting/preauth.esp" - -/* state of the esp subsystem for a specific request */ -struct esp_state { - struct websrv_context *web; - struct EspRequest *req; - struct MprVar variables[ESP_OBJ_MAX]; - struct session_data *session; -}; - -/* - output the http headers -*/ -static void http_output_headers(struct websrv_context *web) -{ - int i; - char *s; - DATA_BLOB b; - uint32_t content_length = 0; - const char *response_string = "Unknown Code"; - const struct { - unsigned code; - const char *response_string; - } codes[] = { - { 200, "OK" }, - { 301, "Moved" }, - { 302, "Found" }, - { 303, "Method" }, - { 304, "Not Modified" }, - { 400, "Bad request" }, - { 401, "Unauthorized" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 500, "Internal Server Error" }, - { 501, "Not implemented" } - }; - for (i=0;ioutput.response_code) { - response_string = codes[i].response_string; - } - } - - if (web->output.headers == NULL) return; - s = talloc_asprintf(web, "HTTP/1.0 %u %s\r\n", - web->output.response_code, response_string); - if (s == NULL) return; - for (i=0;web->output.headers[i];i++) { - s = talloc_asprintf_append_buffer(s, "%s\r\n", web->output.headers[i]); - } - - /* work out the content length */ - content_length = web->output.content.length; - if (web->output.fd != -1) { - struct stat st; - fstat(web->output.fd, &st); - content_length += st.st_size; - } - s = talloc_asprintf_append_buffer(s, "Content-Length: %u\r\n\r\n", content_length); - if (s == NULL) return; - - b = web->output.content; - web->output.content = data_blob_string_const(s); - data_blob_append(web, &web->output.content, b.data, b.length); - data_blob_free(&b); -} - -/* - return the local path for a URL -*/ -static const char *http_local_path(struct websrv_context *web, - const char *url, - const char *base_dir) -{ - int i; - char *path; - - /* check that the url is OK */ - if (url[0] != '/') return NULL; - - for (i=0;url[i];i++) { - if ((!isalnum((unsigned char)url[i]) && !strchr("./_-", url[i])) || - (url[i] == '.' && strchr("/.", url[i+1]))) { - return NULL; - } - } - - path = talloc_asprintf(web, "%s/%s", base_dir, url+1); - if (path == NULL) return NULL; - - if (directory_exist(path)) { - path = talloc_asprintf_append_buffer(path, "/index.esp"); - } - return path; -} - -/* - called when esp wants to read a file to support include() calls -*/ -static int http_readFile(EspHandle handle, - char **buf, - int *len, - const char *path, - const char *base_dir) -{ - struct websrv_context *web = talloc_get_type(handle, - struct websrv_context); - int fd = -1; - struct stat st; - *buf = NULL; - - path = http_local_path(web, path, base_dir); - if (path == NULL) goto failed; - - fd = open(path, O_RDONLY); - if (fd == -1 || fstat(fd, &st) != 0 || !S_ISREG(st.st_mode)) goto failed; - - *buf = talloc_array(handle, char, st.st_size+1); - if (*buf == NULL) goto failed; - - if (read(fd, *buf, st.st_size) != st.st_size) goto failed; - - (*buf)[st.st_size] = 0; - - close(fd); - *len = st.st_size; - return 0; - -failed: - DEBUG(0,("Failed to read file %s - %s\n", path, strerror(errno))); - if (fd != -1) close(fd); - talloc_free(*buf); - *buf = NULL; - return -1; -} - -static int http_readFileFromSwatDir(EspHandle handle, char **buf, int *len, - const char *path) -{ - return http_readFile(handle, buf, len, path, - lp_swat_directory(global_loadparm)); -} - - - -/* - called when esp wants to find the real path of a file -*/ -static int http_mapToStorage(EspHandle handle, char *path, int len, const char *uri, int flags) -{ - if (uri == NULL || strlen(uri) >= len) return -1; - strncpy(path, uri, len); - return 0; -} - -/* - called when esp wants to output something -*/ -static int http_writeBlock(EspHandle handle, const char *buf, int size) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - if (!data_blob_append(web, &web->output.content, buf, size)) - return -1; - return size; -} - - -/* - set a http header -*/ -static void http_setHeader(EspHandle handle, const char *value, bool allowMultiple) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - char *p = strchr(value, ':'); - - if (p && !allowMultiple && web->output.headers) { - int i; - for (i=0;web->output.headers[i];i++) { - if (strncmp(web->output.headers[i], value, (p+1)-value) == 0) { - web->output.headers[i] = talloc_strdup(web, value); - return; - } - } - } - - web->output.headers = str_list_add(web->output.headers, value); - talloc_steal(web, web->output.headers); -} - -/* - set a http response code -*/ -static void http_setResponseCode(EspHandle handle, int code) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - web->output.response_code = code; -} - -/* - redirect to another web page - */ -static void http_redirect(EspHandle handle, int code, char *url) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - const char *host = web->input.host; - - /* form the full url, unless it already looks like a url */ - if (strchr(url, ':') == NULL) { - if (host == NULL) { - struct socket_address *socket_address = socket_get_my_addr(web->conn->socket, web); - if (socket_address == NULL) goto internal_error; - host = talloc_asprintf(web, "%s:%u", - socket_address->addr, socket_address->port); - } - if (host == NULL) goto internal_error; - if (url[0] != '/') { - char *p = strrchr(web->input.url, '/'); - if (p == web->input.url) { - url = talloc_asprintf(web, "http%s://%s/%s", - tls_enabled(web->conn->socket)?"s":"", - host, url); - } else { - int dirlen = p - web->input.url; - url = talloc_asprintf(web, "http%s://%s%*.*s/%s", - tls_enabled(web->conn->socket)?"s":"", - host, - dirlen, dirlen, web->input.url, - url); - } - if (url == NULL) goto internal_error; - } - } - - http_setHeader(handle, talloc_asprintf(web, "Location: %s", url), 0); - - /* make sure we give a valid redirect code */ - if (code >= 300 && code < 400) { - http_setResponseCode(handle, code); - } else { - http_setResponseCode(handle, 302); - } - return; - -internal_error: - http_error(web, 500, "Internal server error"); -} - - -/* - setup a cookie -*/ -static void http_setCookie(EspHandle handle, const char *name, const char *value, - int lifetime, const char *path, bool secure) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - char *buf; - - if (lifetime > 0) { - buf = talloc_asprintf(web, "Set-Cookie: %s=%s; path=%s; Expires=%s; %s", - name, value, path?path:"/", - http_timestring(web, time(NULL)+lifetime), - secure?"secure":""); - } else { - buf = talloc_asprintf(web, "Set-Cookie: %s=%s; path=%s; %s", - name, value, path?path:"/", - secure?"secure":""); - } - http_setHeader(handle, "Cache-control: no-cache=\"set-cookie\"", 0); - http_setHeader(handle, buf, 0); - talloc_free(buf); -} - -/* - return the session id -*/ -static const char *http_getSessionId(EspHandle handle) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - return web->session->id; -} - -/* - setup a session -*/ -static void http_createSession(EspHandle handle, int timeout) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - if (web->session) { - web->session->lifetime = timeout; - http_setCookie(web, SAMBA_SESSION_KEY, web->session->id, - web->session->lifetime, "/", 0); - } -} - -/* - destroy a session -*/ -static void http_destroySession(EspHandle handle) -{ - struct websrv_context *web = talloc_get_type(handle, struct websrv_context); - talloc_free(web->session); - web->session = NULL; -} - - -/* - setup for a raw http level error -*/ -void http_error(struct websrv_context *web, int code, const char *info) -{ - char *s; - s = talloc_asprintf(web,"Error %u

Error %u

%s

\r\n\r\n", - code, code, info); - if (s == NULL) { - stream_terminate_connection(web->conn, "http_error: out of memory"); - return; - } - http_writeBlock(web, s, strlen(s)); - http_setResponseCode(web, code); - http_output_headers(web); - EVENT_FD_NOT_READABLE(web->conn->event.fde); - EVENT_FD_WRITEABLE(web->conn->event.fde); - web->output.output_pending = true; -} - -/* - map a unix error code to a http error -*/ -void http_error_unix(struct websrv_context *web, const char *info) -{ - int code = 500; - switch (errno) { - case ENOENT: - case EISDIR: - code = 404; - break; - case EACCES: - code = 403; - break; - } - info = talloc_asprintf(web, "%s

%s

\n", info, strerror(errno)); - http_error(web, code, info); -} - - -/* - a simple file request -*/ -static void http_simple_request(struct websrv_context *web) -{ - const char *url = web->input.url; - const char *path; - struct stat st; - - path = http_local_path(web, url, lp_swat_directory(web->task->lp_ctx)); - if (path == NULL) goto invalid; - - /* looks ok */ - web->output.fd = open(path, O_RDONLY); - if (web->output.fd == -1) { - DEBUG(0,("Failed to read file %s - %s\n", path, strerror(errno))); - http_error_unix(web, path); - return; - } - - if (fstat(web->output.fd, &st) != 0 || !S_ISREG(st.st_mode)) { - close(web->output.fd); - goto invalid; - } - - return; - -invalid: - http_error(web, 400, "Malformed URL"); -} - -/* - setup the standard ESP arrays -*/ -static void http_setup_arrays(struct esp_state *esp) -{ - struct websrv_context *web = esp->web; - struct esp_data *edata = talloc_get_type(web->task->private, struct esp_data); - struct EspRequest *req = esp->req; - struct socket_address *socket_address = socket_get_my_addr(web->conn->socket, esp); - struct socket_address *peer_address = socket_get_peer_addr(web->conn->socket, esp); - char *p; - -#define SETVAR(type, name, value) do { \ - const char *v = value; \ - if (v) espSetStringVar(req, type, name, v); \ -} while (0) - - SETVAR(ESP_REQUEST_OBJ, "CONTENT_LENGTH", - talloc_asprintf(esp, "%u", web->input.content_length)); - SETVAR(ESP_REQUEST_OBJ, "QUERY_STRING", web->input.query_string); - SETVAR(ESP_REQUEST_OBJ, "POST_DATA", - talloc_strndup(esp, - web->input.partial.data, - web->input.partial.length)); - SETVAR(ESP_REQUEST_OBJ, "REQUEST_METHOD", web->input.post_request?"POST":"GET"); - SETVAR(ESP_REQUEST_OBJ, "REQUEST_URI", web->input.url); - p = strrchr(web->input.url, '/'); - SETVAR(ESP_REQUEST_OBJ, "SCRIPT_NAME", p+1); - SETVAR(ESP_REQUEST_OBJ, "SCRIPT_FILENAME", web->input.url); - if (peer_address) { - struct MprVar mpv = mprObject("socket_address"); - mprSetPtrChild(&mpv, "socket_address", peer_address); - espSetVar(req, ESP_REQUEST_OBJ, "REMOTE_SOCKET_ADDRESS", mpv); - SETVAR(ESP_REQUEST_OBJ, "REMOTE_ADDR", peer_address->addr); - } - p = socket_get_peer_name(web->conn->socket, esp); - SETVAR(ESP_REQUEST_OBJ, "REMOTE_HOST", p); - SETVAR(ESP_REQUEST_OBJ, "REMOTE_USER", ""); - SETVAR(ESP_REQUEST_OBJ, "CONTENT_TYPE", web->input.content_type); - if (web->session) { - SETVAR(ESP_REQUEST_OBJ, "SESSION_ID", web->session->id); - } - SETVAR(ESP_REQUEST_OBJ, "COOKIE_SUPPORT", web->input.cookie?"true":"false"); - - SETVAR(ESP_HEADERS_OBJ, "HTTP_REFERER", web->input.referer); - SETVAR(ESP_HEADERS_OBJ, "HOST", web->input.host); - SETVAR(ESP_HEADERS_OBJ, "ACCEPT_ENCODING", web->input.accept_encoding); - SETVAR(ESP_HEADERS_OBJ, "ACCEPT_LANGUAGE", web->input.accept_language); - SETVAR(ESP_HEADERS_OBJ, "ACCEPT_CHARSET", web->input.accept_charset); - SETVAR(ESP_HEADERS_OBJ, "COOKIE", web->input.cookie); - SETVAR(ESP_HEADERS_OBJ, "USER_AGENT", web->input.user_agent); - - if (socket_address) { - SETVAR(ESP_SERVER_OBJ, "SERVER_ADDR", socket_address->addr); - SETVAR(ESP_SERVER_OBJ, "SERVER_NAME", socket_address->addr); - SETVAR(ESP_SERVER_OBJ, "SERVER_HOST", socket_address->addr); - SETVAR(ESP_SERVER_OBJ, "SERVER_PORT", - talloc_asprintf(esp, "%u", socket_address->port)); - } - - SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory(esp->web->task->lp_ctx)); - SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->conn->socket)?"https":"http"); - SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SAMBA"); - SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1"); - SETVAR(ESP_SERVER_OBJ, "TLS_SUPPORT", tls_support(edata->tls_params)?"true":"false"); -} - -#if HAVE_SETJMP_H -/* the esp scripting lirary generates exceptions when - it hits a major error. We need to catch these and - report a internal server error via http -*/ -static jmp_buf ejs_exception_buf; -static const char *exception_reason; - -static void web_server_ejs_exception(const char *reason) -{ - Ejs *ep = ejsPtr(0); - if (ep) { - ejsSetErrorMsg(0, "%s", reason); - exception_reason = ep->error; - } else { - exception_reason = reason; - } - DEBUG(0,("%s", exception_reason)); - longjmp(ejs_exception_buf, -1); -} -#else -static void web_server_ejs_exception(const char *reason) -{ - DEBUG(0,("%s", reason)); - smb_panic(reason); -} -#endif - -/* - process a esp request -*/ -static void esp_request(struct esp_state *esp, const char *url) -{ - struct websrv_context *web = esp->web; - int size; - int res; - char *emsg = NULL, *buf; - - if (http_readFile(web, &buf, &size, url, lp_swat_directory(esp->web->task->lp_ctx)) != 0) { - http_error_unix(web, url); - return; - } - -#if HAVE_SETJMP_H - if (setjmp(ejs_exception_buf) != 0) { - http_error(web, 500, exception_reason); - return; - } -#endif - - res = espProcessRequest(esp->req, url, buf, &emsg); - if (res != 0 && emsg) { - http_writeBlock(web, "

", 5);
-		http_writeBlock(web, emsg, strlen(emsg));
-		http_writeBlock(web, "
", 6); - } - talloc_free(buf); -} - -/* - perform pre-authentication on every page if /scripting/preauth.esp - exists. If this script generates any non-whitepace output at all, - then we don't run the requested URL. - - note that the preauth is run even for static pages such as images -*/ -static bool http_preauth(struct esp_state *esp) -{ - const char *path = http_local_path(esp->web, - HTTP_PREAUTH_URI, - lp_swat_directory(esp->web->task->lp_ctx)); - int i; - if (path == NULL) { - http_error(esp->web, 500, "Internal server error"); - return false; - } - if (!file_exist(path)) { - /* if the preath script is not installed then allow access */ - return true; - } - esp_request(esp, HTTP_PREAUTH_URI); - for (i=0;iweb->output.content.length;i++) { - if (!isspace(esp->web->output.content.data[i])) { - /* if the preauth has generated content, then force it - to be html, so that we can show the login page for - failed access to images */ - http_setHeader(esp->web, "Content-Type: text/html", 0); - return false; - } - } - data_blob_free(&esp->web->output.content); - return true; -} - - -/* - handling of + and % escapes in http variables -*/ -static const char *http_unescape(TALLOC_CTX *mem_ctx, const char *p) -{ - char *s0 = talloc_strdup(mem_ctx, p); - char *s = s0; - if (s == NULL) return NULL; - - while (*s) { - unsigned v; - if (*s == '+') *s = ' '; - if (*s == '%' && sscanf(s+1, "%02x", &v) == 1) { - *s = (char)v; - memmove(s+1, s+3, strlen(s+3)+1); - } - s++; - } - - return s0; -} - -/* - set a form or GET variable -*/ -static void esp_putvar(struct esp_state *esp, const char *var, const char *value) -{ - if (strcasecmp(var, SAMBA_SESSION_KEY) == 0) { - /* special case support for browsers without cookie - support */ - esp->web->input.session_key = talloc_strdup(esp, value); - } else { - mprSetPropertyValue(&esp->variables[ESP_FORM_OBJ], - http_unescape(esp, var), - mprCreateStringVar(http_unescape(esp, value), 0)); - } -} - - -/* - parse the variables in a POST style request -*/ -static NTSTATUS http_parse_post(struct esp_state *esp) -{ - DATA_BLOB b = esp->web->input.partial; - - while (b.length) { - char *p, *line; - size_t len; - - p = memchr(b.data, '&', b.length); - if (p == NULL) { - len = b.length; - } else { - len = p - (char *)b.data; - } - line = talloc_strndup(esp, (char *)b.data, len); - NT_STATUS_HAVE_NO_MEMORY(line); - - p = strchr(line,'='); - if (p) { - *p = 0; - esp_putvar(esp, line, p+1); - } - talloc_free(line); - b.length -= len; - b.data += len; - if (b.length > 0) { - b.length--; - b.data++; - } - } - - return NT_STATUS_OK; -} - -/* - parse the variables in a GET style request -*/ -static NTSTATUS http_parse_get(struct esp_state *esp) -{ - struct websrv_context *web = esp->web; - char *p, *s, *tok; - char *pp; - - p = strchr(web->input.url, '?'); - web->input.query_string = p+1; - *p = 0; - - s = talloc_strdup(esp, esp->web->input.query_string); - NT_STATUS_HAVE_NO_MEMORY(s); - - for (tok=strtok_r(s,"&;", &pp);tok;tok=strtok_r(NULL,"&;", &pp)) { - p = strchr(tok,'='); - if (p) { - *p = 0; - esp_putvar(esp, tok, p+1); - } - } - return NT_STATUS_OK; -} - -/* - called when a session times out -*/ -static void session_timeout(struct event_context *ev, struct timed_event *te, - struct timeval t, void *private) -{ - struct session_data *s = talloc_get_type(private, struct session_data); - talloc_free(s); -} - -/* - destroy a session - */ -static int session_destructor(struct session_data *s) -{ - DLIST_REMOVE(s->edata->sessions, s); - return 0; -} - -/* - setup the session for this request -*/ -static void http_setup_session(struct esp_state *esp) -{ - const char *session_key = SAMBA_SESSION_KEY; - char *p; - const char *cookie = esp->web->input.cookie; - const char *key = NULL; - struct esp_data *edata = talloc_get_type(esp->web->task->private, struct esp_data); - struct session_data *s; - bool generated_key = false; - - /* look for our session key */ - if (cookie && (p = strstr(cookie, session_key)) && - p[strlen(session_key)] == '=') { - p += strlen(session_key)+1; - key = talloc_strndup(esp, p, strcspn(p, ";")); - } - - if (key == NULL && esp->web->input.session_key) { - key = esp->web->input.session_key; - } else if (key == NULL) { - key = generate_random_str_list(esp, 16, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - generated_key = true; - } - - /* try to find this session in the existing session list */ - for (s=edata->sessions;s;s=s->next) { - if (strcmp(key, s->id) == 0) { - break; - } - } - - if (s == NULL) { - /* create a new session */ - s = talloc_zero(edata, struct session_data); - s->id = talloc_steal(s, key); - s->data = NULL; - s->te = NULL; - s->edata = edata; - s->lifetime = lp_parm_int(esp->web->task->lp_ctx, NULL, "web", "sessiontimeout", 900); - DLIST_ADD(edata->sessions, s); - talloc_set_destructor(s, session_destructor); - if (!generated_key) { - mprSetPropertyValue(&esp->variables[ESP_REQUEST_OBJ], - "SESSION_EXPIRED", mprCreateStringVar("true", 0)); - } - } - - http_setCookie(esp->web, session_key, key, s->lifetime, "/", 0); - - if (s->data) { - mprCopyVar(&esp->variables[ESP_SESSION_OBJ], s->data, MPR_DEEP_COPY); - } - - esp->web->session = s; -} - - -/* callbacks for esp processing */ -static const struct Esp esp_control = { - .maxScriptSize = 60000, - .writeBlock = http_writeBlock, - .setHeader = http_setHeader, - .redirect = http_redirect, - .setResponseCode = http_setResponseCode, - .readFile = http_readFileFromSwatDir, - .mapToStorage = http_mapToStorage, - .setCookie = http_setCookie, - .createSession = http_createSession, - .destroySession = http_destroySession, - .getSessionId = http_getSessionId -}; - -/* - process a complete http request -*/ -void http_process_input(struct websrv_context *web) -{ - NTSTATUS status; - struct esp_state *esp = NULL; - struct esp_data *edata = talloc_get_type(web->task->private, struct esp_data); - struct smbcalls_context *smbcalls_ctx; - char *p; - void *save_mpr_ctx = mprMemCtx(); - void *ejs_save = ejs_save_state(); - int i; - const char *file_type = NULL; - enum page_type { - page_type_simple, - page_type_esp - }; - enum page_type page_type; - const struct { - const char *extension; - const char *mime_type; - enum page_type page_type; - } mime_types[] = { - {"gif", "image/gif"}, - {"png", "image/png"}, - {"jpg", "image/jpeg"}, - {"txt", "text/plain"}, - {"ico", "image/x-icon"}, - {"css", "text/css"}, - {"esp", "text/html", true} - }; - - /* - * give the smbcalls a chance to find the event context - * and messaging context - */ - smbcalls_ctx = talloc(web, struct smbcalls_context); - if (smbcalls_ctx == NULL) goto internal_error; - smbcalls_ctx->event_ctx = web->conn->event.ctx; - smbcalls_ctx->msg_ctx = web->conn->msg_ctx; - - esp = talloc_zero(smbcalls_ctx, struct esp_state); - if (esp == NULL) goto internal_error; - - esp->web = web; - - mprSetCtx(esp); - - if (espOpen(&esp_control) != 0) goto internal_error; - - for (i=0;ivariables);i++) { - esp->variables[i] = mprCreateUndefinedVar(); - } - esp->variables[ESP_HEADERS_OBJ] = mprCreateObjVar("headers", ESP_HASH_SIZE); - esp->variables[ESP_FORM_OBJ] = mprCreateObjVar("form", ESP_HASH_SIZE); - esp->variables[ESP_APPLICATION_OBJ] = mprCreateObjVar("application", ESP_HASH_SIZE); - esp->variables[ESP_COOKIES_OBJ] = mprCreateObjVar("cookies", ESP_HASH_SIZE); - esp->variables[ESP_FILES_OBJ] = mprCreateObjVar("files", ESP_HASH_SIZE); - esp->variables[ESP_REQUEST_OBJ] = mprCreateObjVar("request", ESP_HASH_SIZE); - esp->variables[ESP_SERVER_OBJ] = mprCreateObjVar("server", ESP_HASH_SIZE); - esp->variables[ESP_SESSION_OBJ] = mprCreateObjVar("session", ESP_HASH_SIZE); - - if (edata->application_data) { - mprCopyVar(&esp->variables[ESP_APPLICATION_OBJ], - edata->application_data, MPR_DEEP_COPY); - } - - smb_setup_ejs_functions(web_server_ejs_exception); - - if (web->input.url == NULL) { - http_error(web, 400, "You must specify a GET or POST request"); - mprSetCtx(save_mpr_ctx); - ejs_restore_state(ejs_save); - return; - } - - /* parse any form or get variables */ - if (web->input.post_request) { - status = http_parse_post(esp); - if (!NT_STATUS_IS_OK(status)) { - http_error(web, 400, "Malformed POST data"); - mprSetCtx(save_mpr_ctx); - ejs_restore_state(ejs_save); - return; - } - } - if (strchr(web->input.url, '?')) { - status = http_parse_get(esp); - if (!NT_STATUS_IS_OK(status)) { - http_error(web, 400, "Malformed GET data"); - mprSetCtx(save_mpr_ctx); - ejs_restore_state(ejs_save); - return; - } - } - - http_setup_session(esp); - - esp->req = espCreateRequest(web, web->input.url, esp->variables); - if (esp->req == NULL) goto internal_error; - - p = strrchr(web->input.url, '.'); - if (p == NULL) { - page_type = page_type_esp; - file_type = "text/html"; - } - for (i=0;p && iinput.url); - } - break; - } - - if (web->conn == NULL) { - /* the connection has been terminated above us, probably - via a timeout */ - goto internal_error; - } - - if (!web->output.output_pending) { - http_output_headers(web); - EVENT_FD_WRITEABLE(web->conn->event.fde); - web->output.output_pending = true; - } - - /* copy any application data to long term storage in edata */ - talloc_free(edata->application_data); - edata->application_data = talloc_zero(edata, struct MprVar); - mprSetCtx(edata->application_data); - mprCopyVar(edata->application_data, &esp->variables[ESP_APPLICATION_OBJ], - MPR_DEEP_COPY); - mprSetCtx(esp); - - /* copy any session data */ - if (web->session) { - talloc_free(web->session->data); - web->session->data = talloc_zero(web->session, struct MprVar); - if (esp->variables[ESP_SESSION_OBJ].properties == NULL || - esp->variables[ESP_SESSION_OBJ].properties[0].numItems == 0) { - talloc_free(web->session); - web->session = NULL; - } else { - mprSetCtx(web->session->data); - mprCopyVar(web->session->data, &esp->variables[ESP_SESSION_OBJ], - MPR_DEEP_COPY); - /* setup the timeout for the session data */ - mprSetCtx(esp); - talloc_free(web->session->te); - web->session->te = event_add_timed(web->conn->event.ctx, web->session, - timeval_current_ofs(web->session->lifetime, 0), - session_timeout, web->session); - } - } - - talloc_free(esp); - mprSetCtx(save_mpr_ctx); - ejs_restore_state(ejs_save); - return; - -internal_error: - mprSetCtx(esp); - talloc_free(esp); - if (web->conn != NULL) { - http_error(web, 500, "Internal server error"); - } - mprSetCtx(save_mpr_ctx); - ejs_restore_state(ejs_save); -} - - -/* - parse one line of header input -*/ -NTSTATUS http_parse_header(struct websrv_context *web, const char *line) -{ - if (line[0] == 0) { - web->input.end_of_headers = true; - } else if (strncasecmp(line,"GET ", 4)==0) { - web->input.url = talloc_strndup(web, &line[4], strcspn(&line[4], " \t")); - } else if (strncasecmp(line,"POST ", 5)==0) { - web->input.post_request = true; - web->input.url = talloc_strndup(web, &line[5], strcspn(&line[5], " \t")); - } else if (strchr(line, ':') == NULL) { - http_error(web, 400, "This server only accepts GET and POST requests"); - return NT_STATUS_INVALID_PARAMETER; - } else if (strncasecmp(line,"Content-Length: ", 16)==0) { - web->input.content_length = strtoul(&line[16], NULL, 10); - } else { -#define PULL_HEADER(v, s) do { \ - if (strncmp(line, s, strlen(s)) == 0) { \ - web->input.v = talloc_strdup(web, &line[strlen(s)]); \ - return NT_STATUS_OK; \ - } \ -} while (0) - PULL_HEADER(content_type, "Content-Type: "); - PULL_HEADER(user_agent, "User-Agent: "); - PULL_HEADER(referer, "Referer: "); - PULL_HEADER(host, "Host: "); - PULL_HEADER(accept_encoding, "Accept-Encoding: "); - PULL_HEADER(accept_language, "Accept-Language: "); - PULL_HEADER(accept_charset, "Accept-Charset: "); - PULL_HEADER(cookie, "Cookie: "); - } - - /* ignore all other headers for now */ - return NT_STATUS_OK; -} - - -/* - setup the esp processor - called at task initialisation -*/ -NTSTATUS http_setup_esp(struct task_server *task) -{ - struct esp_data *edata; - - edata = talloc_zero(task, struct esp_data); - NT_STATUS_HAVE_NO_MEMORY(edata); - - task->private = edata; - - edata->tls_params = tls_initialise(edata, task->lp_ctx); - NT_STATUS_HAVE_NO_MEMORY(edata->tls_params); - - return NT_STATUS_OK; -} diff --git a/source4/web_server/swat/__init__.py b/source4/web_server/swat/__init__.py index e0d85dbe2c..d434bb260b 100644 --- a/source4/web_server/swat/__init__.py +++ b/source4/web_server/swat/__init__.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # Unix SMB/CIFS implementation. # Copyright © Jelmer Vernooij 2008 @@ -19,9 +20,20 @@ # along with this program. If not, see . # -def SWAT(environ, start_response): +def __call__(environ, start_response): status = '200 OK' - response_headers = [('Content-type','text/plain')] + response_headers = [('Content-type','text/html')] start_response(status, response_headers) - return ['Hello world!\n'] + yield '\n' + for key, value in environ.items(): + if isinstance(value, str): + yield '\t\n' % (key, value) + + yield '
%s%s
\n' + +if __name__ == '__main__': + from wsgiref import simple_server + httpd = simple_server.make_server('localhost', 8090, __call__) + print "Serving HTTP on port 8090..." + httpd.serve_forever() diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c index ac83a3384d..74eea9e60b 100644 --- a/source4/web_server/web_server.c +++ b/source4/web_server/web_server.c @@ -4,6 +4,7 @@ web server startup Copyright (C) Andrew Tridgell 2005 + Copyright (C) Jelmer Vernooij 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 @@ -29,6 +30,7 @@ #include "system/network.h" #include "lib/socket/netif.h" #include "lib/tls/tls.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" /* don't allow connections to hang around forever */ @@ -39,9 +41,6 @@ */ static int websrv_destructor(struct websrv_context *web) { - if (web->output.fd != -1) { - close(web->output.fd); - } return 0; } @@ -61,11 +60,91 @@ static void websrv_timeout(struct event_context *event_context, stream_terminate_connection(conn, "websrv_timeout: timed out"); } +/* + setup for a raw http level error +*/ +void http_error(struct websrv_context *web, const char *status, const char *info) +{ + char *s; + s = talloc_asprintf(web,"Error %s

Error %s

%s

\r\n\r\n", + status, status, info); + if (s == NULL) { + stream_terminate_connection(web->conn, "http_error: out of memory"); + return; + } + websrv_output_headers(web, status, NULL); + websrv_output(web, s, strlen(s)); +} + +void websrv_output_headers(struct websrv_context *web, const char *status, struct http_header *headers) +{ + char *s; + DATA_BLOB b; + struct http_header *hdr; + + s = talloc_asprintf(web, "HTTP/1.0 %s\r\n", status); + if (s == NULL) return; + for (hdr = headers; hdr; hdr = hdr->next) { + s = talloc_asprintf_append_buffer(s, "%s: %s\r\n", hdr->name, hdr->value); + } + + s = talloc_asprintf_append_buffer(s, "\r\n"); + + b = web->output.content; + web->output.content = data_blob_string_const(s); + websrv_output(web, b.data, b.length); + data_blob_free(&b); +} + +void websrv_output(struct websrv_context *web, void *data, size_t length) +{ + data_blob_append(web, &web->output.content, data, length); + EVENT_FD_NOT_READABLE(web->conn->event.fde); + EVENT_FD_WRITEABLE(web->conn->event.fde); + web->output.output_pending = true; +} + + +/* + parse one line of header input +*/ +NTSTATUS http_parse_header(struct websrv_context *web, const char *line) +{ + if (line[0] == 0) { + web->input.end_of_headers = true; + } else if (strncasecmp(line,"GET ", 4)==0) { + web->input.url = talloc_strndup(web, &line[4], strcspn(&line[4], " \t")); + } else if (strncasecmp(line,"POST ", 5)==0) { + web->input.post_request = true; + web->input.url = talloc_strndup(web, &line[5], strcspn(&line[5], " \t")); + } else if (strchr(line, ':') == NULL) { + http_error(web, "400 Bad request", "This server only accepts GET and POST requests"); + return NT_STATUS_INVALID_PARAMETER; + } else if (strncasecmp(line, "Content-Length: ", 16)==0) { + web->input.content_length = strtoul(&line[16], NULL, 10); + } else { + struct http_header *hdr = talloc_zero(web, struct http_header); + char *colon = strchr(line, ':'); + if (colon == NULL) { + http_error(web, "500 Internal Server Error", "invalidly formatted header"); + return NT_STATUS_INVALID_PARAMETER; + } + + hdr->name = talloc_strndup(hdr, line, colon-line); + hdr->value = talloc_strdup(hdr, colon+1); + DLIST_ADD(web->input.headers, hdr); + } + + /* ignore all other headers for now */ + return NT_STATUS_OK; +} + /* called when a web connection becomes readable */ static void websrv_recv(struct stream_connection *conn, uint16_t flags) { + struct web_server_data *wdata; struct websrv_context *web = talloc_get_type(conn->private, struct websrv_context); NTSTATUS status; @@ -123,7 +202,9 @@ static void websrv_recv(struct stream_connection *conn, uint16_t flags) destroy the stack variables being used by that rendering process when we handle the timeout. */ if (!talloc_reference(web->task, web)) goto failed; - http_process_input(web); + wdata = talloc_get_type(web->task->private, struct web_server_data); + if (wdata == NULL) goto failed; + wdata->http_process_input(wdata, web); talloc_unlink(web->task, web); } return; @@ -133,6 +214,7 @@ failed: } + /* called when a web connection becomes writable */ @@ -159,29 +241,7 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags) web->output.nsent += nsent; - /* possibly read some more raw data from a file */ - if (web->output.content.length == web->output.nsent && - web->output.fd != -1) { - uint8_t buf[2048]; - ssize_t nread; - - data_blob_free(&web->output.content); - web->output.nsent = 0; - - nread = read(web->output.fd, buf, sizeof(buf)); - if (nread == -1 && errno == EINTR) { - return; - } - if (nread <= 0) { - close(web->output.fd); - web->output.fd = -1; - nread = 0; - } - web->output.content = data_blob_talloc(web, buf, nread); - } - - if (web->output.content.length == web->output.nsent && - web->output.fd == -1) { + if (web->output.content.length == web->output.nsent) { stream_terminate_connection(web->conn, "websrv_send: finished sending"); } } @@ -192,7 +252,7 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags) static void websrv_accept(struct stream_connection *conn) { struct task_server *task = talloc_get_type(conn->private, struct task_server); - struct esp_data *edata = talloc_get_type(task->private, struct esp_data); + struct web_server_data *wdata = talloc_get_type(task->private, struct web_server_data); struct websrv_context *web; struct socket_context *tls_socket; @@ -202,7 +262,6 @@ static void websrv_accept(struct stream_connection *conn) web->task = task; web->conn = conn; conn->private = web; - web->output.fd = -1; talloc_set_destructor(web, websrv_destructor); event_add_timed(conn->event.ctx, web, @@ -210,7 +269,7 @@ static void websrv_accept(struct stream_connection *conn) websrv_timeout, web); /* Overwrite the socket with a (possibly) TLS socket */ - tls_socket = tls_init_server(edata->tls_params, conn->socket, + tls_socket = tls_init_server(wdata->tls_params, conn->socket, conn->event.fde, "GPHO"); /* We might not have TLS, or it might not have initilised */ if (tls_socket) { @@ -243,11 +302,12 @@ static void websrv_task_init(struct task_server *task) NTSTATUS status; uint16_t port = lp_web_port(task->lp_ctx); const struct model_ops *model_ops; + struct web_server_data *wdata; task_server_set_title(task, "task[websrv]"); /* run the web server as a single process */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(task->event_ctx, "single"); if (!model_ops) goto failed; if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) { @@ -280,8 +340,15 @@ static void websrv_task_init(struct task_server *task) /* startup the esp processor - unfortunately we can't do this per connection as that wouldn't allow for session variables */ - status = http_setup_esp(task); - if (!NT_STATUS_IS_OK(status)) goto failed; + wdata = talloc_zero(task, struct web_server_data); + if (wdata == NULL)goto failed; + + task->private = wdata; + + wdata->tls_params = tls_initialise(wdata, task->lp_ctx); + if (wdata->tls_params == NULL) goto failed; + + if (!wsgi_initialize(wdata)) goto failed; return; diff --git a/source4/web_server/web_server.h b/source4/web_server/web_server.h index 52aff05dcc..f91c766494 100644 --- a/source4/web_server/web_server.h +++ b/source4/web_server/web_server.h @@ -19,13 +19,28 @@ #include "smbd/process_model.h" +struct websrv_context; + +struct web_server_data { + struct tls_params *tls_params; + void (*http_process_input)(struct web_server_data *wdata, + struct websrv_context *web); + void *private; +}; + +struct http_header { + char *name; + char *value; + struct http_header *prev, *next; +}; + /* context of one open web connection */ struct websrv_context { struct task_server *task; struct stream_connection *conn; - struct { + struct websrv_request_input { bool tls_detect; bool tls_first_char; uint8_t first_byte; @@ -34,45 +49,17 @@ struct websrv_context { char *url; unsigned content_length; bool post_request; - const char *content_type; - const char *query_string; - const char *user_agent; - const char *referer; - const char *host; - const char *accept_encoding; - const char *accept_language; - const char *accept_charset; - const char *cookie; - const char *session_key; + struct http_header *headers; } input; - struct { + struct websrv_request_output { bool output_pending; DATA_BLOB content; - int fd; + bool headers_sent; unsigned nsent; - int response_code; - const char **headers; } output; struct session_data *session; }; -/* - context for long term storage in the web server, to support session[] - and application[] data. Stored in task->private. -*/ -struct esp_data { - struct session_data { - struct session_data *next, *prev; - struct esp_data *edata; - const char *id; - struct MprVar *data; - struct timed_event *te; - int lifetime; - } *sessions; - struct MprVar *application_data; - struct tls_params *tls_params; -}; - #include "web_server/proto.h" diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c new file mode 100644 index 0000000000..dcbb3c7fb6 --- /dev/null +++ b/source4/web_server/wsgi.c @@ -0,0 +1,391 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright © Jelmer Vernooij 2008 + + Implementation of the WSGI interface described in PEP0333 + (http://www.python.org/dev/peps/pep-0333) + + 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 . +*/ + +#include "includes.h" +#include "web_server/web_server.h" +#include "../lib/util/dlinklist.h" +#include "../lib/util/data_blob.h" +#include "lib/tls/tls.h" +#include + +typedef struct { + PyObject_HEAD + struct websrv_context *web; +} web_request_Object; + +static PyObject *start_response(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *response_header, *exc_info = NULL; + char *status; + int i; + const char *kwnames[] = { + "status", "response_header", "exc_info", NULL + }; + web_request_Object *py_web = (web_request_Object *)self; + struct websrv_context *web = py_web->web; + struct http_header *headers = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO|O:start_response", discard_const_p(char *, kwnames), &status, &response_header, &exc_info)) { + return NULL; + } + + /* FIXME: exc_info */ + + if (!PyList_Check(response_header)) { + PyErr_SetString(PyExc_TypeError, "response_header should be list"); + return NULL; + } + + for (i = 0; i < PyList_Size(response_header); i++) { + struct http_header *hdr = talloc_zero(web, struct http_header); + PyObject *item = PyList_GetItem(response_header, i); + PyObject *py_name, *py_value; + + if (!PyTuple_Check(item)) { + PyErr_SetString(PyExc_TypeError, "Expected tuple"); + return NULL; + } + + if (PyTuple_Size(item) != 2) { + PyErr_SetString(PyExc_TypeError, "header tuple has invalid size, expected 2"); + return NULL; + } + + py_name = PyTuple_GetItem(item, 0); + + if (!PyString_Check(py_name)) { + PyErr_SetString(PyExc_TypeError, "header name should be string"); + return NULL; + } + + py_value = PyTuple_GetItem(item, 1); + if (!PyString_Check(py_value)) { + PyErr_SetString(PyExc_TypeError, "header value should be string"); + return NULL; + } + + hdr->name = talloc_strdup(hdr, PyString_AsString(py_name)); + hdr->value = talloc_strdup(hdr, PyString_AsString(py_value)); + DLIST_ADD(headers, hdr); + } + + websrv_output_headers(web, status, headers); + + return Py_None; +} + +static PyMethodDef web_request_methods[] = { + { "start_response", (PyCFunction)start_response, METH_VARARGS|METH_KEYWORDS, NULL }, + { NULL } +}; + + +PyTypeObject web_request_Type = { + PyObject_HEAD_INIT(NULL) 0, + .tp_name = "wsgi.Request", + .tp_methods = web_request_methods, + .tp_basicsize = sizeof(web_request_Object), + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, +}; + +typedef struct { + PyObject_HEAD +} error_Stream_Object; + +static PyObject *py_error_flush(PyObject *self, PyObject *args, PyObject *kwargs) +{ + /* Nothing to do here */ + return Py_None; +} + +static PyObject *py_error_write(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *kwnames[] = { "str", NULL }; + char *str = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:write", discard_const_p(char *, kwnames), &str)) { + return NULL; + } + + DEBUG(0, ("WSGI App: %s", str)); + + return Py_None; +} + +static PyObject *py_error_writelines(PyObject *self, PyObject *args, PyObject *kwargs) +{ + const char *kwnames[] = { "seq", NULL }; + PyObject *seq = NULL, *item; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:writelines", discard_const_p(char *, kwnames), &seq)) { + return NULL; + } + + while ((item = PyIter_Next(seq))) { + char *str = PyString_AsString(item); + + DEBUG(0, ("WSGI App: %s", str)); + } + + return Py_None; +} + +static PyMethodDef error_Stream_methods[] = { + { "flush", (PyCFunction)py_error_flush, METH_VARARGS|METH_KEYWORDS, NULL }, + { "write", (PyCFunction)py_error_write, METH_VARARGS|METH_KEYWORDS, NULL }, + { "writelines", (PyCFunction)py_error_writelines, METH_VARARGS|METH_KEYWORDS, NULL }, + { NULL, NULL, 0, NULL } +}; + +PyTypeObject error_Stream_Type = { + PyObject_HEAD_INIT(NULL) 0, + .tp_name = "wsgi.ErrorStream", + .tp_basicsize = sizeof(error_Stream_Object), + .tp_methods = error_Stream_methods, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, +}; + +typedef struct { + PyObject_HEAD + struct websrv_context *web; + size_t offset; +} input_Stream_Object; + +static PyObject *py_input_read(PyObject *_self, PyObject *args, PyObject *kwargs) +{ + const char *kwnames[] = { "size", NULL }; + PyObject *ret; + input_Stream_Object *self = (input_Stream_Object *)_self; + int size = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", discard_const_p(char *, kwnames), &size)) + return NULL; + + /* Don't read beyond buffer boundaries */ + if (size == -1) + size = self->web->input.partial.length-self->offset; + else + size = MIN(size, self->web->input.partial.length-self->offset); + + ret = PyString_FromStringAndSize((char *)self->web->input.partial.data+self->offset, size); + self->offset += size; + + return ret; +} + +static PyObject *py_input_readline(PyObject *_self) +{ + input_Stream_Object *self = (input_Stream_Object *)_self; + /* FIXME */ + PyErr_SetString(PyExc_NotImplementedError, + "readline() not yet implemented"); + return NULL; +} + +static PyObject *py_input_readlines(PyObject *_self, PyObject *args, PyObject *kwargs) +{ + const char *kwnames[] = { "hint", NULL }; + PyObject *ret; + int hint; + input_Stream_Object *self = (input_Stream_Object *)_self; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i", discard_const_p(char *, kwnames), &hint)) + return NULL; + + /* FIXME */ + PyErr_SetString(PyExc_NotImplementedError, + "readlines() not yet implemented"); + return NULL; +} + +static PyObject *py_input___iter__(PyObject *_self) +{ + input_Stream_Object *self = (input_Stream_Object *)_self; + /* FIXME */ + PyErr_SetString(PyExc_NotImplementedError, + "__iter__() not yet implemented"); + return NULL; +} + +static PyMethodDef input_Stream_methods[] = { + { "read", (PyCFunction)py_input_read, METH_VARARGS|METH_KEYWORDS, NULL }, + { "readline", (PyCFunction)py_input_readline, METH_NOARGS, NULL }, + { "readlines", (PyCFunction)py_input_readlines, METH_VARARGS|METH_KEYWORDS, NULL }, + { "__iter__", (PyCFunction)py_input___iter__, METH_NOARGS, NULL }, + { NULL, NULL, 0, NULL } +}; + +PyTypeObject input_Stream_Type = { + PyObject_HEAD_INIT(NULL) 0, + .tp_name = "wsgi.InputStream", + .tp_basicsize = sizeof(input_Stream_Object), + .tp_methods = input_Stream_methods, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, +}; + +static PyObject *Py_InputHttpStream(struct websrv_context *web) +{ + input_Stream_Object *ret = PyObject_New(input_Stream_Object, &input_Stream_Type); + ret->web = web; + ret->offset = 0; + return (PyObject *)ret; +} + +static PyObject *Py_ErrorHttpStream(void) +{ + error_Stream_Object *ret = PyObject_New(error_Stream_Object, &error_Stream_Type); + return (PyObject *)ret; +} + +static PyObject *create_environ(bool tls, int content_length, struct http_header *headers, const char *request_method, const char *servername, int serverport, PyObject *inputstream, const char *request_string) +{ + PyObject *env; + PyObject *errorstream; + PyObject *py_scheme; + struct http_header *hdr; + char *questionmark; + + env = PyDict_New(); + if (env == NULL) { + return NULL; + } + + errorstream = Py_ErrorHttpStream(); + if (errorstream == NULL) { + Py_DECREF(env); + Py_DECREF(inputstream); + return NULL; + } + + PyDict_SetItemString(env, "wsgi.input", inputstream); + PyDict_SetItemString(env, "wsgi.errors", errorstream); + PyDict_SetItemString(env, "wsgi.version", Py_BuildValue("(i,i)", 1, 0)); + PyDict_SetItemString(env, "wsgi.multithread", Py_False); + PyDict_SetItemString(env, "wsgi.multiprocess", Py_True); + PyDict_SetItemString(env, "wsgi.run_once", Py_False); + PyDict_SetItemString(env, "SERVER_PROTOCOL", PyString_FromString("HTTP/1.0")); + if (content_length > 0) { + PyDict_SetItemString(env, "CONTENT_LENGTH", PyLong_FromLong(content_length)); + } + PyDict_SetItemString(env, "REQUEST_METHOD", PyString_FromString(request_method)); + + questionmark = strchr(request_string, '?'); + if (questionmark == NULL) { + PyDict_SetItemString(env, "SCRIPT_NAME", PyString_FromString(request_string)); + } else { + PyDict_SetItemString(env, "QUERY_STRING", PyString_FromString(questionmark+1)); + PyDict_SetItemString(env, "SCRIPT_NAME", PyString_FromStringAndSize(request_string, questionmark-request_string)); + } + + PyDict_SetItemString(env, "SERVER_NAME", PyString_FromString(servername)); + PyDict_SetItemString(env, "SERVER_PORT", PyInt_FromLong(serverport)); + for (hdr = headers; hdr; hdr = hdr->next) { + char *name; + if (!strcasecmp(hdr->name, "Content-Type")) { + PyDict_SetItemString(env, "CONTENT_TYPE", PyString_FromString(hdr->value)); + } else { + asprintf(&name, "HTTP_%s", hdr->name); + PyDict_SetItemString(env, name, PyString_FromString(hdr->value)); + free(name); + } + } + + if (tls) { + py_scheme = PyString_FromString("https"); + } else { + py_scheme = PyString_FromString("http"); + } + PyDict_SetItemString(env, "wsgi.url_scheme", py_scheme); + + return env; +} + +static void wsgi_process_http_input(struct web_server_data *wdata, + struct websrv_context *web) +{ + PyObject *py_environ, *result, *item, *iter; + PyObject *request_handler = wdata->private; + struct socket_address *socket_address; + + web_request_Object *py_web = PyObject_New(web_request_Object, &web_request_Type); + py_web->web = web; + + socket_address = socket_get_my_addr(web->conn->socket, web); + py_environ = create_environ(tls_enabled(web->conn->socket), + web->input.content_length, + web->input.headers, + web->input.post_request?"POST":"GET", + socket_address->addr, + socket_address->port, + Py_InputHttpStream(web), + web->input.url + ); + if (py_environ == NULL) { + DEBUG(0, ("Unable to create WSGI environment object\n")); + return; + } + + result = PyObject_CallMethod(request_handler, discard_const_p(char, "__call__"), discard_const_p(char, "OO"), + py_environ, PyObject_GetAttrString((PyObject *)py_web, "start_response")); + + if (result == NULL) { + DEBUG(0, ("error while running WSGI code\n")); + return; + } + + iter = PyObject_GetIter(result); + Py_DECREF(result); + + /* Now, iter over all the data returned */ + + while ((item = PyIter_Next(iter))) { + websrv_output(web, PyString_AsString(item), PyString_Size(item)); + Py_DECREF(item); + } + + Py_DECREF(iter); +} + +bool wsgi_initialize(struct web_server_data *wdata) +{ + PyObject *py_swat; + + Py_Initialize(); + + if (PyType_Ready(&web_request_Type) < 0) + return false; + + if (PyType_Ready(&input_Stream_Type) < 0) + return false; + + if (PyType_Ready(&error_Stream_Type) < 0) + return false; + + wdata->http_process_input = wsgi_process_http_input; + py_swat = PyImport_Import(PyString_FromString("swat")); + if (py_swat == NULL) { + DEBUG(0, ("Unable to find SWAT\n")); + return false; + } + wdata->private = py_swat; + return true; +} diff --git a/source4/winbind/config.mk b/source4/winbind/config.mk index b5eb2c23f0..f719f00853 100644 --- a/source4/winbind/config.mk +++ b/source4/winbind/config.mk @@ -4,7 +4,7 @@ # Start SUBSYSTEM WINBIND [MODULE::WINBIND] INIT_FUNCTION = server_service_winbind_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = \ WB_HELPER \ IDMAP \ @@ -13,7 +13,8 @@ PRIVATE_DEPENDENCIES = \ RPC_NDR_LSA \ dcerpc_samr \ PAM_ERRORS \ - LIBCLI_LDAP + LIBCLI_LDAP \ + LIBSAMBA-NET # End SUBSYSTEM WINBIND ####################### diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index 333a86445a..56ade3e8b1 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -54,11 +54,9 @@ static int idmap_get_bounds(struct idmap_context *idmap_ctx, uint32_t *low, dn = ldb_dn_new(tmp_ctx, ldb, "CN=CONFIG"); if (dn == NULL) goto failed; - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); - if (res->count != 1) { ret = -1; goto failed; @@ -228,7 +226,7 @@ NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(|(type=ID_TYPE_BOTH)(type=%s))" "(xidNumber=%u))", id_type, unixid->id); if (ret != LDB_SUCCESS) { @@ -345,7 +343,7 @@ NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(objectClass=sidMap)(objectSid=%s))", ldap_encode_ndr_dom_sid(tmp_ctx, sid)); if (ret != LDB_SUCCESS) { @@ -401,7 +399,7 @@ NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, /* Redo the search to make sure noone changed the mapping while we * weren't looking */ - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(objectClass=sidMap)(objectSid=%s))", ldap_encode_ndr_dom_sid(tmp_ctx, sid)); if (ret != LDB_SUCCESS) { @@ -431,15 +429,13 @@ NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) { DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); status = NT_STATUS_NONE_MAPPED; goto failed; } - talloc_steal(tmp_ctx, res); - if (res->count != 1) { DEBUG(1, ("No CN=CONFIG record, idmap database is broken.\n")); status = NT_STATUS_NONE_MAPPED; diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c index c2ba55ff18..03b59f56e9 100644 --- a/source4/winbind/wb_samba3_cmd.c +++ b/source4/winbind/wb_samba3_cmd.c @@ -113,7 +113,7 @@ NTSTATUS wbsrv_samba3_netbios_name(struct wbsrv_samba3_call *s3call) NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call) { - char *path = s3call->wbconn->listen_socket->service->priv_socket_path; + const char *path = s3call->wbconn->listen_socket->service->priv_socket_path; s3call->response.result = WINBINDD_OK; s3call->response.extra_data.data = path; diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c index d56a82ea18..b8309597d7 100644 --- a/source4/winbind/wb_server.c +++ b/source4/winbind/wb_server.c @@ -21,7 +21,7 @@ #include "includes.h" #include "lib/socket/socket.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "lib/events/events.h" #include "smbd/service_task.h" #include "smbd/process_model.h" @@ -122,7 +122,7 @@ static void winbind_task_init(struct task_server *task) /* within the winbind task we want to be a single process, so ask for the single process model ops and pass these to the stream_setup_socket() call. */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(task->event_ctx, "single"); if (!model_ops) { task_server_terminate(task, "Can't find 'single' process model_ops"); diff --git a/source4/winbind/wb_sid2domain.c b/source4/winbind/wb_sid2domain.c index fcf02cedcd..cb9fa3ada2 100644 --- a/source4/winbind/wb_sid2domain.c +++ b/source4/winbind/wb_sid2domain.c @@ -25,7 +25,7 @@ #include "smbd/service_task.h" #include "winbind/wb_async_helpers.h" #include "libcli/security/security.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "param/param.h" static struct wbsrv_domain *find_domain_from_sid(struct wbsrv_service *service, diff --git a/source4/wrepl_server/config.mk b/source4/wrepl_server/config.mk index 235a897503..c7b5c3e1df 100644 --- a/source4/wrepl_server/config.mk +++ b/source4/wrepl_server/config.mk @@ -4,7 +4,7 @@ # Start SUBSYSTEM WREPL_SRV [MODULE::WREPL_SRV] INIT_FUNCTION = server_service_wrepl_init -SUBSYSTEM = smbd +SUBSYSTEM = samba PRIVATE_DEPENDENCIES = \ LIBCLI_WREPL WINSDB process_model # End SUBSYSTEM WREPL_SRV diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c index 0508c306e0..ac44b4d75d 100644 --- a/source4/wrepl_server/wrepl_in_call.c +++ b/source4/wrepl_server/wrepl_in_call.c @@ -262,9 +262,8 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) (long long)owner_in->min_version, (long long)owner_in->max_version); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, call, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(call, res); DEBUG(10,("WINSREPL: filter '%s' count %d\n", filter, res->count)); if (res->count == 0) { diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index 25227481b8..ecc265e590 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -218,7 +218,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner, /* within the wrepl task we want to be a single process, so ask for the single process model ops and pass these to the stream_setup_socket() call. */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(service->task->event_ctx, "single"); if (!model_ops) { DEBUG(0,("Can't find 'single' process model_ops")); return NT_STATUS_INTERNAL_ERROR; @@ -273,7 +273,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar /* within the wrepl task we want to be a single process, so ask for the single process model ops and pass these to the stream_setup_socket() call. */ - model_ops = process_model_byname("single"); + model_ops = process_model_startup(task->event_ctx, "single"); if (!model_ops) { DEBUG(0,("Can't find 'single' process model_ops")); return NT_STATUS_INTERNAL_ERROR; diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c index a5cd36797d..a239403e3b 100644 --- a/source4/wrepl_server/wrepl_scavenging.c +++ b/source4/wrepl_server/wrepl_scavenging.c @@ -74,9 +74,8 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi "(expireTime<=%s))", owner_filter, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, tmp_mem, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(tmp_mem, res); DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); tombstone_extra_time = timeval_add(&service->startup_time, @@ -188,9 +187,8 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s "(!(recordState=%u))(expireTime<=%s))", owner_filter, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, tmp_mem, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(tmp_mem, res); DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); tombstone_extra_time = timeval_add(&service->startup_time, @@ -404,9 +402,8 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi "(recordState=%u)(expireTime<=%s))", owner_filter, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); - ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); + ret = ldb_search(service->wins_db->ldb, tmp_mem, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "%s", filter); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; - talloc_steal(tmp_mem, res); DEBUG(10,("WINS scavenging: filter '%s' count %d\n", filter, res->count)); for (i=0; i < res->count; i++) { diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c index b703066986..d0b02d0abe 100644 --- a/source4/wrepl_server/wrepl_server.c +++ b/source4/wrepl_server/wrepl_server.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/util/dlinklist.h" +#include "../lib/util/dlinklist.h" #include "smbd/service_task.h" #include "smbd/service.h" #include "lib/messaging/irpc.h" @@ -55,10 +55,8 @@ static uint64_t wins_config_db_get_seqnumber(struct ldb_context *ldb) if (!dn) goto failed; /* find the record in the WINS database */ - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, - NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); if (res->count > 1) goto failed; if (res->count == 1) { @@ -157,10 +155,10 @@ NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service) service->config.seqnumber = new_seqnumber; /* find the record in the WINS database */ - ret = ldb_search(service->config.ldb, ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"), LDB_SCOPE_SUBTREE, - "(objectClass=wreplPartner)", NULL, &res); + ret = ldb_search(service->config.ldb, tmp_ctx, &res, + ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"), + LDB_SCOPE_SUBTREE, NULL, "(objectClass=wreplPartner)"); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); /* first disable all existing partners */ for (partner=service->partners; partner; partner = partner->next) { @@ -391,11 +389,10 @@ static NTSTATUS wreplsrv_load_table(struct wreplsrv_service *service) } /* find the record in the WINS database */ - ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, - "(objectClass=winsRecord)", attrs, &res); + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + attrs, "(objectClass=winsRecord)"); status = NT_STATUS_INTERNAL_DB_CORRUPTION; if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); for (i=0; i < res->count; i++) { wins_owner = ldb_msg_find_attr_as_string(res->msgs[i], "winsOwner", NULL); diff --git a/testprogs/ejs/minschema_classes.txt b/testdata/minschema_classes.txt similarity index 100% rename from testprogs/ejs/minschema_classes.txt rename to testdata/minschema_classes.txt diff --git a/testprogs/blackbox/test_kinit.sh b/testprogs/blackbox/test_kinit.sh index b9969e2c57..90e3d37453 100755 --- a/testprogs/blackbox/test_kinit.sh +++ b/testprogs/blackbox/test_kinit.sh @@ -1,7 +1,7 @@ #!/bin/sh # Blackbox tests for kinit and kerberos integration with smbclient etc # Copyright (C) 2006-2007 Jelmer Vernooij -# Copyright (C) 2006-2007 Andrew Bartlett +# Copyright (C) 2006-2008 Andrew Bartlett if [ $# -lt 5 ]; then cat < ./tmpuserpassfile testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1` + +USERPASS=$NEWUSERPASS +NEWUSERPASS=testPaSS@56% +echo $NEWUSERPASS > ./tmpuserpassfile + +cat > ./tmpkpasswdscript < ./tmpuserpassfile + +test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1` + +cat > ./tmpkpasswdscript < ${object}" + r=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: '` + n=`echo "${r}" | grep 'dn: ' | wc -l` + c=`echo "${r}" | grep "${object}" | wc -l` + + if [ $n -lt 1 ]; then + echo "Object not found by WKGUID" + failed=`expr $failed + 1` + continue + fi + if [ $c -lt 1 ]; then + echo "Wrong object found by WKGUID: [${r}]" + failed=`expr $failed + 1` + continue + fi + done + + return $failed +} + +wellknown_object_test 22B70C67D56E4EFB91E9300FCA3DC1AA ForeignSecurityPrincipals +st=$? +if [ x"$st" != x"0" ]; then + failed=`expr $failed + $st` +fi +wellknown_object_test 2FBAC1870ADE11D297C400C04FD8D5CD Infrastructure +st=$? +if [ x"$st" != x"0" ]; then + failed=`expr $failed + $st` +fi +wellknown_object_test AB1D30F3768811D1ADED00C04FD8D5CD System +st=$? +if [ x"$st" != x"0" ]; then + failed=`expr $failed + $st` +fi +wellknown_object_test A361B2FFFFD211D1AA4B00C04FD7D83A Domain Controllers +st=$? +if [ x"$st" != x"0" ]; then + failed=`expr $failed + $st` +fi +wellknown_object_test AA312825768811D1ADED00C04FD8D5CD Computers +st=$? +if [ x"$st" != x"0" ]; then + failed=`expr $failed + $st` +fi +wellknown_object_test A9D1CA15768811D1ADED00C04FD8D5CD Users +st=$? +if [ x"$st" != x"0" ]; then + failed=`expr $failed + $st` +fi + +echo "Getting HEX GUID/SID of $BASEDN" +HEXDN=`bin/ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:0 | grep 'dn: ' | cut -d ' ' -f2-` +HEXGUID=`echo "$HEXDN" | cut -d ';' -f1` +HEXSID=`echo "$HEXDN" | cut -d ';' -f2` +echo "HEXGUID[$HEXGUID]" +echo "HEXSID[$HEXSID]" + +echo "Getting STR GUID/SID of $BASEDN" +STRDN=`bin/ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 | grep 'dn: ' | cut -d ' ' -f2-` +echo "STRDN: $STRDN" +STRGUID=`echo "$STRDN" | cut -d ';' -f1` +STRSID=`echo "$STRDN" | cut -d ';' -f2` +echo "STRGUID[$STRGUID]" +echo "STRSID[$STRSID]" + +SPECIALDNS="$HEXGUID $HEXSID $STRGUID $STRSID" +for SPDN in $SPECIALDNS; do + echo "Search for $SPDN" + nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "$SPDN" '(objectClass=*)' | grep "dn: $BASEDN" | wc -l` + if [ $nentries -lt 1 ]; then + echo "Special search returned 0 items" + failed=`expr $failed + 1` + fi +done exit $failed diff --git a/testprogs/ejs/base.js b/testprogs/ejs/base.js deleted file mode 100755 index 3c998ee4f8..0000000000 --- a/testprogs/ejs/base.js +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -exec smbscript "$0" ${1+"$@"} - -var options = GetOptions(ARGV, - "POPT_COMMON_SAMBA"); -if (options == undefined) { - println("Failed to parse options"); - return -1; -} - -libinclude("base.js"); - -var obj = new Object(); -obj.FOO = "foo"; -obj.BAR = "bar"; -var str1 = "${FOO}:${BAR}"; -var str2 = "${FOO}:${BAR} "; // note the space after the brace -var sub1 = substitute_var(str1, obj); -var sub2 = substitute_var(str2, obj); - -assert(str1 + " " == str2); -assert(sub1 + " " == sub2); -exit(0); diff --git a/testprogs/ejs/bugs.js b/testprogs/ejs/bugs.js deleted file mode 100644 index 0c1cecb486..0000000000 --- a/testprogs/ejs/bugs.js +++ /dev/null @@ -1,155 +0,0 @@ -/* - demonstrate some bugs in ejs - - tridge -*/ - - -/**************************************** -demo a bug in constructing arrays -fix at http://build.samba.org/build.pl?function=diff;tree=samba4;revision=7124 -status: FIXED -*****************************************/ -function arraybug() { - var a; - - println("First with 3 elements"); - a = new Array("one", "two", "three"); - printVars(a); - assert(a.length == 3); - assert(a[0] == "one"); - assert(a[1] == "two"); - assert(a[2] == "three"); - - println("with a array length"); - a = new Array(5); - printVars(a); - assert(a.length == 5); - - println("\nNow with 1 element"); - a = new Array("one"); - printVars(a); - assert(a.length == 1); - assert(a[0] == "one"); - - println("ALL OK"); -} - - -/**************************************** -demo a bug in variable arguments -fix at http://build.samba.org/build.pl?function=diff;tree=samba4;revision=7085 -status: FIXED -*****************************************/ -function argsbug() { - println("we should have been called with 3 arguments"); - assert(arguments.length == 3); - assert(arguments[0] == "one"); - assert(arguments[1] == "two"); - assert(arguments[2] == "three"); -} - - -/**************************************** -demo a bug in constructing objects -no fix available yet -status: SUBMITTED -*****************************************/ -function MyObj() { - var o = new Object(); - o.test = 42; - return o; -} - -function objbug() { - println("the docs say you should use 'new'"); - var o1 = new MyObj(); - var o2 = MyObj(); - printVars(o1); - printVars(o2); - assert(o1.test == 42); - assert(o2.test == 42); -} - -/* - demo a expression handling bug - status: FIXED -*/ -function exprbug() { - var a = new Array(10); - var i; - for (i=0;i<4;i++) { - a[1+(i*2)] = i; - a[2+(i*2)] = i*2; - } -} - -/**************************************** -demo lack of recursion -fix in http://build.samba.org/build.pl?function=diff;tree=samba4;revision=7127 -status: FIXED -*****************************************/ -function fibonacci(n) { - if (n < 3) { - return 1; - } - return fibonacci(n-1) + fibonacci(n-2); -} - -function recursebug() { - println("First 10 fibonacci numbers:"); - for (i=0;i<10;i++) { - println("fibonacci(" + i + ")=" + fibonacci(i)); - } -} - -/**************************************** -demo lack of function variables inside functions -status: FIXED IN SAMBA -*****************************************/ -function callback() -{ - return "testing"; -} - -function fnbug(c) -{ - s = c(); - assert(s == "testing"); -} - -/**************************************** -demo incorrect handling of reserved words in strings -status: SUBMITTED -*****************************************/ -function reservedbug() -{ - assert("funct" + "ion" == 'function'); -} - - -/**************************************** -demo incorrect handling of boolean functions -status: SUBMITTED -*****************************************/ -function no() -{ - return false; -} - -function boolbug() -{ - assert(false == no()); - assert(!no()); -} - - -/* run the tests */ -arraybug(); -argsbug("one", "two", "three"); -recursebug(); -exprbug(); -fnbug(callback); -reservedbug(); -boolbug(); -objbug(); diff --git a/testprogs/ejs/ldb.js b/testprogs/ejs/ldb.js deleted file mode 100755 index 8c71994805..0000000000 --- a/testprogs/ejs/ldb.js +++ /dev/null @@ -1,385 +0,0 @@ -#!/bin/sh -exec smbscript "$0" ${1+"$@"} -/* - demonstrate access to ldb databases from ejs -*/ - - -var ldb = ldb_init(); -var sys; -var options = GetOptions(ARGV, - "POPT_AUTOHELP", - "POPT_COMMON_SAMBA"); -if (options == undefined) { - println("Failed to parse options"); - return -1; -} - -libinclude("base.js"); - -if (options.ARGV.length != 1) { - println("Usage: ldb.js "); - return -1; -} - -prefix = options.ARGV[0]; - -function basic_tests(ldb) -{ - println("Running basic tests"); - ok = ldb.add(" -dn: cn=x,cn=test -objectClass: foo -x: 3 -"); - assert(ok.error == 0); - - println("Testing ldb.search"); - var res = ldb.search("(objectClass=*)"); - assert(res.msgs[0].objectClass[0] == "foo"); - assert(res.msgs[0].dn == "cn=x,cn=test"); - assert(res.msgs[0].x == 3); - - ok = ldb.add(" -dn: cn=x2,cn=test -objectClass: foo -x: 4 -"); - assert(ok.error == 0); - var attrs = new Array("x"); - res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs); - assert(res.msgs[0].x == 4); - assert(res.msgs[0].objectClass == undefined); - assert(res.msgs[0].dn == "cn=x2,cn=test"); - - ok = ldb.del("cn=x,cn=test"); - assert(ok.error == 0); - - ok = ldb.rename("cn=x2,cn=test", "cn=x3,cn=test"); - assert(ok.error == 0); - res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs); - assert(res.msgs[0].dn == "cn=x3,cn=test"); - - ok = ldb.rename("cn=x3,cn=test", "cn=X3,cn=test"); - assert(ok.error == 0); - res = ldb.search("x=4", NULL, ldb.SCOPE_DEFAULT, attrs); - assert(res.msgs[0].dn == "cn=X3,cn=test"); - - ok = ldb.modify(" -dn: cn=x3,cn=test -changetype: modify -add: x -x: 7 -"); - - res = ldb.search("x=7"); - assert(res.msgs.length == 1); - assert(res.msgs[0].x.length == 2); - - /* Check a few things before we add modules */ - assert(res.msgs[0].objectGUID == undefined); - assert(res.msgs[0].createTimestamp == undefined); - assert(res.msgs[0].whenCreated == undefined); - -} - -function setup_modules(ldb) -{ - ok = ldb.add(" -dn: @MODULES -@LIST: rootdse,operational,rdn_name,partition - -dn: @ROOTDSE -defaultNamingContext: cn=Test - -dn: @PARTITION -partition: cn=SideTest:" + prefix + "/" + "testside.ldb -partition: cn=Sub,cn=PartTest:" + prefix + "/" + "testsub.ldb -partition: cn=PartTest:" + prefix + "/" + "testpartition.ldb -partition: cn=Sub,cn=Sub,cn=PartTest:" + prefix + "/" + "testsubsub.ldb -replicateEntries: @ATTRIBUTES -replicateEntries: @INDEXLIST -modules: cn=PartTest:objectguid -"); -} - -/* Test the basic operation of the timestamps,objectguid and name_rdn - modules */ - -function modules_test(ldb, parttestldb) -{ - println("Running modules tests"); - - ok = ldb.add(" -dn: @ATTRIBUTES -cn: CASE_INSENSITIVE -caseattr: CASE_INSENSITIVE -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - /* Confirm that the attributes were replicated */ - var res_attrs = parttestldb.search("cn=*", "@ATTRIBUTES", parttestldb.SCOPE_BASE); - assert(res_attrs.msgs[0].cn == "CASE_INSENSITIVE"); - - ok = ldb.add(" -dn: cn=x8,cn=PartTest -objectClass: foo -x: 8 -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - ok = ldb.add(" -dn: cn=x9,cn=PartTest -objectClass: foo -x: 9 -cn: X9 -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - ok = ldb.add(" -dn: cn=X9,cn=PartTest -objectClass: foo -x: 9 -cn: X9 -"); - if (ok.error == 0) { - println("Should have failed to add cn=X9,cn=PartTest"); - assert(ok.error != 0); - } - - var res = ldb.search("x=8", "cn=PartTest", ldb.SCOPE_DEFAULT); - assert(res.msgs[0].objectGUID != undefined); - assert(res.msgs[0].uSNCreated != undefined); - assert(res.msgs[0].uSNChanged != undefined); - assert(res.msgs[0].createTimestamp == undefined); - assert(res.msgs[0].whenCreated != undefined); - assert(res.msgs[0].name == "x8"); - assert(res.msgs[0].cn == "x8"); - - /* Confirm that this ended up in the correct LDB */ - var res_otherldb = parttestldb.search("x=8", "cn=PartTest", parttestldb.SCOPE_DEFAULT); - assert(res_otherldb.msgs[0].objectGUID != undefined); - assert(res_otherldb.msgs[0].createTimestamp == undefined); - assert(res_otherldb.msgs[0].whenCreated != undefined); - assert(res_otherldb.msgs[0].name == "x8"); - assert(res_otherldb.msgs[0].cn == "x8"); - - var attrs = new Array("*", "createTimestamp"); - var res2 = ldb.search("x=9", "cn=PartTest", ldb.SCOPE_DEFAULT, attrs); - assert(res2.msgs[0].objectGUID != undefined); - assert(res2.msgs[0].createTimestamp != undefined); - assert(res2.msgs[0].whenCreated != undefined); - assert(res2.msgs[0].name == "x9"); - assert(res2.msgs[0].cn == "x9"); - - assert(res.msgs[0].objectGUID != res2.msgs[0].objectGUID); - - var attrs = new Array("*"); - var res3 = ldb.search("", "", ldb.SCOPE_BASE, attrs); - assert(res3.msgs[0].cn == undefined); - assert(res3.msgs[0].distinguishedName == undefined); - assert(res3.msgs[0].name == undefined); - assert(res3.msgs[0].currentTime != undefined); - assert(res3.msgs[0].highestCommittedUSN != undefined); - - assert(res3.msgs[0].namingContexts[0] == "cn=Sub,cn=Sub,cn=PartTest"); - assert(res3.msgs[0].namingContexts[1] == "cn=Sub,cn=PartTest"); - assert(res3.msgs[0].namingContexts[2] == "cn=PartTest"); - assert(res3.msgs[0].namingContexts[3] == "cn=SideTest"); - var usn = res3.msgs[0].highestCommittedUSN; - - /* Start a transaction. We are going to abort it later, to - * show we clean up all partitions */ - - ok = ldb.transaction_start() - if (!ok) { - println("Failed to start a transaction: " + ok.errstr); - assert(ok.error == 0); - } - - - ok = ldb.add(" -dn: cn=x10,cn=parttest -objectClass: foo -x: 10 -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - var attrs = new Array("highestCommittedUSN"); - var res4 = ldb.search("", "", ldb.SCOPE_BASE, attrs); - var usn2 = res4.msgs[0].highestCommittedUSN; - assert(usn < res4.msgs[0].highestCommittedUSN); - - ok = ldb.add(" -dn: cn=x11,cn=sub,cn=parttest -objectClass: foo -x: 11 -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - var attrs = new Array("highestCommittedUSN"); - var res5 = ldb.search("", "", ldb.SCOPE_BASE, attrs); - assert(usn2 < res5.msgs[0].highestCommittedUSN); - - var attrs = new Array("*", "createTimestamp"); - var res6 = ldb.search("x=11", "cn=parttest", ldb.SCOPE_SUB, attrs); - assert(res6.msgs.length == 0); - - var attrs = new Array("*", "createTimestamp"); - var res7 = ldb.search("x=10", "cn=sub,cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(res7.msgs.length == 0); - - var res8 = ldb.search("x=11", "cn=sub,cn=parttest", ldb.SCOPE_DEFAULT, attrs); - - assert(res8.msgs[0].objectGUID == undefined); /* The objectGUID module is not loaded here */ - assert(res8.msgs[0].uSNCreated == undefined); /* The objectGUID module is not loaded here */ - assert(res8.msgs[0].name == "x11"); - assert(res8.msgs[0].cn == "x11"); - - ok = ldb.add(" -dn: caseattr=XY,cn=PartTest -objectClass: foo -x: Y -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - ok = ldb.add(" -dn: caseattr=XZ,cn=PartTest -objectClass: foo -x: Z -caseattr: XZ -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - ok = ldb.add(" -dn: caseattr=xz,cn=PartTest -objectClass: foo -x: Z -caseattr: xz -"); - if (ok.error == 0) { - println("Should have failed to add caseattr=xz,cn=PartTest"); - assert(ok.error != 0); - } - - ok = ldb.add(" -dn: caseattr2=XZ,cn=PartTest -objectClass: foo -x: Z -caseattr2: XZ -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - ok = ldb.add(" -dn: caseattr2=Xz,cn=PartTest -objectClass: foo -x: Z -caseattr2: Xz -"); - if (ok.error != 0) { - println("Failed to add: " + ok.errstr); - assert(ok.error == 0); - } - - var resX = ldb.search("caseattr=xz", "cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(resX.msgs.length == 1); - assert(resX.msgs[0].objectGUID != undefined); - assert(resX.msgs[0].createTimestamp != undefined); - assert(resX.msgs[0].whenCreated != undefined); - assert(resX.msgs[0].name == "XZ"); - - var rescount = ldb.search("(|(caseattr=*)(cn=*))", "cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(rescount.msgs.length == 5); - - /* Check this attribute is *not* case sensitive */ - var resXcount = ldb.search("caseattr=x*", "cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(resXcount.msgs.length == 2); - - /* Check that this attribute *is* case sensitive */ - var resXcount2 = ldb.search("caseattr2=xz", "cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(resXcount2.msgs.length == 0); - - - /* Now abort the transaction to show that even with - * partitions, it is aborted everywhere */ - ok = ldb.transaction_cancel(); - if (!ok) { - println("Failed to cancel a transaction: " + ok.errstr); - assert(ok); - } - - /* now check it all went away */ - - var attrs = new Array("highestCommittedUSN"); - var res9 = ldb.search("", "", ldb.SCOPE_BASE, attrs); - assert(usn == res9.msgs[0].highestCommittedUSN); - - var attrs = new Array("*"); - var res10 = ldb.search("x=11", "cn=sub,cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(res10.msgs.length == 0); - - var attrs = new Array("*"); - var res11 = ldb.search("x=10", "cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(res11.msgs.length == 0); - - var attrs = new Array("*"); - var res12 = ldb.search("caseattr=*", "cn=parttest", ldb.SCOPE_DEFAULT, attrs); - assert(res12.msgs.length == 0); - -} - -sys = sys_init(); -var dbfile = "test.ldb"; - -sys.unlink(prefix + "/" + dbfile); -sys.unlink(prefix + "/" + "testpartition.ldb"); -sys.unlink(prefix + "/" + "testsub.ldb"); -sys.unlink(prefix + "/" + "testsubsub.ldb"); -sys.unlink(prefix + "/" + "testside.ldb"); - -var ok = ldb.connect("tdb://" + prefix + "/" + dbfile); -assert(ok); - -basic_tests(ldb); - -setup_modules(ldb); -ldb = ldb_init(); -var ok = ldb.connect("tdb://" + prefix + "/" + dbfile); -assert(ok); - -parttestldb = ldb_init(); -var ok = parttestldb.connect("tdb://" + prefix + "/" + "testpartition.ldb"); -assert(ok); - -modules_test(ldb, parttestldb); - -sys.unlink(prefix + "/" + dbfile); -sys.unlink(prefix + "/" + "testpartition.ldb"); -sys.unlink(prefix + "/" + "testsub.ldb"); -sys.unlink(prefix + "/" + "testsubsub.ldb"); -sys.unlink(prefix + "/" + "testside.ldb"); -return 0; diff --git a/testprogs/ejs/minschema.js b/testprogs/ejs/minschema.js deleted file mode 100755 index f088501c1d..0000000000 --- a/testprogs/ejs/minschema.js +++ /dev/null @@ -1,804 +0,0 @@ -#!/bin/sh -exec smbscript "$0" ${1+"$@"} -/* - work out the minimal schema for a set of objectclasses -*/ - -libinclude("base.js"); - -var ldb = ldb_init(); - -var options = GetOptions(ARGV, - "POPT_AUTOHELP", - "POPT_COMMON_SAMBA", - "POPT_COMMON_CREDENTIALS", - "verbose", - "classes", - "attributes"); -if (options == undefined) { - println("Failed to parse options"); - return -1; -} -verbose = options["verbose"]; -dump_all = "yes"; -dump_classes = options["classes"]; -dump_attributes = options["attributes"]; - -if (dump_classes != undefined) { - dump_all = undefined; -} -if (dump_attributes != undefined) { - dump_all = undefined; -} -if (dump_all != undefined) { - dump_classes = "yes"; - dump_attributes = "yes"; -} - -if (options.ARGV.length != 2) { - println("Usage: minschema.js "); - return -1; -} - -var url = options.ARGV[0]; -var classfile = options.ARGV[1]; - -/* use command line creds if available */ -ldb.credentials = options.get_credentials(); - -var ok = ldb.connect(url); -assert(ok); - -objectclasses = new Object(); -attributes = new Object(); -rootDse = new Object(); - -objectclasses_expanded = new Object(); - -/* the attributes we need for objectclasses */ -class_attrs = new Array("objectClass", - "subClassOf", - "governsID", - "possSuperiors", - "possibleInferiors", - "mayContain", - "mustContain", - "auxiliaryClass", - "rDNAttID", - "showInAdvancedViewOnly", - "adminDisplayName", - "adminDescription", - "objectClassCategory", - "lDAPDisplayName", - "schemaIDGUID", - "systemOnly", - "systemPossSuperiors", - "systemMayContain", - "systemMustContain", - "systemAuxiliaryClass", - "defaultSecurityDescriptor", - "systemFlags", - "defaultHidingValue", - "defaultObjectCategory", - - /* this attributes are not used by w2k3 */ - "schemaFlagsEx", - "msDs-IntId", - "msDs-Schema-Extensions", - "classDisplayName", - "isDefunct"); - - -attrib_attrs = new Array("objectClass", - "attributeID", - "attributeSyntax", - "isSingleValued", - "rangeLower", - "rangeUpper", - "mAPIID", - "linkID", - "showInAdvancedViewOnly", - "adminDisplayName", - "oMObjectClass", - "adminDescription", - "oMSyntax", - "searchFlags", - "extendedCharsAllowed", - "lDAPDisplayName", - "schemaIDGUID", - "attributeSecurityGUID", - "systemOnly", - "systemFlags", - "isMemberOfPartialAttributeSet", - - /* this attributes are not used by w2k3 */ - "schemaFlagsEx", - "msDs-IntId", - "msDs-Schema-Extensions", - "classDisplayName", - "isEphemeral", - "isDefunct"); - -/* - notes: - - objectClassCategory - 1: structural - 2: abstract - 3: auxiliary -*/ - - -/* - print only if verbose is set -*/ -function dprintf() { - if (verbose != undefined) { - print(vsprintf(arguments)); - } -} - -function get_object_cn(ldb, name) { - var attrs = new Array("cn"); - - var res = ldb.search(sprintf("(ldapDisplayName=%s)", name), rootDse.schemaNamingContext, ldb.SCOPE_SUBTREE, attrs); - assert(res != undefined); - assert(res.msgs.length == 1); - - var cn = res.msgs[0]["cn"]; - assert(cn != undefined); - if (typeof(cn) == "string") { - return cn; - } - return cn[0]; -} -/* - create an objectclass object -*/ -function obj_objectClass(ldb, name) { - var o = new Object(); - o.name = name; - o.cn = get_object_cn(ldb, name); - return o; -} - -/* - create an attribute object -*/ -function obj_attribute(ldb, name) { - var o = new Object(); - o.name = name; - o.cn = get_object_cn(ldb, name); - return o; -} - - -syntaxmap = new Object(); - -syntaxmap['2.5.5.1'] = '1.3.6.1.4.1.1466.115.121.1.12'; -syntaxmap['2.5.5.2'] = '1.3.6.1.4.1.1466.115.121.1.38'; -syntaxmap['2.5.5.3'] = '1.2.840.113556.1.4.1362'; -syntaxmap['2.5.5.4'] = '1.2.840.113556.1.4.905'; -syntaxmap['2.5.5.5'] = '1.3.6.1.4.1.1466.115.121.1.26'; -syntaxmap['2.5.5.6'] = '1.3.6.1.4.1.1466.115.121.1.36'; -syntaxmap['2.5.5.7'] = '1.2.840.113556.1.4.903'; -syntaxmap['2.5.5.8'] = '1.3.6.1.4.1.1466.115.121.1.7'; -syntaxmap['2.5.5.9'] = '1.3.6.1.4.1.1466.115.121.1.27'; -syntaxmap['2.5.5.10'] = '1.3.6.1.4.1.1466.115.121.1.40'; -syntaxmap['2.5.5.11'] = '1.3.6.1.4.1.1466.115.121.1.24'; -syntaxmap['2.5.5.12'] = '1.3.6.1.4.1.1466.115.121.1.15'; -syntaxmap['2.5.5.13'] = '1.3.6.1.4.1.1466.115.121.1.43'; -syntaxmap['2.5.5.14'] = '1.2.840.113556.1.4.904'; -syntaxmap['2.5.5.15'] = '1.2.840.113556.1.4.907'; -syntaxmap['2.5.5.16'] = '1.2.840.113556.1.4.906'; -syntaxmap['2.5.5.17'] = '1.3.6.1.4.1.1466.115.121.1.40'; - -/* - map some attribute syntaxes from some apparently MS specific - syntaxes to the standard syntaxes -*/ -function map_attribute_syntax(s) { - if (syntaxmap[s] != undefined) { - return syntaxmap[s]; - } - return s; -} - - -/* - fix a string DN to use ${SCHEMADN} -*/ -function fix_dn(dn) { - var s = strstr(dn, rootDse.schemaNamingContext); - if (s == NULL) { - return dn; - } - return substr(dn, 0, strlen(dn) - strlen(s)) + "${SCHEMADN}"; -} - -/* - dump an object as ldif -*/ -function write_ldif_one(o, attrs) { - var i; - printf("dn: CN=%s,${SCHEMADN}\n", o.cn); - for (i=0;i 2005 - (C) Martin Kuehl 2006 - Published under the GNU GPL - Sponsored by Google Summer of Code - */ - -var sys; -var options = GetOptions(ARGV, "POPT_AUTOHELP", "POPT_COMMON_SAMBA"); -if (options == undefined) { - println("Failed to parse options"); - return -1; -} - -libinclude("base.js"); - -if (options.ARGV.length != 2) { - println("Usage: samba3sam.js "); - return -1; -} - -var prefix = options.ARGV[0]; -var datadir = options.ARGV[1]; - -function setup_data(obj, ldif) -{ - assert(ldif != undefined); - ldif = substitute_var(ldif, obj); - assert(ldif != undefined); - var ok = obj.db.add(ldif); - assert(ok.error == 0); -} - -function setup_modules(ldb, s3, s4, ldif) -{ - assert(ldif != undefined); - ldif = substitute_var(ldif, s4); - assert(ldif != undefined); - var ok = ldb.add(ldif); - assert(ok.error == 0); - - var ldif = " -dn: @MAP=samba3sam -@FROM: " + s4.BASEDN + " -@TO: sambaDomainName=TESTS," + s3.BASEDN + " - -dn: @MODULES -@LIST: rootdse,paged_results,server_sort,extended_dn,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,partition - -dn: @PARTITION -partition: " + s4.BASEDN + ":" + s4.url + " -partition: " + s3.BASEDN + ":" + s3.url + " -replicateEntries: @SUBCLASSES -replicateEntries: @ATTRIBUTES -replicateEntries: @INDEXLIST -"; - var ok = ldb.add(ldif); - assert(ok.error == 0); -} - -function test_s3sam_search(ldb) -{ - println("Looking up by non-mapped attribute"); - var msg = ldb.search("(cn=Administrator)"); - assert(msg.error == 0); - assert(msg.msgs.length == 1); - assert(msg.msgs[0].cn == "Administrator"); - - println("Looking up by mapped attribute"); - var msg = ldb.search("(name=Backup Operators)"); - assert(msg.error == 0); - assert(msg.msgs.length == 1); - assert(msg.msgs[0].name == "Backup Operators"); - - println("Looking up by old name of renamed attribute"); - var msg = ldb.search("(displayName=Backup Operators)"); - assert(msg.msgs.length == 0); - - println("Looking up mapped entry containing SID"); - var msg = ldb.search("(cn=Replicator)"); - assert(msg.error == 0); - assert(msg.msgs.length == 1); - println(msg.msgs[0].dn); - assert(msg.msgs[0].dn == "cn=Replicator,ou=Groups,dc=vernstok,dc=nl"); - assert(msg.msgs[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552"); - - println("Checking mapping of objectClass"); - var oc = msg.msgs[0].objectClass; - assert(oc != undefined); - for (var i in oc) { - assert(oc[i] == "posixGroup" || oc[i] == "group"); - } - - println("Looking up by objectClass"); - var msg = ldb.search("(|(objectClass=user)(cn=Administrator))"); - assert(msg.error == 0); - assert(msg.msgs.length == 2); - for (var i = 0; i < msg.msgs.length; i++) { - assert((msg.msgs[i].dn == "unixName=Administrator,ou=Users,dc=vernstok,dc=nl") || - (msg.msgs[i].dn == "unixName=nobody,ou=Users,dc=vernstok,dc=nl")); - } -} - -function test_s3sam_modify(ldb, s3) -{ - var msg, ok; - println("Adding a record that will be fallbacked"); - ok = ldb.add(" -dn: cn=Foo -foo: bar -blah: Blie -cn: Foo -showInAdvancedViewOnly: TRUE -"); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - - println("Checking for existence of record (local)"); - /* TODO: This record must be searched in the local database, which is currently only supported for base searches - * msg = ldb.search("(cn=Foo)", new Array('foo','blah','cn','showInAdvancedViewOnly')); - * TODO: Actually, this version should work as well but doesn't... - * - */ - var attrs = new Array('foo','blah','cn','showInAdvancedViewOnly'); - msg = ldb.search("(cn=Foo)", "cn=Foo", ldb.LDB_SCOPE_BASE, attrs); - assert(msg.error == 0); - assert(msg.msgs.length == 1); - assert(msg.msgs[0].showInAdvancedViewOnly == "TRUE"); - assert(msg.msgs[0].foo == "bar"); - assert(msg.msgs[0].blah == "Blie"); - - println("Adding record that will be mapped"); - ok = ldb.add(" -dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl -objectClass: user -unixName: bin -sambaUnicodePwd: geheim -cn: Niemand -"); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - assert(ok.error == 0); - - println("Checking for existence of record (remote)"); - msg = ldb.search("(unixName=bin)", new Array('unixName','cn','dn', 'sambaUnicodePwd')); - assert(msg.error == 0); - assert(msg.msgs.length == 1); - assert(msg.msgs[0].cn == "Niemand"); - assert(msg.msgs[0].sambaUnicodePwd == "geheim"); - - println("Checking for existence of record (local && remote)"); - msg = ldb.search("(&(unixName=bin)(sambaUnicodePwd=geheim))", new Array('unixName','cn','dn', 'sambaUnicodePwd')); - assert(msg.error == 0); - assert(msg.msgs.length == 1); // TODO: should check with more records - assert(msg.msgs[0].cn == "Niemand"); - assert(msg.msgs[0].unixName == "bin"); - assert(msg.msgs[0].sambaUnicodePwd == "geheim"); - - println("Checking for existence of record (local || remote)"); - msg = ldb.search("(|(unixName=bin)(sambaUnicodePwd=geheim))", new Array('unixName','cn','dn', 'sambaUnicodePwd')); - println("got " + msg.msgs.length + " replies"); - assert(msg.error == 0); - assert(msg.msgs.length == 1); // TODO: should check with more records - assert(msg.msgs[0].cn == "Niemand"); - assert(msg.msgs[0].unixName == "bin" || msg.msgs[0].sambaUnicodePwd == "geheim"); - - println("Checking for data in destination database"); - msg = s3.db.search("(cn=Niemand)"); - assert(msg.error == 0); - assert(msg.msgs.length >= 1); - assert(msg.msgs[0].sambaSID == "S-1-5-21-4231626423-2410014848-2360679739-2001"); - assert(msg.msgs[0].displayName == "Niemand"); - - println("Adding attribute..."); - ok = ldb.modify(" -dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl -changetype: modify -add: description -description: Blah -"); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - assert(ok.error == 0); - - println("Checking whether changes are still there..."); - msg = ldb.search("(cn=Niemand)"); - assert(msg.error == 0); - assert(msg.msgs.length >= 1); - assert(msg.msgs[0].cn == "Niemand"); - assert(msg.msgs[0].description == "Blah"); - - println("Modifying attribute..."); - ok = ldb.modify(" -dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl -changetype: modify -replace: description -description: Blie -"); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - assert(ok.error == 0); - - println("Checking whether changes are still there..."); - msg = ldb.search("(cn=Niemand)"); - assert(msg.error == 0); - assert(msg.msgs.length >= 1); - assert(msg.msgs[0].description == "Blie"); - - println("Deleting attribute..."); - ok = ldb.modify(" -dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl -changetype: modify -delete: description -"); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - assert(ok.error == 0); - - println("Checking whether changes are no longer there..."); - msg = ldb.search("(cn=Niemand)"); - assert(msg.error == 0); - assert(msg.msgs.length >= 1); - assert(msg.msgs[0].description == undefined); - - println("Renaming record..."); - ok = ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", "cn=Niemand2,cn=Users,dc=vernstok,dc=nl"); - assert(ok.error == 0); - - println("Checking whether DN has changed..."); - msg = ldb.search("(cn=Niemand2)"); - assert(msg.error == 0); - assert(msg.msgs.length == 1); - assert(msg.msgs[0].dn == "cn=Niemand2,cn=Users,dc=vernstok,dc=nl"); - - println("Deleting record..."); - ok = ldb.del("cn=Niemand2,cn=Users,dc=vernstok,dc=nl"); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - - println("Checking whether record is gone..."); - msg = ldb.search("(cn=Niemand2)"); - assert(msg.error == 0); - assert(msg.msgs.length == 0); -} - -function test_map_search(ldb, s3, s4) -{ - println("Running search tests on mapped data"); - var res; - var dn; - var attrs; - - - var ldif = " -dn: " + "sambaDomainName=TESTS," + s3.BASEDN + " -objectclass: sambaDomain -objectclass: top -sambaSID: S-1-5-21-4231626423-2410014848-2360679739 -sambaNextRid: 2000 -sambaDomainName: TESTS" - ldif = substitute_var(ldif, s3); - assert(ldif != undefined); - var ok = s3.db.add(ldif); - assert(ok.error == 0); - - printf("Add a set of split records"); - var ldif = " -dn: " + s4.dn("cn=X") + " -objectClass: user -cn: X -codePage: x -revision: x -dnsHostName: x -nextRid: y -lastLogon: x -description: x -objectSid: S-1-5-21-4231626423-2410014848-2360679739-552 -primaryGroupID: 1-5-21-4231626423-2410014848-2360679739-512 - -dn: " + s4.dn("cn=Y") + " -objectClass: top -cn: Y -codePage: x -revision: x -dnsHostName: y -nextRid: y -lastLogon: y -description: x - -dn: " + s4.dn("cn=Z") + " -objectClass: top -cn: Z -codePage: x -revision: y -dnsHostName: z -nextRid: y -lastLogon: z -description: y -"; - - ldif = substitute_var(ldif, s4); - assert(ldif != undefined); - var ok = ldb.add(ldif); - if (ok.error != 0) { - println(ok.errstr); - assert(ok.error == 0); - } - - println("Add a set of remote records"); - - var ldif = " -dn: " + s3.dn("cn=A") + " -objectClass: posixAccount -cn: A -sambaNextRid: x -sambaBadPasswordCount: x -sambaLogonTime: x -description: x -sambaSID: S-1-5-21-4231626423-2410014848-2360679739-552 -sambaPrimaryGroupSID: S-1-5-21-4231626423-2410014848-2360679739-512 - -dn: " + s3.dn("cn=B") + " -objectClass: top -cn:B -sambaNextRid: x -sambaBadPasswordCount: x -sambaLogonTime: y -description: x - -dn: " + s3.dn("cn=C") + " -objectClass: top -cn: C -sambaNextRid: x -sambaBadPasswordCount: y -sambaLogonTime: z -description: y -"; - ldif = substitute_var(ldif, s3); - assert(ldif != undefined); - var ok = s3.db.add(ldif); - assert(ok.error == 0); - - println("Testing search by DN"); - - /* Search remote record by local DN */ - dn = s4.dn("cn=A"); - attrs = new Array("dnsHostName", "lastLogon"); - res = ldb.search("", dn, ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - assert(res.msgs[0].dn == dn); - assert(res.msgs[0].dnsHostName == undefined); - assert(res.msgs[0].lastLogon == "x"); - - /* Search remote record by remote DN */ - dn = s3.dn("cn=A"); - attrs = new Array("dnsHostName", "lastLogon", "sambaLogonTime"); - res = s3.db.search("", dn, ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - assert(res.msgs[0].dn == dn); - assert(res.msgs[0].dnsHostName == undefined); - assert(res.msgs[0].lastLogon == undefined); - assert(res.msgs[0].sambaLogonTime == "x"); - - /* Search split record by local DN */ - dn = s4.dn("cn=X"); - attrs = new Array("dnsHostName", "lastLogon"); - res = ldb.search("", dn, ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - assert(res.msgs[0].dn == dn); - assert(res.msgs[0].dnsHostName == "x"); - assert(res.msgs[0].lastLogon == "x"); - - /* Search split record by remote DN */ - dn = s3.dn("cn=X"); - attrs = new Array("dnsHostName", "lastLogon", "sambaLogonTime"); - res = s3.db.search("", dn, ldb.SCOPE_BASE, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - assert(res.msgs[0].dn == dn); - assert(res.msgs[0].dnsHostName == undefined); - assert(res.msgs[0].lastLogon == undefined); - assert(res.msgs[0].sambaLogonTime == "x"); - - println("Testing search by attribute"); - - /* Search by ignored attribute */ - attrs = new Array("dnsHostName", "lastLogon"); - res = ldb.search("(revision=x)", NULL, ldb. SCOPE_DEFAULT, attrs); - assert(res.error == 0); - assert(res.msgs.length == 2); - assert(res.msgs[0].dn == s4.dn("cn=Y")); - assert(res.msgs[0].dnsHostName == "y"); - assert(res.msgs[0].lastLogon == "y"); - assert(res.msgs[1].dn == s4.dn("cn=X")); - assert(res.msgs[1].dnsHostName == "x"); - assert(res.msgs[1].lastLogon == "x"); - - /* Search by kept attribute */ - attrs = new Array("dnsHostName", "lastLogon"); - res = ldb.search("(description=y)", NULL, ldb. SCOPE_DEFAULT, attrs); - assert(res.error == 0); - assert(res.msgs.length == 2); - assert(res.msgs[0].dn == s4.dn("cn=Z")); - assert(res.msgs[0].dnsHostName == "z"); - assert(res.msgs[0].lastLogon == "z"); - assert(res.msgs[1].dn == s4.dn("cn=C")); - assert(res.msgs[1].dnsHostName == undefined); - assert(res.msgs[1].lastLogon == "z"); - - /* Search by renamed attribute */ - attrs = new Array("dnsHostName", "lastLogon"); - res = ldb.search("(badPwdCount=x)", NULL, ldb. SCOPE_DEFAULT, attrs); - assert(res.error == 0); - assert(res.msgs.length == 2); - assert(res.msgs[0].dn == s4.dn("cn=B")); - assert(res.msgs[0].dnsHostName == undefined); - assert(res.msgs[0].lastLogon == "y"); - assert(res.msgs[1].dn == s4.dn("cn=A")); - assert(res.msgs[1].dnsHostName == undefined); - assert(res.msgs[1].lastLogon == "x"); - - /* Search by converted attribute */ - attrs = new Array("dnsHostName", "lastLogon", "objectSid"); - /* TODO: - Using the SID directly in the parse tree leads to conversion - errors, letting the search fail with no results. - res = ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-552)", NULL, ldb. SCOPE_DEFAULT, attrs); - */ - res = ldb.search("(objectSid=*)", NULL, ldb. SCOPE_DEFAULT, attrs); - assert(res.error == 0); - assert(res.msgs.length == 3); - assert(res.msgs[0].dn == s4.dn("cn=X")); - assert(res.msgs[0].dnsHostName == "x"); - assert(res.msgs[0].lastLogon == "x"); - assert(res.msgs[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552"); - assert(res.msgs[1].dn == s4.dn("cn=A")); - assert(res.msgs[1].dnsHostName == undefined); - assert(res.msgs[1].lastLogon == "x"); - assert(res.msgs[1].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552"); - - /* Search by generated attribute */ - /* In most cases, this even works when the mapping is missing - * a `convert_operator' by enumerating the remote db. */ - attrs = new Array("dnsHostName", "lastLogon", "primaryGroupID"); - res = ldb.search("(primaryGroupID=512)", NULL, ldb. SCOPE_DEFAULT, attrs); - assert(res.error == 0); - assert(res.msgs.length == 1); - assert(res.msgs[0].dn == s4.dn("cn=A")); - assert(res.msgs[0].dnsHostName == undefined); - assert(res.msgs[0].lastLogon == "x"); - assert(res.msgs[0].primaryGroupID == "512"); - - /* TODO: There should actually be two results, A and X. The - * primaryGroupID of X seems to get corrupted somewhere, and the - * objectSid isn't available during the generation of remote (!) data, - * which can be observed with the following search. Also note that Xs - * objectSid seems to be fine in the previous search for objectSid... */ - /* - res = ldb.search("(primaryGroupID=*)", NULL, ldb. SCOPE_DEFAULT, attrs); - println(res.msgs.length + " results found"); - for (i=0;i